Adding Header and Trailer to file

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
prasson_ibm
Premium Member
Premium Member
Posts: 536
Joined: Thu Oct 11, 2007 1:48 am
Location: Bangalore

Adding Header and Trailer to file

Post 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.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Explicitly make the Header, Trailer and Funnel stages run sequentially.
patpicos
Participant
Posts: 2
Joined: Wed Oct 30, 2013 6:39 am

Post 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
FranklinE
Premium Member
Premium Member
Posts: 739
Joined: Tue Nov 25, 2008 2:19 pm
Location: Malvern, PA

Post 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.
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson

Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
prasson_ibm
Premium Member
Premium Member
Posts: 536
Joined: Thu Oct 11, 2007 1:48 am
Location: Bangalore

Post by prasson_ibm »

Thanks FranklinE!

Its better idea. :wink:
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post 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.
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
prasson_ibm
Premium Member
Premium Member
Posts: 536
Joined: Thu Oct 11, 2007 1:48 am
Location: Bangalore

Post by prasson_ibm »

No,Header and trailer is changing in every job run.
Post Reply