Adding header and footer records to a output 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
swathi Singamareddygari
Participant
Posts: 48
Joined: Fri Feb 29, 2008 1:09 am
Location: Bangalore

Adding header and footer records to a output file

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
swathi Singamareddygari
Participant
Posts: 48
Joined: Fri Feb 29, 2008 1:09 am
Location: Bangalore

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Put the third link through an Aggregator to get the total count, then run that single output record to your funnel.
-craig

"You can never have too many knives" -- Logan Nine Fingers
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post 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.
Regards
LakNar
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post 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 .
Nag
vamsi.4a6
Participant
Posts: 334
Joined: Sun Jan 22, 2012 7:06 am
Contact:

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What is this "filename.txt" of which you speak? Where do it come from?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply