The company I work for is using MacolaES for an ERP system. The SQL Server database is structured such that when things are no longer considered active, they are moved from a set of "active" tables to a set of "history" tables. This helps to keep the "active" tables small enough that queries return quickly. On the flip side, the history tables are enormous. The appropriate columns are indexed in these tables, and if you query for something specific it returns quickly.
The problem is when you make a Crystal Report, which is prompting the user for a parameter. For reasons not known to me, Crystal parameters are not translated into SQL parameters, so you end up with queries selecting everything from the order header history table inner joined to everything in the order lines history table, which results in over 8 million rows.
Is there a way to get Crystal Reports to use the parameters in the SQL query instead of loading all the records and filtering after the fact? I read somewhere that a stored procedure should work, but I'm curious if an ordinary parameterized query is possible in the interest of saving my time.
Here is the selection formula:
(
trim({Orderheader.ord_no}) = {?Order No}
)
and
(
{Orderheader.ord_type} = 'O'
)
and
(
{orderlines.ord_type} = 'O'
)
In Crystal Reports top menu go to Report / Selection Formulas / Record... There you can add a formula similar to:
{table.field1} = {?Parameter1} and {table.field2} = {?Parameter2}
That will add the condition to the where statement of the SQL query that the report will use to pull the rows.
To verify what is the condition in the where statement that the report is using to pull the data you can go to the menu database / Show SQL Statement. That way you can verify that the report is using the parameters in the filter.
Crystal Reports 8.5 User Guide mention the following tips:
To push down record selection, you
must select “Use Indexes or Server for
Speed” in the Report Options dialog
box (available on the File menu).
In record selection formulas, avoid data
type conversions on fields that are
not parameter fields. For example,
avoid using ToText( ) to convert a
numeric database field to a string
database field.
You are able to push down some record selection formulas
that use constant expressions.
Your formula has a TRIM function on a field. The function against the field does not allow Crystal to push the formula to the database because is not a constant expression.
If you really need to trim the order number field you should do it using SQL Expressions.
References:
Check out this article.
Related
I use PowerBI (October 2020), and I have one dashboard with a drop down DATE slicer. I have two problems with it:
I need to pass the value of slicer to a stored procedure to use there as a where condition. I mean the query has used in stored procedure, filtered by the date has picked in slicer.
I need keep update the value of slicer too. I means if today is 2021/08/10, this date shows in slicer and tomorrow is become 2020/08/11 automatically.
If somebody can provide some solution that would be great.
Thanks in advance
1).
You have to create 2 parameters for selecting data range if you use stored procedure.
Similar thing happen to me earlier, so I switched from stored procedure to mysql or sql views. I managed to get data via join queries and optimize it.
Because if you use Views you have some limitations.
If you have correct requirement hardcode lower bound date, and if you use view it act as mysql table.
2).
If you have date slicer in the filters you can change it to relative date to selected time, then your upper bound date will update accordingly.
After hours of testing I have the strong opinion that it is not possible to call SQL stored procedures with parameters and DirectQuery, affected by user controls in a PowerBI dashboard.
This is easily done in PowerBI Report Builder.
You can create parameters in PowerBI that affect the parameter-values in your SQL-stored procedures but they are not adjustable by the user in your dashboard.
The syntax for the call to SQL SP is:
let
Source = Sql.Database("[server]", "[database]", [Query="EXEC direct.sp_[stored procedure] '" & DateTime.ToText(prmStartDatum) & "', '" & DateTime.ToText(prmEindDatum) & "'", CommandTimeout=#duration(0, 0, 10, 0), HierarchicalNavigation=true, MultiSubnetFailover=true])
in
Source
The error you get is:
Microsoft SQL: Incorrect syntax near the keyword 'EXEC'. Incorrect
syntax near ')'.
When this is fixed, it would be a great improvement to PowerBI dashboards.
I'm new to SSRS so forgive me if this is an obvious answer. I'll try and simplify my problem as best I can:
I have a report that's based off of a query. On that report it has the fields Account ID and Mail Date from that query on the page. Not a tablix, just the fields.
When I run the query on the DB, it will return 100 records, so 100 distinct Account ID and Mail Date pairs.
When I run the report, I only get one instance of the report, the very first Account ID/Mail Date pair. I was expecting 100 instances of the report, one for each the Account ID/Mail Date pairs (that's how it worked in Oracle Forms, which I'm trying to convert).
Is there a configuration or setting I'm missing to get the expected behavior?
Thanks.
I see a few people have viewed this so here's the solution I used:
I created another report with my dataset, put a table on that report, set it break after each record, then put a subreport on the table that contained the original report and passed all the dataset values from the table to the subreport.
The subreport was then created with 1 record per page as I wanted.
I have a Count query that uses multiple criteria to produce a result looking like:
count ID
1 "abc"
4 "bcd"
5 "def"
1 "cde"
This shows how many times the ID appears in a given database. The datasource is through an odbc connection that updates automatically. So the ID values change everytime it is opened. I would like to try to turn the unique ID or the associated count into a hyperlink that when clicked will return all information involved in the count (*note the database has much more information associated with the ID's than is counted, a date range of the previous three months is applied.) Can this be done simply?
Database format:
ID Instance Device DateBeg DateEnd
Thanks in advance,
LP
The short version -
This should be simple to do using a report (but could also be done using a form I will be explaining how to do a report for this version). You would just make a report that includes all of your fields then call the report on click. It is important to mention that you will need to view the query via a form to make this work.
A more detailed version -
The first step will be to make a form based on your query (you will not be able to do this directly from a query). To do this select your query then click on the create tab then click Multiple Items Form. Adjust as needed.
Then create a report that shows ALL of the records how you want it to display. (I will call it rpt_ViewDetails) (we will limit later)
When you are done adjusting click on the field that contains the "abc" etc. results (if this is a calculated field it will be more complicated.) I will call this field "Criteria" for the example. Go to the events tab on the property sheet (in design view). use the On Dbl Click event and go to code builder.
This is what the code would look like (place in between the private sub.... and the end sub lines of code):
DoCmd.OpenReport "frm_ViewDetails", acViewNormal, , "[Criteria] = " & Me.Critera
Let me know if you have any trouble with this, also let me know if the structure is different than I am assuming, I will need a more detailed report of what the query is doing if this is the case, what the structure of the database is etc.
While querying BAPI, we are generally interested in only few columns of a table.
For example PO_ITEMS table (under BAPI_PO_GETITEMS) has 58 columns. While querying, I am interested in only 10 of those columns. But the BAPI response contains all the columns which is a
overhead.
In SQL world, we can always select which columns we want to retrieve. The query response contains only those columns, not all the columns.
I remember I have read somewhere that we can disable unwanted columns coming in response. But when I need it now, I am not able to find information about it.
Can anybody share a code snippet to achieve this? Or specific online resource/pointers would help?
Thanks
Depending on which technology you use to call the BAPI, you can sometimes restrict which parameters are transferred. For example, if you use the SAP Java Connector (JCo 3), you can use the method setActive of a parameter to restrict whether the parameter is transferred. However:
As far as I know, you can only enable or disable entire TABLES parameters or other parameters. You can't enable or disable individual columns.
As far as I know, the BAPI itself does not know about this setting - and even if it would know, few implementations would care.
Sometimes there are additional parameters that allow you selectively enable or disable fields, but that is part of the actual BAPI implementation and not some omnipresent basic technology.
this is not exact answer for your question.i hope it will help.I think we have no option to select certain number of column from a function module tables.but we can access particular row from that table like passing mandatory values from java side .....like this sample code here i did for function module(not table table).
JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME);
JCoFunction jf=destination.getRepository().getFunction("ZUSER_DET");
jf.getImportParameterList().setValue("FIRST_NAME","username");
jf.execute(destination);
String jfex=jf.getExportParameterList().getString("some column name from return table");
System.out.println(jfex);
it will return a row of table value.you can manipulate whatever you want
I have 3 fields, Action1, Action2 and Action3 contained in one report. Each Action field is selected from the same list of values. I would like to graph a count of these values by the value of the field and not field itself. I need one graph and not one graph per Action field. I have tried to combine the field values into an array in the details section, but the report shows the concatenated string values "Action1, Action2, Action3', as a single value in the graph. I tried to graph using "on change of", but it will only allow 2 fields and not 3. Is there a way to count these values regardless of the Action field where they are found?
I have been working with Crystal for years, but can't figure this out for whatever reason.
I was never able to find a solution to this issue inside of Crystal Reports itself. What I ended up doing was creating a stored procedure in SQL to use as the data source. In the stored procedure I basically performed a cross join such that there was only 1 Action returned per record. In CR I then was able to summarize the Action field values.