XMLDOM and CDATA

Guru's,
I have a requirement using PL/SQL whereby I need to store more that 32K bytes of HTML in an XML Element. Since the content is HTML, it seems to me that I have to use the CDATA method of XMLDOM
(for example item_node := xmldom.appendChild(item_node, xmldom.makeNode(xmldom.createCDATASection(doc, p_bodycopy)));)
My issue is that the createCDATASection can only handle a VARCHAR2, and I require it to handle (at most) 64K of information.
I can use the AppendData procedure w/ Character data, but that creates decode,translation and transformation issues.
Is there any light at the end of this tunnel? or should I punt.
The following works very well for everything <= 32K
item_elmt := xmldom.createElement(doc, 'BodyCopy');
item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_elmt));
item_node := xmldom.appendChild(item_node, xmldom.makeNode(xmldom.createCDATASection(doc, p_bodycopy)));
I am looking for a solution for content >32K
Any insight is much appreciated.
-Scot

Hi Scot. Unfortunately most of the xml packages and functions are brain dead when it comes to handling large data. Most are implicitly tied to varchar limits and lob limitations in PL/SQL.
To get a CDATA element exactly as you describe, I think you need to resort to building it up from 1st principles using lob methods.
e.g.
declare
v_lob clob;
v_lob_temp clob;
begin
v_lob := '<FamilyHistory><![CDATA[';
select x.bigdata into v_lob_temp from x1 x where x.item='mysample';
DBMS_LOB.APPEND(v_lob, v_lob_temp );
DBMS_LOB.APPEND(v_lob, ']]></FamilyHistory>');
insert into x2 values('mysample',v_lob);
end;
There is an approach using xmltype views based on object types, but these will implicitly xml encode your clob rather than quote it as CDATA (and I don't know a way to prevent this).
e.g.
CREATE TABLE x1 (item varchar(25) primary key, bigdata clob);
-- (insert a very large record)
CREATE OR REPLACE TYPE x1_t AS OBJECT
(Holder varchar(25),BookData CLOB);
CREATE OR REPLACE VIEW vx1 OF XMLTYPE
WITH OBJECT ID (ExtractValue(sys_nc_rowinfo$, '/ROW/HOLDER')) AS
SELECT sys_XMLGen(x1_t(x.item, x.bigdata)) from x1 x;
Here's a sample entry:
SELECT
     extractvalue(x.SYS_NC_ROWINFO$,'/ROW/HOLDER') as holder
     ,'xml_length: ' || dbms_lob.getlength(x.SYS_NC_ROWINFO$.getclobval()) as xml_length
FROM vx1 x;
HOLDER XML_LENGTH
mysample xml_length: 324198
Note sql*plus has a problem querying this:
SQL> select * from vx1;
ERROR:
OCI-31167: XML nodes over 64K in size cannot be inserted
Unless we just go for the clob. In this example the "BOOKDATA" is pure unencoded XML in table X1, but automatically encoded in the xmltype view vx1:
SQL> set long 200
SQL> select (SYS_NC_ROWINFO$).GETCLOBVAL() from vx1;
(SYS_NC_ROWINFO$).GETCLOBVAL()
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;ROW&gt;
&lt;HOLDER&gt;mysample&lt;/HOLDER&gt;
&lt;BOOKDATA&gt;&amp;lt;books&amp;gt;
&amp;lt;book id=&amp;quot;1&amp;quot;&amp;gt;
&amp;lt;title&amp;gt;the book 1 title&amp;lt;/title&amp;gt;
&amp;lt;/book&amp;gt;
&amp;lt;book id=&amp;quot;2&amp;qu

Similar Messages

  • XMLDOM and XMLPARSER

    Hello All,
    In one of my oracle 9.2.0.1 installations, The XMLDOM and XMLPARSER packages belongong to the SYS user are missing. Does anybody have any thoughts what might be the issue?
    The initial installation was not done by me hence I don't know the selection of edition and other options, if any.

    You need to install XML DB.
    http://www.lc.leidenuniv.nl/awcourse/oracle/appdev.920/a96620/appaman.htmhttp://www.lc.leidenuniv.nl/awcourse/oracle/appdev.920/a96620/appaman.htm

  • Differences between XMLDOM and DBMS_XMLDOM packages

    Hi all,
    Anybody could tell me if exists any differences between XMLDOM and DBMS_XMLDOM packages. Which are these?
    I have Oracle9i Enterprise Edition Release 9.2.0.3.0
    Thanks.

    hi,
    Can you check this
    Document TitleORA-1031 when setting Attribute via DBMS_SESSION SET_CONTEXT (Doc ID 100130.1)
    thanks,
    baskar.l

  • CREATING XML TAG W/SPACES and CDATA.  EXPORTED FROM PDF BUTTON

    Hello All,
    I was wondering if anyone could help with the following when working with livecycle Designer.
    In our current XML we use in production we have a tag that looks like
    a.       <action function='Form1650' method='Add' and Action 'Upload' />
    How do I go about making a field like this? I tried creating a text field and making in invisible and that’s fine and all BUT  when I go to make the binding name for the field it won’t let me put spaces in for the (function='Form1650' method='Add' and Action 'Upload') portion of the tag.
    2)      We currently use CDATA in our XML file to allow users to enter free form data w/ special characters like (<, &, etc) and not have our application crash. I noticed when using a exporting button in a pdf to generate a XML file it takes tags like < and converts to &lt.  Is there a way to have PDFs use CDATA embedded in the XML tag on output or some other solution?

    >when working with livecycle Designer
    This is the Acrobat forum... you need to find the forum for livecycle Designer

  • Java classgen and CDATA

    Hello,
    I am using the java classgen package to generate xml documents on the fly, and I want to include an ELEMENT, which contains CDATA. So, I have defined the element in the DTD as
    <!ELEMENT VALUE (#PCDATA)>
    When using the addData() method from the oracle.xml.classgen.CGNode class and the isValidating attribute is true, the xml generator complains about markup symbols even though I am enclosing the data within the <![CDATA[]]> construct.
    VALUE.addData("<![CDATA["+str+"]]>");
    When the validation is off, the xml generator seems to parse and modify the contents of the data (i.e. replaces < by &#60;)
    The XMLParser seems to understand the CDATA construct correctly.
    Could anybody please help me to get this straight?
    I will really appreciate some insights.

    In each of the generated classes, there is an addCDATASection() method which allows you to create CDATA inside an element.
    On the other hand, I have tried using the addData() method to create PCDATA with (ampersand)amp; (ampersand)lt; etc. to replace the characters & <, but it doesn't seem to work.
    If you have other experiences with classgen, please let me know. I'm using classgen v1.0.2.
    Thanks.

  • SOAP and CDATA xmlnode 64k limit

    Hi,
    Version: 10.2.0.1.0.
    I have this situation. I have an xml that I am passing as a message body in a SOAP request. Since my message is an xml, we are passing it in the CDATA tag.
    Now, this xml itself is more than 64k. But, when I put it as a CDATA tag , then, it is giving me a more than 64k error.ORA-31167: XML nodes over 64K in size cannot be inserted.
    What could be the workaround for this size restriction so that I can send the XML as a message in the SOAP request?
    I hope I am clear in asking the question.
    Thank you.

    There is no work around for this problem. In 10gR2 and earlier a text node cannot be larger than 64k. This will be addressed in the next release of the data base. If you are interested in being part of the beta program please register at the following URL.
    http://otnbeta.oracle.com/bpo/prospects/index.htm.
    In you case pain is somewhat self inflicted. Why are you making the payload of your message a CDATA section. Why not simply have a single XML document that consists of the SOAP headers and the content. Doing so would avoid the problem as long as none of the text nodes in your payload exceed the 64K limit.

  • Flash and CDATA

    Hi there.
    I load a text from an xml file which has a code like this:
    <?xml version="1.0" encoding="utf-8"?><xml>
    <content>
    <description><![CDATA[<br><br>
    <font color="#FFFFFF" size="20" style="font-family:Calibri">PROFILE</font><br><br><p align="justify"><font color="#FFFFFF"  size="15"><i>My company in italics  </i></font>
    <font color="#ffffff" style="font-family:Calibri" size="15"><b>my Company in bold</b></font>
    <br><br>
    <font color="#FFFFFF"  size="15" style="font-family:Calibri"my Company name with another font family </font><br><br>
    link<br><br></p>
    <br><br>
    <font color="#FFFFFF" size="15">
    <p align='right'><font color="#FFFFFF" size="20">mailto link</font></p></font>]]></description>
    </content>
    </xml>
    When i change the font size and font color i get the result i want.
    But when i try to change the font-family, or to make a part of text in italics or bold i fail to get what i want.
    I also tried this:
    <font style="font-style:italic">my text</font>
    with no success
    What should i do?
    Thank you in advance

    function loadContentText () {
        var cont:XML = new XML ();
        cont.ignoreWhite = true;
        cont.onLoad = function (success) {
            if (success) {
                var root:XMLNode = this.firstChild;
                fullText = root.childNodes[0].childNodes[0].childNodes[0].nodeValue;
                contentTextBox._visible = true;
                ZigoEngine.doTween (contentTextBox,'_alpha',100,2,"easeOutExpo",0);
                contentTextBox.contentText.txt.htmlText = fullText;
                contentTextBox.contentText.txt.autoSize = true;
                if (contentTextBox._height > contentTextArea.back._height) {
                    startFloat ();
        cont.load ("html_content_page_xml-el/contents.xml");
    This is the code its used in .fla and it takes the html data from an xml file. The code at the xml file is like the code at my first post.
    Where:
    contentTextBox is the instance name of contentText movieclip
    contentText is the instance name of the textbox movieclip
    txt is the instance name of the textbox
    (Its like you have a textbox with instance name txt, then convert it to movieclip with instance name contentText and then convert it again to movieclip with instance name contentTextBox).
    At the textbox i have chosen my font (Calibri) and at character embeding i have chosen all. I do not understand how to embed the Calibri italics for example, as font face is italics and font style is italics. I cannot find out where or how to include calibri italics font as a font and not as style.
    What am i doing wrong??

  • Processing instructions and CDATA in XSLT

    Dear all,
    my BPEL process contains a transform activity. The corresponding XSLT stylesheet supplies an output variable that I want to write to the filesystem as an XML document for use in third party applications.
    This XML document must have a few processing instructions inside. When inserting this processing instructions in the XSLT, they are not inserted into the output XML document, i.e. the processing instructions are ignored. Using CDATA sections results in the same behavior.
    Is there a workaround available for this bug in the BPEL Process Manager (without working with strings and string manipulation)?
    Thanks in advance!
    Lars

    This is how I create my DOM...
    DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    org.w3c.dom.Document doc = builder.newDocument();
    Element docElement = doc.createElement("Document");
    docElement.setAttribute("Title", "Home");
    org.w3c.dom.ProcessingInstruction pi = doc.createProcessingInstruction("xml", "type=\"xslt\"");
    doc.appendChild( pi );
    doc.appendChild( docElement );
    And this is the output I get...
    <?xml version="1.0"?>
    <Document Title="Home"/>
    I dont get it, Im using jdk1.4.0, and you get the processing instruction coming through, but I dont...?

  • Xmlbeans and cdata

    I have created an xmlbean, and I am storing html code in one of the elements. I am getting inconsistent results when I call the toString() method of the bean, sometimes the html is enclosed in a CDATA tag and sometimes it is not. Is there something that I can do to get consistent results. This is a critical issue for my development

    It might be in response to the length of the string (HTML) you are passing. My guess is that strings over a certain length would go as CDATA whereas others would go as Text nodes.
    http://www.mail-archive.com/[email protected]/msg00693.html
    A (partial) workaround might be here, but I did not read it fully:
    http://marc2.theaimsgroup.com/?l=xmlbeans-dev&m=111404481811361&w=2
    - Saish

  • XMLParser and CDATA-Element

    Why do the XMLParser replace '<' with '<' in a CDATA-Element?
    I have a Stylesheet with an Element like this:
    <script lang...><![CDATA[
    function test(){
    for(i=0; i<2; i++)...
    }]]>
    </script>
    Now I use the oracle.xml.parser.v2.XMLParser to parse the Stylesheet in this way:
    parser = new DOMParser();
    parser.setPreserveWhitespace(true);
    parser.parse(xslURL);
    xsldoc = parser.getDocument();
    and now I print it out this way:
    xsldoc.print(out);
    This is the result:
    ... for(i=0; i<2; i++) ...
    How can I tell him not to do this replacement? I thought all characters inside the <![CDATA[-tag wouldn't be parsed. Am I wrong?
    I use the XMLParser 9.0.1.0.0 Production                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I've found a workaround with <xsl:comment> like this:
    <script ...>
    <xsl:comment>
    <![CDATA[
    ...Javascriptcode...
    ]]>
    </xsl:comment>
    </script>
    null

  • Spry:repeat and CDATA

    Hi all,
    I'm trying to get CDATAs from a XML-file. But it doesn't work
    within a spry:repeat so far, but maybe I'm missing something (see
    code). All I get is an empty field-column. {field} is tagged with
    CDATA. The {@id} is performing well.
    Any ideas?
    Thank you,
    Thomas

    Hi all,
    I'm trying to get CDATAs from a XML-file. But it doesn't work
    within a spry:repeat so far, but maybe I'm missing something (see
    code). All I get is an empty field-column. {field} is tagged with
    CDATA. The {@id} is performing well.
    Any ideas?
    Thank you,
    Thomas

  • Dbms_xmldom and xmldom

    what is the difference between xmldom and dbms_xmldom packages?
    Has anyone worked with dbms_xmldom? if so does it still uses JVM inside the database?

    dbms_xmldom implemented in C, which doesn't need JVM.
    xmldom is implemented in Java. You should use dbms_xmldom in Oracle9i.

  • Upload and Download ABAP Source Code

    This is a program that I have had kicking around for a couple of years in various incarnations.
    Source Code Listing
    Report: ZKBPROGS *
    Function : Up/Download ABAP reports complete with texts *
    - this program does not update TRDIR with the *
    TRDIR entries that are in the program uploaded. Instead, *
    current users stats are used. *
    - this program allows selection of reports from a list or *
    a single report can be tuped in and uploaded *
    - this program also updates TADIR so that a development class*
    is assigned to the program *
    - this program checks to see if the program already has a *
    TRDIR entry, and if it does, warns the user *
    - this program will save/restore the program documenation too*
    REPORT ZKBPROGS
    NO STANDARD PAGE HEADING
    LINE-SIZE 255.
    Declare Database Objects *
    tables:
    DOKIL,
    TRDIR.
    Constants*
    CONSTANTS:
    MC_TRDIR_IDENTIFIER(72) TYPE C VALUE '%&%& RDIR',
    MC_REPORT_IDENTIFIER(72) TYPE C VALUE '%&%& REPO',
    MC_TEXT_IDENTIFIER(72) TYPE C VALUE '%&%& TEXP',
    MC_THEAD_IDENTIFIER(72) TYPE C VALUE '%&%& HEAD',
    MC_DOC_IDENTIFIER(72) TYPE C VALUE '%&%& DOKL',
    MC_TRDIR_SHORT(4) TYPE C VALUE 'RDIR',
    MC_REPORT_SHORT(4) TYPE C VALUE 'REPO',
    MC_TEXT_SHORT(4) TYPE C VALUE 'TEXP',
    MC_THEAD_SHORT(4) TYPE C VALUE 'HEAD',
    MC_DOC_SHORT(4) TYPE C VALUE 'DOKP'.
    Declare Module level data structures *
    DATA: BEGIN OF MTAB_PROGRAM_SOURCE OCCURS 0,
    LINE(72) TYPE C,
    END OF MTAB_PROGRAM_SOURCE.
    DATA: MTAB_PROGRAM_TRDIR LIKE TRDIR OCCURS 0 WITH HEADER LINE.
    DATA: MTAB_PROGRAM_TEXTS LIKE TEXTPOOL OCCURS 0 WITH HEADER LINE.
    DATA: MSTR_THEAD LIKE THEAD.
    DATA: BEGIN OF MTAB_PROGRAM_FILE OCCURS 0,
    LINE(275) TYPE C,
    END OF MTAB_PROGRAM_FILE.
    DATA: BEGIN OF MTAB_DIRECTORY OCCURS 0,
    NAME LIKE TRDIR-NAME,
    DESC(72) TYPE C,
    SAVENAME LIKE RLGRAP-FILENAME,
    END OF MTAB_DIRECTORY.
    DATA: BEGIN OF MTAB_PROGRAM_DOCUMENTATION OCCURS 0,
    LINE(255) TYPE C,
    END OF MTAB_PROGRAM_DOCUMENTATION.
    Selection Screen *
    *-- Options for upload/download of programs
    SELECTION-SCREEN BEGIN OF BLOCK FRM_OPTIONS WITH FRAME TITLE TEXT-UDL.
    PARAMETERS:
    RB_DOWN RADIOBUTTON GROUP UDL DEFAULT 'X'. " Download reports
    SELECTION-SCREEN BEGIN OF BLOCK FRM_TRDIR WITH FRAME TITLE TEXT-DIR.
    SELECT-OPTIONS:
    S_NAME FOR TRDIR-NAME, " Program Name
    S_SUBC FOR TRDIR-SUBC " Program Type
    DEFAULT 'F' OPTION EQ SIGN E," Exclude Functions by default
    S_CNAM FOR TRDIR-CNAM " Created by
    DEFAULT SY-UNAME,
    S_UNAM FOR TRDIR-UNAM, " Last Changed by
    S_CDAT FOR TRDIR-CDAT, " Creation date
    S_UDAT FOR TRDIR-UDAT. " Last update date
    SELECTION-SCREEN END OF BLOCK FRM_TRDIR.
    *-- Options for uploading programs
    PARAMETERS:
    RB_UP RADIOBUTTON GROUP UDL. " Upload reports
    SELECTION-SCREEN BEGIN OF BLOCK FRM_UPLOAD WITH FRAME TITLE TEXT-UPL.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(29) TEXT-SNG.
    PARAMETERS:
    RB_FILE RADIOBUTTON GROUP HOW DEFAULT 'X'.
    SELECTION-SCREEN COMMENT 33(42) TEXT-FNA.
    SELECTION-SCREEN END OF LINE.
    PARAMETERS:
    RB_LIST RADIOBUTTON GROUP HOW.
    SELECTION-SCREEN END OF BLOCK FRM_UPLOAD.
    SELECTION-SCREEN END OF BLOCK FRM_OPTIONS.
    *-- Options for up/downloading programs
    SELECTION-SCREEN BEGIN OF BLOCK FRM_FILEN WITH FRAME TITLE TEXT-FIL.
    PARAMETERS:
    RB_DOS RADIOBUTTON GROUP FIL DEFAULT 'X', " Save to local
    RB_UNIX RADIOBUTTON GROUP FIL, " Save to UNIX
    P_PATH LIKE RLGRAP-FILENAME " Path to save files to
    DEFAULT 'c:\temp\'.
    SELECTION-SCREEN END OF BLOCK FRM_FILEN.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_NAME-LOW.
    CALL FUNCTION 'F4_PROGRAM'
    EXPORTING
    OBJECT = S_NAME-LOW
    SUPPRESS_SELECTION = 'X'
    IMPORTING
    RESULT = S_NAME-LOW
    EXCEPTIONS
    OTHERS = 1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_NAME-HIGH.
    CALL FUNCTION 'F4_PROGRAM'
    EXPORTING
    OBJECT = S_NAME-HIGH
    SUPPRESS_SELECTION = 'X'
    IMPORTING
    RESULT = S_NAME-HIGH
    EXCEPTIONS
    OTHERS = 1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_UNAM-LOW.
    PERFORM GET_NAME USING 'S_UNAM-LOW'
    CHANGING S_UNAM-LOW.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_UNAM-HIGH.
    PERFORM GET_NAME USING 'S_UNAM-HIGH'
    CHANGING S_UNAM-HIGH.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_CNAM-LOW.
    PERFORM GET_NAME USING 'S_CNAM-LOW'
    CHANGING S_CNAM-LOW.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_CNAM-HIGH.
    PERFORM GET_NAME USING 'S_CNAM-HIGH'
    CHANGING S_CNAM-HIGH.
    TOP-OF-PAGE.
    IF RB_LIST = 'X'.
    FORMAT COLOR COL_HEADING.
    NEW-LINE.
    WRITE: AT 3 TEXT-H01,
    AT 15 TEXT-H03.
    FORMAT COLOR OFF.
    ENDIF.
    AT LINE-SELECTION.
    CHECK RB_LIST = 'X'. " only do in list mode
    READ LINE SY-CUROW FIELD VALUE MTAB_DIRECTORY-SAVENAME.
    *-- Read file into an internal table
    PERFORM READ_REPORT_FROM_DISK TABLES MTAB_PROGRAM_FILE
    USING MTAB_DIRECTORY-SAVENAME.
    *-- Split table into TADIR entry, report lines, and report text
    PERFORM SPLIT_INCOMING_FILE TABLES MTAB_PROGRAM_FILE
    MTAB_PROGRAM_SOURCE
    MTAB_PROGRAM_TEXTS
    MTAB_PROGRAM_DOCUMENTATION
    CHANGING TRDIR
    MSTR_THEAD.
    *-- Save all of the data
    PERFORM INSERT_NEW_REPORT TABLES MTAB_PROGRAM_SOURCE
    MTAB_PROGRAM_TEXTS
    MTAB_PROGRAM_DOCUMENTATION
    USING TRDIR
    MSTR_THEAD.
    Start of processing *
    START-OF-SELECTION.
    FORMAT COLOR COL_NORMAL.
    IF RB_DOWN = 'X'.
    PERFORM DOWNLOAD_REPORTS.
    ELSEIF RB_UP = 'X'.
    PERFORM UPLOAD_REPORTS.
    ENDIF.
    END-OF-SELECTION.
    IF RB_DOWN = 'X'.
    CONCATENATE P_PATH
    'directory.txt'
    INTO P_PATH.
    PERFORM SAVE_TABLE_TO_FILE TABLES MTAB_DIRECTORY
    USING P_PATH.
    ENDIF.
    FORM UPLOAD_REPORTS *
    FORM UPLOAD_REPORTS.
    *-- Can upload a reports entered in selection criteria or
    *-- select from a list. List can be from index.txt in same directory
    *-- (created by the download) or by reading the first line of each file
    *-- in the directory.
    IF RB_FILE = 'X'. " Upload single program from a file
    *-- Read file into an internal table
    PERFORM READ_REPORT_FROM_DISK TABLES MTAB_PROGRAM_FILE
    USING P_PATH.
    *-- Split table into TADIR entry, report lines, and report text
    PERFORM SPLIT_INCOMING_FILE TABLES MTAB_PROGRAM_FILE
    MTAB_PROGRAM_SOURCE
    MTAB_PROGRAM_TEXTS
    MTAB_PROGRAM_DOCUMENTATION
    CHANGING TRDIR
    MSTR_THEAD.
    *-- Save all of the data
    PERFORM INSERT_NEW_REPORT TABLES MTAB_PROGRAM_SOURCE
    MTAB_PROGRAM_TEXTS
    MTAB_PROGRAM_DOCUMENTATION
    USING TRDIR
    MSTR_THEAD.
    ELSEIF RB_LIST = 'X'. " Show list for user to choose from
    *-- get list of report names/descriptions from directory text
    CONCATENATE P_PATH
    'directory.txt'
    INTO P_PATH.
    PERFORM READ_REPORT_FROM_DISK TABLES MTAB_DIRECTORY
    USING P_PATH.
    SORT MTAB_DIRECTORY.
    *-- Write out list of report names/descriptions
    LOOP AT MTAB_DIRECTORY.
    WRITE:
    / MTAB_DIRECTORY-NAME UNDER TEXT-H01,
    MTAB_DIRECTORY-DESC UNDER TEXT-H03,
    MTAB_DIRECTORY-SAVENAME.
    ENDLOOP.
    *-- Process user selections for reports to upload.
    ENDIF.
    ENDFORM. " upload_reports
    FORM DOWNLOAD_REPORTS *
    From the user selections, get all programs that meet the *
    criteria, and save them in ftab_program_directory. *
    Also save the report to disk. *
    FORM DOWNLOAD_REPORTS.
    DATA:
    LC_FULL_FILENAME LIKE RLGRAP-FILENAME.
    *-- The table is put into an internal table because the program will
    *-- abend if multiple transfers to a dataset occur within a SELECT/
    *-- ENDSELCT (tested on 3.1H)
    SELECT * FROM TRDIR
    INTO TABLE MTAB_PROGRAM_TRDIR
    WHERE NAME IN S_NAME
    AND SUBC IN S_SUBC
    AND CNAM IN S_CNAM
    AND UNAM IN S_UNAM
    AND CDAT IN S_CDAT
    AND UDAT IN S_UDAT.
    LOOP AT MTAB_PROGRAM_TRDIR.
    *-- Clear out text and source code tables
    CLEAR:
    MTAB_PROGRAM_FILE,
    MTAB_PROGRAM_SOURCE,
    MTAB_PROGRAM_TEXTS,
    MTAB_PROGRAM_DOCUMENTATION.
    REFRESH:
    MTAB_PROGRAM_FILE,
    MTAB_PROGRAM_SOURCE,
    MTAB_PROGRAM_TEXTS,
    MTAB_PROGRAM_DOCUMENTATION.
    *-- Get the report
    READ REPORT MTAB_PROGRAM_TRDIR-NAME INTO MTAB_PROGRAM_SOURCE.
    *-- Get the text for the report
    READ TEXTPOOL MTAB_PROGRAM_TRDIR-NAME INTO MTAB_PROGRAM_TEXTS.
    *-- Get the documentation for the report
    CLEAR DOKIL.
    SELECT * UP TO 1 ROWS FROM DOKIL
    WHERE ID = 'RE'
    AND OBJECT = MTAB_PROGRAM_TRDIR-NAME
    AND LANGU = SY-LANGU
    AND TYP = 'E'
    ORDER BY VERSION DESCENDING.
    ENDSELECT.
    *-- Documentation exists for this object
    IF SY-SUBRC = 0.
    CALL FUNCTION 'DOCU_READ'
    EXPORTING
    ID = DOKIL-ID
    LANGU = DOKIL-LANGU
    OBJECT = DOKIL-OBJECT
    TYP = DOKIL-TYP
    VERSION = DOKIL-VERSION
    IMPORTING
    HEAD = MSTR_THEAD
    TABLES
    LINE = MTAB_PROGRAM_DOCUMENTATION
    EXCEPTIONS
    OTHERS = 1.
    ENDIF.
    *-- Put the report code and texts into a single file
    *-- Put the identifier line in so that the start of the TRDIR line
    *-- is marked
    CONCATENATE MC_TRDIR_IDENTIFIER
    MTAB_PROGRAM_TRDIR-NAME
    INTO MTAB_PROGRAM_FILE-LINE.
    APPEND MTAB_PROGRAM_FILE.
    *-- Add the TRDIR line
    MTAB_PROGRAM_FILE-LINE = MTAB_PROGRAM_TRDIR.
    APPEND MTAB_PROGRAM_FILE.
    *-- Put the identifier line in so that the start of the report code
    *-- is marked
    CONCATENATE MC_REPORT_IDENTIFIER
    MTAB_PROGRAM_TRDIR-NAME
    INTO MTAB_PROGRAM_FILE-LINE.
    APPEND MTAB_PROGRAM_FILE.
    *-- Add the report code
    LOOP AT MTAB_PROGRAM_SOURCE.
    MTAB_PROGRAM_FILE = MTAB_PROGRAM_SOURCE.
    APPEND MTAB_PROGRAM_FILE.
    ENDLOOP.
    *-- Put the identifier line in so that the start of the report text
    *-- is marked
    CONCATENATE MC_TEXT_IDENTIFIER
    MTAB_PROGRAM_TRDIR-NAME
    INTO MTAB_PROGRAM_FILE-LINE.
    APPEND MTAB_PROGRAM_FILE.
    *-- Add the report texts
    LOOP AT MTAB_PROGRAM_TEXTS.
    MTAB_PROGRAM_FILE = MTAB_PROGRAM_TEXTS.
    APPEND MTAB_PROGRAM_FILE.
    ENDLOOP.
    *-- Put the identifier line in so that the start of the THEAD record
    *-- is marked
    CONCATENATE MC_THEAD_IDENTIFIER
    MTAB_PROGRAM_TRDIR-NAME
    INTO MTAB_PROGRAM_FILE-LINE.
    APPEND MTAB_PROGRAM_FILE.
    MTAB_PROGRAM_FILE = MSTR_THEAD.
    APPEND MTAB_PROGRAM_FILE.
    *-- Put the identifier line in so that the start of the report
    *-- documentation is marked
    CONCATENATE MC_DOC_IDENTIFIER
    MTAB_PROGRAM_TRDIR-NAME
    INTO MTAB_PROGRAM_FILE-LINE.
    APPEND MTAB_PROGRAM_FILE.
    *-- Add the report documentation
    LOOP AT MTAB_PROGRAM_DOCUMENTATION.
    MTAB_PROGRAM_FILE = MTAB_PROGRAM_DOCUMENTATION.
    APPEND MTAB_PROGRAM_FILE.
    ENDLOOP.
    *-- Make the fully pathed filename that report will be saved to
    CONCATENATE P_PATH
    MTAB_PROGRAM_TRDIR-NAME
    '.txt'
    INTO LC_FULL_FILENAME.
    PERFORM SAVE_TABLE_TO_FILE TABLES MTAB_PROGRAM_FILE
    USING LC_FULL_FILENAME.
    *-- Write out message with Program Name/Description
    READ TABLE MTAB_PROGRAM_TEXTS WITH KEY ID = 'R'.
    IF SY-SUBRC = 0.
    MTAB_DIRECTORY-NAME = MTAB_PROGRAM_TRDIR-NAME.
    MTAB_DIRECTORY-DESC = MTAB_PROGRAM_TEXTS-ENTRY.
    MTAB_DIRECTORY-SAVENAME = LC_FULL_FILENAME.
    APPEND MTAB_DIRECTORY.
    WRITE: / MTAB_PROGRAM_TRDIR-NAME,
    MTAB_PROGRAM_TEXTS-ENTRY(65) COLOR COL_HEADING.
    ELSE.
    MTAB_DIRECTORY-NAME = MTAB_PROGRAM_TRDIR-NAME.
    MTAB_DIRECTORY-DESC = 'No description available'.
    MTAB_DIRECTORY-SAVENAME = LC_FULL_FILENAME.
    APPEND MTAB_DIRECTORY.
    WRITE: / MTAB_PROGRAM_TRDIR-NAME.
    ENDIF.
    ENDLOOP.
    ENDFORM. " BUILD_PROGRAM_DIRECTORY
    FORM SAVE_TABLE_TO_FILE *
    --> FTAB_TABLE *
    --> F_FILENAME *
    FORM SAVE_TABLE_TO_FILE TABLES FTAB_TABLE
    USING F_FILENAME.
    IF RB_DOS = 'X'. " Save file to presentation server
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
    FILENAME = F_FILENAME
    FILETYPE = 'ASC'
    TABLES
    DATA_TAB = FTAB_TABLE
    EXCEPTIONS
    OTHERS = 4.
    IF SY-SUBRC NE 0.
    WRITE: / 'Error opening dataset' COLOR COL_NEGATIVE,
    F_FILENAME COLOR COL_NEGATIVE.
    ENDIF.
    ELSE. " Save file to application server
    OPEN DATASET F_FILENAME FOR OUTPUT IN TEXT MODE.
    IF SY-SUBRC = 0.
    LOOP AT FTAB_TABLE.
    TRANSFER FTAB_TABLE TO F_FILENAME.
    IF SY-SUBRC NE 0.
    WRITE: / 'Error writing record to file;' COLOR COL_NEGATIVE,
    F_FILENAME COLOR COL_NEGATIVE.
    ENDIF.
    ENDLOOP.
    ELSE.
    WRITE: / 'Error opening dataset' COLOR COL_NEGATIVE,
    F_FILENAME COLOR COL_NEGATIVE.
    ENDIF.
    ENDIF. " End RB_DOS
    ENDFORM. " SAVE_PROGRAM
    FORM READ_REPORT_FROM_DISK *
    Read report into internal table. Can read from local or *
    remote computer *
    FORM READ_REPORT_FROM_DISK TABLES FTAB_TABLE
    USING F_FILENAME.
    DATA:
    LC_MESSAGE(128) TYPE C.
    CLEAR FTAB_TABLE.
    REFRESH FTAB_TABLE.
    IF RB_DOS = 'X'.
    TRANSLATE F_FILENAME USING '/\'. " correct slash for Dos PC file
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    FILENAME = F_FILENAME
    FILETYPE = 'ASC'
    TABLES
    DATA_TAB = FTAB_TABLE
    EXCEPTIONS
    CONVERSION_ERROR = 1
    FILE_OPEN_ERROR = 2
    FILE_READ_ERROR = 3
    INVALID_TABLE_WIDTH = 4
    INVALID_TYPE = 5
    NO_BATCH = 6
    UNKNOWN_ERROR = 7
    OTHERS = 8.
    IF SY-SUBRC >< 0.
    WRITE: / 'Error reading file from local PC' COLOR COL_NEGATIVE.
    ENDIF.
    ELSEIF RB_UNIX = 'X'.
    TRANSLATE F_FILENAME USING '\/'. " correct slash for unix
    OPEN DATASET F_FILENAME FOR INPUT MESSAGE LC_MESSAGE IN TEXT MODE.
    IF SY-SUBRC = 0.
    DO.
    READ DATASET F_FILENAME INTO FTAB_TABLE.
    IF SY-SUBRC = 0.
    APPEND FTAB_TABLE.
    ELSE.
    EXIT.
    ENDIF.
    ENDDO.
    CLOSE DATASET F_FILENAME.
    ELSE.
    WRITE: / 'Error reading file from remote computer'
    COLOR COL_NEGATIVE,
    / LC_MESSAGE,
    / F_FILENAME.
    SY-SUBRC = 4.
    ENDIF.
    ENDIF.
    ENDFORM. " READ_REPORT_FROM_DISK
    FORM SPLIT_INCOMING_FILE *
    --> FTAB_PROGRAM_FILE *
    --> FTAB_PROGRAM_SOURCE *
    --> ` *
    --> FTAB_PROGRAM_TEXTS *
    FORM SPLIT_INCOMING_FILE TABLES FTAB_PROGRAM_FILE
    STRUCTURE MTAB_PROGRAM_FILE
    FTAB_PROGRAM_SOURCE
    STRUCTURE MTAB_PROGRAM_SOURCE
    FTAB_PROGRAM_TEXTS
    STRUCTURE MTAB_PROGRAM_TEXTS
    FTAB_PROGRAM_DOCUMENTATION
    STRUCTURE MTAB_PROGRAM_DOCUMENTATION
    CHANGING FSTR_TRDIR
    FSTR_THEAD.
    DATA:
    LC_DATATYPE(4) TYPE C, " Type of data, REPO, TEXP, RDIR
    LC_PROGRAM_FILE LIKE MTAB_PROGRAM_FILE.
    LOOP AT FTAB_PROGRAM_FILE.
    LC_PROGRAM_FILE = FTAB_PROGRAM_FILE.
    CASE LC_PROGRAM_FILE(9).
    WHEN MC_TRDIR_IDENTIFIER.
    LC_DATATYPE = MC_TRDIR_SHORT.
    WHEN MC_REPORT_IDENTIFIER.
    LC_DATATYPE = MC_REPORT_SHORT.
    WHEN MC_TEXT_IDENTIFIER.
    LC_DATATYPE = MC_TEXT_SHORT.
    WHEN MC_DOC_IDENTIFIER.
    LC_DATATYPE = MC_DOC_SHORT.
    WHEN MC_THEAD_IDENTIFIER.
    LC_DATATYPE = MC_THEAD_SHORT.
    WHEN OTHERS. " Actual contents of report, trdir, or text
    CASE LC_DATATYPE.
    WHEN MC_TRDIR_SHORT.
    FSTR_TRDIR = FTAB_PROGRAM_FILE.
    WHEN MC_REPORT_SHORT.
    FTAB_PROGRAM_SOURCE = FTAB_PROGRAM_FILE.
    APPEND FTAB_PROGRAM_SOURCE.
    WHEN MC_TEXT_SHORT.
    FTAB_PROGRAM_TEXTS = FTAB_PROGRAM_FILE.
    APPEND FTAB_PROGRAM_TEXTS.
    WHEN MC_THEAD_SHORT.
    FSTR_THEAD = FTAB_PROGRAM_FILE.
    WHEN MC_DOC_SHORT.
    FTAB_PROGRAM_DOCUMENTATION = FTAB_PROGRAM_FILE.
    APPEND FTAB_PROGRAM_DOCUMENTATION.
    ENDCASE.
    ENDCASE.
    ENDLOOP.
    ENDFORM. " SPLIT_INCOMING_FILE
    FORM INSERT_NEW_REPORT*
    --> FTAB_PROGRAM_SOURCE *
    --> FTAB_PROGRAM_TEXTS *
    --> F_TRDIR *
    FORM INSERT_NEW_REPORT TABLES FTAB_PROGRAM_SOURCE
    STRUCTURE MTAB_PROGRAM_SOURCE
    FTAB_PROGRAM_TEXTS
    STRUCTURE MTAB_PROGRAM_TEXTS
    FTAB_PROGRAM_DOCUMENTATION
    STRUCTURE MTAB_PROGRAM_DOCUMENTATION
    USING FSTR_TRDIR LIKE TRDIR
    FSTR_THEAD LIKE MSTR_THEAD.
    DATA:
    LC_OBJ_NAME LIKE E071-OBJ_NAME,
    LC_LINE2(40) TYPE C,
    LC_ANSWER(1) TYPE C.
    *-- read trdir to see if the report already exists, if it does, prompt
    *-- user to overwrite or abort.
    SELECT SINGLE * FROM TRDIR WHERE NAME = FSTR_TRDIR-NAME.
    IF SY-SUBRC = 0. " Already exists
    CONCATENATE 'want to overwrite report'
    FSTR_TRDIR-NAME
    INTO LC_LINE2 SEPARATED BY SPACE.
    CONCATENATE LC_LINE2
    INTO LC_LINE2.
    CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
    EXPORTING
    DEFAULTOPTION = 'N'
    TEXTLINE1 = 'The selected report already exists, do you'
    TEXTLINE2 = LC_LINE2
    TITEL = 'Report already exists'
    CANCEL_DISPLAY = SPACE
    IMPORTING
    ANSWER = LC_ANSWER
    EXCEPTIONS
    OTHERS = 1.
    ELSE.
    LC_ANSWER = 'J'.
    ENDIF.
    IF LC_ANSWER = 'J'.
    *-- Create the TADIR entry. (TRDIR entry created by INSERT REPORT)
    LC_OBJ_NAME = TRDIR-NAME.
    CALL FUNCTION 'TR_TADIR_POPUP_ENTRY_E071'
    EXPORTING
    WI_E071_PGMID = 'R3TR'
    WI_E071_OBJECT = 'PROG'
    WI_E071_OBJ_NAME = LC_OBJ_NAME
    WI_TADIR_DEVCLASS = '$TMP'
    EXCEPTIONS
    EXIT = 3
    OTHERS = 4.
    IF SY-SUBRC = 0.
    *-- Create Report
    INSERT REPORT FSTR_TRDIR-NAME FROM FTAB_PROGRAM_SOURCE.
    *-- Create Texts
    INSERT TEXTPOOL FSTR_TRDIR-NAME FROM FTAB_PROGRAM_TEXTS
    LANGUAGE SY-LANGU.
    *-- Save Documentation
    CALL FUNCTION 'DOCU_UPDATE'
    EXPORTING
    HEAD = FSTR_THEAD
    STATE = 'A'
    TYP = 'E'
    VERSION = '1'
    TABLES
    LINE = FTAB_PROGRAM_DOCUMENTATION
    EXCEPTIONS
    OTHERS = 1.
    ELSE.
    WRITE: / 'Error updating the TADIR entry' COLOR COL_NEGATIVE,
    'Program' COLOR COL_NEGATIVE INTENSIFIED OFF,
    FSTR_TRDIR-NAME, 'was not loaded into SAP.'
    COLOR COL_NEGATIVE INTENSIFIED OFF.
    ENDIF.
    ELSE.
    WRITE: / FSTR_TRDIR-NAME COLOR COL_NEGATIVE,
    'was not uploaded into SAP. Action cancelled by user'
    COLOR COL_NEGATIVE INTENSIFIED OFF.
    ENDIF.
    ENDFORM. " INSERT_NEW_REPORT
    FORM GET_NAME *
    --> VALUE(F_FIELD) *
    --> F_NAME *
    FORM GET_NAME USING VALUE(F_FIELD)
    CHANGING F_NAME.
    DATA: LTAB_FIELDS LIKE DYNPREAD OCCURS 0 WITH HEADER LINE,
    LC_PROG LIKE D020S-PROG,
    LC_DNUM LIKE D020S-DNUM.
    TRANSLATE F_FIELD TO UPPER CASE.
    refresh ltab_fields.
    LTAB_FIELDS-FIELDNAME = F_FIELD.
    append ltab_fields.
    LC_PROG = SY-REPID .
    LC_DNUM = SY-DYNNR .
    CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
    DYNAME = LC_PROG
    DYNUMB = LC_DNUM
    TABLES
    dynpfields = ltab_fields
    EXCEPTIONS
    OTHERS = 01.
    read table ltab_fields index 1.
    IF SY-SUBRC EQ 0.
    F_NAME = LTAB_FIELDS-FIELDVALUE.
    refresh ltab_fields.
    ENDIF.
    CALL FUNCTION 'F4_USER'
    EXPORTING
    OBJECT = F_NAME
    IMPORTING
    RESULT = F_NAME.
    ENDFORM. " GET_NAME
    Program Texts
    DIR File Download Options (File Selection)
    FIL File Options
    FNA Enter filename below (under File Options)
    H01 Prog Name
    H03 Program Description
    SNG Upload a single file
    UDL Upload to SAP/Download from SAP
    UPL File Upload Options
    R Backup/Restore program source code with texts
    P_PATH Path to save programs to
    RB_DOS Files on local computer
    RB_DOWN Download Programs
    RB_FILE Upload a single file
    RB_LIST Select program(s) from a list
    RB_UNIX Files on remote computer
    RB_UP Upload Programs to SAP
    S_CDAT Date Created
    S_CNAM Created by UserID
    S_NAME Program Name
    S_SUBC Program Type
    S_UDAT Date Changed
    S_UNAM Last Changed by UserID

    Hi
    you can use SAPLink for this
    http://code.google.com/p/saplink/
    Abhi

  • SQL query works in the SQLPlus, but fires parse error after being cut and pasted into

    One of our client has a SQL query like this:
    SQL> SELECT LNAME,
    2 QUOTA/12,
    3 (SELECT SUM(CAMT) FROM CONSULTING WHERE CONSULTANT = P.EMPLOYEE
    4 AND ACTIVITYCODE = 'C'AND
    5 CDATE BETWEEN '01-JAN-2001' AND '31-JAN-2001') AS SUM,
    6 (SELECT SUM(CAMT) FROM CONSULTING WHERE CONSULTANT = P.EMPLOYEE
    7 AND ACTIVITYCODE = 'C'AND
    8 CDATE BETWEEN '01-JAN-2001' AND '31-JAN-2001') -
    QUOTA/12 AS PL
    9 FROM PERSONNEL P
    10 ORDER BY LNAME;
    Running the above query in the SQLPlus returns appropriate resultsets to the
    user. After the same SQL being cut and pasted into a portal report
    component, running the report component fires the following error:
    Failed to parse query
    Error:ORA-00911: invalid character (WWV-11230)
    Failed to parse as XXX - SELECT LNAME, QUOTA/12, (SELECT SUM(CAMT) FROM
    CONSULTING WHERE CONSULTANT = P.EMPLOYEE AND ACTIVITYCODE = 'C'AND CDATE
    BETWEEN '01-JAN-2001' AND '31-JAN-2001') AS SUM, (SELECT SUM(CAMT) FROM
    CONSULTING WHERE CONSULTANT = P.EMPLOYEE AND ACTIVITYCODE = 'C'AND CDATE
    BETWEEN '01-JAN-2001' AND '31-JAN-2001') - QUOTA/12 AS PL FROM PERSONNEL P
    ORDER BY LNAME; (WWV-08300)
    Cursor is not open
    Is this because of the multi-table queries, or something else? Is there any
    way around this? Any information regarding this will be highly appreciated.
    Thanks.
    null

    Sunny,
    From the error message that you posted it seems that you are putting a semicolon ";" at the end of your query. I checked the query that you have posted. It is working fine for me. (I am using 3.0.8) but I feel it will work in your version also. I tried the query without a ";" at the end --It worked.
    I tried with ";" at the end -- It gave the error that you have posted. So remove the ";" at the end and it should work. If you are still getting the same error then pls write down the version you are using. I will check in that version.
    Thanx,
    Chetan.

  • Query tuning and using the "better" index.

    I have a database table with about 40,000 records in it. Using
    a certain index first limits the number of rows to 11,000
    records. Using a different index first (by disabling the other
    index in the query) limits the number of rows to 2,500 records.
    Using the explain plan, the rest of the query is parsed the same
    way for both queries. What reasons can explain why when the
    index that returns 11,000 records first runs faster than
    the "better" index? I thought the whole idea behind query
    tuning is to use the index that limits the data the most.

    It looks like Oracle likes the equality condition more than the greater than -less than combination (which you might like to recode as a BETWEEN condition for clarity).
    There are a number of factors here.
    i) Are the "test names" equally distributed? Do some test names appear with greater frequency than others? If so, collecting column statistics might cause the BATCH_2 index to be used for some test names, and not for others.
    ii) Likewise, what is the distribution of cdates? How does the distribution of cdates vary by test name?
    iii) You could force the use of the BATCH_6 index over the BATCH_2 by using an optimizer hint instead of dropping the BATCH_2 index ...
    select /*+ index(batch batch_6) */ id, test, cdate
    from batch
    where test = 'Some test name'
    and cdate >= &start date&
    and cdate < &end date& + 1
    ... or even try prompting Oracle to use both indexes ...
    select /*+ index(batch batch_6) index(batch batch_2) */ id, test, cdate
    from batch
    where test = 'Some test name'
    and cdate >= &start date&
    and cdate < &end date& + 1
    ... and test the response times, then chose to use the optimizer hint in your application
    iv) You might like to replace the rather unselective BATCH_2 index with a BATCH_2_6 index on both test and cdate (in that order). That would probably give you an excellent result, and the BATCH_6 index can still be used to satisfy queries slective on cdate that are not selective on test (in very recent versions of Oracle the BATCH_2_6 index might be used for such an operation, and you could drop both BATCH_6 and BATCH_2)
    Well, see if any of this helps.

Maybe you are looking for

  • Itunes 11 no disk error

    I just loaded itunes 11 and i cant do anything. It says no disk in drive. please insert a disk into drive \device\Harddisk1\DR1/ any help please

  • Address Book sync to Gmail?

    I'm running Leopard Mail and Address Book but I'd like Gmail (via the web site) to also have my addresses. There are a lot of them - it would take forever to manage manually. Is there a way to sync them?

  • Automatic creation of remittance advice for employee expense reimbursements

    Hello experts Is there a way to have remittance advices for employee expense reimbursements created automatically at the time of payment media run? In case of suppliers, in the supplier base you can heck "Advice Required" and then at the time of medi

  • Anyone has a remedy for mail/leopard sending emails problem ?

    I just spend hours on my MBP trying to set up MAIL and on various forums trying to find a cure for what seems to be a common problem on Leopard, not being able to send emails. I like many others are getting the "can not send message using the smtp se

  • TS1717 Itunes re-installed but not opening

    Itunes was running on my Windows 7, 64 bit, Core I7 laptop, but it stopped recognizing my ipod touch.  WIndows would see the device, but not Itunes.  So I checked the Apple support site and it suggested totally uninstalling Itunes and Quick Time and