2011 Nov 21 9:24 AM
Hello SDN Community,
I have a problem regarding the FM FTP_R3_TO_SERVER.
I have an internal table and create an XML-String with BANK_API_PP_UT_DATA_TO_XML out of it.
This string is written to another itab of type char.
Now i want to create an XML-File on an FTP-Server with that itab via FM FTP_R3_TO_SERVER.
The reason i use this FM instead of multiple FTP_COMMAND is to avoid creating the XML-File first as a local file.
In my itab which is given to FTP_R3_TO_SERVER there is the whole XML-Code.
The problem is, that when i create the file on the FTP-Server, FTP_R3_TO_SERVER adds a # as the first character of the string.
When I edit the XML-File and delete that '#' everything is ok and the XML file is correct.
Does anybody have a solution for this?
DATA: lv_length TYPE i, "Length of Password
lv_key TYPE i VALUE 26101957,
lv_pwd(50), "encrypted Password
lv_handle TYPE i, "Parameter of FTP-Connection
lt_result TYPE STANDARD TABLE OF text,
lt_xml_tab TYPE TABLE OF zer_publicitas_firsttry,
wa_xml_tab TYPE zer_publicitas_firsttry,
lt_string TYPE TABLE OF string,
wa_string TYPE string,
lt_outtab TYPE TABLE OF char16384,
wa_outtab TYPE char16384,
im_xml_data TYPE string,
im_absty TYPE bank_dte_pp_abstypename.
APPEND im_xml_tab TO lt_xml_tab.
CALL FUNCTION 'BANK_API_PP_UT_DATA_TO_XML'
EXPORTING
i_str_data = lt_xml_tab"lt_test"
IMPORTING
e_xml_data = im_xml_data
e_abstypename = im_absty.
APPEND im_xml_data TO lt_string.
LOOP AT lt_string INTO wa_string.
APPEND wa_string TO lt_outtab.
ENDLOOP.
lv_length = strlen( im_password ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
source = im_password
sourcelen = lv_length
key = lv_key
IMPORTING
destination = lv_pwd.
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = im_user
password = lv_pwd
* ACCOUNT =
host = im_host
rfc_destination = im_rfc_dest
* GATEWAY_USER =
* GATEWAY_PASSWORD =
* GATEWAY_HOST =
IMPORTING
handle = lv_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.
IF sy-subrc NE 0.
* Implement suitable error handling here
ENDIF.
*Ftp command for passive on
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = lv_handle
command = 'set passive on'
* COMPRESS =
* RFC_DESTINATION =
* VERIFY =
* IMPORTING
* FILESIZE =
* FILEDATE =
* FILETIME =
TABLES
data = lt_result
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = lv_handle
command = 'ascii'
* COMPRESS =
* RFC_DESTINATION =
* VERIFY =
* IMPORTING
* FILESIZE =
* FILEDATE =
* FILETIME =
TABLES
data = lt_result
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
DATA: lv_blob_length TYPE i.
lv_blob_length = '16384'.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = lv_handle
fname = im_filename
blob_length = lv_blob_length
* character_mode = 'X'
TABLES
blob = lt_outtab
* text = lt_outtab"lt_test
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = lv_handle.
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = im_rfc_dest
* TASKNAME =
EXCEPTIONS
destination_not_open = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
2011 Nov 21 12:05 PM
Hi,
..it seems, you must delete BOM ( byte order mark)
analyse this command in abap help or SDN:
open dataset file in text mode encoding utf-8 for input
skipping byte-order mark message msg.
grx.
2011 Nov 21 1:20 PM
Hi Andreas
I tried it but it didnt work well.
It is really weird because the first character of the itab (with only 1 row whre the whole XML-string is written in)
obviously begins with a '<'.
But after processing the FM,the created file on the FTP Server begins with an # and the XML-File becomes unreadable.
After editing that file and deleting the first character, everything is ok!
Does anybody else maybe have an idea?
Greets
Danulf
2011 Nov 23 9:58 AM
Hello SDN Community,
my problem isnt solved yet. The created file on the FTP-Server still starts with a '#'...!
I tried both ways of the FM (binary mode and text mode). Both add this '#' as the first character of the
XML-File on the FTP-Server, therefore the file becomes unreadable....
After deleting this first character, everything is fine.
Does anybody have a solution for this?
Other ways of creating an XML-File out of an itab directly on an FTP-Server without creating it first on the application server
and copying from there to the FTP-Server would be fine too
Greets
Danulf
2012 Mar 26 4:23 AM
Hello Arno,
Have u got solution pls let me know work around for same.
We are Facing same problem .
Yukti
2012 Nov 09 4:25 PM
i are Facing same problem and the solution .
TYPES: BEGIN OF blob,
line(2) TYPE x,
END OF blob.
itab TYPE TABLE OF blob WITH HEADER LINE,
DESCRIBE TABLE itab LINES lineas.
lines = lines * 2.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = mi_handle
fname = v_nom
blob_length = linas
character_mode = ' '
TABLES
blob = itab
* text = itab
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4
.
and solved my problem
2015 Jun 18 8:08 AM
Hi Arno,
We solve same problem with using this code. Blob length value must be correct.
TYPES: BEGIN OF lty_blob,
line(80) TYPE x,
END OF lty_blob.
DATA: lt_blob TYPE TABLE OF lty_blob WITH HEADER LINE,
lo_cx_root TYPE REF TO cx_root,
lv_xml TYPE xstring,
lv_err_text TYPE string,
lv_output_length TYPE i,
lv_handle TYPE i,
lv_blob_length TYPE i,
lv_fname TYPE c LENGTH 100.
TRY.
CALL TRANSFORMATION zsd_pl_xslt
SOURCE packing_list_data = ps_pack_list_data
RESULT XML lv_xml.
CATCH cx_root INTO lo_cx_root.
lv_err_text = lo_cx_root->get_text( ).
MESSAGE lv_err_text TYPE 'E'.
ENDTRY.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_xml
IMPORTING
output_length = lv_output_length
TABLES
binary_tab = lt_blob.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = lv_handle
fname = lv_fname
blob_length = lv_output_length
TABLES
blob = lt_blob
EXCEPTIONS
command_error = 1
data_error = 2
OTHERS = 3.
2016 Aug 05 10:27 PM