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

Active Sum button alv

Former Member
0 Likes
3,488

How active the standard sum button in the alv oo?

10 REPLIES 10
Read only

Former Member
0 Likes
1,754

Is it factory method or set table as first display?

Read only

Former Member
0 Likes
1,754

CALL METHOD gr_alvgrid->set_table_for_first_display

Read only

0 Likes
1,754

try this code:


*&---------------------------------------------------------------------*
*& Report  ZTEST_DEMO_ALV
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

report  ztest_demo_alv.


class cl_event_reciever definition deferred.
data:
wa_vbak type vbak.
data:
i_vbak type standard table of vbak,
i_vbap type standard table of vbap.


data:
v_container1 type scrfname value 'CONT1',
v_grid1      type ref to cl_gui_alv_grid,
v_custom_container1 type ref to cl_gui_custom_container,
v_container2 type scrfname value 'CONT2',
v_grid2      type ref to cl_gui_alv_grid,
v_custom_container2 type ref to cl_gui_custom_container,
ok_code type syucomm,
v_event_reciever type ref to cl_event_reciever.

*----------------------------------------------------------------------*
*       CLASS cl_event_reciever DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class cl_event_reciever definition.
  public section.

    methods:
      handle_double_click for event double_click of cl_gui_alv_grid
        importing e_row e_column.



endclass.                    "cl_event_reciever DEFINITION

*----------------------------------------------------------------------*
*       CLASS cl_event_reciever IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class cl_event_reciever implementation.
  method handle_double_click.

    read table i_vbak
    into wa_vbak
    index e_row.
    if sy-subrc = 0.

      select * from vbap
        into table i_vbap

        where vbeln = wa_vbak-vbeln.
      if sy-subrc = 0.
        set screen 00.
        leave to screen 100.
      endif.
    endif.
  endmethod.                    "handle_double_click
endclass.                    "cl_event_reciever IMPLEMENTATION

select-options:
s_vbeln for  wa_vbak-vbeln.


start-of-selection.

  select * from  vbak
    into table i_vbak
    up to 50 rows
    where vbeln in s_vbeln.
  if sy-subrc <> 0.
    message i000(z_zzz_ca_messages)  with 'No data found!'.
    leave list-processing.

  endif.

end-of-selection.
  call screen 100.


*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.
  set pf-status '100'.
*  SET TITLEBAR 'xxx'.

  if v_custom_container1 is not bound.

    create object v_custom_container1
    exporting container_name = v_container1.

    create object v_grid1
      exporting i_parent = v_custom_container1.

    call method v_grid1->set_table_for_first_display
       exporting
*       i_buffer_active               =
*       i_bypassing_buffer            =
*       i_consistency_check           =
         i_structure_name              = 'VBAK'
*       is_variant                    =
*       i_save                        =
*       i_default                     = 'X'
*       is_layout                     =
*       is_print                      =
*       it_special_groups             =
*       it_toolbar_excluding          =
*       it_hyperlink                  =
*       it_alv_graphics               =
*       it_except_qinfo               =
*       ir_salv_adapter               =
      changing
        it_outtab                     = i_vbak
*       it_fieldcatalog               =
*       it_sort                       =
*       it_filter                     =
      exceptions
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        others                        = 4
            .
    if sy-subrc <> 0.
      message id sy-msgid type sy-msgty number sy-msgno
                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    create object v_event_reciever.
    set handler v_event_reciever->handle_double_click for v_grid1.

  endif.

  if v_custom_container2 is not bound
    and i_vbap is not initial.

    create object v_custom_container2
    exporting container_name = v_container2.

    create object v_grid2
      exporting i_parent = v_custom_container2.

    call method v_grid2->set_table_for_first_display
       exporting
*       i_buffer_active               =
*       i_bypassing_buffer            =
*       i_consistency_check           =
         i_structure_name              = 'VBAP'
*       is_variant                    =
*       i_save                        =
*       i_default                     = 'X'
*       is_layout                     =
*       is_print                      =
*       it_special_groups             =
*       it_toolbar_excluding          =
*       it_hyperlink                  =
*       it_alv_graphics               =
*       it_except_qinfo               =
*       ir_salv_adapter               =
      changing
        it_outtab                     = i_vbap
*       it_fieldcatalog               =
*       it_sort                       =
*       it_filter                     =
      exceptions
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        others                        = 4
            .
  endif.
  if v_custom_container2 is bound.
    call method v_grid2->refresh_table_display.
  endif.

endmodule.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.
  case ok_code.
    when 'BACK'.
      if v_grid1 is bound.
        call method v_grid1->free.
      endif.
      if v_grid2 is bound.
        call method v_grid2->free.
      endif.
      set screen 00.
      leave screen.

  endcase.


endmodule.                 " USER_COMMAND_0100  INPUT

Read only

Former Member
0 Likes
1,754

Hi,

I guess its not only sum button no button is displayed right.

The documentatin for the standard ALV Grid tool par is located in the Function module documentation for I_CALLBACK_PF_STATUS_SET

This is likely what you are looking for.

If the caller wants to use a self-defined user interface (for example, in order to provide additional list functions or use existing

functions), we recommend that you copy standard status STANDARD from function group SALV and modify it accordingly.

ALV standard function codes always start with '&'.

Thanks

Vikranth

Read only

Former Member
0 Likes
1,754

Hi,

For fieldcatalog for any amount filed use :


gs_fieldcat-do_sum = 'X'.

Thanks,

Sriarm Ponna.

Read only

Former Member
0 Likes
1,754

sum button in toolbar!!

Read only

0 Likes
1,754

hi,

WHen you set the do_sum property in the fieldcatalog of any numeric field, the Sum button automatically appears on the toolbar.

Regards,

Subramanian

Read only

0 Likes
1,754

I try with do_sum in the quantity field of fieldcatalog but nothing happens......

Read only

0 Likes
1,754

Can u pl. check from context menu (right mouse button click) whether u r able to see the total menu?

Regards,

Joy.

Read only

Former Member
0 Likes
1,754

Alfonso,

Not only do you have to set 'DO_SUM' attribute but also you have to set the "DATATYPE" attribute. If you are using internal tables, you must set both attributes. Try setting these two field attributes as follow:-

DATA: lwa_fcat TYPE lvc_s_fcat.

clear lvc_s_fcat.

lwa_fcat-fieldname = 'W_COST'.

lwa_fcat-ref_field = 'W_COST'.

lwa_fcat-ref_table = 'IT_OUTPUT1'.

lwa_fcat-datatype = 'CURR'.

lwa_fcat-do_sum = 'X'.

append lwa_fcat to p_fieldcat.