CR 8.5; SQL Server 2000
I have a report that prints out line items for an order: line number, item number, description, qty, and weight. Occasionally, there are detail comments that get associated with a line number/item. But the comments come in separate lines: line 2, item A, may have 3 SEPARATE detail comment lines attached to it. So I get duplicate lines printing. By watching the change of line number, and using the item to check the EOF, I can print the details only once, and capture all the comments.
Problem is summing the weights. Can’t underlay, or suppress, since it still sees the “hidden” weights when summing. The formula below captures the individual weights, but adds in the last weight once too often: the result is consistently over by the last item in the report:
So if I have:
Line Item Qty Wt
1 23 4 10
2 26 3 13
3 36 12 37
comment
comment
comment
4 18 2 12
TOTAL WT: 84 (instead of 72).
Any suggestions as to how to get a correct total would be appreciated.
I have a report that prints out line items for an order: line number, item number, description, qty, and weight. Occasionally, there are detail comments that get associated with a line number/item. But the comments come in separate lines: line 2, item A, may have 3 SEPARATE detail comment lines attached to it. So I get duplicate lines printing. By watching the change of line number, and using the item to check the EOF, I can print the details only once, and capture all the comments.
Problem is summing the weights. Can’t underlay, or suppress, since it still sees the “hidden” weights when summing. The formula below captures the individual weights, but adds in the last weight once too often: the result is consistently over by the last item in the report:
So if I have:
Line Item Qty Wt
1 23 4 10
2 26 3 13
3 36 12 37
comment
comment
comment
4 18 2 12
TOTAL WT: 84 (instead of 72).
Code:
WhilePrintingRecords;
numberVar iWeight ;
numberVar sumWeight;
iWeight :={t_item_master.unit_weight} * {t_hu_detail.planned_qty}; [COLOR=red]//Calcs Weight[/color red]
if not NextIsNull ({t_hu_detail.item_number}) then [COLOR=red]// finds EOF[/color red]
(if{t_hu_detail.line_number} = Next ({t_hu_detail.line_number}) then [COLOR=red]// chk for dupe[/color red]
iWeight := 0
else
iWeight);
sumWeight := sumWeight + iWeight;
iWeight;
Code:
WhilePrintingRecords;
numberVar sumWeight ;
sumWeight;
Any suggestions as to how to get a correct total would be appreciated.