Symptom
The OData protocol has changed considerably from V2 to V4. This requires different handling of the respective Purchase Order APIs.
OData V2 API was started in 2016 and was later adjusted to use the RAP technology.
OData V4 API was started in 2021 and was developed on a more mature RAP framework.
You can find all the information on this link: Changes Compared to OData V2 Model
TECHNICAL OBJECTS AS A PREREQUISITE TO USE THE PURCHASE ORDER APIS
Services
· OData API V2 service: API_PURCHASEORDER_PROCESS_SRV
· OData API V4 service: API_PURCHASEORDER
Environment
- SAP S/4HANA Cloud 2308
- SAP S/4HANA Cloud 2402
Resolution
You can see the List of Differences in Gateway Client
Numbers are not in double quotes
Units of measure, Price Order Unit and currency must be given always
The change to the entities doesn't have the "to" as prefix anymore
When we try out the payloads from the old API, we have to read the response thoroughly and investigate the errors.
1- Differences on Payload: Post Item to multiple Schedule lines(post_item_mult_sch)
- Key values to occur in both, URI and payload
- Key value for new schedule line in the payload (count one up from existing schedule line)
- Numbers not to be in double quotes
- Units of Measure and Currency always
- Different association names (without the "to" as prefix)
Description Scenario | OData V2 API | OData V4 API |
POST purchase order with item and schedule line | /sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/A_PurchaseOrder { | /sap/opu/odata4/sap/api_purchaseorder_2/srvd_a2x/sap/purchaseorder/0001/PurchaseOrderItem/1234567890/10/_PurchaseOrderScheduleLineTP { "PurchaseOrder": "1234567890", "PurchaseOrderItem": "10", "ScheduleLine": "2", "ScheduleLineDeliveryDate": "2023-07-31", "PurchaseOrderQuantityUnit": "EA", "Currency": "EUR", "ScheduleLineOrderQuantity": 4 } |
POST new schedule line to existing Item and purchase order | /sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/A_PurchaseOrder {
| /sap/opu/odata4/sap/api_purchaseorder_2/srvd_a2x/sap/purchaseorder/0001/PurchaseOrderItem/1234567890/00010/_PurchaseOrderScheduleLineTP { |
2- Differences on Payload: Post Item to multiple Account Assignments (post_item_mult_acc)
On checking the existed payload and transfer it into new, following differences were found.
Description | Old Payload | New Payload | Differences |
Adding accounts assignments to existed Purchase order | { | Currently, it is not possible to do account assignments to an existed Purchase Order. Create functionality is disabled. The total quantity is on the item entity. As the additional quantity of anew account assignment is not added to the order quantity on item level an error appears. | An error message will prevent the creation of new account assignments: "Sum of Quantities >N> larger than total quantity"
|
Creating new purchase order with new account assignments | { | { | - Numbers are not in double quotes - Units of measure and currency has to be given always - The change to the entities doesn't have the "to" as prefix anymore |
3- Differences in Batch requests: in OData V4 API payload require the Content-ID, see highlighted in yellow below. In OData V2 API, this content ID is not necessary.
URI: /sap/opu/odata4/sap/api_purchaseorder_2/srvd_a2x/sap/purchaseorder/0001/$batch
Payload:
--batch
Content-Type: multipart/mixed; boundary=changeset_1
--changeset_1
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 1
POST PurchaseOrder HTTP/1.1
Content-Type: application/json
{
"CompanyCode" : "1010",
"PurchaseOrderType" : "NB",
"Supplier" : "10300001",
"PurchasingOrganization" : "1010",
"PurchasingGroup" : "001",
"_PurchaseOrderItem" : [
{
"PurchaseOrderItem" : "00010",
"PurchaseOrderItemText" : "Test: 4711 or 08-15",
"Plant" : "1010",
"OrderQuantity" : 7,
"OrderPriceUnit" : "EA",
"NetPriceAmount" : 130.00,
"NetPriceQuantity" : 1,
"PurchaseOrderItemCategory" : "0",
"AccountAssignmentCategory" : "K",
"PurchaseOrderQuantityUnit" : "EA",
"DocumentCurrency" : "EUR",
"Material" : "mat-1",
"PurchasingItemIsFreeOfCharge" : true
}]
}
--changeset_1--
--batch--
4 -OData V4 API has additional entities for the supplier invoicing plan, these are " supplier address" and " item delivery address " .
5 - The value of WBSElement is now written to WBSElementExternalID.
6- API V2 was deprecated with 2308CE.*
See Also
*What is Deprecation of an API?
- A deprecated API is no longer supported in future releases, and therefore not encouraged for use. Deprecated APIs can't be removed immediately, because this can break existing client code. Deprecation is a tool for ensuring smooth transition between API releases. The successor API must be available on the day the previous version of the API is deprecated.
- A decommissioned API has been retired and can't be used in production.
- Deprecated -> Decommissioned:
- Once an API transitions from and Active to a Deprecated state, SAP will maintain the API in the Deprecated state for a minimum of 12 months before transitioning the API to a Decommissioned state.
Keywords
API_PURCHASEORDERAPI_PURCHASEORDER_PROCESS_SRV V4 API_PURCHASEORDER , KBA , MM-FIO-PUR-PO , Fiori UI for Purchase Orders , MM-PUR-PO , Purchase Orders , How To
Product
Attachments
Pasted image.png |