Page 1 of 1

Add header and trailer to a file

Posted: Thu Sep 16, 2010 7:22 pm
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

Posted: Thu Sep 16, 2010 8:01 pm
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.

Posted: Thu Sep 16, 2010 8:34 pm
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

Posted: Thu Sep 16, 2010 8:47 pm
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.