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: 

ALV Report: Summation button issue.

Former Member
0 Kudos
1,252

Hi Experts,

I have designed the ALV report. And the requirement is to have a summation button on the o/p screen.

I have tried with :

fieldcatalog-do_sum      = 'X'.
  fieldcatalog-datatype = 'QUAN'.

fieldcatalog-do_sum      = 'X'.
  fieldcatalog-inttype = 'P'.

Sometimes its directly summing the field, which I don't need.

I want to sum only If I click on Summation button.

My fieldcatalog is:

fieldcatalog-tabname     = 'IG_FINAL'.
  fieldcatalog-fieldname   = 'ZPROD1'.
  fieldcatalog-seltext_m   =  text-018.
  fieldcatalog-outputlen   = 25.
  fieldcatalog-emphasize   = 'X'.
  fieldcatalog-do_sum      = 'X'.
  fieldcatalog-datatype = 'QUAN'.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.

Now what should I do get the summation button working ?

Pls help !

9 REPLIES 9

Former Member
0 Kudos
514

Hi,

If you are using Do-Sum = 'X', it will give you the total of that column at the end. If you do not set this variable as 'X', you can select the column you want to sum and press the Summation Button in the ALV tool-bar to get the total.

0 Kudos
514

Thank you Deepak.

I have tried even that. The problem is I get the Summation Button from PF STATUS, When I select a column and click on summation button it does'nt sum at all.

0 Kudos
514

Hi,

The Summation button in ALV Tool Bar is already available, if you are using a Summation Button in PF Status, then i think you have a custom Summation Button. In this case you will have to write a code for getting the functionality.

0 Kudos
514

Where and How ?

Can u please explain ?

Thanks in advance.

0 Kudos
514

Check for the function key assigned to the Button(say BUTTON). Check in the USER COMMAND of the screen (PAI) for SY_UCOMM = 'BUTTON', if this is the case do the sum.

0 Kudos
514

Hi Harish,

almost all run time errors in programs with ALV are related to field catalog errors. Functional errors and questions for ALV are relatedto field catalog not much less.

The only ALV released for customer use is the ALV object model involving classes CL_SALV_*, mainly ans atrting fromCL_SALV_TABLE.

The ALV object model does not use any user-created field catalog.

If you do not take the initial load of reading a few blogs explaining ALV object model and the time to get used to it, you will remain at the field catalog level for ever.

lr_aggregations    = lio_salv->get_aggregations( ).
    lv_columnname = io_column->get_columnname( ).
    TRY.
        lr_aggregations->add_aggregation(
          columnname  = lv_columnname
          aggregation = if_salv_c_aggregation=>total ).
      CATCH cx_salv_data_error .
        ASSERT 1 = 2.
      CATCH cx_salv_not_found .
        ASSERT 1 = 2.
      CATCH cx_salv_existing .
        ASSERT 1 = 2.
    ENDTRY.

This code snippet may look strange to you - not after you started with CL_SALV_TABLE. Search for Rich Heilmans aticles to start with.

Regards

Clemens

Former Member
0 Kudos
514

Hi,

Please Check the below fields should be there in your field catalog

wa_fcat-fieldname = 'ZPROD1'.

wa_fcat-do_sum = 'X' .

wa_fcat-outputlen = 25.

wa_fcat-seltext_s = text-018.

wa_fcat-seltext_m = text-018.

wa_fcat-seltext_l = text-018.

IF wa_fcat-fieldname = 'DMBTR'.

wa_fcat-ref_fieldname = 'IT_FINAL'.

wa_fcat-ref_tabname = 'WAERS'.

wa_fcat-datatype = 'CURR'.

ELSEIF wa_fcat-fieldname = 'MENGE'.

wa_fcat-ref_fieldname = 'IT_FINAL'.

wa_fcat-ref_tabname = 'MEINS'.

wa_fcat-datatype = 'QUAN'.

ENDIF.

APPEND wa_fcat to it_fcat.

CLEAR wa_fcat.

In your internal table the reference field you should maintain

suppose your using quantity means 'MENGE' field should be there in you types declaration.

suppose your using Currency means 'WAERS' field should be there in you types declaration.

Regards,

Dhina.

Former Member
0 Kudos
514

Hi,

according to your requirement, we have two options i.e

1. Do not use do_fieldcatalog-sum = 'X'. means if u want total then select the column and press sum ICON. this is applicable in ALV GRID only.

2. you should write logic in user command routine and need to pass the user command form to ALV function module.

Try with above one of the statement.

Ram.

Former Member
0 Kudos
514

Hi Harish,

Just remove 'fieldcatalog-do_sum = 'X'.' from your fieldcatalogue.

Then execute the program and select the particular column and then press the Summarization button (by default ALV report provides Summarization option).

Hope it helps..

Regards,

KK