Michal’s tips: Application Interface Framework (AIF) 2.0 – PO/PI’s message ID from IDOC’s adapter in AIF log
When IDOC messages are coming to SAP backend system via AIF just like shown in my previous article: Michal’s tips: Application Interface Framework (AIF) – IDOC processing with AIF actions sometimes we may need to investigate if the mapping in PO/PI was correct but it turnes out there’s no easy in AIF to link PO/PI’s message ID with AIF message. In case this would required in your system you can do that however in the way shown below. PO/PI’s message ID is always stored in control record of the IDOC in the arckey field in such a format (this is the format for java IDOC adapter and not for ABAP based IDOC adapter):
1. Sender language:
Length: 1
Offset: 17
2. Receiver language:
Length: 1
Offset: 18
3. XI Message Id:
Length: 32
Offset: 20
Format: uppercase, without hyphen
4. Original IDoc number:
Length: 16
Offset: 54
If we want to display it in the AIF message log we can use standard helped class /AIF/UTIL_ADD_MSG to populate the return table (bapiret2) of any of our AIF actions and display there the message ID.
If we need to get the control record we can do that using the function /AIF/IDOC_CONVERT_SAP_STRUCT
or you can do get it from the raw structure itself as per my article: Michal’s tips: Application Interface Framework (AIF) – IDOC processing with AIF actions
For the purpose of the exercise I will show how to map the raw structure to the IDOC structures again and put in the message ID in the AIF log.
Code listing |
---|
*convert the RAW IDOC data to IDOC data again CALL FUNCTION ‘/AIF/IDOC_CONVERT_SAP_STRUCT’ EXPORTING SAP_STRUCT = LR_REF IV_TYPENAME = ‘ZAIFFLIGHTBOOKING_CANCEL01’ IMPORTING ES_EDIDC = LS_IDOC_CONTRL ET_EDIDD = LT_IDOC_DATA . *use helper class to put the data to the log an return in the return_tab structure CALL FUNCTION ‘/AIF/UTIL_ADD_MSG’ EXPORTING MSGTY = ‘I’ MSGID = ‘/AIF/MES’ MSGNO = ‘000’ MSGV1 = ‘PI/PO message_ID is’ MSGV2 = LS_IDOC_CONTRL-arckey+20(40) MSGV3 = ‘ idea by Michal Krawczyk’ TABLES RETURN_TAB = RETURN_TAB . IF SY-SUBRC <> 0. * Implement suitable error handling here ENDIF. |
Now when you run the scenario via AIF you should be able to see the PO/PI’s message ID in the AIF log as shown on the Figure below.