Internal table to XML data in Application Server

Dear Experts,
I have converted the internal table data into XML format using CL_XML_DOCUMENT class and CREATE_WITH_DATA - method. Here I have to upload this XML converted file in the given application server path. Kindly suggest me some methods or class, other options to do this.
I need to upload the XML file in to specified application server path. Kindly give some ideas.
Regards,
Sakthi

I guess you want to transfer XML document type ref to IF_IXML_DOCUMENT (which is instantiated with this method and stored in attribute M_DOCUMENT ) to a file on application server. Is that right?
If so please refer below program you should get the idea
DATA: gr_ixml TYPE REF TO if_ixml,
      gr_ixml_doc TYPE REF TO if_ixml_document.
gr_ixml = cl_ixml=>create( ).
"here you have the same kind of XML document
"as the one created with method CREATE_WITH_DATA
gr_ixml_doc = gr_ixml->create_document( ). 
DATA  gr_ixml_element TYPE REF TO if_ixml_element.
CALL METHOD gr_ixml_doc->create_element
  EXPORTING
    name = 'JOBS'
  RECEIVING
    rval = gr_ixml_element.
CALL METHOD gr_ixml_doc->append_child
  EXPORTING
    new_child = gr_ixml_element.
CALL METHOD gr_ixml_element->set_attribute
  EXPORTING
    name  = 'OBJID'
    value = '566677890'.
"serialization
DATA g_encoding_type TYPE string.
DATA g_stream_factory TYPE REF TO if_ixml_stream_factory.
DATA gr_encoding TYPE REF TO if_ixml_encoding.
g_stream_factory = gr_ixml->create_stream_factory( ).
gr_encoding = gr_ixml->create_encoding( byte_order = 0
                                       character_set = 'UTF-8' ).
DATA b_xml TYPE xstring.
DATA gr_ostream TYPE REF TO if_ixml_ostream.
gr_ostream = g_stream_factory->create_ostream_xstring( b_xml ).
CALL METHOD gr_ostream->set_encoding
  EXPORTING
    encoding = gr_encoding.
CALL METHOD gr_ixml_doc->render
  EXPORTING
    ostream = gr_ostream
    recursive = 'X'.
DATA g_resize TYPE i.
g_resize = gr_ostream->get_num_written_raw( ).
data ex_tab type table of x255.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
  EXPORTING
    buffer                = b_xml
  tables
    binary_tab            = ex_tab.
"now open file on application server
OPEN DATASET dset FOR OUTPUT IN BINARY MODE.
"and transfer ex_tab to dset
Regards
Marcin

