SRM 5.0 Invoice XML format

we are trying to send Invoice from the suppliers to SRM system using XI. We have found the XI message type and generated XML based on the fields that we are aware of. But when we send it to SRM,it creates a credit note. When we tried to post the credit note, it comes with an error "At least one PO reference is incorrect" and "No tax amount possible for non-taxable invoice". We have populated all the known fields. have any one experienced this issue?. Do anybody have the invoice format with some explainations for the tags or examples?
Your help will be much appreciated.
Regards
Arul

Hia
Even if this thread is realy old...
If you are using the extended Classic scenario you will never be able to create a invoice. There is an error in the source-code. We have modified our system, since then it works like a charm... We have opened an oss-call, so there should be a solution soon...
Best Regards
Stef

Similar Messages

  • Incorrect XML format for outbound binding

    Hi,
    I am in the process of configuring a scenario where we are sending PO's from SRM to XI in XML format and later we want these PO's in XML format to be sent to a vendor.  I am able to send the XML from SRM to XI, but I get the following error message (probably while sending the XML to the external application):
    Incorrect XML format for outbound binding , , NO_TO_SERVICE_NAME, MI_Order_CreateOrChangeVendorView_In, urn:poscenario:srm:xi:vendor
    Unable to find element OutboundBindingAttributes: Node DY1WebMethodsMI_Order_CreateOrChangeVendorView_Inurn:poscenario:srm:xi:vendor8f16f906899838c7a4b64634e8140706686c72620ed63ed28c12a634f905d0ce.
    You help will be highly appreciated.
    Regards,
    Ravinder Masuta

    Hi Tanja,
    Now I tried to use the XI channel and I become the same problems. Maybe me configure of the "Receiver Agreement" is wrong.
    sender-service      A1CLNT100
    receiver-service    A2CLNT100
    receiver-Interface: ORDERS.ORDERS05
    namespace:          urn:sap-com:document:sap:idoc:messages
    communication channel : IDOC
    But without the IDOC-channel I become this error message:
    OUTBOUND_BINDING_NOT_FOUND --- no Receiver Agreement found
    Regards
    Christoph

  • Customer Invoice in XML format

    Hi,
    One of our Customers ask us, if we can generate his invoices in xml format and send him.
    How we can make it ?
    We create invoices with vf01 or fb70.
    I now with EDI/Idoc and convert over a subsystem it is possible. But we don't work with inbound or outbound EDI messages.
    Maybe sombody have implemented already a similar solution.
    Thanks for you help
    Marcel

    Hello,
    If you want to send an Invoice in XML instead of a print/fax output, You can check for XSF output in SMARTFORMS.
    Hope this helps you.
    Best Regards, Murugesh AS

  • Regarding conversion of invoice in XML format

    Hi everyone,
    I am working on smartforms and i require smartforms and its output in XML format, if its possible then please let me know the procedure to transmit smartforms output in XML format. Please reply, its urgent.
    Thanks & Regards
    V.B.

    In transaction SE80 browse menu Workbench -> Edit Object. In the popup window enter XSLT Program name (e.g. ZXSLT) and click on create button.
    Enter the following code into the editor
    <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
    <!xsl:output encoding="utf-8" indent="yes"/>
    <xsl:template match="D2CXML">
    <PurchaseOrders>
    <xsl:apply-templates/>
    </PurchaseOrders>
    </xsl:template>
    <xsl:template match="item">
    <PONO>
    <xsl:attribute name="no">
    <xsl:value-of select="EBELN"/>
    </xsl:attribute> 1
    <PORDNO>
    <xsl:apply-templates select="EBELN"/>
    </PORDNO>
    <Vendor>
    <xsl:apply-templates select="LIFNR"/>
    </Vendor>
    <PurchaseOrg>
    <xsl:apply-templates select="EKORG"/>
    </PurchaseOrg>
    <PurchaseGrp>
    <xsl:apply-templates select="EKGRP"/>
    </PurchaseGrp>
    <xsl:apply-templates select="X-MLSTRUCT"/>
    </PONO>
    </xsl:template>
    <xsl:template match="X-MLSTRUCT">
    <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="X-MLSTRUCT/item">
    <Product>
    <ItemNo>
    <xsl:apply-templates select="EBELP"/>
    </ItemNo>
    <Material>
    <xsl:apply-templates select="MATNR"/>
    </Material>
    <Qty>
    <xsl:apply-templates select="MENGE"/>
    </Qty>
    <Price>
    <xsl:apply-templates select="NETPR"/>
    </Price>
    </Product>
    </xsl:template>
    </xsl:transform>
    Create Extraction Program
    Create a report program using ABAP Workbench and the code of the extracting program will be as follows.
    REPORT ZXML_EXTRACTION .
    - - - - - - - - - - DATA DECLARATION - - - - - - - - --*
    TYPE-POOLS: ABAP.
    TYPES: BEGIN OF TY_XML,
    EBELP TYPE STRING,
    MATNR TYPE STRING,
    MENGE TYPE STRING,
    NETPR TYPE STRING,
    END OF TY_XML.
    TYPES: BEGIN OF TY_FINAL_XML,
    EBELN TYPE STRING,
    EKORG TYPE EKKO-EKORG,
    EKGRP TYPE EKKO-EKGRP,
    LIFNR TYPE EKKO-LIFNR,
    XMLSTRUCT TYPE TY_XML,
    END OF TY_FINAL_XML.
    TYPES: BEGIN OF TY_EKPO,
    EBELN TYPE EKPO-EBELN,
    LIFNR TYPE EKKO-LIFNR,
    EKORG TYPE EKKO-EKORG,
    EKGRP TYPE EKKO-EKGRP,
    EBELP TYPE EKPO-EBELP,
    MATNR TYPE EKPO-MATNR,
    MENGE TYPE EKPO-MENGE,
    NETPR TYPE EKPO-NETPR,
    END OF TY_EKPO.
    TYPES: TY_TSRCLIN(1024) TYPE X,
    TY_TSRCTAB TYPE STANDARD TABLE OF TY_TSRCLIN.
    Global Data for XML Creation
    DATA: G_XML_STRING TYPE STRING,
    G_XML_STRING1 TYPE STRING,
    G_FILENAME TYPE STRING,
    G_PATH TYPE STRING,
    G_FULLPATH TYPE STRING,
    G_TITLE TYPE STRING,
    G_LEN TYPE I.
    DATA: G_XSLTP TYPE REF TO CL_XSLT_PROCESSOR,
    G_IXML TYPE REF TO IF_IXML,
    G_STREAM_FACTORY TYPE REF TO IF_IXML_STREAM_FACTORY,
    G_ENCODING TYPE REF TO IF_IXML_ENCODING,
    RESSTR TYPE REF TO IF_IXML_OSTREAM,
    HTTP_CLIENT TYPE REF TO IF_HTTP_CLIENT,
    G_SRCSTR TYPE REF TO IF_IXML_ISTREAM,
    G_GEN_EX TYPE REF TO CX_XSLT_EXCEPTION,
    G_MESSAGE TYPE STRING,
    G_PROGNAME TYPE CXSLTDESC VALUE 'ID'.
    Work Area
    DATA: WA_XML TYPE TY_XML,
    WA_EKPO TYPE TY_EKPO,
    WA_EKPO1 TYPE TY_EKPO,
    WA_SOURCE TYPE ABAP_TRANS_SRCBIND.
    DATA: BEGIN OF WA_FINAL_XML,
    EBELN TYPE STRING,
    LIFNR TYPE STRING,
    EKGRP TYPE STRING,
    EKORG TYPE STRING,
    XMLSTRUCT TYPE TABLE OF TY_XML,
    END OF WA_FINAL_XML.
    INTERNAL TABLES
    DATA: T_XML TYPE TABLE OF TY_XML,
    T_FINAL_XML LIKE TABLE OF WA_FINAL_XML,
    T_EKPO TYPE TABLE OF TY_EKPO,
    T_SOURCE TYPE ABAP_TRANS_SRCBIND_TAB,
    T_SRCTAB TYPE TY_TSRCTAB.
    - - - - - - - - - - SELECTION-SCREEN - - - - - - - - - - - - - - *
    ---Select options/Parameters--
    SELECTION-SCREEN BEGIN OF BLOCK DOWNLOAD
    WITH FRAME TITLE TEXT-002.
    PARAMETERS: P_COMP TYPE CHAR1 AS CHECKBOX.
    PARAMETERS: P_FILE TYPE RLGRAP-FILENAME.
    SELECTION-SCREEN END OF BLOCK DOWNLOAD.
    AT SELECTION-SCREEN.
    IF NOT P_COMP IS INITIAL AND
    P_FILE IS INITIAL.
    MESSAGE E000(38) WITH 'Please enter the file name'(E01).
    ENDIF.
    IF NOT P_COMP IS INITIAL AND
    NOT P_FILE IS INITIAL.
    TRANSLATE P_FILE TO UPPER CASE.
    G_LEN = STRLEN( P_FILE ) - 4.
    IF P_FILE+G_LEN(4) NE '.XML'.
    MESSAGE E000(38) WITH 'Please use the extension as .XML'(E02).
    ENDIF.
    ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
    G_TITLE = 'Result Document'(I01).
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
    EXPORTING
    WINDOW_TITLE = G_TITLE
    FILE_FILTER = '*.XML'
    CHANGING
    FILENAME = G_FILENAME
    PATH = G_PATH
    FULLPATH = G_FULLPATH.
    IF SY-SUBRC = 0.
    P_FILE = G_FULLPATH.
    ENDIF.
    - - - - - - - - - - LOGIC SECTION - - - - - - - - - - - - *
    START-OF-SELECTION.
    PERFORM CLEAR_VARIABLES.
    PERFORM START_SELECTION.
    END-OF-SELECTION.
    WA_FINAL_XML-XMLSTRUCT[] = T_XML[].
    APPEND WA_FINAL_XML TO T_FINAL_XML.
    PERFORM CREATE_XML.
    IF NOT P_COMP IS INITIAL.
    PERFORM DOWNLOAD_FILE.
    ENDIF.
    *& Form START_SELECTION
    Select all the Guids
    FORM START_SELECTION .
    SELECT HEBELN HLIFNR HEKORG HEKGRP
    IEBELP IMENGE INETPR IMATNR
    INTO CORRESPONDING FIELDS OF TABLE T_EKPO
    FROM EKKO AS H INNER JOIN EKPO AS I
    ON HEBELN = IEBELN.
    LOOP AT T_EKPO INTO WA_EKPO.
    WA_EKPO1 = WA_EKPO.
    AT NEW EBELN.
    REFRESH T_XML.
    CLEAR WA_XML.
    WA_FINAL_XML-EBELN = WA_EKPO-EBELN.
    WA_FINAL_XML-LIFNR = WA_EKPO1-LIFNR.
    WA_FINAL_XML-EKORG = WA_EKPO1-EKORG.
    WA_FINAL_XML-EKGRP = WA_EKPO1-EKGRP.
    ENDAT.
    MOVE-CORRESPONDING WA_EKPO TO WA_XML.
    APPEND WA_XML TO T_XML.
    AT END OF EBELN.
    WA_FINAL_XML-XMLSTRUCT[] = T_XML[].
    APPEND WA_FINAL_XML TO T_FINAL_XML.
    ENDAT.
    ENDLOOP.
    ENDFORM. " START_SELECTION
    *& Form CREATE_XML
    Create XML
    FORM CREATE_XML .
    Prepare for Transformation
    WA_SOURCE-NAME = 'D2CXML'.
    GET REFERENCE OF T_FINAL_XML INTO WA_SOURCE-VALUE.
    APPEND WA_SOURCE TO T_SOURCE.
    CLEAR G_XML_STRING.
    CALL TRANSFORMATION ZXSLT
    SOURCE (T_SOURCE)
    RESULT XML G_XML_STRING.
    IF SY-SUBRC <> 0.
    ELSE.
    G_XML_STRING1 = G_XML_STRING.
    REPLACE 'utf-16' WITH 'utf-8' INTO G_XML_STRING.
    ENDIF.
    ENDFORM. " CREATE_XML
    *& Form DOWNLOAD_FILE
    Download the XML into a file
    FORM DOWNLOAD_FILE .
    Local Data
    DATA: L_FILENAME TYPE STRING.
    TRY.
    CREATE OBJECT G_XSLTP.
    CATCH CX_XSLT_EXCEPTION.
    ENDTRY.
    G_IXML = CL_IXML=>CREATE( ).
    G_STREAM_FACTORY = G_IXML->CREATE_STREAM_FACTORY( ).
    G_SRCSTR = G_STREAM_FACTORY->CREATE_ISTREAM_CSTRING(
    STRING = G_XML_STRING1 ).
    XML source is specified by stream
    CALL METHOD G_XSLTP->SET_SOURCE_STREAM
    EXPORTING
    STREAM = G_SRCSTR.
    CALL METHOD G_XSLTP->SET_RESULT_TABLE
    EXPORTING
    TABLE = T_SRCTAB.
    RUN
    TRY.
    CALL METHOD G_XSLTP->RUN
    EXPORTING
    PROGNAME = G_PROGNAME.
    CATCH CX_XSLT_EXCEPTION INTO G_GEN_EX.
    G_XML_STRING = G_GEN_EX->GET_TEXT( ).
    ENDTRY.
    L_FILENAME = P_FILE.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    FILENAME = L_FILENAME
    FILETYPE = 'BIN'
    TABLES
    DATA_TAB = T_SRCTAB.
    IF SY-SUBRC = 0.
    G_MESSAGE = 'File downloaded successfully'(I03).
    ELSE.
    G_MESSAGE = 'Error in downloading file'(I04).
    ENDIF.
    MESSAGE I000(38) WITH G_MESSAGE.
    ENDFORM. " DOWNLOAD_FILE
    *& Form CLEAR_VARIABLES
    Clear the values of Global Variables
    FORM CLEAR_VARIABLES .
    CLEAR: G_TITLE,
    G_FILENAME,
    G_PATH,
    G_FULLPATH,
    G_LEN,
    G_SRCSTR,
    Work Areas
    WA_SOURCE,
    WA_XML,
    WA_FINAL_XML.
    REFRESH: T_XML,
    T_SOURCE,
    T_SRCTAB,
    T_FINAL_XML.
    ENDFORM. " CLEAR_VARIABLES
    Edited by: Minal Nampalliwar on Jan 21, 2008 6:44 AM

  • SRM Classic Scenario & Invoicing Service Purchase Orders through SUS

    Hi everyone,
    I hope I am able to provide enough information to ask this question.  We are running SRM Classic Scenario in addition to SUS.  We would like to be able to have our Vendors login to SUS and Invoice us.  However, we are being told that in order to do this we will need to install EHP4.  We are currently running ECC 6.  Could someone help me understand what it is exactly that we are not able to do this as is?   I understand that we are able to configure our current system setup to process Material related Invoices but not Services related invoices.
    Thanks for your help.

    Hi Jellis,
    Your vendors can send invoice from SUS but only for material POs (As you are not running ECC 6 with Ehp 4)
    If you want the vendors to send you invoice for service POs also, then you need to go with Ehp 4 as service POs are not supported in SUS using IDOC technology. They need to be in XML format only.
    Regards,
    Nikhil

  • Smartforms output in XML format

    Hi everyone,
    I am very new for smartforms and my requirement to convrt given smartform in XML format, I am going through
    Form Attributes -> output options -> output format -> XSF output , then I am giving proper value in output mode & in Output Device but not getting proper output, can You please  tell me what i have to do (in Detail ) ?
    Thanks & Regards,
    Vimarsh B.

    Hi Abhinay
    I have billing order invoice, client is getting its output in standard format but now he needs the output of that form has to come in XML format, if we are using standard output format in form attributes, its showing output but when  we are chenging its option we are not getting any output, only one spool create, and we are not able to understand what exactly output will come, it will come same like standard format or only spool will create and if only spool create then how we can send it to our client. please solve this issue, thanks for ur support.
    Thanks & Regards,
    Vimarsh B.

  • [PENTAHO] export design into xml format

    Hi all,
    I wonder if it's possible to create a design with reportDesigner, export the design to an xml format and then use this xml format file to create a report. For example, in the HelloWorld demo you have to create the necessary code to make a report. However, in the invoice demo you have an xml file in wich you have the structure description of the report and you can use it to make the report without writing all the code.
    Thanks a lot!

    my questionWhat question?
    This is why I wrote my question inWhat question?
    So, Does anyone knows the answer to my question?What question?
    There is no question in what you have posted.
    If your question is about reportDesigner, whatever that is, this is the wrong forum and the wrong site.

  • I am creating a form on LiveCycle Designer and I am trying to create a form that has a e-mail submit button.  When the butten is utilized it attaches the form to the e-mail in an plain text .xml format rather than the pdf format.  Is there a quick fix?

    I am creating a form on LiveCycle Designer and I am trying to create a form that has a e-mail submit button.  When the button is utilized it attaches the form to the e-mail in an plain text .xml format rather than the pdf format.  Is there a quick fix?

    Hi,
    You have the choice between xml or pdf, in later versions of designer you can choose with a dropdown on the email button Object palette, the "Submit As";
    In earlier version you had to edit the XML Source and change the format from xml to pdf (or vice-versa);
    Regards
    Bruce

  • How to generate Campaign details in XML format for sending to downstream sy

    Dear gurus,
    we have a requirement to send the Campaign details from CRM to some Downstream system in the XML format through PI interfaces. We want to include the following campaign details in the structure.
    <SAPTOAL DATE="03-MAR-2011" TIME="13:25pm">
          <CAMPAIGN>
                <ID></ID>
                <NAME></NAME>
                <RUNDATE></RUNDATE>
                <RUNTIME></RUNTIME>
                <STARTDATE></STARTDATE>
                <ENDDATE></ENDDATE>
                <RECORDCOUNT></RECORDCOUNT>
          </CAMPAIGN>
          <TARGETGROUP>
                <ID></ID>
                <NAME></NAME>
    </TARGETGROUP>
          <BUSINESSPARTNERS>
                <BUSINESSPARTNER>
                      <ID>001</ID>
                <TARGETGROUPID></TARGETGROUPID>
                <FIRSTNAME></FIRSTNAME>
                      <LASTNAME></LASTNAME>
                      <TITLE></TITLE>
                      <SUFFIX></SUFFIX>
                      <EMAIL></EMAIL>
                      <REPFIRSTNAME></REPFIRSTNAME>
                      <REPLASTNAME></REPLASTNAME>
                      <REPPHONE></REPPHONE>
                      <REPSIGNATUREURL></REPSIGNATUREURL>
                      <REPPICTUREURL></REPPICTUREURL>
                      <REPEMAIL></REPEMAIL>
                </BUSINESSPARTNER>
                <BUSINESSPARTNER>
                      <ID>002</ID>
                <TARGETGROUPID></TARGETGROUPID>
                      <FIRSTNAME></FIRSTNAME>
                      <LASTNAME></LASTNAME>
                      <TITLE></TITLE>
                      <SUFFIX></SUFFIX>
                      <EMAIL></EMAIL>
                      <REPFIRSTNAME></REPFIRSTNAME>
                      <REPLASTNAME></REPLASTNAME>
                      <REPPHONE></REPPHONE>
                      <REPSIGNATUREURL></REPSIGNATUREURL>
                      <REPPICTUREURL></REPPICTUREURL>
                      <REPEMAIL></REPEMAIL>
                </BUSINESSPARTNER>
          </BUSINESSPARTNERS>
    </SAPTOAL>
    We have already tried the following things in SPRO.
    CRM --> Marketing --> Marketing Planning and Campaign Management --> Campaign Execution --> Define File Export Variants
    But with this we were not able to get the full XML structure, as required above. We got only this much.
    <?xml version="1.0" encoding="utf-8" ?>
    <DATA>
    <ITEM>
       <Field_1>Test Email.</Field_1>
       <Field_2>Test Email.</Field_2>
       <Field_3>ABC Company.</Field_31>
    </ITEM>
    </DATA>
    Any pointers or help on this will he greatly appreciated.rgrds,
    Randhir Soni

    Hi Prabhu,
    The program SAPFPAYM generates the payment Medium  on the basis of your configuration and background settings, this program does not bydefault give the output in the XML.
    Varient creation for the PMW in T. Code OBPM4, use the same program, which i already done it, even without this it is not be possible to create any payment Medium.
    Regards,
    Rony

  • Concurrent request submission displays Output in xml format ?

    Hi ,
    I am submitting a concurrent request from workflow which is an xml publisher report . my problem when the program is run individually it displays the output correctly in rtf format but when the same request is submitted from worklfow the output comes in xml format ?
    What could be the problem ?
    I am using the standard submission "FND_WF_STANDARD.SUBMITCONCPROGRAM " program and assigning the values directly to it . the submission activity is working fine but the output comes as mentioned above.
    Regards,
    Skg

    Kiran ,
    I am not using fnd_request.submit request coc I don't need to capture the user information for my workflow .
    I am only using the standard " FND_WF_STANDARD.SUBMITCONCPROGRAM " . this Package only submits the concurrent program through workflow in a function.
    no need of backend programming.
    My job is to submit and move to the next function . the output will be determined via custom profile option.
    now, for this package I am directly assigning the values like appshort name , prog shrt name , and parameter.
    there is no mention of layouts anywhere in the standard workflow package .
    its very urgent for me friend.
    Regards,
    Shashank.

  • Problem with getting a D2K report in XML format

    Hi all,
    Could any body give a solution for this problem.
    I have a matrix report like following:
    Q_Statement_Of_Net_Assets ----> main query
    |
    G_Cross ----> Cross product
    | CS_VALUE
    | CS_NET_ASSET
    | CF_COSTI
    |
    | --------------------------------- |
    | | G_CTIF | | ------> Like this I have two more groups
    | --------------------------------- |
    ...... |
    -----------------------------------------------|
    My requirement is i want to print CS_VALUE, CS_NET_ASSET, CF_COSTI values in XML report, these values i am getting in a Normal/RTF format reports.
    But i am not getting in XML format report.
    thanks in advance.
    Vasu

    Thanks Schellyc
    actually I want to creat a new SOAPMessage for the very beginning like this:
    try{
                MessageFactory mf = MessageFactory.newInstance();
                SOAPMessage msg = mf.createMessage();
                SOAPPart sp = msg.getSOAPPart();
                //create the header container
                SOAPEnvelope se = sp.getEnvelope();
                SOAPHeader sh = se.getHeader();
                SOAPBody sb = se.getBody();
            }catch(Throwable e) {
                e.printStackTrace();
            }and I want to get the empty header from this newly created SOAPEnvelop and add my own content into the header as well as the empty body.
    I wrote the code by following the example from the jaxm api.
    can anybody tell me any further information about the NullPointerException?

  • Data is not converting in XML format in output while download in report

    Hi All,     While downloading the report in XML format value '&' is not changing its XML format '&amp', but showing in debug mode and sam thing while download its not showing in output. showing in debug like; MS NA - DCS Tooling & Automation but in output showing the data like:  MS NA - DCS Tooling & Automation because of this getting issue. Please help me out . Thanks and Regards Sankil

    In that case, it is correct.
    Try replacing & with &amp; before downloading xml in case you want & to appear as &amp; in web browser view.

  • How can I convert IDoc in XML format w/DTD into a string?

    I want to send by e-mail outbound IDoc in XML format with its document type definition (DTD).
    I want to be able to get the same output result into a string than the XML file IDoc port type with DTD activated.  I have created a FM (based on SAP "OWN_FUNCTION") assigned to an IDoc port of type ABAP-PI that executes the following processing steps:
    1-Extract outbound IDoc information to get the sender & recipient mail addresses (EDP13 / EDIPHONE tables).
    2-Convert & Transform IDoc data into XML string using FM IDX_IDOC_TO_XML.
    3-Prepare and send e-mail with XML attachement using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
    I cand generate the e-mail with the XML file attachement but FM IDX_IDOC_TO_XML does not convert the IDoc with proper formating and DTD.
    What should I use to accomplish the IDoc conversion to XML w/DTD into a string?
    Should I use XSLT tools ?
    How does that work?
    Thank you
    Carl

    muks wrote:
    Use decimal string to number
    Specifically, you can define a constant with a different datatype on the input on the lower left if you need a different datatype (e.g. U8, I64, DBL, etc) Are all your values integers or do you also need to scan fractional numbers? In this case, you should use "fract/exp string to number" instead.
    LabVIEW Champion . Do more with less code and in less time .

  • How to get the metadata (in xml format) of all the fileds in SQl query ?

    Good day ,
    I am using the dbms_xmlgen.getXMLfunction to get the result of any query in xml format.
    With this XML I also want the metadata information about all the fields used in the query (passed to getXML function). Is it possible and how can I achieve this.
    I tried to Google it but couldn't find any solution , it's easy to do it in java where I can get the resultset meta data from the resultset but I have to do it in Oracle function since I want the result in xml format and want to use the oracle XML API.
    You may think why I need metadata , the reason is the application will later use this information to sort the data contained in these fields according to their data type provided to.
    Regards
    Sajjad Ahmed Paracha

    Hi,
    Please always say which version of Oracle you're using (SELECT * FROM v$version).
    With this XML I also want the metadata information about all the fields used in the query (passed to getXML function). Is it possible and how can I achieve this.It is possible but with a bit of effort.
    I would use DBMS_SQL utility to parse the query, extract each column's description and then build a METADATA element with the required information.
    Here's an example (11g) :
    DECLARE
      v_query      varchar2(30) := 'select * from scott.emp';
      v_cur        integer;
      v_desc_tab   dbms_sql.desc_tab;
      v_col_cnt    number;
      v_col_lst    varchar2(4000);
      v_xml_query  varchar2(32767);
      xml_metadata_coll xmlsequencetype := xmlsequencetype();
      xml_metadata      xmltype;
      res          clob;
    BEGIN
      v_cur := dbms_sql.open_cursor;
      dbms_sql.parse(v_cur, v_query, dbms_sql.native);
      dbms_sql.describe_columns(v_cur, v_col_cnt, v_desc_tab);
      dbms_sql.close_cursor(v_cur);
      for i in 1 .. v_col_cnt loop
        if i > 1 then
          v_col_lst := v_col_lst || ', ';
        end if;
        v_col_lst := v_col_lst || v_desc_tab(i).col_name;
        xml_metadata_coll.extend;
        select xmlelement("COLUMN"
               , xmlattributes(v_desc_tab(i).col_name as "name")
               , xmlforest(
                   case v_desc_tab(i).col_type
                     when 1   then 'VARCHAR2'
                     when 2   then 'NUMBER'
                     when 12  then 'DATE'
                     when 180 then 'TIMESTAMP'
                     else 'UNKNOWN'
                   end as "DATATYPE"
                 , v_desc_tab(i).col_max_len as "MAX_LENGTH"
                 , v_desc_tab(i).col_precision as "PRECISION"
                 , v_desc_tab(i).col_scale as "SCALE"
        into xml_metadata_coll(i)
        from dual;
      end loop;
      v_xml_query :=
    'SELECT XMLSerialize(document
             XMLElement("ROOT"
             , :1
             , XMLElement("ROWSET"
               , XMLAgg(
                   XMLElement("ROW", XMLForest(' || v_col_lst || '))
             ) as clob indent
    FROM ( ' || v_query || ')';
      select xmlelement("METADATA", xmlagg(column_value))
      into xml_metadata
      from table(xml_metadata_coll)
      execute immediate v_xml_query into res using xml_metadata;
      dbms_output.put_line(res);
    END;
    /Ouput :
    <ROOT>
      <METADATA>
        <COLUMN name="EMPNO">
          <DATATYPE>NUMBER</DATATYPE>
          <MAX_LENGTH>22</MAX_LENGTH>
          <PRECISION>4</PRECISION>
          <SCALE>0</SCALE>
        </COLUMN>
        <COLUMN name="ENAME">
          <DATATYPE>VARCHAR2</DATATYPE>
          <MAX_LENGTH>10</MAX_LENGTH>
          <PRECISION>0</PRECISION>
          <SCALE>0</SCALE>
        </COLUMN>
        <COLUMN name="JOB">
          <DATATYPE>VARCHAR2</DATATYPE>
          <MAX_LENGTH>9</MAX_LENGTH>
          <PRECISION>0</PRECISION>
          <SCALE>0</SCALE>
        </COLUMN>
        <COLUMN name="MGR">
          <DATATYPE>NUMBER</DATATYPE>
          <MAX_LENGTH>22</MAX_LENGTH>
          <PRECISION>4</PRECISION>
          <SCALE>0</SCALE>
        </COLUMN>
        <COLUMN name="HIREDATE">
          <DATATYPE>DATE</DATATYPE>
          <MAX_LENGTH>7</MAX_LENGTH>
          <PRECISION>0</PRECISION>
          <SCALE>0</SCALE>
        </COLUMN>
        <COLUMN name="SAL">
          <DATATYPE>NUMBER</DATATYPE>
          <MAX_LENGTH>22</MAX_LENGTH>
          <PRECISION>7</PRECISION>
          <SCALE>2</SCALE>
        </COLUMN>
        <COLUMN name="COMM">
          <DATATYPE>NUMBER</DATATYPE>
          <MAX_LENGTH>22</MAX_LENGTH>
          <PRECISION>7</PRECISION>
          <SCALE>2</SCALE>
        </COLUMN>
        <COLUMN name="DEPTNO">
          <DATATYPE>NUMBER</DATATYPE>
          <MAX_LENGTH>22</MAX_LENGTH>
          <PRECISION>2</PRECISION>
          <SCALE>0</SCALE>
        </COLUMN>
      </METADATA>
      <ROWSET>
        <ROW>
          <EMPNO>7369</EMPNO>
          <ENAME>SMITH</ENAME>
          <JOB>CLERK</JOB>
          <MGR>7902</MGR>
          <HIREDATE>1980-12-17</HIREDATE>
          <SAL>800</SAL>
          <DEPTNO>20</DEPTNO>
        </ROW>
        <ROW>
          <EMPNO>7499</EMPNO>
          <ENAME>ALLEN</ENAME>
          <JOB>SALESMAN</JOB>
          <MGR>7698</MGR>
          <HIREDATE>1981-02-20</HIREDATE>
          <SAL>1600</SAL>
          <COMM>300</COMM>
          <DEPTNO>30</DEPTNO>
        </ROW>
        <ROW>
          <EMPNO>7521</EMPNO>
          <ENAME>WARD</ENAME>
          <JOB>SALESMAN</JOB>
          <MGR>7698</MGR>
          <HIREDATE>1981-02-22</HIREDATE>
          <SAL>1250</SAL>
          <COMM>500</COMM>
          <DEPTNO>30</DEPTNO>
        </ROW>
        <ROW>
          <EMPNO>7566</EMPNO>
          <ENAME>JONES</ENAME>
          <JOB>MANAGER</JOB>
          <MGR>7839</MGR>
          <HIREDATE>1981-04-02</HIREDATE>
          <SAL>2975</SAL>
          <DEPTNO>20</DEPTNO>
        </ROW>
        <ROW>
          <EMPNO>7654</EMPNO>
          <ENAME>MARTIN</ENAME>
          <JOB>SALESMAN</JOB>
          <MGR>7698</MGR>
          <HIREDATE>1981-09-28</HIREDATE>
          <SAL>1250</SAL>
          <COMM>1400</COMM>
          <DEPTNO>30</DEPTNO>
        </ROW>
        <ROW>
          <EMPNO>7698</EMPNO>
          <ENAME>BLAKE</ENAME>
          <JOB>MANAGER</JOB>
          <MGR>7839</MGR>
          <HIREDATE>1981-05-01</HIREDATE>
          <SAL>2850</SAL>
          <DEPTNO>30</DEPTNO>
        </ROW>
        <ROW>
          <EMPNO>7782</EMPNO>
          <ENAME>CLARK</ENAME>
          <JOB>MANAGER</JOB>
          <MGR>7839</MGR>
          <HIREDATE>1981-06-09</HIREDATE>
          <SAL>2450</SAL>
          <DEPTNO>10</DEPTNO>
        </ROW>
        <ROW>
          <EMPNO>7839</EMPNO>
          <ENAME>KING</ENAME>
          <JOB>PRESIDENT</JOB>
          <HIREDATE>1981-11-17</HIREDATE>
          <SAL>5000</SAL>
          <DEPTNO>10</DEPTNO>
        </ROW>
        <ROW>
          <EMPNO>7844</EMPNO>
          <ENAME>TURNER</ENAME>
          <JOB>SALESMAN</JOB>
          <MGR>7698</MGR>
          <HIREDATE>1981-09-08</HIREDATE>
          <SAL>1500</SAL>
          <COMM>0</COMM>
          <DEPTNO>30</DEPTNO>
        </ROW>
        <ROW>
          <EMPNO>7900</EMPNO>
          <ENAME>JAMES</ENAME>
          <JOB>CLERK</JOB>
          <MGR>7698</MGR>
          <HIREDATE>1981-12-03</HIREDATE>
          <SAL>950</SAL>
          <DEPTNO>30</DEPTNO>
        </ROW>
        <ROW>
          <EMPNO>7902</EMPNO>
          <ENAME>FORD</ENAME>
          <JOB>ANALYST</JOB>
          <MGR>7566</MGR>
          <HIREDATE>1981-12-03</HIREDATE>
          <SAL>3000</SAL>
          <DEPTNO>20</DEPTNO>
        </ROW>
        <ROW>
          <EMPNO>7934</EMPNO>
          <ENAME>MILLER</ENAME>
          <JOB>CLERK</JOB>
          <MGR>7782</MGR>
          <HIREDATE>1982-01-23</HIREDATE>
          <SAL>1300</SAL>
          <DEPTNO>10</DEPTNO>
        </ROW>
      </ROWSET>
    </ROOT>A couple of comments :
    <li> I handle only four datatypes here (VARCHAR2, NUMBER, DATE, TIMESTAMP). Of course you can add more.
    The list of Oracle Type Number is available here : http://docs.oracle.com/cd/E11882_01/server.112/e26088/sql_elements001.htm#i54330
    Starting with 11g (not sure which release), DBMS_SQL package also declares these numbers through named constants.
    <li> I don't use DBMS_XMLGEN in this example. Instead I rebuild the query using SQL/XML functions and the list of columns that's just been described.

  • Customization of DAC to send emails in XML format

    Hi,
    We need to customize DAC to send emails in XML format to the support team whenever there is a failure of the ETL load.
    We use the HPSC ticketing system.
    Any help to achieve this functionality is much appreciated.
    we have tried to customize the existing email template of DAC, but it is not serving the purpose to generate the ticket in HPSC.
    To generate the HPSC ticket, we have a XML format. We need to customize DAC to use this format.
    This is the version of Oracle BI application we are using:
    Build: 10.1.3.2.1.070411.1900
    Release Version: Oracle Business Intelligence 10.1.3.2.1
    Package: 070411.1900
    Build: 7.9.1.032307.0900
    Release Version: Oracle Business Intelligence Applications 7.9.1
    Package: 032307.0900
    Regards,

    Hi,
    We have raised a SR with Oracle support and are in touch with Engineering also today onwards. However, would like to try out options while waiting for a solution/workaround for this issue.
    Regards,

Maybe you are looking for