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

ALV - Oops Realted Query

Former Member
0 Likes
634

Dear all ,

the codes are pasted from the standard program BCALV_GRID_02. Can any one plz guuide me as in what is this class lcl_event_receiver and its importing parameters ( e_row e_column ) I know there are other options also to the importing parameters like es_row_no ...... . How can I see the other options in the importing paramaters.

Not very clear about the concept. Plz guide.

Rgds,

Anu.

***************************************************************

  • LOCAL CLASSES: Definition

****************************************************************

*===============================================================

  • class lcl_event_receiver: local class to handle event DOUBLE_CLICK

  • and CLOSE.

*

  • Definition:

  • ~~~~~~~~~~~

class lcl_event_receiver definition.

public section.

methods:

handle_double_click

for event double_click of cl_gui_alv_grid

importing e_row e_column,

handle_close

for event close of cl_gui_dialogbox_container

importing sender.

private section.

data: dialogbox_status type c. "'X': does exist, SPACE: does not ex.

endclass.

*

  • lcl_event_receiver (Definition)

*===============================================================

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
606

Hi Anu,

lcl_event_receiver is a local class defined. in transaction SE24 you can see all the standard classes meaning they are available globally like CL_GUI_ALV_GRID.

now suppose you need to display a grid , then you will create an object of this standard class and then use all the methods, events and elements of this class as it is available globally. after creating the class when you do some action say when you double click, then you need to perform your own action.

so we will define some local classes in our program and we will handle the events.

now when you double click depending on the column double clicked you need to perform some different action (like we use GET CURSOR statement) we can make use of e_column..similarly e_row will give the row no. clicked.

Regards,

Vidya.

Dear all ,

the codes are pasted from the standard program BCALV_GRID_02. Can any one plz guuide me as in what is this class lcl_event_receiver and its importing parameters ( e_row e_column ) I know there are other options also to the importing parameters like es_row_no ...... . How can I see the other options in the importing paramaters.

Not very clear about the concept. Plz guide.

Rgds,

Anu.

***************************************************************

  • LOCAL CLASSES: Definition

****************************************************************

*===============================================================

  • class lcl_event_receiver: local class to handle event DOUBLE_CLICK

  • and CLOSE.

*

  • Definition:

  • ~~~~~~~~~~~

class lcl_event_receiver definition.

public section.

methods:

handle_double_click

for event double_click of cl_gui_alv_grid

importing e_row e_column,

handle_close

for event close of cl_gui_dialogbox_container

importing sender.

private section.

data: dialogbox_status type c. "'X': does exist, SPACE: does not ex.

endclass.

*

  • lcl_event_receiver (Definition)

*===============================================================

3 REPLIES 3
Read only

uwe_schieferstein
Active Contributor
0 Likes
606

Hello Anu

Have a look at my simplified report. Debug the DOUBLE_CLICK event and you will understand what happens.

E_ROW is the row where the double-click happened.

E_COLUMN is the column where the double-click happened.

For details of these parameters check event DOUBLE_CLICK in class CL_GUI_ALV_GRID.

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_TWO_ALV_GRIDS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_two_alv_grids.




DATA:
  gd_okcode        TYPE ui_func,
*
  go_docking       TYPE REF TO cl_gui_docking_container,
  go_splitter      TYPE REF TO cl_gui_splitter_container,
  go_cell_top      TYPE REF TO cl_gui_container,
  go_cell_bottom   TYPE REF TO cl_gui_container,
  go_grid1         TYPE REF TO cl_gui_alv_grid,
  go_grid2         TYPE REF TO cl_gui_alv_grid,
  gs_layout        TYPE lvc_s_layo.


DATA:
  gt_knb1          TYPE STANDARD TABLE OF knb1,
  gt_knvv          TYPE STANDARD TABLE OF knvv.





*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler DEFINITION.

  PUBLIC SECTION.
    CLASS-METHODS:
      handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
        IMPORTING
          e_row
          e_column
          es_row_no
          sender.


ENDCLASS.                    "lcl_eventhandler DEFINITION



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

  METHOD handle_double_click.
*   define local data
    DATA:
      ls_knb1      TYPE knb1.

    CHECK ( sender = go_grid1 ).

    READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
    CHECK ( ls_knb1-kunnr IS NOT INITIAL ).

    CALL METHOD go_grid1->set_current_cell_via_id
      EXPORTING
*        IS_ROW_ID    =
*        IS_COLUMN_ID =
        is_row_no    = es_row_no.


*   Triggers PAI of the dynpro with the specified ok-code
    CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).



  ENDMETHOD.                    "handle_double_click

ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION






