Help with this logic

rmdasari

Member
Hi :

I am trying to use ih_hist and idh_hist and trying to get the total sales orders (idh_nbr) but the total is not correct.

Could you please go through the below code and let me know what's wrong :

for each ih_hist where ih_ord_date >= dt and ih_ord_date <= dt1
and ih_userid >= fusr and ih_userid <= tusr no-lock
break by ih_userid + string(ih_ord_date) by ih_ord_date by ih_inv_nbr :
iusr = ih_userid.
idt = ih_ord_date.
for each idh_hist where idh_inv_nbr = ih_inv_nbr and idh_qty_inv > 0
break by idh_inv_nbr :
il = il + 1.
iv = iv + (idh_qty_inv * idh_price).
if last-of(idh_inv_nbr) then i = i + 1.
end.
if last-of(ih_userid + string(ih_ord_date)) then do:
find first so_inv where susr = iusr and sdate = idt exclusive-lock no-error.
if available so_inv then do:
sinv = i.
sinvline = il.

Thanks & Regards,

Ramamurthy Dasari
 
for each idh_hist where idh_inv_nbr = ih_inv_nbr
and idh_nbr = ih_nbr
and idh_qty_inv > 0
break by idh_nbr by idh_inv_nbr :
il = il + 1.
iv = iv + (idh_qty_inv * idh_price).
if last-of(idh_nbr) then
i = i + 1.
end.

Note: idh_nbr is part of index.
 
Top