Flat file to deep XML – using an UDF ‘File Content Conversion‘ OR ‘MessageTransformBean‘ in sender channel can produce a 4 level deep XML, maximum.

Flat file to deep XML – using an UDF

If expected XML is more than 4 level deep.

Flat file to deep XML – using an UDF

Solution: – Develop FCC or MTB to read each line of input.

Flat file to deep XML – using an UDF

Map using an UDF, to split each line to corresponding field.

Flat file to deep XML – using an UDF

Flat file to deep XML – using an UDF

UDF code: – ‘Execution Type’ : ‘All Values of a Context’.

 public void udf_Shopping(String[] eachLine, ResultList Customer, ResultList Name, ResultList ID, ResultList Order, ResultList OrderNumber, ResultList OrderNote, ResultList LineItem, ResultList LineNumber, ResultList Material, ResultList TaxLine, ResultList Type, ResultList Amount, Container container) throws StreamTransformationException{ int countCust = 0, countOrdr = 0, countLine = 0; String values[]; for (String line : eachLine) {     values = line.split(",");     if (line.startsWith("Cust")) {         Customer.addValue("");         Name.addValue(values[1]);  Name.addContextChange();         ID.addValue(values[2]);    ID.addContextChange();         //Add context change form second Customer.         if (countCust > 0) {       Order.addContextChange();  }         countCust++;     } else if (line.startsWith("Ordr")) {         Order.addValue("");         OrderNumber.addValue(values[1]);  OrderNumber.addContextChange();         OrderNote.addValue(values[2]);    OrderNote.addContextChange();         //Add context change form second Order.         if (countOrdr > 0) {              LineItem.addContextChange();  }         countOrdr++;     } else if (line.startsWith("Line")) {         LineItem.addValue("");         LineNumber.addValue(values[1]);  LineNumber.addContextChange();         Material.addValue(values[2]);    Material.addContextChange();         //Add context change form second LineItem.         if (countLine > 0) {             TaxLine.addContextChange();        }         countLine++;     } else if (line.startsWith("Taxl")) {         TaxLine.addValue("");         Type.addValue(values[1]);    Type.addContextChange();         Amount.addValue(values[2]);  Amount.addContextChange();     } } } 


Comma(delimiter), ‘Cust’, ‘Ordr’, ‘Line’ and ‘Taxl’ arbitrary values are used to demonstrate the concept.

If some fields are optional in input, to avoid ArrayIndexOutOfBoundsException append delimiters.

for (String line : eachLine) {

line = line + “,,,–“; //Append “,,,–” commas for optional fields.

values = line.split(“,”);



If input is fixed length file (instead of delimited), use java String method substring(int beginIndex, int endIndex).


Deep XML to Flat file – using an UDF

Other solution available on SCN.

XSLT approach – Flat File to Deep XMLDeepFCCBean – Flat File to Deep XML

Convert Flat File to Deeply XML Using Graphical Mapping

New NetWeaver Information at SAP.com

Very Helpfull



User Rating: Be the first one !