10-20-2008 7:25 AM
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
10-20-2008 7:29 AM
Hello,
Try in this way because SAP will use this FM.
data: bindata type table of blob with header line,
blob_length type i,
docid like sysuuid-c,
hdl type i,
call function 'FTP_R3_TO_SERVER'
exporting
handle = hdl
fname = docid
blob_length = blob_length
tables
blob = bindata.
Try in this way u may get any idea.
10-20-2008 8:27 AM
hi. Thank u for your reply. I tried your suggestion but still the file does not contain anything. It still has 0 bytes.
I tried to move the contents of my internal table to new internal table with properties:
data: begin of i_blob occurs 0,
contents(255),
end of i_blob.
loop at it_transit.
concatenate it_transit-CHARG it_transit-MATNR it_transit-MATKL
it_transit-MTART it_transit-WERKS it_transit-RESWK
it_transit-LGORT it_transit-MENGE it_transit-TEXT1
it_transit-DCOD1 it_transit-DCOD2 it_transit-LTYPE
it_transit-FWERK it_transit-AWERK it_transit-TWERK
into i_blob-content separated by ','.
append i_blob.
endloop.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
HANDLE = lt_hdl
FNAME = p_files
BLOB_LENGTH = lines
character_mode = 'X'
TABLES
BLOB = i_blob "p_transit
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.
Is this correct?
10-20-2008 10:24 AM