Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

possible to run host command ???

Former Member
0 Likes
629

Hi experts,

Is it possible to run host command from SAP environment? How do you run?

Thanks,

Logu

4 REPLIES 4
Read only

Former Member
0 Likes
593
Read only

Former Member
0 Likes
593
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
593

Host command ?? are u meaning unix or linux commands ????

Read only

0 Likes
593

check whether this helps


 DATA:os TYPE sxpgcolist-opsystem.
    DATA:host TYPE rfcdisplay-rfchost.
    DATA:commandname TYPE sxpgcolist-name.
    DATA:exec_protocol LIKE STANDARD TABLE OF btcxpm.
    os = sy-opsys.
    host = sy-host.
    commandname = 'ZDOWNLOAD'.  "SAP Command Name
    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
      EXPORTING
        commandname     = commandname
        operatingsystem = os
        targetsystem    = host
        stdout          = 'X'
        stderr          = 'X'
        terminationwait = 'X'
      TABLES
        exec_protocol   = exec_protocol[].
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.