Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
GabrielSagaya
Active Contributor

Business Requirement: 

 

In my last assignment I had a business requirement to convert the flat file into xml file without changing the Key Field names into a common name in the Header and Item nodes.

 

In Fig 1, The Constant value ‘KAC’ represent as the key field value for Header node and the constant value ‘5640’ represent as the key field value for Item nodes in the input flat file (TAB Delimited). In fig 2, ‘ReceiverId’ element under the Header Node and ‘BranchCode’ element under the Item Node represent as key field name, since the Recordset structure have variable number of substructures and the substructures must be identified by the parser from their content by using the key field.

 

 

 

 

 

Fig 1: An Input Flat File (TAB Delimited) of having Header & Item Node Values

 

 

 

 

 

Fig 2: Structure Developed for the Input file in Data Type Editor

 

 Analysis: 

 

In sender File Adapter for the case of File Content Conversion, Key Field Name should be unique for the given Recordset. For this we should have common key field name in all the substructures. Content Conversion ( The Key Field Problem ) will give the clear picture. But without changing the fieldnames ReceiverID and BranchCode into a common field name say keyfield in the Input Structure, How do we address the key field problem?

 

 Solution: 

 

Without changing the fieldnames ‘ReceiverID’ and ‘BranchCode’ into a common keyfield name, we are going to address the problem by usage of MessageTransformationBean module by having the module key Plain2XML and the corresponding conversion Type is StructPlain2XML since it is of complex conversion type. Fig 3 will give us the clear picture how to use the MessageTransformationBean module in the Sender File Adapter under the Module tab for the purpose of conversion of Flat Files (TAB Delimited) into XML file without changing the key field names in the structure.

  

 

Fig 3: Usage of MessageTransformationBean for the purpose of conversion of Flat File into XML File

 

 

Here we are specifying the key field names for both Header and Item Node Structures as xml.keyFieldName = BranchID and xml.keyFieldValue = KAC for Header Structure and xml. keyFieldName = Branch and xml.keyFieldValue = 5640 for Item Structure. Since the Input file is of Tab separated file, we are using the fieldSeparator as ‘0x09’ for both Header and Item Nodes.

 

 

Finally we will get generated XML source for this scenario in SXMB_MONI as below.

 

 

 

 

Fig 4: The Output Payload from SXMB_MONI.

 

 Conclusion: 

 

I believe this blog would provide better understanding of the usage of the module MessageTransformationBean by having the module key Plain2XML and the corresponding conversion Type is StructPlain2XML for the purpose of conversion of flat files to XML file without changing the key field names.

2 Comments