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: 

Events in oops ALV

Former Member
0 Kudos

Hi abap gurus,

             I'm having a small doubt regarding events in class cl_gui_alv_grid_display. Generally for a event to be triggered we follow these steps:

1.define a class for event handling.

2.define a method for a particular event in that class and then implement that class.

3.create object for that class.

4.register the event by using set_handler.

   My doubt is that whenever we do a particular action how that particular event is getting raised i.e., where Raise event code has been written

   because user_command event has been raised in raise_event of class cl_gui_alv_grid but this method is not accessed in any of the class or method

   still how that event is raising and in debugging mode if i keep break point in this method it is not triggering for user command event.

Regards,

Rakesh reddy challa.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Rakesh,

Events are not methods and they are not used as call method.

Events are triggers and methods are mapped to this triggers.

To call an event we use the RAISE EVENT command and that you can find in the EXECUTE_FCODE method of the class.

For more details of events.

http://help.sap.com/saphelp_nw70/helpdata/en/71/a8a77955bc11d194aa0000e8353423/content.htm

For further queries ASK cheers.

3 REPLIES 3

Former Member
0 Kudos

Hi Rakesh,

Events are not methods and they are not used as call method.

Events are triggers and methods are mapped to this triggers.

To call an event we use the RAISE EVENT command and that you can find in the EXECUTE_FCODE method of the class.

For more details of events.

http://help.sap.com/saphelp_nw70/helpdata/en/71/a8a77955bc11d194aa0000e8353423/content.htm

For further queries ASK cheers.

0 Kudos

Hi Yakub,

Thanks for your reply and if we talk about USER_COMMAND event,

When ever we click on a particular user defined button on the toolbar it is calling DISPATCH

method of the class and it in turn calling EXECUTE_FCODE method where the event is getting

raised.

But my question is that how that Dispatch method is getting called when ever we do a

particular action on the toolbar.

What is the link between user action and DISPATCH method of the class.

Former Member
0 Kudos

The raise_event is written in the CL_GUI_ALV_GRID class and the handler methods are called whenever event is raised.    Test with the provided working Example . Put your break point in the below method in case of double click.      method: dbl_click  .     call TRANSACTION 'SM30'.   ENDMETHOD.  ***************************************************************************  REPORT  Z_ALV.  Data: lt_data type STANDARD TABLE OF zemp. data: l_cust_cont type ref to cl_gui_custom_container,       l_grid type ref to cl_gui_alv_grid. data: l_cus_control type scrfname VALUE 'CUST_CONT'. DATA : OK_CODE TYPE SY-UCOMM.  DATA: LT_F TYPE LVC_t_FCAT. DATA: LW_f TYPE LVC_S_FCAT.   CLASS xyz DEFINITION.   PUBLIC SECTION.   methods: dbl_click FOR EVENT double_click of cl_gui_alv_grid importing e_row .   METHODS: HOT_SPOT FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID . ENDCLASS.  class xyz IMPLEMENTATION.   method: dbl_click  .     call TRANSACTION 'SM30'.   ENDMETHOD.    METHOD HOT_SPOT.     CALL TRANSACTION 'SE11'.   ENDMETHOD.  ENDCLASS.  data: ca type ref to xyz.  START-OF-SELECTION. Select * FROM zemp into TABLE lt_data. CALL SCREEN '0001'. *&---------------------------------------------------------------------* *&      Module  STATUS_0001  OUTPUT *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* MODULE STATUS_0001 OUTPUT.   SET PF-STATUS 'PF'. *  SET TITLEBAR 'xxx'.    PERFORM display_alv . create object ca. set HANDLER ca->dbl_click for l_grid. SET HANDLER CA->HOT_SPOT FOR L_GRID.   ENDMODULE.                 " STATUS_0001  OUTPUT *&---------------------------------------------------------------------* *&      Form  DISPLAY_ALV *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* *  -->  p1        text *  <--  p2        text *----------------------------------------------------------------------* FORM DISPLAY_ALV .     DATA: var type disvariant.     var-REPORT = sy-cprog.   CREATE OBJECT L_CUST_CONT     EXPORTING *      PARENT                      =       CONTAINER_NAME              = l_cus_control. *      STYLE                       = *      LIFETIME                    = lifetime_default *      REPID                       = *      DYNNR                       = *      NO_AUTODEF_PROGID_DYNNR     = *    EXCEPTIONS *      CNTL_ERROR                  = 1 *      CNTL_SYSTEM_ERROR           = 2 *      CREATE_ERROR                = 3 *      LIFETIME_ERROR              = 4 *      LIFETIME_DYNPRO_DYNPRO_LINK = 5 *      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 OBJECT L_GRID     EXPORTING *      I_SHELLSTYLE      = 0 *      I_LIFETIME        =       I_PARENT          = l_cust_cont.    IF SY-SUBRC <> 0. *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.   ENDIF.  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'  EXPORTING *   I_BUFFER_ACTIVE              =    I_STRUCTURE_NAME             =  'ZEMP' *   I_CLIENT_NEVER_DISPLAY       = 'X' *   I_BYPASSING_BUFFER           = *   I_INTERNAL_TABNAME           =   CHANGING     CT_FIELDCAT                  =  LT_F * EXCEPTIONS *   INCONSISTENT_INTERFACE       = 1 *   PROGRAM_ERROR                = 2 *   OTHERS                       = 3           . IF SY-SUBRC <> 0. * Implement suitable error handling here ENDIF.   lOOP AT LT_F INTO LW_F.    IF LW_f-FIELDNAME = 'NAME'.     LW_f-HOTSPOT = 'X'.     MODIFY LT_f FROM lW_f .   ELSEIF LW_f-FIELDNAME = 'NUM'.    LW_f-DO_SUM = 'C'.    MODIFY LT_f FROM lW_f .    ENDIF.    ENDLOOP.  CALL METHOD L_GRID->SET_TABLE_FOR_FIRST_DISPLAY     EXPORTING       I_STRUCTURE_NAME               = 'ZEMP'       IS_VARIANT                     = var       I_SAVE                         = 'U'       I_DEFAULT                     = 'X'     CHANGING       IT_OUTTAB                     = lt_data[]       IT_FIELDCATALOG               = LT_f *      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.    ENDFORM.                    " DISPLAY_ALV *&---------------------------------------------------------------------* *&      Module  STATUS_0002  INPUT *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* MODULE STATUS_0002 INPUT.  CASE OK_CODE.   WHEN 'BACK'.         SET SCREEN 0.  ENDCASE.    ENDMODULE.