‎2008 May 23 1:20 PM
Dear Experts,
how to create a directory in FTP Server (Window Based).
Plz help me as soon as possible.
thanx
‎2008 May 23 1:24 PM
its like 1st u connect to ftp server , place the file in ftp server
and then disconnect
u also use some LINUX commands for ths
U can use
FTP_CONNECT
FTP_COMMAND
just check below report also i have written the steps with there use hope it will help u
REPORT ZFTP_TEST .
data:hdl type handle,
l_key type i value 26101957, "fixed value
l_slen type i, "length of the password
l_pwd type c length 50 value 'bhanu'. "user's password ie, password of FTP server
l_slen = STRLEN( l_pwd ).
DATA: V_PATH LIKE SXPGCOLIST-PARAMETERS. "path for application server
DATA: V_FILE LIKE RLGRAP-FILENAME. "filename from where data is picked
data:file_test type localfile value 'test_ftp',
l_string type string.
l_string = 'test successfull'.
data:V_CMD(80) type c.
data:begin of itab occurs 0,
line(101) type c,
end of itab.
start-of-selection.
*CLEAR: V_DSTLEN, X_PWD.
*DESCRIBE FIELD V_PWD LENGTH V_DSTLEN.
*
*CALL 'AB_RFC_X_SCRAMBLE_STRING'
*ID 'SOURCE' FIELD V_PWD
*ID 'KEY' FIELD KEY
*ID 'SCR' FIELD 'X'
*ID 'DESTINATION' FIELD X_PWD
*ID 'DSTLEN' FIELD V_DSTLEN.
*
v_path = '/usr/sap/EPK/DVEBMGS20/work'. "path of the local directory ie DIR_HOME
v_file = 'test_ftp'. "name of the file which has data
open dataset file_test FOR OUTPUT IN TEXT MODE ENCODING DEFAULT . "opens the respective file in application server
transfer l_string to file_test.
close dataset file_test.
CALL FUNCTION 'HTTP_SCRAMBLE' "encrypt the password of the user of the FTP server
EXPORTING
SOURCE = l_pwd
sourcelen = l_slen "length of the password
key = l_key "fixed value
IMPORTING
DESTINATION = l_pwd . "encrypted password in the output
CALL FUNCTION 'FTP_CONNECT' "TO CONNECT TO THE FTP SERVER
EXPORTING
user = 'bhanu' "USER ID
password = l_pwd
host = '10.25.117.190' "IP ADDRESS WHERE THE SERVER IS PLACED
rfc_destination = 'SAPFTPA' "RFC DESTINATION FIXED
IMPORTING
HANDLE = HDL "IF THE HANDLE VALUE IS 1 THEN THE CONNECTION IS ESTABLISHED
EXCEPTIONS
NOT_CONNECTED = 1
OTHERS = 2.
.
IF SY-SUBRC = 0.
CONCATENATE 'lcd' V_PATH INTO V_CMD SEPARATED BY SPACE. "lcd(case sensitive) is a command to open the path at application server
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
HANDLE = HDL
command = V_CMD
tables
data = ITAB
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3
OTHERS = 4
.
clear v_cmd.
clear itab.
concatenate 'put' V_FILE INTO V_CMD SEPARATED BY SPACE. "the file in the above path is picked and sent to ftp server
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
HANDLE = HDL
command = V_CMD
tables
data = ITAB
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = HDL.
.
endif.