10-20-2011 1:28 PM
Hi,
I've created a exception class. When I created it I selected the optoin "With Message Class" to add MsgIDs behind the texts.
I'm raising an exception which I catch into an object reference
......
raise exception type zcx_dispatcher
exporting textid = zcx_dispatcher=>no_equipment_packages_selected.
catching it with:
lo_error type ref to zcx_dispatcher
catch zcx_dispatcher into lo_error.
Now I want to log the error in the Application Log. So I'm calling a method to add this message.
data ls_exception type bal_s_exc.
ls_exception-msgty = pi_msgty.
ls_exception-exception = pi_exception. (<= my exception class)
ls_exception-detlevel = 1.
convert date sy-datum time sy-uzeit into time stamp ls_exception-time_stmp time zone sy-zonlo.
call function 'BAL_LOG_EXCEPTION_ADD'
exporting
i_log_handle = iv_handle
i_s_exc = ls_exception
exceptions
log_not_found = 1
msg_inconsistent = 2
log_is_full = 3.
The error log is being written and saved. If I go to TA SLG1 and select the error message I can't see any text. It looks like it does not find the MSGNO:
Message Text
Technical Data
Message type__________ E (Error)
Exception Class_______ ZCX_DISPATCHER
Exception ID__________
Message Attributes
Level of detail_______ 1 (Level of detail 1)
Problem class_________
Sort criterion________
Anyone any ideas?
Edited by: Daniel Winter on Oct 20, 2011 2:32 PM
10-21-2011 12:54 AM
FM BAL_LOG_MSG_ADD can be used to add Message class, ID and message variables. It can be added in the same handle.
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_s_msg = wa_log_final
i_log_handle = gv_handle
EXCEPTIONS
log_not_found = 0
OTHERS = 1.
10-21-2011 7:31 AM
Hello,
I know this FM. But I want to add a reference of a exception class to the application log.
I figured out the problem by myself. Apperantly the FM is not able to handle a reference of an expcetion class which uses a message class for the error texts.
If I use standard OTR texts everything is working fine...
If someone is interested in the problem. The error occurs in Include LSBALF26
* get attributes of exception
call method cl_message=>create_for_exception
exporting
the_exception = i_s_exc-exception
receiving
result = l_result.
* exception -> type OTR-message or T100-message?
catch system-exceptions move_cast_error = 4.
l_otr_message ?= l_result.
endcatch.
if sy-subrc = 4.
catch system-exceptions move_cast_error = 4.
l_t100_message ?= l_result.
endcatch.
if sy-subrc = 4.
message e203(bl) raising msg_inconsistent.
endif.
endif.
Method create_for_exception throws an exception.