Page 1 of 1

Adding Header and Trailer to file

Posted: Wed Oct 30, 2013 4:32 am
by prasson_ibm
Hi,

I got a requirment where i am getting a flat file and i need to add header and trailer to that file which later ftped to another server.

I designed a job like this.

Code: Select all

Header -------------------->

Sequential file -----------> 

Trailer----------------------> Funnel(Sequence) -------->Target File

Here i am facing a issue.When i am running this funnel in parallel header is not coming on top rather in between the data but trailer is always in the bottom.

When i tested with running funnel in sequence mode,it giving me desired output like

Header
Data
Trailer

My file is 2GB so i dont think its good practice to run funnel in sequence mode.Can anyone help me to resolve it or is there any other way to do this.

Posted: Wed Oct 30, 2013 5:40 am
by ArndW
Explicitly make the Header, Trailer and Funnel stages run sequentially.

Posted: Wed Oct 30, 2013 6:42 am
by patpicos
you can create 3 separate sequential files, then use unix commands to concatenate them

cat header.txt body.txt trailer.txt > target.txt

Posted: Wed Nov 13, 2013 8:30 am
by FranklinE
I recommend using a job sequence to run the write steps in sequential order:

Code: Select all

Write header, file mode overwrite.

Write details, file mode append.

Write trailer, file mode append.
This helps avoid the problem of forcing high-volume processing into sequential mode.

Posted: Wed Nov 13, 2013 8:58 am
by prasson_ibm
Thanks FranklinE!

Its better idea. :wink:

Posted: Wed Nov 13, 2013 11:40 pm
by asorrell
As a side note, if the header and trailer are "static" (never change), then you can easily use before and after job ExecSh commands to do this with one job.

1) Before job creates the file by copying the header or "echoing" it to a file.
2) Job appends data to the file
3) After job uses cat >> to append the trailer.

Posted: Thu Nov 14, 2013 12:59 am
by prasson_ibm
No,Header and trailer is changing in every job run.