Hi Ak,
Each inbound IDoc will maintain a process code in partner profile, which bound with a function module, right?
So maybe you can do send outbound IDoc in that FM. And FM 'MASTER_IDOC_DISTRIBUTE’' you can used to send outbound IDoc.
regards,
Archer