Fairly standard scenario: I've got this.
DATA: l_requester TYPE xubname.
CALL FUNCTION 'ENQUEUE_EZMYTAB'
EXPORTING
username = i_username
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
CASE sy-subrc.
WHEN 1.
l_requester = sy-msgv1.
RAISE EXCEPTION TYPE zcx_my_exception EXPORTING textid = zcx_my_exception=>lock_error
user = i_username
lockedby = l_requester.
WHEN 2.
RAISE EXCEPTION TYPE zcx_my_exception.
ENDCASE.
But what I really want for WHEN 2 is the class based exception of
MESSAGE sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1...
I.e., in my calling code, I want to catch the exception, and display whatever the original error message was as generated by the ENQUEUE function module.
I suppose I could do this
DATA: ls_error TYPE scx_t100key. ... WHEN 2. ls_error-msgid = sy-msgid. ls_error-msgty = sy-msgty. ls_error-msgno = sy-msgno. ... RAISE EXCEPTION TYPE zcx_my_exception EXPORTING textid = ls_error
but I can't help feel I'm missing something staggeringly obvious...
matt