Application Development and Automation 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: 
Read only

COLLECT&DO_SUM

sivakrishna_boddapati
Participant
0 Likes
480

Hi Experts ,

in my internal table i have one field i.e number of times initially thats value is 1 if all vales(row) in the table are same then it will be incremented by 1 . my requriemnet is instead of using COLLECT i use DO_SUM = 'X' in that final table field cat , it shows dump , so can any one explain how to use DO_SUM instead of COLLECT.

Thanks & Regards

Siva

2 REPLIES 2
Read only

Former Member
0 Likes
436

DO_SUM='X' can be used in the field catalog definition if the column data type is numeric. check data type of your column

Eg:

clear wa_fieldcat.

wa_fieldcat-fieldname = 'DMBTR'.

wa_fieldcat-seltext_m = 'Doc Amount'.

wa_fieldcat-do_sum = 'X'.

append wa_fieldcat to it_fieldcat.

Regards

Vinod

Read only

Former Member
0 Likes
436

HI,

if you want to do a subtotal in alv ,

follow these steps.

1) sort on the field which u require subtotal

REFRESH it_sort.
  wa_sort-spos = '1'.                               "sort position
  wa_sort-fieldname = 'ORGEH'.              " field on which u want the subtotal
  wa_sort-down        = 'X' .                      " ascending or descending
  wa_sort-subtot    = 'X'.
  APPEND wa_sort TO it_sort.
  CLEAR wa_sort.

in the example i want a subtotal for each organisation unit ( orgeh) is afield in my internal table here

wa_fcat-col_pos   = '12'.
  wa_fcat-tabname = 'IT_OUTPUT'.
  wa_fcat-fieldname = 'BET02_NET_PAY'.
  wa_fcat-seltext_m = 'NET PAY'.
  wa_fcat-do_sum =   'X'.
append wa_Fcat To it_fcat
clear wa_Fcat

.

i want the total for this field in the internal table (BET02_NET_PAY)

just pass do_sum = 'X' in the fieldcatalog in your alv.