Application Development and Automation 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: 
Read only

read file from FTP

0 Likes
6,796

I want to fetch data in internal table from FTP server...

P_FILE = '/data/Newfolder/test.txt'.

OPEN DATASET P_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.

break-point.

IF SY-SUBRC = 0.

DO.

READ DATASET P_FILE INTO IT_ITAB.

APPEND IT_ITAB.

CLEAR IT_ITAB.

ENDDO.

ENDIF.

-


but I m getting sy-subrc = 8 ....so dataset couldnt open....plz give correct code

Edited by: ritesh9898 on Dec 3, 2010 9:46 AM

Edited by: ritesh9898 on Dec 3, 2010 9:47 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,862

Check your file path again '/data/Newfolder/test.txt'.

Is it capital N in newfolder?

Also check if you have valid authorization su53...

5 REPLIES 5
Read only

Former Member
0 Likes
2,863

Check your file path again '/data/Newfolder/test.txt'.

Is it capital N in newfolder?

Also check if you have valid authorization su53...

Read only

0 Likes
2,862

you can not use OPEN to login to a ftp server.

Read only

Former Member
0 Likes
2,862

Hi Ritesh,

If you want take file from FTP you should us some functional modules, OPEN DATESET is for application server files.

For FTP refer the some standard programs

RSFTP001 to RSFTP011.

Regards,

Sri

Read only

former_member242255
Active Contributor
0 Likes
2,862

you can use the FM's like

FTP_CONNECT

FTP_COPY

Read only

Former Member
0 Likes
2,862

Hi try this..

you need authorisations to ftp server and login credentials.

data: ftp_add type char1024.

concatenate '//' p_user ':' p_pwd '@' p_host '/<diretory>/Try.pdf' into ftp_add.

CALL FUNCTION 'HTTP_SCRAMBLE'

EXPORTING

SOURCE = P_PWD

SOURCELEN = SLEN

KEY = KEY

IMPORTING

DESTINATION = P_PWD.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

USER = P_USER

PASSWORD = P_PWD

HOST = P_HOST

RFC_DESTINATION = P_RFCDES

IMPORTING

HANDLE = L_HDL.

CONCATENATE 'cd' P_DIR INTO L_CMD SEPARATED BY SPACE.

SLEN = STRLEN( P_PWD ).

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

HANDLE = L_HDL

COMMAND = L_CMD

COMPRESS = P_COMP

TABLES

DATA = LT_RESULT

EXCEPTIONS

COMMAND_ERROR = 1

TCPID_ERROR = 2.

data : t_blob type table of solix.

call function 'FTP_SERVER_TO_R3'

exporting

handle = l_hdl

fname = DOCID2

  • CHARACTER_MODE = 'X'

importing

blob_length = l_length

tables

blob = t_blob "it_blob

  • text = t_blob

exceptions

tcpip_error = 0

command_error = 0

data_error = 0

others = 0.

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

HANDLE = L_HDL.

CALL FUNCTION 'RFC_CONNECTION_CLOSE'

EXPORTING

DESTINATION = P_RFCDES

EXCEPTIONS

OTHERS = 1.