Sequential file validation question

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
jrawsterne
Participant
Posts: 4
Joined: Wed Oct 13, 2004 8:56 am
Location: UK

Sequential file validation question

Post by jrawsterne »

We need to receive a sequential file in the following format:

File Header Record
Item Header Record
Item Detail Record
Item Detail Record
Item Detail Record
Item Header Record
Item Detail Record
Item Detail Record
Item Header Record
Item Detail Record
Item Header Record
Item Detail Record
Item Detail Record
Item Detail Record
etc...
File Trailer Record

We need to validate all the detail lines for each item header. If an error is found we want to move the item header and the associated detail records to an error file. The valid records should continue to the next stage of processing. What's the best way to do this?

Thanks in advance
JR
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You really should have either posted this on the Server forum or indicate that it's a parallel job. Which engine it is will govern the answer.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jrawsterne
Participant
Posts: 4
Joined: Wed Oct 13, 2004 8:56 am
Location: UK

Apologies...

Post by jrawsterne »

Slip of the finger. It is a parallel job.
Thanks
JR
T42
Participant
Posts: 499
Joined: Thu Nov 11, 2004 6:45 pm

Post by T42 »

Quick and dirty method - Do it in two jobs:

1. First job - Place key fields from Item Header Record to every record immediately afterward. You will need to run this transformer in sequential mode to prevent any partitioning. You can use the Stage Variables to handle the awareness of the header records. For all records that are rejected, output just the header's key fields to an output source you can read later. Output records INCLUDING the header key field to another output source.

2. From the actual data, do a lookup (or Join/Merge, dependent on size of rejects you expect to see). For matches, output records to reject file without the key fields. For non-matches, do whatever you want with it.

Enjoy.
Andet
Charter Member
Charter Member
Posts: 63
Joined: Mon Nov 01, 2004 9:40 am
Location: Clayton, MO

Post by Andet »

I thought of two ways:

1. Cycle the records through a transformer, and use staging variables to hold the information from prior records to compare against current records.

2. Split the file into two streams, one of header records and one of detail - send the detail through transformer/aggregator and merge the streams using a lookup, compare, or whatever you prefer.

Good luck!

Ande
Post Reply