Add header and trailer to a 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
kpsita
Participant
Posts: 99
Joined: Tue Jul 21, 2009 11:43 pm

Add header and trailer to a file

Post by kpsita »

Hi,

How do I add header and trailer record to a file. My header record is run date and the trailer record is number of records.

I searched in the forum and found a method to create 3 files and then cat all the files.Is there any other option in version 8 or can it be done in datastage?

Thanks
KPSITA
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

Couple of ways:

1. Create your header as part of before job subroutine, append the data to the flat file in your job and create the trailer in the after job subroutine.

2. Have a Transformer with three output links going into a Funnel Stage. Select sequential operation within your funnel stage. Create your header and trailer records in two links and output the data through the other link. Write the output of the funnel to a flat file.
Kris

Where's the "Any" key?-Homer Simpson
kpsita
Participant
Posts: 99
Joined: Tue Jul 21, 2009 11:43 pm

Post by kpsita »

Thanks for your suggestion.

On your first method, when you say before and after, should I actually execute unix command to create a header file.

Thanks
KPSITA
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

Yes. you need to use UNIX commands. But you don't have to create a header file separately. You can create the header and write it to the output file. In the parallel job, set your Update to Append rather overwrite within the sequential file and in the after job, create your trailer record and append it to the sequential file again.
Kris

Where's the "Any" key?-Homer Simpson
Post Reply