‎2007 May 22 9:44 AM
Hi all,
I want to read a file in unix and read that.
For this I am using the below fm and passin the respective parameters
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = 'Z9CRS_NCRF_FTP' //command
ADDITIONAL_PARAMETERS =
OPERATINGSYSTEM = SY-OPSYS
TARGETSYSTEM = SY-HOST
DESTINATION =
STDOUT = 'X'
STDERR = 'X'
TERMINATIONWAIT = 'X'
TRACE =
IMPORTING
STATUS = gv_comm_status
EXITCODE =
TABLES
exec_protocol = gt_log
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
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
WRITE : /'Command to sftp NCRF File FAILED'.
LEAVE PROGRAM.
ENDIF.
In this fm I am passing commandline-'Z9CRS_NCRF_FTP' .And inporting parameters
STATUS = gv_comm_status
EXITCODE =
TABLES
exec_protocol = gt_log
whenever i rum the program gv_comm_status is being filled with 'o'.
and gt_log is also being filled with some data.
But when I try to read the file sy-subrc is becoming 8 thats means no file found.
Can anyone tell me what is this exec_protocol = gt_log
And why i am not able to read the file.
Thanks,
Uga
‎2007 May 22 9:53 AM
Hi Uga,
exec_protocol = gt_log contains the output returned from the UNIX.
Use like this.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
COMMANDNAME = P_UXCMD "Unix command
OPERATINGSYSTEM = 'AIX' "Operating system
TARGETSYSTEM = SY-HOST
STDOUT = 'X'
STDERR = 'X'
TERMINATIONWAIT = 'X'
TRACE = 'X'
ADDITIONAL_PARAMETERS = L_UXPARM "Parameters
IMPORTING
STATUS = BTCXP3-EXITSTAT
TABLES
EXEC_PROTOCOL = IT_CMD_OUTPUT "Return table(ur gt_log)
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.
Thanks,
Raj.
‎2007 May 22 9:53 AM
Hi Uga,
exec_protocol = gt_log contains the output returned from the UNIX.
Use like this.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
COMMANDNAME = P_UXCMD "Unix command
OPERATINGSYSTEM = 'AIX' "Operating system
TARGETSYSTEM = SY-HOST
STDOUT = 'X'
STDERR = 'X'
TERMINATIONWAIT = 'X'
TRACE = 'X'
ADDITIONAL_PARAMETERS = L_UXPARM "Parameters
IMPORTING
STATUS = BTCXP3-EXITSTAT
TABLES
EXEC_PROTOCOL = IT_CMD_OUTPUT "Return table(ur gt_log)
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.
Thanks,
Raj.
‎2007 May 22 10:10 AM
Hai Raja,
Thanks for quick reply.
1.Is operating system parameter is necessary
2.Status parameter is returning 'O' what does it mean.
3.What is the use of that EXEC_PROTOCOL = IT_CMD_OUTPUT "Return table(ur gt_log).In this log I find the author name ,date,path,authentication failed ,reading of file is sucess.....
4.And one more thing sy-subrc = 0 after running of the function module but when the statement open dataset executes sy-subrc becomes 8 which means file not opened.
Can you please help me to sort above queries.
Thanks,
Uga.
‎2007 May 22 10:31 AM
Hi Uga,
Please find my answers below:
Pls reward pts if useful.
<b>1.Is operating system parameter is necessary</b>
Host system, in which the command is to be run. OPERATINGSYSTEM is specified in the command definition (Transaction SM69).
<b>2.Status parameter is returning 'O' what does it mean.</b>
Returns the final status of the execution of the external command:
If the include RSXPGDEF is called in your program, there are the following possible values:
Value 'O': The external command was started and successfully run.
Value 'F': Error; the external command was not executed.
Value 'E': Error, the external command was terminated with an error.
Value 'S': The external command was terminated due to an operating system message.
Value 'C': The external command was terminated in an unknown way.
If you do not use RSXPGDEF, only the following values can be delivered back:
Value 'O': The external command was started and successfully run.
Value 'E': Error, the external command was not executed
3.<b>What is the use of that EXEC_PROTOCOL = IT_CMD_OUTPUT "Return table(ur gt_log).In this log I find the author name ,date,path,authentication failed ,reading of file is sucess.....</b>
Contains the STDOUT and STDERR output for the external command and output data of the target host system, if TERMINATIONWAIT is active.
<b>You can loop across that table and write the errors occured while doing FTP.</b>
4.<b>And one more thing sy-subrc = 0 after running of the function module but when the statement open dataset executes sy-subrc becomes 8 which means file not opened.</b>
Might be .But you just check the file type.Give as type c .and check.
Thanks.
Raj.