Really working Crosstab / Pivot Report example

try it here:
http://apex.oracle.com/pls/otn/f?p=20819:2
Details:
Create Report - based on PL/SQL ************************************
DECLARE
l_return_value VARCHAR2(32000) DEFAULT NULL;
BEGIN
l_return_value := PK_PIVOT.PivotSQL('SELECT * FROM TESTDATA', 'country,city,product','FDate', 'SUM', 'amount', nvl(:P2_PAGENUMBER,1) );
--:P2_PAGENUMBER - Textbox above the report
RETURN l_return_value;
END;
Create Supporting PACKAGE PK_PIVOT ************************************
create or replace
PACKAGE PK_PIVOT
--AUTHID CURRENT_USER
as
--code based on famous Tom Kyte's books examples
--but not copy-pasted from there
type refcursor is ref cursor;
type array is table of varchar2(30);
type array_varchar2 is table of varchar2(255);
Function PivotSQL (
p_query in varchar2, --query string which returns data you want to make crosstab on
p_rowfields in varchar2, --row fields separated by comma
p_columnfield in varchar2, --one column field
p_function in varchar2,--aggregate function ('SUM','AVG','COUNT','MIN','MAX')
p_functionfield in varchar2 --field for aggregate function
, p_page in number default 1--page from right to left (not all columns can be shown on one page)
) return varchar2; --returns query text for crosstab
example:
SELECT PK_CROSSTAB.PivotSQL('SELECT * FROM scott.emp','empno','job','sum','sal') FROM SYS.DUAL
SELECT deptno
,sum(DECODE(job,'BOSS',sal,null)) as BOSS
,sum(DECODE(job,'FIN',sal,null)) as FIN
,sum(DECODE(job,'HR',sal,null)) as HR
,sum(DECODE(job,'Sales',sal,null)) as Sales
FROM (SELECT * FROM scott.emp)
GROUP BY deptno
ORDER BY deptno
end;
create or replace PACKAGE BODY PK_PIVOT as
Procedure FormatParam (var_data in varchar2, var_type in number, out_decode in out varchar2, out_col in out varchar2);
Function PivotSQL (
p_query in varchar2,--
p_rowfields in varchar2,
p_columnfield in varchar2,
p_function in varchar2,
p_functionfield in varchar2,
p_page in number default 1
) return varchar2
as
l_max_cols number;
l_query long;
l_columnnames array_varchar2 :=array_varchar2();
l_cursor refcursor;
tmp long;
--dbms_sql types:
l_theCursor integer default dbms_sql.open_cursor;--get col types
l_colCnt number default 0;
l_descTbl dbms_sql.desc_tab;
col_num number;
l_columnfieldtype number;
--decode names   
o_decode varchar2(50);
o_col varchar2(50);
l_cols_per_page number := 50;
l_begcol number;
l_endcol number;
begin
--check params
IF instr(p_columnfield,',')>0 THEN
raise_application_error (-20001, 'Can use only 1 columnfield');
ELSIF upper(p_function) not in ('SUM','AVG','COUNT','MIN','MAX') THEN
raise_application_error (-20001, 'Can use only standard aggregate functions');
END IF;
/* analyse query */
dbms_sql.parse(l_theCursor, p_query, dbms_sql.native);
/* get described columns for analysed query */
dbms_sql.describe_columns(l_theCursor, l_colCnt, l_descTbl);
/* Tom Kyte:
* Following loop could simply be for j in 1..col_cnt loop.
* Here we are simply illustrating some of the PL/SQL table
* features.
col_num := l_descTbl.first;
loop
exit when (col_num is null);
--find column field type
if l_descTbl(col_num).col_name=upper(p_columnfield) then
l_columnfieldtype:=l_descTbl(col_num).col_type;
--dbms_output.put_line('Col#:'||col_num||' Name:'||l_descTbl(col_num).col_name||' Type:'||l_descTbl(col_num).col_type);
end if;
col_num := l_descTbl.next(col_num);
end loop;
--return 'test ok';
-- figure out the column names we must support for horizontal cross
if (p_columnfield is not null) then
tmp:='SELECT DISTINCT ' || p_columnfield || ' FROM (' || p_query || ') ORDER BY ' || p_columnfield;
-- dbms_output.put_line('columns cursor:'||tmp);
OPEN l_cursor for tmp;
LOOP
l_columnnames.EXTEND;
FETCH l_cursor into l_columnnames(l_columnnames.COUNT);
--dbms_output.put_line('l_columnnames:'||l_columnnames(l_columnnames.COUNT));
EXIT WHEN l_cursor%NOTFOUND;
END LOOP;
CLOSE l_cursor;
-- execute immediate 'SELECT DISTINCT ' || p_columnfield || ' FROM (' || p_query || ')' bulk collect into l_columnnames ;
else
raise_application_error (-20001, 'Cannot figure out max cols');
end if;
-- Now, construct the query that can answer the question for us...
l_query := 'SELECT ' || p_rowfields ;
l_begcol:=l_cols_per_page*(p_page-1)+1;
l_endcol:=l_cols_per_page*p_page;
if l_begcol>l_columnnames.count-1 then
l_begcol := l_columnnames.count-1;
end if;
if l_endcol>l_columnnames.count-1 then
l_endcol := l_columnnames.count-1;
end if;
--for i in  1 .. l_columnnames.count-1 loop
for i in l_begcol..l_endcol loop
FormatParam(l_columnnames(i),l_columnfieldtype, o_decode, o_col);--format params
l_query := l_query || ',' || p_function || '(DECODE(' || p_columnfield || ',' || o_decode || ','|| p_functionfield ||',null)) as "'|| o_col ||'" ' ; --" для строк с пробелами
end loop;
l_query := l_query || ' FROM (' || p_query || ')';
l_query := l_query || ' GROUP BY ' || p_rowfields || ' ORDER BY ' || p_rowfields;
/* close cursor */
dbms_sql.close_cursor(l_theCursor);
return l_query;
EXCEPTION
WHEN OTHERS THEN
/* close cursor */
dbms_sql.close_cursor(l_theCursor);
raise_application_error (-20001,'Error in PivotSQL:' || SQLERRM);
end;
--=========================
Procedure FormatParam (var_data in varchar2, var_type in number, out_decode in out varchar2, out_col in out varchar2)
--format parameter based on its type - for PivotSQL
--get parameter and its type
-- return strings for decode function and column name
/* dbms_sql.describe_columns types:
DATE Type:12
Varchar2 Type:1
Number Type:2
IS
BEGIN
IF var_data is null THEN
out_decode:='NULL';
out_col:='==NULL==';
ELSIF var_type = 1 THEN -- Varchar2
out_decode:=''''||var_data||'''';--add quotes
out_col:=substr(var_data,1,30);
ELSIF var_type = 2 THEN --Number
out_decode:=var_data;--do nothing
out_col:=substr(var_data,1,30);
ELSIF var_type = 12 THEN --DATE
out_decode:='to_date('''||var_data||''')';--format as internal date
out_col:=to_char(to_date(var_data),'YYYY-MM-DD');
ELSE
out_decode:='== UNDEFINED TYPE:'||var_type;
out_col:='== UNDEFINED TYPE';
END IF;
EXCEPTION
WHEN OTHERS THEN
raise_application_error (-20001,'Error in FormatParam:' || SQLERRM);
END;
end;

Hi,
Thank you for providing such an excellent piece of code. I have used it and it works like a charm. However I faced a problem today and needed your help.
I am executing this code using the following code :
SELECT PK_PIVOT.PivotSQL('SELECT sfid.bill_date ,cust.customer_name FROM split_file_detail sfd,customer cust,split_file_invoice_details sfid where sfd.CUSTOMER_SYS_ID=cust.CUSTOMER_SYS_ID and sfid.SPLIT_FILE_DETAIL_SYS_ID = sfd.SPLIT_FILE_DETAIL_SYS_ID'
,'cust.customer_name','bill_date','count','cust.customer_name') FROM SYS.DUAL
Now when I do so I get the following error :
ORA -20001 : Error in PivotSQL: ORA-06502 and ORA-06512.
Now I guess the error maybe because:
1. The p_query parameter is huge and the tmp long type is not able to hold the value.
2. bill_date holds 200+ values and the ref_cursor is not able to handle it.
I have tried breaking p_query down to some more bits but I face the problem when I concatenate them back together.
Can you help me please?

Similar Messages

  • Dynamic query to produce crosstab/pivot report

    Hello,
    I've not been able to find any examples similar to my situation but perhaps I'm using the wrong search phrases...
    I'm basically trying to create a cross-tab type report based on a dynamic query (since I do not know how many accounts a person has):
    select '  SELECT x.name, x.type, ' from dual
    union
    select ' max(decode(x.account,'''||m.account||''',x.amount,null)) as "'||substr(s.proj||' '||m.account,1,30)||'",'
      from db1.manager m, db1.person p, pi.charges c, db1.status s
    where m.manager_id = p.id
       and M.ACCOUNT_ID = C.ACCT_ID
       and M.ACCOUNT_STRING = S.project
       and C.JNL = (select max(id) from db1.journ j where j.TYPE ='M')
       and p.username = :username
       and nvl(M.END_DATE, sysdate +1) >= sysdate
    group by m.account, s.proj
    union
    select 'sum(x.amount) grand_total from (select m.account, c.name, c.type, c.amount '
              ||'from db1.manager m, db1.person p, pi.charges c '
              ||'where m.manager_id = p.id '
              ||'and p.username = :P68_PRINC '
              ||'and c.acct_id = m.account_id '
              ||'and c.jnl = (select max(id) '
              ||'from db1.journ j where j.TYPE =''M'')) x '
              ||' group by type, name' from dualThe output from this query for the particular manager I selected is:
    SELECT x.name, x.type,
    max(decode(x.account,'12012',x.amount,null)) as "Internal 12012",
    max(decode(x.account,'17929',x.amount,null)) as "Staged 17929",
    max(decode(x.account,'18054',x.amount,null)) as "Help Software 18054",
    max(decode(x.account,'3428',x.amount,null)) as "Mow 3428",
    max(decode(x.account,'3428',x.amount,null)) as "Mow 3428_1",
    max(decode(x.account,'3508',x.amount,null)) as "Stampede 3508",
    max(decode(x.account,'9102',x.amount,null)) as "Open Collaborative 9102",
    sum(x.amount) grand_total
    from (select m.account, c.name, c.type, c.amount
    from db1.manager m, db1.person p, pi.charges c
    where m.manager_id = p.id
        and p.username = :P68_PRINC
        and c.acct_id = m.account_id
        and c.jnl = (select max(id)
       from db1.journ j where j.TYPE ='M')) x
      group by type, nameThis query generates another query that ultimately produces the report below (please pardon the alignment) that I want to see on a report page.
    NAME     TYPE     Internal 12012     Staged 17929     Help Software 18054     Mow 3428     Mow 3428_1     Stampede 3508     Open Collaborative 9102     GRAND_TOTAL
    #EXAM1221     M                                                                            22                                                                                             22
    #EXAM1222     M                          14.83             14.77                     12.56                          2.22                                                          44.38
    #EXAM1223     M                          6.73                 6.7                             5.7                                  1                                                          20.13
    THOEORY       M                          106.5                                                                                                                                      106.5Should I be using the report type that is based on a 'PL/SQL function body returning SQL query' for this type of report??? If so, how does that get set up?
    Thanks in advance!
    ~Jake

    This solution works in that it generates the proper query. I can copy the query (from debug mode) and paste it in TOAD and it works perfectly. However, in the report page it tells me: "report error:ORA-01403: no data found".
    I found this thread: report error: ORA-01403: no data found when SUM columns
    I did have a couple other regions on the page (previous attempts) that were hidden so I deleted them completely. Still no luck.
    I am also summing up several columns...if that has anything to do with it.
    Does anyone have any suggestions?
    Thanks again!!!
    ~Jake
    Edited by: jhammer on Jul 27, 2010 11:02 AM

  • Creating a Crosstab/Pivot report in Oracle Apex

    Hello,
    I want to create a matrix view of a report in the following format. tried a lot of ways llike data pivoting, etc. but most of the ways use aggregate functions.
    format in which i require data is:
    ID NAME LEVEL PROJECT LOCATION ORACLE FORMS ORACLE REPORTS JAVA C++
    AAA123 ABC 2 AB AC Expert Aware Expert
    AAA124 DEF 3 BC AD Expert Proficient Aware
    The data in the table/view is in the format:
    ID NAME LEVEL PROJECT LOCATION Description Proficiency_ID
    AAA123 ABC 2 AB AC ORACLE FORMS Expert
    AAA123 ABC 2 AB AC ORACLE REPORTS Aware
    AAA123 ABC 2 AB AC JAVA Expert
    and similarly for other ID's.
    Since i need character values, aggregate functions would not be of much use.
    Thanks
    Varun
    Can anyone help me with this????

    Hi Arnaud,
    Saw the documentation that you had added and thanks for that..........but it is using sum(decode(...................
    which is an aggregate function but when i want to print character values for a certain distinct column value, that is where i am facing a problem..
    Hope you understood what i am saying:
    the id, name, level, prject, location will remain uniques and then i want proficiency to be put against each technology in a single row with al the technologies being disitnct columns..
    Thanks
    Varun

  • Anyone suggests a barcode font paid/free that really works with Crystal Report?

    Hi fellow B1 Users,
    I am having difficulty producing a print of crystal label report that produces barcodes which can be scanned.
    It seems like I have not been lucky getting barcode fonts and its dimensions (size with height and width) right so it can be scanned by simple
    barcode scanners.
    Anyone got their crystal label to be scan-able?
    Please suggest.
    Thank you,
    Syed

    Hi Gordon,
    Good to see you still active in SAP B1 forums.
    I tried fonts such as CCode39.
    However, I got lucky this time, the font IDAutomationHC39M worked for me, size 18.
    Did not have to do much setting on barcode scanner though I have done it before
    Thank you.

  • How to Extract data from a Request management tool to Apex to avoid working on Excel reports

    Client uses a ticketing tool,I donot know what is the database for the tool,but I would like to know the best way to extract data from the tool to pex so that we can eliminate working on Excel reports.These excel reports are basically the open request log,resolved tickets,aging tickets etc,currently we work on many excel reports,can we achieve this in Apex ,if so how do we achieve this.Then we would like to use this report and prepare multiple charts,how the above two requirements can be mapped.

    A very important function for the system will be - one sends an email in certain format to a dummy email address, then some data will be extracted from the email based on the pre-defined format and inserted into the database my APEX application is using.
    Any idea on how I can make it happen please? I agree that this is not really an Apex question, but a more general PL/SQL question.
    There are many approaches, all boiling down to one of these two:
    1) Push: Some process in the mail server sends/forwards information to your database when new mail arrives.
    The language/tools used to do this, and the way it would connect to your database, depends on your environment (what is your operating system? mail server? existing middleware/tools? security protocols used? etc.).
    2) Pull: Some process in the database contacts the mail server and polls for new information.
    Ie. some PL/SQL code would communicate with the mail server. Again, it depends on your environment (what is your operating system? mail server? existing middleware/tools? security protocols used? etc.).
    For example, if you are using Exchange 2007 or newer, it has a web services API:
    http://msdn.microsoft.com/en-us/library/dd877045.aspx
    The challenge here will be to build the correct SOAP requests from PL/SQL, and to handle the security protocols used.
    - Morten
    http://ora-00001.blogspot.com

  • Crosstab/Pivot queries.  How can I edit using Apex?

    Hello, all.
    I currently have a report within Apex that displays the results of a crosstab/pivot query as shown below. This works fine.
    What I now need to do is provide edit functionality on each row. The row does not have an individual ID column per sé as each row is the result of the crosstab query.
    What is the best way to offer the edit functionality using Apex?
    Thank,
    S>
    QUERY:
    SELECT vendor, product,
         MAX (DECODE (TO_CHAR(valuedate, 'MON'), 'JAN', amount, NULL)) AS JAN,
         MAX (DECODE (TO_CHAR(valuedate, 'MON'), 'FEB', amount, NULL)) AS FEB,
         MAX (DECODE (TO_CHAR(valuedate, 'MON'), 'MAR', amount, NULL)) AS MAR,
         MAX (DECODE (TO_CHAR(valuedate, 'MON'), 'APR', amount, NULL)) APR,
         MAX (DECODE (TO_CHAR(valuedate, 'MON'), 'MAY', amount, NULL)) MAY,
         MAX (DECODE (TO_CHAR(valuedate, 'MON'), 'JUN', amount, NULL)) JUN,
         MAX (DECODE (TO_CHAR(valuedate, 'MON'), 'JUL', amount, NULL)) JUL,
         MAX (DECODE (TO_CHAR(valuedate, 'MON'), 'AUG', amount, NULL)) AUG,
         MAX (DECODE (TO_CHAR(valuedate, 'MON'), 'SEP', amount, NULL)) SEP,
         MAX (DECODE (TO_CHAR(valuedate, 'MON'), 'OCT', amount, NULL)) OCT,
         MAX (DECODE (TO_CHAR(valuedate, 'MON'), 'NOV', amount, NULL)) NOV,
         MAX (DECODE (TO_CHAR(valuedate, 'MON'), 'DEC', amount, NULL)) DEC
    FROM (SELECT v.NAME AS vendor, p.NAME AS product, vt.NAME AS valuetype,
              e.datetime AS valuedate, e.VALUE AS amount
              FROM pfm_entry e, pfm_vendor v, pfm_product p, pfm_value_type vt
              WHERE e.vendor_route_id = v.route_id
              AND e.product_id = p.ID
              AND e.value_type_id = vt.ID
              AND e.value_type_id = 1
              AND e.datetime BETWEEN '01-JAN-07' AND '31-DEC-07')
    GROUP BY vendor, Product

    Hello, Steven
    Maybe you can use collections for that.
    Create a new collection which store your select statement.
    Each member of the collection have a unique id so you can use edit functionnality.
    And create a PL/SQL process which update your original table when the elements
    of your collection is updated.
    You can look at this doc. It may be useful.
    http://www.oracle.com/technology/oramag/oracle/06-nov/o66browser.html
    Mike

  • Change Maintenance Work Order Detail Report in Print WO page

    Hello,
    I would like to ask you for your help. We would like to have different report in Print WO function than Maintenance Work Order Detail Report. I mean SSM responsibility > Search for WOs > click Print WO icon. We applied patch #9871500 (I found it there: Templates associated to datadefinitions other than 'EAMWRREP' are not shown in the Work Order Detail report in EAM [ID 1209703.1]). I did personalizations steps - I defined new data definition (for example TEST) and report with data definition TEST is shown in the option on Print WO page now... But how should I it define to have correct result? What should be defined in Executable, Concurrent Program, Data Definition and Data Template? I have RDF and RTF files for this report. We are using different SQL than it is used in the original report. How could be used our SQL defined in RDF?
    Thanks, Regards,
    Jitka

    Hi,
      1) You can choose to select and Print shop paper when you need.No enhancement is required.
    2) There is not an option in standard to say Print/Not print Long text . You will have to replace the standard form with a custom form and build the logic to print /Not Print long text based on your rules.
    Regards
    Narasimhan

  • Receiving an error in Print Report.vi in the Text Report Example.vi

    I am trying to run the "Text Report Example.vi" example under Windows XP Professional, MS Office 2003 and LV 6.1 and I get an error in the "Print Report.vi" saying that there is an unknown error (-2147452567). I have searched through the Knowledgebase and found a couple of things to try but none of them worked (namely this solution). Is there a known problem with Office 2003 and LabVIEW 6.1? I can run the same example on another computer that is running the same setup except that it has MS Office 2002 SP3 and it prints properly.

    There are several reasons why you could get this error. There was a problem with a DLL change that caused either an invoke node or a property node (sorry, I don't remember which) to need to be replaced or relinked. I think that this is the problem that you linked to.
    The other potential problem is that you could be calling a font that you have on one of the computers but not on the other.
    I hope that this helps,
    Bob Young
    Bob Young - Test Engineer - Lapsed Certified LabVIEW Developer
    DISTek Integration, Inc. - NI Alliance Member
    mailto:[email protected]

  • Can't save power pivot report back to power pivot gallery...file is read only

    Hi eb
    I have developed an excel pivot report in a power pivot gallery (all in 2013).
    Next time i open that report from the power pivot gallery and attempt to save it again to the gallery
    I am blocked with a msg: we cant save http://........./powerpivot gallery/myPwerPvt.xslx  file is read only.
    To keep your changes you'll need to save the woorkbook with a new name or different location.
    Please help!
    TIA
    Rea

    Hi Rea,
    When you try to edit the PowerPivot workbook, are you open it as read-only mode? Please see the screenshot below:
    The "Read Only" mode will not be able to save any changes to the workbook you are loading.
    In addition, is it work for you while you save the PowerPivot workbook with a new name?
    Regards,
    Elvis Long
    TechNet Community Support

  • Identifying standard process & GAPS in QADB with REPORT example.

    Hi all,
    can anyone help me, what is QADB n how to identify GAPS in QADB n standard process with an report example? what is standard process in QADB?can we convert GAPS into standard process?
    <b>PLZ ANSWER REUIRED URGENTLY.....</b>
    Regards,
    Arundhathi

    Hi ,
    This currently seems like a bug , we have encountered this too.
    work around is you have to delete the rtf files from server Siebel\client\temp\XMLP directory and upload them again so that they are not cached any more.
    same on dedicated client you may have to delete relavant files form siebel\client\temp\xmlp directory and upload again.
    Thanks,
    Vamsi

  • Crystal Reports 2008 Customer Details Aging Report Example / Sample

    Hello!
    Anyone willing to send me a customer details aging report example for SAP Business One? (or give me a link?)
    I've been looking all over and have found examples of things, but not specifically for B1.
    Anything would be useful I am pretty flexible, I just want some bones to work from.  In return I can send you back what I build from it.
    Thanks in advance,
    Mike

    Hi Mike, you might have better  replies if you post your question to the B1 forum. They would be familiar with the B1 functioanlity and data sources.

  • New Blog Post - Transposed Report Example

    Hello,
    For anyone that's interested, I just published a blog entry on creating "Transposed Reports".
    http://www.danielmcghan.us/2009/11/transposed-report-example.html
    Regards,
    Dan
    http://danielmcghan.us
    http://www.skillbuilders.com

    While putting CSS into the body tag seems to work without issue I would prefer to put it into the head in its proper place.
    I am using this Javascript to do that:
    var ele = document.createElement("style");
    ele.type = "text/css";
    ele.innerHTML = "CSS CODE"; // Replace with CSS code.
    document.head.appendChild(ele);
    It works in all but IE8 and below (go figure). For IE8 I just left it in the body using IE conditional comments.
    Now if only we could come up with a bit of sorcery for the meta tags! 
    kenneth_rapp said:
    But every single bit of html and css and javascript rendered by our sites ought to be available to edit as we see fit, including what gets put out by the modules.
    I could not agree more. While I can see restricting this to some level there is much more I wish we could have access to and edit.
    Thanks for the Wizardly advice. =>

  • Power pivot report freeze while scrolling

    when scrolling the power pivot reports that are long the excel window freezes, the field list turns white, there's no data loss though, I can click the close button and it will give me the option to save the data if I haven't saved anything, they I go in
    the task manager and end task any running excel processes and it would start working again, this happens on multiple computer in the orgs (with different os windows 7, 8.1 server 2012 r2).

    Excel 32-bit or 64-bit? And how large is the workbook?
    If 32-bit, it's possible that it is facing memory issues. Try 64-bit if you can and see if you have better results.
    Regards, Avi
    www.powerpivotpro.com
    Wiki:How to ask a Power Pivot Question to get a prompt, accurate and helpful response

  • Drill down is not working for Pivot tables,but working for chart

    I have two reports and trying to navigate betwen summary report to detail report. But details report is displaying all the records .The filter condition is not working and displaying all the filters .I have Case statement in my filter.But the summary report column where the filter condition is applied is aggregated in the RPD level. Does this might be the reason ?. Is it passing different type of data type to details report ?. The filter condition is not working for Pivot table .But Chart is working fine and displaying the only selected records based on the filter condition.
    Please help me with the below issue.

    Hi sil174sss,
    Per my understanding you are experiencing the issue with the excel report which have add the drill down action, after export to excel only the expanded nodes included and the collapsed nodes is not shown, right?
    Generally, if we expand the nodes before export to excel then the excel will display the expanded details row and keep collapsed the details row which haven't expand, but we have the toggle "+","-" on the left of the Excel to help
    control the expand and collapse, when you click the "+" you can expand the collapsed notes to see the details rows.
    I have tested on my local environment with different version of SSRS and can always see the "+","-" as below:
    On the Top left corner you can find the "1","2", this help to control the "Collapse All" and "Expand All".
    If you can't see the "+","-" in the excel, the issue can be caused by the Excel version you are currently using, and also excel have limit support of this, please provide us the Excel version information and the SSRS version. You
    can reference to this similar thread:
    lost collapsing columns when export to excel
    Please try to export other drill down report to excel and check if they work fine, if they did, the issue can be caused by the drill down action you have added in this report is not correctly, if possible, please try to redesign the report.
    Article below about how to add  Expand/Collapse Action to an Item for your reference:
    http://msdn.microsoft.com/en-us/library/dd220405.aspx
    If your problem still exists, please feel free to ask
    Regards
    Vicky Liu

  • Changing datasource of reports in a loop only works for first report.

    Hi,
    I have code that loops through a list of reports to change the datasource and save the change in the report. The idea is that this can be done at build time so time taken at runtime is only for opening the report and running it.
    The problem is that the first iteration of the loop works, and any further ones don't. Apart from closing the client document is there anything else that should be explicitly closed? I don't retrieve any ReportSource from the Client Document so I shouldn't need to dispose of that...I don't think. In particular is there something that should be done to the databaseController retrieved from the clientDoc after each loop?
    The code goes like the below:
    for(File report : reports){
         System.out.println("Preparing report: " + report.getAbsolutePath());
         ReportClientDocument clientDoc = CRJavaHelper.getReportClientDocument(
                   report.getAbsolutePath());
         CRJavaHelper.replaceDBConnection(clientDoc, props);
         clientDoc.close();
         System.out.println("Report " + report.getAbsolutePath() + " prepared.");
    getReportClientDocument does this:
    ReportClientDocument clientDoc = new ReportClientDocument();
    clientDoc.setReportAppServer("inproc:jrc");
    clientDoc.open(fullPath,
              OpenReportOptions.openAsReadOnly.value());
    return clientDoc;
    replaceDBConnection does the following:
    DatabaseController dc = clientDoc.getDatabaseController();
    logonDataSource(dc, username, password);
    prepareReport(dc, schema);
    ConnectionInfos cis = dc.getConnectionInfos(null);
    for (IConnectionInfo oldci : cis) {
         IConnectionInfo newci = new ConnectionInfo();
         newci.setKind(ConnectionInfoKind.SQL);
         newci.setAttributes(propBag);
         newci.setUserName(username);
         newci.setPassword(password);
         dc.replaceConnection(oldci, newci, null, DBOptions._useDefault
                   + DBOptions._doNotVerifyDB);
    SubreportController src = clientDoc.getSubreportController();
    IStrings strs = src.getSubreportNames();
    Iterator<?> it = strs.iterator();
    while (it.hasNext()) {
            String name = (String) it.next();
         ISubreportClientDocument subreport = src.getSubreport(name);
         DatabaseController sdc = subreport.getDatabaseController();
         cis = sdc.getConnectionInfos(null);
         for (IConnectionInfo oldci : cis) {
              IConnectionInfo newci = new ConnectionInfo();
              newci.setAttributes(new PropertyBag(propBag));
              newci.setUserName(username);
              newci.setPassword(password);
              sdc.replaceConnection(oldci, newci, null, DBOptions._useDefault
                        + DBOptions._doNotVerifyDB);
    clientDoc.save();

    What's the URL for the site where you are using this?  Offhand, it looks like it should work with your first example so you are either placing the script before those elements are loaded or you might try wrapping your current javascript inside the:
    $(document).ready(function() {
    --- your existing javascript here
    This make sure the code runs once all the html is loaded on the page.  Without seeing a URL and debugging with the js console in Chrome I can't give you a solid answer.
    But, I do know that you can probably do this with a lot less markup.  Once we figure out what the actual problem is I have a better solution mocked up for you on jsfiddle.
    When looking at my HTML code on jsfiddle, please realize I setup some dummy HTML and removed your tags and added actual values which would be output by your tags.  The main thing I did was remove the whole div.more-selection and instead, added a "data-is-selected" attribute on your div.more-option element.  Then, in my javascript for each div.my-option element on the page, we loop through them, find the value of that data attribute and hide that div if it's less than 1 (or 0).
    Here's the fiddle for you to look at:  http://jsfiddle.net/thetrickster/Mfmdu/
    You'll see in the end result that only two divs show up, both of those divs have data-is-selected="1".
    You can try pasting the javascript code near the closing </body> tag on your page and make sure to wrap my js inside a <script> tag, obviously.  My way is neater on the markup side.  If you can't get it to work it's likely a jquery conflict issue.  My version is using the $(document).ready() method to make sure all the code is loaded before it runs.
    Best,
    Chris

Maybe you are looking for