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

Push Button on Alv Grid display

Former Member
0 Likes
3,447

Hi experts,

I strcuk in the middle of one program, i need to have push buttons on the output ALV Grid display, i have copied the standard status and used the same in the Function module for pf-status, iam able to get the output

but my requirement is how to add the push buttons to the out put screen, as when iam clicking on status which i have copied iam unable to find where to add these push button in the application tool bar, iam unable to edit the push button can any body help me out, thanks in advance.

Hi experts,

I strcuk in the middle of one program, i need to have push buttons on the output ALV Grid display, i have copied the standard status and used the same in the Function module for pf-status, iam able to get the output

but my requirement is how to add the push buttons to the out put screen, as when iam clicking on status which i have copied iam unable to find where to add these push button in the application tool bar, iam unable to edit the push button can any body help me out, thanks in advance.

4 REPLIES 4
Read only

messier31
Active Contributor
0 Likes
1,188

Hi Madan,

I guess you are following the traditional approach for displaying alv grid using function module <b>REUSE_AL_GRID_DISPLAY.</b> the functionality required i.e. to add push button on output screen, is not possible by this approach.

You will have to go for control programming for this. Here you will create custom control in custom container with additional button. You can then add event handler for the same..

For additional detail on this topic refer following url

<b><a href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/bf/3bd1369f2d280ee10000009b38f889/frameset.htm">ALV Grid Control Programming</a></b>

Hope this helps you..let me know if you need more inputs on this..

Enjoy SAP.

Pankaj Singh

Read only

Former Member
0 Likes
1,188

When you go into the PF status editor(se41). Open the node Apllication Tool bar. Add an new button with some text, icon and other required parameters.

Regards,

ravi

Read only

Former Member
0 Likes
1,188

U can have button on application toolbar.

You just have to use the new pf status in your report program.

You should copy the 'STANDARD' GUI status from program SAPLKKBL using transaction SE90 >Programming SubObjects> Gui Status.

Execute this transaction to get to next screen. select status using checkbox. click on GUI Status --> Copy.

Enter your Z program name and the name you what for this status - you can keep it as 'STANDARD' to be simple.

<b>Then you can edit the new status to add or delete buttons</b>. This will also bring in the standard SAP ALV functionality.

Have a look at below code for using the new status.

TYPE-POOLS: slis.

DATA: i_qmel LIKE qmel OCCURS 0.

data v_repid type repid.

SELECT * FROM qmel INTO TABLE i_qmel.

v_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = v_repid

I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

i_structure_name = 'QMEL'

TABLES

t_outtab = i_qmel

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.

form set_pf_status using rt_extab type slis_t_extab.

set pf-status 'TEST'.

endform.

FORM user_command USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

data lv_ucomm type sy-ucomm.

lv_ucomm

= sy-ucomm.

CASE lv_ucomm.

WHEN 'BUTTON'. "Double Click line Item

**Write ur functinality here

endcase.

endform.

Also have a look at below links.

http://www.sap-basis-abap.com/abap/add-button-to-alv-toolbar-with-reuse-alv-list-display.htm

Best Regards,

Vibha

*Please mark all the helpful answers

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,188

Hello Madan

I cannot help you with the FM-based ALV lists. However, for OO-based ALV grids (CL_GUI_ALV_GRID) I have a sample program that simulates radio buttons by using icons with hotspots.

PROGRAM ZUS_SDN_BCALV_GRID_DEMO_2.
 
* Based on: BCALV_GRID_DEMO.
 
TYPE-POOLS: icon.
 
 
TYPES: BEGIN OF ty_s_sflight.
INCLUDE TYPE sflight.
TYPES: button1    TYPE lvc_emphsz.
TYPES: button2    TYPE lvc_emphsz.
TYPES: button3    TYPE lvc_emphsz.
TYPES: button4    TYPE lvc_emphsz.
TYPES: END OF ty_s_sflight.
 
 
DATA:
  gt_sflight    TYPE STANDARD TABLE OF ty_s_sflight,
  gt_fcat       TYPE lvc_t_fcat.
 
 
DATA: ok_code LIKE sy-ucomm,
*      gt_sflight TYPE TABLE OF sflight,
      g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
      grid1  TYPE REF TO cl_gui_alv_grid,
      g_custom_container TYPE REF TO cl_gui_custom_container.
 
 
 
 
*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler DEFINITION.
 
  PUBLIC SECTION.
 
    CLASS-DATA:
      md_cnt    TYPE i.
 
    CLASS-METHODS:
      handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
        IMPORTING
          e_row_id
          e_column_id
          es_row_no
          sender.
 
ENDCLASS.                    "lcl_eventhandler DEFINITION
 
 
*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler IMPLEMENTATION.
 
  METHOD handle_hotspot_click.
* define local data
    FIELD-SYMBOLS:
      <ls_entry>    TYPE ty_s_sflight,
      <ld_fld>      TYPE ANY.
 
    READ TABLE gt_sflight ASSIGNING <ls_entry> INDEX es_row_no-row_id.
    CHECK ( <ls_entry> IS ASSIGNED ).
 
*   Set all radio buttons "unselected"
    <ls_entry>-button1 =  icon_wd_radio_button_empty.
    <ls_entry>-button2 =  icon_wd_radio_button_empty.
    <ls_entry>-button3 =  icon_wd_radio_button_empty.
    <ls_entry>-button4 =  icon_wd_radio_button_empty.
 
    ASSIGN COMPONENT e_column_id-fieldname OF STRUCTURE <ls_entry>
                                              TO <ld_fld>.
    IF ( <ld_fld> IS ASSIGNED ).
