Outbound IDocs process using the SAP Application Interface Framework
For this scenario, the following are required:
- 2 SAP Application Interface Framework interfaces
- A port functions.
- An action
- To trigger the processing in the SAP Application Interface Framework
- To send the final IDoc to the receiver
Let’s take the example of the Material Master outbound standard IDOC (MATMAS), where we need to modify a field segment when transferring data from the source side to the receiver system.
As per pre-requisite, we have to create two Outbound Interfaces in AIF under namespace and define Interface engine. To create the required structure and interfaces, use the Generate IDoc Structure and Interface Definition report (transaction code /AIF/IDOC_GEN, see IDoc Structure Generation and Interface Definition). The raw and SAP data structure are identical for both interfaces.
AIF Interface 1 : I_MATMAS7O ( IDOC data send from Source SAP to AIF )
Let’s define Interface engine for above interface
Now, Let’s create similar Interface 2 : I_MATMAS7. Here IDOC data send from AIF to Target Receiver. We can use same SAP and Raw data structure.
Next step will be Validate/assign IDOC Type in AIF. Path : SAP Application Interface Framework->Interface Development->Additional Interface Properties->Assign IDoc Types.
Please note you can define additional logical system for AIF and use in Partner profile config. Since I’m using same Partner number ( WE20 ), I will use message variant for IDOC distinguish. We will see while configuring partner profile for IDOCs.
Moreover, As both interfaces have the same message type/basic type , we need define entry in Interface determination.
Path : SAP Application Interface Framework under . Here we will use IDOC Control record Receiver Port ( RCVPOR ) field for determination and assign respective port value to interfaces.
Next Step ,
The SAP Application Interface Framework delivers the /AIF/SINGLE_IDOC_PORT_FUNCTION function module. In Ports in IDoc processing (transaction code WE21), you need to maintain the port function in an ABAP-PI port. You must assign this port in the partner profile (WE20 ).
WE21 : Port Config.
WE20 : Partner Profile Setting
Port AIF_O_PORT = Send IDOC to AIF
Port A00000058 = Send IDOC to Target system
In the scenario for processing IDocs shown in the graphic above, the first IDoc is send to the AIF port function and is processed via the SAP Application Interface Framework. All mappings, checks, fix values, and value mappings must be done in the first interface, which is used for the processing of the first IDoc. To finally send the IDoc to the receiver, an action is required to trigger the sending of the IDoc.
Assign Function module to Action :
Action FM ABAP Code : The Customizing for the first interface contains the processing logic of the IDoc. You must maintain some mapping for the first interface. In order to be able to send the second IDoc to the correct receiver, you need to adjust the sender/receiver data of the EDIDC structure (Control Record) to the values of the final sender/receiver of the IDoc.
Please make sure, If you do not do this, the IDoc ends in a loop of creating one copy after another without sending the IDoc to the final receiver.
Assign Action to Interface 1 .
- Execute DRFOUT or (BD10/BD21) to generate MATMAS IDOC.
- After execution, it generates two IDOCs.
- IDOC 0000000004762048 : Send Data to AIF
- IDOC 0000000004761668 : Data to Target Receiver
Send Original IDOC 0000000004762048 data content to AIF.
Send IDOC 0000000004761668 to Target Receiver with data content modification.
We can check same in /AIF/ERR as well.
- Interface : I_MATMAS71 : For the second interface, a pure monitoring scenario is sufficient. The interface is used to monitor the IDocs that are sent to the final receiver.