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: 

excuting unix program.

Former Member
0 Kudos

Hi.

I just want excute java.exe in bw unix without using function 'SXPG_CALL_SYSTEM'.

cause that function has limit number of command string.

I think I can use this command but somehow it returns null.

don't know what is problem and actually not sure usage of CALL 'SYSTEM' function.

anyone can fix this problem?

DATA: INFO_SGL(700) TYPE C OCCURS 0 WITH HEADER LINE.

data: COMMAND_STR type string.

data: CODE_number_500 type string.

CODE_number_500 = '43423424324........'.

concatenate '/opt/java1.3/bin/java -jar'

' test_v2.jar'

CODE_number_500

INTO COMMAND_STR.

CALL 'SYSTEM' ID 'COMMAND' FIELD COMMAND_STR ID 'TAB' FIELD INFO_SGL-SYS.

loop at info_sgl.

return_value = info_sgl.

endloop.

thank you.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try using trx SM69 to register the UNIX command and then use it.

I think system functions are not for external use.

Regards,

Shashank

6 REPLIES 6

Former Member
0 Kudos

Hi,

Try using trx SM69 to register the UNIX command and then use it.

I think system functions are not for external use.

Regards,

Shashank

0 Kudos

hi.

thank you for answer.

but that is useage of function 'SXPG_CALL_SYSTEM'.

I already done this but 'SXPG_CALL_SYSTEM' can work because parameter 'CODE_number_500' is too long.

so I try find other way that is send string directly.

and some other programs use that 'SYSTEM' function.

so think that can be work for external use.

but don't know how to get useage of this function.

0 Kudos

Hi,

Length of the parameter COMMANDNAME is 18.

Hence 'CODE_number_500' should work.

There must be some other problem.

Go thru following documentation.

Hope it helps.

FU SXPG_CALL_SYSTEM

Execute an External Command

Functionality

SXPG_CALL_SYSTEM: Execute External Command (Express Method)

Using this function module, you can:

o Check a user's authorization to execute a command

o Execute the command

To determine the system on which the command should be executed, the

function module uses by default the current host system and the current

operating system type of the user.

As the function module is RFC-capable, you can use the RFC interface

(Remote Function Call Interface) to run the function module in a

different SAP application server. The external command is then

accordingly executed in the host system of the other SAP server.

SXPG_CALL_SYSTEM uses the following rules to determine which variant of

a command is used for the execution:

o If a command with the same operating system type as the one in the

sytem field SY-OPSYS exists, this definition is used for the

execution of the command.

o If the first check fails, the syntax group for SY-OPSYS is

determined. A syntax group is an SAP construct that groups operating

systems that use the same syntax for commands and filenames. If a

command whose operating system type matches the determined syntax

group, this definition of the command is used.

o If no matching definition is found for the syntax group, the

function module searches for a definition with the operating system

type ANYOS (executable in all supported operating systems). This

definition is then used, if found.

o Otherwise, the exception COMMAND_NOT_FOUND is triggered.

Use

Syntax:

CALL FUNCTION SXPG_CALL_SYSTEM

IMPORTING

COMMANDNAME = <SAP command name> DEFAULT '*'

ADDITIONAL_PARAMETERS = <Argument string> default <space>

EXPORTING

STATUS = <Exit status of command>

TABLES

EXEC_PROTOCOL = <Log> In structure BTCXPM. Can

contain STDOUT, STDERR

EXCEPTIONS

NO_PERMISSION Command rejected by User exit auth.

check

COMMAND_NOT_FOUND Command not defined in SAP database

PARAMETERS_TOO_LONG Complete parameter string exceeds

128 characters

SECURITY_RISK Security check failed

WRONG_CHECK_CALL_INTERFACE Problem with function

module for additional security

check

PROGRAM_START_ERROR Error while starting program

PROGRAM_TERMINATION_ERROR Error while requesting final

status of program

X_ERROR Reserved

PARAMETER_EXPECTED Required parameter not specified

TOO_MANY_PARAMETERS User arguments not allowed by

supplied in call

ILLEGAL_COMMAND Command not legitimately defined

OTHERS

Parameters

COMMANDNAME

ADDITIONAL_PARAMETERS

STATUS

EXITCODE

EXEC_PROTOCOL

Exceptions

NO_PERMISSION

COMMAND_NOT_FOUND

PARAMETERS_TOO_LONG

SECURITY_RISK

WRONG_CHECK_CALL_INTERFACE

PROGRAM_START_ERROR

PROGRAM_TERMINATION_ERROR

X_ERROR

PARAMETER_EXPECTED

TOO_MANY_PARAMETERS

ILLEGAL_COMMAND

Function Group

SXPT

Regards,

Shashank

0 Kudos

there is misunderstanding .

value of 'CODE_number_500' is not just '43423424324'.

that is huge number of series about 500 character.

I already used that 'SXPG_CALL_SYSTEM' function before and works well until that parameter is less than 255 long.

after exceed 255 character that function are not working anymore so I need get other solution that is my problem.

thanks for finding these reference.

do you have any idea executing external unix program other than this?

0 Kudos

Hi,

Not very sure but did you try using the parameter

ADDITIONAL_PARAMETERS

for the function module 'SXPG_CALL_SYSTEM' ?

It helps in specifying the arguments to be passed to the ext command.

Regards,

Shashank