Skip to Content

get exception text using subrc and function module name

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.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Apr 11, 2016 at 11:54 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 11, 2016 at 11:44 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 11, 2016 at 12: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

    Add comment
    10|10000 characters needed characters exceeded