Page 1 of 1

Validate No of Records

Posted: Sun Aug 12, 2007 7:31 pm
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.

Posted: Sun Aug 12, 2007 8:20 pm
by ray.wurlod
Use a before-job subroutine.
Use OpenSeq, a loop containing ReadSeq statements, and CloseSeq.

Posted: Mon Aug 13, 2007 12:36 am
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)

Posted: Mon Aug 13, 2007 3:28 am
by cosec
Thanks for the input..shall try and see if its successful