Similar Messages

  • XML data into Oracle Tables. XML file on Application Server.Oracle Apps R12

    Hi All,
    My Database version : 11.2.0.2.0
    I have an XML file which needs to be loaded into the Database Tables. How ever i do not want to use the XMLTYPE as given below
    insert into test1 (
    SELECT PrcDate, PmtType, PmtStatus, PmtTypeCount, PmtTypeAmt
    FROM XMLTABLE(
    '/WFPaymentAck/RejectedDom1ACH'
    PASSING XMLTYPE( BFILENAME('ECX_UTL_LOG_DIR_OBJ','wf_test_xml.XML'), NLS_CHARSET_ID('UTF8') )
    COLUMNS
    PrcDate VARCHAR2(2000) PATH '@PrcDate' ,
    PmtType VARCHAR2(2000) PATH '@PmtType' ,
    PmtStatus VARCHAR2(100) PATH '@PmtStatus' ,
    PmtTypeCount VARCHAR2(100) PATH 'PmtTypeCount' ,
    PmtTypeAmt VARCHAR2(100) PATH 'PmtTypeAmt'
    Because this way the XML file needs to reside on the DB server.
    I am looking into other option of loading the XML file into a CLOB column of a table and reading it from that column.
    I did a couple of tests and feel that this way also the XML file has to reside on the Database Server itself. I am not sure if this is correct or if there is any problem with our TEST instance.
    ++Can anyone let me know if i need to have the XML file on the DB server instead of the Application server to load into a CLOB column of table ??++
    ++Or++
    ++Is there any other workaround for me to load XML into Oracle Tables, while having the XML file on Application Server.++
    Your immediate help is appreciated. I need to get past this ASAP.
    Thanks in Advance.
    VJ

    1) Are you asking me to create a folder on Database directory which points to a folder on the Apps server ?I suggest creating an Oracle directory object (a database object) pointing to a real location (folder) on Application server.
    we DONOT want a hand shake between the DB Server and the APPS server.I don't see where the problem is.
    I'm not familiar with Apps R12 but there's no doubt the two servers are already communicating, at least App server should be able to access the DB for the whole thing to run.
    As I said :
    One way or another, the data has to make its way to the database, there's no workaround to that.How do you imagine the data will end up in a database table if it doesn't come to the DB server?
    There's no magical method out there, both servers have to communicate at some point.
    About client-server approaches (client being here the App server), you can read about accessing the XML DB repository in the XML DB Developer's Guide : http://download.oracle.com/docs/cd/E11882_01/appdev.112/e23094/toc.htm
    Other option : SQL*Loader can load a CLOB, or an XMLType column too
    Edited by: odie_63 on 19 déc. 2011 20:22

  • Download internal table to XSLX on SAP application server

    I was struggling with this feature for a longtime and finally found some solution and so thought of listing it:
    Here is what I did to download an internal table to xslx format (works for xls aso) :
    I found this excellent link that allowed me to download an XSLX file on to local directory and then I added a little more to download to app server.
    http://abapblog.com/articles/tricks/33-create-xlsx-mhtml-file-from-internal-table-in-background
    <
    Per this link. once the bin file is prepared, pass it to
      CALL FUNCTION 'HR_CA_DOWNLOAD_TO_APPSERVER'         EXPORTING           filename          = p_file           filesize          = g_size         IMPORTING           bytes_transfered  = len         TABLES           data_tab          = gt_bintab         EXCEPTIONS           invalid_filesize  = 1           no_authority      = 2           dataset_open_error = 3           OTHERS            = 4.
    This works for xslx as well as xls

    I guess you want to transfer XML document type ref to IF_IXML_DOCUMENT (which is instantiated with this method and stored in attribute M_DOCUMENT ) to a file on application server. Is that right?
    If so please refer below program you should get the idea
    DATA: gr_ixml TYPE REF TO if_ixml,
          gr_ixml_doc TYPE REF TO if_ixml_document.
    gr_ixml = cl_ixml=>create( ).
    "here you have the same kind of XML document
    "as the one created with method CREATE_WITH_DATA
    gr_ixml_doc = gr_ixml->create_document( ). 
    DATA  gr_ixml_element TYPE REF TO if_ixml_element.
    CALL METHOD gr_ixml_doc->create_element
      EXPORTING
        name = 'JOBS'
      RECEIVING
        rval = gr_ixml_element.
    CALL METHOD gr_ixml_doc->append_child
      EXPORTING
        new_child = gr_ixml_element.
    CALL METHOD gr_ixml_element->set_attribute
      EXPORTING
        name  = 'OBJID'
        value = '566677890'.
    "serialization
    DATA g_encoding_type TYPE string.
    DATA g_stream_factory TYPE REF TO if_ixml_stream_factory.
    DATA gr_encoding TYPE REF TO if_ixml_encoding.
    g_stream_factory = gr_ixml->create_stream_factory( ).
    gr_encoding = gr_ixml->create_encoding( byte_order = 0
                                           character_set = 'UTF-8' ).
    DATA b_xml TYPE xstring.
    DATA gr_ostream TYPE REF TO if_ixml_ostream.
    gr_ostream = g_stream_factory->create_ostream_xstring( b_xml ).
    CALL METHOD gr_ostream->set_encoding
      EXPORTING
        encoding = gr_encoding.
    CALL METHOD gr_ixml_doc->render
      EXPORTING
        ostream = gr_ostream
        recursive = 'X'.
    DATA g_resize TYPE i.
    g_resize = gr_ostream->get_num_written_raw( ).
    data ex_tab type table of x255.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        buffer                = b_xml
      tables
        binary_tab            = ex_tab.
    "now open file on application server
    OPEN DATASET dset FOR OUTPUT IN BINARY MODE.
    "and transfer ex_tab to dset
    Regards
    Marcin

  • Write internal table to a file on application server using OPEN DATASET

    I have logical file path and XLS file name. I want to write internal table to a XLS or CSV file on application sever. Please give example.

    Hi
    see this program
    EXCEL SHET to INTERNAL table and then to APPLICATION server
    *& Report  ZSD_EXCEL_INT_APP
    REPORT  ZSD_EXCEL_INT_APP.
    parameter: file_nm type localfile.
    types : begin of it_tab1,
            f1(20),
            f2(40),
            f3(20),
           end of it_tab1.
    data : it_tab type table of ALSMEX_TABLINE with header line,
           file type rlgrap-filename.
    data : it_tab2 type it_tab1 occurs 1,
           wa_tab2 type it_tab1,
           w_message(100)  TYPE c.
    at selection-screen on value-request for file_nm.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
      PROGRAM_NAME        = SYST-REPID
      DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
       STATIC              = 'X'
      MASK                = ' '
      CHANGING
       file_name           = file_nm
    EXCEPTIONS
       MASK_TOO_LONG       = 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.
    start-of-selection.
    refresh it_tab2[].clear wa_tab2.
    file = file_nm.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = file
        i_begin_col                   = '1'
        i_begin_row                   =  '1'
        i_end_col                     = '10'
        i_end_row                     = '35'
      tables
        intern                        = it_tab
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    loop at it_tab.
      case it_tab-col.
       when '002'.
        wa_tab2-f1 = it_tab-value.
       when '004'.
        wa_tab2-f2 = it_tab-value.
      when '008'.
        wa_tab2-f3 = it_tab-value.
    endcase.
    at end of row.
      append wa_tab2 to it_tab2.
    clear wa_tab2.
      endat.
    endloop.
    data : p_file TYPE  rlgrap-filename value 'TEST3.txt'.
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    *--- Display error messages if any.
      IF sy-subrc NE 0.
        MESSAGE e001(zsd_mes).
        EXIT.
      ELSE.
    *---Data is downloaded to the application server file path
        LOOP AT it_tab2 INTO wa_tab2.
          TRANSFER wa_tab2 TO p_file.
        ENDLOOP.
      ENDIF.
    *--Close the Application server file (Mandatory).
      CLOSE DATASET p_file.
    loop at it_tab2 into wa_tab2.
      write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
    endloop.

  • Downloading internal table in excel file on application server

    Hi,
        I am trying to download ITAB into excel file on my application server . I am using FM 'SAP_CONVERT_TO_XLS_FORMAT' for that .
        When I run the report I can see file getting generated on APP server but no ITAB data is saved in that excel.
        After debugging I found that error code  'SAVE_DOCUMENT_FAILED'  is retuned in above FM.
        Could any one please suggest how to go about this?
    Regards,
    Ganesh

    Hi ganesh,
    Please have a look into the below link
    [Link1|How to Upload Excel file to Application Server]
    [Link2|Error in Downloading the Text file on Application Server]
    Hope this will be Helpful
    Thanks
    Kalyan

  • Download  350MB of data from Application Server to Presentation server

    i want to Download  350MB(Around 2.5Million record of Table BSEG) of data from Application Server to Presentation server..
    i have tried with the transaction CG3Y and program using open dataset,read dataset,close dataset,ws_download...but went in vain,,,ended with TIMEOUT ERROR..will OPEN DATASET 'path' FOR OUTPUT FILTER 'Compress'  be helpful
    ..please help me ..its urgent..

    you can do the FTP with Unix commands..
    initially connect to the application server  by using command
    FTP <app server ip>,then it willl ask for username and password... after successful connection you  can use the following commnads to transfer file
    lcd <destination path name>(set the dest path)
    cd <source path>(set the sorce path),
    get <filename to be transfererd>( do the transfer)....
    You can do same with ABAP code also, for this you need to use some function modules like..
    FTP_CONNECT ( to establish the connection)
    FTP_COMMAND ( to execute the commands like cd, lcd get,put)
    finally FTP_DISCONNECT to close the open connection...
    for further details refer standard program RSFTP002,RSFTP003....
       reward points if helpful...

  • Sending internal table data to application server as an XML file

    Hi All,
    I am trying to send the internal table data to application server which should be stored in XML format.
    I am using the following code:
    DATA:
              result TYPE xstring.
            CALL TRANSFORMATION id
            SOURCE tab = p_output-xsfdata
            RESULT XML result.
            OPEN DATASET l_xml_full_path FOR OUTPUT IN BINARY MODE.
            TRANSFER  result TO l_xml_full_path.
            CLOSE DATASET l_xml_full_path.
    And the content in the internal table is :
    3C3F786D6C2076657273696F6E3D22312E30223F3E3C736620786D6C6E733D2275726E3A736
    73796D206E616D653D22534653592D44415445223E30362F31302F323030393C2F73796D3E2
    50617961626C653C6E65772D6C696E652F3E50617274206F6620746865204E616D653C6E657
    .......and so on
    With this a file is getting created on the application server, but the data is not correct. I am getting the data something like:
    <?xml version="1.0" encoding="utf-8"?>
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"><asx:values><TAB><item>
    PD94bWwgdmVyc2lvbj0iMS4wIj8+PHNmIHhtbG5zPSJ1cm46c2FwLWNv
    MDA6eHNmIj48c21hcnR4c2Y+PGhlYWRlcj48Z2VuZXJhbD48dmVyc2lvbj4xLjE0LjI8L3ZlcnNp
    b24PGZvcm0WkJMX1NESU5WX0xfMzwvZm9ybT48bGFuZ3VhZ2U+RU48L2xhbmd1YWdlPjxkZXZp
    Y2UUFJJTlRFUjwvZGV2aWNlPjxvdXRwdXQtZGV2aWNlPlNYU0Y8L291dHB1dC1kZXZpY2UPC9n
    ZW5lcmFsPjxwYWdlIG5hbWU9IkZJUlNUIiBpZD0iMDAxIi8PC9oZWFkZXIPGRhdGEgeG1sOnNw
    YWNlPSJwcmVzZXJ2ZSIgc3R5bGU9Ii9TTUIxMS9CTF9TRiI+PGdyYXBoaWNzIG5hbWU9IkNPTUxP
    R08iIG9iam5hbWU9Ii9TTUI0MC9MRUFGIiBvYmplY3Q9IkdSQVBISUNTIiBpZD0iQk1BUCIgdHlw
    ZT0iQkNPTCIgcGFnZT0iRklSU1QiIHBhZ2UtaWQ9IjAwMSIgcmVzb2x1dGlvbj0iMDEwMCIvPjx3
    aW5kb3cgbmFtZT0iU0VOREVSIiBwYWdlPSJGSVJTVCIgcGFnZS1pZD0iMDAxIj48dGV4dCBuYW1l
    PSJDT01BRERSIiBzdHlsZT0iL1NNQjExL0JMX1NGIiBvYmpuYW1lPSIvU01CMTEvQkxfU0VOREVS
    IiBsYW5nPSJFTiIPHAgbmFtZT0iWlMiPkJhc2VsaW5lIENvbXBhbnk8L3APHAgbmFtZT0iWlMi
    PjM0NzUgRGVlciBDcmVlazx0YWIvPlBob25lOjx0YWIvPisxICg2NTApIDg0OS00MDAwPC9wPjxw
    IG5hbWU9IlpTIj5QYWxvIEFsdG8sIENBIDk0MzA0PHRhYi8+RmF4Ojx0YWIvPisxICg2NTApIDg0
    OS00MjAwPC9wPjxwIG5hbWU9IlpTIj5VU0E8dGFiLz5JbnRlcm5ldDo8dGFiLz5odHRwOi8vd3d3
    LnNhcC5jb208L3A+PC90ZXh0Pjwvd2luZG93Pjx3aW5kb3cgbmFtZT0iUEFHRSIgcGFnZT0iRklS
    U1QiIHBhZ2UtaWQ9IjAwMSI+PHRleHQgbmFtZT0iUEFHRU5VTUJFUiIgc3R5bGU9Ii9TTUIxMS9C
    TF9TRiIgbGFuZz0iRU4iPjxwIG5hbWU9IlROIj5QYWdlIDxzeW0gbmFtZT0iU0ZTWS1QQUdFIj4x
    PC9zeW0IG9mIDxzeW0gbmFtZT0iU0ZTWS1KT0JQQUdFUyIvPjwvcD48cCBuYW1lPSJUTiIPA==</item>
    <item>c3ltIG5hbWU9IlNGU1ktREFURSI+MDYvMTAvMjAwOTwvc3ltPiA8c
    RSIMTQ6MDg6MDM8L3N5bT48L3APC90ZXh0Pjwvd2luZG93Pjx3aW5kb3cgbmFtZT0iTkFNRSIg
    cGFnZT0iRklSU1QiIHBhZ2UtaWQ9IjAwMSI+PHRleHQgbmFtZT0iRk9STVVMQVJUSVRFTCIgc3R5
    bGU9Ii9TTUIxMS9CTF9TRiIgbGFuZz0iRU4iPjxwIG5hbWU9IlROIj48Y2hyIG5hbWU9Ik1MIj48
    c3ltIG5hbWU9IlRJVExFIj5JbnZvaWNlPC9zeW0PC9jaHIPC9wPjwvdGV4dD48L3dpbmRvdz48
    d2luZG93IG5hbWU9IkJJTExUT1BBUlRZIiBwYWdlPSJGSVJTVCIgcGFnZS1pZD0iMDAxIj48dGV4
    dCBuYW1lPSJXSU5ET1dfVEVYVCIgc3R5bGU9Ii9TTUIxMS9CTF9TRiIgbGFuZz0iRU4iPjxwIG5h
    bWU9IlRIIj5CaWxsLVRvLVBhcnR5PC9wPjwvdGV4dD48YWRkcmVzcyBuYW1lPSJCSUxMQUREUkVT
    UyIgYWRkcm51bWJlcj0iMDAwMDAyMjQyNyI+PHRleHQgbmFtZT0iQklMTEFERFJFU1MiIHN0eWxl
    PSIvU01CMTEvQkxfU0YiIGxhbmc9IkVOIj48cCBuYW1lPSJUMiI+VGVjaCBJbmM8bmV3LWxpbmUv
    Could anyone tell me the reason why am I getting the data in this way?
    Thanks in advance,
    Swapna.
    Edited by: NagaSwapna Thota on Jun 10, 2009 5:44 PM

    HI,
    Use this FM SAP_CONVERT_TO_XML_FORMAT to convert the data to XML format and then upload the convert data from the internal table to Application server.

  • Upload XML file from Application Server to Internal Table

    Hi Experts,
       i have xml file in application server and i want to convert to internal table .
       i have tried this link http://wiki.sdn.sap.com/wiki/display/ABAP/UploadXMLfiletointernal+table.
       Here the file is loaded from local(presentation Server) ..
       i want to know how to select file from application layer ..and schedule in background..
       i also tried  FM '/SAPDMC/LSM_F4_SERVER_FILE' but this need front end selection of file from application server..
       i need to select a xml file from application server and convert into internal table in background.. help me on this..

    Have a look on
    Re: How to convert XML data to different ABAP internal table
    Thanks
    Ravin

  • How to Down load Data in Application server into the Internal Table

    hi freinds,
    iam having a file in the application server.
    now i need to send the data in the file to the internal table.
    is there any Function Module?
    i need with out using the OPEN DATA SET and CLOSE DATA SET Keywords.
    is there any possible?
    Regard's,
    Ranjith.

    Hi,
    There is no other option for uploading the data from the application server to the internal table without using OPEN DATASET and CLOSE DATASET. Even if you find the FM internal logic in FM uses these keywords to read the data from Application server.

  • FM to upload the Internal table data into application server.

    Hi,
      Could you please give me Function module to Upload the Internal table data into Application server ie., in Tcode AL11.
    I know for downloading the Application server file into itab is "SUBST_GET_FILE_LIST" FM and using open dtaa set we get the data.
    Regards,
    deepthi.

    Hi Deepthi
    Incase you are looking to upload data in the AL11 through a program , then you can make use of OPEN DATASET...CLOSE DATASET statements.
    Here's the code snippet:
    IF tb_alvdisplay[] IS INITIAL.
        MESSAGE e999(/dcsea/zais_msg) WITH text-e01.
      ELSE.
        IF  NOT cb_ufile IS INITIAL  "Download to file
         AND sy-pagno = 0.            "Only down page headers for first page
          PERFORM fm_concatenate_path_name USING    p_path
                                                    p_file
                                           CHANGING v_file.
    *Open file for download.
          PERFORM fm_open_file USING v_file .
        ENDIF.
        LOOP AT tb_alvdisplay.
          IF  NOT cb_ufile IS INITIAL.
    *Passing the values of the respective headings to the structure.
            ws_rec-vend_no     = tb_alvdisplay-vendno.
            ws_rec-vend_nm     = tb_alvdisplay-vendnm.
            ws_rec-title       = tb_alvdisplay-vendtl.
            ws_rec-add         = tb_alvdisplay-add.
            ws_rec-city1       = tb_alvdisplay-city1.
            ws_rec-region      = tb_alvdisplay-region.
            ws_rec-country     = tb_alvdisplay-country.
            ws_rec-pobox       = tb_alvdisplay-po.
            ws_rec-phone       = tb_alvdisplay-telf1.
            ws_rec-extn        = tb_alvdisplay-extn.
            ws_rec-fax         = tb_alvdisplay-telfx.
            ws_rec-zterm       = tb_alvdisplay-zterm.
            ws_rec-remark      = tb_alvdisplay-remark.
            ws_rec-email       = tb_alvdisplay-email.
    *Passing the separator 'PIPE' to the structure.
              ws_rec-sep01  = co_sep.
              ws_rec-sep02  = co_sep.
              ws_rec-sep03  = co_sep.
              ws_rec-sep04  = co_sep.
              ws_rec-sep05  = co_sep.
              ws_rec-sep06  = co_sep.
              ws_rec-sep07  = co_sep.
              ws_rec-sep08  = co_sep.
              ws_rec-sep09  = co_sep.
              ws_rec-sep10  = co_sep.
              ws_rec-sep11  = co_sep.
              ws_rec-sep12  = co_sep.
              ws_rec-sep13  = co_sep.
            TRANSFER ws_rec TO v_file.
          ENDIF.
          AT LAST.
            IF NOT cb_ufile IS INITIAL.
    *Closing the DATASET file.
              CLOSE DATASET v_file.
              IF sy-subrc <> 0.
    *Failure Message.
                MESSAGE e999(/dcsea/zais_msg) WITH text-t04 text-t06.
              ELSE.
    *Success message.
                MESSAGE s999(/dcsea/zais_msg) WITH text-t05.
              ENDIF.
            ENDIF.
          ENDAT.
        ENDLOOP.
      ENDIF.
    Also as Gautham suggested you can use tcode CG3Z or CG3Y incase you are looking to upload the data directly.
    FInally, you can search SCN using the keywords, "Upload to AL11" and you'll get loads of results.
    Hope this helps.
    Harsh

  • Reading XML file from application server and  put into internal table-4.6C

    Dear All,
    Is there any way of reading XML file from application server to SAP? I am using 4.6C. Function module SCMS_STRING_TO_XSTRING function module is not available. Please suggest.
    Thanks and regards,
    Atanu

    Hi Atanu!
    Simply use the XSLT transformation 'ID'.
    FIELD-SYMBOLS <ls_result> TYPE ANY.
    CREATE DATA lref_data TYPE (your_structure).
    ASSIGN lref_data->* TO <ls_result>.
    CALL TRANSFORMATION id
                        SOURCE XML xmlstr
                        RESULT result = <ls_result>.
    "xmlstr" contains your XML file. Just read it into it via standard I/O operations. "<ls_result>" will contain your DDIC formatted content.
    Best regards
    Torsten

  • 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

  • In what tables does Data in Application Server save ?

    Dear Gurus,
    In what tables does Data in Application Server save ?
    Does the code we write is saved in some tables (or) saved in
    repository ??
    what is a repository ???
    what are the tables where repository data is saved ????

    >
    Srikar M wrote:
    > Dear Gurus,
    >
    > In what tables does Data in Application Server save ?
    All of them
    >
    Srikar M wrote:
    > Does the code we write is saved in some tables (or) saved in
    > repository ??
    Both
    >
    Srikar M wrote:
    > what is a repository ???
    >
    The place where workbench objects are saved
    >
    Srikar M wrote:
    > what are the tables where repository data is saved ????
    Many and various.  Some not accessible via ABAP.

  • Uploading xml file from application server

    HI everybody guys having promblem reading xml file from application server.Here is the solution. the sample program is below.
    TYPE-POOLS: ixml. "iXML Library Types
    *TABLES : rbkp.
           TYPE DECLERATIION
    TYPES: BEGIN OF type_tabpo,
           ebeln  TYPE ekko-ebeln,         "PO document number
           ebelp TYPE ekpo-ebelp,          "PO line item
           END OF type_tabpo.
    TYPES: BEGIN OF type_ekbe,
           belnr TYPE rbkp-belnr,          "Invoice document
           gjahr TYPE rbkp-gjahr,          "fiscal year
           END OF type_ekbe.
    TYPES: BEGIN OF type_invoice,
           belnr TYPE rbkp-belnr,          "PO document number
           gjahr TYPE rbkp-gjahr,          "Fiscal Year
           rbstat TYPE rbkp-rbstat,        "invoice status
           END OF type_invoice.
    TYPES: BEGIN OF t_xml_line,            "Structure for holding XML data
            data(256) TYPE x,
            END OF t_xml_line.
         INTERNAL TABLE DECLERATIION
    DATA: gi_tabpo TYPE STANDARD TABLE OF type_tabpo,
          gi_ekbe TYPE STANDARD TABLE OF type_ekbe,
          gi_invoice TYPE STANDARD TABLE OF type_invoice,
          gi_bapiret2 TYPE STANDARD TABLE OF bapiret2.
    DATA: l_ixml TYPE REF TO if_ixml,
          l_streamfactory TYPE REF TO if_ixml_stream_factory.
         l_parser TYPE REF TO if_ixml_parser,
         l_istream TYPE REF TO swif_ixml_istream,
         l_document TYPE REF TO if_ixml_document,
         l_node TYPE REF TO if_ixml_node,
         l_xmldata TYPE string.
    *DATA: l_elem TYPE REF TO if_ixml_element,
         l_root_node TYPE REF TO if_ixml_node,
         l_next_node TYPE REF TO if_ixml_node,
         l_name TYPE string,
         l_iterator TYPE REF TO if_ixml_node_iterator.
    DATA: l_xml_table TYPE TABLE OF t_xml_line, " XML Table of the structure
          l_xml_line TYPE t_xml_line, " Record of structure t_xml_line
          l_xml_table_size TYPE i. " XML table size
    DATA: l_filename TYPE string.
          WORK AREA DECLARATION
    DATA: gw_tabpo TYPE type_tabpo,
          gw_ekbe TYPE type_ekbe,
          gw_invoice TYPE type_invoice,
          gw_bapiret2 TYPE bapiret2.
       BEGIN OF SELECTION SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    PARAMETERS: p_file TYPE pathintern LOWER CASE DEFAULT '/usr/sap/tmp/'.
    Validation of XML file: Only DTD included in XML document is supported
    SELECTION-SCREEN END OF BLOCK blk1.
      INTIALISATION.
    INITIALIZATION.
      SELECTION SCREEN VALIDATION
    AT SELECTION-SCREEN.
    To validate p_file is not initial
      PERFORM sub_validate_file.
    PERFORM sub_validate_path.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    Request for filename for xml file from the application server
      PERFORM sub_get_filename_appl USING  p_file.
      START OF SELECTION SCREEN
    START-OF-SELECTION.
      PERFORM sub_fetch_po_details.
      PERFORM sub_get_invoice.
      PERFORM sub_rel_invoice.
      END OF SELECTION SCREEN
    END-OF-SELECTION.
    *&      Form  sub_validate_file
         To Validate the file
    FORM sub_validate_file .
      IF p_file IS INITIAL.
        MESSAGE e000.           "specify the file path
      ENDIF.
    ENDFORM.                    " sub_validate_file
    *&      Form  sub_get_filename_appl
    form sub_get_filename_appl  USING  l_fname TYPE any.
    DATA:  l_fname TYPE filename-fileintern.        " File name
    *GET THE FILENAME FROM THE APPLICATION SERVER
      CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
        EXPORTING
          directory        = l_fname
          filemask         = '*'
        IMPORTING
          serverfile       = l_fname
        EXCEPTIONS
          canceled_by_user = 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.
    ENDFORM.                    " sub_get_filename_appl
    *&      Form  sub_fetch_po_details
         To fetch the PO details from the application server
         Format of file is XML
    FORM sub_fetch_po_details .
          TYPE DECLERATIION
      l_ixml = cl_ixml=>create( ).
    Creating a stream factory
      l_streamfactory = l_ixml->create_stream_factory( ).
      PERFORM get_xml_table.
      LOOP AT gi_tabpo INTO gw_tabpo.
        WRITE:/ gw_tabpo.
      ENDLOOP.
    ENDFORM.     " sub_fetch_po_details
    *&      Form  get_xml_table
          Read from the xml file
    FORM get_xml_table .
    Local variable declarations
      DATA: l_len TYPE i,
      l_len2 TYPE i,
      l_tab TYPE tsfixml,
      l_content TYPE string,
      l_str1 TYPE string,
      c_conv TYPE REF TO cl_abap_conv_in_ce,
      l_itab TYPE TABLE OF string.
      l_filename = p_file.
    code to upload data from application server
      OPEN DATASET l_filename FOR INPUT IN BINARY MODE.
      IF sy-subrc <> 0.
        WRITE:/ 'invalid file path'.
      ENDIF.
      DO.
        READ DATASET l_filename INTO l_xml_line.
        IF sy-subrc EQ 0.
          APPEND l_xml_line TO l_xml_table.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET l_filename.
    code to find the table size
      DESCRIBE TABLE l_xml_table.
      l_xml_table_size = ( sy-tleng ) * ( sy-tfill ).
    *code to convert hexadecimal to XML
      LOOP AT l_xml_table INTO l_xml_line.
        c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data
    replacement
        = space ).
        c_conv->read( IMPORTING data = l_content len = l_len ).
        CONCATENATE l_str1 l_content INTO l_str1.
      ENDLOOP.
      l_str1 = l_str1+0(l_xml_table_size).
      SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
      LOOP AT l_itab INTO l_str1.
        REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
        l_str1 WITH space.
      ENDLOOP.
      CALL TRANSFORMATION ('ID')    " code to put in internal table
      SOURCE XML l_str1
      RESULT tab = gi_tabpo[].
    ENDFORM. " get_xml_table

    Hi Raja,
    I tried the same. But it not populating the table and giving an error message in the return table "line   1 col   1-unexpected symbol; expected '<', '</', entity reference, charac".
    I can't find any ' ; ' in the XML file. What could be the possible reason of error?

Maybe you are looking for