2016 Oct 12 11:04 AM
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 !
2016 Oct 12 12:33 PM
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.
2016 Oct 12 12:57 PM
Did you try function module RFC_GET_ATTRIBUTES, parameter CALLER_IP?
2016 Oct 12 1: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
2016 Oct 14 8: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
2016 Oct 24 10:01 AM