FQDN ermitteln
mit folgendem Snippet ist es möglich den FQDN eines SAP-Systems zur Laufzeit zu ermitteln. Diese Information ist für diejenigen wichtig, die BSPs o.ä. dynamisch rufen wollen. Sollte das SAP nicht mit FQDN parametrisiert sein, wird statt dessen die IP-Adresse verwendet.
Am Ende steht in der Variablen GV_URL entweder FQDN + PORT oder IP + PORT.
TYPES: BEGIN OF kernel_version,
key TYPE c LENGTH 21,
data TYPE c LENGTH 69,
END OF kernel_version.
*– global object declaration
DATA:
gr_client TYPE REF TO if_http_client,
gt_html TYPE w3htmltab,
gv_url TYPE string,
gt_server TYPE STANDARD TABLE OF msxxlist,
gs_server TYPE msxxlist,
gv_hostname TYPE string,
gv_portnumber TYPE string,
gv_val TYPE slic_sysid,
gt_kernel_version TYPE STANDARD TABLE OF kernel_version,
gw_kernel_version TYPE kernel_version.
INITIALIZATION.
*— get all servers
CALL FUNCTION ‘TH_SERVER_LIST’
TABLES
list = gt_server
EXCEPTIONS
no_server_list = 1
OTHERS = 2
.
LOOP AT gt_server[] INTO gs_server.
* — read http data —————
CALL FUNCTION ‘TH_GET_VIRT_HOST_DATA’
DESTINATION gs_server-name
EXPORTING
protocol = 1
IMPORTING
hostname = gv_hostname
port = gv_portnumber
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
CASE sy-subrc.
WHEN 0.
* — read SYSID ————-
CALL FUNCTION ‘SLIC_GET_SYSTEM_ID’
IMPORTING
systemid = gv_val.
* — read all core data —–
CALL ‘SAPCORE’ ID ‘ID’ FIELD ‘VERSION’
ID ‘TABLE’ FIELD gt_kernel_version[].
* — read ip-address ——–
READ TABLE gt_kernel_version[] INTO gw_kernel_version
WITH KEY key = ‘IP address’.
IF gv_hostname CS ‘.’.
* — hostname is FQDN ——-
gv_url = gv_hostname.
CONCATENATE ‘http://’ gv_url ‘:’ gv_portnumber INTO gv_url.
ELSE.
* — hostname is not FQDN —
gv_url = gw_kernel_version-data.
CONCATENATE ‘http://’ gv_url ‘:’ gv_portnumber INTO gv_url.
ENDIF.
WHEN 1.
* raise NOT_AUTHORIZED.
WHEN 2.
* RAISE no_valid_date.
WHEN 3.
WHEN 4.
ENDCASE. ” sy-subrc
ENDLOOP. ” AT gt_server[]
- 7. December: Excel Racing Simulation – Root Vole Race - 7. Dezember 2024
- 5. December: ABAPConf - 5. Dezember 2024
- 4. December: Only a lazy developer is a good developer - 4. Dezember 2024