Application Development 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: 

How to run an OS command from ABAP?

Former Member
0 Kudos

Hi,

is it possible to run an OS command from ABAP?

Thank you,

Olian

1 ACCEPTED SOLUTION

Former Member

Hi Olian.

I would like to suggest my opinion,

Yes, I think it is possible.

It is possible through a function module,

SXPG_CALL_SYSTEM - Run an External Command.

Suggested Reference for know about passing the parameters to the function module as well as its details,

[SAP HELP Library - Standard Reference for SXPG_CALL_SYSTEM: Run an External Command (Express Method)|http://help.sap.com/saphelp_nw04/helpdata/en/fa/0971ee543b11d1898e0000e8322d00/content.htm]

SXPG_COMMAND_CHECK - Check whether the user is authorized to execute the specified command on the target host system with the specified arguments.

SXPG_COMMAND_EXECUTE - Check a useru2019s authorization to use a command, as in SXPG_COMMAND_CHECK. If the authorization check is successful, then execute the command on the target host system.

Suggested Reference,

[SAP HELP Library - Standard Reference - Programming Techniques|http://help.sap.com/saphelp_nw04/helpdata/en/fa/0971ee543b11d1898e0000e8322d00/frameset.htm]

Hope this works out well.

Good Luck & Regards.

Harsh Dave

Edited by: Harsh Dave on Aug 21, 2008 5:28 PM

6 REPLIES 6

Former Member
0 Kudos

hi,

Please check the link.

http://www.saptechies.com/execute-os-command-on-the-server/

Regards

Sumit Agarwal

Former Member
0 Kudos

Yes, it is possible to run an OS command.

First of all create the external command in SM69 transaction and use function module SXPG_COMMAND_EXECUTE to execute the command programmatically.

Regards,

Kiran Bobbala

Former Member
0 Kudos

Create External Command in SM69 .

you can call them using the SAP delivered FM SXPG_COMMAND_EXECUTE

raymond_giuseppi
Active Contributor
0 Kudos

Predefined command

- SM69 - Describe command (if not already) [Maintaining External Commands|http://help.sap.com/erp2005_ehp_03/helpdata/EN/c4/3a607b505211d189550000e829fbbd/frameset.htm]

- SM49 - Execute them [Executing External Command|http://help.sap.com/erp2005_ehp_03/helpdata/EN/c4/3a606e505211d189550000e829fbbd/frameset.htm] or Execute in program thru FM [SXPG_COMMAND_EXECUTE|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=sxpg_command_execute&adv=false&sortby=cm_rnd_rankvalue]

Dynamic command

- SM49 or use FM [SXPG_CALL_SYSTEM|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=sxpg_call_system&adv=false&sortby=cm_rnd_rankvalue]

Regards

former_member188685
Active Contributor
0 Kudos

if your OS is unix you can do this also ...

input your unix command

REPORT ZUNIX line-size 400
                no standard page heading.
 
 
parameters : unixcom like   rlgrap-filename.   
 
 
data: begin of tabl occurs 500,
        line(400),
      end of tabl.
 
data: lines type i.
  
*----------------------------------------------------------------------
 
start-of-selection.
  refresh tabl.
 
  call 'SYSTEM' id 'COMMAND' field unixcom
                id 'TAB'     field tabl[].
 
 "if the files are different then you will some content in tabl
 "Loop the tabl and write the results.

Former Member

Hi Olian.

I would like to suggest my opinion,

Yes, I think it is possible.

It is possible through a function module,

SXPG_CALL_SYSTEM - Run an External Command.

Suggested Reference for know about passing the parameters to the function module as well as its details,

[SAP HELP Library - Standard Reference for SXPG_CALL_SYSTEM: Run an External Command (Express Method)|http://help.sap.com/saphelp_nw04/helpdata/en/fa/0971ee543b11d1898e0000e8322d00/content.htm]

SXPG_COMMAND_CHECK - Check whether the user is authorized to execute the specified command on the target host system with the specified arguments.

SXPG_COMMAND_EXECUTE - Check a useru2019s authorization to use a command, as in SXPG_COMMAND_CHECK. If the authorization check is successful, then execute the command on the target host system.

Suggested Reference,

[SAP HELP Library - Standard Reference - Programming Techniques|http://help.sap.com/saphelp_nw04/helpdata/en/fa/0971ee543b11d1898e0000e8322d00/frameset.htm]

Hope this works out well.

Good Luck & Regards.

Harsh Dave

Edited by: Harsh Dave on Aug 21, 2008 5:28 PM