Page 1 of 1

Adding header and footer records to a output file

Posted: Wed Sep 23, 2009 9:35 am
by swathi Singamareddygari
Hi all,

I am creating a fixed width output file in a datastage job.
I want to add the header and footer records to the output file


File format:
Header record --->will contain the record type,and source group name
Data record----->actual fixed width data
Footer record--->will contain record type and number of data records

I am doing this by using 3 links in transformer
1 link---header link
2 link---actual data
3 link---footer record

after transformer i am using funnel with sequential option so that i can get the records in the proper order

can you please tell me is there any other method to do this

Thanks for your help

Regards

Swathi S

Posted: Wed Sep 23, 2009 9:52 am
by chulett
Your method is fine. Another way is to write them to three separate files and then concatenate them together after job in the proper order.

Posted: Thu Sep 24, 2009 8:59 pm
by swathi Singamareddygari
Hi chulet,

Thanks for your reply.

I am facing problem while creting the footer record.

I have to specify constraints on the header and footer links or else i will get header and footer records as of number of detail records.

for header record i gave the constraint like @inrownum=1 so we will get only 1 header record,but for footer record i am not getting what constraint i have to give.

can any one please help me in this


Thanks for your help

Regards,

Swathi S

Posted: Thu Sep 24, 2009 9:11 pm
by chulett
Put the third link through an Aggregator to get the total count, then run that single output record to your funnel.

Posted: Thu Sep 24, 2009 10:47 pm
by laknar
create a sequence like this

ExecCommand-------LoadJobActivity-----ExecCommand-=---ExecCommand

First echo a header to the filename i.e header>Filename

In Job Activity Stage create a temperory Detail File.

third Stage Move concatenate header file into the header file

fourth stage create a footer record into the above file.

Posted: Fri Sep 25, 2009 9:50 am
by nagarjuna
Makesure that @inrownum is generating correctly with multiple nodes .

Write a before job routine

cat header > out_file

after job routine

cat footer >> output_file .

Here header n footer are static in nature .

Posted: Fri Apr 13, 2012 11:32 am
by vamsi.4a6
could anyone please correct me if i am wrong

Write a before job routine

head -1 filename.txt>out_file

after job routine

tail -1 filename.txt>>out_file

Posted: Fri Apr 13, 2012 2:47 pm
by chulett
What is this "filename.txt" of which you speak? Where do it come from?