Implementing Synchronous Inbound Proxy interface in AIF – Step-by-Step guide
- 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 🙂
Thanks for the detailed Steps!!
I was trying to replicate the scenario but limitation I see is that you need to build structure containing request and response segment manually (even the deep structure elements). You can't copy Proxy generated data structure.
We have services built using GDT which got complex structure. Generating SAP structure for that manually is very difficult.
Secondly, if you see , response mapping is done in code itself. So only value addition AIF is doing is calling the action.
Any shortcut to eliminate these limitations ?
Thanks & Regards,
I see your screenshot no 3 where you used proxy generated structure to build your SAP structure. How you were able to do that ?
When I'm trying that I get error message saying that you can't use Proxy generated structure while creating custom structure.
Thanks & Regards,
Dear Dijesh, I usually use self-created structures, not generated.
If someone is still stuck here in 2022... you can use type... boxed instead of just 'type' if you have a proxy generated structure. This worked for me and the error does not show up. I have no idea why it works, though.
There's a webinar recording on YouTube where you and D.Lebedev are making intro presentation on AIF.
But there are problems with sound in the clip - it disappears pretty often when you are explaining something. E.g. https://www.youtube.com/watch?v=FT7TSCaNoew&feature=player_detailpage#t=1655 (listen for 10-20 seconds).
Can you fix this with reuploading the clip? Or this is how it was recorder during the webinar?
Dear Petr, this video was uploaded by our marketing, I think you shold try to write to an author on YouTube.
Was trying the easier way. Commenting on YouTube requires Google account. Pity.