This is the second part of a detailed comparison of the order creation process using APIs and IDocs. The first part focused on partner mappings. In this part, I will examine the mapping of external material numbers to internal ones. My objective is to compare the features supported by the API with those available for IDocs, identify new opportunities, and highlight deviations that require attention. The purpose of this analysis is to evaluate whether the selected API can effectively replace IDoc-based processing. For this, I will focus on the logic that aligns closely with classical IDocs. While the API may offer extended functionality, such cases are beyond the scope of this article.
As mentioned in one of my previous posts, the appropriate API for inbound order creation is ORDERREQUEST_IN: Sales Order/Customer Return - Create, Update, Cancel (B2B). This API is compared with the IDoc ORDERS processing, which uses process code ORDE and function module IDOC_INPUT_ORDERS.
The B2B API supports most of the IDoc logic in the described areas while introducing several useful new features:
This topic can be divided into two parts: business logic and technical implementation. In my previous article about IDoc processing for Material Determination for Inbound Orders, I shared my thoughts on business logic, including X12 and EDIFACT examples, approaches relevant for "contracts" and "catalogues", and key challenges from a business perspective. Naturally, these challenges and ideas also apply to API processing. For more details, please refer to that article.
This article focuses on the technical aspect—specifically, how material determination logic works for APIs in comparison to IDocs.
For illustration, I will use the same test cases as those used for IDocs. Generally, customers use the following options as input data:
Material number mapping
The ORDERREQUEST_IN API request structure provides transparent fields for these options, as well as for unit of measure (UoM) information:
<OrderItem>
<PurchaseOrderItemID>10</PurchaseOrderItemID>
<OrderItemText>Customer Order item text</OrderItemText>
<RequestedQuantity unitCode="PCE">10.0</RequestedQuantity>
<Product>
<GlobalTradeItemNumber>8427324815219</GlobalTradeItemNumber>
<SupplierProductID>1521</SupplierProductID>
<BuyerProductID>ACME-1521</BuyerProductID>
</Product>
</OrderItem>
Processing logic is described in the program code. The MAP_PRODUCT method in the CL_EDI_SD_ORDR_MAPPING class outlines the logic as follows:
* Material determination logic:
* Priority 1: Supplier Product ID (material_no)
* Priority 2: EAN code (international_article_no)
* Priority 3: Buyer Product ID (customer_material_no)
*
* If EAN does not match material -> error in GOAL
* If EAN does not match customer material -> ignore customer material
* If material does not match customer material -> ignore customer material
T-code SE80, MAP_PRODUCT method:
Material Mapping Logic in the ABAP method MAP_PRODUCT
From this description, it is clear that this logic differs from IDoc material determination in at least two ways: the sequence of priorities and the additional EAN/GTIN control.
Another noteworthy feature is the use of EAN/GTIN data directly from the material master record during the determination process. This capability, long desired by users, is now available out of the box!
When the SAP standard function module IDOC_INPUT_ORDERS is used to process inbound orders, the material determination sequence is as follows:
Vendor Material Number (Qualf = 002):
CMIR (Qualf = 001):
EAN (Qualf = 003):
For API processing, the material determination sequence is:
Vendor Material Number (<SupplierProductID>):
EAN/GTIN (<GlobalTradeItemNumber>):
CMIR (<BuyerProductID>):
Sequence Differences:
Interdependency:
Data Source for EAN/GTIN Determination:
Vendor Material:
CMIR Determination:
If only CMIR and Vendor Material are used for determination, the API and IDoc logic function identically. However, if EAN is included in the material determination process, the master data and determination logic must be carefully reviewed and adjusted.
Unit of Measure (UoM) determination is a critical feature for certain industries. I previously elaborated on this topic in the context of EDI and IDocs in the article UoM Determination for Inbound Orders.
The API follows a similar approach but includes some important adjustments:
Mapping of UoM:
EAN-Based UoM Validation:
Default UoM Logic:
From my perspective, UoM determination based on EAN is a valuable enhancement introduced with the API. However, its effectiveness relies heavily on the quality of both the customer's and supplier's master data.
Let’s review test cases to illustrate both successful processing scenarios and potential errors.
In the message snippet below, all three external identifiers are provided:
<OrderItem>
<PurchaseOrderItemID>10</PurchaseOrderItemID>
<OrderItemText>Customer Order item text</OrderItemText>
<RequestedQuantity unitCode="PCE">10.0</RequestedQuantity>
<Product>
<GlobalTradeItemNumber>8427324815219</GlobalTradeItemNumber>
<SupplierProductID>1521</SupplierProductID>
<BuyerProductID>ACME-1521-0000</BuyerProductID>
</Product>
In this case, Vendor Material 1521 must be recognized either as an SAP material or through the material substitution technique, and the EAN 8427324815219 must correspond to the determined material. While the CMIR ACME-1521-0000 is not used for material determination, it is recorded as the customer material number in the relevant sales order item.
Below is the complete request structure for this test case:
<n0:OrderRequest xmlns:n0="http://sap.com/xi/EDI">
<MessageHeader>
<ID>Message_Header_ID</ID>
<CreationDateTime>2020-04-10T02:53:20Z</CreationDateTime>
<SenderParty>
<InternalID>246</InternalID>
</SenderParty>
</MessageHeader>
<Order>
<PurchaseOrderID>B2B_API_test_23122024-1</PurchaseOrderID>
<PurchaseOrderCreationDate>2024-12-23</PurchaseOrderCreationDate>
<Party PartyType="SoldTo">
<BuyerPartyID>ACME-0211</BuyerPartyID>
<GlobalLocationNumber>7089900000016</GlobalLocationNumber>
</Party>
<Party PartyType="ShipTo">
<BuyerPartyID>ACME-0212</BuyerPartyID>
<GlobalLocationNumber>7089900000023</GlobalLocationNumber>
</Party>
<Party PartyType="Supplier">
<BuyerPartyID>WHOLESALER_ASA</BuyerPartyID>
<GlobalLocationNumber>7088800010002</GlobalLocationNumber>
</Party>
<Text Type="SalesNote">
<TextElementLanguage>EN</TextElementLanguage>
<TextElementText>Header note 1 by API</TextElementText>
</Text>
<OrderItem>
<PurchaseOrderItemID>10</PurchaseOrderItemID>
<OrderItemText>Customer Order item text</OrderItemText>
<RequestedQuantity unitCode="PCE">10.0</RequestedQuantity>
<Product>
<GlobalTradeItemNumber>8427324815219</GlobalTradeItemNumber>
<SupplierProductID>1521</SupplierProductID>
<BuyerProductID>ACME-1521-0000</BuyerProductID>
</Product>
<ExpectedNetPrice>
<Amount currencyCode="NOK">11</Amount>
<BaseQuantity unitCode="PCE">1</BaseQuantity>
</ExpectedNetPrice>
<ExpectedNetAmount currencyCode="NOK">110</ExpectedNetAmount>
<Text Type="MaterialText">
<TextElementLanguage>EN</TextElementLanguage>
<TextElementText>Material text by API</TextElementText>
</Text>
</OrderItem>
</Order>
</n0:OrderRequest>
The Sales Order created by this request :
Sales order 1576
Material Master Validation: The EAN in the message (8427324815219) matches the EAN in the material's master record (t-code MM03) for the specified unit of measure (PC).
Material master: EAN details
In this scenario, the Supplier Product Number (X1521) provided cannot be recognized by the system:
<Product>
<GlobalTradeItemNumber>8427324815219</GlobalTradeItemNumber>
<SupplierProductID>X1521</SupplierProductID>
<BuyerProductID>ACME-1521-0000</BuyerProductID>
</Product>
Error message: EAN/UPC 8427324815219 is incompatible with material X1521 and unit PC
The actual reason for the error is that the Supplier Product Number (X1521) was not recognized as a valid SAP material or substitution. However, since an EAN (8427324815219) was provided in the message, the system performed an additional validation to check the EAN's compatibility with the material and unit of measure (PC). The error description reflects the result of this EAN check, even though the primary issue lies with the unrecognized material.
Below is the complete error response:
<n0:StandardMessageFault xmlns:n0="http://sap.com/xi/SAPGlobal/Global" xmlns:prx="urn:sap.com:proxy:SW1:/1SAI/TAS86C5ECFCD060648BFE9A:757">
<standard>
<faultText> Execution failed; see further messages for details</faultText>
<faultDetail>
<severity>error</severity>
<text>EAN/UPC 8427324815219 is incompatible with material X1521 and unit PC</text>
<id>084(SLS_LORD)</id>
</faultDetail>
<faultDetail>
<severity>information</severity>
<text>Check route for Ship-to party 0000000212 in document header</text>
<id>008(VPD)</id>
</faultDetail>
<faultDetail>
<severity>information</severity>
<text>Taxes have been re-determined</text>
<id>217(V1)</id>
</faultDetail>
</standard>
</n0:StandardMessageFault>
In this scenario, the EAN provided (8427324815202) cannot be recognized by the system:
<Product>
<GlobalTradeItemNumber>8427324815202</GlobalTradeItemNumber>
<SupplierProductID>1521</SupplierProductID>
<BuyerProductID>ACME-1521-0000</BuyerProductID>
</Product>
Error Message: No material exists for EAN/UPC 8427324815202
Since an EAN (8427324815202) was included in the message, the system attempted to validate it against the material master. The error occurred because this EAN could not be found or matched to a valid SAP material.
This example highlights a potential risk when using EAN as additional data. Even though the Vendor Material (1521) is correct and could be processed successfully, the inclusion of an invalid or unrecognized EAN causes the entire message to fail.
In this scenario, the EAN provided (8427324815219) does not match the unit of measure (UoM) specified in the message:
<RequestedQuantity unitCode="PAK">10.0</RequestedQuantity>
<Product>
<GlobalTradeItemNumber>8427324815219</GlobalTradeItemNumber>
<SupplierProductID>1521</SupplierProductID>
<BuyerProductID>ACME-1521-0000</BuyerProductID>
</Product>
Error Message: EAN/UPC 8427324815219 is incompatible with material 1521 and unit PAC
Since an EAN (8427324815219) was provided, the system recognized it as relevant for Material 1521 and the UoM PC (Piece). However, the UoM specified in the message item was PAK, which was mapped to PAC during processing using the CUNI-related technique. This mismatch triggered the error.
In this scenario, the Supplier Product Number (X1521) provided cannot be recognized by the system and the EAN wasn't provided.
<Product>
<SupplierProductID>X1521</SupplierProductID>
<BuyerProductID>ACME-1521-0000</BuyerProductID>
</Product>
Error Message: Material X1521 is not defined for sales org.1000, distr.chan.10, language EN
In this scenario, the Unit of Measure (XXX) provided cannot be recognized by the system and the EAN wasn't provided.
<RequestedQuantity unitCode="XXX">10.0</RequestedQuantity>
<Product>
<SupplierProductID>1521</SupplierProductID>
<BuyerProductID>ACME-1521-0000</BuyerProductID>
</Product>
Error Message: Sales unit XXX is not defined for item 000010
When using an EAN, both the material and unit of measure (UoM) can be determined. In this test case, the EAN 8427324815226 is recognized by the system as uniquely relevant to Material 1521 and the UoM PAC.
Below is the complete request structure for this test case:
<n0:OrderRequest xmlns:n0="http://sap.com/xi/EDI">
<MessageHeader>
<ID>Message_Header_ID</ID>
<CreationDateTime>2020-04-10T02:53:20Z</CreationDateTime>
<SenderParty>
<InternalID>246</InternalID>
</SenderParty>
</MessageHeader>
<Order>
<PurchaseOrderID>B2B_API_test_23122024-3</PurchaseOrderID>
<PurchaseOrderCreationDate>2024-12-23</PurchaseOrderCreationDate>
<Party PartyType="SoldTo">
<BuyerPartyID>ACME-0211</BuyerPartyID>
<GlobalLocationNumber>7089900000016</GlobalLocationNumber>
</Party>
<Party PartyType="ShipTo">
<BuyerPartyID>ACME-0212</BuyerPartyID>
<GlobalLocationNumber>7089900000023</GlobalLocationNumber>
</Party>
<Party PartyType="Supplier">
<BuyerPartyID>WHOLESALER_ASA</BuyerPartyID>
<GlobalLocationNumber>7088800010002</GlobalLocationNumber>
</Party>
<OrderItem>
<PurchaseOrderItemID>10</PurchaseOrderItemID>
<OrderItemText>Customer Order item text</OrderItemText>
<RequestedQuantity>10.0</RequestedQuantity>
<Product>
<GlobalTradeItemNumber>8427324815226</GlobalTradeItemNumber>
</Product>
</OrderItem>
</Order>
</n0:OrderRequest>
Material Master data: The EAN in the message (8427324815226) is relevant for material 1521 and UoM PAC.
Material master: EAN details
The Sales Order created from this request successfully uses the UoM PAC, determined automatically based on the provided EAN.
Sales order 1577
In this case EAN was clearly spoiled and couldn't be recognized:
<Product>
<GlobalTradeItemNumber>X8427324815226</GlobalTradeItemNumber>
</Product>
Error Message: No material exists for EAN/UPC X8427324815226
In this case, the EAN provided for material determination (8427324815219) is assigned to multiple materials in the system.
<Product>
<GlobalTradeItemNumber>8427324815219</GlobalTradeItemNumber>
</Product>
MEAN table: EAN 8427324815219 is associated with two SAP materials: 1521 and 2591.
MEAN for 8427324815219
Error Message:More than one material exists for EAN/UPC 8427324815219
Notice: if a correct CMIR record was provided also, a material could be determined, as shown below.
If material determination succeeds using an EAN, the CMIR is ignored. In this test case, the EAN 8427324815202 is recognized by the system as uniquely relevant to Material 2591 with the UoM PAC.
Request example:
<RequestedQuantity unitCode="PAK">10.0</RequestedQuantity>
<Product>
<GlobalTradeItemNumber>8427324815202</GlobalTradeItemNumber>
<BuyerProductID>ACME-1521</BuyerProductID>
</Product>
The EAN 8427324815202 is associated in the master data with Material 2591 and the UoM PAC.
8427324815202
While the CMIR value ACME-1521 is valid for SAP Material 1521 (t-code VD52), it was not used during material determination because the EAN was sufficient to uniquely identify the material.
CMIR for ACME
Sales order 1578 was created with material 2591. Despite being ignored for material determination, the CMIR ACME-1521 was recorded as the Customer Material Number in the sales order item.
Sales Order 1578
As previously shown, the EAN 8427324815219 is assigned to multiple materials in the system. However, if the message also contains a relevant CMIR, the material can be uniquely recognized.
<RequestedQuantity>10.0</RequestedQuantity>
<Product>
<GlobalTradeItemNumber>8427324815219</GlobalTradeItemNumber>
<BuyerProductID>ACME-1521</BuyerProductID>
</Product>
MEAN table: the EAN 8427324815219 is associated with two SAP materials: 1521 and 2591.
MEAN for 8427324815219
The CMIR value ACME-1521 is valid for SAP Material 1521 (t-code VD52). CMIR for ACME
By combining the EAN and the CMIR value, the system was able to identify Material 1521 as the correct material.
Sales Order 1579
CMIR records helps if it matches a material determined by EAN. Otherwise determination fails as if CMIR wasn't provided. In the example below CMIR in the message is relevant to SAP material 1531, while EAN 8427324815219 is relevant for 1521 and 2591.
<RequestedQuantity>10.0</RequestedQuantity>
<Product>
<GlobalTradeItemNumber>8427324815219</GlobalTradeItemNumber>
<BuyerProductID>ACME-1531</BuyerProductID>
</Product>
As result error appears. Error Message:More than one material exists for EAN/UPC 8427324815219
A correct CMIR is enough for material determination.
<RequestedQuantity unitCode="PCE">10.0</RequestedQuantity>
<Product>
<BuyerProductID>ACME-1521</BuyerProductID>
</Product>
The CMIR value ACME-1521 is valid for SAP Material 1521 (t-code VD52). CMIR for ACME
Sales order 1580 created:
Sales Order 1580
In this case, CMIR ACME-1521-0000 is not recognized in the system.
<RequestedQuantity unitCode="PCE">10.0</RequestedQuantity>
<Product>
<BuyerProductID>ACME-1521-0000</BuyerProductID>
</Product>
Since the CMIR value ACME-1521-0000 cannot be determined, the system does not assign an SAP material number. Instead of generating an error, the system creates a text item (item category TATX). Such item doesn't contain SAP material number and quantity. Sales order with TATX item
This approach avoids a processing error and delegates the issue to customer service for manual resolution.
Note: This case is another difference between IDoc and API logic:
Thanks to my colleagues at Capgemini and others who explored this topic with me across numerous projects. Also, thanks to Capgemini for providing me with a sandbox system, which I used for investigations, creating test examples, and preparing screenshots. The sandbox was SAP S/4HANA 2022 (S/4HANA On-Premise Release 2022 SP 01, February 2023 FPS).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 12 | |
| 6 | |
| 6 | |
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 |