2024 May 14 1:19 PM - edited 2024 May 14 1:25 PM
All, Schedule lines are defined as 1:* cardinality in my target schema. However after the message mapping it's returned as single element instead of array. Can you guys help on how to convert it as Array? Delivery date/ Quantity of the schedule line schema are mapped to source item fields.
Target XSD Schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="PurchaseOrder">
<xs:complexType>
<xs:sequence>
<xs:element name="PurchaseOrderType" type="xs:string"/>
<xs:element name="PurchaseOrderDate" type="xs:date"/>
<xs:element name="Language" type="xs:string"/>
<xs:element name="CompanyCode" type="xs:string"/>
<xs:element name="PurchasingOrganization" type="xs:string"/>
<xs:element name="PurchasingGroup" type="xs:string"/>
<xs:element name="Supplier" type="xs:string"/>
<xs:element name="DocumentCurrency" type="xs:string"/>
<xs:element name="_PurchaseOrderItem" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="PurchaseOrderItem" type="xs:string"/>
<xs:element name="PurchaseOrderCategory" type="xs:string"/>
<xs:element name="DocumentCurrency" type="xs:string"/>
<xs:element name="MaterialGroup" type="xs:string"/>
<xs:element name="PurchaseOrderItemText" type="xs:string"/>
<xs:element name="ProductTypeCode" type="xs:string"/>
<xs:element name="CompanyCode" type="xs:string"/>
<xs:element name="Plant" type="xs:string"/>
<xs:element name="SupplierIsSubcontractor" type="xs:boolean"/>
<xs:element name="PurchaseOrderQuantityUnit" type="xs:string"/>
<xs:element name="OrderPriceUnit" type="xs:string"/>
<xs:element name="NetPriceQuantity" type="xs:decimal"/>
<xs:element name="PurchaseOrderItemCategory" type="xs:string"/>
<xs:element name="AccountAssignmentCategory" type="xs:string"/>
<xs:element name="NetAmount" type="xs:decimal"/>
<xs:element name="GrossAmount" type="xs:decimal"/>
<xs:element name="OrderQuantity" type="xs:decimal"/>
<xs:element name="NetPriceAmount" type="xs:decimal"/>
<xs:element name="OrderPriceUnitToOrderUnitNmrtr" type="xs:decimal"/>
<xs:element name="OrdPriceUnitToOrderUnitDnmntr" type="xs:decimal"/>
<xs:element name="_PurchaseOrderScheduleLineTP" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="PurchaseOrderItem" type="xs:string"/>
<xs:element name="ScheduleLine" type="xs:string"/>
<xs:element name="ScheduleLineDeliveryDate" type="xs:date"/>
<xs:element name="SchedLineStscDeliveryDate" type="xs:date"/>
<xs:element name="Batch" type="xs:string"/>
<xs:element name="BatchBySupplier" type="xs:string"/>
<xs:element name="ScheduleLineOrderQuantity" type="xs:decimal"/>
<xs:element name="PurchaseOrderQuantityUnit" type="xs:string"/>
<xs:element name="Currency" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="_PurOrdAccountAssignment" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="PurchaseOrderItem" type="xs:string"/>
<xs:element name="AccountAssignmentNumber" type="xs:string"/>
<xs:element name="OrderQuantityUnit" type="xs:string"/>
<xs:element name="Quantity" type="xs:decimal"/>
<xs:element name="DocumentCurrency" type="xs:string"/>
<xs:element name="CostCenter" type="xs:string"/>
<xs:element name="GLAccount" type="xs:string"/>
<xs:element name="Fund" type="xs:string"/>
<xs:element name="CompanyCode" type="xs:string"/>
<xs:element name="ChartOfAccounts" type="xs:string"/>
<xs:element name="ControllingArea" type="xs:string"/>
<xs:element name="ProfitCenter" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="_PurOrdPricingElement" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="PurchaseOrder" type="xs:string"/>
<xs:element name="PurchaseOrderItem" type="xs:string"/>
<xs:element name="PricingDocument" type="xs:string"/>
<xs:element name="PricingDocumentItem" type="xs:string"/>
<xs:element name="PricingProcedureStep" type="xs:string"/>
<xs:element name="PricingProcedureCounter" type="xs:string"/>
<xs:element name="ConditionType" type="xs:string"/>
<xs:element name="ConditionBaseAmount" type="xs:decimal"/>
<xs:element name="TransactionCurrency" type="xs:string"/>
<xs:element name="ConditionIsDeletable" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Source schema
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="externalId" type="xs:string"/>
<xs:element name="formNumber" type="xs:string"/>
<xs:element name="vendorName" type="xs:string"/>
<xs:element name="vendorCode" type="xs:string"/>
<xs:element name="taxTotal" type="xs:decimal"/>
<xs:element name="lineItems" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="xs:string"/>
<xs:element name="quantity" type="xs:string"/>
<xs:element name="total" type="xs:decimal"/>
<xs:element name="unit" type="xs:string"/>
<xs:element name="unitPrice" type="xs:decimal"/>
<xs:element name="lineNumber" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Sample payload after mapping:
{
"PurchaseOrderType": "NB",
"PurchaseOrderDate": "2024-05-14",
"Language": "EN",
"CompanyCode": "2024",
"PurchasingOrganization": "2024",
"PurchasingGroup": "001",
"Supplier": "1000000",
"DocumentCurrency": "USD",
"_PurchaseOrderItem": [
{
"PurchaseOrderItem": "10",
"PurchaseOrderCategory": "F",
"DocumentCurrency": "USD",
"MaterialGroup": "E002",
"PurchaseOrderItemText": "From CPI",
"ProductTypeCode": "1",
"CompanyCode": "2024",
"Plant": "2024",
"PurchaseOrderQuantityUnit": "EA",
"OrderPriceUnit": "EA",
"NetPriceQuantity": "1",
"PurchaseOrderItemCategory": "0",
"AccountAssignmentCategory": "P",
"NetAmount": "10",
"GrossAmount": "10",
"OrderQuantity": "10",
"NetPriceAmount": "1",
"_PurchaseOrderScheduleLineTP": {
"ScheduleLineDeliveryDate": "2024-05-14",
"SchedLineStscDeliveryDate": "2024-05-14",
"ScheduleLineOrderQuantity": "10",
"PurchaseOrderQuantityUnit": "EA",
"Currency": "USD"
},
"_PurOrdAccountAssignment": {
"AccountAssignmentNumber": "1",
"OrderQuantityUnit": "EA",
"Quantity": "10",
"DocumentCurrency": "USD",
"CostCenter": "20240001",
"GLAccount": "42007000",
"Fund": "FUND1",
"CompanyCode": "2024",
"ChartOfAccounts": "XXXA",
"ControllingArea": "AXX0",
"ProfitCenter": "XXXX"
}
}
]
}
Request clarification before answering.
You need to enable streaming in your XML to JSON converter with the appropriate settings. See the help URL for more information. https://help.sap.com/docs/cloud-integration/sap-cloud-integration/how-streaming-in-xml-to-json-conve...
Regards,
Ryan Crosby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
30 | |
9 | |
8 | |
8 | |
7 | |
7 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.