消息控制[系统]

Moudle : MM_MESSAGES_MAC .

mmpur_message 'W' 'ZEMM' '045' '100,000,000' '' '' ''.

//--------------------------------------------------------------------------

CLASS cl_message_mm DEFINITION LOAD.

DATA: gl_handle TYPE REF TO cl_handle_mm,
gl_dummy(72),
gl_message_handler TYPE REF TO cl_message_handler_mm,
gl_subrc TYPE sy-subrc,
gl_tabix TYPE sy-tabix,
gl_objdesc TYPE mepo_objdesc.

************************************************************************
* *
* Current business Object *
* *
************************************************************************
DEFINE mmpur_business_obj.
gl_subrc = sy-subrc.
gl_tabix = sy-tabix.
call method cl_message_mm=>set_current_business_obj
exporting im_business_obj = &1.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.

DEFINE mmpur_business_obj_id.
gl_subrc = sy-subrc.
gl_tabix = sy-tabix.
call method cl_handle_manager_mm=>get
exporting im_id = &1
importing ex_handle = gl_handle.

call method cl_message_mm=>set_current_business_obj
exporting im_business_obj = gl_handle.
call method cl_message_mm=>set_current_context
exporting im_context = 5.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.

DEFINE mmpur_obj_from_id.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.
call method cl_handle_manager_mm=>get
exporting im_id = &1
importing ex_handle = &2.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.

* Definitions via varkey (non object Case)
DEFINE mmpur_business_obj_hd.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.
clear gl_objdesc.
gl_objdesc-objtyp = cl_po_header_handle_mm=>c_objtyp.
gl_objdesc-varkey+0(10) = &1.
call method cl_message_mm=>set_current_business_obj
exporting im_business_obj_var = gl_objdesc.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.

DEFINE mmpur_business_obj_it.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.
clear gl_objdesc.
gl_objdesc-objtyp = cl_po_item_handle_mm=>c_objtyp.
gl_objdesc-varkey+0(10) = &1.
gl_objdesc-varkey+10(5) = &2.
call method cl_message_mm=>set_current_business_obj
exporting im_business_obj_var = gl_objdesc.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.

DEFINE mmpur_business_obj_sc.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.
clear gl_objdesc.
gl_objdesc-objtyp = cl_po_schedule_handle_mm=>c_objtyp.
gl_objdesc-varkey+0(10) = &1.
gl_objdesc-varkey+10(5) = &2.
gl_objdesc-varkey+15(4) = &3.
call method cl_message_mm=>set_current_business_obj
exporting im_business_obj_var = gl_objdesc.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.

DEFINE mmpur_business_obj_ac.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.
clear gl_objdesc.
gl_objdesc-objtyp = cl_po_accounting_handle_mm=>c_objtyp.
gl_objdesc-varkey+0(10) = &1.
gl_objdesc-varkey+10(5) = &2.
gl_objdesc-varkey+15(2) = &3.
call method cl_message_mm=>set_current_business_obj
exporting im_business_obj_var = gl_objdesc.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.


************************************************************************
* *
* meta fields *
* *
************************************************************************
DEFINE mmpur_metafield.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.
call method cl_contextfield_mm=>set_current_field
exporting im_field = &1.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.
*
DEFINE mmpur_metafield_add.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.
call method cl_contextfield_mm=>add_to_current_fields
exporting im_field = &1.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.
*-----------------------------------------------------------------------
*
* Context
*
*-----------------------------------------------------------------------
DEFINE mmpur_context.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.
call method cl_message_mm=>set_current_context
exporting im_context = &1.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.
************************************************************************
* *
* Events *
* *
************************************************************************
DEFINE mmpur_message_config.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.
call method cl_message_mm=>configure exporting im_msgty = &1
im_dialog = &2
im_collect = &3
exceptions failure = 01.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.


* simple replacement of the ABAP message statement

DEFINE mmpur_message.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.

message id &2 type &1 number &3 with &4 &5 &6 &7 into gl_dummy.

call method cl_message_mm=>create exporting im_msgid = &2
im_msgty = &1
im_msgno = &3
im_msgv1 = sy-msgv1
im_msgv2 = sy-msgv2
im_msgv3 = sy-msgv3
im_msgv4 = sy-msgv4
exceptions failure = 01
dialog = 02.
if sy-subrc = 1 or sy-subrc = 2.

message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.

* configurable message ( T160M )

DEFINE mmpur_message_enaco.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.

message id &2 type 'W' number &3 with &4 &5 &6 &7 into gl_dummy.

call method cl_message_mm=>create exporting im_msgid = &2
im_msgty = &1
im_msgno = &3
im_msgv1 = sy-msgv1
im_msgv2 = sy-msgv2
im_msgv3 = sy-msgv3
im_msgv4 = sy-msgv4
im_custom = 1
exceptions failure = 01
dialog = 02.
if sy-subrc = 1 or sy-subrc = 2.

message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.

DEFINE mmpur_message_enaco_forced.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.
message id &2 type 'W' number &3 with &4 &5 &6 &7 into gl_dummy.
clear sy-msgty.
call method cl_message_mm=>create exporting im_msgid = &2
im_msgty = &1
im_msgno = &3
im_msgv1 = sy-msgv1
im_msgv2 = sy-msgv2
im_msgv3 = sy-msgv3
im_msgv4 = sy-msgv4
im_custom = 1
im_force_collect = mmpur_yes
exceptions failure = 01
dialog = 02.
if sy-subrc = 1 or sy-subrc = 2.

message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.

* specialized version of mmpur_message: useful for soft
* error messages

DEFINE mmpur_message_forced.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.
message id &2 type &1 number &3 with &4 &5 &6 &7 into gl_dummy.

call method cl_message_mm=>create exporting im_msgid = &2
im_msgty = &1
im_msgno = &3
im_msgv1 = sy-msgv1
im_msgv2 = sy-msgv2
im_msgv3 = sy-msgv3
im_msgv4 = sy-msgv4
im_force_collect = mmpur_yes
exceptions failure = 01
dialog = 02.
if sy-subrc = 1 or sy-subrc = 2.

message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.

DEFINE mmpur_remove_messages_by_id.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.
call method cl_handle_manager_mm=>get
exporting im_id = &1
importing ex_handle = gl_handle.

call method cl_message_handler_mm=>get_handler importing
ex_handler = gl_message_handler.

call method gl_message_handler->remove_by_bo exporting
im_business_obj = gl_handle
im_context = 5.
sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.

DEFINE mmpur_remove_msg_by_context.
gl_tabix = sy-tabix.
gl_subrc = sy-subrc.
call method cl_handle_manager_mm=>get
exporting im_id = &1
importing ex_handle = gl_handle.
call method cl_message_handler_mm=>get_handler
importing ex_handler = gl_message_handler.
call method gl_message_handler->remove_by_bo
exporting im_business_obj = gl_handle
im_context = &2.

sy-subrc = gl_subrc.
sy-tabix = gl_tabix.
END-OF-DEFINITION.

你可能感兴趣的:(C++,c,C#)