SAP Knowledge Base Article - Public

3360429 - Differences Between OData API V2 API_PURCHASEORDER_PROCESS_SRV and V4 API_PURCHASEORDER

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

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

{
  
"CompanyCode""1234",
  
"PurchaseOrderType""NB",
  
"Supplier""SUP_01",
  
"PurchasingOrganization""2233",
  
"PurchasingGroup""001",
  
"to_PurchaseOrderItem" :
  [{
    
"Plant""1234",
    
"OrderQuantity""7",
    
"NetPriceAmount""130.00",
    
"Material""mat-01",
    
"to_ScheduleLine":
    [{
      
"ScheduleLineOrderQuantity""7" ,
      
"ScheduleLineDeliveryDate""2023-12-30T00:00:00"
    }]
  }]
}

/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

{
"PurchasingDocument": "
1234567890",
"PurchasingDocumentItem": "10",
"ScheduleLineOrderQuantity": "11",
"ScheduleLineDeliveryDate"
: "/Date(1546099200000)/"
}

 

/sap/opu/odata4/sap/api_purchaseorder_2/srvd_a2x/sap/purchaseorder/0001/PurchaseOrderItem/1234567890/00010/_PurchaseOrderScheduleLineTP

{
  "PurchaseOrder":"1234567890",
  "PurchaseOrderItem":"00010",
  "ScheduleLine":"2",
  "ScheduleLineOrderQuantity" : 2,
  "PurchaseOrderQuantityUnit": "EA"
}

 

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

{
  
"PurchaseOrder" "4500343224",
  
"PurchaseOrderItemText" "Test:506B4BC345E01EECA6DBD10FF2E0FCD6",
  
"Plant" "0001",
  
"OrderQuantity" "10",
  
"PurchaseOrderQuantityUnit" "EA",
  
"NetPriceAmount" "10.00",
  
"PurchaseOrderItemCategory" "0",
  
"AccountAssignmentCategory" "K",
  
"MultipleAcctAssgmtDistribution" "1",
  
"Material" "mat-1",
  
"to_AccountAssignment" : [
    {
      
"AccountAssignmentNumber" "1",
      
"Quantity" "5.000",
      
"GLAccount" "400000",
      
"CostCenter" "SAP_CC_PR1"
    },
    {
      
"AccountAssignmentNumber" "2",
      
"Quantity" "5.000",
      
"GLAccount" "400000",
      
"CostCenter" "SAP_CC_PR1"
    }
  ]
}

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

{
  
"CompanyCode" "0001",
  
"PurchaseOrderType" "NB",
  
"Supplier" "sipplier2",
  
"PurchasingOrganization" "0001",
  
"PurchasingGroup" "001",
  
"to_PurchaseOrderItem" : [
    {
      
"PurchaseOrderItemText" "Test:506B4BC345E01EECA6DBD047BC4C9C70",
      
"Plant" "0001",
      
"OrderQuantity" "7.000",
      
"NetPriceAmount" "130.00",
      
"NetPriceQuantity" "1",
      
"PurchaseOrderItemCategory" "0",
      
"AccountAssignmentCategory" "K",
      
"Material" "mat-1",
      
"to_AccountAssignment" : [
        {
          
"Quantity" "7.000",
          
"GLAccount" "400000",
          
"CostCenter" "SAP_CC_PR1"
        }
      ]
    }
  ]
}

{
  
"CompanyCode""0001",
  
"PurchaseOrderType""NB",
  
"Supplier""supplier2",
  
"DocumentCurrency""EUR",
  
"PurchasingOrganization""0001",
  
"PurchasingGroup""001",
  
"_PurchaseOrderItem": [
    {
      
"PurchaseOrderItem""1",
      
"PurchaseOrderItemText""OData API V4 test",
      
"Plant""0001",
      
"OrderQuantity": 7,
      
"OrderPriceUnit""EA",
      
"AccountAssignmentCategory""K",
      
"PurchaseOrderQuantityUnit""EA",
      
"DocumentCurrency""EUR",
      
"NetPriceAmount": 130,
      
"NetPriceQuantity": 5,
      
"Material""mat-1",
      
"_PurOrdAccountAssignment": [
        {
          
"Quantity": 7,

          
"GLAccount""400000",
          
"CostCenter""SAP_CC_PR1"
        }
      ]
    }
  ]
}

- 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_PURCHASEORDER API_PURCHASEORDER_PROCESS_SRV  V4  API_PURCHASEORDER , KBA , MM-FIO-PUR-PO , Fiori UI for Purchase Orders , MM-PUR-PO , Purchase Orders , How To

Product

SAP S/4HANA Cloud 2308 ; SAP S/4HANA Cloud 2402

Attachments

Pasted image.png