I am writing some custom reports for some 3rd party software. The software provides stored procedures from which to get my data.
One of the new requirements for my report is to get the data for an order, then if there is an associated order, then run the same sproc using the associated order's data.
Basically:
Order #1 is associated with Order #2, I need to:
Run sproc GetOrderInfo (pass parameter OrderId = 1)
Look at field AssociatedOrderId (in this case it equals a string value of "2", but could be null or even a blank string [I know I know, but I don't own the database design])
Run sproc GetOrderInfo (pass parameter OrderId = 2 [OrderId is an int])
Display report
Is this possible in Crystal reports? I cannot see a way to set the parameter of the sproc based on other sproc's returned values.
Database is SqlServer, but I doubt that matters.
You can create a subreport, base it on the same stored procedure and link the parameters values of the subreport to a field in the main report
Related
I have a parent report with a dynamic where clause, which is passed as $P!{WHERE_CLAUSE}, and the where clause in turn contains $P{} parameters
Eg: $P!{WHERE_CLAUSE}=> where docno between $P{P_FROMDOCNO} and $P{P_TODOCNO}
Values for $P{P_FROMDOCNO} and $P{P_TODOCNO} are also passed in the same execution
The parent report has a subreport, that summarizes based on certain category, whose query is based on the parent's where clause.
select vat,sum(amt) from tablename $P!{WHERECLAUSE} order by vat
So the where clause is passed to the sub-report using parameter mapping. But the subreport fails to read $P{P_FROMDOCNO} and $P{P_TODOCNO} values from the parent, resulting in empty document. All the above parameters have been mapped to the subreport parameters. The main goal is to fire the query in the database with bind parameters, even for the sub reports.
Kindly let me know if any solution for the above.
Edit: My question is not a duplicate of the mentioned question in the comments section. Because my subreport receives all the mapped parameter values, but the dynamic where clause($P!{WHERECLAUSE_SUB} which has the $P{P_FROMDOCNO} and $P{P_TODOCNO} fails to evaluate.
Thanks in advance,
Geetha
I have a table with a GUID column and a recordId (not a guid) column. I need my report to accept a GUID as a report parameter and use it as part of the Record Selection formula to make certain the report only get the record Id's it needs.
[Linking Table] -> [Detail Containing Table]
Since the report doesn't support passing a GUID parameter directly, I was able to convert the GUID to a string and pass it in without incident. When I generate the SQL query in Crystal Designer it looks good: The WHERE clause is properly formatted and if I run the query in SQL Designer it will find all the records I need to fetch. Actually attempting to display the report fail however, it states that 0 records were found despite SQL Profiler also showing that the same SQL was fired off.
Has anyone run into this issue? Is there any way to get the Record Selection formula to not drop the records when actually displaying the report?
After working with SAP Support we were able to determine that there is a defect in 14.0.11. The SQL Query was being formatted correctly, but the record linking under the hood was using a different (and incorrect) linking order. Since the database results and internal schema wound up with different starting tables, Crystal discarded the results to prevent exceptions.
Going to Database Expert -> Links -> Order Links and checking the 'Link Ordering is Enforced' box forced the engine to use the same link ordering throughout the report in the proper order. Then the SQL query and internal record schema matched and we got records.
I am evaluating JasperReports and Jaspersoft Studio for using in the company I work for and I am trying to build a report that contains information from 2 different databases.
I have 2 data adapters configured.
I've my research and found out that the only way to do so is to have either a list, table or subreport in a main report, but I still can't make it work.
I took the subreport approach, I have two reports that work separately, the main one executes this query in the sample DB
select 1 from ORDERS limit 10
The subreport runs this one in a Vertica database I own:
select 1 from my_schema.my_table limit 10
Both of them, as said, run separately.
So I go to the mainreport and add a SubReport element to the ColumnHeader band, then the wizard opens:
In the step 1 I select the subreport from the project
Second step is connection. I have these options:
Same JDBC conection
Use another connection
Use an empty data source
Use a JRDatasourceExpression
Don't use any connection.
The first and third ones are not what I want.
I tried to set the second one, but I could not find a way to select the data adapter that I have configured.
The last one doesn't work ( I get a message saying that my_schema doesn't exists, so I think that it is still trying to access the MainReport database).
Is there anyway I can make a subreport run a query in a different database/datasource from the main report?
I can summarize what I did if anyone has the same issue:
I made a proof of concept (therefore I do not have the code anymore), but I created a JRDataSource class using this tutorial and there I manually access the database and returned the rows. Then I use this as the datasource of my subreport/table.
Not as nice as I wanted, but it is possible
I guess this iReport article is also applicable to reports designed in jaspersoft studio; you just need to define the subreport connection parameter with the given expression.
Perhaps, you can ask for help from two parameters which defined in the master report by yourself. Such as:
$P{MySubreport} with type net.sf.jasperreport.engine.JasperReport;
$P{MyDatasource} with type net.sf.jasperreport.engine.JRDataSource;
Associate these two parameters to your subreport element respectively in attributes 'Expression' and 'Data Source Expression';
Please write your DataSource class that implements interface JRDataSource.
Then, in your servlet class, put your real parameter values(JasperReport for your subreport .jasper file, and your DataSource object) into a parameters Map object, and call JasperFillManager.fillReport().
I'm using Crystal Reports XI. We use Crystal Reports embedded into a share point site written in C#/ASP.net. Our web developers instatiate a report in code and pass the selection criteria by appending to the Select Formula object.
The problem I'm running in to is that when I use a SQL Command Object, the selection formula is not being passed to the sql server as a where clause. This causes the entire result set to be queried and then limited on the server. For very large tables, this is causing a significant performance hit.
Here's an example:
SELECT foo.id, foo.code, foo.name
FROM foo foo
Select criteria is shown as:
{Command.name} like "someName"
If I then run the report the entire foo table is queried and then crystal reports limits from the entire set.
If instead I do it based on the table without a command object, the WHERE clause is appended to the sql query and all the limiting is done at the db level.
I'm assuming this occurs because a SQL command could potentially be very complex and adding a WHERE clause to the bottom isn't always possible. My question then, is there any good way to force some sort of pass through. Should I be talking to the C# devs and asking them to rework the way we pass parameters?
Thanks for any help and discussions.
A record-selection formula is never added to the Command-object's query.
I'm not certain if the CR SDK supports Command object modification (I know it supports read-only access, however).
The Command object does support parameters (in 2008, they can be multi-valued parameters) which can be accessed programmatically (they are converted to Parameter Fields in the report).
I'm assuming that you are using a Command object because of the query's complexity. If you can push the complexity to a SQL view, then use the 'visual linking' expert to create your query, you'll have more flexibility.
I have crystal report with dynamic parameter (for example, linked on table COUNTRIES in some datebase).
How can i programmatically get allowed values for this parameter (list of countries)?
For static i can get default values using :
ReportDocument rd = new ReportDocument();
rd.Load(reporthPath);
rd.ParameterFields; // contains params with default values collections
Dynamic parameters has no items in DefaultValues collection. I can retrieve existing connections for report, but where i can get relation between connection and dynamic parameters?
It's not possible to do that in Crystal Reports. It's better to not use dynamic parameter field; they make your report unnecessary slow. Instead convert them to a static parameter an fill the default values from your code; that's much faster plus you know what the accepted values are.
the above answer is incorrect - as of Crystal Reports XI (at least that's where my information comes from) it is possible; see
http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/en/CrystalReports_dotNET_SDK/crsdk_net_doc/doc/crsdk_net_doc/html/crtsktutorialsrdparametersdiscrete.htm, particularly parts 2(Creating a Report with Parameters) and 5(Create a ListBox Control that Displays Default Parameters)
basically the list of possible values can be taken from the default values list,
thanks,
MD-Tech
Improving on the existing answers a little bit after running this problem to ground myself:
A ParameterField with a Static list of values has these values as items in its DefaultValues collection. The problem is that a ParameterField with a Dynamic list does not have these values pre-populated and the API does not seem to have a mechanism to query them.
A workaround involves using a Static list instead of a Dynamic one, but there may be hundreds of acceptable values which may change over time. Unless remembering to change the report(s) is appealing, a Dynamic list makes sense in this context.
In addition, using the CrystalDecisions.ReportAppServer.DataDefModel.ParameterField reveals a property BrowseField. BrowseField has properties TableAlias and Name which you can query with ADO.NET. However, BrowseField is only populated for Static parameters; it is null when using a Dynamic parameter. This is currently documented as a "needs fixed" on SAP's knowledge base, Article 2114469.
So, once you somehow get the table and column name, use ADO.NET to query the database and stick those values into the DefaultValues collection of the Dynamic parameter. Consider using a naming convention for the parameters to make this easier. Perhaps use a static parameter that isn't used in the report to house your table and column information.