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: 

Contents of internal table in transfer correctly using FTP FM

Former Member
0 Kudos
811

Hi Expert's

I have Transfered content of internal table from R3 to FTP Server using FTP_CONNECT FTP_R3_TO_CLIENT,FTP_COMMAND ,FTP_DISCONNECT,

in background and file is created successfully ,

Now the Problem is Content of internal table is neither tranfered correctly nor tab delimeted and file format in the ftp server is ".txt".

please suggest any solution for this

thanks

7 REPLIES 7

brad_bohn
Active Contributor
0 Kudos
715

Hard to tell without seeing your code or the codepage(s) involved. One thing I would suggest is debugging it in the foreground and verifying the contents of the internal table before FTP. As you may know, you can use a different RFC destination for FTP in the foreground and debug the process. Also, if you haven't done so already, activate the FTP server on your local PC and FTP to that location. Check the format of the file and contents. Do they match the remote server or are they different?

Former Member
0 Kudos
715

Hi Brad ,

Thanks for your reply , please find the below code which i have written for ftp file transfer,

DATA : DEST TYPE RFCDES-RFCDEST VALUE 'SAPFTPA',

HANDLE TYPE I,

SLEN TYPE I,

KEY TYPE I VALUE 26101957.

DATA : USER(30) TYPE C VALUE 'XXXXXXXX',

PWD(30) TYPE C VALUE 'XXXXXXXX'.

SLEN = STRLEN( PWD ).

CALL FUNCTION 'HTTP_SCRAMBLE'

EXPORTING

SOURCE = PWD

SOURCELEN = SLEN

KEY = KEY

IMPORTING

DESTINATION = PWD.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

USER = USER

PASSWORD = PWD

  • ACCOUNT = ACCOUNT

HOST = HOST

RFC_DESTINATION = DEST

  • GATEWAY_USER = GATEWAY_USER

  • GATEWAY_PASSWORD = GATEWAY_PASSWORD

  • GATEWAY_HOST = GATEWAY_HOST

IMPORTING

HANDLE = HANDLE

EXCEPTIONS

NOT_CONNECTED = 1.

IF SY-SUBRC NE 0.

MESSAGE 'Not connected' TYPE 'I'.

ELSE.

MESSAGE 'Connected' TYPE 'S'.

ENDIF.

DATA : CMD(120) TYPE C.

TYPES: BEGIN OF BLOB,

LINE(255) TYPE C,

END OF BLOB.

TYPES: BEGIN OF TEXT,

LINE(120) TYPE C,

END OF TEXT.

DATA: BINDATA TYPE TABLE OF BLOB WITH HEADER LINE,

RESULT TYPE TABLE OF TEXT WITH HEADER LINE,

FILESIZE TYPE I,

FILEDATE(10),

FILETIME(10),

DOCID LIKE SYSUUID-C,

BS(2) TYPE C,

DATE(10) TYPE C,

DATE_SEPARATED(10) TYPE C.

BS = '\t'.

CALL FUNCTION 'SYSTEM_UUID_C_CREATE'

IMPORTING

UUID = DOCID.

CONCATENATE 'project name'

'project description'

'client manager (optional)'

'Idhasoft Manager'

'vendors'

'start date'

'finish date''\t' INTO BINDATA-LINE SEPARATED BY DLIM.

APPEND BINDATA.

CLEAR BINDATA. Cont......

Edited by: anil kumar on Jul 29, 2009 11:27 AM

Edited by: anil kumar on Jul 29, 2009 11:28 AM

Former Member
0 Kudos
715

LOOP AT IST_DTL INTO WA_DTL.

CONCATENATE WA_DTL-PLFAZ4(2) '/' WA_DTL-PLFAZ6(2) '/' WA_DTL-PLFAZ+0(4) INTO DATE.

CONCATENATE WA_DTL-E_DATE4(2) '/' WA_DTL-E_DATE6(2) '/' WA_DTL-E_DATE+0(4) INTO DATE_SEPARATED.

CONCATENATE WA_DTL-PSPID

WA_DTL-POST1

WA_DTL-CLNT

WA_DTL-VERNR

WA_DTL-LIFNR

DATE

DATE_SEPARATED

BS INTO BINDATA-LINE SEPARATED BY DLIM.

    • CONCATENATE bindata-line rlim INTO bindata-line.

    • CONDENSE bindata-line.

  • CONCATENATE BINDATA-LINE BS INTO BINDATA-LINE.

  • CONDENSE BINDATA-LINE.

APPEND BINDATA.

CLEAR BINDATA.

ENDLOOP.

DESCRIBE TABLE BINDATA LINES SLEN.

SLEN = SLEN * 255.

CALL FUNCTION 'FTP_R3_TO_CLIENT'

EXPORTING

FNAME = DOCID

RFC_DESTINATION = DEST

BLOB_LENGTH = SLEN

  • character_mode = 'X'

TABLES

BLOB = BINDATA.

  • TEXT = RESULT.

CONCATENATE 'put' DOCID '/vinod/vendor/Project.txt ' INTO CMD SEPARATED BY ' '.

REFRESH RESULT.

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

HANDLE = HANDLE

COMMAND = CMD

  • RFC_DESTINATION = DEST

VERIFY = 'X'

IMPORTING

FILESIZE = FILESIZE

FILEDATE = FILEDATE

FILETIME = FILETIME

TABLES

DATA = RESULT

EXCEPTIONS

TCPIP_ERROR = 1

COMMAND_ERROR = 2

DATA_ERROR = 3.

IF SY-SUBRC = 0.

MESSAGE 'file moved' TYPE 'S'.

ENDIF.

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

HANDLE = HANDLE.

LOOP AT RESULT.

WRITE: / RESULT-LINE.

ENDLOOP.

Edited by: anil kumar on Jul 29, 2009 2:42 PM

Former Member
0 Kudos
715

The above code `ll run in background and contents of are stored in Project.txt file and i have used RFCdestination as SAPFTPA.

The same code is tested in foreground using SAPFTP RFCDestination call it works fine and getting exact result with tab delimeted

but when i run same code using SAPFTPA in Background the content of internal table in moved correctly to BINDATA ITABLE which is used in

FTP_R3_TO_cLIENT FM with tab delimeted,

but Project.txt file is neither getting correct value of binddata table nor tab delimeted.

I mean to say,

for eg.

IST_DTL contains 71 records, which are append correctly to Bindata itab i,e IST_DTL = BINDATA with tab delim

so IST_DTL =71 and BINDATA = 71 with tab delim

when i run code in foreground `m getting all 71 records with tab delim, but in background `m getting only 20-30 records without tab delim

it works fine for SAPFTP RFC dest call,partially for SAPFTPA RFC dest call

for tab delim i have used : DLIM TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

please suggest

Former Member
0 Kudos
715

any suggestions please its an issue.

thanks

Former Member
0 Kudos
715

sloved self

0 Kudos
642

Please share the solution on this issue.