Skip to Content
0

Get computer ID who called BAPI via RFC

Oct 12, 2016 at 10:04 AM

162

avatar image

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 !

bapi | rfc
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Raghu Govindarajan Oct 12, 2016 at 11:33 AM
1

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.

Share
10 |10000 characters needed characters left characters exceeded
J. Graus Oct 14, 2016 at 07:38 AM
1

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

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Oct 12, 2016 at 12:12 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Sandra Rossi Oct 12, 2016 at 11:57 AM
0

Did you try function module RFC_GET_ATTRIBUTES, parameter CALLER_IP?

Share
10 |10000 characters needed characters left characters exceeded
Kalimullah Shakoor Oct 24, 2016 at 09:01 AM
0

Thanks @ All, problem solved using your solution.

Share
10 |10000 characters needed characters left characters exceeded