Validate No of Records

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
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Validate No of Records

Post by cosec »

Hi,

I am reading a fixed width sequential file with a header and footer....The footer gives the number of rows in the file.

I would like the first step of the job to validate if the number of rows of data in the file match the number of rows in the footer...If it is correct I would like it to process and if it fails I would like it to abort.

Is there a way to do this ? if so please elaborate...thank you.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use a before-job subroutine.
Use OpenSeq, a loop containing ReadSeq statements, and CloseSeq.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

If you have MKS Toolkit installed (Which Ships and installs with version 7.5x2) you can try the below described:

Do the file sanity validation before calling the job :

Use 2 Execute_Command stages in your main sequence to get the number of lines and value at last line using below commands:

Code: Select all

For total line number - wc -l < Filename
For Footer value - tail -n 1 Filename

Use a sequencer stage in 'All' mode and then put a Nested Condition stage which will have 2 triggers

Code: Select all

Success(Conditional) - (Trim(LineNo.$CommandOutput,@FM,'')) = Trim(Footer.$CommandOutput,@FM,'') 

Note: If your footer value is excluding header and footer lines count then minus 2 as shown below
Success(Conditional) - (Trim(LineNo.$CommandOutput,@FM,'') - 2) = Trim(Footer.$CommandOutput,@FM,'') 

Fail - Otherwise (NA)
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>
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

Thanks for the input..shall try and see if its successful
Post Reply