Creating XML file from ABAP internal table data....

Hello,
I am fethcing data froma  custom table and I have to write data in XMl format. Following is the XML format in which I want data. Is there any function module iN SAP which will help me in writing data from internal table to XML file ?
<batch>
  <invoice>
    <StatusCode>10</StatusCode>
    <paymentamount>122.00</paymentamount>
     <ReferenceNumber>70980934</ReferenceNumber>
  </invoice>
  <invoice>
     <StatusCode>90</StatusCode>
    <paymentamount>122.00</paymentamount>
     <ReferenceNumber>70980934</ReferenceNumber>
  </invoice>
  <control>
    <InvoiceCount>2</InvoiceCount>
  </control>
</batch>
Please help.
Regards,
Jainam.

I suggest you look into "simple transformations". That's SAP's most recent technology for such purposes, as far as I know.
http://help.sap.com/abapdocu_70/en/ABENABAP_ST.htm
Thomas

Similar Messages

  • Create XML file from ABAP with SOAP Details

    Hi,
    I am new to XML and I am not familiar with JAVA or Web Service. I have searched in SDN and googled for a sample program for creating XML document from ABAP with SOAP details. Unfortunately I couldn't find anything.
    I have a requirement for creating an XML file from ABAP with SOAP details. I have the data in the internal table. There is a Schema which the client provided and the file generated from SAP should be validating against that Schema. Schema contains SOAP details like Envelope, Header & Body.
    My question is can I generate the XML file using CALL TRANSFORMATION in SAP with the SOAP details?
    I have tried to create Transformation (Transaction XSLT_TOOL) in SAP with below code. Also in CALL transformation I am not able to change the encoding to UTF-8. It's always show UTF-16.
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
      <xsl:template match="/">
        <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
          <SOAP:Header>
            <CUNS:HeaderInfo>
              <CUNS:InterfaceTypeId>10006</InterfaceTypeId>
              <CUNS:BusinessPartnerID>11223344</BusinessPartnerID>
              <CUNS:SchemaVersion>1.0</SchemaVersion>
              <CUNS:DateTime>sy-datum</DateTime>
            </CUNS:HeaderInfo>
          </SOAP:Header>
          <SOAP:Body>
            <xsl:copy-of select="*"/>
          </SOAP:Body>
        </SOAP:Envelope>
      </xsl:template>
    </xsl:transform>
    In ABAP program, I have written below code for calling above Transformation.
      call transformation ('Z_ID')
           source tab = im_t_output[]
           result xml xml_out.
      call function 'SCMS_STRING_TO_FTEXT'
        exporting
          text      = xml_out
        tables
          ftext_tab = ex_t_xml_data.
    Please help me how to generate XML file with SOAP details from ABAP. If anybody have a sample program, please share with me.
    Is there any easy way to create the XML file in CALL Transformation. Please help.
    Thanks

    Try ABAP forum, as it seems not to be PI related.

  • Reading XML file to ABAP internal table

    Hi all,
    Iam trying to convert a XLM file into abap internal table , am using XSLT transformation to parse the XML file and i am using "CALL METHOD cl_gui_frontend_services=>gui_upload" for reading the XML file.
    below is the XML file.
    ===========================================================================
    - <PIXBridge version="2.2" timestamp="2003-04-09T15:27:00">
    - <PIX>
      <TransactionType>605</TransactionType>
      <TransactionCode>98</TransactionCode>
      <TransactionNumber>6888965</TransactionNumber>
      <SequenceNumber>40001</SequenceNumber>
    - <SKUDefinition>
      <Company>GZL</Company>
      <Division>BMD</Division>
      <Season />
      <SeasonYear />
      <Style>ORT002A</Style>
      <StyleSuffix />
      <Color>K13</Color>
      <ColorSuffix />
      <SecDimension />
      <Quality />
      <SizeRangeCode />
      <SizeDesc>M</SizeDesc>
      <SkuID>200140577</SkuID>
      </SKUDefinition>
      </PIX>
      </PIXBridge>
    =================================================================
    and my Transformation code is as below
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
      <xsl:strip-space elements="*"/>
      <xsl:template match="/">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <IPIX>
              <xsl:apply-templates select="//PIX"/>
            </IPIX>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <xsl:template match="PIX">
        <item>
          <TRANSACTIONTYPE>
            <xsl:value-of select="TransactionType"/>
          </TRANSACTIONTYPE>
          <TRANSACTIONCODE>
            <xsl:value-of select="TransactionCode"/>
          </TRANSACTIONCODE>
          <TRANSACTIONNUMBER>
            <xsl:value-of select="TransactionNumber"/>
          </TRANSACTIONNUMBER>
          <SEQUENCENUMBER>
            <xsl:value-of select="SequenceNumber"/>
          </SEQUENCENUMBER>
          <SKUDEFINITION>
            <COMPANY>
              <xsl:value-of select="Company"/>
            </COMPANY>
            <DIVISION>
              <xsl:value-of select="Division"/>
            </DIVISION>
            <SEASON/>
            <SEASONYEAR/>
            <STYLE>
              <xsl:value-of select="Style"/>
            </STYLE>
            <STYLESUFFIX/>
            <COLOR>
            <xsl:value-of select="Color"/>
            </COLOR>
            <COLORSUFFIX/>
            <SECDIMENSION/>
            <QUANTITY/>
            <SIZERANGECODE/>
            <SIZEDESC>
              <xsl:value-of select="SizeDesc"/>
            </SIZEDESC>
            <SKUID>
              <xsl:value-of select="SkuID"/>
            </SKUID>
          </SKUDEFINITION>
          </item>
        </xsl:template>
    When i run my program i am getting the values only till the sequence number part and im not getting any values  that is read in between <SKUDEFINITION> ..... </SKUDEFINITION>
    I need help to sort this , kindly help me in this.
    regs,
    raja

    I am not able to get a clue out of that, can Get Durairaj Athavan Raja in to loop for sorting this out.
    I made changes to my transformation program , but still not getting the output of the components inside the
    <SKUDefinition> , but when i debug  the transformation i can able to see the output values for those components but when i get the values in the result table im not getting values of those components.
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
      <xsl:strip-space elements="*"/>
      <xsl:template match="/">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <IPIX>
              <xsl:apply-templates select="//PIX"/>
            </IPIX>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <xsl:template match="PIX">
        <item>
          <TRANSACTIONTYPE>
            <xsl:value-of select="TransactionType"/>
          </TRANSACTIONTYPE>
          <TRANSACTIONCODE>
            <xsl:value-of select="TransactionCode"/>
          </TRANSACTIONCODE>
          <TRANSACTIONNUMBER>
            <xsl:value-of select="TransactionNumber"/>
          </TRANSACTIONNUMBER>
          <SEQUENCENUMBER>
            <xsl:value-of select="SequenceNumber"/>
          </SEQUENCENUMBER>
          <xsl:for-each select="SKUDefinition">
          <SKUDEFINITION>
          <COMPANY>
              <xsl:value-of select="Company"/>
          </COMPANY>
          <DIVISION>
              <xsl:value-of select="Division"/>
          </DIVISION>
          <SEASON/>
          <SEASONYEAR/>
          <STYLE>
            <xsl:value-of select="Style"/>
          </STYLE>
          <STYLESUFFIX/>
          <COLOR>
            <xsl:value-of select="Color"/>
          </COLOR>
          <COLORSUFFIX/>
          <SECDIMENSION/>
          <QUANTITY/>
          <SIZERANGECODE/>
          <SIZEDESC>
              <xsl:value-of select="SizeDesc"/>
          </SIZEDESC>
          <SKUID>
              <xsl:value-of select="SkuID"/>
          </SKUID>
          </SKUDEFINITION>
          </xsl:for-each>
        </item>
      </xsl:template>
    </xsl:transform>
    ==================
    Below is my main program
    ===================
    TYPE-POOLS abap.
    CONSTANTS gs_file TYPE string VALUE 'C:\XMLABAP1.xml'.
    This is the structure for the data from the XML file
    TYPES: BEGIN OF ty_text,
             TransactionType(3) type n,
             TransactionCode(2) type n,
             TransactionNumber(7) type n,
             SequenceNumber(5) type n,
             Company(3) type c,
             Division(3) type c,
             Season(3) type c,
             SeasonYear(4) type c,
             Style(8) type c,
             Color(3) type c,
             SecDimension(3) type c,
             Quality(3) type n,
             SizeRangeCode(2) type c,
             SizeDesc(1) type c,
             SkuID(10) type c,
           END OF ty_text.
    Table for the XML content
    DATA: gt_itab       TYPE STANDARD TABLE OF char2048.
    data: xmlstr        TYPE XSTRING.
    Table and work ares for the data from the XML file
    DATA: gt_person     TYPE STANDARD TABLE OF ty_text,
          gs_person     TYPE ty_text.
    Result table that contains references
    of the internal tables to be filled
    DATA: gt_result_xml TYPE abap_trans_resbind_tab,
          gs_result_xml TYPE abap_trans_resbind.
    For error handling
    DATA: gs_rif_ex     TYPE REF TO cx_root,
          gs_var_text   TYPE string.
    Get the XML file from your client
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename                = gs_file
      CHANGING
        data_tab                = gt_itab
      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
        not_supported_by_gui    = 17
        error_no_gui            = 18
        OTHERS                  = 19.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Fill the result table with a reference to the data table.
    Within the XSLT stylesheet, the data table can be accessed with
    "IPERSON".
    GET REFERENCE OF gt_person INTO gs_result_xml-value.
    gs_result_xml-name = 'IPIX'.
    APPEND gs_result_xml TO gt_result_xml.
    Perform the XSLT stylesheet
    TRY.
        CALL TRANSFORMATION ZAUM_MANH_SYNC_RPT
        SOURCE XML XMLSTR
        RESULT (gt_result_xml).
      CATCH cx_root INTO gs_rif_ex.
        gs_var_text = gs_rif_ex->get_text( ).
        MESSAGE gs_var_text TYPE 'E'.
    ENDTRY.
    Now let's see what we got from the file
    LOOP AT gt_person INTO gs_person.
    WRITE: / 'Transaction Type:', gs_person-TransactionType.
      WRITE: / 'Transaction Code :', gs_person-TransactionCode.
      WRITE: / 'Transaction Number :', gs_person-TransactionNumber.
       WRITE: / 'SequenceNumber :', gs_person-SequenceNumber.
       WRITE: / 'Company : ', gs_person-Company.
      WRITE : /.
    ENDLOOP. "gt_person.

  • Create a xml file from an internal table: CALL TRANSFORMATION

    Hello gurus,
    I want to create a xml file using data from scustom table. I will create an internal table and will select some records to it.
    I searched the forum and i discovered the call transformation, but when i execute the example program at the CALL TRANSFORMATION shows a dump screen.
    How we create a xml file from internal table??
    Please help me. I will mark the useful answers.

    I'm using if_ixml class to create xml documents
    TYPES: BEGIN OF xml_line,
             data(256) TYPE x,
           END OF xml_line.
    DATA: o_ixml          TYPE REF TO if_ixml,
          o_document      TYPE REF TO if_ixml_document,
          o_element       TYPE REF TO if_ixml_element,
          o_streamfactory TYPE REF TO if_ixml_stream_factory,
          o_ostream       TYPE REF TO if_ixml_ostream,
          o_renderer      TYPE REF TO if_ixml_renderer.
    DATA: t_xml_table     TYPE TABLE OF xml_line,
          v_xml_size      TYPE i.
    o_ixml = cl_ixml=>create( ).
    o_document = o_ixml->create_document( ).
    * The o_document have a set of methods to add elements, attributes, etc.
    o_element  = o_document->create_simple_element(
                      name = 'RootNode'
                      value = 'some text'
                      parent = o_document ).
    o_streamfactory = o_ixml->create_stream_factory( ).
    o_ostream = o_streamfactory->create_ostream_itable( table = t_xml_table ).
    o_renderer = o_ixml->create_renderer( ostream  = o_ostream document = o_document ).
    o_renderer->render( ).
    v_xml_size = o_ostream->get_num_written_raw( ).
    CALL METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
        bin_filesize = v_xml_size
        filename     = 'C:a.xml'
        filetype     = 'BIN'
      CHANGING
        data_tab     = t_xml_table.

  • PDF File from an internal table data

    I have an internal table ready for grid display of a report. But according to the new requirement, it shouldn't create a Spool request as it is affecting the performance of the system (because its a huge file with 3000+ pages).
    So, now we want to create a (non-editable) PDF File and store it in an application server.
    From the forum, i see that i have only one option, which is to Convert internal table data to OTF Format and then to PDF.
    Right now i am using  PRINT_TEXT to convert to OTF file and FM CONVERT_OTF for PDF file.
    The challenges i am facing right now is..
    1. After getting the OTF file from PRINT_TEXT, i couldn't get the correct PDF File. It shows random characters instead..
    2. My internal table has 103 columns. So how should i accommodate data from all these columns into a single row on a PDF?
    3. I couldn't create a table kind of view/display in PDF
    Please help/advice me on the above issue.
    Thanks,
    Sarada

    Hi,
    103 columns need to be seen in at least 7 pages or more. Cant display in just 1 page.
    I guess that better to create a smartforms and pass all the information from the table to the smartforms.
    There you can create multipages.
    Probably, that huge table need to separete it in 7 tables, so each page will get the information from one table...
    i will try to do sth like that.
    Regards
    Miguel

  • Code to transfer xml file to abap internal table using transformation

    Hi friends
    Given the following xml file .the requirementis to  display and transfer the xml file to internal table usin transformation and gui_upload.If any onehaving simple code on this please send .
    Can any one sugest the steps to be followed to write source code using simple transformation.
    <?xml version="1.0" encoding="utf-8" ?>
    - <Negara>
    - <item>
    - <COUNTRY>
      <MANDT>600</MANDT>
      <ZCODE>500</ZCODE>
      <ZDESC>Pening Lalat</ZDESC>
      <ZSAPCD>T1</ZSAPCD>
      </COUNTRY>
      </item>
    - <item>
    - <COUNTRY>
      <MANDT>600</MANDT>
      <ZCODE>600</ZCODE>
      <ZDESC>Pening Lalat2</ZDESC>
      <ZSAPCD>T2</ZSAPCD>
      </COUNTRY>
      </item>
      </Negara>
    Thaking You

    hi..
    1. itab --- > xml
    xml ---> itab.
    2. This program will do both.
    (just copy paste in new program)
    3.
    REPORT abc.
    DATA
    DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
    DATA : BEGIN OF itab OCCURS 0,
    a(100) TYPE c,
    END OF itab.
    DATA: xml_out TYPE string .
    DATA : BEGIN OF upl OCCURS 0,
    f(255) TYPE c,
    END OF upl.
    DATA: xmlupl TYPE string .
    FIRST PHASE
    FIRST PHASE
    FIRST PHASE
    Fetch Data
    SELECT * FROM t001 INTO TABLE t001.
    XML
    CALL TRANSFORMATION ('ID')
    SOURCE tab = t001[]
    RESULT XML xml_out.
    Convert to TABLE
    CALL FUNCTION 'HR_EFI_CONVERT_STRING_TO_TABLE'
    EXPORTING
    i_string = xml_out
    i_tabline_length = 100
    TABLES
    et_table = itab.
    Download
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    filetype = 'BIN'
    filename = 'd:\xx.xml'
    TABLES
    data_tab = itab.
    SECOND PHASE
    SECOND PHASE
    SECOND PHASE
    REFRESH t001.
    CLEAR t001.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = 'D:\XX.XML'
    filetype = 'BIN'
    TABLES
    data_tab = upl.
    LOOP AT upl.
    CONCATENATE xmlupl upl-f INTO xmlupl.
    ENDLOOP.
    XML
    CALL TRANSFORMATION ('ID')
    SOURCE XML xmlupl
    RESULT tab = t001[].
    <b>Reward points if useful</b>
    Regards
    Ashu

  • Trying to create XML file from 1 oracle table .

    I'M NEW IN ODI
    Step1: Target XML format
    - <Customers>
    - <UserInfo> 
    <UserID>0000000000202406</UserID>  
    <LegalEntityCode>0USAL</LegalEntityCode>  
    <BranchCode>001</BranchCode>  
    <LegalEntity>>0USAL</LegalEntity>  
    <BranchCode>001</BranchCode>  
    <TypeOfChange>123jkl</TypeOfChange>  
    - <CustomerDetails> 
    - <MasterData> 
    <RelationshipManager>jkiu123</RelationshipManager>  
    <CustomerID />  
    <GroupCustomerID>0000000000202406</GroupCustomerID>  
    <FirstName>sdfgh</FirstName>  
    <LastName>dhgfs</LastName>  
    <CustomerType>c</CustomerType>  
    <CustomerSubType>fitz</CustomerSubType>  
    <SAE>430</SAE>  
    <DoubleCitizenship>NA</DoubleCitizenship>  
    <TelephoneNumber>NA</TelephoneNumber>  
    <Citizenship>NA</Citizenship>  
    <TIN>NA</TIN>  
    <Language>GB</Language>  
    <BirthCountryCode>AL</BirthCountryCode>  
    <BirthCountry>ALB</BirthCountry>  
    <DateOfBirth>NA</DateOfBirth>  
    </MasterData>
    </CustomerDetails>
    </UserInfo>
    </Customers>
    Step 2. Specified the logical and physical schema FOR XML.
    jdbc:snps:xml?f=V:\MYFILE.xml&d=V:\MYFILE.DTD&s=FXML
    where schema and work schema are the same: FXML
    Step3.Logged into Designer and reverse engineered from the the schema created in step2.
    step 4. Following Hierarchy is created:
    CUSTOMERS USERINFO CUSTOMERDETAILS MASTERDATA
    PLEASE HELP ME WITH EXPLANATIONS  IN DETAILS!!!
    T.Y. IN ADVANCE

    Hi Ayush!
    Thnx for your help.
    But know i have this:
    ODI-1228: Task ISPBA_FATCA_XML_MASTERDATA_FINAL (Integration) fails on the target XML connection FATCA_FINAL.
    Caused By: java.sql.SQLException: data exception: numeric value out of range
      at com.sunopsis.jdbc.driver.xml.SnpsXmlPreparedStatementRedirector.execute(SnpsXmlPreparedStatementRedirector.java:211)
      at com.sunopsis.jdbc.driver.xml.SnpsXmlPreparedStatement.execute(SnpsXmlPreparedStatement.java:48)
      at oracle.odi.runtime.agent.execution.sql.SQLCommand.execute(SQLCommand.java:163)
      at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:102)
      at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:1)
      at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:50)
      at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)
      at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)
      at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:580)
      at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:468)
      at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2128)
      at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:366)
      at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
      at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
      at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:292)
      at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:855)
      at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
      at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:83)
      at java.lang.Thread.run(Thread.java:662)
    All the values for source and target have the same size and type. Can you help me?

  • Xml string to abap internal  table

    HI Experts ,
    I want to parse this XML file to abap internal table ,i read as usual  the Help and i think
    that something is missing on my code.
    There is someone can help.
    The fields is type string and the value is :
    <Containers> <Container workitemid = "00000017" IsParent = "X"><Element name = "_WF" value = "USI029"/><Element name = "_WF_PRIOR" value = "5"/><Element name = "_WF_VERSION" value = "0000"/><Element name = "_WF_NESTING_LEVEL" value = ""/><Element name = "XUBNAME" value = ""/><Element name = "XUACCNT" value = ""/><Element name = "SHORTTEXT" value = ""/><Element name =
    i use the call transformation code and there i put this code:
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
    <tt:root name="XML_TAB"/>
      <tt:template>
        <Containers>
          <tt:loop name="a" ref=".XML_TAB">
            <Container>
              <tt:attribute name="Element name" value-ref="$a.name"/>
              <tt:attribute name="value" value-ref="$a.value"/>
            </Container>
          </tt:loop>
        </Containers>
      </tt:template>
    </tt:transform>
    I think that i miss something with the line :<Container workitemid = "0000007" IsParent = "X">
    the dump is:
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_ST_MATCH_ATTRIBUTE', was not
      caught and
    therefore caused a runtime error.
    The reason for the exception is:
    XML matching error
    Expected was attribute: "Elementname" [ ] Read was element-start: "Container" [
    Please help
    Regards
    Chris
    Edited by: Chris Teb on Aug 6, 2009 9:57 AM

    H Siva,
    Thanks ,
    I try exactly like u tell and i get this dump:
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_ST_MATCH_ELEMENT', was not caught
      and
    therefore caused a runtime error.
    The reason for the exception is:
    XML matching error
    Expected was element-end: "Containers" [ ] Read was element-start: "Container"
    <Containers>
        <Container>
            <tt:loop name="a" ref=".XML_TAB">
            <Element >
              <tt:attribute name="name" value-ref="$a.name"/>
              <tt:attribute name="value" value-ref="$a.value"/>
              </Element>
              </tt:loop>
            </Container>
        </Containers> ->**the dump in the debugger is here .**
      </tt:template>
    </tt:transform>
    Any Idea?
    Regards
    Chris

  • Collect data from a dynamic XML file into multiple internal tables

    I need to convert the XML file into multiple internal tables. I tried many links and posts in SDN but still was facing difficulty in achieving this. Can some one tell me where I am going wrong.
    My XML file is of the following type.It is very complex and the dynamice.
    The following tags occur more than once in the XML file. The "I" and "L" tags and its child tags can occur ones or more than once for each XML file and it is not constant. i.e in one file they can occur 1 time and in another they can occur 100 times.
    "I" and "L" are child tags of <C>
    <I>
           <J>10</J>
             <K>EN</K>
      </I>
    <L>
             <J>20</J>
              <N>BB</N>
      </L>
    Tags <C> and <F> occur only ones for each XML file. <C> is the child tag of "A" and "F" is the child tag of <C>.
    I need to collect <D>, <E> in one internal table ITAB.
    I need to collect <G>, <H> in one internal table JTAB.
    I need to collect <J>, <K> in one internal table KTAB.
    I need to collect <J>, <N> in one internal table PTAB.
    Below is the complete XML file.
    ?xml version="1.0" encoding="iso-8859-1" ?>
    <A>
        <B/>
        <C>
           <D>RED</D>
           <E>999</E>
        <F>
           <G>TRACK</G>
           <H>PACK</H>
        </F>
        <I>
           <J>10</J>
           <K>EN</K>
        </I>
        <I>
           <J>20</J>
           <K>TN</K>
        </I>
        <I>
           <J>30</J>
           <K>KN</K>
        </I>
        <L>
           <J>10</J>
           <N>AA</N>
        </L>
        <L>
           <J>20</J>
           <N>BB</N>
        </L>
        <L>
           <J>30</J>
           <N>CC</N>
        </L>
        </C>
      </A>
    With the help of SDN I am able to gather the values of <D> <E> in one internal table.
    Now if I need to gather
    <G>, <H> in one internal table JTAB.
    <J>, <K> in one internal table KTAB.
    <J>, <N> in one internal table PTAB.
    I am unable to do. I am following  XSLT transformation method. If some one has some suggestions. Please help.
    Here is my ABAP program
    TYPE-POOLS abap.
    CONSTANTS gs_file TYPE string VALUE 'C:\TEMP\ABCD.xml'.
    * This is the structure for the data from the XML file
    TYPES: BEGIN OF ITAB,
             D(10) TYPE C,
             E(10) TYPE C,
           END OF ITAB.
    * Table for the XML content
    DATA: gt_itab       TYPE STANDARD TABLE OF char2048.
    * Table and work ares for the data from the XML file
    DATA: gt_ITAB     TYPE STANDARD TABLE OF ts_ITAB,
          gs_ITAB     TYPE ts_ITAB.
    * Result table that contains references
    * of the internal tables to be filled
    DATA: gt_result_xml TYPE abap_trans_resbind_tab,
          gs_result_xml TYPE abap_trans_resbind.
    * For error handling
    DATA: gs_rif_ex     TYPE REF TO cx_root,
          gs_var_text   TYPE string.
    * Get the XML file from your client
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename                = gs_file
      CHANGING
        data_tab                = gt_itab1
      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
        not_supported_by_gui    = 17
        error_no_gui            = 18
        OTHERS                  = 19.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    * Fill the result table with a reference to the data table.
    * Within the XSLT stylesheet, the data table can be accessed with
    * "IITAB".
    GET REFERENCE OF gt_shipment INTO gs_result_xml-value.
    gs_result_xml-name = 'IITAB'.
    APPEND gs_result_xml TO gt_result_xml.
    * Perform the XSLT stylesheet
    TRY.
        CALL TRANSFORMATION zxslt
        SOURCE XML gt_itab1
        RESULT (gt_result_xml).
      CATCH cx_root INTO gs_rif_ex.
        gs_var_text = gs_rif_ex->get_text( ).
        MESSAGE gs_var_text TYPE 'E'.
    ENDTRY.
    * Now let's see what we got from the file
    LOOP AT gt_ITAB INTO gs_ITAB.
      WRITE: / 'D:', gs_ITAB-D.
      WRITE: / 'E :', gs_ITAB-E.
    ENDLOOP.
    Transformation
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
      <xsl:strip-space elements="*"/>
      <xsl:template match="/">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <IITAB>
              <xsl:apply-templates select="//C"/>
            </IITAB>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <item>
          <D>
            <xsl:value-of select="D"/>
          </D>
          <E>
            <xsl:value-of select="E"/>
          </E>
        </item>
      </xsl:template>
    </xsl:transform>
    Now the above pgm and transformation work well and I am able to extract data into the ITAB. Now what changes should I make in transformation and in pgm to collect
    <G>, <H> in one internal table JTAB.
    <J>, <K> in one internal table KTAB.
    <J>, <N> in one internal table PTAB.
    Please help..i am really tring hard to figure this out. I am found lot of threads addressing this issue but not my problem.
    Kindly help.
    Regards,
    VS

    Hi Rammohan,
    Thanks for the effort!
    But I don't need to use GUI upload because my functionality does not require to fetch data from presentation server.
    Moreover, the split command advised by you contains separate fields...f1, f2, f3... and I cannot use it because I have 164 fields.  I will have to split into 164 fields and assign the values back to 164 fields in the work area/header line.
    Moreover I have about 10 such work areas.  so the effort would be ten times the above effort! I want to avoid this! Please help!
    I would be very grateful if you could provide an alternative solution.
    Thanks once again,
    Best Regards,
    Vinod.V

  • How to create xml file from relational tables in 10gR2

    Hi,
    I am very new to XML and was wondering how to create an XML file from querying relational tables. Some child tables may contain multiple rows that need to be returned in certain instances. Other queries will just be single or multiple rows from one or more tables. I would like to use the latest feathers in 10gR2. Thanks for any help you can provide.
    Thanks,
    Lee

    Here is the first row of data created from our person table - it used the column names as the tag names:
    <?xml version="1.0"?>
    <ROWSET>
         <ROW>
              <MP_ID_SEQ>289</MP_ID_SEQ>
              <MP_NAME>LOBERG,JUDITH LEE</MP_NAME>
              <MP_SEX>F</MP_SEX>
              <MP_RACE>I</MP_RACE>
              <MP_DOB>19500709</MP_DOB>
              <MP_HT>504</MP_HT>
              <MP_WT>170</MP_WT>
              <MP_EYE_CLR>BLU</MP_EYE_CLR>
              <MP_HAIR_CLR>BRO</MP_HAIR_CLR>
              <MP_SKN>RUD</MP_SKN>
              <MP_SMT>POCKMARKS</MP_SMT>
              <MP_SOC>517607968</MP_SOC>
              <MP_OLN>517607968</MP_OLN>
              <MP_OLS>MT</MP_OLS>
              <MP_OLY>2007</MP_OLY>
              <MP_CAUT_MED>70</MP_CAUT_MED>
              <MP_VISION_SCRIPT>C0RRECTIVE LENSES</MP_VISION_SCRIPT>
              <MP_DNA_AVAIL>N</MP_DNA_AVAIL>
              <CREATED_BY>MMPS</CREATED_BY>
              <DTM_CREATED>31-AUG-06</DTM_CREATED>
              <MI_INC_ID_SEQ>288</MI_INC_ID_SEQ>
              <MP_ALERT>N</MP_ALERT>
         </ROW>

  • Creating an xml file from abap code

    Hello All,
    Please let me know which FM do I need to execute in order to create an XML file from my ABAP code ?
    Thanks in advance,
    Paul.

    This has been discussed before
    XML files from ABAP programs

  • Upload an XML file into the Internal table

    Hi Guys,
    I want to know, how to upload an xml file into the Internal table through ABAP programming

    you just wanted to load the xml file into internal table (as a table of binary strings)or load the xml data mapped to itab row columns
    for the first one you can simply use gui_upload
    and for the second one you need to load the xml file using gui_upload and use XLST program to transform into an itab
    Regards
    Raja

  • Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the rows? Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
    Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    The Oracle documentation has a good overview of the options available
    Generating XML Data from the Database
    Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
    You can also find some information in XML DB FAQ

  • Reading XMl file from ABAP

    Hi friends,
    I am working in SAP 4.6c. Please help me in the following scenario.
    I have to read the xml whixjh in the application server.
    I have to Make sure each XML only contains 1 IDOC.  If 10 idocs are pushed out , there should be 10 XML messages.  1 idoc per XML.
    So if the FM receives a message that contains 10 idocs, the routine just needs to split the XML into 10 separate XML's using YYYYMMDDHHMMSS_IDOCNUMBER.XML as the new of each XML.
    Convert the XML into UTF-8 compliant
    above is my requirement.
    Can you guide me how to read a XMl file and findout how many idocs are present in that...
    Please guide me...
    Thanks in advance,
    Sudha

    Hi Sudha,
    Refer this blog and thread to get more information on how to process XML documents.
    /people/thomas.jung3/blog/2004/06/24/bsp-150-a-developer146s-journal-part-v-xml-for-rfcs
    redaing an XML file to an internal table
    Regards,
    Uma
    Message was edited by: Uma Maheswari

  • Creating XML file from Java Bean

    Hi
    Are there any standard methods in Java 1.5 to create XML file from java bean,
    i can use JAXB or castor to do so,
    But i would like to know if there is any thing in java core classes,
    I have seen XMLEncoder, but this is not what i want.
    Any ideas
    Ashish

    Marshall JavaBean to an XML document with JAXB or XMLBeans.

Maybe you are looking for

  • How do I move CS4 onto my new Mac?

    Hi, I have a student edition of CS4 on my Mac, I have just bought a new Mac and want to use it on there instead, how do I move it? or can I just re-use the initial install disc? Thanks

  • Change of structure of database table

    A custom database table has been created and is already in use by 10 programs. Now a new requirement has come to add a field i.e. a check box to the database table to be used by one of the 10 programs. Can we change the structure of the database tabl

  • Missing Parameter - Global Date Variable

    I am trying to use a global variable for a date in my interface. I have the variable declared on the schema of my staging area and when I refresh it it works fine. I put the variable as refresh followed by the interface in a package. When I run the p

  • Problem when installing Publisher : corrupted published_content_portlets.pt

    I've installed Publisher 6.4 under Linux RedHat and I have a problem : the file "published_content_portlets.pte" has some corrupted lines, like these : <PTPORTLETTEMPLATEARRAY> <!-- pcp_en.xml goes here --> <!-- new language starts here EN --> <PTOBJ

  • Elements 12 jpg photo upside down in collage

    I was in Elements 12, collage and photos were loaded upside down. How do I get them tio load right?