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.