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: 

SM69 -> Operating system command

Former Member
0 Kudos
3,980

Hello!

I have created an external command "ZTEST" via SM69 to

execute a shell script.

As far as I know the "Operating system command" is the location

of my script on the app server.

Suppose the script is located in

/usr/sap/ADE/

and the script name is "aus.sh"

1)

How is the correct syntax of ?

What do I have to input into this field

"Operating system command" to run this script.

2)How to call

'ZTEST' from FM SXPG_COMMAND_EXECUTE ?

Regards

sas

1 ACCEPTED SOLUTION

Former Member
0 Kudos
686

hi erdem,

i call it like this (example with LS ...):

DATA: BEGIN OF ITAB_LS OCCURS 0,

LINE(200),

END OF ITAB_LS.

*

<b>* change here your command as you like

  • ITAB_LS is the output table

CONSTANTS: CMD_LS(50) VALUE 'ls -al /transfer/sap'.

*</b>

CALL 'SYSTEM'

ID 'COMMAND' FIELD CMD_LS

ID 'TAB' FIELD ITAB_LS-SYS.

*

Regards, dieter

7 REPLIES 7

Former Member
0 Kudos
686

please help me its important.

Currently I'm not be able to run this script (aus.sh).

This is not working:

Operating system command:

/usr/sap/ADE/aus.sh

CALL 'SXPG_COMMAND_EXECUTE'

COMMANDNAME : ZTEST ...

Regards

sas

former_member223537
Active Contributor
0 Kudos
686

Hi,

  • get the name of DB server

IF sy-host = dbhost. "on the DB server, no RFC

CALL FUNCTION 'READ_FILE_SQLDB'

EXPORTING

directory = rundir

name = filename

TABLES

filetable = opmessage_dat

EXCEPTIONS

wrong_format = 3

  • OS_NOT_SUPPORTED = 4

OTHERS = 5.

ELSE. "use RFC if possible

CALL FUNCTION 'FIND_DB_APPLICATION_SERVER'

IMPORTING

servername = dbdest

EXCEPTIONS

OTHERS = 1.

IF sy-subrc <> 0.

IF sy-opsys <> 'Windows NT'. "#EC NOTEXT

CONCATENATE rundir filename INTO parameters SEPARATED BY '/' .

<b> CALL FUNCTION 'SXPG_COMMAND_EXECUTE'</b>

EXPORTING

<b> commandname = 'ZTEST'

operatingsystem = 'UNIX'</b>

  • additional_parameters = parameters

stderr = 'X'

stdout = 'X'

targetsystem = dbhost

terminationwait = 'X'

trace = ' '

IMPORTING

status = ret_code

TABLES

exec_protocol = opmessage_dat

EXCEPTIONS

command_not_found = 01

no_permission = 02

parameters_too_long = 03

parameter_expected = 04

program_start_error = 05

program_termination_error = 06

security_risk = 07

too_many_parameters = 08

wrong_check_call_interface = 09

x_error = 10

OTHERS = 11.

ELSE.

MESSAGE e805. "no application server on DB host and WindowsNT

ENDIF.

ELSE. "need RFC to reach the file

CALL FUNCTION 'READ_FILE_SQLDB'

DESTINATION dbdest

EXPORTING directory = rundir

name = filename

TABLES filetable = opmessage_dat

EXCEPTIONS system_failure = 1 MESSAGE mess

communication_failure = 2 MESSAGE mess

wrong_format = 3

  • OS_NOT_SUPPORTED = 4

OTHERS = 5.

IF sy-subrc <> 0.

MESSAGE e706 WITH 'Operating messages not found ?'. "#EC NOTEXT

ENDIF.

ENDIF.

ENDIF.

Best regards,

Prashant

0 Kudos
686

The operating system command should just be /usr/sap/ADE/aus.sh

Check the permissions on the file on the UNIX file system. CHMOD 777 /usr/sap/ADE/aus.sh for a test if necessary.

0 Kudos
686

hello,

I also have change the attributes. Its still not working.

What else can be wrong. ??

Regards

sas

Former Member
0 Kudos
687

hi erdem,

i call it like this (example with LS ...):

DATA: BEGIN OF ITAB_LS OCCURS 0,

LINE(200),

END OF ITAB_LS.

*

<b>* change here your command as you like

  • ITAB_LS is the output table

CONSTANTS: CMD_LS(50) VALUE 'ls -al /transfer/sap'.

*</b>

CALL 'SYSTEM'

ID 'COMMAND' FIELD CMD_LS

ID 'TAB' FIELD ITAB_LS-SYS.

*

Regards, dieter

0 Kudos
686

dieter thank you very much your kindly help.

What do you do whether you have more than one command or one row of

command. How can I seperate (delimeter )commands from eachother.

Regards

sas

0 Kudos
686

Make sure the first line of your script contains #!/bin/ksh

Run the script on the apps server directly to check it works, then run it through SM49 and post any error messages here.