Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

FTP prob

Hi. I am having a probem with my reqm'ts. I need to ftp file to another server. I am using FM ftp_r3_to_server. I am able to see the file in the server however the file does not contain anything but when I check the internal table that i'm passing, the internal table has data. Please see the my codes below:

DATA: LT_COMMAND(100) TYPE C,

LT_HDL TYPE I,

LT_KEY TYPE I VALUE 26101957,

LT_SLEN TYPE I,

  • connection parameters

LT_USER(30) TYPE C VALUE 'dev_ftp',

LT_PWD(30) TYPE C VALUE 'qwerty123',

LT_HOST(30) TYPE C VALUE '10.100.15.76',

LT_DEST LIKE RFCDES-RFCDEST VALUE 'SAPFTP',

BEGIN OF LITABT_RESULT OCCURS 0,

LINE(100) TYPE C,

END OF LITABT_RESULT.

REFRESH LITABT_RESULT.

CLEAR: LT_COMMAND(100),

LT_HDL,

LT_SLEN.

***scramble password

CALL FUNCTION 'SCRAMBLE_STRING'

EXPORTING

SOURCE = LT_PWD

KEY = LT_KEY

IMPORTING

TARGET = LT_PWD.

***connect to server

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

USER = LT_USER

PASSWORD = LT_PWD

HOST = LT_HOST

RFC_DESTINATION = LT_DEST

IMPORTING

HANDLE = LT_HDL

EXCEPTIONS

NOT_CONNECTED = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

EXIT.

ENDIF.

*FTP_R3_TO_SERVERThis is used to transfer the internal table data as a

*file to other system in the character mode.

concatenate 'cd' '/export/home/irabdev/dev/ftp/inbound/sap'

into lt_command separated by space.

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

HANDLE = lt_hdl

COMMAND = lt_command

COMPRESS = 'N'

TABLES

DATA = LITABT_RESULT

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.

clear litabt_result.

refresh litabt_result.

data: blob_length type i, lines type i.

describe table p_transit lines lines.

blob_length = lines.

clear lines.

CALL FUNCTION 'FTP_R3_TO_SERVER'

EXPORTING

HANDLE = lt_hdl

FNAME = p_files <filename: data.txt>

BLOB_LENGTH = lines

character_mode = 'X'

TABLES

BLOB = p_transit <internal table>

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.

  • disconnect

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

HANDLE = LT_HDL.

  • close connection

CALL FUNCTION 'RFC_CONNECTION_CLOSE'

EXPORTING

DESTINATION = LT_DEST

EXCEPTIONS

OTHERS = 1.

please let me know what to do to successfully put the data to the server.

Helpful suggestions will be rewarded with points. Thanks

Tags:
Not what you were looking for? View more on this topic or Ask a question