Skip to Content
0
Jan 14, 2017 at 12:18 PM

Parsing String Which has XML structure in a SOAP To RFC Sync Interface

433 Views

Hi Everybody,

Below is the input structure coming from web service and i need to parse this to a well formed XML structure including <pBigTxt> which has Order as an header node with 1 to 1 occurrence which has attributes/fields and Line as item node with 0 to unbounded which has attributes/fields.

Input Structure :

<?xml version="1.0" encoding="UTF-8"?>
<CreateOrder>
   <pDynamicsID>38</pDynamicsID>
   <pCustomerNo>300696</pCustomerNo>
   <pBigTxt>
     <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Order OrderID="1125153" CustomerID="PP20101CMUNIEN" UserID="WC10562" DateCreated="20170111" DealerOrderNumber="1125153_TEST" OrderTypeID="021" ShipmentMethodID="Z2" Surcharge="0" Discount="0" SubTotal="356.49" VAT="49.9086" Total="406.3986">
<Line LineID="1" ItemID="0095031" Qty="2.00" DealerUnitCost="0.0000" LineDiscount="0.0000" LineAmount="0.0000" />
<Line LineID="2" ItemID="0095314" Qty="3.00" DealerUnitCost="0.0000" LineDiscount="0.0000" LineAmount="0.0000" />
<Line LineID="3" ItemID="21825666" Qty="4" DealerUnitCost="0" LineDiscount="0" LineAmount="0" />
</Order>
</pBigTxt>
</CreateOrder>

Expected Output Structure:

<?xml version="1.0" encoding="UTF-8"?>
<CreateOrder>
   <pDynamicsID>38</pDynamicsID>
   <pCustomerNo>300696</pCustomerNo>
   <pBigTxt>
     <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Order 
OrderID="1125153" 
CustomerID="PP20101CMUNIEN" 
UserID="WC10562" 
DateCreated="20170111" 
DealerOrderNumber="1125153_TEST" 
OrderTypeID="021" 
ShipmentMethodID="Z2" 
Surcharge="0" 
Discount="0" 
SubTotal="356.49" 
VAT="49.9086" 
Total="406.3986">
<Line 
LineID="1" 
ItemID="0095031" 
Qty="2.00" 
DealerUnitCost="0.0000" 
LineDiscount="0.0000" 
LineAmount="0.0000" />
<Line 
LineID="2" 
ItemID="0095314" 
Qty="3.00" 
DealerUnitCost="0.0000" 
LineDiscount="0.0000" 
LineAmount="0.0000" />
<Line 
LineID="3" 
ItemID="21825666" 
Qty="4" 
DealerUnitCost="0" 
LineDiscount="0" 
LineAmount="0" />
</Order>
</pBigTxt>
</CreateOrder>

I have decided to map the output of well formed XML to a intermediate structure and finally mapping to BAPI to create sales order.I tried to parse input message using Java map however facing difficulties.Any suggestions will highly appreciated.

Thanks

Pavan

Attachments

input.jpg (162.1 kB)