‎2010 Jul 04 9:44 AM
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
‎2010 Jul 05 2:18 PM
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
‎2010 Jul 05 2:18 PM
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
‎2010 Jul 05 3:04 PM
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
‎2010 Jul 05 3:06 PM
‎2010 Jul 05 3:09 PM
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
‎2010 Jul 05 3:13 PM
> but difficult to say without seeing your code
Same remark again...
‎2010 Jul 05 3:18 PM
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.
‎2010 Jul 05 3:43 PM
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' ?
‎2010 Jul 05 3:48 PM
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
‎2010 Jul 05 4:24 PM
‎2010 Jul 05 4:30 PM
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
‎2010 Jul 06 4:44 AM
execute them both in debug and try to detect a differerence in the behaviour between SM69 and SXPG_COMMAND_EXECUTE
‎2010 Jul 06 6:56 AM
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
‎2010 Jul 06 8:19 AM
Please check passing the OS value as Linux instead of LINUX as suggested by Sandra Rossi .
‎2010 Jul 06 8:51 AM
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
‎2010 Jul 06 9:06 AM
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.
‎2010 Jul 06 9:09 AM
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
‎2010 Jul 06 9:23 AM
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)
‎2010 Jul 06 9:26 AM
I didn't even think to that little checkbox of SE37 test mode
As a matter of fact most of us don't
‎2010 Jul 06 10:18 AM
The case sensitivity check-box worked.
Thanks everybody for the guiding tips !
Yaniv
‎2010 Jul 06 4:34 PM
> 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])
‎2010 Jul 07 6:47 AM
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.
‎2010 Jul 07 7:24 AM
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
‎2010 Jul 07 8:45 AM
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.