cancel
Showing results for 
Search instead for 
Did you mean: 

File content conversion: How to append rows to existing file starting at new line?

former_member190293
Active Contributor
0 Kudos

Hello, friends!

I work on scenario where I want to put some message data to flat text file for further processing. And want to append data to existing file instead of making new one each time I get new message.

In my receiver file communication channel I use file content conversion to make a flat structure from xml data and use "Append" file construction mode to add new data to existing file.

It works, but... new data is appended to file starting at last position of  the last line. And I want it to append data starting at new row.

I tried to use parameters like ".endSeparator" and "beginSeparator" with value "'nl'" but it doesn't work for me.

What else could I do to make it work the way I want?

Accepted Solutions (1)

Accepted Solutions (1)

former_member190293
Active Contributor
0 Kudos

I see that 'nl' as endSeparator adds new line to file but next portion of data is written right after the last sign and not from new line.

And the second: I try using 'nl' as beginSeparator but it append it in file as 'nl' instead of adding a new line. What am I doing wrong?

Former Member
0 Kudos

Hi Evgenly,

Try using '\nl' instead of 'nl'.

Regards,

Alka.

former_member190293
Active Contributor
0 Kudos

It doesn't work too. Just adds 'l' to the end.

former_member182412
Active Contributor
0 Kudos

Hi Evgeniy,

May be with endSeparator 'nl' is adding LF to the file, when you open the file in notepad if your operating system is windows it needs CRLF to display in new line.

Try using end separator as '0x0D''0x0A' it will insert CRLF.

Regards,

Praveen.

former_member190293
Active Contributor
0 Kudos

Thanks a lot Praveen!

It did the trick!

Answers (4)

Answers (4)

former_member190293
Active Contributor
0 Kudos

Another way for me might be to read flat file consisting of one row at next step but I can't do that too.

Source file then looks like:

AAAAABBBBBCCCC

where each value has the same length and represents a single row of data. But FCC in Sender File Adapter reads only first value (first row).

Ryan-Crosby
Active Contributor
0 Kudos

Hi Evgeny,

Can you give a sample of 2-3 messages and what you are expecting for output in the flat file?

Regards,

Ryan Crosby

former_member190293
Active Contributor
0 Kudos

Hi Ryan!

Source messages are:

<Message>

     <IDOC>

          <IDOC_REFINT>111</IDOC_REFINT>

     </IDOC>

</Message>

...

<Message>

     <IDOC>

          <IDOC_REFINT>222</IDOC_REFINT>

     </IDOC>

     <IDOC>

          <IDOC_REFINT>333</IDOC_REFINT>

     </IDOC>

</Message>

And output text file sould look like:

111

222

333

And now I get:

111222333

Former Member
0 Kudos

Hi Evgeniy,

I stand corrected,

The parameter would be ".beginSeparator" and the value should be 'nl' including the single quotation marks.

Thanks,

Alka.

former_member190293
Active Contributor
0 Kudos

I've already tried that. It just put 'nl' string before new data.

giridhar_vegi
Participant
0 Kudos

Hi ,

     Could you please share the screenshot of your file content conversion parameters

Thanks

Giridhar

former_member190293
Active Contributor
0 Kudos

Input XML structure looks like:

<Message>

     <IDOC>

          <IDOC_REFINT>Value(23 signs)</IDOC_REFINT>

     </IDOC>

</Message>

former_member184720
Active Contributor
0 Kudos

>>>I tried to use parameters like ".endSeparator" and "beginSeparator" with value "'nl'" but it doesn't work for me.

if you are sure about it, then add a newline for the last field during the mapping.

Refer to Former Member reply in below thread

former_member190293
Active Contributor
0 Kudos

Hareesh Gampa wrote:

>>>I tried to use parameters like ".endSeparator" and "beginSeparator" with value "'nl'" but it doesn't work for me.

if you are sure about it, then add a newline for the last field during the mapping.

Refer to Former Member reply in below thread

File adapter-How to set line break in text file-split record into two lines

What do you mean "add a newline for the last field"? I've tried to add an empty row to my source xml structure but it didn't work either.

former_member184720
Active Contributor
0 Kudos

>>>What do you mean "add a newline for the last field"? I've tried to add an empty row to my source xml structure but it didn't work either.

If you have gone through the discussion that i shared, Marina had the similar problem.

If below is your target structure, then when you map IDOC_REFINT field, append a newline to it. So that everytime a newline would be added by the mapping itself.

Input XML structure looks like:

<Message>

     <IDOC>

          <IDOC_REFINT>Value(23 signs)</IDOC_REFINT>

     </IDOC>

</Message>

your source field -> UDF -> IDOC_REFINT

UDF : (execution type: single values)

String output= var1 + "\r\n ";

return output;