Thursday, December 20, 2007

How can I get the IP address of the system programmatically?

You can use cl_gui_frontend_services to get the system IP address.

DATA ip_addr TYPE c LENGTH 50.
CALL METHOD cl_gui_frontend_services=>get_ip_address
RECEIVING
ip_address = ip_addr
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
DATA terminal LIKE USR41-TERMINAL.
CALL FUNCTION 'TERMINAL_ID_GET'
EXPORTING
USERNAME = sy-uname
IMPORTING
TERMINAL = terminal.

No comments:

Blog Archive