START-OF-SELECTION.

  SELECT        * FROM  knb1 INTO TABLE gt_knb1
         WHERE  bukrs  = '1000'.


* 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 splitter container
  CREATE OBJECT go_splitter
    EXPORTING
      parent            = go_docking
      rows              = 2
      columns           = 1
*      NO_AUTODEF_PROGID_DYNNR =
*      NAME              =
    EXCEPTIONS
      cntl_error        = 1
      cntl_system_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.

* Get cell container
  CALL METHOD go_splitter->get_container
    EXPORTING
      row       = 1
      column    = 1
    RECEIVING
      container = go_cell_top.
  CALL METHOD go_splitter->get_container
    EXPORTING
      row       = 2
      column    = 1
    RECEIVING
      container = go_cell_bottom.

* Create ALV grids
  CREATE OBJECT go_grid1
    EXPORTING
      i_parent          = go_cell_top
    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_double_click FOR go_grid1.


  CREATE OBJECT go_grid2
    EXPORTING
      i_parent          = go_cell_bottom
    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.


* Display data
  gs_layout-grid_title = 'Customers'.
  CALL METHOD go_grid1->set_table_for_first_display
    EXPORTING
      i_structure_name = 'KNB1'
      is_layout        = gs_layout
    CHANGING
      it_outtab        = gt_knb1
    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.

  gs_layout-grid_title = 'Customers Details (Sales Areas)'.
  CALL METHOD go_grid2->set_table_for_first_display
    EXPORTING
      i_structure_name = 'KNVV'
      is_layout        = gs_layout
    CHANGING
      it_outtab        = gt_knvv  " empty !!!
    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.


* NOTE: dynpro does not contain any elements
  CALL SCREEN '0100'.
* Flow logic of dynpro (does not contain any dynpro elements):
*
*PROCESS BEFORE OUTPUT.
*  MODULE STATUS_0100.
**
*PROCESS AFTER INPUT.
*  MODULE USER_COMMAND_0100.



END-OF-SELECTION.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS_0100'.  " contains push button "DETAIL"
*  SET TITLEBAR 'xxx'.


* Refresh display of detail ALV list
  CALL METHOD go_grid2->refresh_table_display
*    EXPORTING
*      IS_STABLE      =
*      I_SOFT_REFRESH =
    EXCEPTIONS
      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.


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.

*   User has pushed button "Display Details"
    WHEN 'DETAIL'.
      PERFORM entry_show_details.

    WHEN OTHERS.
  ENDCASE.

  CLEAR: gd_okcode.

ENDMODULE.                 " USER_COMMAND_0100  INPUT

*&---------------------------------------------------------------------*
*&      Form  ENTRY_SHOW_DETAILS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM entry_show_details .
* define local data
  DATA:
    ld_row      TYPE i,
    ls_knb1     TYPE knb1.

  CALL METHOD go_grid1->get_current_cell
    IMPORTING
      e_row = ld_row.

  READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
  CHECK ( syst-subrc = 0 ).

  SELECT        * FROM  knvv INTO TABLE gt_knvv
         WHERE  kunnr  = ls_knb1-kunnr.



ENDFORM.                    " ENTRY_SHOW_DETAILS

Regards

Uwe

Read only

Former Member
0 Likes
606

Hi Anu,

In the class CL_GUI_ALV_GRID (used to implement ALV Grids) there are some events defined to utilize some additional functionalities of the ALV Grid. For these types of functionalities, we require a class to be implemented (generally local in our program e.g. lcl_event_receiver in your program) to be the event handler for the ALV Grid instance.

The import parameters of the handler methods defined in the local class are basically nothing but the parameters of the events defined in global class CL_GUI_ALV_GRID. So you can check it using SE24 transaction. Select the event and press "PARAMETERS" button to see what parameters the event has and the same can be imported in the handler method of the event.

Check the following useful URL.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a41...

Award points if found useful.

Regards

Indrajit

Read only

Former Member
0 Likes
607

Hi Anu,

lcl_event_receiver is a local class defined. in transaction SE24 you can see all the standard classes meaning they are available globally like CL_GUI_ALV_GRID.

now suppose you need to display a grid , then you will create an object of this standard class and then use all the methods, events and elements of this class as it is available globally. after creating the class when you do some action say when you double click, then you need to perform your own action.

so we will define some local classes in our program and we will handle the events.

now when you double click depending on the column double clicked you need to perform some different action (like we use GET CURSOR statement) we can make use of e_column..similarly e_row will give the row no. clicked.

Regards,

Vidya.