Skip to Content
0
Former Member
Nov 25, 2010 at 06:51 PM

Download created XML File in batch mode // Parse XML file into single lines

688 Views

Hello!

I upload a CSV file and based on that CSV file I create an XML "object". First I uploaded and downloaded it via gui frontendclass, but as it has to be run in a batch in the night I need to upload and download the data via OPEN DATASET.

The import and transformation of the CSV file works fine, also the transfer into an itab with the same structure as a CSV line is ok. I also create the XML file, which could be downloaded easily with gui-download but it is not permittet.

Import of data: I scan the folder and get the filenames into a itab, I loop over that itab and read the single files like this:

     OPEN DATASET ls_convert_batch FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      CLEAR tab.
      IF sy-subrc = 0.
        DO.
          READ DATASET ls_convert_batch INTO line.
          IF sy-subrc <> 0.
            EXIT.
          ELSE.
            CLEAR tmptab.
            SPLIT line AT ';' INTO  tmptab-product
                                    tmptab-contract
                                    ......
                                    tmptab-extagent.
            APPEND tmptab TO tab.
          ENDIF.
        ENDDO.
      ENDIF.

The XML file has a strucutre like

<file>
- <file formant_no="1.1" format_date="02.10.2003">
  <status>V</status> 
  <number>001001025</numbner> 
  <name>Schmeisser,Christof</name> 
- <details>
-    <detail>
         <contract>00000003494</contract> 
         <name>Schmeisser, Christof</name> 
         <invoice_no>000000003840</invoice_no> 
         <due_date>20100601</due_date> 
         <amount>140,00</amount> 
     </detail>
-    <detail>
         <contract>00000003495</contract> 
         <name>Schmeisser, Christof</name> 
         <invoice_no>000000003841</invoice_no> 
         <due_date>20100601</due_date> 
         <amount>130,00</amount> 
     </detail>
- </details>
 <elements>2</elements> 
 <amount_overall>270</amount_overall> 
</file>

At the moment I download it like this:

CALL METHOD cl_gui_frontend_services=>gui_download
        EXPORTING
          bin_filesize = l_xml_size
          filename     = filename
          filetype     = 'BIN'
*        CONFIRM_OVERWRITE = '0'
        CHANGING
          data_tab     = l_xml_table
        EXCEPTIONS
          OTHERS       = 24.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSEIF sy-subrc = 0.
        lv_create_counter = lv_create_counter + 1.
      ENDIF.

But I need to download it via OPEN TRANSFER CLOSE Dataset as it has to run in batch mode.

Anyone has an idea? I am really desperate here. One idea would be to parse the single lines into a string and then create the XML file line by line as text and save it with ending XML, should work. But I don't know how!

Thank you very much in advance,

kind regards from Tallinn, Estonia,

Christof!

Edited by: Christof Schmeisser on Nov 25, 2010 7:51 PM

I edited the heading, would be too general and missleading!