how to Create header, detail and trailer record in a file using talend
Hi,
I have N no of records in a table and write it into a positional file which has the following format:
Header record layout
-------------------------
currentdate 1-6
Detail record layout
------------------------
ename 1-10
esal 11-18
trailer layout
-----------------
Totalsal 1-10
sample output file
--------------------
2011-24-05
ganesh 0001000
shong 0002000
00003000
So my output file is, one header entry, one trailer entry and multiple detail entries.
Hi
The job looks like:
extract the header data from a data source or use the tFixedFlowInput to define the header data --main-->tFileOutputPositional_1
|
onsubjobok
|
extract the Detail data from a data source or use the tFixedFlowInput to define the header data--main---tFileOutputPositional_2(write the records into the same file and check the option 'Append')
|
onsubjobok
|
extract the trailer data from a data source or use the tFixedFlowInput to define the header data--main---tFileOutputPositional_3(write the records into the same file and check the option 'Append')
Best regards
Shong
Thanks for your valuable suggestions. I need a output file which has the following format:
Main Header (1st line)
Batch Header(2nd Line)
Record1 (3rd line)
Record 2 (4th line)
.
.
.
Record N (n+4th line)
Batch Trailer(n+5th line)
Batch Header(n+6th line)
Record1 ((n+7th line)
Record 2 (n+8th line)
.
.
.
Record N
Batch Trailer
FileTrailer(last line)
Main Header - contains the current date
Batch header - sequence number ( 1 for Header 1)
record - amount (fetch from db)
Batch trailer - (Batch Amount Total)
File Trailer - (File Amount Total)
N - no of records in a batch
Ex:
---
23/11/2011
1 (Batch No)
12 (record1)
8 (record2)
20 (Batch1 Amount Total)
2(Batch No)
30 (record3)
20 (record4)
50 (Batch2 Amount Total)
70 (File Amount overall Total)
Please reply ASAP. Thanks in advance.
Hi
I have replied you and give an example job in previous post, have you tried to create the job? Do you understand the 'append' option?
Best regards
Shong