Writind Data to XML in XML Format

Hi,
This is my First post in Sun Forums.
I m learning XML writing in Java.
I have searched on the Net but unable to find the proper XML writing Method using any API.
Please provide code for writing the XML in correct format with useful API.?
i m giving the Scenario of XML here:-
<?xml version="1.0" encoding="UTF-8"?>
<Data>
<Description>Description Addes</Description>
<Details>Details Added</Details>
</Data>
I want to Write this Data Using the Java using any API.
Also I want to append the Data while i m executing the XML for second time.
<?xml version="1.0" encoding="UTF-8"?>
<Data>
<Description>Description Addes</Description>
<Details>Details Added</Details>
</Data>
<Data>
<NewDescription>NewDescription Addes</NewDescription>
<NewDetails>NewDetails Added</NewDetails>
</Data>
I have also made 1 application using dom4j which write data to XML file but while i m appending the Data
for the Second time in the XML the same line repeatd <?xml version="1.0" encoding="UTF-8"?> in the XML.
So please guide me how to remove or delete this line while i m going for writing the XML again or Appending the Data Again..
Please provide some code or good Links or Solution for my Problem for writing the Simple XML format file and Appending the Data to the Same XML without including the <?xml version="1.0" encoding="UTF-8"?> this line
Again ?
?.

