Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Sub Total in classical report..........

Former Member
0 Kudos
252

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos
181

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

5 REPLIES 5

Former Member
0 Kudos
179

Before this loop Apply sort on that Internal table.

awrd points if useful

Bhupal

Former Member
0 Kudos
179

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.

prasanth_kasturi
Active Contributor
0 Kudos
179

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

Former Member
0 Kudos
182

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

Former Member
0 Kudos
179

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