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

MESSAGE MESSAGE_HANDLER is already registe

former_member660488
Participant
0 Likes
3,505

Hi Expert,

When run the "CREATE OBJECT gx_msg_hndler" message MESSAGE_HANDLER is already registe,how to

deal with the error?

DATA:

gx_cancpick TYPE REF TO /scwm/cl_cancpick_sp,

gx_attr_hndler TYPE REF TO /scmb/cl_attribute_handler,
gx_msg_hndler TYPE REF TO /scmb/cl_message_handler.

CREATE OBJECT gx_attr_hndler.
CREATE OBJECT gx_msg_hndler.

CREATE OBJECT gx_cancpick
EXPORTING
io_attribute_handler = gx_attr_hndler
io_message_handler = gx_msg_hndler.

1 ACCEPTED SOLUTION
Read only

michael_piesche
Active Contributor
2,562

This error happens obviously, when you are running a second time through your coding, when those objects have been created before already (You probably run your programm, return to the selection screen and run it again, without closing the screen. All global variables will still exist in this case).

Because the creation of an object for class /scmb/cl_message_handler also creates a static object for class /scmb/cl_controller with values that are checked against during creation, you would have to initialize the static object of class /scmb/cl_controller before hand.

Option A)
Dont recreate the object if it already exists and it doesnt need to be recreated.

DATA: gx_cancpick    TYPE REF TO /scwm/cl_cancpick_sp,
      gx_attr_hndler TYPE REF TO /scmb/cl_attribute_handler,
      gx_msg_hndler  TYPE REF TO /scmb/cl_message_handler.

IF gx_msg_hndler IS NOT BOUND.
  CREATE OBJECT gx_msg_hndler.
ENDIF.

CREATE OBJECT gx_attr_hndler.
CREATE OBJECT gx_cancpick EXPORTING io_attribute_handler = gx_attr_hndler
                                    io_message_handler = gx_msg_hndler.<br>

Option B)
Recreate the object if it needs recreation in case it already exists.

DATA: gx_cancpick    TYPE REF TO /scwm/cl_cancpick_sp,
      gx_attr_hndler TYPE REF TO /scmb/cl_attribute_handler,
      gx_msg_hndler  TYPE REF TO /scmb/cl_message_handler,

      gx_contrl      TYPE REF TO /scmb/cl_controller.

gx_contrl = /scmb/cl_controller=>get_instance( ).
IF gx_contrl IS BOUND AND gx_msg_hndler IS BOUND.
  gx_contrl->initialize( io_tm = gx_msg_hndler ).
ENDIF.
CREATE OBJECT gx_msg_hndler.

CREATE OBJECT gx_attr_hndler.
CREATE OBJECT gx_cancpick EXPORTING io_attribute_handler = gx_attr_hndler
                                    io_message_handler = gx_msg_hndler.

Hi Expert,

When run the "CREATE OBJECT gx_msg_hndler" message MESSAGE_HANDLER is already registe,how to

deal with the error?

DATA:

gx_cancpick TYPE REF TO /scwm/cl_cancpick_sp,

gx_attr_hndler TYPE REF TO /scmb/cl_attribute_handler,
gx_msg_hndler TYPE REF TO /scmb/cl_message_handler.

CREATE OBJECT gx_attr_hndler.
CREATE OBJECT gx_msg_hndler.

CREATE OBJECT gx_cancpick
EXPORTING
io_attribute_handler = gx_attr_hndler
io_message_handler = gx_msg_hndler.

4 REPLIES 4
Read only

michael_piesche
Active Contributor
2,563

This error happens obviously, when you are running a second time through your coding, when those objects have been created before already (You probably run your programm, return to the selection screen and run it again, without closing the screen. All global variables will still exist in this case).

Because the creation of an object for class /scmb/cl_message_handler also creates a static object for class /scmb/cl_controller with values that are checked against during creation, you would have to initialize the static object of class /scmb/cl_controller before hand.

Option A)
Dont recreate the object if it already exists and it doesnt need to be recreated.

DATA: gx_cancpick    TYPE REF TO /scwm/cl_cancpick_sp,
      gx_attr_hndler TYPE REF TO /scmb/cl_attribute_handler,
      gx_msg_hndler  TYPE REF TO /scmb/cl_message_handler.

IF gx_msg_hndler IS NOT BOUND.
  CREATE OBJECT gx_msg_hndler.
ENDIF.

CREATE OBJECT gx_attr_hndler.
CREATE OBJECT gx_cancpick EXPORTING io_attribute_handler = gx_attr_hndler
                                    io_message_handler = gx_msg_hndler.<br>

Option B)
Recreate the object if it needs recreation in case it already exists.

DATA: gx_cancpick    TYPE REF TO /scwm/cl_cancpick_sp,
      gx_attr_hndler TYPE REF TO /scmb/cl_attribute_handler,
      gx_msg_hndler  TYPE REF TO /scmb/cl_message_handler,

      gx_contrl      TYPE REF TO /scmb/cl_controller.

gx_contrl = /scmb/cl_controller=>get_instance( ).
IF gx_contrl IS BOUND AND gx_msg_hndler IS BOUND.
  gx_contrl->initialize( io_tm = gx_msg_hndler ).
ENDIF.
CREATE OBJECT gx_msg_hndler.

CREATE OBJECT gx_attr_hndler.
CREATE OBJECT gx_cancpick EXPORTING io_attribute_handler = gx_attr_hndler
                                    io_message_handler = gx_msg_hndler.
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,562

I guess you mean the error message /SCMB/ESA_EMULATION025 "ID &1 is already registered at controller".

Read only

former_member660488
Participant
0 Likes
2,562

The Option B works well,the option A is not work,Thank you so much!

the gx_msg_hndler is a local variable in a perfrom,every run the object is initial.

gx_contrl = /scmb/cl_controller=>get_instance( ).

gx_contrl->initialize( io_tm = gx_msg_hndler ).

CREATE OBJECT gx_attr_hndler.
CREATE OBJECT gx_msg_hndler.

CREATE OBJECT gx_cancpick
EXPORTING
io_attribute_handler = gx_attr_hndler
io_message_handler = gx_msg_hndler.

Read only

former_member660488
Participant
0 Likes
2,562

Yes,the message number is /SCMB/ESA_EMULATION025