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.
Split Records
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 147
- Joined: Sat Apr 30, 2005 1:23 am
- Location: Bangalore,India
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
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>
<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>
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
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>
<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>
-
- Premium Member
- Posts: 99
- Joined: Mon Sep 03, 2007 7:49 am
- Location: Stockholm, Sweden
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.
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.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.