‎2007 Apr 09 8:50 AM
*----------------------------------------------------------------------*
***INCLUDE MZTEST_CLASS .
*----------------------------------------------------------------------*
DATA gr_event_handler TYPE REF TO lcl_event_handler .
.. ..
*--Creating an instance for the event handler
CREATE OBJECT gr_event_handler .
*--Registering handler methods to handle ALV Grid events
SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid .
*&---------------------------------------------------------------------*
*& Class LCL_EVENT_HANDLER
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION .
METHODS:
*--Double-click control
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
ENDCLASS. "LCL_EVENT_HANDLER
*&---------------------------------------------------------------------*
*& Class (Implementation) lcl_event_handler
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.
--Handle Double Click
METHOD handle_double_click .
PERFORM handle_double_click USING e_row es_row_no .
ENDMETHOD . "handle_double_click
ENDCLASS. "lcl_event_handlerI got the below error for the above code
<b>
The type "LCL_EVENT_HANDLER" is unknown.</b>
can u guys help me out
‎2007 Apr 09 10:01 AM
Have these statements at last instead of first:
DATA gr_event_handler TYPE REF TO lcl_event_handler .
.. ..
*--Creating an instance for the event handler
CREATE OBJECT gr_event_handler .
*--Registering handler methods to handle ALV Grid events
SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid .
Regards,
Ravi
OR
<b>use this statement at first:
Predefine a local class for event handling to allow the
declaration of a reference variable before the class is defined.
CLASS lcl_event_receiver DEFINITION DEFERRED.</b>
Message was edited by:
Ravi Kanth Talagana
‎2007 Apr 09 8:55 AM
HI,
Check whether the handler LCL_EVENT_HANDLER was declared as PUBLIC or not?May be it declared as Private or protected..that's why it says here that it is not known.
change it to PUBLIC and see.
reward if useful
regards,
ANJI
‎2007 Apr 09 9:02 AM
dear anji
can you tell me in detail where it has to be declared Public is there any error in the given code
‎2007 Apr 09 9:08 AM
‎2007 Apr 09 11:20 AM
Hi,
The error is occuring at the declaration
DATA gr_event_handler TYPE REF TO lcl_event_handler
this is the include program, So in this include you are creating a object
gr_event_handler with reference to <b>lcl_event_handler</b> which wasmight have declared in the main program. check for the definition of that.
in which class/interface it was defined?
Since you are using in this include, for this include it is unknown, so the error is occuring. check the main program..
regards,
ANJI
‎2007 Apr 09 9:58 AM
‎2007 Apr 09 10:01 AM
Have these statements at last instead of first:
DATA gr_event_handler TYPE REF TO lcl_event_handler .
.. ..
*--Creating an instance for the event handler
CREATE OBJECT gr_event_handler .
*--Registering handler methods to handle ALV Grid events
SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid .
Regards,
Ravi
OR
<b>use this statement at first:
Predefine a local class for event handling to allow the
declaration of a reference variable before the class is defined.
CLASS lcl_event_receiver DEFINITION DEFERRED.</b>
Message was edited by:
Ravi Kanth Talagana
‎2007 Apr 09 11:10 AM
i have put those lines in the last now i got this error
Statement is not accessible.
at line CREATE OBJECT gr_event_handler .
*----------------------------------------------------------------------*
***INCLUDE MZVENDOR_CLASS .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Class LCL_EVENT_HANDLER
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
*--Double-click control
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
PRIVATE SECTION.
ENDCLASS. "LCL_EVENT_HANDLER
*&---------------------------------------------------------------------*
*& Class (Implementation) lcl_event_handler
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.
*--handle double click
METHOD handle_double_click .
PERFORM handle_double_click USING e_row e_column .
ENDMETHOD . "handle_double_click
ENDCLASS. "lcl_event_handler
DATA gr_event_handler TYPE REF TO lcl_event_handler .
CREATE OBJECT gr_event_handler .
SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid .
‎2007 Apr 09 11:13 AM
Did you try my second suggestion?
Follow the code in BCALV_GRID_05 program.
Regards,
Ravi
‎2007 Apr 09 12:31 PM
‎2007 Apr 09 11:50 AM
----
***INCLUDE MZTEST_CLASS .
----
CLASS lcl_event_handler DEFINITION DEFERRED. <<---- Add this line
DATA gr_event_handler TYPE REF TO lcl_event_handler .
Now, go on and declare the class. You can instantiate the class only once you have declared it. So, "Create Object " should come after the class definition and implementation.