2019 Jan 31 10:58 PM
Hi Experts,
Is there a trick to pass the exception message (in case of failure) of the function module to an abap variable ?
e.g. for the following FM there are 17 specified exceptions:
If an exception with ID INVALID_REQUEST is thrown, how can I store the text message in red in an abap string (exception_str) ?
Here is how I intend to use it:
IF sy-subrc <> 0.
MESSAGE exception_str TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
Any help will be appreciated.
Khaled
2019 Feb 01 1:59 PM
sy-msg* fields are already set by FM.
So you may simply output the message using sy-msg* fields:
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
2019 Jan 31 11:40 PM
The exception texts for function modules are stored in the data dictionary in table FUPARAREF
2019 Feb 01 12:23 AM
There are 2 type of message from function module ( I think):
One with raising exception and one without raising.
So for message with raising exception, you already have exception number and you check sy-subrc to get it. the message ID, number...is stored in system: SY-MSGID, SY-MSGTY...which if you call fm through pattern button, it will generate the code for you.
With message without raising exception, you have to add ERROR_MESSAGE to exception part of function module and do the same as above.
2019 Feb 01 1:59 PM
sy-msg* fields are already set by FM.
So you may simply output the message using sy-msg* fields:
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.