cancel
Showing results for 
Search instead for 
Did you mean: 

Help needed with xml to flat file conversion

former_member190543
Participant
0 Kudos

Hi all,

I am doing a webservice (SOAP) to file scenario. The file I get into the target directory is as below.

<?xml version="1.0" encoding="UTF-8"?>

<ns1:MT_Test_interface xmlns:ns1="http://test_namespace.co.uk"><fieldA>0000012345</fieldA><fieldB></fieldB><fieldC>0010203040</fieldC><transaction_type>NEW</transaction_type><transaction_date>2011/08/21</transaction_date><sales data>PARTNERS (((119006.258 169077.102), (372718.323 77854.466, 371449.872 70783.383), (382225.17 73214.976, 398410.463 95156.636)))</sales data></ns1:MT_Test_interface>

But I want it to be a plain text file like below, not an xml file.

0000012345

0010203040

NEW

2011/08/21

PARTNERS

(((119006.258 169077.102), (372718.323 77854.466, 371449.872 70783.383), (382225.17 73214.976, 398410.463 95156.636)))

What are all the modules I need and also the parameters and their values please?

Any help is appreciated.

Thanks.

Ramesh.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ramesh,

You can achieve this by Using "File Content Conversion " as Message Protocol and follow the below steps.in FTP Receiver Adapter .

Add one more field "Row" in your receiver side data structure and follow the below setps.

Enable Content Conversion Parameters

Record Structure : Row

In the table provide following elements.

Row.fieldNames : fieldA,fieldB,fieldC,transaction_type,transaction_date,sales data

Row.fieldSeparator : 'nl'

Row.processConfiguration: FromConfiguration

Row.endSeparator : 'nl'

former_member190543
Participant
0 Kudos

Thanks guys.

My xml now is like this:

<?xml version="1.0" encoding="UTF-8" ?>

- <ns1:MT_test xmlns:ns1="http://test.co.uk">

- <REPORT>

<company_number>0000043239</company_number>

<transaction_type>CREATE</transaction_type>

<transaction_date>2011/08/21</transaction_date>

<sales_data>Partners (((119006.258 169077.102), (372718.323 77854.466, 371449.872 70783.383), (382225.17 73214.976, 398410.463 95156.636)))</Partners>

</REPORT>

</ns1:MT_test>

I am using the content conversion as below:

Recordset Structure: REPORT

Name: REPORT.addHeaderLine Value: 1

Name: REPORT.fieldSeparator Value: ,

Name: REPORT.endSeparator Value: 'nl'

Name: company_number.endSeparator Value: 'nl'

and I am getting the result as:

company_number,transaction_type,transaction_date,sales_data

0000043239,CREATE,2011/08/21,Partners (((119006.258 169077.102), (372718.323 77854.466, 371449.872 70783.383), 382225.17 73214.976, 398410.463 95156.636)))

But I want file like this:

company_number,transaction_type,transaction_date,sales_data

0000043239

CREATE

2011/08/21

Partners (((119006.258 169077.102), (372718.323 77854.466, 371449.872 70783.383), 382225.17 73214.976, 398410.463 95156.636)))

What will be the CC parameters please?

Many thanks.

Ramesh.

Former Member
0 Kudos

Hi Ramesh,

As I given you example earlier , you can use 'nl" as field Separator.

Name: REPORT.fieldSeparator Value: 'nl'

Please let me know the results.

Former Member
0 Kudos

HI Ramesh Naidu,

you can use 'nl' (newLine) as a field separator then solve your problem.

Ex:

name is: REPORT.fieldSeparator

value is : 'nl'

Thanks,

former_member190543
Participant
0 Kudos

Thanks guys.

Kumar,

I now gave the parameters as:

Recordset Structure: REPORT

Name: REPORT.addHeaderLine Value: 1

Name: REPORT.fieldSeparator Value: 'nl'

Name: REPORT.endSeparator Value: 'nl'

Name: company_number.endSeparator Value: 'nl'

and I am getting the result as below which is good except that I want the header items in the first line to be separated by comas:

company_number

transaction_type

transaction_date

sales_data

0000043239

CREATE

2011/08/21

Partners (((119006.258 169077.102), (372718.323 77854.466, 371449.872 70783.383), 382225.17 73214.976, 398410.463 95156.636)))

But I want file like this:

company_number,transaction_type,transaction_date,sales_data

0000043239

CREATE

2011/08/21

Partners (((119006.258 169077.102), (372718.323 77854.466, 371449.872 70783.383), 382225.17 73214.976, 398410.463 95156.636)))

Where I am doing wrong?

Thank you.

Former Member
0 Kudos

instead of "REPORT.addHeaderLine = 1" try below mentioned 2 parameters:


REPORT.addHeaderLine Value: 3 
REPORT.headerLine Value: company_number,transaction_type,transaction_date,sales_data

http://help.sap.com/saphelp_nw73/helpdata/en/44/658abd344a4de0e10000000a1553f7/frameset.htm

former_member190543
Participant
0 Kudos

Thanks everyone for the help.

Amitsri,

I used the parameters suggested by you and that worked perfectly. Thank you.

Best regards.

Ramesh.

Answers (2)

Answers (2)

Former Member
0 Kudos

If you want each field in the flat file to be on a separate line then your fieldSeparator needs to have a value of 'nl'.

former_member854360
Active Contributor
0 Kudos

You can use File content conversion in receiver file adapter.

http://help.sap.com/saphelp_nw04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm

former_member190543
Participant
0 Kudos

Hi Debashish,

I have seen that help page, but could not implement it for my requirement. Could you help me with that please?

Also, can I use "AF_Modules/StrictXml2PlainBean" bean?

Thanks.

Ramesh.

former_member854360
Active Contributor
0 Kudos

Hi,

You can use the module AF_Modules/StrictXml2PlainBean

but if you are using file adapter then no need to use module you can use file content conversion easily.

Former Member
0 Kudos

Hi,

Do not use any adaptor module to do this. You can just use File adapter content conversion at receiver side:

provide following key value pair:

recordStructure.endSeperator and value 'nl' (new line), which would solve your problem, Provide proper recordStrure value according to your message structure.

Best Regards,

RK