04-21-2007 9:00 PM
Hi all,
I have to execute more than one times from an ABAP program an exernal command of Operating system windows NT . In order to reach this goal I found the standard program RSBDCOS0 and it works very well if you execute it one time. Unfortunately I have to execute this external command more than one times. Is there any soluiton?
thank to all
Gino Bonfiglioli
04-22-2007 7:20 AM
Well why are you using this report RSBDCOS0 to execute external commands?
Because SAP provides certain function modules that can be used to call operating system commands; so you can use these functions to do your task.
Just check the following link
http://help.sap.com/saphelp_nw2004s/helpdata/en/fa/0971e1543b11d1898e0000e8322d00/frameset.htm
As you mentioned that you need to execute multiple times, you can easily put the call to function module inside a loop or do/enddo structure. for example consider the following
do 3 times.
call function 'SXPG_COMMAND_EXECUTE'
exporting
commandname = 'Put operating system command here'
additional_parameters = full_filename
targetsystem = targtsys
stdout = 'X'
stderr = 'X'
terminationwait = 'X'
importing
status = sxpg_status
exitcode = sxpg_exitcode
tables
exec_protocol = sxpg_results
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.
write the results
loop at sxpg_results.
write:/ sxpg_results-length,
sxpg_results-message.
endloop.
refresh sxpg_results.
enddo.
04-23-2007 8:33 AM
Thank you for your answer but I have already tried to execute function module "SXPG_COMMAND_EXECUTE" and it doesn't work. I mean it works but I am not autorizhed to execute it. In fact in order to try the function SXPG_COMMAND_EXECUTE I setted in the SM69 transaction the external command that I wanted to execute and then I tried to execute it from SM49 transaction but the result is there in no autorization. In particular the system shows me the following message:
<i>This is tp version 340.16.24 (release 640)
E-F:\usr\sap\trans\bin\TP_DOMAIN_EN2.PFL' could not be opened.
EXIT
ERROR: System : Parameter SAPEVTPATH not set. Batch jobs cannot be started.
tp returncode summary:
TOOLS: Highest return code of single steps was: 0
ERRORS: Highest tp internal error was: 0208
tp finished with return code: 208
meaning:
error in transportprofil (param missing, unknown,...)
sapparam: sapargv( argc, argv) has not been called.
sapparam(1c): No Profile used.
sapparam: SAPSYSTEMNAME neither in Profile nor in Commandline
Error in F:\usr\sap\trans\bin\TP_DOMAIN_EN2.PFL': transdir not set.
External program terminated with exit code 208 </i>
Thank you
Gino
04-23-2007 8:42 AM
I'd suggest discussing it with your BASIS team, as Rashid's solution is a very good one.