‎2007 Jul 16 1:03 PM
Hi Experts,
Can you explain me the fuctionality below code...
DATA: l_target_syst LIKE rfcdisplay-rfchost.
DATA: i_error LIKE btcxpm OCCURS 0 WITH HEADER LINE.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'SAPDBHOST'
ID 'VALUE' FIELD l_target_syst.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = commandname
additional_parameters = filename
operatingsystem = sy-opsys
targetsystem = l_target_syst
DESTINATION =
stdout = stdout
stderr = stderr
terminationwait = terminationwait
TRACE =
IMPORTING
status = status
exitcode = exitcode
tables
exec_protocol = i_exec_protocol
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 = 99.
CASE sy-subrc.
WHEN 1.
RAISE no_permission.
WHEN 2.
RAISE command_not_found.
WHEN 3.
RAISE parameters_too_long.
WHEN 4.
RAISE security_risk.
WHEN 5.
RAISE wrong_check_call_interface.
WHEN 6.
RAISE program_start_error.
WHEN 7.
RAISE program_termination_error.
WHEN 8.
RAISE x_error.
WHEN 9.
RAISE parameter_expected.
WHEN 10.
RAISE too_many_parameters.
WHEN 11.
RAISE illegal_command.
WHEN 12.
RAISE wrong_asynchronous_parameters.
WHEN 13.
RAISE cant_enq_tbtco_entry.
WHEN 14.
RAISE jobcount_generation_error.
WHEN 99.
RAISE x_error.
ENDCASE.
Regards
Kali Pramod
‎2007 Jul 16 1:08 PM
Hi,
This function module transfers the file (filename in the function module) from sy-opsys ( Operating system ) to the target system.
The command name is the name you have created using transaction SM49 or SM69
Regards
Arun
‎2007 Jul 16 1:05 PM
Hi,
Execute an External Command
Using this function module, you can check the authorization of a user to execute a particular external command and run the command:
With the arguments specified in ADDITIONAL_PARAMETERS
On the target host system defined by OPERATINGSYSTEM and TARGETSYSTEM
If an SAP profile parameter is inserted in the portion of the command stored in the database, then the value of this parameter is substituted into the command. If an SAP application server is active on the target system (TARGETSYSTEM), then the profile parameter values are read from the profile that is active on that system. No parameter substitution is made in ADDITIONAL_PARAMETERS.
After substitution, the command is checked for the presence of "dangerous" characters such as the semicolon ( ; ) on UNIX systems.
If an additional "security function module" is specified in the command definition, this function module is also called in the course of processingebenfalls. This function module can prevent execution of the command.
If the authorization checks complete successfully, the command is run on the target host system.
Reward if useful!
‎2007 Jul 16 1:12 PM
Hi Pramit
Please dont cut and paste allready i gone through this reply..
Regards,
Kali Pramod
‎2007 Jul 16 1:08 PM
Hi,
This function module transfers the file (filename in the function module) from sy-opsys ( Operating system ) to the target system.
The command name is the name you have created using transaction SM49 or SM69
Regards
Arun
‎2007 Jul 16 1:16 PM
In this FM.. main three parameters are:
<b>commandname
additional_parameters
exec_protocol</b>
Commandname is the command created thru SM49 they are called external operating system command,,,
In this command first parameter is always an operating system command like..
<b>ls for listing all files and directories</b>
<b>put</b> etc
in additional_parameters you can pass the parameters for that command like for the command you can see the contents of some particular directory so u have to pass that directory path in additional_parameters field
i.e. additional_parameters = '/usr/sap/tmp'
and exec_protocol is the table which returns u the contents which are retrieved using that command...
e.g using ls command all files an dir names appended to this table...
You can use another FM is ur additional parametes field is very long..
<b> SXPG_COMMAND_EXECUTE_LONG</b>
<i>Two more parameters: STATUS and EXITCODE are very important... your command is run successfully only when <b>STATUS = 'O' " Capital O
and
EXITCODE = '0' " Zero</b>
</i>
Reward if useful
Regards
Prax
‎2007 Jul 16 1:19 PM
Hi,
OK see it will execute an external command of OS , you can give operating system say UNIX, and perticular command of promt.
say ls additional parameters say file name .
It will execute find command and return you the result.
Reward if useful!