on 10-21-2014 8:40 AM
Hi Experts,
We have one idoc to flat file scenario and structure is shown as below:
<root>
<NameA>
<first_name>value</first_name>
<last_name>value</last_name>
<city>value<city>
</NameA>
</root>
So, ideally the csv file will look like
first_name, last_name, city
James, Brandon, England
But as per our requirement, Header line in csv file has to change as per input data.
I mean if city is England, header tag should come as city_EN.
if it is paris, then it should come as city_FR.
Do we have any special parameters for passing header line dynamically.
One other approach I think would be, if we can pass the dynamic header name to one field(lets say Detail) in xml file and then while generating csv file in adapter, file adapter replaces header tag with value from predefined field, Detail,
If yes, then I would like to know how the header line can be replaced with some value from xml. I mean, FCC or message transform bean parameters.
Please share your thoughts.
Regards,
Vikram
Vikram,
if I understand correctly you are able to change input XML payload? If so, solution may be quite easy and you are on the right track. You will just need to specify two recordset structures with recordset 1 handling your "header" and taking its values from "Detail" node of your input XML and recordset 2 handling all the "body" data taking values from "first_name", "last_name", "city"
Please have a look here for starters How To...Content conversion module with J2EE JMS adapter - Process Integration - SCN Wiki
Come back if you are stuck or if you succeeded
HTH
Cheers
Jens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, let's assume the following input XML (having header nodes and body nodes)
<?xml version="1.0" encoding="utf-8"?>
<root>
<NameA>
<header>
<header_first_name>first_name</header_first_name>
<header_last_name>last_name</header_last_name>
<header_city>city_US</header_city>
</header>
<body>
<first_name>John</first_name>
<last_name>Appleseed</last_name>
<city>Cupertino</city>
</body>
</NameA>
<NameA>
<header>
<header_first_name>first_name</header_first_name>
<header_last_name>last_name</header_last_name>
<header_city>city_FR</header_city>
</header>
<body>
<first_name>Jean</first_name>
<last_name>Dupont</last_name>
<city>Paris</city>
</body>
</NameA>
</root>
Now let's further assume you are using MessageTranformBean module instead of inplace FCC because it is a little more versatile.
The trick here is that you have 2 structures, that both take their values dynamically from the XML payload. The first structure acts as a header in the future CSV but it's still a normal structure. It feeds from the <details> node. The second structure holds your actual payload data and feeds from the <first_name>, <last_name> and <city> nodes.
You will then be ending up with something like this for MessageTransformBean
Module Key | Paramter Name | Parameter Value |
---|---|---|
MessageTransformBean | Transform.ContentType | text/plain;charset=utf-8 |
MessageTransformBean | Transform.Class | com.sap.aii.af.sdk.xi.adapter.Conversion |
MessageTransformBean | xml.addHeaderLine | 0 |
MessageTransformBean | xml.conversionType | StructXML2Plain |
MessageTransformBean | xml.recordsetStructure | header,body |
MessageTransformBean | xml.header.endSeparator | '0' |
MessageTransformBean | xml.header.fieldFixedLengths | 10,9,7 |
MessageTransformBean | xml.header.fixedLengthTooShortHandling | Cut |
MessageTransformBean | xml.body.endSeparator | '0' |
MessageTransformBean | xml.body.fieldSeparator | , |
I didn't test this, though, so YMMV
Cheers
Jens
Hi Jens,
I followed the same approach as suggested by you and Diptee.
Its working fine .
I have slightly modified it as the header tag can be of 19 different names.
So for populating Header_City, I am using RFC lookup, so that when the same mapping needs to be used for other country, I don't have to change it again.
And it is working perfectly.
Thanks a lot for your help.
Hello Vikram,
You can try the second option. Generate headers just like records of the file and do not add header line using FCC parameters.
BR,
Diptee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.