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

Exception in RFC

Hi,

could anybody tell me how to raise exception in RFC.If anybody can tell me with some example.

Thanks in advance.

Regards

Lalit

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 14, 2008 at 08:52 AM

    hi..

    Try to set some flag in rfc and after function call checkthe flag value and raise app error message

    regards

    vivek

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 14, 2008 at 08:56 AM

    you can use the RAISE statement to raise an exception in a function module. the exception should be first defined in the exceptions tab in the function module.

    after the fm is called, if the exception is raised, the value will be available in sy-subrc.

    Example..

    define an exception DATA_NOT_FOUND in the exceptions tab.

    write a select query in the function module, if it returns sy-subrc as non-zero, then raise this exception.

    select............<your select query>

    if sy-subrc ne 0.

    raise data_not_found.

    endif.

    in the calling program...

    call function <function name>

    exporting.....

    importing....

    EXCEPTIONS

    DATA_NOT_FOUND = 1 (this number will depend on the order in which you have defined exceptions in exceptions tab...1 means it is defined first, 2 will stand

    for the second exception)

    in case the exception is raised, the value of

    Edited by: Priyank Jain on Aug 14, 2008 4:56 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 14, 2008 at 08:58 AM

    I have written th exception in the exception tab..but when i run the function module its giving me dump.do I need to do something extra means write some code.

    I have written the raise exception in the source code.

    Regards

    Lalit

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      you need to catch the exception also when calling your fm...

      this is done through the EXCEPTIONS addition in the call function statement

      ....and i hope your raise exception statement is in the source code of FM and not in the calling program

      Edited by: Priyank Jain on Aug 14, 2008 4:59 AM

  • author's profile photo Former Member
    Former Member
    Posted on Aug 14, 2008 at 08:59 AM

    Hi,

    Go to the exceptions tab and maintain some exception with short text.Suppose exception is exception1

    Now in the source code,

    write :

    if sy-uname <> ' ABCD'.

    raise exception1.

    endif.

    Thanks

    Papiya

    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.