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

unable to create object

Former Member
0 Likes
1,636

Hi Abapers,

I have written the code like this.

----


  • CLASS lcl_event_receiver 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.

DATA CHECK_BOX TYPE C.

ENDCLASS.

----


  • CLASS LCL_EVENT_RECEIVER IMPLENTATION

----


  • ........ *

----


CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.

METHOD HANDLE_DOUBLE_CLICK.

READ TABLE ALV_ITAB INDEX E_ROW-INDEX INTO WA_ITAB.

PERFORM DATARETRIEVALTAB2 USING WA_ITAB.

IF CHECK_BOX IS INITIAL.

CHECK_BOX = 'x'.

PERFORM CREATE_DETAIL_LIST.

ELSE.

CALL METHOD CL_DIALOGBOX_OBJ->SET_VISIBLE

EXPORTING

VISIBLE = 'x'.

  • CALL METHOD CL_ALV_OBJ1->REFRESH_TABLE_DISPLAY.

ENDIF.

ENDMETHOD.

METHOD HANDLE_CLOSE.

CALL METHOD SENDER->SET_VISIBLE

EXPORTING

VISIBLE = SPACE.

ENDMETHOD.

ENDCLASS.

but when I am creating the object

data event_obj type ref to lcl_event_receiver.

It is showing error that type lcl_event_receiver is unknown.

Kindly tell me the reason.

Regards

Ansuman

6 REPLIES 6
Read only

Former Member
0 Likes
976

Hi!

I think you are creating object before defining the class.

First define the class, under that create the object.

Regards

Abhijeet

Read only

Former Member
0 Likes
976

hi,

Make Sure You are Defining Objects in the DAta Section but

You are Creating them in START-OF_SELECTION event.

You have to explicitly write the event Statement.

Check this out.

Regards

Sumit Agarwal

Read only

Former Member
0 Likes
976

Hi Ansuman,

go through following piece of code and define accordingly...

i hope u will get the solution..

*&----


*& Class Declaration

*&----


class lcl_event_receiver definition deferred.

class lcl_event_receiver1 definition deferred.

data gr_events_reciever type ref to lcl_event_receiver.

data gr_events_reciever1 type ref to lcl_event_receiver1.

*&----


*& Class Definition

*&----


class lcl_event_receiver definition.

public section.

methods:

double_click

for event double_click of cl_gui_alv_grid

importing e_row e_column .

endclass. "lcl_event_receiver DEFINITION

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

class lcl_event_receiver1 definition.

public section.

methods:

handle_double_click1

for event double_click of cl_gui_alv_grid

importing e_row e_column .

endclass. "lcl_event_receiver DEFINITION

*&----


*& CLASS IMPLEMETATION

*&----


class lcl_event_receiver implementation.

method double_click.

perform event_double_click using e_row e_column.

endmethod. "handle_double_click

endclass. "lcl_event_receiver IMPLEMENTATION

----


  • CLASS lcl_event_receiver1 IMPLEMENTATION

----


*

----


class lcl_event_receiver1 implementation.

method handle_double_click1.

perform event_double_click1 using e_row e_column.

endmethod. "handle_double_click

endclass. "lcl_event_receiver1

Thanks& Regards

Ashu Singh.

Read only

Former Member
0 Likes
976

Hi Ansuman,

For your reference..

*---------------------------------------------------------------------*
*       CLASS lcl_event_receiver 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.

    DATA check_box TYPE c.

ENDCLASS.                    "LCL_EVENT_RECEIVER DEFINITION

*---------------------------------------------------------------------*
*       CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD handle_double_click.
**    your code
  ENDMETHOD.                    "HANDLE_DOUBLE_CLICK

  METHOD handle_close.
**    your code
  ENDMETHOD.                    "HANDLE_CLOSE
ENDCLASS.                    "LCL_EVENT_RECEIVER DEFINITION

DATA cobj TYPE REF TO lcl_event_receiver.

START-OF-SELECTION.
  CREATE OBJECT cobj.

Read only

Former Member
0 Likes
976

Hi Ansuman,

Kindly create the object in the following way:

DATA:OBJ TYPE REF TO <CLASS NAME>.

START-OF-SELECTION.

CREATE OBJECT OBJ.

Always use 'START-OF-SELECTION' event to avoid such errors.

Reward if useful.

Cheers,

Vaishnavi Putlur.

Read only

former_member8532
Participant
0 Likes
976

hi,

just write this at the top "class lcl_event_receiver definition deferred."

because if you try to use a class before use it will give you an like u are getting just tell the compiler by writing "class lcl_event_receiver definition deferred." that you have defined class. just create object.

Thnaks & Regards.

Punit