First of all please dont post duplicate threads for same query its against the rules.
Seconldy this function module MASTERIDOC_CREATE_SMD_HRMD is used to for sending IDOCS which internally calls RH_MASTER_IDOC_DISTRIBUTE_HRMD to send IDOCs
You can cross check by putting break point in these FM. Inside it BADI HRALE00OUTBOUND_IDOC is called. You can creat implementation of it and use method IDOC_DATA_FOR_RECEIVER_MODIFY to fill your custom segments OR Imlement customer exit EXIT_SAPLRHA0_001 to handle your validations and add custom segment(Easy solution)
Nabheet