ABAP Programming Interface (PI) 
The exchange of IDocs between the ABAP function modules
The SAP System is the "external system" in which further processing can be programmed as required. Thus, you can for example program your own techniques for transfer to an external system.
You only have to enter the name of the function module to be called (for IDoc outbound processing) or the calling function module (for IDoc inbound processing). This function module can be programmed to contain the required processing. Only the interface is already defined.
SAP supplies the function module OWN_FUNCTION as a template, which reads the IDoc data and writes a status record for each IDoc (status 18 for no errors, 20 for error). If an error occurs, a workflow is started.
Your function module must call the SAP function module IDOC_INBOUND_ASYNCHRONOUS, which saves the IDocs in the database and triggers an event. As a result, inbound processing is started asynchronously.