Hi
I have a loop in my code which goes through each job and extracts the relevant information for labour. there is a temp table which gets populated so that data can be outputted called ptjobs.
But the problem i have is that when adding the labour quantity together it loop sthrough 9 times for the same value and then moves onto the next.
example i have a job number 1234e this has 9 labour quantities against it. these have to be accumulated for each job number. but it finds the first value and adds that 9 times and then gets the next value and adds that 9 times why would this be???
Heres my code:
FOR EACH job WHERE
job.kco = 1 AND
job.comp-date ge jp-start AND
job.comp-date le jp-end NO-LOCK,
EACH labour WHERE
labour.kco = 1 AND
labour.kjobcode = job.kjobcode AND
labour.kdeptsn begins "24" AND
(labour.koper = "14") NO-LOCK, /* removed 9 as run on has metr~
es */
EACH blab where bLab.kco = labour.kco and
bLab.kjobcode begins labour.kjobcode and
(bLab.koper = "14" or
bLab.koper = "9") and
bLab.kdeptsn begins "21" no-lock,
EACH ptjobs WHERE
ptjobs.pt-docket = job.kjobcode :
find jpwid where jpwid.kco = 1 and jpwid.kjobcode = job.kjobcode ~
no-lock no-error.
IF labour.ktt lt 501 OR labour.ktt gt 510 THEN NEXT .
ASSIGN
ptjobs.pt-labquantity = ptjobs.pt-labquantity + labour.qty.
I have a loop in my code which goes through each job and extracts the relevant information for labour. there is a temp table which gets populated so that data can be outputted called ptjobs.
But the problem i have is that when adding the labour quantity together it loop sthrough 9 times for the same value and then moves onto the next.
example i have a job number 1234e this has 9 labour quantities against it. these have to be accumulated for each job number. but it finds the first value and adds that 9 times and then gets the next value and adds that 9 times why would this be???
Heres my code:
FOR EACH job WHERE
job.kco = 1 AND
job.comp-date ge jp-start AND
job.comp-date le jp-end NO-LOCK,
EACH labour WHERE
labour.kco = 1 AND
labour.kjobcode = job.kjobcode AND
labour.kdeptsn begins "24" AND
(labour.koper = "14") NO-LOCK, /* removed 9 as run on has metr~
es */
EACH blab where bLab.kco = labour.kco and
bLab.kjobcode begins labour.kjobcode and
(bLab.koper = "14" or
bLab.koper = "9") and
bLab.kdeptsn begins "21" no-lock,
EACH ptjobs WHERE
ptjobs.pt-docket = job.kjobcode :
find jpwid where jpwid.kco = 1 and jpwid.kjobcode = job.kjobcode ~
no-lock no-error.
IF labour.ktt lt 501 OR labour.ktt gt 510 THEN NEXT .
ASSIGN
ptjobs.pt-labquantity = ptjobs.pt-labquantity + labour.qty.