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: 

button on ALV Grid

Former Member
0 Kudos

Hai1

what my requirement is creating button on ALV grid only.... let me explain briefly

i have a general material master details on my grid what my requirement is i place a cursor on any material detail and i click button ( i want this how to create a button on alv grid) on alv grid . the details of the clicked material document details to be shown...

pls help me friends..

Regards

kiran kumar

1 ACCEPTED SOLUTION

Sm1tje
Active Contributor
0 Kudos

have look at sample report BCALV_GRID_05.

5 REPLIES 5

Sm1tje
Active Contributor
0 Kudos

have look at sample report BCALV_GRID_05.

Former Member
0 Kudos

Refer to the program BCALV_GRID_05.

It shows how to add buttons to the toolbar and handle all the events.

regards,

Jinson

Former Member
0 Kudos

Hi,

Refer to program "SALV_DEMO_TABLE_COLUMNS

Cheers,

Pravin S

Former Member
0 Kudos

METHODS:

  • toolbar event for handling repricing and reassigning of values

handle_toolbar

FOR EVENT toolbar OF cl_gui_alv_grid

IMPORTING e_object,

by using this here we can create buttons on grid display

if we use pf-status buttons will be created in application tool bar

Former Member
0 Kudos

Hi,

you can get the solution by doing the following way.

This internal has data and will be passed to the ALV function module later.

DATA:BEGIN OF tbl_output OCCURS 0,  
      check TYPE charx,            "-----------CHECK BOX APPEARENCE-----
      vbeln LIKE vbak-vbeln,        "Sales Doc
      posnr LIKE vbap-posnr,        "Item-sales Doc
      omeng LIKE vbbe-omeng,        "Open qty
      color_line(04) TYPE c,
   END OF tbl_output.
*---------------------------------------------------------------------*
CONSTANTS:    c_standard(20) TYPE c             VALUE 'STANDARD',
                        c_user_command TYPE slis_formname VALUE  'USER_COMMAND',
                        c_pfstatus     TYPE slis_formname VALUE 'PF_STATUS_SET',
                        c_bcgrd        LIKE bapibds01-objkey VALUE 'ALV_BACKGROUND'.

Start-of-selection.
Perform get_data.  " fetch data from datbase depending on the selection screen params
Perform begin_alv_process.

*&---------------------------------------------------------------------*
FORM begin_alv_prcoess.
  gv_repid =  sy-repid.
* initialize layout
  PERFORM initialize_layout USING gs_layout.
* Subroutine to build events
  PERFORM f_build_events.
* fill fields to be output
  PERFORM fill_field_catalog.
* call ALV function module
  PERFORM alv_grid_display.
ENDFORM.                    " begin_Alv_prcoess }
*&---------------------------------------------------------------------*

FORM initialize_layout USING rs_layout TYPE slis_layout_alv.
  rs_layout-zebra        = c_x.         "Striped Pattern
  rs_layout-no_keyfix    = c_x.         "Fix Key columns
  rs_layout-max_linesize = 855.
* Name of the field with color
  rs_layout-info_fieldname = 'COLOR_LINE'.
ENDFORM.                    " initialize_layout
*&---------------------------------------------------------------------*

FORM fill_field_catalog.
  PERFORM build_catalog USING:
   'CHECK'   'TBL_OUTPUT'     'CHECK'     'TBL_OUTPUT'  'X'   ' ',
   'VBELN'   'TBL_OUTPUT'      'VBELN'      'TBL_OUTPUT'         ' '   text-005,
   'OMENG'  'TBL_OUTPUT'     'OMENG'   'TBL_OUTPUT'  'E'   text-008.
ENDFORM.                    " fill_field_catalog
*&---------------------------------------------------------------------*
FORM build_catalog USING    p_ref_fieldname
                            p_ref_table
                            p_fieldname
                            p_table
                            p_check
                            p_short.
*
  DATA: ls_fieldcat TYPE slis_fieldcat_alv.
  ls_fieldcat-fieldname        = p_fieldname.
  ls_fieldcat-tabname          = p_table.
  ls_fieldcat-seltext_m        = p_short.
  ls_fieldcat-seltext_l        = p_short.
  ls_fieldcat-outputlen        = p_short.
  IF p_check = c_x.
    ls_fieldcat-checkbox = c_x.
    ls_fieldcat-input    = c_x.
  ENDIF.
  IF p_check = c_e.
    ls_fieldcat-input = c_x.
  ENDIF.
  APPEND ls_fieldcat TO gt_fieldcat.
  CLEAR ls_fieldcat.
ENDFORM.                    " build_catalog
*&---------------------------------------------------------------------*
FORM alv_grid_display.
* The order quantities in output report can be edited to print datasheet
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
            i_callback_program       = gv_repid
            i_background_id          = c_bcgrd
            i_callback_pf_status_set = c_pfstatus
            i_callback_user_command  = c_user_command
            is_layout                = gs_layout
            it_fieldcat              = gt_fieldcat[]
            i_save                   = 'U'
            it_events                = tbl_alv_events[]
       TABLES
            t_outtab                 = tbl_output
       EXCEPTIONS
            program_error            = 1
            OTHERS                   = 2.
ENDFORM.                    " alv_list_display
*&---------------------------------------------------------------------*
FORM pf_status_set USING extab TYPE slis_t_extab .
  REFRESH extab. CLEAR   extab.
  SET PF-STATUS 'ZDATASHEET'.
ENDFORM.                    " PF_STATUS_SET
*&---------------------------------------------------------------------*
FORM user_command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
  CASE ucomm.
    WHEN 'SALL'.
      LOOP AT tbl_output.
        tbl_output-check = c_x.
        MODIFY tbl_output TRANSPORTING check omeng.
      ENDLOOP.
    WHEN 'DSEL'.
      LOOP AT tbl_output.
        CLEAR tbl_output-check.
        MODIFY tbl_output TRANSPORTING check omeng.
      ENDLOOP.
    WHEN 'PRNT'.
      PERFORM  After_output_data.
      ENDCASE.
  selfield-refresh = c_x.
ENDFORM.                    " USER_COMMAND 


FORM f_build_events.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = tbl_alv_events
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.

Add event name for User Command 
READ TABLE tbl_alv_events WITH KEY name = slis_ev_user_command
INTO s_evts.
IF sy-subrc = 0.
s_evts-form = c_user_command.
MODIFY tbl_alv_events FROM s_evts
TRANSPORTING form
WHERE name = slis_ev_user_command.
CLEAR s_evts.
ENDIF.
ENDFORM. " f_build_events

Regds

Parvathi