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

ALV-grid Sum

Former Member
0 Likes
930

Hi Experts,

i have issue were in i need to show sum of the total currency. like example...

for Custmer 100 there are vendor number 1,2,3,4,5. so for all this vendor numbers.. the currency should b added automatically and show us the total of that currency .hope u experts have undestood. so how can i add the it and show it in the output....

Corrects answers will be fully rewarded..

Regards

Sunita.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
886

Hi Sunita,

While Filling Field cat use Do_Sum = "X'.

Like this :

lfs_fieldcat-fieldname     = 'KBETR_IV'.
  lfs_fieldcat-tabname       = 'T_FINAL_DATA'.
  lfs_fieldcat-seltext_l     =   text-iof.
  lfs_fieldcat-cfieldname = 'WAERS_I'.
  lfs_fieldcat-do_sum      = 'X'.
  lfs_fieldcat-no_zero = 'X'.
  lfs_fieldcat-col_pos       = '6'.

  APPEND lfs_fieldcat TO t_fieldcat.
  CLEAR lfs_fieldcat.

  lfs_fieldcat-fieldname     = 'WAERS_I'.
  lfs_fieldcat-tabname       = 'T_FINAL_DATA'.
  lfs_fieldcat-seltext_l     =  text-cur.
  lfs_fieldcat-col_pos       = '7'.

  APPEND lfs_fieldcat TO t_fieldcat.
  CLEAR lfs_fieldcat.

Then it Will Automaticaly calculates Sum based on Currency.

If Foun HelpFull Do reward.

Regards.

Eshwar Reddy

Hi Sunita,

While Filling Field cat use Do_Sum = "X'.

Like this :

lfs_fieldcat-fieldname     = 'KBETR_IV'.
  lfs_fieldcat-tabname       = 'T_FINAL_DATA'.
  lfs_fieldcat-seltext_l     =   text-iof.
  lfs_fieldcat-cfieldname = 'WAERS_I'.
  lfs_fieldcat-do_sum      = 'X'.
  lfs_fieldcat-no_zero = 'X'.
  lfs_fieldcat-col_pos       = '6'.

  APPEND lfs_fieldcat TO t_fieldcat.
  CLEAR lfs_fieldcat.

  lfs_fieldcat-fieldname     = 'WAERS_I'.
  lfs_fieldcat-tabname       = 'T_FINAL_DATA'.
  lfs_fieldcat-seltext_l     =  text-cur.
  lfs_fieldcat-col_pos       = '7'.

  APPEND lfs_fieldcat TO t_fieldcat.
  CLEAR lfs_fieldcat.

Then it Will Automaticaly calculates Sum based on Currency.

If Foun HelpFull Do reward.

Regards.

Eshwar Reddy

6 REPLIES 6
Read only

Former Member
0 Likes
886

hi,

Check the following link for sample code.

http://saptechnical.com/Tutorials/ALV/Subtotals/Define.htm

Hope it is useful.

Regards,

Jaya Vani

Read only

peter_ruiz2
Active Contributor
0 Likes
886

hi,

when defining the field category of the amount field in your alv grid, include the currency field of that amount in CFIELDNAME then assign 'X' to DO_SUM.

regards,

Peter

Read only

Former Member
0 Likes
886

You can use sort and subtotal facility of ALV grid or else you have to calculate it in your internal table using control break statements.

Have a look at below link:

http://www.saptechnical.com/Tutorials/ALV/Subtotals/Define.htm

I hope it helps.

Thanks,

Vibha

Read only

Former Member
0 Likes
886

Hi,

In ALV_GRID also for the in the field cataog structure we can have SUM = 'X'. After this use the collect statement and move to toher table.

Or

After you get the data into final internal table.

Try to loop this internal table.

At new <<fieldname>>.

And we need to use COLLECT statement which automatically adds the contents and move to other internal table.

ENDAT.

Reward if helpful.

Regards

Chandralekha.

Read only

Former Member
0 Likes
887

Hi Sunita,

While Filling Field cat use Do_Sum = "X'.

Like this :

lfs_fieldcat-fieldname     = 'KBETR_IV'.
  lfs_fieldcat-tabname       = 'T_FINAL_DATA'.
  lfs_fieldcat-seltext_l     =   text-iof.
  lfs_fieldcat-cfieldname = 'WAERS_I'.
  lfs_fieldcat-do_sum      = 'X'.
  lfs_fieldcat-no_zero = 'X'.
  lfs_fieldcat-col_pos       = '6'.

  APPEND lfs_fieldcat TO t_fieldcat.
  CLEAR lfs_fieldcat.

  lfs_fieldcat-fieldname     = 'WAERS_I'.
  lfs_fieldcat-tabname       = 'T_FINAL_DATA'.
  lfs_fieldcat-seltext_l     =  text-cur.
  lfs_fieldcat-col_pos       = '7'.

  APPEND lfs_fieldcat TO t_fieldcat.
  CLEAR lfs_fieldcat.

Then it Will Automaticaly calculates Sum based on Currency.

If Foun HelpFull Do reward.

Regards.

Eshwar Reddy

Read only

Former Member
0 Likes
886

hi check this simple example..

REPORT ztest_alv_perc_13317.

TYPE-POOLS: slis.

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat TYPE slis_fieldcat_alv,

it_events TYPE slis_t_event,

wa_events TYPE slis_alv_event,

it_sort TYPE slis_t_sortinfo_alv,

wa_sort TYPE slis_sortinfo_alv,

l_layout TYPE slis_layout_alv.

TYPES: BEGIN OF ty_itab,

field1(10),

qty1 TYPE i,

qty2 TYPE i,

qty3 TYPE i,

dummy TYPE c,

END OF ty_itab.

DATA: itab TYPE STANDARD TABLE OF ty_itab WITH HEADER LINE,

itab1 TYPE ty_itab.

START-OF-SELECTION.

itab-field1 = 'FIRST'.

itab-qty1 = 2.

itab-qty2 = 1.

itab-qty3 = 5.

APPEND itab.

itab-field1 = 'SECOND'.

itab-qty1 = 52.

itab-qty2 = 14.

itab-qty3 = 76.

APPEND itab.

itab-field1 = 'THIRD'.

itab-qty1 = 34.

itab-qty2 = 21.

itab-qty3 = 78.

APPEND itab.

wa_fieldcat-col_pos = 1.

wa_fieldcat-fieldname = 'FIELD1'.

wa_fieldcat-tabname = 'ITAB'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-col_pos = 2.

wa_fieldcat-fieldname = 'QTY1'.

wa_fieldcat-tabname = 'ITAB'.

wa_fieldcat-do_sum = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-col_pos = 3.

wa_fieldcat-fieldname = 'QTY2'.

wa_fieldcat-tabname = 'ITAB'.

wa_fieldcat-do_sum = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-col_pos = 4.

wa_fieldcat-fieldname = 'QTY3'.

wa_fieldcat-tabname = 'ITAB'.

wa_fieldcat-do_sum = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

l_layout-totals_text = 'total text'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = sy-repid

it_fieldcat = it_fieldcat

is_layout = l_layout

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2

.

IF sy-subrc <> 0.

ENDIF.