Quantcast
Channel: SCN : Document List - Process Integration (PI) & SOA Middleware
Viewing all articles
Browse latest Browse all 571

Flat File to DeepXML using Standard FCC and Message Mapping Part 1

$
0
0

Introduction

Standard file content conversion supports one level of nested XML but many times we need more than one nested deep XML, We have many blogs in SCN that deals with this requirement. In this document i want to show by using standard file content conversion and message mapping.


Example Scenarios

Scenario 1

I took the example from this thread Re: Sender File content conversion , this is flat file to two level nested XML structure.


This below is sender flat file, sender message type structure and sender file FCC parameters.

File_FCC.png

File Content Conversion


InvoiceHeader.keyFieldValueH
InvoiceHeader.keyFieldNameLineIndicator
InvoiceHeader.fieldNamesLineIndicator,SupplierCode,InvoiceDate,Currency,Amount
InvoiceHeader.fieldSeparator;
InvoiceHeader.endSeparator'nl'
InvoiceDetail.keyFieldNameLineIndicator
InvoiceDetail.keyFieldValueD
InvoiceDetail.fieldNamesLineIndicator,LineType,CompanyCode,Costelement
InvoiceDetail.fieldSeparator;
InvoiceDetail.fieldSeparator'nl'
ControlHeader.keyFieldValueCH
ControlHeader.keyFieldNameLineIndicator
ControlHeader.fieldNamesControlIndicator,TotalLine,TotalAmt
ControlHeader.fieldSeparator;
ControlHeader.endSeparator'nl'
ControlData.keyFieldValueCD
ControlData.keyFieldNameLineIndicator
ControlData.fieldNamesControlIndicator,TotalLine,TotalAmt,Currency
ControlData.fieldSeparator;
ControlData.endSeparator'nl'

 

Output

The below is output of the mapping, you can find source is flat file structure according to file above, the output is nested three level deep XML as we expected.

Output.png

 

Mapping

The mapping simple field to field mapping except for Invoice node, ControlHeader node and ControlData, these three we just need to change the context to root node.

Mapping.png

Scenario 2

I took this example from this thread structure not populating correctly in FCC, This example is flat structure to three level nested XML.

 

Input Data

The below is sender file, sender message structure and file content conversion.

File_FCC.png

File Content Conversion

FILE_HEADER.keyFieldValueA
FILE_HEADER.keyFieldNameKEY
FILE_HEADER.fieldNamesKEY,FIELD1,FIELD2
FILE_HEADER.fieldFixedLengths1,2,1
FILE_HEADER.endSeparator'nl'
VOUCHER_HEADER.keyFieldNameKEY
VOUCHER_HEADER.keyFieldValueB
VOUCHER_HEADER.fieldNamesKEY,FIELD1,FIELD2
VOUCHER_HEADER.fieldFixedLengths1,2,7
VOUCHER_HEADER.endSeparator'nl'
VOUCHER_DETAIL.keyFieldValueD
VOUCHER_DETAIL.keyFieldNameKEY
VOUCHER_DETAIL.fieldNamesKEY,FIELD1,FIELD2
VOUCHER_DETAIL.fieldFixedLengths1,2,7
VOUCHER_DETAIL.endSeparator'nl'

 

Output

The below is output of the mapping, you can find source is flat file structure according to file above, the output is nested three level deep XML as we expected.

MappingInputOutput.png

Mapping

First level node you can directly map and change the context change to root node. The fields under first level node you can directly map

FileHeaderMap.png

 

For all other child level nodes (Second level node and third level node) you can apply the below mapping.

SecondLevelMap.png

For second level and third level node fields you can apply the below mapping.

FieldsUnderSecond.png

 

User Defined Function

The below is the mapChildNode UDF which is used above, this is generic UDF we can use this in all similar requirement in future.

UDF.png

 

public void mapChildNode(int[] parentCount, int[] childCount, ResultList result, Container container)  throws StreamTransformationException {  int i = 0;  for (; i < parentCount.length; i++) {  if (childCount[i] > 0) {  if (parentCount[i] > 0 && i != 0)  result.addContextChange();  for (int j = 0; j < childCount[i]; j++)  result.addValue("");  } else {  if (i != 0)  result.addContextChange();  result.addSuppress();  }  }  }

Similar documents in SCN

Deep XML to Flat file - using an UDF

XSLT approach - Flat File to Deep XML

DeepFCCBean - Flat File to Deep XML

Convert Flat File to Deeply XML Using Graphical Mapping


Conclusion

We can do flat file to nested deep XML using standard file content conversion and message mapping using one generic user defined function.I hope this helps.


Viewing all articles
Browse latest Browse all 571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>