Hi,
I have Attached my Whole code in which the Same Line <?xml version="1.0" encoding="UTF-8"?> is appended while i m running this code second ,third ,fourth....n..times...
import java.util.logging.Level;
import java.util.logging.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.XMLWriter;
import org.dom4j.io.OutputFormat;
import java.io.*;
public class XMLWriting {
FileWriter out;
int i=1;
OutputFormat outformat;
XMLWriter writer;
public XMLWriting() {
public static void main(String s[]) {
System.out.println("In the Main Method::");
XMLWriting onj = new XMLWriting();
onj.createDocument();
System.out.println("In the Main Method::111111111111");
public void createDocument() {
try {
System.out.println("In the Main Method::22222222222");
out = new FileWriter("D:/foo3",true);
} catch (IOException ex) {
//Logger.getLogger(XMLWriting.class.getName()).log(Level.SEVERE, null, ex);
System.out.println("Exception Is in the CreateDocument Is::"+ex.getMessage());
Document document =DocumentHelper.createDocument();
Element root = document.addElement("root");
String Data="Data";
//Element testNode = root.addElement("Description");
Element author1 = root.addElement("Description").addText(Data);
Element author2 = root.addElement("Data").addText(" nimesh");
Element author3 = root.addElement("XMl").addText("Jignesh");
try {
//OutputFormat outformat =OutputFormat.createCompactFormat();
outformat = OutputFormat.createPrettyPrint();
writer= new XMLWriter(out,outformat);
writer.write(document);
writer.close();
} catch (Exception e) {
System.out.println("Exception Is ::"+e.getMessage());
e.printStackTrace();
OutPut after Executing Two Time:-
<?xml version="1.0" encoding="UTF-8"?>//same line appended twice
<root>
<Description>Data</Description>
<Data>nimesh</Data>
<XMl>Jignesh</XMl>
</root>
<?xml version="1.0" encoding="UTF-8"?>//same line appended twice
<root>
<NewDescription>NewData</NewDescription>
<NewData>Newnimesh</NewData>
<NewXMl>NewJignesh</NewXMl>
</root>
Please help me out in this ....If any modification is needed then correct my mistake and reply me with modified code ...I want this type of OutPut without Appending the <?xml version="1.0" encoding="UTF-8"?> this line in the XML file....
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Description>Data</Description>
<Data>nimesh</Data>
<XMl>Jignesh</XMl>
</root>
<root>
<NewDescription>NewData</NewDescription>
<NewData>Newnimesh</NewData>
<NewXMl>NewJignesh</NewXMl>
</root>

Similar Messages

  • How to write the oracle data as XML format. (.XML file)

    create or replace procedure pro(p_number )
    is
    cursor c1 is select *from emp where empno=p_number;
    v_file utl_file.file_type;
    begin
    v_file := utl_file.fopen('dirc','filename.txt','w');
    for i in c1 loop
    utl_file.put_line(v_file,i.ename || i.empno ||i.job);
    end loop;
    closef(v_file);
    end;
    Now my client want instead of .txt file he need .xml files
    File should contains xml tags. can any one help regarding this.. with one example.
    How to write the oracle data as XML format. (.XML file)

    hi,
    hope this example will do something....
    SQL> select employee_id, first_name, last_name, phone_number
    2 from employees where rownum < 6
    EMPLOYEE_ID FIRST_NAME LAST_NAME PHONE_NUMBER
    100 Steven King 515.123.4567
    101 Neena Kochhar 515.123.4568
    102 Lex De Haan 515.123.4569
    103 Alexander Hunold 590.423.4567
    104 Bruce Ernst 590.423.4568
    SQL> select dbms_xmlgen.getxml('select employee_id, first_name,
    2 last_name, phone_number from employees where rownum < 6') xml
    3 from dual;
    *<?xml version="1.0"?>*
    *<ROWSET>*
    *<ROW>*
    *<EMPLOYEE_ID>100</EMPLOYEE_ID>*
    *<FIRST_NAME>Steven</FIRST_NAME>*
    *<LAST_NAME>King</LAST_NAME>*
    *<PHONE_NUMBER>515.123.4567</PHONE_NUMBER>*
    *</ROW>*
    *<ROW>*
    *<EMPLOYEE_ID>101</EMPLOYEE_ID>*
    *<FIRST_NAME>Neena</FIRST_NAME>*
    *<LAST_NAME>Kochhar</LAST_NAME>*
    *<PHONE_NUMBER>515.123.4568</PHONE_NUMBER>*
    *</ROW>*
    *<ROW>*
    *<EMPLOYEE_ID>102</EMPLOYEE_ID>*
    *<FIRST_NAME>Lex</FIRST_NAME>*
    *<LAST_NAME>De Haan</LAST_NAME>*
    *<PHONE_NUMBER>515.123.4569</PHONE_NUMBER>*
    *</ROW>*
    *<ROW>*
    *<EMPLOYEE_ID>103</EMPLOYEE_ID>*
    *<FIRST_NAME>Alexander</FIRST_NAME>*
    *<LAST_NAME>Hunold</LAST_NAME>*
    *<PHONE_NUMBER>590.423.4567</PHONE_NUMBER>*
    *</ROW>*
    *<ROW>*
    *<EMPLOYEE_ID>104</EMPLOYEE_ID>*
    *<FIRST_NAME>Bruce</FIRST_NAME>*
    *<LAST_NAME>Ernst</LAST_NAME>*
    *<PHONE_NUMBER>590.423.4568</PHONE_NUMBER>*
    *</ROW>*
    *</ROWSET>*
    ask if you want more assistance.
    thanks.

  • How to view BIW  data in XML format

    hi guys ...
                 just wondering if it is possible to view BIW data in XML format ,if yes how .
                        I am looking to pass this  XML formatted data in to another server.
    venkat

    Hi venkatesh
    Look at this link
    http://help.sap.com/saphelp_nw04/helpdata/en/33/f3843b0af3de0ee10000000a114084/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/33/f3843b0af3de0ee10000000a114084/content.htm
    will give u idea
    regards
    NR

  • Report to Save data in XML format

    Hi,
    I am getting data in XML format through a RFC. I want this data to be saved as an XML file by opening a 'Save As' dialog box so that I can choose a destination and save the file there. Please provide me code for writing such a report program. It would be better if someone can provide me the area in SAP Help where I can find such material.
    Thanks in advance!!
    Regards,
    Saurabh

    Hi,
    Use the class cl_gui_frontend_services.
    For more info please see this.
    save_dialog func module
    Cheers
    Vinod

  • How to download the report data in xml format

    Hi All,
    how to download the report data (sql/interactive) in xml format...
    Thanks,
    Vinoth

    You will want to do something like this:
    http://spendolini.blogspot.com/2006/04/custom-export-to-csv.html
    except customize it for xml.
    hth,
    John

  • How to map data in xml format to BAPIs tructures?

    A webservice call to an external system from XI, is returning data to XI in xml format.
    This needs to be formatted to map to the structure of BAPI from SAP.
    I searched and found several threads pointing to do transformations.
    But I am not sure where to start. So this thread is being posted.
    Please help.
    Thanks,
    Ven

    The thing is my data is being retrieved from webservice call a bit different.
    here is the sample data that I need to map to two structures of BAPI - Housinginfo, Houseresponsersults.
      <?xml version="1.0" encoding="utf-8" ?>
    - <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    - <soap:Body>
    - <GetResidentsResponse xmlns="http://empur.org/XLSWebSvc/XLS_Interface">
    - <GetResidentsResult>
    - <Residents xmlns="">
    - <Resident LastName="Xyz" FirstName="Abced" MiddleInitial="T" STX="1234567" Houseid="45622" SubDivName="xyz homes">
    - <Houses HousesName="villa ben" HousesId="1550" HousesStatus="P" HousesStatusDate="09/22/2009 15:26:54" HousesScore="90">
      <Street StreetCode="2538" StreetName="Victoria" StreetStatus="c" StreetStatusDate="09/22/2009 12:25:38" />
    - <Street StreetCode="2539" StreetName="Vicotria Ln" StreetStatus="p" StreetStatusDate="09/22/2009 15:26:54" StreetScore="90" ProctorID="3572" OwnerName="DONNA Perl">
      <HomeInteractions HomeNum="25873" ResidentResp="C" LayoutLawn="C" Judged="c" />
      <HomeInteractions HomeNum="25884" ResidentResp="B" LayoutLawn="B" Judged="c" />
      <HomeInteractions HomeNum="25896" ResidentResp="B" LayoutLawn="B" Judged="c" />
      <HomeInteractions HomeNum="25918" ResidentResp="D" LayoutLawn="D" Judged="c" />
      <HomeInteractions HomeNum="25919" ResidentResp="D" LayoutLawn="D" Judged="c" />
      <HomeInteractions HomeNum="25924" ResidentResp="A" LayoutLawn="A" Judged="c" />
      <HomeInteractions HomeNum="25948" ResidentResp="t" LayoutLawn="t" Judged="c" />
      <HomeInteractions HomeNum="25952" ResidentResp="C" LayoutLawn="A" Judged="w" />
      <HomeInteractions HomeNum="25953" ResidentResp="C" LayoutLawn="C" Judged="c" />
      <HomeInteractions HomeNum="25954" ResidentResp="D" LayoutLawn="D" Judged="c" />
      </Street>
      </Houses>
      </Resident>
      </Residents>
      </GetResidentsResult>
      </GetResidentsResponse>
      </soap:Body>
      </soap:Envelope>

  • Data in XML format (XML files) to BW?

    Hi,
    My customer is interested in loading data to BW (from 3rd party system) in XML format. Are there any advantages of doing this (compared to traditional ascii files)? How about disadvantages (BW version is 3.5) ?. How to get started with this one, I noticed there is a possibility to create a XML data source. Is this able to take XML files into BW or what?.
    Any help highly appreciated!

    Hi Jimmy,
       Have a look:
    http://help.sap.com/saphelp_nw04/helpdata/en/9b/821140d72dc442e10000000a1550b0/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/55/014e3c97f6bb3ee10000000a114084/content.htm
    Hope it Helps
    Srini

  • Uploading data from xml format

    Hi Experts,
                       i am working under ' ZTOOLREV ' transaction which is plant maintainence. i maintain one rfc in se37.
    import parameters are  mandatory fields entering in this application ,   export parameters are for the errors -
        it is of error structutre name.
    further i am creating one web service using transaction ' WSCONFIG  ' .  so it will be coverted in xml data.
    now my client will enter data in xml it has to come to sap and store in sap. and show if any errors.
    my requirement is the data is coming from xml format. i have to upload data from xml.
    what is the function module should be used to upload the data anad also what function module should used to handle errors?
    here in this case i am using gui_download. but i want to put in export parameters.
    which i maintained previously.
    please guide me experts.
    i can get a solution for this query because there are so many experts are there in sdn.sap.

    Hi Chaitanya,
    You may use the following program to upload your xml data into internal table
    REPORT z_read_xml_file.
    PARAMETERS: p_filnam TYPE localfile OBLIGATORY
    DEFAULT 'C:\Documents and Settings\ssaha\Desktop\test.xml'.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_filnam.
    DATA: l_v_fieldname TYPE dynfnam.
    l_v_fieldname = p_filnam.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    program_name = syst-cprog
    dynpro_number = syst-dynnr
    field_name = l_v_fieldname
    IMPORTING
    file_name = p_filnam.
    START-OF-SELECTION.
    TYPES:
    BEGIN OF ty_tab,
    name TYPE string,
    value TYPE string,
    END OF ty_tab.
    DATA:
    lcl_xml_doc TYPE REF TO cl_xml_document,
    v_subrc TYPE sysubrc,
    v_node TYPE REF TO if_ixml_node,
    v_child_node TYPE REF TO if_ixml_node,
    v_root TYPE REF TO if_ixml_node,
    v_iterator TYPE REF TO if_ixml_node_iterator,
    v_nodemap TYPE REF TO if_ixml_named_node_map,
    v_count TYPE i,
    v_index TYPE i,
    v_attr TYPE REF TO if_ixml_node,
    v_name TYPE string,
    v_prefix TYPE string,
    v_value TYPE string,
    v_char TYPE char2.
    DATA:
    itab TYPE STANDARD TABLE OF ty_tab,
    wa TYPE ty_tab.
    CREATE OBJECT lcl_xml_doc.
    CALL METHOD lcl_xml_doc->import_from_file
    EXPORTING
    filename = p_filnam
    RECEIVING
    retcode = v_subrc.
    CHECK v_subrc = 0.
    v_node = lcl_xml_doc->m_document.
    CHECK NOT v_node IS INITIAL.
    v_iterator = v_node->create_iterator( ).
    v_node = v_iterator->get_next( ).
    WHILE NOT v_node IS INITIAL.
    CASE v_node->get_type( ).
    WHEN if_ixml_node=>co_node_element.
    v_name = v_node->get_name( ).
    v_nodemap = v_node->get_attributes( ).
    IF NOT v_nodemap IS INITIAL
    attributes
    v_count = v_nodemap->get_length( ).
    DO v_count TIMES.
    v_index = sy-index - 1.
    v_attr = v_nodemap->get_item( v_index ).
    v_name = v_attr->get_name( ).
    v_prefix = v_attr->get_namespace_prefix( ).
    v_value = v_attr->get_value( ).
    ENDDO.
    ENDIF.
    WHEN if_ixml_node=>co_node_text OR
    if_ixml_node=>co_node_cdata_section.
    text node
    v_value = v_node->get_value( ).
    MOVE v_value TO v_char.
    IF v_char <> cl_abap_char_utilities=>cr_lf.
    wa-name = v_name.
    wa-value = v_value.
    APPEND wa TO itab.
    CLEAR wa.
    ENDIF.
    ENDCASE.
    advance to next node
    v_node = v_iterator->get_next( ).
    ENDWHILE.
    LOOP AT itab INTO wa.
    ENDLOOP.

  • How to download data in xml format from a jsp in IE

    In my program, I am trying to download xml data from jsp. The problem I am facing is that the downloaded page opens in the browser itself. I want it to open in a new page. The same code works fine with csv and pdf format.

    Hello
    I am using a link that calls a javascript function. To show the file download box, I have used setContentType and setHeader functions in the jsp. Thanks.

  • Group SQL data in XML Format

    Hi All,
    I have t-sql result set (Shown in image). I want to convert it into xml data format (like the code under Edit this code section).
    There can be any number of clients and any number of projects. Can some one please help me out on this.

    declare @t table
    client varchar(100),
    project varchar(100),
    amt varchar(100)
    insert @t
    values('client1','project1',100),
    ('client1','project2',200),
    ('client2','project1',150),
    ('client2','project2',250),
    ('client3','project1',300),
    ('client3','project2',400)
    SELECT client as [li],
    (SELECT
    project AS [li],
    amt AS [li/u1/li]
    FROM @t
    WHERE client = t.client
    FOR XML PATH('ul'),TYPE)as [li/*]
    FROM
    SELECT DISTINCT client
    FROM @t)t
    FOR XML PATH('ul')
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Storing data from Java Pogram(data in xml format) to SAP R/3

    Hi,
    I am having a java program which results me an xml.
    I want to dump the data to SAP R/3.
    What are the different ways/techniques should i use,to achieve the result?
    Thanks for your reply,
    regards,
    cg

    Hi,
    In simle terms can you explain me in more detail.
    lest say my java application produces xml as:
    <xml>
    <fname>myfirstname</fname>
    <lname>mylastname</lname>
    thanks for your reply,
    reg
    cg

  • Legacy data(mapping to be done by xi (in xml format)) to sap using idoc .

    hi all,
    I need to work in an object in which requirement is like , the source data is directly extracted from legacy and input file is made. now i need to create an interface program which will be used to create purchase req. in weekly basis.  now according to functional specification xi team will  map the source data in xml format and then  through idoc data is to be pushed into sap. i am confused about the step by step senario from source data to final pr creation . please clarify if somebody had worked on this kind of situation.

    Hi i encounter like this but in SD side,
    from legacy ->XI -> SAP (create SO)
    then from created SO via IDOC my requirement is to post delivery then billing.
    I think in your case the PR is already created and to be process to PO.. better check and fully understand the flow with your team.

  • Data Export in XML format

    Dear SAP Gurus;
    I had developed a <b><u>HR Data Extract Report</u></b> to export data in CSV format, but one of our vender application needs data in XML format - any assistance in writing code will be highly <b>appreciated</b> and reward points are <b><i>assured</i></b>.
    Best Regards,
    Aslam Riaz

    Hi We are also in version 4.7.
    Use the code below as refefence.  It works.  Please close the issue with appropriate points if helps.  Good luck.
    Selection Screen
    SELECTION-SCREEN BEGIN OF BLOCK selscr WITH FRAME TITLE text-s01.
    PARAMETER:p_file TYPE rlgrap-filename MODIF ID fil." Output File Name
    SELECTION-SCREEN END OF BLOCK selscr.
    Data Declaratiion
    TYPES: BEGIN OF address,
            street(20) TYPE c,
            apt(10)    TYPE c,
            city(20)   TYPE c,
            state(2)   TYPE c,
            zip(10)    TYPE c,
           END OF address.
    TYPES: BEGIN OF person,
            name(20) TYPE c,
            ssn(11) TYPE c,
            dob(12) TYPE c,
            address TYPE address,
           END OF person.
    DATA: BEGIN OF employee OCCURS 0,
           person TYPE person,
          END OF employee.
    Data for xml conversion
    DATA: l_dom TYPE REF TO if_ixml_element,
                  m_document TYPE REF TO if_ixml_document,
                  g_ixml TYPE REF TO if_ixml,
                  w_string TYPE xstring,
                  w_size TYPE i,
                  w_result TYPE i,
                  w_line TYPE string,
                  it_xml TYPE dcxmllines,
                  s_xml LIKE LINE OF it_xml,
                  w_rc LIKE sy-subrc.
    DATA: xml TYPE dcxmllines.
    DATA: rc TYPE sy-subrc,
    BEGIN OF xml_tab OCCURS 0,
                  d LIKE LINE OF xml,
    END OF xml_tab.
    Initialization
    INITIALIZATION.
    At Selection-Screen On Value Request
    AT SELECTION-SCREEN.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    Validating file
      PERFORM get_local_file_name USING p_file.
    Start-of-selection
    START-OF-SELECTION.
    Populate the internal table
      PERFORM populate_data.
    Create xml file
      PERFORM create_xml.
    END-OF-SELECTION.
    Down load the xml file
      PERFORM download_xml.
    *&      Form  populate_data
          text
    -->  p1        text
    <--  p2        text
    FORM populate_data .
      REFRESH employee.
      CLEAR employee.
      MOVE:   'Venu Test One'        TO employee-person-name,
              '111-11-1111'          TO employee-person-ssn,
              '01/01/1900'           TO employee-person-dob,
              '1111 Sanzo road'      TO employee-person-address-street,
              '111 A1'               TO employee-person-address-apt,
              'BALTIMORE'            TO employee-person-address-city,
              'MD'                   TO employee-person-address-state,
              '21209'                TO employee-person-address-zip.
      APPEND employee.
      CLEAR  employee.
      MOVE:   'John Smith'           TO employee-person-name,
              '222-22-2222'          TO employee-person-ssn,
              '02/02/1888'           TO employee-person-dob,
              '2222 John Smith road' TO employee-person-address-street,
              '222 B2'               TO employee-person-address-apt,
              'SANFRANSISCO'         TO employee-person-address-city,
              'CA'                   TO employee-person-address-state,
              '99999'                TO employee-person-address-zip.
      APPEND employee.
    ENDFORM.                    " populate_data
    *&      Form  create_xml
          text
    -->  p1        text
    <--  p2        text
    FORM create_xml .
      CLASS cl_ixml DEFINITION LOAD.
      g_ixml = cl_ixml=>create( ).
      CHECK NOT g_ixml IS INITIAL.
      m_document = g_ixml->create_document( ).
      CHECK NOT m_document IS INITIAL.
      WRITE: / 'Converting DATA TO DOM 1:'.
      CALL FUNCTION 'SDIXML_DATA_TO_DOM'
        EXPORTING
          name         = 'EMPLOYEE'
          dataobject   = employee[]
        IMPORTING
          data_as_dom  = l_dom
        CHANGING
          document     = m_document
        EXCEPTIONS
          illegal_name = 1
          OTHERS       = 2.
      IF sy-subrc = 0.
        WRITE 'Ok'.
      ELSE.
        WRITE: 'Err =',
        sy-subrc.
      ENDIF.
      CHECK NOT l_dom IS INITIAL.
      w_rc = m_document->append_child( new_child = l_dom ).
      IF w_rc IS INITIAL.
        WRITE 'Ok'.
      ELSE.
        WRITE: 'Err =',
        w_rc.
      ENDIF.
      CALL FUNCTION 'SDIXML_DOM_TO_XML'
        EXPORTING
          document      = m_document
        IMPORTING
          xml_as_string = w_string
          size          = w_size
        TABLES
          xml_as_table  = it_xml
        EXCEPTIONS
          no_document   = 1
          OTHERS        = 2.
      IF sy-subrc = 0.
        WRITE 'Ok'.
      ELSE.
        WRITE: 'Err =',
        sy-subrc.
      ENDIF.
      LOOP AT it_xml INTO xml_tab-d.
        APPEND xml_tab.
      ENDLOOP.
    ENDFORM.                    " create_xml
    *&      Form  get_local_file_name
          text
         -->P_P_FILE  text
    FORM get_local_file_name  USING    p_p_file.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        CHANGING
          file_name     = p_p_file
        EXCEPTIONS
          mask_too_long = 1
          OTHERS        = 2.
      IF sy-subrc <> 0.
        MESSAGE i007(zu).  " 'Error in getting filename'.
      ENDIF.
    ENDFORM.                    " get_local_file_name
    *&      Form  download_xml
          text
    -->  p1        text
    <--  p2        text
    FORM download_xml .
      CALL FUNCTION 'WS_DOWNLOAD'
        EXPORTING
          bin_filesize = w_size
          filename     = p_file
          filetype     = 'BIN'
        TABLES
          data_tab     = xml_tab
        EXCEPTIONS
          OTHERS       = 10.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
       SKIP 5.
       WRITE:(15) 'The ', p_file , 'is created successfully'.
      ENDIF.
    ENDFORM.                    " download_xml

  • ABAP Data to XML file

    Hi,
    I have read this weblog
    /people/patrick.baer/blog/2005/02/24/abap-serialization--part-i-quick-n-easy and tried to serialize ABAP data into XML format.
    In fact, I have copied the exact code from this weblog, but somehow this file is not visible in my pc.
    DATA example_data TYPE spfli.
    select single * from spfli into example_data.
    DATA xml_utils TYPE REF TO if_ixml.
    xml_utils = cl_ixml=>create( ).
    DATA xml_stream_factory TYPE REF TO if_ixml_stream_factory.
    xml_stream_factory = xml_utils->create_stream_factory( ).
    DATA xml_output_stream TYPE REF TO if_ixml_ostream.
    xml_output_stream = xml_stream_factory->create_ostream_uri( system_id =
    'file://c:test.xml' ).
    try.
    CALL TRANSFORMATION id
    SOURCE data_node = example_data
    RESULT XML xml_output_stream.
    catch cx_sy_conversion_base64 CX_SY_CONV_ILLEGAL_DATE_TIME.
    write 'there is an exception'.
    endtry.
    This part of the code, I have also changed to :
    xml_stream_factory->create_ostream_uri( system_id =
    'file://test.xml' ).
    and still the file is not visible.
    I presume three reasons:
    a) Looking in the wrong place
    b) Some configuration, I am not doing properly
    c) Something else has to be done, to write a file to system
    Any help on this regard, is highly appreciated.
    Next issue being, how robust is the approach of serializing ABAP data into XML format, so that a third party system can pick up this data and do a comparison ?
    Some parameters that I am looking for in this regards are:
    a) Error Validation (can XML data be incorrectly written into a file/while transmitting this data some errors can creep in. If so, how do I rectify it. As far as I know, this data can only be written to Presentation Server or using FTP ,transported to required destination. Is there any other approach ? )
    b) Security
    Would be great if you could drop some hints for the above procedure.
    Regards,
    Subramanian V.

    I think you are perhaps overestimating the capabilities of the osteam object.  If you want to write the XML to a file the easiest thing to do is render it an ostream_itable (internal ABAP table).  Then you can download it your PC with the GUI_DOWNLOAD function:
    parameter: ifile type file_table-filename obligatory
               default 'c:issue.xml'.
    ****Temp File name for function module call.
    data: ifilename type string.
      move ifile to ifilename.
      create object issue
         exporting
           id     = id
           create_mode = abap_false.
      data: g_ixml type ref to if_ixml,
             g_stream_factory type ref to if_ixml_stream_factory,
             xslt_err type ref to cx_xslt_exception,
             g_encoding type ref to if_ixml_encoding,
             ostream type ref to if_ixml_ostream.
      constants:  line_length type i value 4096.
      types:      line_t(line_length) type x,
                  table_t type standard table of line_t.
      data: restab type table_t.
      constants:
    * encoding for download of XML files
        encoding     type string value 'utf-8'.
      data: ressize type i.
      try.
          g_ixml = cl_ixml=>create( ).
          g_stream_factory = g_ixml->create_stream_factory( ).
          g_encoding = g_ixml->create_encoding( character_set = encoding
            byte_order = 0 ).
          refresh restab.
          ostream =
            g_stream_factory->create_ostream_itable( table = restab ).
          ostream->set_encoding( encoding = g_encoding ).
          call transformation id_indent
            source     asap_issue = issue
            result xml restab
            options
            data_refs = 'embedded'.
          ressize = ostream->get_num_written_raw( ).
        catch cx_xslt_exception into xslt_err.
          data: s type string.
          s = xslt_err->get_text( ).
      endtry.
      call function 'GUI_DOWNLOAD'
        exporting
          bin_filesize = ressize
          filename     = ifilename
          filetype     = 'BIN'
        tables
          data_tab     = restab
        exceptions
          others       = 1.
      call method cl_gui_frontend_services=>execute
         exporting
           document               = ifilename
    *    APPLICATION            =
    *    PARAMETER              =
    *    DEFAULT_DIRECTORY      =
    *    MAXIMIZED              =
    *    MINIMIZED              =
    *    SYNCHRONOUS            =
        exceptions
          cntl_error             = 1
          error_no_gui           = 2
          bad_parameter          = 3
          file_not_found         = 4
          path_not_found         = 5
          file_extension_unknown = 6
          error_execute_failed   = 7
          others                 = 8.
    As far as a different system, once you have the data serialized into a string or internal table you have lots of possibilites.  If the other system is an SAP system you could send the data via RFC.  You could always write the XML string to the server file system (via open dataset, transfer to dataset).  You can then FTP the file (using built in SAP FTP functionality) just about anywhere.
    What are you looking for as far as robust and secure.  The XML serializer is built in the ABAP Kernel and quite robust.  As far as secure- the data isn't secure at all.  The data is written into a simple string (if written into the file system or your pc - it is a text or binary file that can easily be read by just about anything).  Serializing to XML in and of itself isn't going to provide any security.

  • How to upload the data from XML file to SAP database using IDOC

    Hi,
    I need some steps  to upload  data from XML format file from other directory to SAP database using IDOC.
    how to approch this please if any one knows give me ans
    it will be a great help ful to me
    Thanks in Advance
    Mallik

    Thank you vijay,
    But i heard that by using this Fun modules, when we are passing IDOC in back ground schedule,  so some other depended FM not supporting, so how to approach this and how to avoid this problem. 
    Have you worked on this before if any one worked on this please help me out
    And thank you once again for your valuable information
    Best Regards
    Mallik

Maybe you are looking for

  • How do i transfer pictures from my ipad to a sd card?

    How do I transfer pictures from an album I have in my iPad over to a SD card?

  • Shooting a school play, camera advice

    Hi, We have been asked by the school if we could shoot this years Christmas play. We thought the best way was to setup 3 fixed cameras covering different angles of the stage and use Final Cut Pro to cut the footage together. We would ideally like to

  • I cannot mount my digital camera

    So I have very old and crappy digital camera HP Photosmart 433. I use it for reading memory cards on my pc. So I plug the usb cable.. Oct 10 20:24:41 marduk usbcore: registered new interface driver usb-storage Oct 10 20:24:41 marduk USB Mass Storage

  • Need to make Assignment field in Cash Journal mandatory

    Hi friends I have a requirement to make the assignment field as mandatory in the Cash Journal for a particular G/L. So accordingly, i changed the Field Status for that particular G/L as mandatory in the Field Status Group. But now when i am entering

  • Changing Photo Aspect in Calendar

    I'm trying to build a calendar in iPhoto '08 and I can't seem to change the picture aspect for certain layouts. In the seven picture layout the example shows the large picture with a landscape aspect but when I try to use this layout the large pictur