Skip to Content

Get computer ID who called BAPI via RFC

Hi All,

Anyone know if it's possible to get the computer ID/name who called a BAPI using RFC ?

Or the only way is to send it to the BAPI on call as a parameter ?

In our case, we have a program who use an RFC Call to update values in SAP and we want to log the computer who send these data.

Thanks !

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Oct 12, 2016 at 11:33 AM

    I am doing the same thing for logging... depending on where and how the RFC is called - Internal to SAP vs External, you will get different results. I have tried to cover most occurances and get output which is useful. Here is a code sample...

        DATA:
          l_long_line  TYPE c LENGTH 2048,
          l_terminal   TYPE string,
          l_ip_address TYPE ni_nodeaddr,
          terminal_id  TYPE syindex,
          li_usr_tabl  TYPE STANDARD TABLE OF uinfo,
          nodeaddr     TYPE ni_nodeaddr.
    
        " Get user's terminal information
        CALL FUNCTION 'TH_USER_INFO'
          IMPORTING
            tid     = terminal_id
            addrstr = l_ip_address.
    
        CALL FUNCTION 'THUSRINFO'
          TABLES
            usr_tabl = li_usr_tabl.
    
        DATA(longname) = li_usr_tabl[ tid = terminal_id ]-term.
    
        CALL FUNCTION 'NI_NAME_TO_ADDR'
          EXPORTING
            hostname      = CONV ni_hostname( longname )
          IMPORTING
            nodeaddr      = nodeaddr
          EXCEPTIONS
            ehost_unknown = 1
            einval        = 2
            OTHERS        = 3.
    
        IF sy-subrc <> 0.
          IF l_ip_address IS NOT INITIAL.
            l_log-syst_log = l_ip_address && |-| && longname.
          ELSE.
            l_log-syst_log = 'Not available' ##NO_TEXT. 
          ENDIF.
        ELSE.
          l_log-syst_log = nodeaddr && |-| && longname.
        ENDIF.
    
    Add comment
    10|10000 characters needed characters exceeded

  • Oct 14, 2016 at 07:38 AM

    When a RFC is called one can call a RFC in the sending system. One can do so by calling the RFC with destination BACK. As your BAPI is a RFC you can get system information of the calling RFC system by calling the function RFC_SYSTEM_INFO with destination BACK.

    Regards Jack

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 12, 2016 at 12:12 PM

    Hi

    You can try to use fm like TH_LONG_USR_INFO, it returns the data of the active sessions of a user, in particolar the terminal Id

    Max

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 12, 2016 at 11:57 AM

    Did you try function module RFC_GET_ATTRIBUTES, parameter CALLER_IP?

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 24, 2016 at 09:01 AM

    Thanks @ All, problem solved using your solution.

    Add comment
    10|10000 characters needed characters exceeded