Have a look at the picture above. What if, this huge jam was a result of a failing interface to or from the warehouse. Whether the root cause of the error is in communication, mapping, or anything else, you could quickly find out using the interface monitors, like the ones provided by SAP PI or SAP AIF. But on the other hand, from those monitors you would not see the implication that these errors have on the company’s business processes. Yes, in this case probably looking out the window would be enough? But, it is not always that obvious.
Recently, during my last AIF project, we encountered a challenge and we wondered if it is possible to save the payload of the response message for the outbound synchronous proxy interface in SAP AIF. We found a solution, but since that time many of our colleagues working with SAP AIF encountered the same challenge and that was the reason why we decided to write this blog with our proposed solution. This blog is written in cooperation with my colleague, Krzysztof Łuka.
Imagine the situation when you have to configure the outbound synchronous proxy interface in SAP AIF and you have to save the content of the request and the response messages. If it comes to the content of the request message – there is no problem. You may encounter a challenge if you want to save also the response of the synchronous message.
In this blog we will focus only on the SAP AIF part – we won’t describe how to create objects on SAP PO side. We will use the ABAP report to send the request message with the message ID from ERP system to SAP PO. We expect to receive back in the synchronous response the SAP PO message key that is related to the message ID we sent in the request.
This is how sample synchronous request message looks like (with the message ID):
And below you can see the synchronous response message with message key from the above request:
First, you have to generate and activate Service Consumer that will be used in order to send the request from ERP to SAP PO.
Then you have to copy the name of the class for the generated Service Consumer. In our case, it is /INT4/CO_SI_O_GET_MESSAGE_LIST.
This class is necessary in order to create SAP AIF interface.
In next step go to AIF Customization ( /AIF/CUST transaction ) and go to Interface Development -> Define Interfaces. We will have to create new entries: one interface for the request message and the second interface for the response message.
First, create a new entry for the request message. Type OPRGMSG001 as the interface name and 1 as the interface version.
Then Provide your Service Consumer class (in our case it’s /INT4/CO_SI_O_GET_MESSAGE_LIST ) in the class Proxy Class Outbound field and choose the proper method that will trigger sending a message to PO.
Once you provide proxy class outbound – automatically RAW Data Structure and Record Type in Raw Structure should be filled. Please provide the same structure in SAP Data Structure as was filled into RAW Data Structure and mark Move Corresponding Structures checkbox, as it is visible on the screen below:
As a next step, we have to create another entry in Define Interface node. This time we have to do it for the Response Message.
Add a new entry with Interface Name: IPRGMSG001, interface version: 1. In Proxy Class Inbound provide the class of your Service Consumer. In our case, it is /INT4/CO_SI_O_GET_MESSAGE_LIST. Then click enter and again your Raw Data Structure should be filled automatically. Right now we are interested in the response message and because of this, we have to provide the type of the structure that is used as the exporting parameter of our class for the service consumer. In our case it is /INT4/MT_GET_MSG_LIST_RES as it’s visible on the screen below:
Use the same structure in SAP and RAW structure and mark Move Corresponding checkbox. Please also make sure, that you have chosen specific proxy method as shown on the screen below:
Right now we have to make sure, that proper Engine is used for both of our interfaces. Go to AIF Customization (transaction /AIF/CUST ). Then open Interface Development -> Additional Interface Properties -> Specify Interface Engines node and set for both interfaces Proxy as Application Engine, XML as Persistence Engine, AIF Index Tables as Selection Engine and AIF Application Log as Logging Engine.
The last step is to create ABAP Report, that will trigger sending the message from ERP to SAP PO.
Create a new program in transaction SE38.
In order to make this program simpler – we will hardcode the message ID that will be sent to SAP PO. We are using function module /AIF/SEND_WITH_PROXY to send the data out from ERP. We have to provide a namespace, interface name and interface version of our interface we created in AIF. In this step, you have to provide an interface used for the request message ( ‘OPRGMSG001’).
In the RESP_SAP_STRUCT changing parameter we have to provide a structure of the response, that we used in the IPRMSG001 SAP AIF interface. Then in the SAP_STRUCT changing parameter, we have to provide filled with the data structure for the request interface.
In the end, we have to use method /AIF/IF_PERSISTENCY_ENGINE~UPDATE of class /aif/cl_persist_engine_xml in order to store the response payload in SAP AIF. While using this method we have to provide details of the second interface in SAP AIF, that will store the response message.
Please see the whole code snippet for this program below:
<em> lc_ns TYPE /aif/ns VALUE 'ZDEMO',</em>
<em> lc_ifname TYPE /aif/ifname VALUE 'OPRGMSG001',</em>
<em> lc_ifver TYPE /aif/ifversion VALUE '1',</em>
<em> lc_ns_resp TYPE /aif/ns VALUE 'ZDEMO',</em>
<em> lc_ifname_resp TYPE /aif/ifname VALUE '1PRGMSG001',</em>
<em> lc_ifver_resp TYPE /aif/ifversion VALUE '1'.</em>
<em> lv_msguid TYPE sxmsmguid,</em>
<em> lv_error_msg TYPE string,</em>
<em> ls_request TYPE /int4/mt_get_msg_list_req,</em>
<em> ls_sap_resp TYPE /int4/mt_get_msg_list_res,</em>
<em> ls_xi_data TYPE /aif/xmlparse_data,</em>
<em> lt_bapiret TYPE TABLE OF bapiret2,</em>
<em> lo_data TYPE REF TO data,</em>
<em> lo_xml_pers TYPE REF TO /aif/cl_persist_engine_xml.</em>
<em>ls_request-mt_get_msg_list_req-message_id = 'fd9b26f7-7456-11e8-a1b1-00000069c71a'.</em>
<em>ls_request-mt_get_msg_list_req-archive = ' '.</em>
<em>IF ls_request-mt_get_msg_list_req-message_id IS NOT INITIAL.</em>
<em> CALL FUNCTION '/AIF/SEND_WITH_PROXY'</em>
<em> ns = lc_ns</em>
<em> ifname = lc_ifname</em>
<em> ifversion = lc_ifver</em>
<em> appl_log_function = 'AIF_SEND_WITH_PROXY'</em>
<em> do_commit = 'X'</em>
<em> iv_persist_xml = 'X'</em>
<em> ximsgguid = lv_msguid</em>
<em> add_return_tab = lt_bapiret</em>
<em> resp_sap_struct = ls_sap_resp</em>
<em> sap_struct = ls_request</em>
<em> error_string = lv_error_msg</em>
<em> persistency_error = 1</em>
<em> status_update_failed = 2</em>
<em> missing_keys = 3</em>
<em> interface_not_found = 4</em>
<em> transformation_error = 5</em>
<em> general_error = 6</em>
<em> OTHERS = 7.</em>
<em>"Persist response message</em>
<em>GET REFERENCE OF ls_sap_resp INTO ls_xi_data-xi_data.</em>
<em>ls_xi_data-msgguid = lv_msguid.</em>
<em>ls_xi_data-ns = lc_ns_resp.</em>
<em>ls_xi_data-ifname = lc_ifname_resp.</em>
<em>ls_xi_data-ifver = lc_ifver_resp.</em>
<em>CREATE OBJECT lo_xml_pers.</em>
<em>IF lo_xml_pers IS NOT INITIAL.</em>
<em> GET REFERENCE OF ls_xi_data INTO lo_data.</em>
<em> CALL METHOD lo_xml_pers->/aif/if_persistency_engine~update</em>
<em> cr_xmlparse = lo_data.</em>
<em> CATCH /aif/cx_error_handling_general .</em>
Right now we can run the report. If the proxy call was successful we should see a new entry in transaction /AIF/ERR with the payload in the outbound interface OPRGMSG001 with the request message and new entry in with the payload of the response message in interface IPRGMSG001.
Below you can see the request message with the content. Message text automatically contains the information in which interface the response was processed:
In order to make sure that the response is visible we’ll go to the second interface for the response message. As you can see on the screenshot below – response message with the payload is there:
How do you like this approach to save the message payload? Please let us know in the comments!
PS. I have a big pleasure to invite you on SAP Teched at Barcelona that will take place in October. As the INT4 team we will be one of the exhibitors and we will be presenting our SAP certified automated regression testing and service interface virtualization software – IFTT.
If you want to learn more about this tool or if you want to ask me or Michal Krawczyk SAP AIF or SAP PO related question we will be available for you at our booth everyday from 13:00-14:00 everyday! See you there!
I can bet, that if you use SAP AIF you are familiar with AIF Monitoring and Error Handling (transaction /AIF/ERR ). Here, we can monitor and perform actions for specific interface. In addition to this transaction SAP AIF also gives us opportunity to monitor all interfaces in one place. In this blog we are going to set up interface in SAP AIF Interface Monitor (AIF/IFMON transaction). Let’s imagine the situation, that you are responsible for monitoring several interfaces. Monitoring interfaces in /AIF/ERR transaction is very helpful, although it still can be time consuming if you just want to have a quick overview what is going on in all interfaces you are responsible for.
Nowadays, every single day we have to cope with many different interfaces and technologies. The number of the interfaces that we have to carry on is constantly growing.
When you use SAP AIF (SAP Application Interface Framework) you can monitor all interfaces from one place and that saves a lot of time!
That’s the reason why some of our customers use very ofter SAP AIF only for the monitoring purposes. Today I would like to show you how quickly you can enable monitoring IDoc interfaces in SAP AIF in less than 3 minutes!
Please let us know if you like such short videos!
Hi there! In this blog I will show you can you can use SAP AIF multi index table and single index tables in your interfaces.
This blog is the extension of the previous blog: How To Create a Single Index Table in SAP AIF and therefore some steps will be explained in a more general way. You can always visit the previous blog in case you occur any issues with details, but I believe that you won’t have any problems, as you mastered this knowledge last time reading the previous blog! 🙂
Have you ever heard about single index table in SAP AIF? Have you ever encountered the issue while you were looking for a specific message in Monitoring and Error Handling? Let’s imagine the situation, that you receive tons of inbound messages every single day and you want to find a message with a specific purchase order number in your AIF Interface, but you don’t know what is the AIF message ID that contains this specific Purchase Order number.
Here, single index table in SAP AIF with custom selection screen for the interface come to help us!
Custom functions in SAP AIF (SAP Application Interface Framework) can enhance and speed up your process of monitoring messages and business documents related to the messages.
In this post, I will show you how to quickly create a custom function for inbound sales order interface, that redirects you to Display Sales Order transaction and allows preview of the created Sales Document.
It is possible to create a custom function in two ways: in /AIF/CUST_FUNC transaction and directly in the Monitor and Error Handling.
Almost all integration scenarios require some sort of mapping to be performed. SAP AIF offers a flexible tool called Structure Mapping to handle that. It’s based on general concept of traversing the source structure from the root and drilling down to substructures and their fields. However it has certain limitations. One is that if in the source message at certain same level we have multiple structures, we can’t indicate in what order SAP AIF should process them. To be more specific, they are always mapped in alphabetical sequence.
However there is a certain trick to specify for SAP AIF structures that should be processed ignoring the alphabetical order, at the very beginning. For that we use a mapping between dummy (blank) source and destination structures (marked in the picture below).
In this particular example for DEBMAS IDoc we would like to map fields of EDIDC structure before E1KNA1M and E1KNB1M so they can be used when mapping those two structures. Unfortunately standard processing will map it at the very end. Below is the dummy mapping that we’ll use to address that.
Then in Define Field Mappings we specify any structures we would like to be processed before the rest. In our case this is EDIDC structure.
Don’t forget to provide Sub-Table relevant to the mapped structure. In our case it is EDIDC.
Finally we can define our actual mapping for EDIDC structure (as Indirect Mapping) and for its fields.
As a result of this setting we make SAP AIF process the EDIDC structure at the very begging, before other structures. Now we can be sure that when we process the remaining structures they can use the already mapped fields of EDIDC.
Among SAP integration specialist and clients there is quite often a confusion about usage of tools mentioned in the topic of this article. The main reason for their confusion is the fact, that they don’t know which tool should they use and what is more important how SAP PO and SAP AIF can be combined in order to make your integration scenario more robust. Let’s start from the beginning and let me briefly introduce to you each tool.
SAP Process Orchestration (PO) is an integration platform. It is the middleware between different SAP and non-SAP systems and applications. PO in an easy way allows you to design, model, implement and monitor business processes.
Image 1 Source: https://tinyurl.com/yczgk58g
Thanks to SAP PI/ PO it is possible to:
Application interface Framework (AIF) is more like an integration add-on for your specific business applications. It allows you to implement and monitor an interface and then also handle errors in case of any troubles.
Image 2 Source: https://tinyurl.com/y9psmqls
AIF, as an integration add-on has the following advantages:
As you see both tools share a few features, however, each of them has its specific advantages.
Combination of these two tools allows us to separate business logic from integration logic in your scenarios. This is a general recommendation for all IT landscapes with both business applications and integration platforms. In such scenario, we can put all integration logic to PI and all business logic into AIF.
For example, if you have to cope with different kinds of connectivity protocols like FTP, RFC or SOAP you should handle that in PI. Process Integration is used very often for routing messages between different environments and technical systems. Structure mapping between different message formats can be also handled by SAP PI.
On the other hand, it is good to format, validate data and perform value mappings and put all business logic in SAP AIF. For example, you can easily enrich your data with relevant information retrieved from database tables or use a standard function module to check material availability. Also, the value mapping rules can be accessed and maintained by business users and they can participate in the error handling process.
With AIF it is not possible to connect many legacy systems directly if legacy systems don’t allow to call web services. In such scenarios, we should use PI for connection with different systems and then let AIF perform all business logic.
The general rule is to have PI/PO handle the communication across the landscape with all its and take advantage of AIF to perform the business logic.
I hope, that right now you have the general overview of the purpose of Application Interface Framework and Process Orchestration. In next article, we will go through error handling and mappings in both tools.