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

Exception COMMAND_NOT_FOUND at SXPG_COMMAND_EXECUTE

Former Member
0 Likes
5,509

Hi Experts

I am testing FM: SXPG_COMMAND_EXECUTE (using SE37) with a Customer OS Command that I created in SM69.

For some reason, the FM returns exception: COMMAND_NOT_FOUND. However, when I user T-code: SM69 to exexcute the OS command (with the same parameters) - everything is OK.

Is there some different way to use FM: SXPG_COMMAND_EXECUTE ?

Thanks,

Yaniv

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
0 Likes
3,657

Maybe you programmed SXPG_COMMAND_EXECUTE incorrectly, but difficult to say without seeing your code!

See this example: http://wiki.sdn.sap.com/wiki/display/ABAP/CreationofExternalCommandswiththehelpofUNIXCodingin+SAP

23 REPLIES 23
Read only

Sandra_Rossi
Active Contributor
0 Likes
3,658

Maybe you programmed SXPG_COMMAND_EXECUTE incorrectly, but difficult to say without seeing your code!

See this example: http://wiki.sdn.sap.com/wiki/display/ABAP/CreationofExternalCommandswiththehelpofUNIXCodingin+SAP

Read only

0 Likes
3,657

Hi

I implemented the example program in the link that you attached but still - the Function Module doesn't work.

