on 08-29-2013 4:42 AM
Hi All
We have multiple instance of SAP systems where all messages are routed through AIF. We want to built a central logging table where we can provide overview of message flow across all systems. In this central log table we need a field where we can provide a content based search based on object type for example Purchase Order No. Can anybody help in this regard how can we read standard AIF log tables to retrieve message details including the payload fields for example MATNR etc. The idea is to retrieve this log including status and push into our central log table.
Assuming you created a custom index table with the couple of addutional keyfields like MATRN you can use the following code to retrieve the information.
PS custom index table
Copy /AIF/STD_IDX_TB
Add keyfields before .include /AIF/ADMIN
/aif/cust -> Error handling -> define namespace specific features and define index table
/aif/cust -> Error handling -> Interface specific -> Define keyfields and link your fields to your index table key fields
DATA:
lv_namespace TYPE /aif/ns,
lv_ifname TYPE /aif/ifname,
lv_ifversion TYPE /aif/ifversion,
lv_idx_tab_name TYPE /aif/msg_tbl,
lv_aif_status TYPE /aif/proc_status,
lv_wait_times TYPE i.
FIELD-SYMBOLS:
<ls_idx_entry> TYPE ANY,
<lv_status> TYPE /aif/proc_status.
* Get current interface information
CALL FUNCTION '/AIF/FILE_GET_
IMPORTING
ns = lv_namespace
ifname = lv_ifname
ifversion = lv_ifversion.
* Retrieve AIF Index table
SELECT SINGLE msg_tbl INTO lv_idx_tab_name
FROM /aif/t_inf_tbl
WHERE ns EQ lv_namespace
AND ifname EQ lv_ifname
AND ifver EQ lv_ifversion.
IF sy-subrc NE 0 OR lv_idx_tab_name IS INITIAL.
lv_idx_tab_name = '/AIF/STD_IDX_TBL'.
ENDIF.
* Assume that aif is potentially still processing when reading the index table
CLEAR lv_aif_status.
CLEAR lv_wait_times.
lv_aif_status = 'I'.
lv_wait_times = 0.
* Only exit loop if status is not in process
WHILE lv_aif_status EQ 'I'.
TRY.
CREATE DATA lr_idx_entry TYPE (lv_idx_tab_name).
ASSIGN lr_idx_entry->* TO <ls_idx_entry>.
SELECT SINGLE * INTO <ls_idx_entry> FROM (lv_idx_tab_name) WHERE msgguid EQ lv_messageid.
IF sy-subrc NE 0.
ls_textid-msgid = '/AIF/ENGINE_IDX_TAB'.
ls_textid-msgno = '002'.
ls_textid-attr1 = lv_messageid.
ls_textid-attr2 = lv_idx_tab_name.
RAISE EXCEPTION TYPE /aif/cx_error_handling_general EXPORTING textid = ls_textid.
RAISE index_table_error.
ENDIF.
CATCH cx_sy_create_data_error.
ls_textid-msgid = '/AIF/ENGINE_IDX_TAB'.
ls_textid-msgno = '001'.
ls_textid-attr1 = lv_idx_tab_name.
RAISE EXCEPTION TYPE /aif/cx_error_handling_general EXPORTING textid = ls_textid.
RAISE index_table_error.
ENDTRY.
ASSIGN COMPONENT 'STATUS' OF STRUCTURE <ls_idx_entry> TO <lv_status>.
ASSERT sy-subrc IS INITIAL.
lv_aif_status = <lv_status>.
IF lv_aif_status EQ 'I'.
WAIT UP TO 1 SECONDS.
lv_wait_times = lv_wait_times + 1.
ENDIF.
IF lv_wait_times GE 10.
* Return error pr exit to avoif infinite loop
ENDIF.
ENDWHILE.
*Use ASSIGN COMPONENT 'XXX' OF STRUCTURE <ls_idx_entry> TO <lv_xxxx> to fetch info from index table
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marc
Many thanks for the detailed answer.
We want to retrieve the AIF MSG status and keyfield value for each interface where we have defined key fields.
Can you please provide more detail where exactly we can use this code to get both the status of all types messages (IDOC or Proxy inbound or outbound). Probably in action but during AIF processing message can fail anywhere e.g. value mapping , action , etc.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.