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

Do_sum not working for Quantity field

Former Member
0 Likes
2,090

Hi,

Can any one Suggest me how to get total for Quantity field in ALV as Do_sum is not working.

And in my report there is no Unit field also.so i need to add all the quantities irrespective of unit.

I checked with Do_sum = 'X'.It is not working.

Thanks,

Suresh.

6 REPLIES 6
Read only

Former Member
0 Likes
1,044

Hi,

then what about this.., here it is working for me just check it.

report  ztest_alv_check     message-id zz           .

type-pools: slis.
data: x_fieldcat type slis_fieldcat_alv,
      it_fieldcat type slis_t_fieldcat_alv,
      l_layout type slis_layout_alv,
      x_events type slis_alv_event,
      it_events type slis_t_event.

data: begin of itab occurs 0,
      vbeln like vbak-vbeln,
      posnr like vbap-posnr,
      <b>ZMENG like vbap-ZMENG,</b>
     end of itab.

select vbeln
       posnr
       zmeng
       from vbap
       up to 20 rows
       into table itab.
loop at itab.
itab-ZMENG = sy-tabix .
modify itab index sy-tabix.
endloop.


x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-seltext_l = 'VBELN'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 2.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.

x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-seltext_l = 'POSNR'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 3.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.

<b>x_fieldcat-fieldname = 'ZMENG'.
x_fieldcat-seltext_l = 'ZMENG'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-do_sum = 'X'.
x_fieldcat-col_pos = 4.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.</b>

data: sort type slis_sortinfo_alv,
      it_sort type  SLIS_T_SORTINFO_ALV.
sort-fieldname = 'VBELN'.
sort-up = 'X'.
sort-subtot = 'X'.

APPEND sort to it_sort.

 l_layout-TOTALS_TEXT = 'total text'.
l_layout-SUBTOTALS_TEXT = 'subtotal text'.


call function 'REUSE_ALV_LIST_DISPLAY'
  exporting
    i_callback_program       = sy-repid
    is_layout                = l_layout
    it_fieldcat              = it_fieldcat
    it_events                = it_events
    it_sort                  = it_sort
  tables
    t_outtab                 = itab
  exceptions
    program_error            = 1
    others                   = 2.
if sy-subrc <> 0.

  message id sy-msgid type sy-msgty number sy-msgno
          with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.

regards

vijay

Read only

Former Member
0 Likes
1,044

hi suresh,

GIVE LIKE THIS...

<b>wa-fieldcat-datatype = 'QUAN'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.</b>

Read only

0 Likes
1,044

Please make sure to give the datatype as 'QUAN'.

wa-fieldcat-datatype = 'QUAN'.

It should work then.

Regards,

Rich Heilman

Read only

0 Likes
1,044

Priya, if you are going to edit your post, please make sure to allow the "Message Edited" text to be posted as well.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,044

HI Suresh,

wa-fieldcat-datatype = 'QUAN'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

Regards,

Laxmi.

Read only

Former Member
0 Likes
1,044

hi suresh,

here is a sample code . check this link:

http://sap.niraj.tripod.com/id64.html

regards,

keerthi.