2020 Sep 29 4:48 AM
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.
2020 Sep 29 5:46 AM
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.
2020 Sep 29 5:46 AM
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.
2020 Sep 29 7:16 AM
I guess you mean the error message /SCMB/ESA_EMULATION025 "ID &1 is already registered at controller".
2020 Sep 29 7:58 AM
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.
2020 Sep 29 8:09 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |