This article illustrates the complete file to inbound Proxy interface development in detail. In addition, we will look at how to generate Proxy class in SAP back-end and implement ABAP logic. File to Proxy interface scenario is illustrated using an SAP exchange rate creation asynchronous interface. Exchange rates included in the XML file are sent to SAP via a Proxy message. Once exchange rates are received in SAP, TCURR table will be updated from BAPI.
Inbound Proxy Scenario Overview:
Let’s assume we have an sFTP file system that sends exchange rates in XML format. Exchange rates in XML file should be extracted, transformed and sent to target SAP system via SAP PI/PO.
Information is sent to SAP system as a Proxy message and exchange rates should be updated in SAP table TCURR (Exchange Rates). However, we will use BAPI ‘BAPI_EXCHANGERATE_CREATE’ to update the exchange rates table TCURR as it’s the preferred best practice.
Mapping logic between the XML file sender message and target proxy message is as follows.
Proxy Target Element
XML Source Element
Convert MM-dd-yyyy to yyyy-MM-dd
Functionality of the Proxy Class:
ABAP Proxy class update the SAP exchange rates table TCURR using ‘BAPI_EXCHANGERATE_CREATE‘. In addition, proxy ABAP logic assigns the exchange rate values from the proxy message to the BAPI input parameter.
BAPI accepts the exchange rates through importing parameter EXCH_RATE. ABAP logic assigns the exchange rates in the proxy message to EXCH_RATE parameter of the BAPI_EXCHANGERATE_CREATE.
File to Proxy Interface Development Steps:
Configure Proxy connectivity between SAP PI/PO and SAP back-end system.
Create sender XML Data Type and Message Type.
Create receiver Proxy Data Type and Message Type.
Define Outbound file Service Interface and Inbound Proxy Service Interface.
Implement Message Mapping between XML and Proxy message.
Generate Proxy class in SAP back-end using transaction SPROXY.
Create sFTP sender Communication Channel and Proxy (SOAP) receiver Channel.
Finally, configure iFlow using Eclipse NWDS.
Step 1 – Configure Proxy Connectivity Between SAP PI/PO and SAP Back-end System:
You will find information on SLD setup, RFC destination configuration, HTTP Destination configuration, Integration Engine (SXMB_ADM) settings, and Proxy Communication Channel configuration in my previous post. Therefore, I will not elaborate on the steps in this example.
Step 2 – Create Sender XML Data Type and Message Type:
Next step is to create the exchange rate sender Data Type and Message Type in Enterprise Service Repository (ESR). You can either create the Message Type as an External Definition by importing the XSD or by creating a Data Type which reflects the XML data structure.
In this illustration, I have created a Data Type and Message Type to represent the exchange rate sender XML message format.
Sender Data Type:
Sender Message Type:
Step 3 – Create Receiver Proxy Data Type and Message Type:
The function of the Proxy is to update exchange rates in SAP using the Function Module BAPI_EXCHANGERATE_CREATE. Therefore, we will create the target Proxy Message Type to closely reflect the import parameters of the BAPI.
To update the exchanges rates we need to assign values from Proxy message to input parameter EXCH_RATE of the BAPI. Create the receiver Message Type similar to the structure of EXCH_RATE Data Type. In other words, Data Type should be similar to DDIC structure BAPI1093_0.
Designing the Message Type like this allows us to easily move data from the proxy message to the BAPI using MOVE-CORRESPONDING ABAP statement.
Receiver Data Type:
Receiver Message Type:
Step 4 – Define Outbound file Service Interface and Inbound Proxy Service Interface:
Create an Outbound Service interface for XML file sender and an Inbound Service Interface to represent the Proxy message. As we have only one operation, let’s use Interface Pattern Stateless (XI30 Compatible) for both interfaces.
Outbound Asynchronous Service Interface:
Inbound Asynchronous Proxy Interface:
Step 5 – Implement the Message Mapping between the XML file and the Proxy message:
Next, define the Message Mapping and the Operation mapping.
Operation and Message Mapping:
Create the Message Mapping from the XML file Message Type to the Proxy Message Type. Most importantly, apart from the date conversion between sender message ‘ValidFromDate’ element and receiver message ‘VALID_FROM’ element, all the other fields are mapped one-to-one or mapped with constant values.
Date Transformation using DateTrans Function:
XML contains the date in format MM-DD-YYYY, and it should be converted to SAP Proxy date format YYYY-MM-DD. SAP accepts the date in YYYYMMDD conversion. Sender date format should be converted in the Mapping program.
Standard PI mapping function DateTrans allows us to convert date formats.
Step 6 – Generate Proxy Class in SAP Back-end Using Transaction SPROXY:
Now we need to generate Proxy Consumer class in SAP back-end system.
Go to transaction SPROXY in target SAP system (SADCLNT900) and find the Proxy Service Interface from the ESR navigation tree.
Next, right-click on the Service Interface and click Generate. Proxy generation wizard will guide you through the proxy class creation.
In the next screen of the wizard, you will be prompted to assign a Package, Prefix and Transport request for the new Proxy class. Fill in the required information in the wizard, save and activate the Proxy class.
Successfully generated and activated Proxy Service Interface (Proxy ABAP class) will be visible in SPROXY transaction with a green mark as below.
Using Proxy Services external view tab, we can check the Proxy Inbound data type. Notice, this correlates to the Receiver Message Type we created in Step 3. Message Types and Data Types we created in ESR are automatically generated as DDIC structures in SAP when the Proxy class is created using SPROXY transaction.
In this example, the Proxy Implementing Class name is ZCL_EXCHANGE_RATES_INB_ASYNC. It has one method, which is ZII_EXCHANGE_RATES_INB_ASYNC~EXCHANGE_RATES_INB_ASYNC. ABAP logic to execute the exchange rate creation BAPI should be implemented here.
Implement ABAP logic to Update Exchange Rates in SAP:
Finally, implement ABAP logic in Proxy class to update the exchange rates in SAP. ABAP logic reads the incoming proxy message (parameter INPUT) and assigns the values to import parameter EXCH_RATE of FM BAPI_EXCHANGERATE_CREATE.
Double-click on the Implementing Proxy class in transaction SPROXY and it will take you to the method EXCHANGE_RATES_INB_ASYNC in which you need to implement ABAP code. Or you can implement ABAP code via transaction se24.
Next, implement ABAP program logic in Proxy class which updates exchange rates in SAP.