Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Catch Runtime Error Call Function - RFC

Former Member
0 Likes
9,985

Hi,

When I call a function in RFC mode, I would like to catch the exceptions to don't display a horrible dump but rather a error message.

The exceptions that I would like to catch are :

- CALL_FUNCTION_NO_DEST

- CALL_FUNCTION_NOT_REMOTE

- CALL_FUNCTION_REMOTE_ERROR

...

When I use the syntax :

CATCH SYSTEM-EXCEPTIONS CALL_FUNCTION_NOT_REMOTE = 1.
ENDCATCH.

I have a syntax error : "system-exception" expected, not "CALL_FUNCTION_NOT_REMOTE".

I see in ABAP Keyword Documentation that for the CALL FUNCTION syntax, the Runtime errors aren't catchable....

What I do?

Regards.

Xavier.

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
4,529

Instead of capture exceptions you can do


CALL FUNCTION 'RFC_VERIFY_DESTINATION'
  EXPORTING
    DESTINATION = V_DESTINATION
        TIMEOUT = 5
  EXCEPTIONS
    INTERNAL_FAILURE           = 1
    TIMEOUT                    = 2
    DEST_COMMUNICATION_FAILURE = 3
    DEST_SYSTEM_FAILURE        = 4
    UPDATE_FAILURE             = 5
    NO_UPDATE_AUTHORITY        = 6
    OTHERS                     = 7.
 
  IF SY-SUBRC EQ 0.
    " Call Your RFC here 
  ELSE.
    " Make a Error message 
  ENDIF.

a®

4 REPLIES 4
Read only

former_member194669
Active Contributor
4,530

Instead of capture exceptions you can do


CALL FUNCTION 'RFC_VERIFY_DESTINATION'
  EXPORTING
    DESTINATION = V_DESTINATION
        TIMEOUT = 5
  EXCEPTIONS
    INTERNAL_FAILURE           = 1
    TIMEOUT                    = 2
    DEST_COMMUNICATION_FAILURE = 3
    DEST_SYSTEM_FAILURE        = 4
    UPDATE_FAILURE             = 5
    NO_UPDATE_AUTHORITY        = 6
    OTHERS                     = 7.
 
  IF SY-SUBRC EQ 0.
    " Call Your RFC here 
  ELSE.
    " Make a Error message 
  ENDIF.

a®

Read only

Former Member
0 Likes
4,529

The function 'RFC_VERIFY_DESTINATION' allow to return the error RFC connection as I want but, in the integration system, everybody SAP users haven't the object authorization 'S_RFC_ADM'. So, the function isn't useable.

Another process allow to control RFC connection without particulary authorization object?

Edited by: Xavier Couloumies on Mar 30, 2009 3:39 PM

Read only

4,529

Hi Xavier,

I was coming across the same problem, Googled it and came across your thread. Although a little late on replying and am sure you've got around your problem.

But for others, who are coming across the same problem... and i quote from SAP online help..

" Function module calls with the addition DESTINATION can handle two special system exceptions:

SYSTEM_FAILURE

This is triggered if a system crash occurs on the receiving side.

COMMUNICATION_FAILURE

This is triggered if there is a connection or communication problem.

In both cases, you can use the optional addition

... MESSAGE mess

to receive a description of the error."

so you simply add the following code at the end of RFC FM

Call Function

DESTINATION lv_rfc_dest

....

EXCEPTIONS

system_failure = 1

communication_failure = 2

OTHERS = 99.

Message text example

Data: lv_error_text(100) TYPE c

Call Function

DESTINATION lv_rfc_dest

....

EXCEPTIONS

system_failure = 1 MESSAGE lv_error_text

communication_failure = 2 MESSAGE lv_error_text

OTHERS = 99.

here is the complete reference http://tinyurl.com/ykvf99x

best regards,

Asim

Read only

0 Likes
3,127

It seems reasonable to check this before the FM call. Cheers!