Passing Dataset in Subreport

Hi,
I have a report that has a summary section (main report) and details section (subreport located in the report footer of the main). Both the main and subreport pull data from the same tsql stored procedure. Is there a way i can pass the dataset from the main report to the subreport so that i dont have to make 2 calls to the stored procedure as it is very expensive? Can this be done through shared variables?
Thanks in advance,
Will

I suppose it might be feasible using shared array variables, but arrays have a limit of 1000 elements.
Can the summary section be built with a crosstab?  That would allow you to use one call to the SP to generate both sets of results.
Lastly, you could store the results of the SP call into a table in the database, using some identifier to distinguish separate report runs (for simultaneous executions), so the SP is only called once (all within an SQL Command in the report), then write both parts of the report over the results table.  You'd want to clear the results table periodically, so you may also want a run timestamp in the table.
Other than the above, I don't think there's another way to reduce the SP call to one.
HTH,
Carl

Similar Messages

  • Passing values to subreport in SSRS throwing an error - Data Retrieval failed for the report, please check the log for more details.

    Hi,
    I have the subreport calling from the main report. The subreport is based on MDX query agianst the SSAS cube. some dimensions in cube has values 0 and 1.
    when I try to pass '0' to the sub report as the parameter value, it gives an error "Data Retrieval failed for the report, please check the log for more details".
    Actually I am using table for storing these parameter values. In the main report I am calling this table (dataset) and passing these values to subreport.
    so I have given like [0],[1] and this works fine. when I give only either [0] or [1] then it is throwing an error.
    Could you please advise on this.
    Appreciate all and any help.
    Thanks,
    Divya

    Hi Divya,
    Based on the current description, I understand that there is no issue if you pass two values from main report to subreport, while the issue occurs when passing one value to subreport.
    To narrow down the issue, I want to confirm whether the subreport can run if there is only [0] or [1] in the subreport. If so, it indicates the query statements exist error in the subreport. If it’s not the case, this shows the issue occurs during passing
    values from main report to subreport. To make further analysis, please post the details of query statements of the subreport to the forum.
    Regards,
    Heidi Duan
    Heidi Duan
    TechNet Community Support

  • Pass variable to subreport

    I'm using SQL Server 2014 and Reporting Services and I've got a report containing a number of linked subreports. The main report I have will be different for each customer I produce the report for and will contain different text, but I need to pass a customerID
    to the subreport in order to filter the following query:
    SELECT V.vCenterName,
    COUNT(DISTINCT M.VMName) *1.0/COUNT(DISTINCT M.Hostname) AS VMsPerHost
    FROM
    dbo.VMs M INNER JOIN dbo.vcenters V ON M.vCenterID = V.vCenterID
    WHERE M.vCenterID LIKE V.vCenterID
    GROUP BY V.vCenterName
    ORDER BY VMsPerHost DESC
    If I can declare a VARCHAR variable before the query and then pass the customerID from the main report to the subreport, I can filter the data by the specific customer only and do this for each main report. How would this be done though. I know there's an
    option to work with parameters but I don't understand how it works.
    Thanks in advance
    Adam

    Hi Adam,
    create customerid parameter in sub-report.
    In main report use subreport control and provide the subreport.
    in subreport properties go to parameter section.set parameter value from your main report parameter which will give the customer id.
    If you want to pass the value by dataset you can give the dataset field value.
    Thanks
    Prasad

  • Passing values to subreport that has many records?

    I have a report with a subreport in it and that subreport is a bill that includes things like name, address, etc. My report will run the subreport many times for each bill that comes up.
    I am needing to pass values to text objects in these individual subreports that is information that is obtained in the code. My code works fine when this subreport is ran on it's own but I'm having trouble figuring out how to change the code up to put the information into individual subreports. Here is a simple example of some of my code:
    using (PrintBills reportPrintBills = new PrintBills())
        using (CrystalReportBill reportBill = new CrystalReportBill())
            CrystalDecisions.CrystalReports.Engine.TextObject lblBalanceDue = ((CrystalDecisions.CrystalReports.Engine.TextObject)reportBill.Summary.ReportObjects["lblBalanceDue"]);
            CrystalDecisions.CrystalReports.Engine.TextObject lblName = ((CrystalDecisions.CrystalReports.Engine.TextObject)reportBill.Summary.ReportObjects["lblName"]);
            DataSet ds = new DataSet();
            GetBills(ref ds, "Bills", date);
            DataView dvID = new DataView(ds.Tables["Bills"]);
            num = 0;
            foreach (DataRowView rowID in dvID)
                GetBioInfo(ref ds, "BioData", id);
                DataRow row = ds.Tables["BioData"].Rows[num];
                lblName.Text = row["Stu_Name"].ToString();
                lblBalanceDue.Text = String.Format("{0:C}", row["Amount_Due"]);
                num++;
        reportPrintBills.SetParameterValue("@tblMonth", date);
        reportPrintBills.SetParameterValue("@begdate", strBegdate);
        reportPrintBills.SetParameterValue("@enddate", strEnddate);
        //Export to PDF code here
    reportBill does not display the values obviously. Somehow I need to set that reportBill is a subreport of reportPrintBills in the code so that each record will recognize the TextObject values that I am sending to them.
    Another solution I've tried is adding parameter fields to reportBill and reportPrintBills and linking them up and then passing values like so:
    foreach (DataRowView rowCWID in dvCWID)
        GetBioInfo(ref ds, "BioData", id);
        DataRow row = ds.Tables["BioData"].Rows[num];
        name = row["Stu_Name"].ToString();
        amtDue = String.Format("{0:C}", row["Amount_Due"]);
        reportPrintBills.SetParameterValue("@strName", name);
        reportPrintBills.SetParameterValue("@strAmtDue", amtDue);
        num++;
    But the value stays the same in all of the subreports rather than changing with each pass through.

    Open the report up in the Designer and Click on Edit, Subreport Links. Likely what you can do is use Shared Variables to pass values from the main report to the subreport.
    You need to do this in the report first. If you are using RAS then you can at runtime. If RAS is not available to you then no way in code.
    See these samples:
    Root Page
    http://wiki.sdn.sap.com/wiki/display/BOBJ/BusinessIntelligence%28BusinessObjects%29+Home
    Enterprise Samples (including managed and unmanaged ras)
    http://wiki.sdn.sap.com/wiki/display/BOBJ/BusinessObjectsSDKSampleApplications
    Non-Enterprise Samples
    http://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsSDKSampleApplications
    Exporting Samples (RAS)
    http://wiki.sdn.sap.com/wiki/display/BOBJ/NETRASSDK+Samples#NETRASSDKSamples-Exporting%2FPrinting
    Also refer to the DSK help files for the Engine or RAS and search on the subreportcontroller.
    If you are using RAS I'll move your post to the SDK forum.
    Thank you
    Don

  • Pass data to SUbreport

    Hi to all,
    I'm using asp.net 2.0, VS 2005 and by default CR.
    I have a CR and added sub report in detail section, i want to know how to pass the DataSet value to report and sub report.

    Lots of info and code on this here in the forums. Also, see [Crystal Reports For Visual Studio 2005 Walkthroughs|https://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/2081b4d9-6864-2b10-f49d-918baefc7a23&overridelayout=true] page 332 re setting a report to a dataset. To do th same with a subreport use code along these lines:
    Dim crSections As Sections
    Dim crSection As Section
    Dim crSubreportObject As SubreportObject
    'set the crSections object to the current report's sections
    crSections = crReportDocument.ReportDefinition.Sections
    'loop through all the sections to find all the report objects
    For Each crSection In crSections
    crReportObjects = crSection.ReportObjects
    'loop through all the report objects to find all the subreports
    For Each crReportObject In crReportObjects
    If crReportObject.Kind = ReportObjectKind.SubreportObject Then
    'you will need to typecast the reportobject to a subreport
    'object once you find it
    crSubreportObject = CType(crReportObject, SubreportObject)
    'open the subreport object
    crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
    'set the database and tables objects to work with the subreport
    <your .SetDataSource code here>
    Next
    End If
    Next
    Other possible sources of information.
    Notes:
    https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_ossnotes&query=&adv=true
    Articles:
    https://www.sdn.sap.com/irj/sdn/businessobjects-articles
    Sample apps:
    https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples
    Ludek

  • Problems passing Resultset to SubReport

    Hello Everybody,
    I have a very simple Problem but I can not fix it. I have a Report which contains a Subreport. The Subreport is nearly the same like the Mainreport, I´m also passing Parameters to the Subreport. This works fine.
    But if I try to pass a ResultSet, the ReportViewer ask for Username an Password of the Database. The Subreport contains further all Datasets of the Database and not the custombuild in the Mainapplication.
    Does anybody know why this happend?
    Thanks a lot.
    Markus

    Please define "Fails". Error? Behavior? Symptom?
    - Ludek

  • Data Passing from a Subreport to the Main Report

    <p>Hello,</p><p>I have been able to pass data from a subreport to a main report using shared variables. The Complete Reference: CR XI (p. 313) states that you should be able to now suppress the subreport to prevent it from showing on the main report, however this is not working. I want to get the data from the subreport and then further manipulate it in the main report, and I do not want the subreport shown on the main report. I tried suppressing/hiding the section where the subreport is placed as well as suppressing the subreport itself. The formula values on the main report become null when I do this though. Is it possible to keep the subreport off the main report?</p><p>Thanks.</p>

    Search forums, this has been answered multiple times.

  • "Missing parameter values " when passing parameter to subreport

    i have a subreport embedded in main report.
    sub report take a procedure with parameter.the main report does nothing but only holds many sub report.now i have to pass parameter from code to sub report.ive used the following code but it gives "missing parameter values" error
    Any help??
       ParameterField paramField = new ParameterField();
            ParameterFields paramFields = new ParameterFields();
            ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
            paramField.Name = "@LabNo";
            paramDiscreteValue.Value = "1034";
            paramFields.Add(paramField);
            ParameterValues paramvalues = new ParameterValues();
           paramvalues.Add(paramDiscreteValue);
            paramField.CurrentValues.Add(paramDiscreteValue);
    rptDocument.ParameterFields[0].CurrentValues = paramvalues;

    does the sub report have parameters in it as well?
    if the sp used for the sub report has parameters you need to pass them to the sub. i would probably remove the parameters from the sub and join the sub to the main by the parameter from the main to the field in the sub.

  • Crystal Reports 10, Want to pass values from subreports to main report

    Post Author: playmkr278
    CA Forum: General
    Is there a way to just share values out of subreports.
    The reason I ask is that I am having problems pulling the correct information in one subreport so I'd like to use 2 subreports to pull out Billable hours on one and Billed Hours on another and then add them together to display on the main report.

    Post Author: Jedit
    CA Forum: General
    Yep there is!
    In your sub report
    I the formula editor create a shared variable then create the same variable in your main report.
    EG
    IN your SUB
    Create new formular called tothrs etcu2026..
    whileprinting records;
    shared numbervar tothrs: sum({table.fieldname}&#93;
    In Your Main Report
    whileprinting records;
    shared numbervar tothrs
    this passes the value from your sub to the main, check help for different types of format as the one above is only for a number there are others for time & date etc..
    hope this helps!
    I have been doing a similar exercise myself but got stuck summing the parameter values in my main report, if you solve this let me know?
    Please see http://technicalsupport.businessobjects.com/cs/forums/thread/6210.aspx

  • Passing Array From Subreport to Main Report then Summing

    Hi,
    I am having troble passing an array from a sub report to the main repport.  I have managed to create the array, pass it and display it in the main report, however the first value of the array is displayed twice.  Here is the  formulae I have used:
    In the sub report:
    whileprintingrecords;
    shared stringvar str;
    str:=str{@value}","
    In the main report:
    whileprintingrecords;
    shared stringvar str;
    stringvar array arr;
    arr:=split(str,",");
    join(arr,",")
    Also, when I have managed to resolve the problem of the first value printing twice, I hope to change the array back to a number array and sum all of the values together.  I'm not too sure how to do this either.
    I hope you can help.
    Julie

    Ummm... Isn't Join(Split(str,","), ",") = str?  Why bother with the two extra lines of code?  Also, are you sure the subreport isn't creating the "duplicate first value"?  (I.e.  The data has the same value on two records, so it's being added twice?)
    Also if you're looking for the sum, why not create another shared variable and sum the value in the subreport as you're building the array (assuming you need the array for other purposes)?
    HTH,
    Carl

  • Passing values from subreport to main report

    Dear All,
           I have used shared values in my sub report and i want to use that shared variable in my main report in one of the formulas for average calculation but i see the values as 0.
    Can someone let me know what I am missing.
    Regards,
    Sonali

    Hi
    The most important thing to remember when using shared variables is that Crystal Reports must first evaluate the formula where the value is stored before evaluating the formula that retrieves the shared variable.
    For example if you want to pass a grand total from the subreport to do a calculation in the main report, follow these steps:
    1. In the subreport, create a formula similar to the one below:
    //@SubFormula
    //Stores the grand total of the
    //{Orders.Order Amount} field
    //in a currency variable called 'myTotal'
    WhilePrintingRecords;
    Shared CurrencyVar myTotal := Sum ({Orders.Order Amount})
    2. Place this formula in your subreport.
    3. In the main report, create a formula that declares the same variable name:
    //@MainFormula
    //Returns the value that was stored
    //in the shared currency variable called
    //myTotal in the subreport
    WhilePrintingRecords;
    Shared CurrencyVar myTotal;
    myTotal
    4. Place @MainFormula in a main report section that is beneath the section containing the subreport.
    NOTE:
    For the shared variable to return the correct value in the main report, you must place @MainFormula in a main report section that is beneath the section containing the subreport. This ensures Crystal Reports evaluates the @SubFormula before @MainFormula.
    One way to do this is to insert a section below the section containing the subreport, and place @MainFormula in this new sub-section:
    · On the 'Format' menu, click 'Section'.
    · On the 'Sections' list, click the section containing the subreport.
    · Click 'Insert' (at top of dialog box). This inserts an additional subsection.
    · Click 'OK' to return to the report, and insert @MainFormula into this new sub-section.
    The next time you preview the report, @MainFormula displays the value from the subreport. In this particular example, that value was the grand total of the {Orders.Order Amount} field.
    5. Once you have verified that @MainFormula is returning the correct value from the subreport, you can include this formula in other main report formulas, such as:
    //@NewFormula
    //includes data from subreport
    {@MainFormula} + Sum ({Customer.Last Year's Sales})
    · Place this formula in the same section as @MainFormula, or in a section further down on the report.
    You have now successfully shared data from a subreport with the main report.
    NOTE:
    This is not possible with On Demand Subreports in Crystal Reports since the report will not be processed until after clicking report.
    Regards
    Sourashree

  • Best Practices: Question about Passing DataSet to Crystal through C#

    I have used the tutorial provided by Business Objects and have successfully passed a dataset from C# code to Crystal Reports.
    I have a few questions about "best pratices" though.
    It appears that when passing the dataset to crystal then you no longer have the ability to put SQL Expressions in the report anymore otherwise errors will occur.
    So, I'm trying to come up with a way to have a custom field in the SELECT statement and have it show up on the report as a field. So, in the below example I created a custom SQL field called TIMES7 in the query.
    "Select CLM_ID, CLM, PAID_111X, *(PAID111X * 7) As TIMES7*_ From WIKI.MULCRICKET WHERE CLM_ID < 5"
    If I create a formula field in Crystal and set it's value to {MULCRICKET .TIMES7} then it works like a hybrid SQL Expression at run-time.
    This does work but has issues because the database field doesn't really exist in the design environment which causes error when the formula is saved. But it does work at run-time.
    I was wondering if their was a best practice for this?

    So why are you using a formula that doesn't work? If it errors in the designer it's telling you it's not supported.
    Drop the formula into a filed and hide it if you don't want it displayed, this way it gets into the record selection formula.
    "Best Practices" is don't use formulae that won't verify in the Designer. "If it doesn't work in the designer it won't work in code"
    If you need to add an "unknown" field at run time then use RAS to insert the field.

  • Passing values in Subreport

    Hi,
    In GH1: i have one subreport
    In GH2: i have two or three subreport
    My question is, i have to pass the GH2 sureport values to GH1 Report Header. can any one explain?

    by using shared formulas.
    These are my personal crib notes and formula names to remind me how to do it:
    Shared variable formulas for subreport/main report,
    must use same <var name> in each shared formula variable declaraions. 
    also use the same <var name> in naming shared formulas & in related running
    total formula names and declared variables to mentally link them together.
    Shared formulas work in either direction.  Order of appearence on report controls
    primary/secondary. To go from subreport to main report, @mainform.<shared var> 
    must appear after the subreport in the main report.
    subreport shared formula - primary; must "print" in subreport-can be white text
    and/or off the 'page' but do not suppress
    1. {@subform.field1} <<<sample formula
    ////{@subform.<var name>}   stores the figure to be shared with main report.
    whileprintingrecords;
    Shared numberVar <var name> := <source field or formula name>;
    main report shared formula - secondary. must "print" in main report after subreport;
    can be white text and/or off the 'page', but do not suppress; use same <var name>
    as subreport formula
    2. {@mainform.field1} <<<sample formula
    //{@mainform.var name>} retrieves {@subform.<var name>}
    whileprintingrecords;
    shared numberVar <var name> ;
    <var name>
    You could then share the formula to the next subreport by putting the shared formula
    {@subform.field1} in the next subreport.

  • Fail to pass parameters to subreports via VB6 application

    Hi everybody,
    I'm a newbie here and I need to view a report (CR10) via a VB6 application where you enter the report's parameters. The report has subreports where its parameters are linked to the main report's ones.
    The application works properly on the development computer but doesn't work on the client computer (Crystal Reports 10 is not installed on it). In fact, the "Enter Parameter Value" message box appears and wants me to enter the parameters manually.
    For reports without subreports, it works nicely.
    How can I do to fix this problem ?
    I really need your help.
    Thank you
    Delphine

    Hello, Delphine;
    If the parameters are linked to the main report they should pass correctly.
    Linked parameters will fail if the database logon fails and the data they are linked to does not exist.
    Open the report in the Crystal Report designer. Go to Database|Set Datasource location.
    What is displayed for the properties of the main report database?
    For the subreport database?
    How do you pass the connection properties in code at runtime?
    Elaine

  • Passing Data into Subreport

    Hello,
    I am using Crystal 10. I am wondering if it is possible to pass data from a report into a subreport for calculations.
    Thank you.

    Hi Sabian,
    You can pull sub report information and use in main report, while getting the data from sub report to main please take care of the following :
    --Your sub report should be placed above your calculations in main report. ie. after processing of your sub report only you get data into your main report.
    --While writing formulas in sub report or in main report you will have to use Whileprintingrecords; to get get data into your shared variables. Eg:
    Whileprintingrecords;
    shared numbervar x;
    x:=x+fieldvalue;
    --When you create a formula in sub report it should be plced on your sub report, use the same variable name while creating a formula in main report.
    Make sure that the shared variable which you are calling in the main report should be in the below section of the sub report. If you want to pass the sub report to the main report in the same section then insert section below the sub report
    Hope this helps
    Regards,
    Shweta

Maybe you are looking for

  • Windows 7 Install Issues with Mac Pro

    I have Mac Pro with Windows XP SP3 installed with Boot Camp on a separate, dedicated 250GB HD. I purchased an upgrade version of Windows 7 Home Premium. I hoped to install the 64-bit version. I upgraded, per Boot Camp I&S Guide, Boot Camp to version

  • Problem with small text in iview header

    hi, i got a little problem with iView header. I've set 2 pages containing the same iViews. The 2 pages have layout (1 column full width -- standard) and the 2 pages have the same properties, themes. The problem is that in the first page the header te

  • Adding flags to a Panasonic 1200 deck for reverse telecine in post?

    I am doing a telecine of some 16mm film. We are dumping it as 720p DVCPRO HD with a rented Panasonic 1200 deck. I did this last time and everything looks great except I had major issues turning my 59.94 source material to 23.98 material [reverse tele

  • Oracle 11g installation

    Hi all, By mistake i have installed oracle on my F: drive which is external (i.e. i have app folder in F drive and oracle folder in C drive program files folder) Now when i execute few commands like isqlplusctl start, it cannot execute similarly when

  • Producer consumer loop only execute once?

    Hello here, In my VI, the producer loop seems working continuously, but the consumer loop only execute once. I haven't used producer/consumer pattern before, could someone give me some ideas why this happens? My code is in attachment. Thank you in ad