Record Selection Formula and Parameters

We've currently upgraded from Crystal Reports 9 to Crystal Reports 2008 (SP3).  In our legacy reports, we use the "record selection formula editor" to filter the results of our report.  This is an example of one of our formulas:
{DOVREP_TIME_AND_EXPENSE.ITEM_DATE} >= {?FROMDATE} and {DOVREP_TIME_AND_EXPENSE.ITEM_DATE} <= {?TODATE}
In this formula, we pass in the FROMDATE and TODATE from our .NET applicaiton to filter on dates.  After upgrading to Crystal Reports 2008 (SP3) this no longer works.  I get an error "Error in formula Record_Selection".  It looks as if it was having issues parsing the formula.  If I replace my parameters (?FROMDATE/?TODATE) with hard coded dates it works fine (It also worked fine in Crystal Reports 9) so from what I can tell adding the parameters causes parsing errors. Also in the error it shows the formula and it's defintily messed up:
((( NOT {DOVREP_TIME_AND_EXPENSE.ITEM_DATE} >= {?FROMDATE}) AND ( NOT {DOVREP_TIME_AND_EXPENSE.ITEM_DATE} <= {?TODATE})))
I'm not sure why it is adding the NOT to the formula or the extra brackets...
Any suggestions?
Regards,
Mike

David,
First off, the way I determined it was the beta dlls was that I installed CR 2008 SP3 runtimes fresh and ran my report.  I didn't experience any issues.  I then took the beta dlls and replaced the originals, rebooted and ran my report again.  The report failed to execute as I described above.  I then took my backup of the SP3 dlls and replaced the beta dlls, rebooted and tested again.  I worked fine with the original dlls. 
The formula that I was passing into that report was a bit more complex than I first described.  I had a few other conditions in the formula that checked for a project ID.  I tested it with just the dates and there wasn't any issues (as in your example), as soon as I added additional parameters that's when the "NOT"'s were included.  Could you try your test again with a few additional parameters?  Here is an example of what I was passing into the report:
((({DOVREP_TIME_AND_EXPENSE.ITEM_DATE} >= {?FROMDATE}  )   AND   ( {DOVREP_TIME_AND_EXPENSE.ITEM_DATE} <= {?TODATE})))  AND (({%PROJECT_ID}=99 OR {%PROJECT_ID}=113 OR {%PROJECT_ID}=112 OR {%PROJECT_ID}=103 OR {%PROJECT_ID}=107 OR {%PROJECT_ID}=111)))
Mike

