check lines amount with total amount

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
sb_akarmarkar
Participant
Posts: 232
Joined: Fri Sep 30, 2005 4:52 am
Contact:

Post by sb_akarmarkar »

Use stage variable to calulate ......................


Thanks,
Anupam
kjaouhari
Participant
Posts: 325
Joined: Thu Mar 16, 2006 10:22 am

Post by kjaouhari »

Thanks all,

but I had to precise that col1 is a column and amount to.
(I have two column)
a sample of my file :
('06' = lines and '08' = total)
------------------------------------------
col1 amount
06 25
06 15
06 05
08 45 (correct amount 25+15+05 = 45)
06 15
08 10 (incorrect total must be 15 )
-------------------------------------------

Thanks ArndW, but I think your solution is just for one column, is it ?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You changed your metadata since the first post. Instead of my 2 stage variables, just use your two columns, otherwise the solution is the same.
kjaouhari
Participant
Posts: 325
Joined: Thu Mar 16, 2006 10:22 am

Post by kjaouhari »

I think it's more complicated because in your example you don't check if each total '08' = total lines '06'

I'm creating a routine to check this because I have to check 2 sequence :
The first to know if it's the same article
The second to check total '08' = total lines '06'

I let you know !
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

You can still use this code with small modificaiton.

Code: Select all

vRunningTotal = 0 --> InitialDeclaration.

vCorrectFlag => If Type = '08' Then if Amount = vRunningTotal Then "Correct" Else False Else ''
vRunningTotal =>IF Type='06' THEN RunningTotal+Value ELSE 0 
You havnt mentioned what to do after checking the total with the amount.
You can intoduce a new column callled CorrectFlag. And assign stage variable vCorrectFlag to it.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Post Reply