Download XML structure to Application server

Hi all.
I am generating an XML structure based on some data that I select from HR e-Recruiting, and I need to save the generated XML file on the application server, not the presentation server (local computer). Most of the code I have found on SDN (contributed by Robert Eijpe) and I must admit that I do not understand everything the code does.
I have attached the source code and the resulting XML structure:
REPORT  zhr_test2_tk.
TYPE-POOLS: ixml.
TYPES: BEGIN OF xml_line,
        data(256) TYPE x,
       END OF xml_line.
DATA: l_ixml            TYPE REF TO if_ixml,
      l_streamfactory   TYPE REF TO if_ixml_stream_factory,
      l_ostream         TYPE REF TO if_ixml_ostream,
      l_renderer        TYPE REF TO if_ixml_renderer,
      l_document        TYPE REF TO if_ixml_document.
DATA: l_element_position TYPE REF TO if_ixml_element,
      l_element_title    TYPE REF TO if_ixml_element,
*        l_element_flight  TYPE REF TO if_ixml_element,
*        l_element_from    TYPE REF TO if_ixml_element,
*        l_element_to      TYPE REF TO if_ixml_element,
        l_element_dummy   TYPE REF TO if_ixml_element,
         l_value           TYPE string.
DATA: l_xml_table       TYPE TABLE OF xml_line,
      l_xml_size        TYPE i,
      l_rc              TYPE i.
DATA: lt_erec TYPE TABLE OF hrp5126,
      l_erec TYPE hrp5126.
DATA: date(10),
      time(4),
      filepath TYPE string.
CONSTANTS: filedir TYPE string VALUE 'C:tmp',
           filename TYPE string VALUE 'ZHR_test'.
START-OF-SELECTION.
* fill internal table
  SELECT * FROM hrp5126 INTO TABLE lt_erec.
* Start filling xml DOM object from internal table lt_erec.
  LOOP AT lt_erec INTO l_erec.
*Create the root node 'position'
    IF sy-tabix EQ 1.
*     create an ixml factory
      l_ixml = cl_ixml=>create( ).
*     create Document Object Model
      l_document = l_ixml->create_document( ).
*    Fill root node with value 'position'
      l_element_position = l_document->create_simple_element(
                     name   = 'position'
                     parent = l_document ).
    ENDIF.
    IF sy-tabix GT 1.
*     create element jobtitle as child of position
      l_value = l_erec-jobtitle.
      l_element_title = l_document->create_simple_element(
                         name   = 'job_title'
                         parent = l_element_position
                         value  = l_value ).
      l_value = l_erec-empl_start_date.
      l_element_dummy = l_document->create_simple_element(
                         name   = 'StartDate'
                         parent = l_element_title
                         value  = l_value ).
      l_value = l_erec-empl_end_date.
      l_element_dummy = l_document->create_simple_element(
                         name   = 'EndDate'
                         parent = l_element_title
                         value  = l_value ).
    ENDIF.
  ENDLOOP.
  IF sy-subrc NE 0.
    WRITE: 'No data in table hrp5125'.
  ENDIF.
* create a stream factory
  l_streamfactory = l_ixml->create_stream_factory( ).
* connect internal XML table to streamfactory
  l_ostream = l_streamfactory->create_ostream_itable(
                  table = l_xml_table ).
* render the document
  l_renderer = l_ixml->create_renderer( ostream  = l_ostream
                                        document = l_document ).
  l_rc = l_renderer->render( ).
* Get time and date
  WRITE sy-uzeit+2(2) TO time+2(2).
  WRITE sy-uzeit+0(2) TO time+0(2).
  WRITE sy-datum+4(2) TO date+0(2).
  WRITE sy-datum+6(2) TO date+2(2).
  WRITE sy-datum+0(4) TO date+4(4).
