Need help in Logic through Stage Variables

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Pavan_Yelugula
Premium Member
Premium Member
Posts: 133
Joined: Tue Nov 23, 2004 11:24 pm
Location: India

Need help in Logic through Stage Variables

Post by Pavan_Yelugula »

Hi All
I have a input file in the following format
profile|2007|2
1|1|1|1
2|2|2|2
profile|2007|2

The header and footer needs to be the same and the count of the files given in the header should match with the actual number of rows

I am trying to achieve this in a single transformer.
I am holding the first row in a stage variable and comparing it with the row that comes in as specified in the header.

Code: Select all

IF (@INROWNUM = (Field(svHEADER,'|',3) +2)) THEN (IF svINPUTROW = svHEADER
so in the above example i will be comparing the header and the footer and passing the file.
Suppose if the file comes like this
profile|2007|1
1|1|1|1
2|2|2|2
profile|2007|1

The logic is taken care as the header is compared with 2|2|2|2...The process aborts as the data in the rows didn't match

The problem is i overlooked the scenario if the file comes as follows
profile|2007|100
1|1|1|1
2|2|2|2
profile|2007|1

I am trying to fit the logic for this and working all around without success.

Any advice will be really helpful

Thanks
Pavan
boxtoby
Premium Member
Premium Member
Posts: 138
Joined: Mon Mar 13, 2006 5:11 pm
Location: UK

Post by boxtoby »

It's not quite clear to me exactly what you're doing with the stage variables in the stage, but here's one approach you can try:

Assuming you can detect header, detail and trailer records which might be a little tricky as they header and trailer appear rather similar!, here's the logic:


Detect the header, store any values you want from the header in SVs. Zeroise the detail record count.

Detect detail record and add one to the count for each record.

Detect the trailer and compare the header, trailer and detail record counts.


It's slightly more fiddly than I'm making out, but I followed this path in the past with success.

Btw, why have you got the record count in the header and footer?

Hth
Bob.
Bob Oxtoby
Pavan_Yelugula
Premium Member
Premium Member
Posts: 133
Joined: Tue Nov 23, 2004 11:24 pm
Location: India

Post by Pavan_Yelugula »

Hi Bob
The header and footer contains the record count because we don't want to process files which have a different actual count of records from the number specified in the header.

I guess i am doing the same as you suggested in the stage variables but the only mess up is when the count in the header exceeds the count of actual records. i wonder if it can be done in a single job with a single transformer as we don't have a facility to find the last row

Thanks
Pavan
Post Reply