cancel
Showing results for 
Search instead for 
Did you mean: 

Reciever File Adapter file content conversion: Header line change in CSV file

former_member585940
Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

JaySchwendemann
Active Contributor
0 Kudos

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

former_member585940
Participant
0 Kudos

Jens,

Thanks for your response.

I checked this blog but it also talks about hardcoding recordset structure.

xml.recordsetStructure   NameA,NameB,NameC

Can you help me in finding the particular module parameter which will add the header(from detail field) to csv file.

Thanks,

Vikram

JaySchwendemann
Active Contributor
0 Kudos

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 KeyParamter NameParameter Value
MessageTransformBeanTransform.ContentTypetext/plain;charset=utf-8
MessageTransformBeanTransform.Classcom.sap.aii.af.sdk.xi.adapter.Conversion
MessageTransformBeanxml.addHeaderLine0
MessageTransformBeanxml.conversionTypeStructXML2Plain
MessageTransformBeanxml.recordsetStructureheader,body
MessageTransformBeanxml.header.endSeparator'0'
MessageTransformBeanxml.header.fieldFixedLengths10,9,7
MessageTransformBeanxml.header.fixedLengthTooShortHandlingCut
MessageTransformBeanxml.body.endSeparator'0'
MessageTransformBeanxml.body.fieldSeparator,

I didn't test this, though, so YMMV

Cheers

Jens

former_member585940
Participant

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.

Answers (1)

Answers (1)

Former Member
0 Kudos

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

former_member585940
Participant
0 Kudos

Hi Dipee,

Thanks for this approach.

Yes, it worked perfectly.

Still, I would like to know if we have some module parameters for choosing header line dynamically.

Regards,

Vikram