Custom function to return Record Selection Criteria
<p>Here's what I need to do. There will be two prompts for range of dates; say, Begin date and End Date on almost all of the reports here. But it is not mandatory to enter Begin Date nor end date. So depending on the data the user enters we have to build the where clause.</p><p>So, to achive this I am trying to write a custom function which accepts the column name , and data from the parameters in the report. </p><p>my_func(col_nme, bgn_date, end_date) .. </p><p>This function does all the validations and returns a string depending on the data entered by the user. </p><p> Eg., if user entered only begin date then it will return col_nme <= bgn_date<br /> if user entered both dates then col_nme between bgn_date and end_date</p><p> And I am trying to user this complete clause in my record selection of the report. </p><p>In Record Selection call my_func({Query.Eff_date},p_bgn_date,p_end_date) </p><p>It is not accepting it since the function returns it as a string and the Reord selection should return a bolean. </p><p>Can any one let me know how to get this functionality in my report. </p><p> </p><p>ANy other suggestions to achieve this would be a great help<br />Thanks a lot in advance. </p>
as long as you have discrete and multi values checked on for the parameter, the resulting array is all you need.
In the RSF, the desired results will be returned by a REALLY simple boolean statement
{table.field} in {?my param}
"Like" may replace "in"Â for some cases.
Try it, you'll like it. :)Â
    - Kathryn Webster (Report Design Consultant)
          Kat's News: http://diamond.businessobjects.com/blog/279