*     Set selected radio button "selected".
      <ld_fld> = icon_wd_radio_button.
    ENDIF.
 
*   Force PAI followed by refresh of table display in PBO
    CALL METHOD cl_gui_cfw=>set_new_ok_code
      EXPORTING
        new_code = 'DUMMY'
*      IMPORTING
*        RC       =
        .
 
 
 
  ENDMETHOD.                    "handle_hotspot_click
 
ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
 
 
START-OF-SELECTION.
 
*---------------------------------------------------------------------*
*       MAIN                                                          *
*---------------------------------------------------------------------*
 
  PERFORM select_data.
 
 
  CALL SCREEN 100.
 
 
*---------------------------------------------------------------------*
*       MODULE PBO OUTPUT                                             *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
  SET PF-STATUS 'MAIN100'.
  IF g_custom_container IS INITIAL.
    CREATE OBJECT g_custom_container
           EXPORTING container_name = g_container.
    CREATE OBJECT grid1
           EXPORTING i_parent = g_custom_container.
 
    PERFORM build_fieldcatalog.
 
    CALL METHOD grid1->set_table_for_first_display
*      EXPORTING
*        i_structure_name = 'SFLIGHT'
      CHANGING
        it_fieldcatalog  = gt_fcat
        it_outtab        = gt_sflight.
 
*   Set event handler for event TOOLBAR
    SET HANDLER:
      lcl_eventhandler=>handle_hotspot_click FOR grid1.
 
  else.
    CALL METHOD grid1->refresh_table_display
*      EXPORTING
*        IS_STABLE      =
*        I_SOFT_REFRESH =
      EXCEPTIONS
        FINISHED       = 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.
 
  ENDIF.
 
 
 
ENDMODULE.                    "PBO OUTPUT
*---------------------------------------------------------------------*
*       MODULE PAI INPUT                                              *
*---------------------------------------------------------------------*
MODULE pai INPUT.
*   to react on oi_custom_events:
  CALL METHOD cl_gui_cfw=>dispatch.
  CASE ok_code.
    WHEN 'EXIT'.
      PERFORM exit_program.
    WHEN OTHERS.
*     do nothing
  ENDCASE.
  CLEAR ok_code.
ENDMODULE.                    "PAI INPUT
*---------------------------------------------------------------------*
*       FORM EXIT_PROGRAM                                             *
*---------------------------------------------------------------------*
FORM exit_program.
*  CALL METHOD G_CUSTOM_CONTAINER->FREE.
*  CALL METHOD CL_GUI_CFW=>FLUSH.
  LEAVE PROGRAM.
ENDFORM.                    "EXIT_PROGRAM
 
 
*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build_fieldcatalog .
* define local data
  DATA:
    ls_fcat        TYPE lvc_s_fcat,
    ls_hype        TYPE lvc_s_hype.
 
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
*     I_BUFFER_ACTIVE              =
      i_structure_name             = 'LVC_S_FCAT'
*     I_CLIENT_NEVER_DISPLAY       = 'X'
*     I_BYPASSING_BUFFER           =
*     I_INTERNAL_TABNAME           =
    CHANGING
      ct_fieldcat                  = gt_fcat
    EXCEPTIONS
      inconsistent_interface       = 1
      program_error                = 2
      OTHERS                       = 3.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  DELETE gt_fcat WHERE ( fieldname <> 'EMPHASIZE' ).
 
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
*     I_BUFFER_ACTIVE              =
      i_structure_name             = 'SFLIGHT'
*     I_CLIENT_NEVER_DISPLAY       = 'X'
*     I_BYPASSING_BUFFER           =
*     I_INTERNAL_TABNAME           =
    CHANGING
      ct_fieldcat                  = gt_fcat
    EXCEPTIONS
      inconsistent_interface       = 1
      program_error                = 2
      OTHERS                       = 3.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
 
 
  READ TABLE gt_fcat INTO ls_fcat
       WITH KEY fieldname = 'EMPHASIZE'.
  IF ( syst-subrc = 0 ).
    DELETE gt_fcat INDEX syst-tabix.
  ENDIF.
 
  ls_fcat-fieldname = 'BUTTON4'.
  ls_fcat-icon    = 'X'.
  ls_fcat-hotspot = 'X'.
  INSERT ls_fcat INTO gt_fcat INDEX 4.
*
  ls_fcat-fieldname = 'BUTTON3'.
  INSERT ls_fcat INTO gt_fcat INDEX 4.
*
  ls_fcat-fieldname = 'BUTTON2'.
  INSERT ls_fcat INTO gt_fcat INDEX 4.
*
  ls_fcat-fieldname = 'BUTTON1'.
  INSERT ls_fcat INTO gt_fcat INDEX 4.
 
 
  LOOP AT gt_fcat INTO ls_fcat.
    ls_fcat-col_pos = syst-tabix.
    MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
  ENDLOOP.
 
 
 
 
 
 
ENDFORM.                    " BUILD_FIELDCATALOG
 
 
*&---------------------------------------------------------------------*
*&      Form  SELECT_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM select_data .
* define local data
  DATA:
    ls_sflight    TYPE ty_s_sflight.
 
 
  SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE gt_sflight.
 
  ls_sflight-button1 = icon_wd_radio_button.
  ls_sflight-button2 = icon_wd_radio_button_empty.
  ls_sflight-button3 = icon_wd_radio_button_empty.
  ls_sflight-button4 = icon_wd_radio_button_empty.
*
  MODIFY gt_sflight FROM ls_sflight
      TRANSPORTING button1 button2 button3 button4
    WHERE ( carrid IS NOT INITIAL ).
 
ENDFORM.                    " SELECT_DATA

Regards

Uwe