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

What's the Function Module name to execute OS command?

Former Member
0 Likes
4,571

Hi Expert,

I remeber that there is a function module which can be used to execute OS command, but forget the FM name.

Does any expert know the FM name?

Thanks in advance,

Best Regards, Johnney.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,684

Create the command name in SM49 defining the operating system name and other parameters. Then use the command in FM SXPG_COMMAND_EXECUTE to execute OS commands in ABAP.

11 REPLIES 11
Read only

Former Member
0 Likes
2,684

in transaction SM69 create external command,

call command using function, example:

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'

EXPORTING

commandname = w_command

ADDITIONAL_PARAMETERS = w_output

IMPORTING

STATUS = w_status

TABLES

EXEC_PROTOCOL = LOG.

Read only

Former Member
0 Likes
2,684

Hi,

"SXPG_COMMAND_EXECUTE" is the FM which will Execute an External Command.

regards,

Naveen

Read only

awin_prabhu
Active Contributor
0 Likes
2,684

Please Search SDN

Edited by: Sap Fan on Apr 7, 2009 11:07 AM

Read only

anuj_srivastava
Active Participant
0 Likes
2,684

Hi ,

The FM name is 'SXPG_COMMAND_EXECUTE'.

You need to create the command in SM69.

You can test the same command in SM49.

Regards,

Anuj

Read only

Former Member
0 Likes
2,684

You use this FM 'SXPG_COMMAND_EXECUTE' to execute OS command.

Regards,

Joan

Read only

Former Member
0 Likes
2,685

Create the command name in SM49 defining the operating system name and other parameters. Then use the command in FM SXPG_COMMAND_EXECUTE to execute OS commands in ABAP.

Read only

0 Likes
2,684

Hi Experts,

Thanks for your reply.

One more question about SXPG_COMMAND_EXECUTE. I need to pass parameters via input ADDITIONAL_PARAMETERS. My parameter is more than 380 characters, while the length of ADDITIONAL_PARAMETERS is only 255.

How to handle the case? Does any expert have idea?

Thanks a lot.

Best Regards, Johnney.

Read only

0 Likes
2,684

Does any expert have idea over the case?

Thanks in advance,

Best Regards, Johnney.

Read only

0 Likes
2,684

copy the FM to a Zfm and make your changes...

Read only

0 Likes
2,684

I use SXPG_STEP_XPG_START, this FM works fine.

I close the message.

Thanks for all your help. Best Regards, Johnney.

Read only

0 Likes
2,684

Hello , I have the same problem I created a command in SM49 transaction with command name = ZCOPY, and S.O command = "scp". because I want to copy the files in unix (al11) to windows server.

my problem is that I want to copy a lot of file in the same parameter but I only have 255 caracter. If I create a new fuction 'Z' then I have to change a lot of other function that are calling by the 'SXPG_COMMAND_EXECUTE'.

In the parameters I have to repeat all the time the origin directory:'/usr/sap/DEV/RetencionesWeb/ if i don´t repeated it the file is not found

The command is like this:

SCP

file 1 = '/usr/sap/DEV/RetencionesWeb/26000000012009.PDF'

file 2 = '/usr/sap/DEV/RetencionesWeb/26000000012009.PDF'

Destination windows server

Do you know any way to don´t repeat the '/usr/sap/DEV/RetencionesWeb/?

Thanks,

Lucila

Edited by: Lucila Isernia on Apr 25, 2011 4:31 PM