Page 1 of 1

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

Posted: Sun Mar 25, 2007 10:58 pm
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

Posted: Sun Mar 25, 2007 11:12 pm
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.

Posted: Sun Mar 25, 2007 11:31 pm
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?

Posted: Sun Mar 25, 2007 11:42 pm
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

Posted: Sun Mar 25, 2007 11:45 pm
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

Posted: Sun Mar 25, 2007 11:54 pm
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!

Posted: Mon Mar 26, 2007 5:14 am
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.