2016 Apr 11 12:15 PM
hi guru's,
how to fetch exception short text using the sy-subrc and fucntional module name.
example :
CALL FUNCTION 'EQUIPMENT_LOCK'
EXPORTING
equi_no = wa_equi-equnr
EXCEPTIONS
equi_not_found = 1
lock_failure = 2
OTHERS = 3.
if i get the subrc = 2 i want to get the text lock_failure in an variable .
please help.
thanks.
2016 Apr 11 12:44 PM
Try the below code.
data l_message type string.
CALL FUNCTION 'EQUIPMENT_LOCK'
EXPORTING
equi_no = wa_equi-equnr
EXCEPTIONS
equi_not_found = 1
lock_failure = 2
OTHERS = 3.
if sy-subrc <> 0.
call function 'FORMAT_MESSAGE'
exporting
id = sy-msgid
lang = sy-langu
no = sy-msgno
v1 = sy-msgv1
v2 = sy-msgv2
v3 = sy-msgv3
v4 = sy-msgv4
importing
msg = l_message
exceptions
not_found = 1
others = 2.
endif.
you will get the message in l_message.
2016 Apr 11 12:54 PM
Use FM FUNCTION_IMPORT_INTERFACE or read data from tables FUPARAREF and FUNCT.
Hint: Also check easy way to get the exception text returned by FM (without case/IF)
Regards,
Raymond
2016 Apr 11 1:04 PM
Hello,
You can use
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
ENDIF.
OR populate the text accordingly like, CASE sy-subrc. WHEN 1. v_error = 'EQUI_NOT_FOUND'. WHEN 2. v_error = 'LOCK_FAILURE'. ENDCASE. Regards, Syed