cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

Dear Guru's,

I have to solve following problem with XML (with mulitiple records) to TEXT file scenario using file adapter. I have to output for ever ONE data record in XML always two identical lines in text file. Second line should have a little bit different mapping in few fields like date,... So I did duplicate fileds in my output structure in mapping and need to know how to set line break in the middle and see half of structure in first line and next structure half in second line

_______________________________________________________________________________________________________________________________________________________________________________

My output structure in mapping is:

CASHFLOW

- INTERFACE

- GESELLSCHAFT

- ANWENDUNG

- PRODUKT

- VERTRAG

- BETRAG

- WAEHRUNG

- DIRECTION

- BEWEGUNGSTYP

- FAELLIGKEIT

- ZINSFESTSTELLUNG

- ZAHLUNGSTAG

- RENDITE

- INTERFACE2

- GESELLSCHAFT2

- ANWENDUNG2

- PRODUKT2

- VERTRAG2

- BETRAG2

- WAEHRUNG2

- DIRECTION2

- BEWEGUNGSTYP2

- FAELLIGKEIT2

- ZINSFESTSTELLUNG2

- ZAHLUNGSTAG2

- RENDITE2

_______________________________________________________________________________________________________________________________________________________________________________

Question is how can I set on receiving file adapter in Content Conversion Parameters that fields from first structure half INTERFACE...RENDITE should be outputed in one line and fields from second half of structure INTERFACE2...RENDITE2 should start on second line in final text file.

_______________________________________________________________________________________________________________________________________________________________________________

I'm getting at the moment one line only and I need to know how can set line break so that second line starting with INTERFACE2(CA)...RENDITE2 will start in new line.

CA,"0100","7","512",20090127010001,-12454762586.6800,"EUR",2,12,2009-01-28,2009-01-27,2009-01-28,"0.0000000",CA,"0100","7","512",20090127010001,-12454762586.6800,"EUR",1,10,2009-01-27,2009-01-27,2009-01-27,"0.0000000"

_______________________________________________________________________________________________________________________________________________________________________________

This should be final output:

CA,"0100","7","512",20090127010001,-12454762586.6800,"EUR",2,12,2009-01-28,2009-01-27,2009-01-28,"0.0000000"

CA,"0100","7","512",20090127010001,-12454762586.6800,"EUR",1,10,2009-01-27,2009-01-27,2009-01-27,"0.0000000"

_______________________________________________________________________________________________________________________________________________________________________________

My file adapter settings:

RecordsetStructure=CASHFLOW

CASHFLOW.fieldNames=INTERFACE,GESELLSCHAFT,ANWENDUNG,PRODUKT,VERTRAG,BETRAG,WAEHRUNG,DIRECTION,BEWEGUNGSTYP,FAELLIGKEIT,ZINSFESTSTELLUNG,ZAHLUNGSTAG,RENDITE

CASHFLOW.fieldSeparator=,

CASHFLOW.endSeparator='nl'

CASHFLOW.fieldNames=INTERFACE2,GESELLSCHAFT2,ANWENDUNG2,PRODUKT2,VERTRAG2,BETRAG2,WAEHRUNG2,DIRECTION2,BEWEGUNGSTYP2,FAELLIGKEIT2,ZINSFESTSTELLUNG2,ZAHLUNGSTAG2,RENDITE2

CASHFLOW.fieldSeparator=,

_______________________________________________________________________________________________________________________________________________________________________________

It wont help if I add two identical structures in mapping because in output i would see for multiple entries section with first lines only and after that section with second lines only. And CASHFLOW is one part of more complex mapping ...

(This is final output structure RecordsetStructure=HEADER,CASHFLOW,CONDITION,REFERENCE,CONTRACT - more sections with different data and all these should have duplicate lines at the end)

_______________________________________________________________________________________________________________________________________________________________________________

Thanks a lot for any help

Cheers

Marian

Edited by: Marian Luscon on Jul 14, 2009 11:44 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mariam,

The default endSeparator is a new line. So You no do need specify "CASHFLOW.endSeparator" parameter.

On other hand, It is not possible to use the same recordset name to generate different outputs. You can handle it inside your message mapping. One option is put inside the value of "INTERFACE2 " a newline('nl').

