List rows = llect ĭef currHeader = it.I am in a position where I am required to convert CSV files following the same template into XML files. You can enhance the code based on your requirement. I have hardcoded the fields for code simplicity. GenerateXML Method converts the object to the XML format. GetListNodes creates an array of objects with each PO and associated Items together. Lines array is split based on the commas and stored in List(rows). GetRows Method splits each line and store it in a array(lines). In the CSV_XML Converter, i have added the Groovy script mentioned below. csv file into an XML File as shown in the output File.īelow groovy script can be used to achieve this requirement. Received multiple purchase Orders from the client as shown in Input File. In this scenario I get a Purchase Order and multiple Line Items associated to it. In the below scenario, I have taken a sample XML file and converted that to an output XML file using Groovy script in SAP CPI. This blog explains about the Groovy script used to convert a CSV structure to Nested XML file. In that case we need to use of either Groovy Script or third-party conversion agents or inbuilt graphical mapping by using intermediate structures and user defend functions. IF we are receiving a complex/nested csv files from third party system, then standard CSV converters in SAP CPI would not help us. Standard Conversion methods in SAP CPI allow you to convert the incoming CSV file to flat XML structures only i.e., only one level of nesting is possible. Many times, we are required to convert CSV structures to deeply nested XML structures. This blog helps you solve most common requirement to convert nested CSV structure to an XML in SAP CPI.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |