[ABAP] System-Funktion des c-kernel aufrufen

Vorsicht: Unsachgemäßer Aufruf von Kernelfunktionen kann Systemschäden verursachen!

* Server-Directory auflisten
DATA: lv_cmd TYPE char255.
DATA: lt_result_tab TYPE TABLE OF char255.

lv_cmd = 'ls -lasi'.

CALL 'SYSTEM' ID 'COMMAND' FIELD lv_cmd ID 'TAB' FIELD lt_result_tab.

LOOP AT lt_result_tab INTO DATA(res_line).
  WRITE: / res_line.
ENDLOOP.

* aufrufende Transaktion
DATA: lv_trans TYPE tcode.
CALL 'GET_PARAM_TCOD' ID 'PTCOD' FIELD lv_trans.
WRITE: / lv_trans.

* eingegebenen OK-Code ermitteln
DATA: my_ucomm TYPE sy-ucomm.
CALL 'DYNP_OKCODE_GET' ID 'FCODE' FIELD my_ucomm.
WRITE: / my_ucomm.

* CPUID ermitteln
DATA: local_host TYPE spfid-host.
CALL 'C_GET_CPU_ID' ID 'CPUID' FIELD local_host.
WRITE: / local_host.

* SAP-System ermitteln
DATA: lv_sapsystem TYPE spfid-sysnr.
CALL 'C_GET_SYSTEM_NUMBER' ID 'SYSTEM' FIELD lv_sapsystem.
WRITE: / lv_sapsystem.

* SAP Servername
DATA: lv_server_name LIKE btctgtsrvr-srvname.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'rdisp/myname' ID 'VALUE' FIELD lv_server_name.
WRITE: / lv_server_name.

* AL11 DIR_HOME
DATA: lv_dir_home TYPE dirname_al11.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_HOME' ID 'VALUE' FIELD lv_dir_home.
WRITE: / lv_dir_home.

* AL11 DIR_TRANS
DATA: lv_dir_trans TYPE dirname_al11.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_TRANS' ID 'VALUE' FIELD lv_dir_trans.
WRITE: / lv_dir_trans.

* Namens-Format für Audit-Files
DATA: lv_aufn TYPE rsauflist-file_name.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'FN_AUDIT' ID 'VALUE' FIELD lv_aufn.
WRITE: / lv_aufn.

* Directory für Audit-Files
DATA: lv_audit TYPE dirname_al11.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_AUDIT' ID 'VALUE' FIELD lv_audit.
WRITE: / lv_audit.

Links