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

Similar Messages

  • Internal table data download to XML format

    Hello All,
    I have devloped one OOPS ALV report in that our requirement is on "SAVE" button the data of the report has to be downloaded in given XML format.Please check the format provided in Finnish language.The word "Value" specified as value which are coming in the ALV report against fields mentioned.
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!u2014Aromi list -->
    <!-- Copyright -->
    <!-- Edited with Visual Basic 6 -->
    <!-- Versio 1.0 -->
        <Tiedot Lahettaja="Value" Yhteyshlo=" Value"    
                    Yhteystieto=" Value " Asiakasnumero="">
           <Raaka-aine Nimi="" Ryhma=" Value ">
              <Tuotemerkki Nimi=" Value " Ean=" Value "
                                  Ykspakkauskoko="1" Ykspakkaustyyppi="KPL" almistaja="Value">
                 <Toimittajatiedot Tuotekoodi="10" Sopimustuote="Y" Myyntierakoko="5"
                                    Myyntieratyyppi="ME" Myyntierahinta="3,035" Hintapvm="value"
                  />
          </Tuotemerkki>
      </Raaka-aine>
    </Tiedot>
    Could anybody help how to download the report data into above format.
    Regards,
    Sachin

    Hi Sachin,
    I see the sample XML has field values embedded as XML element attributes.ie <Raaka-aine Ryhma=" Value ">. For such specific requirements:
    1. Loop through the table and Use iXML library functions to build the complete XML, element by element. Help - http://help.sap.com/saphelp_nw04/helpdata/en/86/8280ba12d511d5991b00508b6b8b11/frameset.htm
    2. You can create an XSLT Transformation that match the specific XML format,  and use CALL TRANSFORMATION to convert internal table to that specific XML format.
    Few Standard Function modules and class CL_XML_DOCUMENT may help for generic SAP XML conversions, where XML element names will be same as internal table field names. Not, sure if these can be used to generate specific XML formats.
    Thanks,
    Varun
    Edited by: Varun VS on Oct 25, 2011 7:48 AM

  • Data Import from XML Format file

    I want to import data  from XML file format.Can i do it ? If yes then please give me more details in the step.

    Pl read the below link.
    It will be helpful.
    SAP Business One Application
    Jeyakanthan

  • EAS data export in column format question

    I am trying to export data in column format and import back to replace 0 with #Missing. I want to see if it will reduce any blocks. When I export I am getting data header members from a different dimension other that Period. It is getting tricky to map these many data rows in rule file as oppose to 12 from Period.
    What determines this behavior. I know I have tried in the past (different app) and Period came through as data header record.
    Any help is appreciated.

    You can't directly control which dimension is selected (at least, not without changing your cube) in a native export.
    However, for what you are doing, you do not need a load rule - you could just find-and-replace in the file.
    You can also try converting zero to #Missing with a calc script (see Re: BSO Level 0 Block Analysis Advice) although it's going to be slow and you'd need to defrag with a dense restructure afterward.

  • Excel dates export with wrong format.

    When I exported an Excel Spreadsheet with several date columns, they displayed correctly but because of wrong formatting, they didn't sort right. The cell display was, for example, 2/7/2013 but Excel treated it as 7/2/2013 because it was assigning another country's formatting. some of the cells were formatted correctly, but about half of them were wrong and they were wrong in different ways. some were Argentinian, some Carribean, some European. Any ideas how to prevent this from happening?

    Go to Sequence>Settings and in the lower left use load presets.
    Anything that's in the HD in the sequence will have to be reset using the remove attributes function. If you have mixed media, strange things will happen.
    Also use easy setup to change your preset so any future sequences you create will be in the correct format.

  • Issues with data exported in CSV format

    Hi,
    I'm wondering if anyone else is having problems with exporting system data as a CSV? I can successfully run an export, however many of the CSV files contain superfluous line breaks resulting in the comma delimiting not working properly when viewing the records in Excel.
    Does this sound familiar to anyone else?
    Cheers,
    Cameron

    Are you talking about the case where you export some records and when you open using microsoft excel everything looks as if in a text file? If so,then yes. Infact yesterday I was exporting and having the issue. Donot remember having the issue before the upgrade. What I did is opened a blank microsoft excel sheet.Then File>Open and chose the csv file.Then modified in the text import wizard to get it in the right format.

  • CCM. Data upload SAP XML Format for CatalogueUpdateNotification

    Hi everybody
    Could anyone send me a SAP XML file example for CatalogueUpdateNotification?
    My email [email protected]
    Thanks in advance.
    Raúl.

    Hi Raul,
    Sent.
    Hope it will be useful.
    and you can give me points.
    BR
    Dinesh

  • How could I export FCE project into XML format?

    Hello,
    I recently decided to upgrade from Final Cut Express to Final Cut Pro X. But I don't seem to be able to export my FCE unfinish projects. That is because FCE  does not export into XML format !!!
    Does anyone knows how to have FCE to generate a XML file? Or to have the FCP file format converted into a XML file format?
    Thanks

    If you are editing in FCE4, then you can open your FCE Project in FCP6 or FCP7 and do the .xml export there. Once you have that .xml file, you need to use the software 7toX to convert the file to FCP-X.
    http://assistedediting.intelligentassistance.com/7toX/
    It should be noted that the conversion of a sequence file to .xml and then .xml to FCP-X may not pass 100% of the information.
    There is information about what is and is not translated here:
    http://assistedediting.intelligentassistance.com/7toX/about.html
    MtD

  • How to get XML format output from Hyperion Financial Reporting

    Dears,
    We are using Hyperion Financial Reporting to replace FSG in fusion. I found that Hyperion FR report can be exported to html/excel/pdf format. However, I would like the report to export to xml format.It means I only need the xml data source.
    Anyone who knows how to get the xml format output from Hyperion FR, is there any avaiable API?

    I think if you export the report, you will be able to open the .des file in Notepad/Wordpad and see xml content.

  • I am not able to convert a pdf file to a xml format using adobe reader 11. please tell me how to do the same!!!

    I have to upload a form in xml format. The file is in pdf format. I am using adobe reader 11. Please tell me how to export to xml format. There is no option for xml.

    Please give us a link to the instructions you are trying to follow.

  • Form Data Order in XML

    How can you organize form data exported via XML Email Submit button? I would expect this data to follow the order within the XDP object heirarcy, however the results jump from object to object on different pages. Forget about mapping this to a database...in this case I just want the raw data to be merged via Acrobat and into a .CSV
    Is there something I'm missing? Would I need an XML Schema...thats seems like overkill. By the way I created this on Designer 11 but have tried it in Design 8.2 as well. I would expect this to function just like this feature did with AcroForms.

    Figured it out. You veterans will probably laugh, but I don't do a lot of this. I found a pallette called "Binding" and noticed a list of the fields there. Two were missing and they happened to be the ones that were out of order. I compared them to the ones that were there and the missing ones were marked global while the others were marked normal. I changed those two to normal, they showed up in the binding pallatte in the right order and my test worked just fine.
    As usual, thanks to all.

  • How can I generate Payment Instruction Register in XML format?

    Hi,
    I am going to customize the report "Payment Instruction Register". First of all, I have to get its data result in XML format. does anyone know how can to do that? Thanks a lot.
    24Billy

    Hi
    Select report and click on view select output format as DATA you will get dta in xml format.If data is not there in drop down list,go to layout by clicking on edit report then select u r template check the output format as DATA also.

  • Apply conditional formatting when a report is exported to CSV format

    Hello
    OBIEE dasboard has the option to export the report data to CSV format.
    But the problem is that on some columns of the report, it uses various different types of conditional formatting that tells, what to display when data is equal to one of those edge cases. So hence the report on the dashboard page shows accordingly which is fine.
    But when the report is exported to CSV format, no conditional formatting is applied and all the raw data is shown without any formatting.
    Is there any way to make sure that the conditional formatting is applied even in the data exported to CSV format.
    thanks

    CSV is supposed to be a data dump .. i dont think you can have formatting saved when u download csv file.. try downloading it to excel and changing it to CSV

  • How to get data out of XML?

    Hi,All.
    I am running SAX (JAXP1.01) in Applet to process XML file. My question is how to get data out of xml format according to the field name (@age,@rank etc)
    and write into string buffer seperated by comma.
    Should I use SAX or DOM? (file size is big)
    My xml as follow :
    <ROOT>
    <FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@team/relay}">
         <ObjectName>Field124</ObjectName>
         <FormattedValue>HUNTER</FormattedValue>
         <Value>HUNTER</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@age}">
         <ObjectName>Field125</ObjectName>
         <FormattedValue> 19</FormattedValue>
         <Value> 19</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@Rank}">
         <ObjectName>Field126</ObjectName>
         <FormattedValue>43</FormattedValue>
         <Value>43</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{results.athrel_name}">
         <ObjectName>Field127</ObjectName>
         <FormattedValue>1-1 NORRIE</FormattedValue>
         <Value>1-1 NORRIE</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@timefield2}">
         <ObjectName>Field128</ObjectName>
         <FormattedValue>1:54.75</FormattedValue>
         <Value>1:54.75</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@timefield1course}">
         <ObjectName>Field129</ObjectName>
         <FormattedValue/>
         <Value/>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@timefield1std}">
         <ObjectName>Field130</ObjectName>
         <FormattedValue/>
         <Value/>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@timefield2course}">
         <ObjectName>Field131</ObjectName>
         <FormattedValue/>
         <Value/>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@timefield2std}">
         <ObjectName>Field132</ObjectName>
         <FormattedValue>QT</FormattedValue>
         <Value>QT</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@points(left)}">
         <ObjectName>Field133</ObjectName>
         <FormattedValue/>
         <Value/>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@pointsdecimal}">
         <ObjectName>Field134</ObjectName>
         <FormattedValue/>
         <Value/>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:decimal" FieldName="{@points(right)}">
         <ObjectName>Field135</ObjectName>
         <FormattedValue>0</FormattedValue>
         <Value>0.00</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@timefield1}">
         <ObjectName>Field136</ObjectName>
         <FormattedValue>1:55.98</FormattedValue>
         <Value>1:55.98</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@Rank}">
         <ObjectName>Field137</ObjectName>
         <FormattedValue>43</FormattedValue>
         <Value>43</Value>
    </FormattedReportObject>
    Repeat...
    </FormattedReportObject>
    </ROOT>
    ------------------------------------------------

    For big files use SAX: quicker and less memory usage.
    The xerces parser from Apache has some examples. Basically what you do is scan the XML, remembering what tag you are and once you find the right tag, read the contents.

  • Extracting SOE details in XML format

    Do we have any seeded concurrent program through which we can extract the SOE details(how we get in Payslip) in XML format for US legislation in R12 ?
    I searched in metalink and saw few clients have placed enhancement request to this. Is it available in R12 or is it yet to come ?

    Hi Robb,
    I'm afraid for data you will be limited to either custom code or potentially ODI in conjunction with the XML driver. A little review of the XML driver doesn't make it obvious that it would support writing the data to an XML format -- it does seem to support writing schema setup to XML.
    If you write custom code you may want to look at Apache Xerces at: http://xerces.apache.org/
    Anyone else?
    Regards,
    John A. Booth
    http://www.metavero.com

