In this blog, you will learn how to use the Cloud BAdIs in sales order inbound and outbound EDI processing.
Background
I’m working on the SD-SLS-EDI component for SAP S/4HANA Cloud. Our most important topic is about EDI Integration Between Buyers and Suppliers.
In this blog, I’d like to share some information with our community about BAdIs in sales order/returns order inbound and order confirmation outbound EDI processing on Supplier side. Before we start, please let me give you a brief introduction about the EDI Integration between Buyers and Suppliers separately with inbound and outbound processing.
For EDI inbound processing, once a purchase order is created, changed, or cancelled in buyer side, a corresponding EDI message will be created and transferred to the supplier, and a sales document will be created or changed when the EDI message is received and valid in supplier side.
For EDI outbound processing, once a sales order is created or changed, a corresponding EDI message will be created and transferred to the buyer, and the corresponding purchase order will be updated when the EDI message is received by the buyer side.
For more information about the EDI processing, see inbound and outbound.
Introduction about BAdIs
We have the following BAdIs designed for both inbound and outbound EDI processing in supplier side. They work for both S/4HANA Cloud and S/4HANA (after release 2022 FPS1).
Inbound
- Header Modification for Sales Orders/Returns Orders in Inbound EDI (EDI_SD_ORDER_MODIFY_HEADER)
Enable the modification of order request in EDI message fields SupplierPaymentTermsID, CustomerPurchaseOrderType on header level of sales orders.
- Item Modification for Sales Orders/Returns Orders in Inbound EDI (EDI_SD_ORDER_MODIFY_ITEM)
Enable the modification of order request in EDI message fields SupplierProductID on item level of sales orders.
Enable the exclusion of an item from order request in EDI message for sales order creation and update when ignore indicator for the corresponding item is set to be true.
- Header Partner Modification for Sales Orders/Returns Orders in Inbound EDI (EDI_SD_ORDER_MODIFY_HEAD_PARTY)
Enable the modification of order request in EDI message field Region in the partner address detail information on sales order header level.
- Item Partner Modification for Sales Orders/Returns Orders in Inbound EDI (EDI_SD_ORDER_MODIFY_ITEM_PARTY)
Enable the modification of order request in EDI message field Region in the partner address detail information on sales order item level.
Outbound
- Header Modification for Sales Orders/Returns Orders in Outbound EDI (EDI_SD_ORDER_CONF_OUT_HEADER)
Enable the modification of order confirmation out EDI message fields BuyerSystemID and SupplierSystemID on header level.
- Item Modification for Sales Orders/Returns Orders in Outbound EDI (EDI_SD_ORDER_CONF_OUT_ITEM)
Enable the exclusion of an item in order confirmation out message when ignore indicator for the corresponding item is set to be true.
Filter
All these BAdIs have the same filter COMMUNICATION_SYSTEM_TYPE which allow you to set communication system type as a condition to determine whether the BAdI implementation should be called or not.
The filter uses the following fields to determine whether to call the BAdI implementation:
Inbound: Field SenderBusinessSystemID in inbound EDI message
Outbound: Field Type of communication system (EXT_COMM_SYST_TYPE) from sales order header table VBAK
If you are integrated with the Ariba Network (SAP Business Network), you must define the business system type with value ‘A’ in configuration activity Define Business System Type and set the filter to be ‘01’ in the BAdI implementation. Otherwise, you set the filter to be ‘not equals 01‘.
Create BAdI Implementation
Step1: Create Implementation
Open App Custom Logic, create a new implementation. Enter the technical name of the BAdI, add a filter and enter an implementation description and ID.
Step2: Publish
Step3: Open Code Editor
After published, we can choose Open Code Editor to write custom logic.
Hint: You have to save and publish every time you change the code.
For S/4HANA users, you can create the implementations through TCode SE18/SE19.
Example
For Inbound EDI Processing
The buyer sends an EDI message through Postman:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header> </soapenv:Header>
<soapenv:Body>
<n0:OrderRequest xmlns:n0="http://sap.com/xi/EDI" xmlns:prx="urn:sap.com:proxy:CCF:/1SAI/TAE813A0CAF5E48F72CEACA:790" xmlns:YY1="http://SAPCustomFields.com/YY1_">
<MessageHeader>
<ID>42010AEEC4571EDD83C6F165DE1B48A7</ID>
<CreationDateTime>2022-08-30T05:38:42Z</CreationDateTime>
<SenderBusinessSystemID>0LEU10H</SenderBusinessSystemID>
<SenderParty>
<InternalID>17100001</InternalID>
</SenderParty>
<RecipientParty>
<InternalID>17300081</InternalID>
</RecipientParty>
</MessageHeader>
<Order>
<ActionCode>01</ActionCode>
<PurchaseOrderID>BAdI_test_01</PurchaseOrderID>
<PurchasingDocumentType>NB</PurchasingDocumentType>
<CompanyCode>1710</CompanyCode>
<CompanyCodeName>Company Code 1710</CompanyCodeName>
<PurchasingOrganization>1710</PurchasingOrganization>
<PurchasingOrganizationName>Purch. Org. 1710</PurchasingOrganizationName>
<PurchasingGroup>001</PurchasingGroup>
<PurchasingGroupName>Group 001</PurchasingGroupName>
<PurchaseOrderCreationDate>2022-07-28</PurchaseOrderCreationDate>
<PurchaseOrderLastChangeDate>2022-07-29</PurchaseOrderLastChangeDate>
<TransactionCurrency>USD</TransactionCurrency>
<BuyerCompanyCodeCurrency>USD</BuyerCompanyCodeCurrency>
<BuyerExchangeRate>1</BuyerExchangeRate>
<SDDocumentReason>001</SDDocumentReason>
<Party PartyType="SoldTo">
<BuyerPartyID>1710</BuyerPartyID>
</Party>
<Party PartyType="Supplier">
<BuyerPartyID>17300081</BuyerPartyID>
</Party>
<PaymentTerms>
<BuyerPaymentTermsID>0004</BuyerPaymentTermsID>
</PaymentTerms>
<OrderItem>
<PurchaseOrderItemID>10</PurchaseOrderItemID>
<PurchaseOrderItemCategory>0</PurchaseOrderItemCategory>
<OrderItemText>Trad.Good 11,PD,Reg.Trading</OrderItemText>
<RequestedQuantity unitCode="PCE">1.0</RequestedQuantity>
<ProductType>1</ProductType>
<Product>
<BuyerProductID>TG12</BuyerProductID>
<SupplierProductID>TG12</SupplierProductID>
</Product>
<ExpectedNetPrice>
<Amount currencyCode="USD">10.0</Amount>
<BaseQuantity unitCode="PCE">1.0</BaseQuantity>
</ExpectedNetPrice>
<ExpectedNetAmount currencyCode="USD">10.0</ExpectedNetAmount>
<ScheduleLine>
<PurchaseOrderScheduleLine>0001</PurchaseOrderScheduleLine>
<RequestedDeliveryDate>2022-08-08</RequestedDeliveryDate>
<RequestedDeliveryTimeZone>PST</RequestedDeliveryTimeZone>
<RequestedDeliveryDateTime>2022-08-08T12:00:00-07:00</RequestedDeliveryDateTime>
<ScheduleLineOrderQuantity unitCode="PCE">1.0</ScheduleLineOrderQuantity>
</ScheduleLine>
</OrderItem>
<OrderItem>
<PurchaseOrderItemID>20</PurchaseOrderItemID>
<PurchaseOrderItemCategory>0</PurchaseOrderItemCategory>
<OrderItemText>Trad.Good 11,PD,Reg.Trading</OrderItemText>
<RequestedQuantity unitCode="PCE">1.0</RequestedQuantity>
<ProductType>1</ProductType>
<Product>
<BuyerProductID>TG11</BuyerProductID>
<SupplierProductID>TG11</SupplierProductID>
</Product>
<ExpectedNetPrice>
<Amount currencyCode="USD">10.0</Amount>
<BaseQuantity unitCode="PCE">1.0</BaseQuantity>
</ExpectedNetPrice>
<ExpectedNetAmount currencyCode="USD">10.0</ExpectedNetAmount>
<ScheduleLine>
<PurchaseOrderScheduleLine>0001</PurchaseOrderScheduleLine>
<RequestedDeliveryDate>2022-08-08</RequestedDeliveryDate>
<RequestedDeliveryTimeZone>PST</RequestedDeliveryTimeZone>
<RequestedDeliveryDateTime>2022-08-08T12:00:00-07:00</RequestedDeliveryDateTime>
<ScheduleLineOrderQuantity unitCode="PCE">1.0</ScheduleLineOrderQuantity>
</ScheduleLine>
</OrderItem>
</Order>
</n0:OrderRequest>
</soapenv:Body>
</soapenv:Envelope>
You have created and published the custom logic of header and item modification for inbound EDI processing:
In the Message Dashboard app, you can view the information messages when these fields are changed by your custom logic:
In the corresponding sales order, as you can see, SupplierPaymentTermsID and CustomerPurchaseOrderType have been changed and item #20 not created by the custom logic.
For Outbound EDI Processing
You have created a custom logic of header and item modification for outbound EDI processing.
Then, you create a sales order and trigger order confirmation out.
In the Message Dashboard app, BuyerSystemID and SupplierSystemID on header level have been updated and item #20 excluded by the custom logic in the EDI outbound message.
Related Information
Extensibility: Sales Order/Customer Return – Create, Update, Cancel
Extensibility: Sales Order/Customer Return – Confirm Processing