Last active
May 20, 2021 14:54
-
-
Save js1972/7af08e42b9d727189207 to your computer and use it in GitHub Desktop.
Example ABAP code using the IF_RECA_MESSAGE_LIST interface for application log logging.
Note there needs to be a commit somewhere after the store() call.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Create MDG change pointers if email or street2 have changed | |
try. | |
data(mdg_cp) = value mdg_cp_s_cp( object_key = vendor ). | |
"Create a MDG Change Pointer so Vendor can be replicated later via DRF (TCODE DRFOUT) | |
call method cl_mdg_change_pointer=>create_cp | |
exporting | |
iv_business_object = 'ZM_VENDOR' | |
is_change_pointer = mdg_cp. | |
catch | |
cx_mdg_cp_no_bus_system | |
cx_mdg_change_pointer | |
cx_mdg_cp_no_business_object | |
cx_mdg_cp_missing_obj_key | |
cx_mdg_cp_misc | |
cx_mdg_cp_exception | |
into data(exception_obj). | |
data(log) = cf_reca_message_list=>create( id_object = 'ZMM' id_subobject = 'VENDOR' ). | |
log->add_from_exception( exception_obj ). | |
" add some details as well via via SY vars | |
call method cl_reca_string_services=>raise_string_as_symsg | |
exporting | |
id_string = |Failed to raise MDG change pointer for Vendor { vendor }| | |
id_msgty = 'E' | |
exceptions | |
message = 1 | |
others = 2. | |
if sy-subrc <> 0. | |
log->add_symsg( ). | |
endif. | |
log->store( ). | |
endtry. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
report y_test_abap_log. | |
" Small test program to force the creation of an application log entry | |
start-of-selection. | |
data(log) = cf_reca_message_list=>create( id_object = 'ZMM' id_subobject = 'ZMM_LE_SHP_DL' ). | |
" add some details as well via via SY vars | |
call method cl_reca_string_services=>raise_string_as_symsg | |
exporting | |
id_string = |This is a test error that will get picked up by CCMS monitoring.| | |
id_msgty = 'E' | |
exceptions | |
message = 1 | |
others = 2. | |
if sy-subrc <> 0. | |
log->add_symsg( ). | |
endif. | |
log->store( ). | |
commit work. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment