2008 May 30 7:54 AM
Hi Experts,
I am using calassical report in which i want a subtotal.
Example :
X
a 3
b 2
Subtotal : 5.
Y
a 4
b 5
Subtotal : 9
Report is OK but subtotal is not comming. Pl. see my loop and guide me. I want subtotal of itab_out-typedesc feild.
LOOP AT itab_out.
ON CHANGE OF itab_out-typedesc.
FORMAT COLOR COL_TOTAL.
WRITE:/1 sy-vline, 5 itab_out-typedesc, 130 sy-vline.
WRITE:/1 sy-vline, 5 '===============', 130 sy-vline.
FORMAT COLOR OFF.
ENDON.
ON CHANGE OF itab_out-srno.
ULINE.
FORMAT INTENSIFIED ON.
FORMAT COLOR COL_NORMAL.
WRITE :/1 sy-vline, 5 itab_out-matkl, 15 itab_out-desc.
WRITE : 63 itab_out-dailyqty LEFT-JUSTIFIED DECIMALS 0.
WRITE : 100 itab_out-erfmg LEFT-JUSTIFIED DECIMALS 0.
WRITE : 130 sy-vline.
FORMAT COLOR OFF.
AT END OF typedesc.
WRITE :/1 'Sub-Total :'.
ENDAT.
AT LAST.
ULINE.
SUM.
FORMAT INTENSIFIED ON.
FORMAT COLOR COL_POSITIVE ON.
WRITE:/1 sy-vline, 20 'Total : ' , itab_out-dailyqty UNDER 'Mfg. Qty.' LEFT-JUSTIFIED DECIMALS 0.
WRITE: itab_out-erfmg UNDER 'Cumm. Qty.' LEFT-JUSTIFIED DECIMALS 0.
WRITE: 130 sy-vline.
FORMAT INTENSIFIED OFF.
FORMAT COLOR OFF.
ULINE.
ENDAT.
ENDON.
Yusuf
2008 May 30 8:07 AM
Hi,
this is a suggestion:
try to avoid ON CHANGE OF . as sometimes it will produce unexpected results.
try to use AT NEW, AT END, based on ur requirement.
make sure u SORT the internal table with correct fields( ie fields used in control break statements) .
regards,
madhu
2008 May 30 8:03 AM
Before this loop Apply sort on that Internal table.
awrd points if useful
Bhupal
2008 May 30 8:05 AM
Hi ,
Try this in your code.
AT END OF typedesc.
SUM
WRITE :/1 'Sub-Total :',itab_out-srno .
ENDAT.
Regards,
Vishvesh
if helpful, rewards it.
2008 May 30 8:07 AM
hi,
you used sun keyword in AT LAST but it will be execute only at the last pass of the loop
so use it in the at end of
and also its better to use sort statemnt
2008 May 30 8:07 AM
Hi,
this is a suggestion:
try to avoid ON CHANGE OF . as sometimes it will produce unexpected results.
try to use AT NEW, AT END, based on ur requirement.
make sure u SORT the internal table with correct fields( ie fields used in control break statements) .
regards,
madhu
2008 May 30 8:24 AM
Hi
remove ON CHANGE OF. Instead use AT NEW.
it is not required when using AT NEW and AT END OF .
try this...
AT END OF typedesc.
SUM.
WRITE :/1 'Sub-Total :',itab_out-typedesc .
ENDAT.
reward if useful
Edited by: Srikanth Kadiyala on May 30, 2008 9:27 AM