- You have Inbound synchronous ABAP-Proxy
- You would like to implement AIF Interface for your Proxy.
- You have a developer key
As example, we will use simple inbound interface for bank data:
First, we have to create RAW structure for our interface. I create RAW structure ZAIF_BANK_SAP_N in se11:
We shouldn’t define SAP structure because this is our generated Proxy structure.
Now, go to /n/AIF/CUST_IF transaction and create an interface BANK_IN (you should use your predefined namespace):
Hint: when you enter Proxy class name and press enter, Raw Data Structure and Record Type In Raw Structure will filled automatically.
Then we have to define an action…
…and a function module for this action:
Note, that we should enter Associated Type name for parameter CURR_LINE:
Then we have to implement our FM. If you would like to insert some data from your SAP structure, you should use curr_line-request structure. To send your response (ext_id in our case) to proxy response, we have to put it to curr_line-response structure.
I just fill curr_line-response-ext_id with value ‘0001’ :
Save and activate FM.
Then, we have to define Structure Mapping. Click New Entries and add IMPORT_PARAM as source structure:
Choose our source structure, click “Assign Destination Structure” and assign LINES as destination structure:
Save and click Define Field Mappings. You have to define field mappings as on the picture:
Then define created above Action as described and save.
I will not describe configuration steps like creating and assigning recipients, you can find it in other docs about AIF.
As the last step, we have to implement our Proxy class ZCL_BANK_IN with code like this:
DATA: lt_return TYPE bapiret2_tab.
lv_message_id TYPE sxmsmguid,
ls_sap_data TYPE ZAIF_BANK_SAP_N,
ls_input TYPE ZMT_BANK.
ls_input = input.
cl_proxy_access=>get_inbound_message_key( “getting message key
message_id = lv_message_id ).
call FUNCTION ‘/AIF/FILE_PROCESS_DATA’ “call FM to create an AIF message
ns = ‘MD’
ifname = ‘BANK_IN’
ifversion = ‘1’
transform_data = ‘X’
ximsgguid = lv_message_id
xi_flag = ‘X’
return_tab = lt_return
data = ls_sap_data
raw_struct = ls_input-mt_bank “pass record type
not_found = 1
customizing_incomplete = 2
max_errors_reached = 3
cancel = 4
err_log = 5
OTHERS = 6.
output-MT_BANK_RESP-ext_id = ls_sap_data-lines-response-EXT_ID. “assign the ext_id to proxy response
So, lets try to test our interface using proxy test:
Yoo-hoo! We get back an answer to our proxy 🙂 Now, go to /n/AIF/ERR, select our interface, click “Today” in Generic Selection and Select All in Status Selection and Execute:
Note, that you will not see a payload of your message when it sent from test tool in sproxy. To see a payload, you need two things:
1) Turn on logging for synchronous messages in tcode sxmb_adm: Integration Engine Configuration —> Category: RUNTIME —> add new parameter LOGGING_SYNC with value “1”.
2) Send message from your PI/PO system.
Hope this blog was helpful 🙂
p.s. Special thanks to George Gita 🙂