Skip to Content

Question on RFC handling in sap

Hi Experts,

I know we can use RFC for communicating from external system to R3 or from R3 to external system, I have a question on the exception handling done.

If we are communicating from R3 to external system, we would use as

CALL FUNCTION FM NAME DESTINATION DEST NAME

Exceptions

exceptions and based on the sy-subrc value the exception is caught

and if we are calling from external system how are the exceptions handled I had gone through the links below

https://help.sap.com/abapdocu_731/en/abenrfc_exceptions_abexa.htm

https://help.sap.com/saphelp_nwpi71/helpdata/en/13/90a594a1ab0841bbb731bdec1a7fd7/content.htm

Thanks,

rg

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Nov 08, 2016 at 06:53 AM

    Hi Ramya G,

    Exception Handling will be effective one, You want to prevent your RFC should not goes to dump, Then you should keep exceptions in your RFC.

    The following two exceptions are SAP Standard Exceptions,

    system_failure = 1

    communication_failure = 2

    You can use these exceptions in your Program(Program which you are executing RFC),

    After that RFC function module(if you kept these standard exceptions), Then system will come from RFC without dump incase any system failure or communication failure happen.

    You can caught it using sy-subrc,

    Everything ok then sy-subrc = 0.

    System failure happens , then sy-subrc = 1

    Communication failure happens, then sy-subrc = 2.

    Answer for your Question: you need to developed report program/ class to handle exceptions, From where you are calling this RFM using CALL FUNCTION FM NAME DESTINATION DEST NAME.

    Note: you can implement your custom exceptions also, while creating Function module itself.

    Thanks,

    Sivaraj Sadasivam.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 08, 2016 at 01:37 PM

    Are you asking about an external non-SAP system to SAP? The RFC connector that is used for Visual Studio languages returns a code. For example the call may look like.

    return_code = myRFCFunction.execute

    This return_code will contain the equivalent of the sy-subrc in SAP. Since the code itself means nothing to the program on the other side, if it is possible return a detailed error message in a structure such as the BAPIRET2, with at the very least a message type and full error message. This will make life easier on both sides of the interface.

    Add comment
    10|10000 characters needed characters exceeded

    • Okay. I think it's the same thing between the 2 languages, but I had misinterpreted when you said "contain the equivalent of the sy-subrc": I thought you were saying that return_code was an integer to be used as a boolean (either 0 or 1)... In VB, there's such a return code, a boolean too. If it's "false", then we have to get the exception name with "theFunc.Exception" (string), and I guess it's the same for C with "RfcLastError.message". Here is a VB code :

      dim returnFunc as Boolean

      returnFunc = theFunc.Call

      If returnFunc = False Then
      MsgBox "Exception " + theFunc.Exception + " when accessing function in SAP ! "
      Else
      MsgBox "OK"
      End if