Writing from internal table to xml format

Hi,
I searched all the forum and I have a question on writing the data from internal table in xml format to the file on app.server.
Data: ITAB1   TYPE TABLE OF SPFLI,
         L_XML  TYPE REF TO CL_XML_DOCUMENT.
  SELECT * FROM SPFLI INTO TABLE ITAB1.
CREATE THE XML OBJECT
  CREATE OBJECT L_XML.
CONVERT THE DATA TO XML
  CALL METHOD L_XML->CREATE_WITH_DATA( DATAOBJECT = ITAB1[] ).
after this how to move the XML data in the object to a file on app.server.
Thanks

p_ufile is the path of the application server
p_output is the internal table with data to be moved to app serv.
OPEN DATASET p_ufile FOR OUTPUT IN TEXT MODE.
LOOP AT p_output INTO wa_file.
TRANSFER wa_file TO p_ufile.
CLEAR wa_file.
ENDLOOP.
CLOSE DATASET p_ufile.
for XML I guees the path p_ufile ill be <b>sap/usr/tmp/file.xml</b>

Similar Messages

  • Error while downloading data from internal table into XML file

    hi all,
    i developed a program to download data from into internal table to xml file like this.
    tables: mara.
    parameters: p_matnr like mara-matnr.
    data: begin of itab_mara occurs 0,
                matnr like mara-matnr,
                ernam like mara-ernam,
                aenam like mara-aenam,
                vpsta like mara-vpsta,
          end of itab_mara.
    data: lv_field_seperator type c,     " value 'X',
          lv_xml_doc_name(30) type c,    " string value ‘my xml file’,
          lv_result type i.
          lv_field_seperator = 'x'.
          lv_xml_doc_name = 'my xml file'.
    types: begin of truxs_xml_line,
              data(256) type x,
          end of truxs_xml_line.
    types:truxs_xml_table type table of truxs_xml_line.
    data:lv_tab_converted_data type truxs_xml_line,
         lt_tab_converted_data type truxs_xml_table.
    data: lv_xml_file type rlgrap-filename value 'c:\simp.xml'.
    select matnr ernam aenam vpsta from mara into table itab_mara up to 5
           rows where matnr = p_matnr.
    CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
    EXPORTING
       I_FIELD_SEPERATOR          = lv_field_seperator
      I_LINE_HEADER              =
      I_FILENAME                 =
      I_APPL_KEEP                = ' '
       I_XML_DOC_NAME             = lv_xml_doc_name
    IMPORTING
       PE_BIN_FILESIZE            = lv_result
      TABLES
        I_TAB_SAP_DATA             = itab_mara
    CHANGING
       I_TAB_CONVERTED_DATA       = lt_tab_converted_data
    EXCEPTIONS
      CONVERSION_FAILED          = 1
      OTHERS                     = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    open dataset lv_xml_file for output in binary mode.
    loop at lt_tab_converted_data into lv_tab_converted_data.
    transfer lv_tab_converted_data to lv_xml_file.
    endloop.
    close dataset lv_xml_file.
    this program is syntactically correct and getting executed, but when i open the target xml file it is showing the following error.
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    XML document must have a top level element. Error processing resource 'file:///C:/simp.xml'.
    will anyone show me the possible solution to rectify this error
    thanks and regards,
    anil.

    Hi,
    Here is a small sample program to convert data in an internal table into XML format and display it.
    DATA: itab  TYPE TABLE OF spfli,
          l_xml TYPE REF TO cl_xml_document.
    * Read data into a ITAB
    SELECT * FROM spfli INTO TABLE itab.
    * Create the XML Object
    CREATE OBJECT l_xml.
    * Convert data in ITAB to XML
    CALL METHOD l_xml->create_with_data( name = 'Test1'
                                         dataobject = t_goal[] ).
    * Display XML Document
    CALL METHOD l_xml->display.
    Here are some other sample SAP programs to handle XML in ABAP:
    BCCIIXMLT1, BCCIIXMLT2, and BCCIIXMLT3.
    Hope this helps,
    Sumant.

  • Convert data from internal table to XML file.

    Hi All,
    I am selecting data from database into one internal table.
    Now I want to convert data from internal table to xml file format and save in to my desktop. Please suggest me how I can achieve my requirement.
    Kindly reply me ASAP.

    Use this FM. SAP_CONVERT_TO_XML_FORMAT
    Check this link too -
    Re: Data Export in XML format
    XML files from ABAP programs

  • Download internal table in XML format

    Hi experts,
    I want to download an internal table into an XML format.
    How can I achieve this?
    I have used the GUI_DOWNLOAD earlier for XLS purpose, will that work in this case too?
    Thanks,
    Ajay.

    Hi Ajay,
      You can use the below format
    DATA : gs_xml TYPE lvc_t_fccl.
    (Fill lt_Table here)
        TRY.
            CALL TRANSFORMATION id SOURCE root = lt_Table
                 RESULT XML gs_xml.
          CATCH cx_st_error.
    ENDTRY.
    Then Call GUI_DOWNLOAD, passing gs_XML as data_tab and filetype = BIN
    Note : GUI_DOWNLOAD will not work in background.
    Hope this solves your problem
    Regards,
    Seema

  • Converting internal table to XML format using XCBL schema.

    Hi Guys,
    I am trying to convert my internal table content to XML format. This is fine. But we need to use XCBL schema/elements within the converted XML format. How to achieve this.
    Thanks,

    Hello Laxman,
    Use SAP_CONVERT_TO_XML_FORMAT function module.
    Thanks
    Venkat.O

  • Using abap code data from internal table to XML file create

    Hi ALL,
    i am using methods
      L_VALUE = GS_DOCUMENT-U_MITARBEITER.
      L_RC = L_ELEMENT_FLIGHTS->SET_ATTRIBUTE( NAME = 'U_Mitarbeiter' VALUE = L_VALUE ).
      CLEAR: L_VALUE,
             L_RC.
      L_VALUE = GS_DOCUMENT-VORNAME .
      L_RC = L_ELEMENT_FLIGHTS->SET_ATTRIBUTE( NAME = 'Vorname' VALUE = L_VALUE ).
         ENDLOOP.
      LOOP AT GS_DOCUMENT-GI_TIMETABLE INTO GS_TIMETABLE.
        L_ELEMENT_AIRLINE  = L_DOCUMENT->CREATE_SIMPLE_ELEMENT(
            NAME = 'Timetable'
            PARENT = L_ELEMENT_FLIGHTS  ).
          Create attribute 'code' of node 'airline'
        L_VALUE = GS_TIMETABLE-BEGINNUHRZEIT.
        L_RC = L_ELEMENT_AIRLINE->SET_ATTRIBUTE( NAME = 'Beginnuhrzeit' VALUE = L_VALUE ).
        L_VALUE = GS_TIMETABLE-BEMERKUNGEN.
        L_RC = L_ELEMENT_AIRLINE->SET_ATTRIBUTE( NAME = 'Bemerkungen' VALUE = L_VALUE ).
        L_VALUE = GS_TIMETABLE-ENDEUHRZEIT  .
        L_RC = L_ELEMENT_AIRLINE->SET_ATTRIBUTE( NAME = 'Endeuhrzeit' VALUE = L_VALUE ).
        L_VALUE = GS_TIMETABLE-BUCHUNGSDATUM.
        L_RC = L_ELEMENT_AIRLINE->SET_ATTRIBUTE( NAME = 'Buchungsdatum' VALUE = L_VALUE ).
      ENDLOOP.
      Creating a stream factory
      L_STREAMFACTORY = L_IXML->CREATE_STREAM_FACTORY( ).
      Connect internal XML table to stream factory
      L_OSTREAM = L_STREAMFACTORY->CREATE_OSTREAM_ITABLE( TABLE = L_XML_TABLE ).
      Rendering the document
      L_RENDERER = L_IXML->CREATE_RENDERER( OSTREAM  = L_OSTREAM
                                            DOCUMENT = L_DOCUMENT ).
      L_RC = L_RENDERER->RENDER( ).
      Saving the XML document
      L_XML_SIZE = L_OSTREAM->GET_NUM_WRITTEN_RAW( ).
    i am geting the output,
    line1
    <?xml version="1.0"?><Head Document="002_TMA1_KW1_SAP.XML" Innenauftragsnummer="008004000800" Kalenderwoche="17" MonatJahr="04/2008" Name="" Personalnummer="91003139" Projektnummer="1400000700" Regionalstelle="B" U_Entleiher="1" U_Mitarbeiter="1" Vorname=
    line 2
    Ricky"><Timetable Beginnuhrzeit="08:00" Bemerkungen="" Endeuhrzeit="16:30" Buchungsdatum="21.04.2008"/><Timetable Beginnuhrzeit="08:00" Bemerkungen="" Endeuhrzeit="16:30" Buchungsdatum="22.04.2008"/><Timetable Beginnuhrzeit="08:00" Bemerkungen="" Endeuhrz
    line 3
    it="16:30" Buchungsdatum="23.04.2008"/><Timetable Beginnuhrzeit="08:00" Bemerkungen="" Endeuhrzeit="16:30" Buchungsdatum="24.04.2008"/><Timetable Beginnuhrzeit="08:00" Bemerkungen="" Endeuhrzeit="16:30" Buchungsdatum="25.04.2008"/></Head>
    but i want this type line by line
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <Document Dokumentnummer="001_TMA7_KW2_MAN" Dokumenttyp="TN_HE" Innenauftragsnummer="8004750104" Kalenderwoche="15" MonatJahr="04/2008" Name="Banana" Personalnummer="166326" Projektnummer="1400000203" Regionalstelle="RV1" U_Entleiher="1" U_Mitarbeiter="1" Vorname="Sepp">
    <TimeTable Beginnuhrzeit="08:00" Bemerkungen="" Buchungsdatum="07.04.2008" Endeuhrzeit="16:00"/>
    <TimeTable Beginnuhrzeit="08:00" Bemerkungen="" Buchungsdatum="08.04.2008" Endeuhrzeit="16:00"/>
    <TimeTable Beginnuhrzeit="08:00" Bemerkungen="" Buchungsdatum="09.04.2008" Endeuhrzeit="16:30"/>
    <TimeTable Beginnuhrzeit="08:00" Bemerkungen="" Buchungsdatum="10.04.2008" Endeuhrzeit="16:30"/>
    <TimeTable Beginnuhrzeit="08:00" Bemerkungen="" Buchungsdatum="11.04.2008" Endeuhrzeit=""/>
    </Document>
    for line breaking, please give me solution
    Regards,
    Santha

    Hi,
    Please give me more inforamtion, how to use this
    CLASS cl_abap_char_utilities DEFINITION LOAD.
    cl_abap_char_utilities=>newline
    Regards,
    Santha

  • Create XML file from internal table and vise a versa

    Hi Friends,
    I have requirement to create an XML string from internal table data and also read XML string data to internal table.
    Can anybody tell are there any Function Modules or methods existing for this?
    Thanks.
    Krishna Yerram.

    1. Write XSLT program. T.code XSLT . e.g. XSLT name "ZTRANS".
    2. Write ABAP program
    Which includes declaration of internal tables
    that you need "IT_DATA".
    Upload XML data to an internal table "IT_XML "
    use below statement to convert XML to internal table.
    Call transformation ZTRANS
    source XML IT_XML
    result IT_DATA.

  • Format data in the flat file while downloading from internal table

    Just I used 'GUI_DOWNLOAD' with WRITE_FIELD_SEPARATOR = 'X'. In my case one of the field contains large quantity. Bcoz of this value , it pushes the remaining filed position values in that particular row. The fields in the internal table refers the stadard data elements.I need the field values should be under corresponding field names.Can anyone help me?

    Hi,
    declare another internal table in the format in which you want to download .
    say itab_text.
    itab is your orginal internal table .
    than loop at itab.
    MOVE-CORRESPONDING Itab TO Itab_text.
    APPEND ITab_text.
    endloop.
    now pass the itab_text to gui_download.
    Thanks

  • How can we transfer huge amount of data from database server to xml format

    hi guru
    how can we transfer huge amount of data from database server to xml format.
    regards
    subhasis.

    Create ABAP coding
    At first we create the internal table TYPES and DATA definition, we want to fill with the XML data. I have declared the table "it_airplus" like the structure from XML file definition for a better overview, because it is a long XML Definition (see the XSD file in the sample ZIP container by airplus.com)
    *the declaration
    TYPES: BEGIN OF t_sum_vat_sum,
              a_rate(5),
              net_value(15),
              vat_value(15),
             END OF t_sum_vat_sum.
    TYPES: BEGIN OF t_sum_total_sale,
            a_currency(3),
            net_total(15),
            vat_total(15),
            vat_sum TYPE REF TO t_sum_vat_sum,
           END OF t_sum_total_sale.
    TYPES: BEGIN OF t_sum_total_bill,
            net_total(15),
            vat_total(15),
            vat_sum TYPE t_sum_vat_sum,
            add_ins_val(15),
            total_bill_amount(15),
           END OF t_sum_total_bill.TYPES: BEGIN OF t_ap_summary,
            a_num_inv_det(5),
            total_sale_values TYPE t_sum_total_sale,
            total_bill_values TYPE t_sum_total_bill,
           END OF t_ap_summary.TYPES: BEGIN OF t_ap,
            head    TYPE t_ap_head,
            details TYPE t_ap_details,
            summary TYPE t_ap_summary,
           END OF t_ap.DATA: it_airplus TYPE STANDARD TABLE OF t_ap
    *call the transformation
    CALL TRANSFORMATION ZFI_AIRPLUS
         SOURCE xml l_xml_x1
         RESULT xml_output = it_airplus
         .see the complete report: Read data from XML file via XSLT program
    Create XSLT program
    There are two options to create a XSLT program:
    Tcode: SE80 -> create/choose packet -> right click on it | Create -> Others -> XSL Transformation
    Tcode: XSLT_TOOL
    For a quick overview you can watch at the SXSLTDEMO* programs.
    In this example we already use the three XSLT options explained later.
    As you can see we define a XSL and ASX (ABAP) tags to handle the ABAP and XML variables/tags. After "

  • To get recent timestamp records from internal table

    hi all,
      i have one requirment
      i'm storing error messages in one table  while creating a sales order basing on timestamp
      which is of this format yyyy-mm-dd hh:mm:ss (random Number) 
      if i want to see the error messages left i'm getting all the error messages displayed
      for example i have created a sales order
    i got 10 errors displayed
    i have rectified 5 errors ... if i again display error messages the 10 errors + the 5 errors is getting displayed
    i want to display the 5 error messages only not the previous messages from internal table
    basing on timestamp current one has to displayed remaining has to deleted from internal table.

    I thought we used Sales Order Incompletion process for this....  but, if you're recreating the errors list every time you save with a create or change transaction then, at save, delete all rows in your error table for this document.   Then get your errors and update your db table from your current errors table.   From this viewpoint, the timestamp is not relevant.

  • Download Internal Table in CSV format it gets downloaded in single column

    Hi All
    I am converting Internal Table in CSV format using the FM CONVERT TO CSV FORMAT and then downloading data using GUI_DOWNLOAD FM.
    I have given separator as ','.
    However when I download the data the file is opened in Excel and first 2 to 3 column are merged in to single column and there was separator shown ';'.
    How to overcome this problem.
    Amol

    hI..,
    Check this code..
    <b>
    It first downloads the data in internal table to a CSV format file..
    and then uploads the same data into another internal table and prints it..</b>
    analyze this and use accordingly..
    tables:
      spfli.
    field-symbols : <fs>, <fs1>.
    data:
      w_line(1000),
      w_field(20) type c,
      wa_spfli type spfli.
    data:
      begin of fs_spfli,
        carrid    type spfli-carrid,
        connid    type spfli-connid,
        countryfr type spfli-countryfr,
        countryto type spfli-countryto,
        fltime    type spfli-fltime,
      end of fs_spfli.
    data :
      t_file like standard table
               of w_line
          initial size 0.
    data:
      t_spfli like
    standard table
           of fs_spfli
      initial size 0.
    data:
      t_spfli_up like
        standard table
              of fs_spfli
         initial size 0.
    select carrid
           connid
           countryfr
           countryto
           fltime
      into corresponding fields of table t_spfli
      from spfli.
    loop at t_spfli into fs_spfli.
      do.
        assign component sy-index of structure fs_spfli to <fs>.
        if sy-subrc ne 0.
          exit.
        endif.
        w_field = <fs>.
        condense w_field no-gaps.
        if sy-index eq 1.
          w_line = w_field.
        else.
          concatenate w_line ',' w_field into w_line.
        endif.
      enddo.
      append w_line to t_file.
    endloop.
    call function 'GUI_DOWNLOAD'
      exporting
         BIN_FILESIZE                    =
           filename                        = 'D:\file.txt'
           filetype                        = 'ASC'
         APPEND                          = ' '
         write_field_separator           = ' '
         header                          = '00'
         TRUNC_TRAILING_BLANKS           = ' '
         WRITE_LF                        = 'X'
         COL_SELECT                      = ' '
         COL_SELECT_MASK                 = ' '
         DAT_MODE                        = ' '
         CONFIRM_OVERWRITE               = ' '
         NO_AUTH_CHECK                   = ' '
         CODEPAGE                        = ' '
         IGNORE_CERR                     = ABAP_TRUE
         REPLACEMENT                     = '#'
         WRITE_BOM                       = ' '
         TRUNC_TRAILING_BLANKS_EOL       = 'X'
         WK1_N_FORMAT                    = ' '
         WK1_N_SIZE                      = ' '
         WK1_T_FORMAT                    = ' '
         WK1_T_SIZE                      = ' '
       IMPORTING
         FILELENGTH                      =
      tables
        data_tab                           = t_FILE
         FIELDNAMES                      =
    exceptions
       file_write_error                = 1
       no_batch                        = 2
       gui_refuse_filetransfer         = 3
       invalid_type                    = 4
       no_authority                    = 5
       unknown_error                   = 6
       header_not_allowed              = 7
       separator_not_allowed           = 8
       filesize_not_allowed            = 9
       header_too_long                 = 10
       dp_error_create                 = 11
       dp_error_send                   = 12
       dp_error_write                  = 13
       unknown_dp_error                = 14
       access_denied                   = 15
       dp_out_of_memory                = 16
       disk_full                       = 17
       dp_timeout                      = 18
       file_not_found                  = 19
       dataprovider_exception          = 20
       control_flush_error             = 21
       others                          = 22.
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    clear t_FILE.
    call function 'GUI_UPLOAD'
      exporting
        filename                      = 'D:\file.txt'
       FILETYPE                       = 'ASC'
      HAS_FIELD_SEPARATOR            = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      tables
        data_tab                      = t_FILE
    EXCEPTIONS
       FILE_OPEN_ERROR               = 1
       FILE_READ_ERROR               = 2
       NO_BATCH                      = 3
       GUI_REFUSE_FILETRANSFER       = 4
       INVALID_TYPE                  = 5
       NO_AUTHORITY                  = 6
       UNKNOWN_ERROR                 = 7
       BAD_DATA_FORMAT               = 8
       HEADER_NOT_ALLOWED            = 9
       SEPARATOR_NOT_ALLOWED         = 10
       HEADER_TOO_LONG               = 11
       UNKNOWN_DP_ERROR              = 12
       ACCESS_DENIED                 = 13
       DP_OUT_OF_MEMORY              = 14
       DISK_FULL                     = 15
       DP_TIMEOUT                    = 16
       OTHERS                        = 17
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    clear fs_spfli.
    *constants :
    *C_HTAB value CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    loop at t_file into w_line.
      do.
        if w_line eq space.
          exit.
        endif.
        split w_line at ',' into w_field w_line.
        condense w_field no-gaps.
        assign component sy-index of structure fs_spfli to <fs>.
        <fs> = w_field.
      enddo.
      append fs_spfli to t_spfli_up.
    endloop.
    loop at t_spfli_up into fs_spfli.
      do.
        assign component sy-index of structure fs_spfli to <fs>.
        if sy-subrc ne 0.
          exit.
        endif.
        write <fs>.
      enddo.
      skip.
    endloop.
    reward if it helps u..
    sai ramesh

  • Import from internal table

    Dear Experts,
    I need a solution for importing from an internal table.
    Two variables I_EXP01 and I_EXP02 containing an xml stream have been exported to the database using the following syntax
    and depending on the size of I_EXP01 and I_EXP02 two or more entries are created in table LTEX.
    EXPORT
             L_SAPRL
             I_EXP01
             I_EXP02
    TO    DATABASE LTEX(LT)
                           ID LS_LTEXKEY.
    But now i have a few entries of table LTEX in an internal table and they need to be imported from the internal table.
    What would be the syntax to import from internal table so that after importing I can de-serialise the data from XML to ABAP.
    Thanks & Regards,
    Ashwini

    Try this and let me know if it works:
    IMPORT
    L_SAPRL
    I_EXP01
    I_EXP02
    To
    L_SAPRL1 (same type as above)
    I_EXP011 (same type as above)
    I_EXP021 (same type as above)
    FROM DATABASE LTEX(LT)
    ID LS_LTEXKEY.
    if it is not working. try using seperate statements for each internal table and see.
    Thanks,
    Venkatesh.
    Edited by: venkatesh333 on Jul 27, 2011 6:23 AM

  • Downloding from internal table to excel

    Hi All,
    I am using ole concept to download data from internal table to excel because i want to fill few records with colors and few with bold etc.
    But this ole concept is downloading to excel line by line and taking much time.
    How can i improve the performance in this concept or is there any other concept please let me know.
    i am using fallowng logic to download to excel.
    *Generating the Excel report in the foreground
    data: h_excel type ole2_object, " Excel object
    h_mapl type ole2_object, " list of workbooks
    h_map type ole2_object, " workbook
    start Excel
    create object h_excel 'EXCEL.APPLICATION'.
    set property of h_excel 'Visible' = 1.
    get list of workbooks, initially empty
    call method of h_excel 'Workbooks' = h_mapl.
    perform err_hdl.
    add a new workbook
    call method of h_mapl 'Add' = h_map.
    perform err_hdl.
    output column headings to active Excel sheet
    perform fill_cell using 1 1 1 000 'Job Name'(001).
    perform fill_cell using 1 2 1 000 'Variant'(002).
    perform fill_cell using 1 3 1 000 'Description'(003).
    perform fill_cell using 1 4 1 000 'Run Date'(004).
    perform fill_cell using 1 5 1 000 'Run Time'(005).
    perform fill_cell using 1 6 1 000 'Duration'(006).
    perform fill_cell using 1 7 1 000 'Spool'(007).
    perform fill_cell using 1 8 1 000 'Records Upl'(008).
    perform fill_cell using 1 9 1 000 'Error'(009).
    perform fill_cell using 1 10 1 000 'Total'(010).
    perform fill_cell using 1 11 1 000 'Action'(011).
    perform fill_cell using 1 12 1 000 'ReRun'(012).
    loop at t_final.
    copy datato active EXCEL sheet
    h = sy-tabix + 1.
    perform fill_cell using h 1 0 000 t_final-jobname.
    perform fill_cell using h 2 0 000 t_final-variant.
    perform fill_cell using h 3 0 000 t_final-description.
    perform fill_cell using h 4 0 000 t_final-strtdate.
    perform fill_cell using h 5 0 000 t_final-strttime.
    perform fill_cell using h 6 0 000 t_final-duration.
    perform fill_cell using h 7 0 000 t_final-listident.
    perform fill_cell using h 8 0 000 t_final-rec_upl.
    perform fill_cell using h 9 0 000 t_final-rec_err.
    perform fill_cell using h 10 0 000 t_final-rec_tot.
    if t_final-comment eq 'job did not run'.
    perform fill_cell using h 11 0 200 t_final-comment.
    elseif t_final-rec_err eq 0.
    perform fill_cell using h 11 0 000 t_final-comment.
    else.
    perform fill_cell using h 11 0 200 t_final-comment.
    endif.
    perform fill_cell using h 12 0 000 t_final-rerun.
    endloop.
    CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
    call method of h_excel 'Worksheets' = h_mapl." EXPORTIN G #1 = 2.
    perform err_hdl.
    add a new workbook
    call method of h_mapl 'Add' = h_map exporting #1 = 2.
    perform err_hdl.
    tell user what is going on
    set property of h_map 'NAME' = 'COPY'.
    loop at t_final.
    copy flights to active EXCEL sheet
    h = sy-tabix + 1.
    perform fill_cell using h 1 0 000 t_final-jobname.
    perform fill_cell using h 2 0 000 t_final-variant.
    perform fill_cell using h 3 0 000 t_final-description.
    perform fill_cell using h 4 0 000 t_final-strtdate.
    perform fill_cell using h 5 0 000 t_final-strttime.
    perform fill_cell using h 6 0 000 t_final-duration.
    perform fill_cell using h 7 0 000 t_final-listident.
    perform fill_cell using h 8 0 000 t_final-rec_upl.
    perform fill_cell using h 9 0 000 t_final-rec_err.
    perform fill_cell using h 10 0 000 t_final-rec_tot.
    if t_final-comment eq 'job did not run'.
    perform fill_cell using h 11 0 200 t_final-comment.
    elseif t_final-rec_err eq 0.
    perform fill_cell using h 11 0 000 t_final-comment.
    else.
    perform fill_cell using h 11 0 200 t_final-comment.
    endif.
    perform fill_cell using h 12 0 000 t_final-rerun.
    endloop.
    free object h_excel.
    perform err_hdl.
    *& Form ERR_HDL
    outputs OLE error if any *
    form err_hdl.
    if sy-subrc <> 0.
    write: / 'Batch Job Automation Carried Out Succesfully'.
    stop.
    endif.
    endform. " ERR_HDL .
    FORM FILL_CELL *
    sets cell at coordinates i,j to value val boldtype bold *
    form fill_cell using i j bold col val.
    call method of h_excel 'Cells' = h_zl exporting #1 = i #2 = j.
    perform err_hdl.
    set property of h_zl 'Value' = val .
    perform err_hdl.
    get property of h_zl 'Font' = h_f.
    perform err_hdl.
    set property of h_f 'Bold' = bold .
    perform err_hdl.
    set property of h_f 'Color' = col.
    perform err_hdl.
    endform. "FILL_CELL

    Hi,
    You are populating the Cells one by one from the internal table, and all of them are coloured and font is bold. the method is OK, but when the amount of data is huge - it is going to take a longer time. May be the performance will improve a little if you turn the visibility off.
    I ll suggest you to use ALV_XXL_CALL, it can color the key columns, at the same time you can have colored headings - and the performance is good. It is the same function module called when you do a "Export to Excel" from an ALV grid. But you can compain about the Font characteristics - as this does not change the Font size etc.
    Your code has got a lot of freedom as long as the formatting is concerned - for bigger data - i ll suggest you to use a WS_DOWNLOAD kind of a function module to get the data at once in the presentation server and then call Excel methods and do the formatting.

  • Export Internal Table to XML in Background

    Hi
    I need to export a internal table into xml file in background using open dataset. The file is getting created but i am not able to open the file using IE/XML editor . When i open the file uisng wordpad i can see some charcters at the end of file which prevents it from opening in xml editor. if i delete the characters(box like) and save the file. i am able to open the file
    When i downalod the same internal table via frontend using ws_downlod it works pefectly. no junk charcters are appended in the end. and hence files opens perfectly
    below is the extract of program
    START-OF-SELECTION.
       PERFORM get_data.
       PERFORM create_xml.
    FORM get_data.
       REFRESH accesos.
       CLEAR accesos.
       MOVE: '45050' TO accesos-socio-numero,
                     'MOISES MORENO' TO accesos-socio-nombre,
                     '0' TO accesos-socio-reposicion.
       APPEND accesos.
    ENDFORM.
    i am using the following function modules
    CALL FUNCTION 'SDIXML_DATA_TO_DOM'
            EXPORTING
                 name         = 'ACCESOS'
                 dataobject   = accesos[]
            IMPORTING
                 data_as_dom  = l_dom
    CHANGING
                 document     = m_document
            EXCEPTIONS
                 illegal_name = 1
                 OTHERS       = 2.
           CHECK NOT l_dom IS INITIAL.
    w_rc = m_document->append_child( new_child = l_dom ).
    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.
    LOOP AT it_xml INTO xml_tab-d.
         APPEND xml_tab.
       ENDLOOP.
    The following syntax for open datset which does not work
      lv_physcial_file = '
    hdat03\test.xml'.
    OPEN DATASET lv_physcial_file IN BINARY MODE   FOR OUTPUT MESSAGE l_msg.
       LOOP AT xml_tab.
         TRANSFER xml_tab TO lv_physcial_file.
       ENDLOOP.
    The ws_download function works
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
                   BIN_FILESIZE = W_SIZE
                   FILENAME = GK_RUTA
                   FILETYPE = 'BIN'
    TABLES
                   DATA_TAB = XML_TAB
    EXCEPTIONS
                   OTHERS = 10.
    many thnaks

    Hi Chetan,
    Can you just try changing the syntax to the following, I not sure if that will help but just try and see.
    OPEN DATASET  lv_physcial_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    Regards
    Mohamed

  • Internal Table to XML

    Hallo Experts,
    I have retrived a Internal Table from FM.
    CALL FUNCTION 'SRTUTIL_CONVERT_XML_TO_TABLE'
        EXPORTING
          xdoc             = lv_xstring
    IMPORTING
    *   ERROR_TEXT       =
         data             = lt_xml
    I have manipulated the Tagnames in the Internal Table lt_xml.
    Now I want to change the internal table to xml.
    Is there any FM or a class. can anyone help me??
    Thanks
    Kind regards
    rana Waseem

    Hallo,
    Thanks for your Reply. I am trying to manipulate the xml attributes in print report. I have the data in xstring form. I have changed it to internal Table with following code.
    CALL FUNCTION 'SRTUTIL_CONVERT_XML_TO_TABLE'
        EXPORTING
          xdoc             = lv_xstring
    IMPORTING
    *   ERROR_TEXT       =
         data             = lt_xml
    After the change in the table lt_xml I am trying to have once again a xstring to give to the Print Report. I have tried it with class
    LOOP AT lt_xml INTO ls_xml.
        CALL METHOD cl_soap_xml_helper=>transform_to_xml
          EXPORTING
            tag_name          = ls_xml-tag_name
            data              = ls_xml-tag_value
            data_type         = ls_xml-tag_type
            ignore_init_value = 'X'
    *    ignore_exception  =
          CHANGING
            xml               = lv_xstring_two
    *  ENDLOOP.
    but when I try to check the XML become an error
    The XML cannot be showed, when Stylesheet XSL  is used Remove the error and try again.
    I cannot understand where is the error. Because the orignal xstring from system is shown correct. But when I create the new xstring give error .
    Thanks for your help
    kind regards
    waseem

Maybe you are looking for