HOw to Create a Header and Trailer for a Sequential 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
reddy.cba
Premium Member
Premium Member
Posts: 27
Joined: Wed Jan 31, 2007 3:32 am
Location: sydney

HOw to Create a Header and Trailer for a Sequential file?

Post by reddy.cba »

HI Everyone,
Before posting this topic i did searched for my requirement without any luck.
can anyone help me how to create a Sequential file with a Header and Trailer(Count) in a sequential file?
My requirement would be
Header(This is a Test File)
Record 1
Record 2
Trailer 2
where Trailer 2 is the sum of all the records in the sequentail file.
Thans in Advance for your help.
Vee Yes
Man Has Created Money...Its not Money which has created Man....
Sreedhar
Participant
Posts: 187
Joined: Mon Oct 30, 2006 12:16 am

Post by Sreedhar »

Sri,

There are two methods of creating the Header and trailer to a file.

1) Manual
2) Automated

In manual process you have to manually amend the header and trailer to the file.

In an automated system send a file as in input to the system, the out come of that would be an header and trailer added to it, with the appropriate count in the trailer record.


Hope this helps you.

In most of the cases this process is automated.
Regards,
Shree
785-816-0728
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

vsripuram,

Are you pulling data from a database and loading into a sequential file?
And do you want this header and detail count in the target sequential file?
Thanks and Regards!!
dspxlearn
reddy.cba
Premium Member
Premium Member
Posts: 27
Joined: Wed Jan 31, 2007 3:32 am
Location: sydney

Post by reddy.cba »

HI All,
Thanks for your reply...
I am pulling data from Oracle and Dropping on a sequential file....
In normal scenario we would only have the data with Only the Detail records, Our requirement is to add a Header and Trailer to count the no of records in the file.
Thanks
Vee Yes
Man Has Created Money...Its not Money which has created Man....
reddy.cba
Premium Member
Premium Member
Posts: 27
Joined: Wed Jan 31, 2007 3:32 am
Location: sydney

Post by reddy.cba »

Hi sreedhar,
How do we do it manually can we hardcode the header and how do we do about counting the records and appending at the end in the trailer.
Thanks
Vee Yes
Man Has Created Money...Its not Money which has created Man....
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

One option is-

Trailer record count:
Create dummy column along with your target fields derivations. Take an aggregator and take this dummy column as an input.In the aggregator select the 'aggregation type' as 'Count Rows' and give this column as an input to this and pass the output to the target.

Eg: ORacle stage-->transformer1-->aggregator(for record count),column export(detail records)---> funnel1.

Header:
OracleStage --> transformer1(hardcode the header desc)-->funnel1

Done!
Thanks and Regards!!
dspxlearn
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Depends what has to be in them. If the header is fixed text, for example, you could set up a before-job subroutine to use echo command. The Sequential File stage in your job would then be set to append, rather than to overwrite. Similarly trailer could be an operating system command that picks up the record count written to a temporary file by the job.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply