Application Development 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: 

Get computer ID who called BAPI via RFC

0 Kudos

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 !

5 REPLIES 5

raghug
Active Contributor

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.

Sandra_Rossi
Active Contributor
0 Kudos

Did you try function module RFC_GET_ATTRIBUTES, parameter CALLER_IP?

Former Member
0 Kudos

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

jack_graus2
Active Contributor

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

0 Kudos

Thanks @ All, problem solved using your solution.