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

Finding connection information

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.

Add comment
10|10000 characters needed characters exceeded

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jul 08, 2004 at 01:32 PM

    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

    Add comment
    10|10000 characters needed characters exceeded