When I debug the program, the function module is not executed. Instead other function module is executed (I don't know why) and ends up doing nothing...

more help?

Thanks,

Yaniv

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,657

Did you define the external command in SM69 ?

Read only

0 Likes
3,657

Yes, I created it in SM69.

Also, when I execute it in SM69 (or SM49) everything is OK.

The exception COMMAND_NOT_FOUND occures only when I use the FM in SE37 (I also made sure that the parameters that I use with the FM in se37 are OK)

Thanks,

Yaniv

Read only

0 Likes
3,657

> but difficult to say without seeing your code

Same remark again...

Read only

0 Likes
3,657

Here's my code: (sorry for the bad styling)

REPORT ZBW_TEST_OS.

CONSTANTS: c_extcom TYPE sxpgcolist-name VALUE 'ZBW_TEST_LS',

c_oper TYPE syopsys VALUE 'LINUX'.

DATA: v_dir_input TYPE sxpgcolist-parameters. " Input Directory

DATA: t_result TYPE STANDARD TABLE OF btcxpm.

v_dir_input = '/scripts/'.

break yanivf.

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'

EXPORTING

commandname = c_extcom

additional_parameters = v_dir_input

operatingsystem = c_oper

TABLES

exec_protocol = t_result

EXCEPTIONS

no_permission = 1

command_not_found = 2

parameters_too_long = 3

security_risk = 4

wrong_check_call_interface = 5

program_start_error = 6

program_termination_error = 7

x_error = 8

parameter_expected = 9

too_many_parameters = 10

illegal_command = 11

wrong_asynchronous_parameters = 12

cant_enq_tbtco_entry = 13

jobcount_generation_error = 14

OTHERS = 15.

t_result = t_result.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,657

I debugged & found the source of the exception to be a subroutine command_check_if_exists in the include LSXPTF06.

Check the tables SXPGCOTABE & SXPGCOSTAB, your command has to be maintained in either one of them. Else you get this EXCEPTION.

BR,

Suhas

PS: Is the command 'ZBW_TEST_LS' maintained for the operating system 'LINUX' ?

Read only

0 Likes
3,657

Hi Suhas

I checked table SXPGCOSTAB (Customer OS commands) and it is maintained with my OS command for Operating system Linux.

(I would like to remind that when I execute the command from SM69 - everything is OK)

Thanks,

Yaniv

Read only

0 Likes
3,657

You must enter "Linux" in lower case.

Read only

0 Likes
3,657

Hi

I've used 'SXPG_CALL_SYSTEM' function once to call a unix script

it was successful.

SM49 and the function 'SXPG_CALL_SYSTEM' works identically.

Maybe you should try this.

Hope it helps.

Bulent

Edited by: Bulent Balci on Jul 5, 2010 9:36 PM

Read only

0 Likes
3,657

execute them both in debug and try to detect a differerence in the behaviour between SM69 and SXPG_COMMAND_EXECUTE

Read only

0 Likes
3,657

Hi Neil

I debugged the function module in 2 different modes:

1. Executing the OS command using SM69

2. Executing the OS command using the FM in SE37.

The difference was in the execution of FM SXPG_COMMAND_GET:

1. In SM69 - it was executed OK (when I hit F5 in the debugger, I enter the FM) with return code 0

2. In SE37 - It was not executed (when I hit F5 in the debugger, the FM was skipped... and return code 801.

Anyone has an idea???

Thanks,

Yaniv

Read only

0 Likes
3,657

Please check passing the OS value as Linux instead of LINUX as suggested by Sandra Rossi .

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,657

The domain SYOPSYS is case sensitive, so if you pass LINUX instead of 'Linux', the select from the tables SXPGCOTABE (and / or SXPGCOSTAB) will fail. You need to provide the Oper. Syst. name in correct case.

1. In SM69 - it was executed OK (when I hit F5 in the debugger, I enter the FM) with return code 0

2. In SE37 - It was not executed (when I hit F5 in the debugger, the FM was skipped... and return code 801.

In SE37 while executing the function module check the "Uppercase / Lowecase" checkbox & execute the FM. It should work fine

Now since we are discussing the topic. Can anyone tell why would SAP provide 2 similar FMs (SXPG_CALL_SYSTEM & SXPG_COMMAND_EXECUTE) doing the same job (& both are "Released" too) ? This is kind of redundant for me ...

BR,

Suhas

Edited by: Suhas Saha on Jul 6, 2010 1:23 PM

Read only

0 Likes
3,657

Please don't repeat, let him think and find by himself (he'll learn).

Note: I updated the wiki to warn about the case sensitivity of the operatingsystem field.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,657

Hi Sandra,

I too don't like to spoonfeed. But to give an insight why the OP's test in SE37 was failing, i had to give the insight

Cheers,

Suhas

Read only

0 Likes
3,657

You're right 😄

(as you could imagine by looking at my answers, I didn't even think to that little checkbox of SE37 test mode)

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,657

I didn't even think to that little checkbox of SE37 test mode

As a matter of fact most of us don't

Read only

0 Likes
3,657

The case sensitivity check-box worked.

Thanks everybody for the guiding tips !

Yaniv

Read only

0 Likes
3,657

> Can anyone tell why would SAP provide 2 similar FMs (SXPG_CALL_SYSTEM & SXPG_COMMAND_EXECUTE) doing the same job (& both are "Released" too) ? This is kind of redundant for me

That's just a matter of preference. SAP says that SXPG_CALL_SYSTEM is the "express method" (see [SAP Library - External commands - Programming Techniques|http://help.sap.com/saphelp_nw70/helpdata/en/fa/0971e1543b11d1898e0000e8322d00/frameset.htm] and [SAP Library - External commands - SXPG_CALL_SYSTEM|http://help.sap.com/saphelp_nw70/helpdata/en/fa/0971ee543b11d1898e0000e8322d00/frameset.htm])

Read only

0 Likes
3,657

Hi Yaniv,

why did you not award the points to Sandra Rossi? She gave you the answer, admittedly it was a bit more succinct than the later answer, 4 hours before Suhas.

Read only

0 Likes
3,657

Hi Neil

I didn't give the points to Sandra because I tried using 'Linux' in the OS parameter and it didn't work. Moreover, I was not familiar with the functionallity of the Case sensitivity check-box in SE37, hence I gave the points to the answer that stated it.

Thanks,

Yaniv

Read only

0 Likes
3,657

Suhas gave a better answer, in my answer I didn't think to SE37 case checkbox (Yaniv told us since the beginning his question was about SE37). Well when he wrote the ABAP program, he should have seen that "Linux" worked while "LINUX" didn't work.

I think the point system has to point out the interesting answers so that to help people who seek for solutions about "COMMAND_NOT_FOUND SXPG_COMMAND_EXECUTE". Mine is interesting to see, and it's short to understand what the issue is and Suhas's answer is about SE37 checkbox. Things are corrected now, thank you Yaniv.

Last thing, so many people don't understand what the point system is for, that I gave up telling them. And I don't help people anymore who don't respect the rules.