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: 

execute more than one times external command of OS Windows NT

former_member480606
Participant
0 Kudos

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

3 REPLIES 3

Rashid_Javed
Contributor
0 Kudos

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.

RJv

0 Kudos

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

0 Kudos

I'd suggest discussing it with your BASIS team, as Rashid's solution is a very good one.