Purchase Order to Sales Order Creation in a 2-Tier Scenario
In a related blog, we have considered sales processes in a 2-tier model and seen how SAP S/4HANA Cloud can support the organization and subsidiaries to run in an independent yet integrated fashion. The “Sell from stock at a subsidiary with drop shipment from headquarters” scenario was highlighted in which the subsidiary acts as a mere sales office with sales presence, whereas the delivery of the material is the responsibility of the HQ.
In this blog, we will cover one of the integration points which is “sending purchase order from the subsidiary which gets converted into a sales order at the headquarter”. Here, the Purchase Order created at subsidiary (which is on S/4 HANA Cloud) gets converted to Sales Order at headquarters (which is on SAP On-Premise or ECC).
The main steps in the scenario:
- Purchase Orders created in SAP S/4 HANA Cloud system are read via API.
- Map these Purchase Orders to Sales Order IDOC (SALESORDER_CREATEFROMDAT202/SALESORDER_CREATEFROMDAT2)
- The IDOCs are sent to On-Premise system (Cloud Connector configuration is done)
- The IDOCs are read and converted to Sales Orders in On-Premise system
We will see the configuration required for each of these steps in detail.
Configuration in SAP S/4 HANA Cloud:
For the SAP S/4 HANA Cloud system to communicate with outside system, Communication Arrangement needs to be set up. The relationship between Communication Arrangement, Scenario, System and User is shown below.
- Create a Communication User in SAP S/4 HANA Cloud system. This user credential will be used in Purchase Order API read in SAP HANA Cloud Platform Integration tenant.
- Maintain a Communication System to specify the host details.
- Maintain a Communication Arrangement to facilitate the read of API. The Communication Scenario used for Purchase Order read is SAP_COM_0053.
Fig 1: Communication Arrangement
Configuration in SAP On-Premise ECC:
The incoming IDOC (SALESORDER_CREATEFROMDAT202/ SALESORDER_CREATEFROMDAT2) needs to be processed and converted to a Sales Order. We need to maintain the following configurations.
- Maintain the Partner Profile details. The partner type maintained is Logical system (LS) (WE20). The Message Type is SALESORDER_CREATEFROMDAT2 and Process Code is BAPI.
- Ensure the relevant BAPI-ALE interfaces are maintained so that the IDOC is processed. Using transaction WE42, check if the entry for Process Code “BAPI” is present. If not, enter the following data.
- Ensure that the function module is assigned to the IDOC processing. Using transaction BDBG, check if the function module is already assigned. If the function module is not assigned, assign it as shown below.
Creation of SAP Cloud Integration iFlow:
This is what the iFLow would look like:
The iFlow is scheduled to run at regular intervals. It reads all the Purchase Orders from S/4 HANA Cloud system which are created after the last processed PO. These are mapped to Sales Order IDOC and sent to On-Premise via Cloud Connector. We will have a look at the configuration of main components below.
- The ODATA API call needs be configured as shown below. The Address can be obtained from Communication arrangement (see Fig. 1). In case authentication is chosen as basic, the Credential name should contain the Communication User credentials of S/4 HANA Cloud system.
- The next important component in iFlow is the mapping between EDMX file of ODATA service and Sales Order IDOC. The source and target needs to be given for mapping. The easiest way to obtain an XSD file from message type SALESORDER_CREATEFROMDAT2 is:
WE60->Documentation->XML Schema (Basic type: SALESORDER_CREATEFROMDAT202). An XSD file is created which needs to be given as Target input for mapping.
To get the Source mapping, the following needs to be done.
- Download the EDMX file for Purchase Order processing from API hub. If only the header data needs to be mapped, this file can be directly used as Source mapping. However, in this scenario we need the Item level (relationship data) as well. So, we cannot use this EDMX file directly.
- The EDMX file needs to be used in Eclipse to create an XSD file which contains Purchase Order Header as well as Items data. In Eclipse tool, choose the Adapter type as ODATA. Use the downloaded EDMX file to model your Query. At the end, an XSD file is generated which can be used as Source mapping. For more details on how to do it, please refer here.
- Do the relevant mapping between Purchase Order XSD and Sales Order IDOC. The mapping is done in a way to facilitate processing of multiple Purchase Orders.
- The last important component is the IDOC communication to SAP On-Premise system. Maintain the configuration as shown below.
Save and deploy the iFlow. The iFlow will get triggered based on the interval of scheduling. The success/failure of the iFlow can be monitored in “Monitor Message Processing” window in SAP HCI tenant.
Configuration in Cloud Connector:
Since we are passing data to On-Premise system, we would need SAP Cloud Connector. For more details on how to set it up, please go through the official documentation here.
- A video of the business scenario depicting this use case can be found here.
- For more information on 2-tier use cases, please refer the blog here.
Would you like to access Full Article?
If you are already a member in this website, Please Click here to loginIf you are not yet a member, Please Click here to Sign up
New NetWeaver Information at SAP.com