*Build filename with date and time reference
CONCATENATE filedir filename date time '.xml' INTO filepath.
<i>* This is the code I hope to modify in order to save the xml structure on the application server, with a specified filepath.</i>
<b>  OPEN DATASET filepath FOR OUTPUT IN BINARY MODE.
  LOOP AT lt_erec into l_erec.
    TRANSFER  l_erec TO filepath.
  ENDLOOP.
  CLOSE DATASET filepath.</b>
* save XML document
  l_xml_size = l_ostream->get_num_written_raw( ).
*This is the code for download to local computer
*  CALL METHOD cl_gui_frontend_services=>gui_download
*    EXPORTING
*      bin_filesize            = l_xml_size
*      filename                = filepath
*      filetype                = 'BIN'
*    CHANGING
*      data_tab                = l_xml_table
*    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.
<b>XML result:</b>
<?xml version="1.0" ?>
<position>
   <job_title>Test Process Template</job_title>
   <job_title>jjjj</job_title>
   <job_title>Test Job Req. 20092005</job_title>
   <job_title>Created 22.09</job_title>
   <job_title>title 07.12</job_title>
   <job_title>Test fra portal</job_title>
   <job_title>Test med 100328</job_title>
   <job_title>Test restricted recruiter</job_title>
   <job_title>Test restricted recruiter</job_title>
   <job_title>Workshop requisition job title</job_title>
</position>
Any help is greatly appreciated.
Best Regards,
Thomas Kjelsrud

Hi Guillaume,
The thing is that the code I presented to you is incorrect. I am asking the question of how to download / save an XML (not an internal table) to the application server. Using the gui_download will not satisfy me need, as it only downloads to the presentation server (local machine that I run my SAP session on), when I need it to download to the application server. The Open Dataset and Transfer statements are (as far as I know) only used for downloading internal tables to the application server.
So I guess my question should be like this instead:
"How can I save the XML structure that is created in the above program to the file system in the application server?"
It is a bit hard to explain this, so please ask me more questions if required.
Thank you for helping.
Best regards,
Thomas

