ABAP 获取登陆者IP地址和主机名 & 获取应用程序服务器的IP地址

2021-08-27 19:32发布


          点击此处--->   EasySAP.com 群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)

获取登陆者IP地址和主机名:

REPORT ZTEST.


DATA: opcode_usr_attr(1) TYPE x VALUE 5,
terminal TYPE usr41-terminal.

    获取终端名 OPCODE 码在 TSKHINCL 252行
    CALL ‘ThUsrInfo’ ID ‘OPCODE’ FIELD opcode_usr_attr
    ID ‘TERMINAL’ FIELD terminal.
    WRITE:/ ‘Terminal:’, terminal.

“获取登陆IP地址
DATA:ip TYPE string.
CALL METHOD cl_gui_frontend_services=>get_ip_address
RECEIVING
ip_address = ip
.

WRITE:/ ‘IP :’,ip.


获取应用程序服务器的IP地址:


REPORT ZTEST.


TYPES: BEGIN OF kernel_version,
         key(21) TYPE c,
         data(69) TYPE c,
      END OF kernel_version.

  DATA : gt_kernel_version TYPE STANDARD TABLE OF kernel_version,
         gw_kernel_version TYPE kernel_version.

  DATA ip_address(69) TYPE c.
  CALL 'SAPCORE' ID 'ID' FIELD 'VERSION'
                 ID 'TABLE' FIELD gt_kernel_version[].

  READ TABLE gt_kernel_version INTO gw_kernel_version INDEX 11.
  ip_address = gw_kernel_version-data.

WRITE ip_address.

赞赏支持