Maybe you are looking for

  • Using in Japan

    Hi, I am going to Japan and staying with my family for a while. I am taking my powerbook G4 17in. Electricity over there is 100 V and here in the US is 120 V, so I bought a World Travel Adapter Kit, but the North America and Japanese plugs are the sa

  • Sony DCR-HC62 camcorder won't connect to iMovie with express card adapter

    I got a Sony HC62 Mini DV video camera but it will not connect to iMovie. Since I don't have a firewire 6 pin on my Mac (only a 9 pin) i got an express card adapter. So I am using 4 pin (camera) to 6 pin (Express card) firewire. I have no other devic

  • Searching forms in Numbers for iPad

    I want to use the iPad for wine inventory, but paging through 200+ forms kind of defeats the purpose. Am I missing something? Thanks for any thoughts on this?

  • I want to remove windows explorer 7 and the Yahoo toolbar, if this cannot be done I will find another browser!

    I think this is pretty basic. Your browser has always been user friendly and allowed a high level of personalization. I don't like Yahoo toolbar thinking for me. I don't like the intrusive windows explorer 7. I am disturbed that you choose to base yo

  • Solaris 10 will not boot from DVD on my system

    I first installed Solaris 10 on my system and it worked fine. Then when it went to boot the OS it just kept rebooting. I must have made a midtake in the install so went to install it again. Problem is that now the DVD will not boot and give me the op