Similar Messages

  • How to get well structured XML format in application server ?

    Hi Experts,
                    I have developed program to download XML format in application server. The below format which i am getting in
    application server :
    <?xml version="1.0" encoding="utf-16" ?> - <asx:abap xmlns:asx="http://www.sap.com/abapxml"  version="1.0">asx:values>- <TAB>- <item>  <EBELN>4151503309</EBELN>   <BUKRS>1000</BUKRS>
      <VENDOR>T-K515A09</VENDOR>   <EKORG>1000</EKORG>  <EKGRP>001</EKGRP>
    But i want the format like  below one which i am getting when i am downloading presentation server . I want it to achieve
    in application server.
    <?xml version="1.0" encoding="utf-16" ?>
    - <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    - <asx:values>
    - <TAB>
    - <item>
      <EBELN>4151503309</EBELN>
      <BUKRS>1000</BUKRS>
      <VENDOR>T-K515A09</VENDOR>
      <EKORG>1000</EKORG>
      <EKGRP>001</EKGRP>
    Pls anyone help me out regarding this.
    Thanks
    Ramesh Manoharan

    Hi
       I am new to transformation ( strans ) .Pls send me if you have any document. Is it possible to get below format in application
    server using transaction STRANS ?
    <?xml version="1.0" encoding="utf-16" ?>
    - <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    - <asx:values>
    - <TAB>
    - <item>
    <EBELN>4151503309</EBELN>
    <BUKRS>1000</BUKRS>
    <VENDOR>T-K515A09</VENDOR>
    <EKORG>1000</EKORG>
    <EKGRP>001</EKGRP>
    Thanks
    Ramesh Manoharan

  • 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

  • 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?

  • Reading XML File from application server

    Hi experts,
    My aim is to read a XML file from application server and extract the relevant data from it and process further.
    When I am trying to read a XML file from application server it is reading success fully but the problem is that its not reading the last root structure of XML file why is so happening can any body help me?
    I am using the following code:
    TYPES: BEGIN OF xml_line,
    text(256) type x,
    END OF xml_line.
    DATA: e_file LIKE rlgrap-filename VALUE  'applcatin server path'
    OPEN DATASET e_file FOR INPUT IN BINARY MODE.
    IF sy-subrc EQ 0.
      DO.
        READ DATASET e_file INTO wa_item1-text.
        IF sy-subrc EQ 0.
          APPEND wa_item1 TO gt_item1 .
          CLEAR wa_item1.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
    ENDIF.
    CLOSE DATASET e_file.
    after this i am passing this internal table to "cl_ixml" class to extract the data
    but it returning the itab with required value except the last record.
    The stream reading the file it self is i thought in complete thats why it is not converting the all values.
    Please  help me...
    Thanks a ton in advance.

    Hi,
    1 Copy Report BCCIIXMLT1
    2 (you can change the way of filling internal table xml_table if necessary)
    3 you don't need the part between
    *-- render the DOM back into an output stream/internal table
    and
    *-- print the whole DOM tree as a list...
    Comment it out or simply delete it
    4 Rename form print_node to your liking e.g. process_node
    5 In your new form you need three extra variables:
    data: attribs type ref to IF_IXML_NAMED_NODE_MAP,
          attrib_node type ref to IF_IXML_NODE,
          attrib_value type string.
    6 After the lines:
    when if_ixml_node=>co_node_element.
      string = pNode->get_name( ).
    Insert:
    attribs = pNode->get_attributes( ).
    clear attrib_value.
    case string.
      when ''. "put your XML tag name here
        attrib_node = attribs->get_named_item(name = '' ). "put your XML attribute name here
        attrib_value = attrib_node->get_value( ).
    You can also refer link,
    /people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
    thanks & regards
    shreemohan

  • How to upload XML file from Application server.

    Hi,
    How to upload XML file from Application server.Please tell me as early as possible.
    Regards,
    Sagar.

    Hi,
    parameters : p_file type ibipparms-path obligatory.
    ***DOWNLOAD---->SAP INTO EXCEL
    filename1 = p_file.
    call function 'GUI_DOWNLOAD'
      exporting
      BIN_FILESIZE                    =
        filename                        = filename1
        filetype                        = 'ASC'
      APPEND                          = ' '
      WRITE_FIELD_SEPARATOR           = 'X'
      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                        = it_stock
      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.
    Regards,
    Deepthi.

  • Download text file from application server to client server.

    Hi all,
    I am facing a format issue while downloading text file from application server to the client machine.
    The issue is that, say I have 6 to 10 lines in my text file in application server. but when i store it on the hard drive,
    it shoes all the data in a single line. Where as i need to download data in same format as in application server.
    Awaiting for your responses.
    Regards,
    Jose

    Hi,
    If we want to upload file data from the application server to the internal table, there is no function module or class static method which we can use, we must wirte the code by ourselves.
    1. For the file data which has no seperator between field columns.
    PARAMETERS p_file  TYPE dxfile-filename.
    START-OF-SELECTION.
    OPEN DATASET p_file IN TEXT MODE ENCODING DEFAULT FOR INPUT.
      DO.
        READ DATASET p_file INTO gds_data.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        APPEND gds_data TO gdt_data.
      ENDDO.
    CLOSE DATASET p_file.2. For the file data which has tab separator between field columns.
    DATA: gds_field_split type gts_data.
    FIELD-SYMBOLS: <fs_field> TYPE gts_data.
    PARAMETERS p_file  TYPE dxfile-filename.
    START-OF-SELECTION.
    OPEN DATASET prf_file IN TEXT MODE ENCODING DEFAULT FOR INPUT.
      DO.
        READ DATASET p_file INTO gds_field.
        SPLIT gds_field  AT cl_abap_char_utilities=>horizontal_tab
             INTO TABLE gdt_field_split.
       LOOP AT gdt_field_split  into gds_field_split.
           gdf_index = gdf_index + 1.
           ASSIGN COMPONENT gdf_index OF STRUCTURE
                 gds_data to <fs_field>.
          IF sy-subrc = 0.
              <fs_field> = gds_field_split.
          ENDIF.
       ENDLOOP.
        APPEND gds_data TO gdt_data.
      ENDDO.
    CLOSE DATASET p_file.
    Thanks & regards,
    ShreeMohan

  • Read xml filr from application server

    Hi I want to read an XML file from application server. can anyone please give me the sample code?
    Please its very urgent,
    Thanks

    Hello
    The following sample report <b>ZUS_SDN_BCCIIXMLT2</b> (modified from BCCIIXMLT2) shows how to upload an XML file from the application server.
    If the structure of the XML is according to the structure of a DDIC structure then you can directly convert the XML into the DDIC record using the transformation ID (= identical) which is used to convert ABAP to XML and vice versa.
    *  BCCIIXMLT2 - sample program
    *  This sample program shows how to read an XML document from a file
    *  in the appserver's file system, parse the document into a DOM
    *  representation and display the content as a list.
    *  Additionally the DOM representation is rendered back into an XML
    *  stream and stored as an output XML file on the appserver machine.
    *  This sample program uses ABAP strings to represent the XML input
    *  and output streams. See BCCIIXMLT1 for using internal tables.
    REPORT zus_sdn_bcciixmlt2 MESSAGE-ID bcciixmlt3_msg LINE-SIZE 1000.
    DATA:
      gd_rc     TYPE sysubrc,
      go_doc    TYPE REF TO cl_xml_document.
    START-OF-SELECTION.
      PARAMETERS: filename(80) TYPE c
              DEFAULT 'tempIDoc_430040.xml'.  "#EC NOTEXT
    *-- read the XML document from a dataset into a string
      DATA: inputstring TYPE xstring.
      OPEN DATASET filename FOR INPUT IN BINARY MODE.
      IF sy-subrc NE 0.
        MESSAGE e000.
      ENDIF.
      READ DATASET filename INTO inputstring.
      CLOSE DATASET filename.
      CREATE OBJECT go_doc.
      CALL METHOD go_doc->parse_xstring
        EXPORTING
          stream  = inputstring
        RECEIVING
          retcode = gd_rc.
      CALL METHOD go_doc->display
    *    EXPORTING
    *      WITH_BDN = SPACE
    *-- create the main factory
      DATA: pixml TYPE REF TO if_ixml.
      pixml = cl_ixml=>create( ).
    *-- create the initial document
      DATA: pdocument TYPE REF TO if_ixml_document.
      pdocument = pixml->create_document( ).
    *-- create the stream factory
      DATA: pstreamfactory TYPE REF TO if_ixml_stream_factory.
      pstreamfactory = pixml->create_stream_factory( ).
    *-- create a stream for the input (string)
      DATA: pistream TYPE REF TO if_ixml_istream.
      pistream = pstreamfactory->create_istream_xstring( inputstring ).
    *-- create the parser
      DATA: pparser TYPE REF TO if_ixml_parser.
      pparser = pixml->create_parser( stream_factory  = pstreamfactory
                                        istream       = pistream
                                        document      = pdocument ).
    *-- parse the stream
      IF pparser->parse( ) NE 0.
        IF pparser->num_errors( ) NE 0.
          DATA: count TYPE i.
          count = pparser->num_errors( ).
          WRITE: count, ' parse errors have occured:'.          "#EC NOTEXT
          DATA: pparseerror TYPE REF TO if_ixml_parse_error,
                i TYPE i.
          DATA: index TYPE i VALUE 0.
          WHILE index < count.
            pparseerror = pparser->get_error( index = index ).
            i = pparseerror->get_line( ).
            WRITE: 'line: ', i.                                 "#EC NOTEXT
            i = pparseerror->get_column( ).
            WRITE: 'column: ', i.                               "#EC NOTEXT
            DATA: string TYPE string.
            string = pparseerror->get_reason( ).
            WRITE: string.
            index = index + 1.
          ENDWHILE.
        ENDIF.
      ENDIF.
    *-- we don't need the stream any more, so let's close it...
      CLEAR pistream.
    *-- just for fun: render the DOM back into an output stream/xstring
      DATA: postream TYPE REF TO if_ixml_ostream,
            outputstring TYPE xstring.
      postream = pstreamfactory->create_ostream_xstring( outputstring ).
      CALL METHOD pdocument->render( ostream = postream ).
    *-- write the XML document as a dataset
      DATA: dsn(80) TYPE c.
      CONCATENATE filename '.out' INTO dsn.                     "#EC NOTEXT
      OPEN DATASET dsn FOR OUTPUT IN BINARY MODE.
      TRANSFER outputstring TO dsn.
      CLOSE DATASET dsn.
    *-- print the whole DOM tree as a list...
      DATA: pnode TYPE REF TO if_ixml_node.
      pnode = pdocument.
      PERFORM print_node USING pnode.
    *       FORM print_node                                               *
    FORM print_node USING value(pnode) TYPE REF TO if_ixml_node.
      DATA: indent      TYPE i.
      DATA: ptext       TYPE REF TO if_ixml_text.
      DATA: string      TYPE string.
      indent  = pnode->get_height( ) * 2.
      CASE pnode->get_type( ).
        WHEN if_ixml_node=>co_node_element.
          string  = pnode->get_name( ).
          WRITE: AT /indent '<', string, '> '.                  "#EC NOTEXT
        WHEN if_ixml_node=>co_node_text.
          ptext ?= pnode.
          IF ptext->ws_only( ) IS INITIAL.
            string = pnode->get_value( ).
            WRITE: AT /indent string.
          ENDIF.
      ENDCASE.
      pnode = pnode->get_first_child( ).
      WHILE NOT pnode IS INITIAL.
        PERFORM print_node USING pnode.
        pnode = pnode->get_next( ).
      ENDWHILE.
    ENDFORM.                    "print_node
    Regards
      Uwe

  • FM to read XML files from Application server in ECC5.0

    Hi All,
    We need to pick up an XML file from Application server/FTP server. The requirement is to parse the XML file and process it to create material master. SAP provides standard function modules to read XML files.
    Now we need to read the XML file contents of MM01 and upload into SAP Data Base through BAPI
    I need to know about the Function modules to read XML files from Application Server and also about the FM's that will update the Date base tables with the data obtained form XML files.
    Regards
    Prathima

    Parsing XML data:
    http://help.sap.com/saphelp_nw04/helpdata/en/86/8280ba12d511d5991b00508b6b8b11/frameset.htm
    or alternatively check out ABAP online help for "CALL TRANSFORMATION".
    For creating the material master look at BAPI_STANDARDMATERIAL_CREATE.
    Thomas

  • How to download a file from application server to presentation server

    Hi experts,
    I want to download a file from application server to presentaion server, file contaims three fields customer name, customer email id and status..
    help me out i m new into sap.

    Dear Aditya,
    Please check below thread
    http://scn.sap.com/thread/1010164
    it will help you.
    BR
    Atul

  • How can I download the data to Application Server and Network Drive

    Hi Experts
    I am having problem with download the data to Application Server and Network Drive in back ground. its working in foregorund but not in back ground.please suggest me . Thanks for advance.
    Thanks & Regards
    Raghava

    Hi Experts
    I am using like this
    P_Back is a check box on the selection-screen.
    it_fihrst_out-its internal table
    sy-batch -Program is running in the background
    IF sy-batch IS INITIAL.
        IF p_back = 'X'.
          OPEN DATASET file_01 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
          IF sy-subrc = 0.
            LOOP AT it_fihrst_out.
              TRANSFER it_fihrst_out TO file_01.
            ENDLOOP.
          ENDIF.
          CLOSE DATASET file_01.
          CASE sy-subrc.
            WHEN 0.
              WRITE: / file_01, / 'successfully generated.'.
            WHEN OTHERS.
              WRITE: / file_01, 'Unexpected error occurred.'.
          ENDCASE.
        ELSE.
          CALL FUNCTION 'WS_DOWNLOAD'
            EXPORTING
              filename                = file_01
              filetype                = 'ASC'
            TABLES
              data_tab                = it_fihrst_out
            EXCEPTIONS
              file_open_error         = 1
              file_write_error        = 2
              invalid_filesize        = 3
              invalid_type            = 4
              no_batch                = 5
              unknown_error           = 6
              invalid_table_width     = 7
              gui_refuse_filetransfer = 8
              customer_error          = 9
              OTHERS                  = 10.
          CASE sy-subrc.
            WHEN 0.
              WRITE: / file_01, / 'successfully generated.'.
            WHEN 2.
              WRITE: / file_01, 'Output Error: File still open'.
            WHEN OTHERS.
              WRITE: / file_01, 'Unexpected error occurred.'.
          ENDCASE.
        ENDIF.
      ELSE.
        LOOP AT it_fihrst_out.
          WRITE:/ it_fihrst_out.
        ENDLOOP.
      ENDIF.
    This is the code .

  • Xml file in application server

    Experts,
    I'm using a a simple tranformation and "open dataset" statement in order to write a xml file in application server: This is working fine.
    i notice that when i preview the file in transaction "AL11" , it shows like " <tag> <tag> <tag> <tag> ......
    The encoding of this file is 'utf-8'.
    I did another test that was writing, trouht transaction CG3Z, a xml file in encoding 'ISO-8859-15'. When a preview the file in AL11 is shows like :
    <tag>
    <tag>
    <tag>
    <tag>
    The change in the preview is due to the codification ? Or is regarding that way we write the file to the server ?
    Best regards,
    MR.

    Hello,
    Change is because of the encoding style changed from utf-8 to 'ISO-8859-15'.
    May be you can try changing this manualy in XML file and see the output result.
    Thanks,
    Augustin.

  • 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

  • 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

  • Gui_download function to download the file in application server in bdc

    Can we use gui_download function to download the file in application server in bdc?
    Regards,
    pandu.

    for downloading the file on application sever you use the concept of Dataset. GUI_DOWNLOAD is for presentaion server.
    regards
    Abhi

Maybe you are looking for

  • Modifying to-do list view in the calendar

    the calendar of my 9300 currently shows all the entries in my to-do list, including entries that are not yet due. i would like to modify the view so that it does not show entries that are still due in the future. i would appreciate any help in making

  • VERY Important Question on a WRT54G?

    Can a WRT54G be setup not to completely reset it's settings to default when reset button pushed? Here is my dilemma.  I oversee the network at a medium sized business.  We have one WRT54G wireless router.  I really do not like having it on premises b

  • How to maintain bitmap index on a large table in DW?

    Hi all, We have many tables which are constantly doing either FULL or INCREMENTAL loading. And we have created many BITMAP indexes and several B*Tree index (caused by PRIMARY KEY or UNIQUE key constraints) on those tables. So, what I want to know is,

  • How can i compare two color images in vision builder for AI?

    What i want to do is to compare two images. I have a base color image that represents the desired colors and tones. I have another image to be compared to the base image. What i want to do is to compare this two images to know how close they are rega

  • What is the process of upgrading 10g Express to Standard/Ent Edition?

    We would like to start rolling out Oracle 10g Express to our clients when the production release is available. Our issue is that 50% of our client will stay within the limits of 10g Express (4G of user data etc), 30% of our clients will start on Expr