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

OBJECT_OBJREF_NOT_ASSIGNED for Text editor

Former Member
0 Likes
385

We tried to use Text editor on a Screen which is RF enabled. It is working fine when we work in SAP. When this is being connected from LM01 the below error message is coming.

Runtime error: OBJECT_OBJREF_NOT_ASSIGNED

Exception: CX_SY_REF_INITIAL

The code:

IF g_editor IS INITIAL.

*-- Create custom Container

CREATE OBJECT g_editor_container

EXPORTING

container_name = 'EDITOR'

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.

ENDIF.

*-- Create Text Editor

CREATE OBJECT g_editor

EXPORTING

style = 0

max_number_chars = 28

wordwrap_mode = 2

wordwrap_position = 14

wordwrap_to_linebreak_mode = cl_gui_textedit=>false

parent = g_editor_container

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

gui_type_not_supported = 5

OTHERS = 6

.

IF sy-subrc <> 0.

ENDIF.

*-- Remove text editor toolbar

CALL METHOD g_editor->set_toolbar_mode

EXPORTING

toolbar_mode = cl_gui_textedit=>false

EXCEPTIONS

error_cntl_call_method = 1

invalid_parameter = 2

OTHERS = 3.

*--Remove text editor status bar

CALL METHOD g_editor->set_statusbar_mode

EXPORTING

statusbar_mode = cl_gui_textedit=>false

EXCEPTIONS

error_cntl_call_method = 1

invalid_parameter = 2

OTHERS = 3.

ENDIF.

Can someone please suggest what is missing here.

Thanks,

NKumar

1 REPLY 1
Read only

Former Member
0 Likes
297

Hi,

Looking at the code the problem seems to be at:

==============

IF g_editor IS INITIAL.

Create custom Container

CREATE OBJECT g_editor_container

EXPORTING

container_name = 'EDITOR'

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.

ENDIF.

Create Text Editor

CREATE OBJECT g_editor

EXPORTING

style = 0

max_number_chars = 28

wordwrap_mode = 2

wordwrap_position = 14

wordwrap_to_linebreak_mode = cl_gui_textedit=>false

parent = g_editor_container

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

gui_type_not_supported = 5

OTHERS = 6

.

IF sy-subrc 0.

ENDIF.

Remove text editor toolbar

CALL METHOD g_editor->set_toolbar_mode " This point

EXPORTING

toolbar_mode = cl_gui_textedit=>false

EXCEPTIONS

error_cntl_call_method = 1

invalid_parameter = 2

OTHERS = 3.

*--Remove text editor status bar

CALL METHOD g_editor->set_statusbar_mode " This point

EXPORTING

statusbar_mode = cl_gui_textedit=>false

EXCEPTIONS

error_cntl_call_method = 1

invalid_parameter = 2

OTHERS = 3.

ENDIF.

===============

You are creating the object "g_editor" and catching the exception. I think create object for g_editor is failing and since you are not checking this it is causing the problem.

You can fix the code as follows:

=====

IF g_editor IS INITIAL.

Create custom Container

CREATE OBJECT g_editor_container

EXPORTING

container_name = 'EDITOR'

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.

ENDIF.

Create Text Editor

CREATE OBJECT g_editor

EXPORTING

style = 0

max_number_chars = 28

wordwrap_mode = 2

wordwrap_position = 14

wordwrap_to_linebreak_mode = cl_gui_textedit=>false

parent = g_editor_container

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

gui_type_not_supported = 5

OTHERS = 6

.

IF sy-subrc 0. -


> put the below code under this if. That means the code is executed only

if g_editor is created.

Remove text editor toolbar

CALL METHOD g_editor->set_toolbar_mode " This point

EXPORTING

toolbar_mode = cl_gui_textedit=>false

EXCEPTIONS

error_cntl_call_method = 1

invalid_parameter = 2

OTHERS = 3.

*--Remove text editor status bar

CALL METHOD g_editor->set_statusbar_mode " This point

EXPORTING

statusbar_mode = cl_gui_textedit=>false

EXCEPTIONS

error_cntl_call_method = 1

invalid_parameter = 2

OTHERS = 3.

ENDIF.

ENDIF.

=====