Display statement issues

Ross Stanek

New Member
I am trying to total up some sales and costs. I know that I can use the TOTAL in an aggregate phrase for this but I then want to take that TOTAL sales and TOTAL cost and calculate a TOTAL Gross Profit %. How could I accomplish this. I tried just not using the TOTAL thing and created some variables that did the totaling and the calculation but then the display doesn't look right. I need help with either:

1) Some phrase that lets you display a % of a calculated field. or

2) Be able to use 2 display statements for one for each (do not even know if possible).

Some of my code is below:

def var d1 like ordetail.inv-date label "Begin Date".
def var d2 like ordetail.inv-date label "End Date".
def var totret as deci.
def var totcost as deci.
update d1 d2.
output to /flynns/accounting/gpinfo2.txt.
for each ordetail no-lock where inv-date ge d1 and inv-date le d2 and od-cat = 'nst' and line-type = 5 break by opven# by descr by location.
totret = totret + net-ext.
totcost = totcost + ext-cost.
display
OPven# column-label "Vendor"
location label "Loc"
salesman#1 label "Slsman"
invoice# label "Inv#"
inv-date label "Date"
item# label "Item #"
descr column-label "Description"
net-ext label "Retail" /* also used the TOTAL phrase for these*/
ext-cost label "Cost" /* also used the TOTAL phrase for these*/
(net-ext - ext-cost) label "Profit" /* also used the TOTAL phrase for these*/
((net-ext - ext-cost) / net-ext) * 100 label "GP%" format ">>,>>>.99-%"
with width 245.
if LAST-OF(opven#) THEN DO:
display skip(1) space(86) "--------- --------- -------- ---------" skip(1) space(85) totret no-label totcost no-label space(1) (totret - totcost) ((totret - totcost) / totret) * 100 format ">>,>>>.99-%" skip (1).
totret = 0.
totcost = 0.
END.
END.

Thanks,

Ross:confused:
 
Back
Top