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: 

see a file as XML File in ftp server

former_member457420
Participant
0 Kudos
822

Hallo Experts,

I have coded as follows to write an itab to an FTP server.

types truxs_t_text_data(4096) type c occurs 0.

data text_outputtab type TRUXS_T_TEXT_DATA.

CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'

    EXPORTING

      i_field_seperator    = '#'

    TABLES

      i_tab_sap_data       = gt_offpo   “ -Internal Itab

    CHANGING

      i_tab_converted_data = text_outputtab

    EXCEPTIONS

      conversion_failed    = 1

      OTHERS               = 2.

  IF sy-subrc <> 0.

                * To Connect to the Server using FTP ,Iam using the following FM.

                CALL FUNCTION 'FTP_CONNECT'

  CONCATENATE '/Text1_Out.' sy-datum  INTO           wrk_file.

*FTP_R3_TO_SERVER:used to transfer the internal table data as a file to other system in the character mode.

  CALL FUNCTION 'FTP_R3_TO_SERVER'

  exporting

    handle         = w_hdl

    fname          = wrk_file          "file path of destination system

    character_mode = ' X'

tables

    text           =  text_outputtab

ENDIF.

If I open the file on the FTP server,I want to see the file in XML format.I don’t want to see it in text format.Is there any way to do that.

Any help in this regard is greatly appreciated.

Regards

P

1 ACCEPTED SOLUTION

Former Member
0 Kudos
417

Hi Arun

Have you tried FM SAP_CONVERT_TO_XML_FORMAT?
This should convert your data to XML format.

Regards

Vic

12 REPLIES 12

Former Member
0 Kudos
417

How are you saving the file? as .txt or .xml?

Change the file extension to .xml and try.

Former Member
0 Kudos
418

Hi Arun

Have you tried FM SAP_CONVERT_TO_XML_FORMAT?
This should convert your data to XML format.

Regards

Vic

0 Kudos
417

Hi Vic.Thats true.But How can I transfer this file to the FTP server

0 Kudos
417

Hi Arun

I normally use the SM69 Functionality, to create a system command and transfer it to another server.
You can look at the FM SXPG_COMMAND_EXECUTE.
Hope this helps.

Regards

Vic

0 Kudos
417

If I stick to the text format,Iam using the datatype as follows

types truxs_t_text_data(4096) type c occurs 0.

Increasing the char value to 10000 or so gives me an error.

What If the file I want to send a bigger file?

0 Kudos
417

Hi Arun

I'd download the file using Open Dataset Transfer and Close Dataset then create an OS script to transfer/FTP the File to the other server there are two ways of doing this, You can either run the sm69 transaction as an additional step in your background job to execute the script or Call the FM SXPG_COMMAND_EXECUTE to execute that command directly out of your program after the File has been saved on your app server. The FM will then execute the transfer script to transfer your file to another server. File size should not be a problem in this case. You should talk to your system administrator with regards to the OS scripts and who creates or manages them.

Hoping this helps.

Regards

Vic

0 Kudos
417

Hi Arun,

Can you try using CALL TRANSFORMATION?

  TRY.

  CALL TRANSFORMATION ('ID')
  SOURCE DATA = lt_table

  RESULT XML XML_STRING.
  CATCH CX_ST_ERROR.
  ENDTRY.

Use the XML string and pass it to 'FTP_R3_TO_SERVER' or as Vic has said using OS commands and move to FTP.

0 Kudos
417

Is it possible to create the xml stream using CL_XML_DOCUMENT

0 Kudos
417

Yes you can,

CALL METHOD l_xml->create_with_data( dataobject = itab[] name = 'ROOT' ).

You can do the same with IXML also.

http://help.sap.com/saphelp_erp2004/helpdata/en/86/8280ba12d511d5991b00508b6b8b11/content.htm

What exactly are you looking for?

0 Kudos
417

Shambu,I was looking for saving an xml file directly as it is in the FTP server using the FTP command(You can see it in my first post).

0 Kudos
417

Hi Arun

You can use the XML Document Class(cl_xml_document)

Is your current problem creating the XML File or transferring it?

After you have created the XML File Save it to the app server using OPEN,TRANSFER and CLOSE DATASET.

Then you can Transfer/Copy it to the other server, then delete it from the app server when the transfer/copy is successful.

Regards

Vic

0 Kudos
417

Hi Vic,

Thanks for the support.I was trying to create an xml file directly in the fpserver instead of creating it in the app.server and then transferring it to the ftp server.

As I understood you ,that is not possible,then I will try your way.

Thanks