cancel
Showing results for 
Search instead for 
Did you mean: 

Receiver File Adapter - File Content Conversion

Former Member
0 Kudos

My XML is like this in XI:

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

- <ns0:Target xmlns:ns0="http://test.com">

- <Target>

- <Directory>

<Comment_1>#</Comment_1>

<Directory_Rec>testfile.csv</Directory_Rec>

</Directory>

- <File>

<Comment_2>#</Comment_2>

<File_Rec>testfile.csv</File_Rec>

</File>

<Target_Rec>Record 1</Target_Rec>

<Target_Rec>Record 2</Target_Rec>

<Target_Rec>Record 3</Target_Rec>

</Target>

</ns0:Target>

and my CSV file should looklike

#testfile.csv

#testfile.csv

Record 1

Record 2

Record 3

How can I do that. Would someone help he. If I put fieldseparator as 'nl' its writing as follows

#

#

Record 1

Record 2

Record 3

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ram,

with the structure you have given we can not achieve your target csv structure. at the max you can achieve the output as the following

#testfile.csv

#testfile.csv

Record 1Record 2Record 3

using the below specified config

Recordset Structure: Target,Directory,File

Target.fieldSeparator as 'nl'

Directory.fieldSeparator as '0'

Directory.endSeparator as 'nl'

File.fieldSeparator as '0'

File.endSeparator as 'nl'

in teh output the last line Record 1... comes like that because the File.fieldSeparator's value overrides the parents fieldSeparator i.e of Targets. '0' stands for no separator.

if you want to achieve your target output Target_Rec should be inside one more node say TargetRecords

and XML should be like this in XI:

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

- <ns0:Target xmlns:ns0="http://test.com">

- <Target>

- <Directory>

<Comment_1>#</Comment_1>

<Directory_Rec>testfile.csv</Directory_Rec>

</Directory>

- <File>

<Comment_2>#</Comment_2>

<File_Rec>testfile.csv</File_Rec>

</File>

<TargetRecords>

<Target_Rec>Record 1</Target_Rec>

<Target_Rec>Record 2</Target_Rec>

<Target_Rec>Record 3</Target_Rec>

</TargetRecords>

</Target>

</ns0:Target>

and the content conversion configuration should be

Recordset Structure: Target,Directory,File,TargetRecords

Target.fieldSeparator as 'nl'

Directory.fieldSeparator as '0'

Directory.endSeparator as 'nl'

File.fieldSeparator as '0'

File.endSeparator as 'nl'

TargetRecords.fieldSeparator as 'nl'

Regards,

Sundar

Former Member
0 Kudos

Sundar, I followed your idea creating Target_Records and it worked. When I'm giving points its right now showing error and I promise to give you full credit asap. Thanks again for your time and effort.

Former Member
0 Kudos

Hi Ram,

I'm happy that the scenario is working as you wished. )

Regards,

Sundar.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Ram,

Without a mapping and directly with File adapter, try that:

Recordset Structure = Directory,File,Target_Rec

Then,

Directory.<b>end</b>Separator = 'nl'

File.<b>end</b>Separator = 'nl'

Target_Rec.<b>field</b>Separator = 'nl'

Could you please try and give me the result?

I have just a doubt for <Target_Rec>...

Mickael

Former Member
0 Kudos

Mickel and Sundar,

thanks a lot for you reply. I will make changes you suggested soon. Sorry I'm now in travel and will let you know asap after I get my system access.

I have to have the structure generated like I gave in the first message.

Its because I'm using the Directory and File as variables ( will write UDF to populate file and directory fields) to write the current file in the receiver File adapter.

If I string together ( for example '#testfile' to the receiver adapter then I have trouble extracting 'testfile' out of '#testfile' during variable substitution.

Variable substitution wont take part of the reference.

Former Member
0 Kudos

Mickael,

Its producing like this.

#

/sales/temp

#

testfile.csv

File Directory test

But my problem is

/sales/temp and testfile.csv should be treated as comment in the target application. So Output must be in the following format

#/sales/temp

#testfile.csv

File Directory test

Since I'm using variable substitution in the receiver adapter I should be able to use /sales/temp as directory and testfile.csv as filename in the receiver adapter.

The whole purpose of this is to use Variable substitution and at the same time treating these extra 2 records as a comment when I sent them out.

Is there any way we can remove these 2 lines (#/sales/temp and #testfile.csv ) from appearing in the target file ?

I dont understand why there is no flexibility at all in fixing such a small issue like this in XI. Way to go for XI.

former_member206604
Active Contributor
0 Kudos

Hi,

Why dont you try with .beginSeparator for this record in the content conversion.

Set the beginSeparator as #

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

Thanks,

Prakash

Former Member
0 Kudos

Hi,

maybe it's possible directly by a receiver adapter, but you can also do it with a simple Mapping with a target Message Type:

<MT_target>
<FileName_1> with occurence = 0..1
<FileName_2> with occurence = 0..1
<Record>  with occurence = 0..Unbounded
</MT_target>

>> Wait some minutes, I think I find the solution without mapping...

Regards

Mickael

Message was edited by: Mickael Huchet