Continuing with our episode 1, here in this Blog post I would like to cover the update and delete operations for Purchase Requisition and its associated entities.

Updating a Purchase Requisition

As per the available/exposed fields in Purchase Requisition header only ‘PurchaseReqnDescription’ can be updated in header. This operation is supported with HTTP PATCH or batch of updates. A sample batch would look like –

–batch
Content-Type: multipart/mixed; boundary=changeset

–changeset
Content-Type: application/http
Content-Transfer-Encoding: binary

PATCH A_PurchaseRequisitionHeader(PurchaseRequisition=’4000068920′) HTTP/1.1
Content-Type: application/json
Content-Length: 1231

{
” PurchaseReqnDescription “:”Purchase requisition description update”
}

–changeset–

–batch–

Updating a Purchase Requisition Item

Updates to item and its associated entities can be done via HTTP PATCH or batch updates. A sample batch would look the same as a header request, with appropriate entity –

–batch
Content-Type: multipart/mixed; boundary=changeset

–changeset
Content-Type: application/http
Content-Transfer-Encoding: binary

PATCH A_PurchaseRequisitionItem(PurchaseRequisition=’4000068920′,PurchaseRequisitionItem=’10’) HTTP/1.1
Content-Type: application/json
Content-Length: 1231

{
“PurchaseRequisitionItemText”:”Test Update 1″
}

–changeset–

–batch–

Points to note: –
1. Fields such as LastChangedDateTime, CreationDate, CreatedBy, PurReqCreationDate, DeliveryAddressID, ManualDeliveryAddressID, PurchasingDocumentCategory, PurchasingDocumentSubtype are read only fields and patch to these fields shall be ignored without raising any error.
2. Patching fields like PurReqnReleaseStatus shall not guarantee expected behavior of PR and follow on document(s), as such fields are manipulated by system and should not be modified manually
3. Date related fields shall take (date + UTC) timestamp in milliseconds.
4. DELETE operation is not supported. However, PR item can be marked for deletion using PATCH operation sending IsDeleted as ‘X’(true).
5. If IsDeleted is marked ‘X’, patch for that items shall fail with appropriate error message (item marked for deletion cannot be changed, until undeleted).

Updating Account Assignment, Delivery Address and Item Text

All the three entities can be updated by the user via batch or non-Batch call.
Account assignment can be modified from unknown account assignment (U) to a single/Multiple account assignment via a Batch call, since the data is dependent on Item entity.

While changing account assignment from U(Unknown) to K (Single/Multiple):
1. Send update (PATCH) for ‘AccountAssignmentCategory’
2. Send update (PATCH) for ‘MultipleAcctAssgmtDistribution’ : (‘ ’ – Single Accounting, 1 – Distribution by Quantity, 2 – Distribution by percentage)
3. Send create (POST) for A_PurReqnAcctAssgmt [in batch]*

While changing form account assignment K(Single/Multiple) to U (Unknown) :
1. Send update (PATCH) for ‘AccountAssignmentCategory’
2. Send update (PATCH) for ‘MultipleAcctAssgmtDistribution’ setting it to blank value

While updating Account assignment make sure your Item Quantity is completely covered by your Accounting lines else it might generate an error.

POST for associated entities is restricted in order to prevent business data inconsistency and support logical operations for the document.

DELETE operation for A_PurReqnAcctAssgmt and A_PurReqAddDelivery entities is not supported by the API since they are dependent on Item data.

DELETE operation for A_PurchaseReqnItemText shall delete the item note for a PR item.

Reference addresses are not supported for ODATA API, only supported address types are Default Address from Plant and Manual address.

* – POST is only enabled for A_PurReqnAcctAssgmt in batch mode in order to support logical changes in accounting for Purchase Requisitions

Some related links for reference –

  1. FAQs
  2. API Hub – Purchase Requisition
  3. Business documentation

Thanks for going through the blog posts. Let us know your suggestions in comments section below.