10-25-2006 4:42 AM
Hi
I have to move a file from UNIX to ftp server(WINDOWS)R:\SAPRpts\User Reports\abc.xls. Iam using 4.6C version. so what is the procedure and how should i send the file.
Thanks in advance
Satya
10-25-2006 4:49 AM
Use the Function module <b>SXPG_COMMAND_EXECUTE</b>.
data: begin of IEPCOL occurs 100.
include structure BTCXPM.
data: end of IEPCOL.
BTCXPM = Log message from external program to calling program
data: W_STATUS like EXTCMDEXEX-STATUS.
EXTCMDEXEX = Parameters of SXPG_COMMAND_EXECUTE
data: W_HOST like RFCDISPLAY-RFCHOST.
RFCDISPLAY = Display structure for RFCDES maintenance "M5
The External operating system command ZECOM is created using the transaction SM69. For any changes to the command goto SM69 and for executing and testing use the transaction SM49.
W_HOST = SY-HOST.
call function 'SXPG_COMMAND_EXECUTE'
exporting
COMMANDNAME = 'ZECOM'
ADDITIONAL_PARAMETERS = P_F_UNIX
OPERATINGSYSTEM = SY-OPSYS
TARGETSYSTEM = W_HOST
STDOUT = 'X'
STDERR = 'X'
TERMINATIONWAIT = 'X'
importing
STATUS = W_STATUS
tables
EXEC_PROTOCOL = IEPCOL
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.
case SY-SUBRC.
when 1.
message E138(ZSM) with 'No permission to Execute ' 'External O/S command'.
when 2.
message E138(ZSM) with 'External O/S Command not found'.
when 3.
message E138(ZSM) with 'Parameters too long.' 'Exceeds the limit of 128 characters'.
when 4.
message E138(ZSM) with 'Security risk. ' 'The Command contains impermissible characters'.
when 5.
message E138(ZSM) with 'Wrong check call interface. Check the command.'.
when 6.
message E138(ZSM) with 'Error while starting the External O/S Command'.
when 7.
message E138(ZSM) with 'Error getting the return ' 'code of the External O/S command'.
when 8.
message E138(ZSM) with 'Unknown error'.
when 9.
message E138(ZSM) with 'Some mandatory parameter is not supplied'.
when 10.
message E138(ZSM) with 'Too many parameters. ' 'Check the additional parameter'.
when 11.
message E138(ZSM) with 'Illegal command'.
when others.
message E138(ZSM) with 'Unknown error'.
endcase.
else.
if W_STATUS = 'O'.
if UNIX_FILE cs '.ES'.
message S138(ZSM) with 'File FTP Successfull..!'.
External O/S command to' 'FTP the above file to' 'ES FTP server succesfully!' P_F_UNIX.
endif.
else.
message I138(ZSM) with 'Ext O/S command to FTP the ' 'abv file to ext UNIX system not executed due to:'.
loop at IEPCOL.
write:/ SY-TABIX, IEPCOL-MESSAGE,255 ' '.
endloop.
endif.
endif.
endform. " TRIGGER_EXT_OS_COMMAND
Regards
- Gopi
Message was edited by: Gopi Narendra
10-25-2006 2:54 PM
Hi Gopi
WHere should we give the source and destination paths in the function module
10-26-2006 6:40 AM
Hi Satya
With FM: SXPG_COMMAND_EXECUTE, you have to create an external command which can transfer the files.
Kind Regards
Eswar
10-25-2006 5:40 AM
10-25-2006 9:17 AM
Hi Satya,
Use transaction codes CG3Y and CG3Z for moving files b/w servers.
Regards,
Chandra.
Note: Please reward if helpful.