Similar Messages
-
How can i change the record selection criteria via SDK?
Hi,
I wanna change the record selection criteria in rpt file in java program, What API is required?
Thanks.
ForestHi,
You can use RAS API to change record selection formula at runtime. Go to
https://www.sdn.sap.com/irj/boc/index?rid=/webcontent/uuid/f0aea666-5384-2b10-ffb0-a6facef1d5e5
and look for Report Application Server Java SDK Feature Samples. It contains the record selection change code.
Thanks
Aasavari -
Date range stops working when I add record selection criteria
I have a simple report, using only nine fields, from four tables, plus two date parameter fields that I use to set a date range:
SELECT "Job"."Job", "Job_Operation"."Vendor", "Customer"."Customer", "Job"."Part_Number", "Delivery"."Promised_Date", "Job_Operation"."Status", "Job_Operation"."Sched_End", "Job_Operation"."Sched_Start", "Job_Operation"."Operation_Service"
FROM ("TECH"."dbo"."Delivery" "Delivery" INNER JOIN ("TECH"."dbo"."Job_Operation" "Job_Operation" INNER JOIN "TECH"."dbo"."Job" "Job" ON "Job_Operation"."Job"="Job"."Job") ON "Delivery"."Job"="Job"."Job") INNER JOIN "TECH"."dbo"."Customer" "Customer" ON "Job"."Customer"="Customer"."Customer"
WHERE (("Job_Operation"."Sched_End">={ts '2013-08-05 00:00:00'} AND "Job_Operation"."Sched_End"<{ts '2013-08-08 00:00:01'}) AND "Job_Operation"."Status"='O' OR "Job_Operation"."Status"='S' AND "Job_Operation"."Operation_Service"='150-170 SS' OR ("Job_Operation"."Operation_Service"='150-170 ST' OR "Job_Operation"."Operation_Service"='60-180' OR "Job_Operation"."Operation_Service"='180-200 SS' OR "Job_Operation"."Operation_Service"='180-200 ST' OR "Job_Operation"."Operation_Service"='200-220 ST' OR "Job_Operation"."Operation_Service"='F-1.1923'))
ORDER BY "Job"."Job"
When my record selection formula is
{Job_Operation.Sched_End} IN {?StartDate} TO {?EndDate}
AND
{Job_Operation.Status} = 'O' OR {Job_Operation.Status} = 'S'
the date range works.
However, when my record selection formula is
{Job_Operation.Sched_End} IN {?StartDate} TO {?EndDate}
AND
{Job_Operation.Status} = 'O' OR {Job_Operation.Status} = 'S'
AND
{Job_Operation.Operation_Service} = '150-170 SS' OR
{Job_Operation.Operation_Service} = '150-170 ST' OR
{Job_Operation.Operation_Service} = '60-180' OR
{Job_Operation.Operation_Service} = '180-200 SS' OR
{Job_Operation.Operation_Service} = '180-200 ST' OR
{Job_Operation.Operation_Service} = '200-220 ST' OR
{Job_Operation.Operation_Service} = 'F-1.1923'
the date range doesn't work. Instead, the report returns records with all kinds of {Job_Operation.Sched_End} dates.
What could be the reason?
Thanks,
MatteoHi Matteo,
Try this as the selection formula:
{Job_Operation.Sched_End} IN {?StartDate} TO {?EndDate}
AND
({Job_Operation.Status} = 'O' OR {Job_Operation.Status} = 'S')
AND
{Job_Operation.Operation_Service} = '150-170 SS' OR
{Job_Operation.Operation_Service} = '150-170 ST' OR
{Job_Operation.Operation_Service} = '60-180' OR
{Job_Operation.Operation_Service} = '180-200 SS' OR
{Job_Operation.Operation_Service} = '180-200 ST' OR
{Job_Operation.Operation_Service} = '200-220 ST' OR
{Job_Operation.Operation_Service} = 'F-1.1923'
-Abhilash -
Function that returns currently selected cell address or column
Is there a function that returns the address (or just the column) of the currently selected cell? Simply put, something like =selectedcolumn.
Background: I want to display help text in a cell, and I want that help text to change according to which cell (actually, which column) the user has selected. I have put the help texts in a hidden row. They take up too much space to be displayed all the time. I want one cell to contain the help text of the column of the currently selected cell.
Trying to not use Filemaker for this project if possible
Thanks for any help /MattThe Numbers method, using comments as Barry showed, is probably the best method. An alternate method which is more complex would be to use an Applescript running in the background. The Applescript can scan in the background for which cell/column is currently selected and write that cell/column address into a cell in your table. A formula in your table (most likely a lookup formula) can use that address to serve up the correct help text in a diffrerent cell in the table or in another table.
Some problems with this methodare
The script is not part of the document. It is a separate entity.
The script must be started manually. It will not automatically start when the Numbers document is opened.
If the Numbers document is to be used on other Macs, each would also need the script installed. -
Using custom fields of Infoset as Selection Criteria in Query Reporting
Hi Experts,
I have created one Infoset based on LDB PNPCE and added some custom fields to it. Coding has been done for the custom fields.
But these additional custom fields are not available as selection criteria while creating the query.
Can you please tell me how to use the custom fields as selection criteria?
Reply soon
Thanks in Advance.
RaveeshHello Guys,
I just noticed that it is possible to select custom fields as selection criteria in case of SAP Query,
but NOT is case of Infoset(Adhoc) query.
Can anyone tell me the whether it is possible to select the custom fields as Selection Criteria in case of Infoset Query?
Thanks in Advance,
Raveesh -
Using dynamic array as record selection criteria-performance issue
Hi All,
I have successfully passed an array to my subreport and using it as selection criteria. This subreport is embedded in a group and prints data recursively. Problem is the selection is happening locally which causes all the records to be brought and then filters them. Any solution/help will be greatly appreciated.
Thanks, in advance.
-VishalThanks Vinay. But I think I found my answer actually at the selection criteria I was creating an array from string as follows,
stringvar array ConjugateLots = split( str, ",")
in ConjugateLots* //this was causing the local fitration and then I switch to
* in split( str, ",") // which worked.
But once again thanks. But now I have another issue, I want the records to be sort in the array items. Any help with that also greatly appreciated.
Thanks,
-Vishal -
Custom function to return no_of_records
hello
i wrote a simple function
create or replace
FUNCTION "GET_COUNT"("TABLE_NAME" IN VARCHAR2) RETURN NUMBER IS
no_of_records NUMBER := 0;
BEGIN
select count(*)
from TABLE_NAME
into no_of_records;
EXCEPTION
WHEN OTHERS THEN
return no_of_records;
RETURN no_of_records;
END;however it would not compile
error at the select statment;
id appreciate if anyone could point what is wrong with this function?
thank you
rgdsUserMB wrote:
i wrote a simple function
however it would not compileThis is not really the best of design approaches - it requires dynamic SQL and raises several interface and usability and security issues.
But assuming you are simply testing the water - it should look something like the following. Also note that uppercase is not abused and camelcase and pascalcase used as per the naming standards used by most languages, including .Net and Java.
create or replace function GetRowsInTable( tableName varchar2 ) return integer is
cnt integer;
begin
execute immediate 'select count(*) from '||tableName into cnt;
return( cnt );
end;The only exception that is likely to be raised is ORA-00942: table or view does not exist - you can decide to trap that exception and for example return a null to indicate no count exists, or simply leave it as is above and have the caller deal with the exception and decide how to re-act to it.
And please keep in mind - the above function is not how one should be designing code for an Oracle application. -
How to specify custom query as well as a selection criteria
Hi
I'm struggling to specify a custom select query with variable no. of agruments through toplink.
The custom query looks like:
select outer.col1, outer.col2, outer.col3,
outer.effective_date, outer.capacity_rate, outer.expiry_date, outer.comments, outer.create_date,
outer.create_user_id, outer.modify_date, outer.modify_user_id, outer.vol_uom_type_code
from tbl outer,
( select max(effective_date) effective_date, col1, col2, col3 from tbl
where expiry_date is null
or (trunc(effective_date) >= to_date('01/01/'||to_char(sysdate,'yyyy'), 'dd/mm/yyyy') )
group by col1, col2, col3
) inner
where outer.col1 = inner.col1
and outer.col2 = inner.col2
and outer.col3 = inner.col3
and trunc(outer.effective_date) = trunc(inner.effective_date)
My domain class TBL.class is mapped one to one with DB Table TBL.
With this customer query, I want to add a selection criteria depending upon what is specified on the UI-screen - I can get col1, col2 or a combination of these as search criteria.
So far I have tried multiple approaches:
1. Specifying the custom query (without arguments) as a ReadAll Query in toplink descriptor and then using expression builder to add the criteria but this doesn't work as custom ReadAll query gets overridden and i get back all the results from
TBL which match the criteria specified.
expFinal = new ExpressionBuilder().get("col1").equal(srchCriteria.getCol1());
results = (List) getTopLinkTemplate().readAll(TBL.class,expFinal,false);
2. Using Named Query:
Toplink doesn't allow me to specify a custom SQL along with a selection criteria - both for the same NamedQuery.
3. Specifying the DB query in java layer and then adding arguments and argument values. When query is executed, i don't see arguments being added.
ReadAllQuery query = new ReadAllQuery(TBL.class);
query.setSQLString(READ_ALL_QUERY);
ExpressionBuilder exp = new ExpressionBuilder();
query.addArgument("col1", Long.class);
Vector vect = new Vector();
vect.add(srchCriteria.getCol1());
query.addArgumentValues(vect);
result = (List) getTopLinkTemplate().executeQuery(query, false);
Please suggest. Would be great if you could share some code bits.
Thanks
NitinNitin,
This style of query does require code to apply logic as it is created. If you wish to have this used as a named query you can use a query re-direct so that instead of executing a query we call a method of yours.
You can setup your named query to use re-direction into a static method as:
QueryRedirector redirector = new MethodBaseQueryRedirector(QueryRedirectorExample.class, "redirectMethod");
ReadAllQuery raq = new ReadAllQuery(Employee.class);
raq.addArgument("FIRST_NAME");
raq.setRedirector(redirector);
descriptor.getDescriptorQueryManager().addQuery("findByFirstNameLike", raq);The static method that then gets invoked where you can dynamically create a query looks like:
public static Object redirectMethod(DatabaseQuery query, Record record, Session session) {
String firstName = (String)record.get("FIRST_NAME");
ReadAllQuery raq = new ReadAllQuery(Employee.class);
if (firstName != null) {
raq.setSelectionCriteria(raq.getExpressionBuilder().get("firstName").likeIgnoreCase(firstName));
return session.executeQuery(raq);
}Doug -
Count() function with selective criteria?
I'm struggling with what I would expect to be a fundamental reporting concept in CR.
Suppose I have the following EMPLOYEE table:
u2022 EMPLOYEE.ID
u2022 EMPLOYEE.GENDER_CODE
u2022 EMPLOYEE.MANAGER_FLAG
I need to generate a statistical summary report containing the following:
u2022 Total number of Employees
u2022 Number of Male Employees
u2022 Number of Management Employees
This would be easy if I could just use a Count() function in the Function Workshop which
contained selective criteria. For example: Count ({EMPLOYEE.GENDER_CODE} = 'M')
But I can't figure out how to do this without getting a CR error message.
Record Selection doesn't work, because I need the whole data set.
Group Selection with Summaries doesn't work, because the gender and management
attributes are not mutually exclusive.
One solution that seems awkward to me is to create additional SQL commands in the
Database Expert using COUNT(*) and WHERE criteria to get the number of Males
and number of Managers. But I have to believe that there is a better way. Plus this
approach causes problems elsewhere in my report.
Am I missing something?
Thanks,
BillThanks Raghavendra!
The good news is that I was able to create a "1 or 0" formula and then sum the resulting values.
The bad news is that I'm only able to get this to work for part of my report.
I am joining two tables. As an example COMPANY and EMPLOYEE.
I can use "1 or 0" formulas on all of the employee statistics.
But I cannot do the same for company statistics, because the number of company records being assigned a 1 is being inflated by the join between the two tables.
I have achieved a successful result by using Running Total Fields at the end of the report.
But I want to place these summary statistics at the begining of my report. (Such as Total Companies in the Western Region.)
I tried to use "COMPANY.NAME = previous(COMPANY.NAME)" logic in my function, but then I was not allowed to summarize it.
Any ideas?
Thanks,
Bill -
Date Format in Record Selection
Hello,
I have a problem where the Crystal Report is not returning all the rows that meet the record selection criteria because I believe there is a problem with the date format.
My record selection criteria is:
( {EMPOS.POS_STARTC} <= {@EB_EDATE} and {EMPOS.POS_ENDD} >= {@EB_SDATE} ) or
IsNull({EMPOS.POS_ENDD} )
where EB_EDATE and EB_SDATE are formula fields with the values Date(2011, 12, 31) and Date(2011, 01, 01) respectively which returns the format of DD/MM/YYYY used by the FinanceOne (F1) ERP application that we run the report from. Both formula fields are overriden by the run parameters in the same date format in F1.
If I were to run the SQL below in a query tool like Toad, it returns a row where pos_startc is 1/01/2011 and pos_endd is null, that is not included in the report.
select * from empos where det_numbera = '01285'
and ( (pos_startc <= '20111231' and pos_endd >= '20110101') or pos_endd is null )
1. Why is Crystal Reports excluding this row when the date format is different?
2. How can I change the criteria (or format) to include the one of many other rows missing?Hello,
Crystal Reports is now returning all rows where pos_endd is null in the database with the record selection criteria of:
{CHRIS_EmpSal.pos_endd} = date(0, 0, 0)
However, when I run it in Finance One, it doesn't like this date format Is there another way to get both Crystal and Finance One (i.e., SQL Server DB) to recognise the same syntax for null dates? -
Record Selection happening on Database or Crystal Server?
I am learning about the benefits of SQL commands, in terms of efficiency.
My database is a SQL databse. Crystal 10 runs off of a connected server. My reports connect to the database using Microsoft OLE DB Provider for SQL Server.
I do not use explicitly defined SQL commands in my report. Rather, I have specificed my record selection criteria in the record selection formula. However, The Complete Reference to Crystal Reports XI indicates that if your record selection formula is coded within the underlying SQL Query in the WHERE statement, that record selection occurs on the database server (as opposed to the Crystal server).
When I go to Database | Show SQL Query, I DO have a WHERE statement that corresponds to my Record Selection formula. Does this mean that my record selection is occuring on the database server? If so, why is this the case? Would I get the same level of performance by putting this code into a SQL Command explicitly?I'm pretty sure that Crystal can not always push the record selection to the database. I think you really have to check each report query. (I know it can't if the report is based off of a stored procedure, for example...) If record selection is done by Crystal (and not the DBMS), you could be pumping huge volumes of data over the network.
Also, another huge performance gainer with SQL Commands is if you can do aggregation (sum, max, etc.) in them and only return summary data. I'm not sure how good Crystal is at pushing this kind of logic to the DBMS (if it can do it at all).
Personally, I'm a big fan of basing reports off of SQL Commands due to the efficiencies that can be gained.
HTH,
Carl -
Return records from Stored Procedure to Callable Statement
Hi All,
I am createing a web application to display a students score card.
I have written a stored procedure in oracle that accepts the student roll number as input and returns a set of records as output containing the students scoring back to the JSP page where it has to be put into a table format.
how do i register the output type of "records" from the stored function in oracle in the "registerOutParameter" method of the "callable" statement in the JSP page.
if not by this way is there any method using which a "stored function/procedure" returning "record(s)" to the jsp page called using "callable" statement be retrieved to be used in the page. let me know any method other that writing a query for the database in the JSP page itself.I have a question for you:
If the stored procedure is doing nothing more than generating a set of results why are you even using one?
You could create a view or write a simple query like you mentioned.
If you're intent on going the stored procedure route, then I have a suggestion. Part of the JDBC 2.0 spec allows you to basically return an object from a CallableStatement. Its a little involved but can be done. An article that I ran across a while back really helped me to figure out how to do this. There URL to it is as follows:
http://www.fawcette.com/archives/premier/mgznarch/javapro/2000/03mar00/bs0003/bs0003.asp
Pay close attention to the last section of the article: Persistence of Structured Types.
Here's some important snippets of code:
String UDT_NAME = "SCHEMA_NAME.PRODUCT_TYPE_OBJ";
cstmt.setLong(1, value1);
cstmt.setLong(2, value2);
cstmt.setLong(3, value3);
// By updating the type map in the connection object
// the Driver will be able to convert the array being returned
// into an array of LikeProductsInfo[] objects.
java.util.Map map = cstmt.getConnection().getTypeMap();
map.put(UDT_NAME, ProductTypeObject.class);
super.cstmt.registerOutParameter(4, java.sql.Types.STRUCT, UDT_NAME);
* This is the class that is being mapped to the oracle object.
* There are two methods in the SQLData interface.
public class ProductTypeObject implements java.sql.SQLData, java.io.Serializable
* Implementation of method declared in the SQLData interface. This method
* is called by the JDBC driver when mapping the UDT, SCHEMA_NAME.Product_Type_Obj,
* to this class.
* The object being returned contains a slew of objects defined as tables,
* these are retrieved as java.sql.Array objects.
public void readSQL(SQLInput stream, String typeName) throws SQLException
String[] value1 = (String[])stream.readArray().getArray();
String[] value2 = (String[])stream.readArray().getArray();
public void writeSQL(SQLOutput stream) throws SQLException
}You'll also need to create Oracles Object. The specification for mine follows:
TYPE Detail_Type IS TABLE OF VARCHAR2(1024);
TYPE Product_Type_Obj AS OBJECT (
value1 Detail_Type,
value2 Detail_Type,
value3 Detail_Type,
value4 Detail_Type,
value5 Detail_Type,
value6 Detail_Type,
value7 Detail_Type,
value8 Detail_Type);Hope this helps,
Zac -
Using Custom function in Validation
I have a custome function that returns a varchar of TRUE or FALSE.
I have tested the function and even hardcoded with TRUE.
However when I use it in the Validation and even thought all lines return True they get pushed into the Fail table.
I have the rule Enabled and action on Fail is set to "Send To Fail"
I have printed out the data being returned and all Pass so why are they being sent to the Fail.
I call the function like this.
So I assume that if the vlaue returned is True it should go to the true table.
P2CMM01_LKP_STORAGE_LOC("Material Type(MTART)", "+STORAGE_LOCATION","+MATERIAL_NUMBER") = 'True'what is the value returned by the function True or False or TRUE or FALSE ?
you will have to do a case-sensitive comparision
TRUE = True will fail -
Record Selection in Japanese not pulling the correct records.
Hello,
I am using Crystal XI running off of a Remedy SQL Database that has Japanese data in the records. When I place the following criteria in the Record Selection, I pull no records. But, If the put the criteria with the japanese criteria in the Group Selection formula, I get the records that I want but then many of my formulas are adding up all the records.
{HPD_HelpDesk_VW.Severity} in ["1","2"] and
{HPD_Affected_Organizations.Organization} like "ジブラルタ"
How can I get Crystal to recognize the japanese criteria in the Record Selection criteria?
Any help would be appreciated.
Thanks, StacyHello,
I am using Crystal XI running off of a Remedy SQL Database that has Japanese data in the records. When I place the following criteria in the Record Selection, I pull no records. But, If the put the criteria with the japanese criteria in the Group Selection formula, I get the records that I want but then many of my formulas are adding up all the records.
{HPD_HelpDesk_VW.Severity} in \"1\",\"2\" and
{HPD_Affected_Organizations.Organization} like "ジブラルタ"
How can I get Crystal to recognize the japanese criteria in the Record Selection criteria?
Any help would be appreciated.
Thanks, Stacy -
How to define a function that returns a void?
Hi all,
How can I define a custom function that returns a void?
My understanding is simple UDF can only return a string.
Is there any way around this limitation?
Thanks.
Ron> Hi,
> User Defined Function in XI always return a String.
>
> If you requirement is that you want to perfrom some
> operation in an user defined function, one option is
> to move it to the Java Section in your mapping and do
> it in the intialization / clean up section.
>
> Else, wite a UDF that will return a Blank string as
> the output, and map it to the root node of the
> target.
>
Hi all,
Thank you all for your kind responses.
The scenario I have is I need to insert the value of a particular field into a database table. E.g. MessageId, to keep track of the messages going through XI.
Naturally, such operations return void. These operations are already encapsulated in a custom jar file.
My purpose of using a UDF is solely to invoke the operation.
But I realized I each UDF has to have a return type, and the output of this UDF must be mapped to a node in the outgoing message.
Currently, my UDF returns an empty string, by using the implementation as below, I manage to perform my desired operation without affecting the result:
MessageId -- UDF -- CONCAT -
InstitutionCD_Transformed
InstitutionCode_____
But as you can see, this is not an elegant way of doing things.
That's why I'm seeking alternative solutions for this problem.
Bhavesh, you mentioned something about doing the operation in the initialization/cleanup section.
Can you please explain more?
Thanks.
Ron
Maybe you are looking for
-
So I have an iPad with the smart cover, and it's usually supposed to turn on and off the iPad when u open it and close it, but it's not turning on for me. Nor is it turning off without pressing the button. What is the meaning of this?what caused it t
-
Can't send mail from my new ipod touch
Got a brandnew ipod touch 32gig and everything works fine except the sending of emails. I always get the error message "the connection to the outgoing server smtp.xxxx.ch failed". I have no problems to send emails from my computer with the identical
-
How to set user defined type in binded parameter to NULL
Hello I have a type in PL/SQL MY_ARRAY which is a array of VARCHAR2 and I want to call a procedure MY_PROC in OCCI, the procedure takes MY_ARRAY as its IN parameter, but I want to set the parameter to null. How can I do that? "begin MY_PROC(:1); end;
-
HT1338 how do i update java for my computer
how do i update java for my computer
-
Dear All, While doing the Cost estimation for a Product i am getting the below mentioned error.. Cost estimate for material W275271299NEW / plant LEP1 is incorrect Message no. CK168 Diagnosis The system found errors in the cost estimate of material c