Execute system command from ABAP
Sometimes it's useful to call the operating system command from SAP.
There are many ways you can do it (regarding authorizations).
The standard way is to define a system command in the transaction SM49 or SM69 and call it from those transactions
or with function module SXPG_CALL_SYSTEM or other similar SXPG*.
There are many examples of system call in the Internet using the old-style reference on the output internal table (tabl-*sys*),
but I prefer to use something less cryptic:
REPORT ztest.
DATA:
lv_command(50) TYPE c,
lv_line(150) TYPE c,
lt_tab LIKE TABLE OF lv_line.
lv_command = 'ls -l'.
CALL 'SYSTEM' ID 'COMMAND' FIELD lv_command
ID 'TAB' FIELD lt_tab.
LOOP AT lt_tab INTO lv_line.
WRITE: / lv_line.
ENDLOOP.
DATA:
lv_command(50) TYPE c,
lv_line(150) TYPE c,
lt_tab LIKE TABLE OF lv_line.
lv_command = 'ls -l'.
CALL 'SYSTEM' ID 'COMMAND' FIELD lv_command
ID 'TAB' FIELD lt_tab.
LOOP AT lt_tab INTO lv_line.
WRITE: / lv_line.
ENDLOOP.
Full list of examples in my infodepot
If you have a question, have found an error or just want to contact me, please use this form.
If you have a question, have found an error or just want to contact me, please use this form.
Copyright (C) 2011 http://www.kerum.pl/infodepot/
Disclaimer: I am not affiliated or related to any division or subsidiary of SAP AG.
Trademarks or registered trademarks of any products or companies referred to on this site belong to those companies.
Anyone using the given solutions, is doing it under his/her own responsibility and at own risk.