Split Records

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
rafidwh
Participant
Posts: 179
Joined: Mon Oct 10, 2005 11:30 pm

Split Records

Post by rafidwh »

Hi All,

I need to take only detail record from a file which has header and trailer also and it is a fixed width file.

record format is

Header

Record Type Alphanumeric 1 1 A - header record
File Create Date and Time Alphanumeric 26 2 - 27 Date and time file created
Filler Alphanumeric 123 28 - 150 Not Use



Detail Records follows



Trailer Record


Record Type Alphanumeric 1 1 T - trailer record
Record Count Numeric 10 2 - 11 Count of detail records
Filler Alphanumeric 139 12 - 150 Not Used


I need to read only the detail.What is the best logic to reado nly detail records form this file.


Your suggestions are most helpful

Regards,
Saik.
Raghavendra
Participant
Posts: 147
Joined: Sat Apr 30, 2005 1:23 am
Location: Bangalore,India

Post by Raghavendra »

You can use a shell script in before job subroutine to remove header and trailer records from the file and read only the detail records.
Raghavendra
Dare to dream and care to achieve ...
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

In the 'filter' option of your sequential file stage use the below code and try

Code: Select all


sed -e '$d' -e '1d'

Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
rafidwh
Participant
Posts: 179
Joined: Mon Oct 10, 2005 11:30 pm

Post by rafidwh »

Hi George can you please how it removes header and trailer or read only detail records
rafidwh
Participant
Posts: 179
Joined: Mon Oct 10, 2005 11:30 pm

Post by rafidwh »

The header record is of length 150
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

Did you try? Sed is an Unix command, you will find details about that command if you search. Above code will remove the first and last line from the input stream feeding to datastage.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
stefanfrost1
Premium Member
Premium Member
Posts: 99
Joined: Mon Sep 03, 2007 7:49 am
Location: Stockholm, Sweden

Post by stefanfrost1 »

I did a similar thing reading files with a header and trailer line, header was send information and trailer no of records sent information.

I read everything as one column varchar (with appropriate length to capture all data on a line). Then i passed it into a transformer where i put the first line into a stage variable, counted each record and converted them (excluding first and last record) a schema and sent them done a link. Then when the last line occured (i could spot this in the data for that line (special char)). I parsed that line for a no of records sent count and compared it to my record count in the transformer and if it wasnt the same i sent a record done a new link with constraint to fail job!

This worked out great as a way to vaildate file deliveries at the same time as converting them to a useable schema and format.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If the header and trailer are differently structured to detail records, they can be captured using the Sequential File stage's reject link. They can be parsed subsequently, if desired, using a Column Import stage.
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