Skip to Content
0
Dec 19, 2020 at 10:41 AM

SAP CPI multipart mixed message

181 Views Last edit Jun 27 at 12:16 PM 2 rev

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--