I hope this helps you.

Regards

Ivan

Former Member
0 Kudos

Hi Ivan,

right, I did test just for sure.

Putting constant 'nl' into field CASHFLOW-INTERFACE1 didnt help - still getting one line instead two lines.

CA ,"0100" ,"7" ,"512" ,20090127GTP101 ,-12454762586.6800 ,"EUR" ,2 ,12 ,2009-01-28 ,2009-01-27 ,2009-01-28 ,"0.0000000" ,'nl' ,"GTP1" ,"7" ,"512" ,20090127GTP101 ,-12454762586.6800 ,"EUR" ,1 ,10 ,2009-01-27 ,2009-01-27 ,2009-01-27 ,"0.0000000"

So there is still question. Is there any way (mapping,...) how to output always 2 lines in text file for one record in XML. It always does 1 record in mapping structure = 1 line but we need 2 lines ...

Example:

Input: 4 records in XML

Output: 8 lines in final text file ...

Thanks to you all guys

Marian

Former Member
0 Kudos

Hi Marian,

You have not to put a constant 'nl' to must put a new line, It means include an ascii(13) inside the content of the "CASHFLOW-INTERFACE1" field.

For example this: "hi

world"; It inserts a new line between hi and world.

Regards

Ivan

Edited by: Jose Iván Reyes Arteaga on Jul 14, 2009 11:23 PM

Former Member
0 Kudos

Hi Ivan,

thanks for reply. I doesnt work.

"0.0000000"\nCA --> CASHFLOW-RENDITE

didn't create two lines

CA,"GTP1","7","512",20090127GTP101,-12454762586.6800,"EUR",2,12,2009-01-28,2009-01-27,2009-01-28,"0.0000000"\nCA,"GTP1","7","512",20090127GTP101,-12454762586.6800,"EUR",1,10,2009-01-27,2009-01-27,2009-01-27,"0.0000000"

Marian

former_member272911
Participant
0 Kudos

Hi Lousi,

Break the structure in 2lines in mapping and then endseparator as 'NL'

in the file adapter.

Thanks

kamath

Former Member
0 Kudos

Hi Kamath,

we need to see following output line one and two in pairs for ever record

Correct:

Record1 line1

Record1 line2

Record2 line1

Record2 line2

....

If I use 2 structures in mapping instead one, it will output first section with first lines and after that section with second lines.

Wrong:

Record1 line1

Record2 line1

Record3 line1

...

Record1 line2

Record2 line2

Record3 line2

...

Thanks

Marian

former_member272911
Participant
0 Kudos

Hi Louis,

What i was suggestion was something like this.

One structure in the target with 2 records probablyline1 and then line2.

Split the single line into two records which will provide you the result.

let me know if it is different

thanks

kamath

Former Member
0 Kudos

Hi Kamath,

you mean to create target mapping structure which has 2 fields instead current 26 fields and set fieldsSeparator to 'nl'?

Yes I was thinking already about that as a last option, because concatenation of all these 26 fields into new fields Line1 and Line2 would be very big and not very transparent or user friendly...

Thanks for reply

Marian

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi guys.

we did solve it by an UDF in mapping, udf was added at first fiekd of second line.

Mapping:

CONSTANT(CA) -->UDF SetLineBreak -->INTERFACE2

Udf option cache with argument A:

-


public String UDF1(String a,Container container){

//write your code here

String string = ( new StringBuffer("\n")).append(a).toString();

return string;

Thanks for your help

Cheers

Marian

Former Member
0 Kudos

hi Marian

You can try this INTERFACE.beginseparator INTERFACE.endSeparator 'nl' after this use INTERFACE2.beginseparator AND INTERFACE2.endSeparator 'nl'

Former Member
0 Kudos

Hi Luis,

thanks for your reply. Just for sure INTERFACE and INTERFACE1 are fields in structure CASHFLOW. I did try all combinations in Content Conversion on File adapter, but I´m still getting whole CASHFLOW structure in one line in text file.

Thanks

Marian

Former Member
0 Kudos

Oh I make a mistake ...Please use the Structure CASHFLOW with beginseparator (INTERFACE)