Application Development 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: 

writing an xml file to FTP Server

former_member457420
Participant
0 Kudos

Dear Experts,

Iam using the class CL_XML_DOCUMENT to create an xml document out of my itab in an ABAP report.

This file needs to be put in to an ftp server as an xml file.

Iam not sure how to go about it.

Could anyone suggest me how to put the file on the FTP server.

The class has a "export_to_file" method where one has to give a path name.

Any Pointers would be greatly appreciated

Thanks

P

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Arun ,

U can try like this.....

gd_slen = STRLEN( p_pwd ).

CALL FUNCTION 'HTTP_SCRAMBLE'

EXPORTING

SOURCE = p_pwd

sourcelen = gd_slen

key = gd_key

IMPORTING

destination = p_pwd.


CALL FUNCTION 'FTP_CONNECT'

EXPORTING

user = p_user

password = p_pwd

host = p_host

rfc_destination = p_dest

IMPORTING

handle = gd_hdl.


CALL FUNCTION 'FTP_COMMAND'

EXPORTING

handle = gd_hdl

command = 'ascii'

TABLES

data = it_result

EXCEPTIONS

tcpip_error = 1

command_error = 2

data_error = 3.


CALL FUNCTION 'FTP_R3_TO_SERVER'

EXPORTING

handle = gd_hdl

fname = gd_fname

blob_length = l_count

character_mode = 'X'

TABLES

text = it_final

EXCEPTIONS

TCPIP_ERROR = 1

COMMAND_ERROR = 2

DATA_ERROR = 3.


if sy-subrc = 0.

write: / 'File uploaded:', gd_fname.

endif.

Regards,

Yukti

7 REPLIES 7

former_member209685
Participant
0 Kudos

Former Member
0 Kudos

Hi Arun,

I don't think the method, export_to_file will work to put file in FTP as the FTP needs host name,port name and user credentials.

The following blog may help you:

http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP+solution+to+implement+FTP+transactions

Cheers,

Samir

0 Kudos

Thanks Guys.

That means I have to download the generated xml file in my application server and then transfer it to the ftp server.Iam using ECC 6.0.

Is that so.I have googled a bit and I have seen people posting abt some formatting problems.

Is downloading to the app.server and from there to the ftp server is the right way.

0 Kudos

Hi Arun,

no you don't have to download it to the application server. Get the XML contents as an internal table and then use the internal table as the blob parameter to the function module FTP_R3_TO_SERVER.

Cheers
   Adi

0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi Arun ,

U can try like this.....

gd_slen = STRLEN( p_pwd ).

CALL FUNCTION 'HTTP_SCRAMBLE'

EXPORTING

SOURCE = p_pwd

sourcelen = gd_slen

key = gd_key

IMPORTING

destination = p_pwd.


CALL FUNCTION 'FTP_CONNECT'

EXPORTING

user = p_user

password = p_pwd

host = p_host

rfc_destination = p_dest

IMPORTING

handle = gd_hdl.


CALL FUNCTION 'FTP_COMMAND'

EXPORTING

handle = gd_hdl

command = 'ascii'

TABLES

data = it_result

EXCEPTIONS

tcpip_error = 1

command_error = 2

data_error = 3.


CALL FUNCTION 'FTP_R3_TO_SERVER'

EXPORTING

handle = gd_hdl

fname = gd_fname

blob_length = l_count

character_mode = 'X'

TABLES

text = it_final

EXCEPTIONS

TCPIP_ERROR = 1

COMMAND_ERROR = 2

DATA_ERROR = 3.


if sy-subrc = 0.

write: / 'File uploaded:', gd_fname.

endif.

Regards,

Yukti

0 Kudos

This message was moderated.