We have discussed the simple File Adapter Configuration earlier. In this article we will understand the concept of File Content Conversion using an example of comma separated text file as source. File Content Conversion helps in converting the file formats to/from XML.
We need to simply define the structure of the source or target file so that the adapter can accordingly convert it to/from XML.
File Sender Adapter with Content Conversion
Let’s say we have a simple CSV (Comma-separated values) file something like the one shown in the adjacent figure. It contains employee details. The same needs to be sent to XI via sender file adapter.
Figure below shows a typical configuration for the sender adapter. Document Name and namespace indicate the message type used (from the Integration Repository). Recordset Name specifies the name of the root node that should be created while generating the corresponding XML. This should be in sync with the message structure in the Integration Repository. If you don’t specify this, XI creates a default root node called Recordset.
In Recordset Structure you specify the substructure and its occurrence. In our case ‘Emp,*’ indicates that node Emp can occur any number of times within the root node.
Three mandatory parameters that must be provided are –
- <node>.fieldSeparator – can be a comma for a CSV file, or any other separator. You can specify the hex code here, e.g. for a tab separated file you could provide ‘0x09’ (including quotes).
- <node> .endSeparator – signifies the end of a record, ‘nl’ (including quotes) indicates a new line character.
- <node> .fieldNames – list of field names in each record.
For an exhaustive list of parameters available for recordset structure please go through this link. You can find detailed description of File Sender Adapter parameters here.
File Receiver Adapter with Content Conversion
Assume you have XML content as generated by the sender adapter above and are required to generate a tab separated file (as shown in adjoining figure) at the receiver end. File Content Conversion comes in handy here.
Specify the Recordset Structure giving the list of nodes including the root and substructure that needs to be read.
The mandatory parameters are – <node>.fieldSeparator and <node>.endSeparator. Description is same as in sender adapter. Please see the figure on the right to have a clear understanding.
For an exhaustive list of parameters available for recordset structure, please visit this link. You can find detailed description of Receiver File Adapter here.
In the next part we will see configuring file adapter when dealing with files with complex structures.
Hi Riyaz,
this is a very useful site.
but kindly provide the information of the data types or message types also
so that we can configure the channels according to the structure.
thanks and regards,
Divya.
Hi Divya,
This is a simple structure i.e. no child nodes involved…something like
<DT_Employee>
<EmpID></EmpID>
<Name></Name>
<Surname></Surname>
<Dept></Dept>
<Location></Location>
<Phone></Phone>
</DT_Employee>
Hope this helps.
Regards,
Riyaz
Hi Riyaz,
Excellent work. I appreciate the way you put up all articles. I have a quick question though. The value for the field like .endSeparator when put to ‘nl, would work for all OS. I know form the fact that this is UNIX command. How about Linux ?
We have PI installed on Linux and some of the command like ‘nl’ are not working .
Any idea on that?
Thanks & keep the nice work going..
Harish
In those cases where the transfer would be from one kind of OS to a different kind,you have to place modules in the comm channel itself before the xml is generated by XI.So in case a win2k document is sent to a Unix system,since win2k uses CRLF[carriage return line feed], this needs to be converted to LF[Line feed] for unix. You can write an ejb module and add this code as a module in the comm channel.
This way u can achieve the way u want ur docs to get through XI and reach the recipient in a format it understands.
Hi Riyaz,
I have a small issue here, What is happening here is PI transfers the Host flat files to theERP( AG landscape) via IDocs
The host file contains some accent charecters , when this Host flat file is transferred though IDoc i see the accent charecters are replace with space say suppose Employee name is SÉBASTIEN here E is the accent charecter when i check my idoc the employee name seems to be in this way S BASTIEN there is a space between S and B. Can you help me what i can do on this?
You probably need to change the character set used in XML document/mapping from UTF-8 to the suitable character set, possibly ISO-8859-1 or similar series.
hi riyar , i have question
hi Riyaz,
I HAVE QUESTION,
In Target system, At end of the file i need to Pass a special Charcater ASCII13 in JMS Adapter.
I am Using character set UTF-8 format.Please let me know what parameter we need to pass to achieve this
How to do content conversion of below file in Receiver Adapter.
PI.IDENT:A,B,2.4,20040305,205707,164754,,,E,C,,D
PI.HEADER:A123,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
PI.LINEITEM:,12345678,,,3,,,,,,,,,,,,,,,,,,,,
PI.TRAILER:1
Its a Star Format File. Your Input will be very valuable for me.
My file structure is like below,
————————————-
“FirstName”|”LastName”
“Ashok”|”Raj”
————————————–
Could pls let me know how to configure it in FCC?