Skip to Content
author's profile photo Former Member
Former Member

How to read error messages at runtime

Hi Mates,

I got a requirement need to read error details(class n number) at runtime.

I have tried with some fm's message_collect,...etc but it is not picking all messages. My need is however error message was thrown using message statement or BADI or fm's...etc, I should read at runtime.

Thanks in advance.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Sep 04, 2013 at 07:03 AM


    Do like below,

    if sy-subrc <> 0.

    "Read your error message.




    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 04, 2013 at 08:50 AM

    When the statement is executed, the following system variables are set:
    * SY-MSGID (Message class)
    *SY-MSGTY (Message type)
    * SY-MSGNO (Message number)

    So the details can be retreived from the above variables.

    if sy-subrc ne 0.

    call function 'MESSAGE_TEXT_BUILD'


    msgid = sy-msgid "Messg class

    msgnr = sy-msgno "Messg No.

    msgv1 =

    msgv2 =

    msgv3 =

    msgv4 =


    message_text_output = sapmessage.


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.