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: 

About events of class cl_gui_alv_grid third Q

Former Member
0 Kudos

I have created one container, and by using oops concept I mean classes and event handler, I have displayed entries of one table ( suppose the entries of table SPFLI )

How can I make each field of any one line in display as push button. I mean I want to display all cells of one row as push button.

For your info. I am able to convert any individual cell as push button by using following code, but by using this I could only make any one cell in one row as push button but not entire row as push button.

READ TABLE it_vbak INTO wa_vbak INDEX 7.

wa_cellstyles-fieldname = 'VBELN'.

wa_cellstyles-style = cl_gui_alv_grid=>mc_style_button.

APPEND wa_cellstyles TO wa_vbak-cellstyles.

MODIFY TABLE it_vbak FROM wa_vbak .

this will make the cell 'VBELN' of 7th row as push button,

in this case I am not able to make reaming cells of 7th row as push button.

please help me out.

3 REPLIES 3

uwe_schieferstein
Active Contributor
0 Kudos

Hello Amit

You cannot define an entire row as push button but only cells or entire columns.

Regards

Uwe

0 Kudos

Ok,

Can u tell me which event gets triggered when use click this button ?

is it public or protected ?

if it is protected how to overwrite your own code for that method ?

0 Kudos

Hello Amit

The event which is triggered is BUTTON_CLICK. Have a look at sample report ZUS_SDN_ALV_EVT_BUTTON_CLICK.


*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_ALV_EVT_BUTTON_CLICK
*&
*&---------------------------------------------------------------------*
*&Thread: About events of class cl_gui_alv_grid third Q
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1048457"></a>
*&
*& Thread: Button for grid display
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="788773"></a>
*&---------------------------------------------------------------------*
*&
*  Flow logic of screen '0100' (contains no dynpro elements):
*  PROCESS BEFORE OUTPUT.
*    MODULE STATUS_0100.
**
*  PROCESS AFTER INPUT.
*    MODULE USER_COMMAND_0100.
*&---------------------------------------------------------------------*
REPORT  zus_sdn_alv_evt_button_click.

TYPE-POOLS: abap, icon.

DATA:
  gd_okcode        TYPE ui_func,
*
  gs_layout        TYPE lvc_s_layo,
  gt_fcat          TYPE lvc_t_fcat,
  go_docking       TYPE REF TO cl_gui_docking_container,
  go_grid1         TYPE REF TO cl_gui_alv_grid.


DATA:
  gt_knb1          TYPE STANDARD TABLE OF knb1.


PARAMETERS:
  p_bukrs      TYPE bukrs  DEFAULT '2000'  OBLIGATORY.



*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler DEFINITION.
  PUBLIC SECTION.

    CLASS-METHODS:
      handle_button_click FOR EVENT button_click OF cl_gui_alv_grid
        IMPORTING
          es_col_id
          es_row_no
          sender.

ENDCLASS.                    "lcl_eventhandler DEFINITION


*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler IMPLEMENTATION.

  METHOD handle_button_click.
*   define local data
    DATA:
      ls_knb1     TYPE knb1,
      ls_col_id   TYPE lvc_s_col.

    READ TABLE gt_knb1 INTO ls_knb1 INDEX es_row_no-row_id.
    CHECK ( ls_knb1-kunnr IS NOT INITIAL ).


    SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
    SET PARAMETER ID 'BUK' FIELD p_bukrs.

    CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.


**   OR: show your popup
*    call screen '0200' starting at 5   5
*                       ending   at 10  20.




  ENDMETHOD.                    "handle_button_click

ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION


START-OF-SELECTION.

  PERFORM select_and_modify_data.




* Create docking container
  CREATE OBJECT go_docking
    EXPORTING
      parent = cl_gui_container=>screen0
      ratio  = 90
    EXCEPTIONS
      OTHERS = 6.
  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 ALV grid
  CREATE OBJECT go_grid1
    EXPORTING
      i_parent = go_docking
    EXCEPTIONS
      OTHERS   = 5.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

* Set event handler
  SET HANDLER:
    lcl_eventhandler=>handle_button_click FOR go_grid1.


* Build fieldcatalog and set button for field KUNNR
  PERFORM build_fieldcatalog_knb1.



* Display data
  gs_layout-detailinit = 'X'.
  gs_layout-zebra      = 'X'.
  CALL METHOD go_grid1->set_table_for_first_display
    EXPORTING
      is_layout       = gs_layout
    CHANGING
      it_outtab       = gt_knb1
      it_fieldcatalog = gt_fcat
    EXCEPTIONS
      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.




* Link the docking container to the target dynpro
  CALL METHOD go_docking->link
    EXPORTING
      repid                       = syst-repid
      dynnr                       = '0100'
*      CONTAINER                   =
    EXCEPTIONS
      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.


* ok-code field = GD_OKCODE
  CALL SCREEN '0100'.


END-OF-SELECTION.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS_0100'.
*  SET TITLEBAR 'xxx'.


ENDMODULE.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE gd_okcode.
    WHEN 'BACK' OR
         'END'  OR
         'CANC'.
      SET SCREEN 0. LEAVE SCREEN.


    WHEN OTHERS.
  ENDCASE.

  CLEAR: gd_okcode.

ENDMODULE.                 " USER_COMMAND_0100  INPUT


*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCATALOG_KNB1
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build_fieldcatalog_knb1 .
* define local data
  DATA:
    ls_fcat        TYPE lvc_s_fcat.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
*     I_BUFFER_ACTIVE              =
      i_structure_name             = 'KNB1'
*     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.


  LOOP AT gt_fcat INTO ls_fcat
          WHERE ( fieldname = 'BUKRS' ).
    ls_fcat-style = cl_gui_alv_grid=>mc_style_button.
    ls_fcat-icon  = abap_true.

    MODIFY gt_fcat FROM ls_fcat.
  ENDLOOP.




ENDFORM.                    " BUILD_FIELDCATALOG_KNB1


*&---------------------------------------------------------------------*
*&      Form  SELECT_AND_MODIFY_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM select_and_modify_data .
* define local data
  DATA: ls_knb1   TYPE knb1.

  SELECT        * FROM  knb1 INTO TABLE gt_knb1
         WHERE  bukrs  = p_bukrs.


  ls_knb1-bukrs = icon_customer.
  MODIFY gt_knb1 FROM ls_knb1
    TRANSPORTING bukrs
    WHERE ( bukrs NE ls_knb1-bukrs ).

ENDFORM.                    " SELECT_AND_MODIFY_DATA

Regards

Uwe