Skip to Content

Prerequisites:

  • 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:

/wp-content/uploads/2014/04/1_430023.jpeg

First, we have to create RAW structure for our interface. I create RAW structure ZAIF_BANK_SAP_N in se11:

Screenshot 2014-04-10 18.31.jpeg

/wp-content/uploads/2014/04/5_430087.png

Screenshot 2014-04-10 18.32.jpeg/wp-content/uploads/2014/04/4_430086.png

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):

/wp-content/uploads/2014/04/6_430091.jpeg

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…

/wp-content/uploads/2014/04/7_430092.jpeg

…and a function module for this action:

/wp-content/uploads/2014/04/8_430093.jpeg

Note, that we should enter Associated Type name for parameter CURR_LINE:

/wp-content/uploads/2014/04/9_430094.jpeg

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’ :

/wp-content/uploads/2014/04/10_430095.jpeg

Save and activate FM.

Then, we have to define Structure Mapping. Click New Entries and add IMPORT_PARAM as source structure:

/wp-content/uploads/2014/04/11_430096.jpeg

Choose our source structure, click “Assign Destination Structure” and assign LINES as destination structure:

/wp-content/uploads/2014/04/12_430097.jpeg

Save and click Define Field Mappings. You have to define field mappings as on the picture:

/wp-content/uploads/2014/04/13_430098.jpeg

Then define created above Action as described and save.

/wp-content/uploads/2014/04/14_430099.jpeg

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:

method ZII_BANK_IN~BANK_IN.

DATA: lt_return     TYPE bapiret2_tab.

DATA:

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

    IMPORTING

      message_id     = lv_message_id ).

call FUNCTION ‘/AIF/FILE_PROCESS_DATA’       “call FM to create an AIF message

  EXPORTING

      ns = ‘MD’

      ifname = ‘BANK_IN’

      ifversion = ‘1’

      transform_data = ‘X’

ximsgguid              = lv_message_id

      xi_flag = ‘X’

TABLES

      return_tab = lt_return

    CHANGING

      data = ls_sap_data

      raw_struct = ls_input-mt_bank “pass record type

    EXCEPTIONS

      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

endmethod.

So, lets try to test our interface using proxy test:

/wp-content/uploads/2014/04/15_430100.jpeg/wp-content/uploads/2014/04/16_430101.jpeg

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:

/wp-content/uploads/2014/04/17_430102.jpeg

/wp-content/uploads/2014/04/18_430103.jpeg

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 🙂

To report this post you need to login first.

11 Comments

You must be Logged on to comment or reply to a post.

  1. Dijesh Tanna

    Hello Andrey,

     

    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,
    Dijesh Tanna

    (0) 
    1. Dijesh Tanna

      Hello Andrey,

       

      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,
      Dijesh Tanna

      (0) 
  2. Petr Perstnev

    Hi!

     

    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?

     

    Regards,

    Petr Perstnev

    (0) 

Leave a Reply