cancel
Showing results for 
Search instead for 
Did you mean: 

Finding connection information

Former Member
0 Kudos

Hello all,

Within an RFC-enabled FM, is there a way one could find whether a call has been made from the same sytem or some other system.

Thanks.

Srinivas.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Do you want to know whether the call has been made from the same system or whether the function has been called by RFC, as these are slightly different (since it is possible to do RFC back into the same system, such as with CALL FUNCTION ... STARTING NEW TASK).

NOTE: The following will only work if the RFC client is also an RFC server (such as an SAP system) and thus has the functions RFC_PING and RFC_SYSTEM_INFO automatically defined.

If you just want to know whether the function has been called via RFC, then you could use code in your RFC-enabled function module like:


CALL FUNCTION 'RFC_PING' DESTINATION 'BACK'
  EXCEPTIONS
    COMMUNICATION_FAILURE = 4.

IF SY-SUBRC NE 0.
* Not called via RFC
ENDIF.

If you want to know whether the function has been called from the same system, you should be able to get there by calling back into the caller via funciton RFC_SYSTEM_INFO.


DATA:
  lv_rfcsi TYPE rfcsi.

CALL FUNCTION 'RFC_SYSTEM_INFO'
  DESTINATION 'BACK'
  IMPORTING
    rfcsi_export = lv_rfcsi
  EXCEPTIONS
    communication_failure = 4.

IF SY-SUBRC NE 0.
* Not called by RFC
ENDIF.

IF sy-sysid NE lv_rfcsi-rfcsysid.
* Called from another system
ENDIF.

Good luck.

Scott