[ask] duplicate output

benedictine191

New Member
hi all,may i ask about ih_hist....
i build a report which display sales output per period...
but when i display it to page..their invoice date has duplicate from 1 item to 8 same items.

Code:
FOR EACH ih_hist WHERE ih_domain = GLOBAL_domain AND ih_nbr >= nbr AND ih_nbr <= nbr1 AND ih_ship >= shto and ih_ship <= shto1  
    and ih_inv_date >= ord and ih_inv_date <= ord1  NO-LOCK BREAK BY ih_ship :
    
FIND FIRST ad_mstr WHERE ad_domain = GLOBAL_domain AND ad_addr = ih_ship NO-LOCK NO-ERROR.

CREATE det.
ASSIGN
    ihnbr = ih_nbr.
    ****o = ih_ship.
    nmstor = ad_name .
    ord = ih_inv_date.
    ord1 = ih_inv_date.  
 
END. 
PUT SKIP(2).

PUT "LAPORAN KOMISI GAJI" AT 50 SKIP
    "===================" at 50 skip(2).
PUT "STORE         :" at 9 SPACE(2) nmstor FORMAT "x(50)" 
    "Periode : " at 96 ord format "99/99/9999"  "Sampai : " at 96 ord1 format "99/99/9999" SKIP. 
PUT "ATAS NAMA :" at 9 SPACE(2) dibuat FORMAT "x(30)".

PUT SKIP(1).

FOR EACH ih_hist WHERE ih_domain = GLOBAL_domain AND ih_nbr >= nbr AND ih_nbr <= nbr1 
and ih_ship >= shto and ih_ship <= shto1 
and ih_inv_date >= ord and ih_inv_date <= ord1  NO-LOCK : 

    for each idh_hist where idh_domain = global_domain and idh_nbr = ih_nbr no-lock :
 
       DISPLAY
            space(8) 
            ih_inv_date LABEL "TGL."        
            ih_invoicetotal FORMAT "->>>,>>>,>>9.99" LABEL "SALES" WITH width 120.
    end.
jml = jml + ih_invoicetotal.
tot = totc + tran.
end.
to make it clearly....here i add the printscreen as attachment

the question is : how to make it right (1 invoice date as output only)..sory if my english so bad...thanks
 

Attachments

  • untitled.JPG
    untitled.JPG
    36.9 KB · Views: 50

DivyaRajesh

New Member
It should be like this - each ih_hist will have multiple idh_hist records....

FOR EACH ih_hist WHERE ih_domain = GLOBAL_domain AND ih_nbr >= nbr AND ih_nbr <= nbr1
and ih_ship >= shto and ih_ship <= shto1
and ih_inv_date >= ord and ih_inv_date <= ord1 NO-LOCK :


DISPLAY
space(8)
ih_inv_date LABEL "TGL."
ih_invoicetotal FORMAT "->>>,>>>,>>9.99" LABEL "SALES" WITH width 120.

for each idh_hist where idh_domain = global_domain and idh_nbr = ih_nbr no-lock :
.....
.....
....
end.
end.


Rgds,
Divya
 
as your wanting, I can give your some advice.
you should define a temp table for storing data which you want to total by different DATE at first,
then you can FOR EACH your temp table and list table content .
 

lig.qad

New Member
Aside any other reasons... first of all, ih_hist is not unique on ih_nbr... multiple invoices can be generated from same SO number. Domain aside, the connection between ih_hist and idh_hist must include both _nbr and _inv_nbr. None of them, alone would suffice. Here is an example...

for each ih_hist no-lock:
disp
ih_nbr
ih_ship
with frame x down.
for each idh_hist no-lock
where idh_nbr = ih_nbr
and idh_inv_nbr = ih_inv_nbr:
disp
idh_line idh_part idh_qty_inv
with frame y down.
end.
end.

Second, you should be printing the "store" in the same for each as where you are looking... the fact you state "BREAK BY" does not mean it will only show once; you need to ask (if first-of... or the like); break-by has a performance issue...

This program, as is, would print first all sites and then all invoice amounts...

You did not clarify the spec of the report... if you want to print for a given period or range of dates or produce a report the sales separated per period... if this is the second case, then I would also suggest using a temp-table to total per period. There is no index on "ih_ship" (there is on ih_cust and ih_inv_date)... assuming it is show all sales of a given site, per calendar period within a range of dates... the "simplest" code would be... not necessarily the most effective:

for each ih_hist no-lock
where ....
break by ih_ship by year(ih_inv_date) by month(ih_inv_date) by idh_inv_date:
if first-of(ih_ship) then do:
get address, print, reset variable totalling sales for ih_ship.
end.
for each ih_hist no-lock where ih_domain = global_domain and idh_nbr = ih_nbr and idh_inv_nbr = ih_inv_nbr:
assign
v-tot-day = v-tot-day + idh_qty_inv * idh_price
v-tot-per = v-tot-per + idh_qty_inv * idh_price
v-tot-ship = v-tot-ship + idh_qty_inv * idh_price.
end.
if last-of(ih_inv_date) then do:
display total for day, reset var to zero.
end.
if last-of(month(ih_inv_date)) then do:
display total for month, reset var to zero.
end.
if last-of(year(ih_inv_date)) then do:
display total for month, reset var to zero.
end.

etc... etc..

end.
 
Top