Similar Messages

  • Inner select and select in "record selection"- Formula workshop problem

    Hi,
    I am facing a bit tough situation in creating a Crystal Report.
    I have two queries which I need to accommodate in the Report according to a given parameter (selectionParameter).
    The queries are as follows:
    select total, minvalue, customer
    (select  sum(A) TOTAL, min(B) minValue, C customer
         from table1, table2
         where table1.A = table2.E
         AND B in (Select B from table3 where F=10)
         group by C
    order by total, minValue
    select total, minvalue, customer
    (select  sum(A) TOTAL, min(B) minValue, C customer
         from table1, table2
         where table1.A = table2.E
         AND C in (Select C from table4 where G=20)
         group by C
    order by total, minValue
    These queries should be executed according to the selectionParameter set to 0 or 1. The only difference in these queries in one of the where clauses. In the formula workshop "record selection"- I have put an if clause.
    if(selectParameter = 0) then (B in (Select B from table3 where F=10)
    else C in (Select C from table4 where G=20).
    This is not supported, since select statement cannot be used in the formula workshop!!.. And also, I have understood that what ever procedure I have been following is completely wrong, since the where clause written in "record selection" formula workshop applies to OUTER SELECT, but not to inner select, which is not what I want!!.
    Please help me to solve this puzzle. I am eagerly waiting for a solution.
    Thanks and Regards,
    Janakiram Dandibhotla.

    A command object is really the only way to create a custom SQL query in Crystal Reports.  You have the option to create a command object after you connect to your datasource.
    Alternatively you can create a JavaBean class, create the custom query in the java page, retrieve the resultset, and use that in the report.

  • Database DLL error on editing the record selection formula?

    Post Author: Aravind
    CA Forum: Older Products
    Hi All,I recently edited the record selection formula of an old report and since then the report is issuing me an "Error detected by database DLL" error.The report was running fine earlier and still continues to run fine if I undo the changes. Earlier, the records were selected based on a 'date' field and I edited the formula to select records based on another date field, but the report doesn't work.The report runs fine on my local PC using Crystal Reports, but web based reporting fails with the error message. The data is selected from a view and the date parameters I talked about are the fields in the same view.This view has around five date parameters and the report runs fine for all of them, except one date field.Any pointers are appreciated.Crystal reports version is 8.5. Regards,Aravind.

    Post Author: DPowell
    CA Forum: Older Products
    Ah, yes, the good old generic date error.
    The problem is likely an invalid date value in one (or all) of your records with that field.  You don't say what database engine you are connected to or which driver you are using for the report, but I'll give you some "pointers".
    Basically, the SQL fetch has encountered an error in your date field and the driver you are using in the report can't handle it.
    A null date could cause that problem.  Also a date-time field with an invalid value or truncated time value.  A robust ODBC driver, like one of the Microsoft drivers might be able to overcome it.  Likewise, vendors frequently release updated drivers to improve error handling just like this.
    1.  Analyze your data, specifically the contents of the "new" date field you are using for some kind of invalid date.
    2.  Experiment with different ODBC drivers by creating alternate ODBC connections to the same database using different ODBC drivers.
    3.  Browse and experiment with options in Crystal Reports Properties that allow you to specify data conversions for NULLs and Dates.
    Good luck !

  • Select-options and Parameters, when to use what?

    Hi gurus,
    I have been using Parameters for long. Now I want to choose a range of values, which I need to retrieve from database.
    I tried using select-options. Can't I use 2 parameters that is parameter1 and parameter2 and mention query BETWEEN para1 AND
    para2, and when I use NO INTERVALS and NO EXTENSION together, it behaves same like parameter, then why did SAP gave these
    extensions.

    Hi friend,
    Simple differences between Select-options and parameters.
    Select-Options Uses keyword 'for'                         
    Parameters Uses keywords 'like', 'type'     
    Select-Options  Uses operator 'in'                         
    Parameters Uses operator '='
    Select-Options  Provides ranges for selection     
    Parameters  No ranges only single value
    Select-Options Creates selection table                              
    Parameters No selection table
    Select-Options  When i/p blank all records selected          
    Parameters   When i/p blank none is selected
    Note:
    Select options can act as parameters by using 'no-extension' 'no intervals', but all records will be selected when i/p is blank unlike parameters.
    Might be helpful..
    Thanks...
    Edited by: Guest77 on Feb 10, 2009 5:44 AM

  • Select-options and parameters

    hi,
    In How many ways we can define select-options and parameters.

    hi uday,
    Usually we use PARAMETERS for single value input and
    SELECT-OPTIONS is used to give a range of input values for a single field
    SELECT-OPTIONS implicitly consists of internal table with fields
    OPTIONS
    LOW
    HIGH
    SIGN
    eg:
          DATA: G_VBELN TYPE VBAK-VBELN.
          SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
          PARAMETERS : P_VBELN LIKE VBAK-VBELN.
          SELECT-OPTIONS: S_VBELN FOR G_VBELN.
          SELECTION-SCREEN END OF BLOCK B1.
       o/p:
              P_VBELN: _________________.
             S_VBELN:___________ TO  ____________.
    reward if helpful
    regards.
    shashikanth naram.

  • HI major diffrence in select-options and parameters

    Hi,
      Can any one explain me the major diffrence between select options and parameters.
    I know that in select options we can give a range of values and in parameter one value.
    Thanks

    Hello Hari,
    I would see following differences:
    1. As you have mentioned, many values/ranges can be given in the SELECT-OPTIONS. However, the parameter can hold only one value.
    2. In the run time, we see the data w.r.t a select option as an Internal table and Parameter may be accessed as a global variable.
    3. Consider following statements:
       a. select-options: s_matnr for mara-matnr no-extension no intervals.
       b. parameters: P_MATNR like mara-matnr.
    Both the statements look same on the selection screen.
    consider the SQLs:
    <b>select * into corresponding fields of table g_t_mara
    from mara
    where
    matnr in s_matnr.</b>
    and
    <b>select * into corresponding fields of table g_t_mara
    from mara
    where
    matnr eq p_matnr.</b>
    both the SQLs give the same output if the user gives a material number on Selection screen.
    If the user does NOT give any input in selection screen, the first SQL will fetch all data from DB, whereas the SQL with the PARAMETER will fail.
    So I think we should keep in mind the requirement and code accordingly.
    I hope this helps you.
    Best Regards,
    Murugesh AS

  • Too Many Lines of Code in Record Selection Formula....

    I'm trying to run a crystal rpt. w/ over 2000 lines of code/conditions in Record Selection Formula, but the report bombs out after typing a little over 1065 lines of code.
    I get the following error message:
    Failed to open rowset.
    Details: ADO Error Code: 0x80040e14
    Source: OraOLEDB
    Description: ROW-00001: Cannot allocate memoryD
    Native Error: 1
    Does anyone have any suggestions or possible solutions??

    this is the oracle forms forum. your chances increase going to the right forum.
    Gerd

  • "Missing parameter values." Error when setting record selection formula

    Setup - VS 2008, CR 2008 (v12.0), Win XP & C#.Net
    I have a form which loops through all parameters (non-linked to sub reports, so only off the main report) and allows users to enter the values for each parameter. When hitting the preview button, I loop through all of the saved values, set the parameter field values and then add any additional filters into the recordselection formula as below. The problem i'm having is that the ReportDocument.HasRecords returns true if the ReportDocument.RecordSelectionFormula doesn't filter out every result.
    For example, I have a list of customers and if I set the selection formula to filter out a specific customer, ReportDocument.HasRecors returns true, if I set the selection formula to filter something that doesn't exist i.e. customer "xk39df", the moment this line of code runs "ReportDocument.RecordSelectionFormula = rsFormula;" - ReportDocument.HasRecors returns the following exception as opposed to "False".
    Message: Missing parameter values.
    Source: CrystalDecisions.ReportAppServer.DataSetConversion
    StackTrace:    at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
       at CrystalDecisions.CrystalReports.Engine.ReportDocument.hasRecords()
       at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_HasRecords()
    ErrorID: MissingParameterFieldCurrentValue
    The strange thing is, it works fine if the recordselectionformula selects a record which exists in the results - all parameters have a current value except for the linked parameters.
    This one has got me stumped!
    foreach (ParameterFieldDefinition parameterField in ReportDocument.DataDefinition.ParameterFields)
                    var query = ReportObjects.Values.Cast<Filters>().Where(objects => objects.ParameterName == parameterField.Name.ToUpper().Trim());
                    foreach (var item in query)
                        parameterField.CurrentValues.Clear();
                        parameterField.CurrentValues.Add(item.ParameterValue);
                        parameterField.ApplyMinMaxValues(item.MinLength, item.MaxLengh);
                        parameterField.ApplyCurrentValues(parameterField.CurrentValues);
                var records = ReportObjects.Values.Cast<Filters>().Where(recordSelection => recordSelection.RecordSelectionFormula.Trim().Length != 0);
                foreach (var item in records)
                    rsFormula += item.RecordSelectionFormula;
                if (rsFormula.EndsWith(" AND "))
                    rsFormula = rsFormula.RTrim(5);
                ReportDocument.RecordSelectionFormula = rsFormula;

    Hi,
    The report has it's own ADO Datasource set in crystal reports, so I just pass the log on information to the report object before doing anything else.
    this.DataSourceConnections[0].SetConnection("ServerName", "Database", "sa", "Password");
    I then do a refresh before applying the parameter values (I do this because the user can preview the report more than one time by using a preview button on the parameter form without re-loading the report object)
    this.Refresh();
    Then I set all parameter values followed by setting the recordselection formula.

  • Resetting Record Selection Formula on report on Crystal Reports XI Server

    We have Crystal reports with recurring schedules running on Crystal Reports XI Server. If I change the Record Selection criteria in Crystal Reports Designer and do a "Save As" to overwrite the previous version of the report on the server, it does not reset the Filter -> Record Selection on each scheduled instance of the report. This means that the new criteria I've added to the base report is effectively ignored.
    I understand why this would be the default behaviour but given that we have a condition that must be added to a large number of reports which are scheduled many times, I need a way to be able to force a reset of the Record Selection to that of the Crystal Report.
    Any ideas how to do this?
    Thanks

    Hello Alan,
    There's no way to alter parameters for an already-created report schedule, as you've noted. 
    As implied in your message, this is so that no updates on a report would affect, and potentially break, already existing scheduled report instances.
    It's recommended to make changes and reschedule.  As you indicate, this may be effort intensive if there are many such scheduled.
    If such changes have to be done regularly, then report redesign to parameterize the filter would be recommended - but I'm assuming this is not your situation.
    Sincerely,
    Ted Ueda

  • Please help on this (record selection formula)

    Post Author: adsmag
    CA Forum: Formula
    I have the following data for example
    GROUP SECTION
    Invoice Number &#91;Aug 8, 2007&#93;
    DETAILS SECTION
    ItemNo           |       Description              |          Latest PurchaseDate
    SAMPLEA  |   DESCRIPTIONA      |    Aug 7, 2007
    SAMPLEA  |   DESCRIPTIONA      |   Jul 1, 2007
    SAMPLEA  |   DESCRIPTIONA      |    Jun 5, 2007
    SAMPLEB  |   DESCRIPTIONB      |    Jun 6, 2007
    SAMPLEB  |   DESCRIPTIONB      |    May 5, 2007
    Is there a way i can only select in the detail section the maximum date
    of the latest purchase where the latest purchase date should be <=
    Invoice Number Date
    Thanks for the help

    Post Author: V361
    CA Forum: Formula
    Create a running total to get Maximum latest purchase date 
    (Field to summarize is latest purchase date, Type of summary is maximum,  evaluate every record, reset on change of group (Invoice number)
    in your details section, go to section expert, select the X/2 next to the supress and put in this formula
    {Latest PurchaseDate}< {#MaxLatestPurchaseDate}
    The report will supress all the latest purchase dates that are less than the {#MaxLatestPurchaseDate}

  • Symaltaneous use of select-option and parameters in smartforms .

    hello Abaper,
    I am design a smartforms . we have given some input. when we use only parameters it works properly. as same when we use select-option only its works .
       But when i use both parameter and select option at that time error generate .
      Actually call function is not works .
    So please give me proper idea how to solve this problem .
    Regards
    kamal kishore

    Hi ,
    Still problem is not solved.
    i want to call following fields but function modules show run time error. IF separately i call only parameter its run properly.
    in the same way if i call only select option is runs properly.
    please suggest me how can i call both the things.
    PARAMETERS: P_BUKRS   TYPE BSEG-BUKRS        OBLIGATORY,
                P_GJAHR   TYPE BSEG-GJAHR        OBLIGATORY.
    parameters: P_SECCO type  SECCODE-SECCODE   OBLIGATORY.
    *SELECT-OPTIONS :  P_SECCO FOR  SECCODE-SECCODE   OBLIGATORY.
    PARAMETERS: P_QSCOD   TYPE J_1IEWTNUMGR-QSCOD OBLIGATORY.
    SELECT-OPTIONS: P_BUDAT FOR BKPF-BUDAT        OBLIGATORY,
                P_BLART   FOR BKPF-BLART,
                P_J_HLN   FOR J_1IEWTCHLN-J_1IEXTCHLN,
                P_J_HDT   FOR J_1IEWTCHLN-J_1IEXTCHDT OBLIGATORY,
                P_LIFNR   FOR LFB1-LIFNR.
    regards
    kamal
    Edited by: kamal_kishore_sah on Apr 12, 2011 7:44 AM

  • How to  create a Select in Formula Workshop - Record selection editor

    In the Formula Workshop u2013 Record Selection Formula Editor I am trying to write a formula to exclude certain customer ids. Iu2019m getting errors when I click the Check formula button. The statement is below, any suggestions?
    I dont think I can use the Select statement in crystal as you would in SQL but how should I write it in crystal format?
    not in (select { STATISTICS.custid} from  
        where { STATISTICS.date_reg} >= '27-may-2011' and { STATISTICS.date_reg} < '30-sep-2011')

    Hi,
    You can try the below logic:
    STATISTICS.date_reg} >= '27-may-2011' and { STATISTICS.date_reg} < ' 27-June-2011'
    I guess you are trying to apply this condition.
    Here in selection formula you need not to give select and from.
    Cheers,
    Kiran

  • Help with dynamic datasource and record selection

                                                                                                                                                                                                                                                                                     <span>Hi, I&#39;m having some difficulty with part of an application I&#39;m trying to build, but here&#39;s some background first.<br /> <br /> I am a student at the University of Maryland, and I&#39;m writing an application for one of the departments here at the university.  It is sort of a front-end for an access database with a lot of extra functionality.  This includes reports.  First of all, the user can change the databse that the application uses, so I store that in an appsetting.  For this reason, I have to tell the report what database to use at runtime rather than using the database expert.  I am building a sort of report wizard in which the user selects certain values, and based upon those values, the SQL statement that the report gets data from changes.  So almost everything about the report&#39;s data is dynamic and will be determined at runtime.  <br /> <br /> So for example if the user chooses an officer report by chapter names, I do this (chapters is a comma delimited string):<br /> <br /><span style="font-weight: bold"> string sel = "SELECT * FROM [Undergrad Leadership] WHERE [Leadership Position] = &#39;" + txtPosition.Text + "&#39; AND [Chapter Name] IN (" + chapters + ");";</span><br /> <br /> The part I am lost on, is how to actually interface with crystal reports.  In the following code, conn is an OleDbConnection to the correct database, rep is the ReportDocument, and view is a CrystalReportsViewer.<br /> <br /><span style="font-weight: bold"> rep.DataSourceConnections[0].SetConnection(conn.DataSource, conn.Database, false); <br /> rep.RecordSelectionFormula = sel;</span><br /><span style="font-weight: bold"> view.ReportSource = rep;</span><br /> <br /> When I try to load the report, I get the following error message:<br /> Error in formula <Record Selection>:  a number, currency amount, boolean, date, time, date-time, or string is expected here.<br /> <br /> Also, assuming this formula gets fixed, how do I actually get fields from this formula and datasource onto my report, since I can&#39;t do it at design time?  Thanks in advance for the help.<br /> <br /> -Jared<br />    </span>

    <p>RCAPI (Report Creation and Modification) calls are only available with Crystal Reports Server RAS SDKs.  This means that using the bundled version of Crystal Reports for Visual Studio will not allow you to place fields onto the report.  A free copy of Crystal Reports Server comes with a registered copy of Crystal Reports Developer.  My guess is that you don&#39;t have either of these products and that you are just using the product that came with Visual Studio.</p><p>All is not lost.  The first question is, do you really need to add the fields at runtime?  In many cases developers just want to have control of the data that gets sent to the report and they are ok with having the same fields display.</p><p>In your code you are changing the datasource which is fine, and you are assigning a Record selection formula which is also fine.  </p><p>The problem with the record selection is that it doesn&#39;t fit the syntax of the Report.  I would suggest printing out the value that you programatically get for the formula and insert it into the Crystal Report Designer.  You will probably get the same error there and gets some  hints as to why it doesn&#39;t work.</p><p>What I would suggest is creating a template report that already has the fields on the report and then change its datasource at runtime and add a RecordSelectionFormula.</p><p>Otherwise you will have to use RAS to be able to add fields at runtime. </p><p>Rob Horne<br /><a href="/blog/10">Rob&#39;s blog - http://diamond.businessobjects.com/blog/10</a></p>

  • Pass the results from a selection formula to the default values for a parameter field

    Post Author: kevans
    CA Forum: General
    Crystal 10 u2013 SQL 2000
    I want to create a parameter field that will display all of our IT Departments so the end user can select the one they want to run the report against, such as IT-Security, IT-Network, etc. about 40 in all.  BUT I donu2019t want this to be a static list where I type in all 40 depts in the default list, I was hoping I could do something more dynamic such a formula field that says u201C if {group.name startswith u2018ITu2019 then {group.name}u201D and then have the parameter field pull from this source.
    Iu2019m sure this has been answered in a previous post but Iu2019m not finding it.  I see stuff on creating a record selection formula such as u2018if {?group} like u2018IT-Secur*u2019 thenu2026u201D  but this leaves too much room for error if people donu2019t type the name correctly.  Maybe Iu2019m not using the record selection formula correctly?  Sorry if I offend anyone but I just upgraded from 8 to 10 and thought for sure this option would be in 10, perhaps built right into the parameter default value page where you can place in select criteria but NOTHING has changed.

    Post Author: sharonmtowler
    CA Forum: General
    if you are creating the parameters in the rpt file, it will only pull values you enter, or directly from the database
    in the record selection you can do something like this, so if they only enter the first 2 characters it should pick up only the IT etc.
    (if eft(,2)={?parameter} then true else ={?parameter})

  • Issue using a parameter twice in record selection

    Setup:
    1) Crystal Report: (Client, Start Date, End Date) parameters linked to the Sub reports
    2) Four sub-reports: (All open issues), (Oldest issue), (Average age of open issues), (Average age of closed issues)
    I need to report on issues based on Customer types of "Company" and "Customer."  All of the records I'm reporting on are in the same table (Subset), but the "Client" parameter I'm using exists in two different columns depending on the Customer type.
    ie. My paramter for "Client" is "ABC"
    "ABC" is found in Subset.Sitename for (Company records)
    "ABC" is found in Subset.Companyname for (Customer Records)
    My record selection formula is:
    {Subset.Companyname}={?Pm-?Client} or {Subset.Sitename}={?Pm-?Client}
    Showing the SQL query shows both values filled in correctly, and if I paste the query in SQL, I get the correct result set.  But if I use any kind of "Running total", "Average", "Maximum", etc... functions, Crystal doesn't include my Company records in its evaluations.  It only evaluates Customer records.
    Does anyone have a work-around for this?  Is this is a limitation?

    All Open Issues -- My work-around was:
    1) Running total (count) of open Customer issues
    2) Running total (count) of open Company issues
    3) Formula (sum) function of 1 and 2
    Oldest Issue -- No workaround yet; Parameters listed above are in the Record selection
    1) Datediff between Received date and Current date
    2) Maximum of the Datediff results
    Average Open - No workaround yet; Parameters listed above are in the Record selection
    1) Datediff between Received and Current Date
    2) Average of Datediff results
    Average Closed - No workaround yet; Parameters listed above are in the Record selection
    1) Datediff between Received Date and Closed Date
    2) Average of Datediff results

Maybe you are looking for