on 12-19-2020 10:41 AM
Hi,
I am getting a payload similar to below into CPI
My aim is to replace "PurReqnExternalSystemType" value with value from field "PurchasingDocumentCategory" and remove "PurchasingDocumentCategory" field and its value from the payload
These fields appear under multiple times in the payload
PATCH A_PurchaseRequisitionItem(PurchaseRequisition='0011234',PurchaseRequisitionItem='2') HTTP/1.1
and
PATCH A_PurchaseRequisitionItem(PurchaseRequisition='0011234',PurchaseRequisitionItem='2') HTTP/1.1
How do I achieve this in SAP CPI. Any hints on grrovy script?
--batch
content-type: multipart/mixed; boundary=changeset
--changeset
content-type: application/http
content-transfer-encoding: binary
PATCH A_PurchaseRequisitionHeader(PurchaseRequisition='001234') HTTP/1.1
accept: application/json
content-type: application/json
{"PurchaseRequisition":"","PurchaseRequisitionType":"NB","PurReqnDescription":"CPI payloads","SourceDetermination":false}
--changeset
content-type: application/http
content-transfer-encoding: binary
PATCH A_PurchaseRequisitionItem(PurchaseRequisition='0011234',PurchaseRequisitionItem='1') HTTP/1.1
accept: application/json
content-type: application/json
{"PurchaseRequisition":"","PurReqnExternalReference":"6149","PurReqnItemExternalReference":"1","PurReqnExternalSystemType":"A","ExternalApprovalStatus":"A","AccountAssignmentCategory":"K","MaterialGroup":"A00906","PurchasingDocumentCategory":"B","RequestedQuantity":"1.0000000000"}
--changeset
content-type: application/http
content-transfer-encoding: binary
PATCH A_PurchaseRequisitionItem(PurchaseRequisition='0011234',PurchaseRequisitionItem='2') HTTP/1.1
accept: application/json
content-type: application/json
{"PurchaseRequisition":"","PurReqnExternalReference":"6149","PurReqnItemExternalReference":"2","PurReqnExternalSystemType":"A","ExternalApprovalStatus":"A","AccountAssignmentCategory":"K","MaterialGroup":"A00906","PurchasingDocumentCategory":"C","RequestedQuantity":"1.0000000000"}
--changeset
content-type: application/http
content-transfer-encoding: binary
PATCH A_PurchaseReqnItemText(PurchaseRequisition='0011234',PurchaseRequisitionItem='1',DocumentText='B01',TechnicalObjectType='EBAN',Language='EN') HTTP/1.1
accept: application/json
content-type: application/json
{"NoteDescription":"Test "}
--changeset
content-type: application/http
content-transfer-encoding: binary
PATCH A_PurchaseReqnItemText(PurchaseRequisition='001234',PurchaseRequisitionItem='2',DocumentText='B01',TechnicalObjectType='EBAN',Language='EN') HTTP/1.1
accept: application/json
content-type: application/json
{"NoteDescription":"Test "}
--changeset--
--batch--
Hello @sankar_bhatta I am still quite new to the topic to write the script hint directly. But I would check on jsonslurper https://groovy-lang.org/json.html or if more convenient, JSON to XML and in XML you could try to utilize Xpath or even XSLT script. also https://groovyide.com/cpi online debugging should help a lot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
9 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.