Crystal Reports - Wildcard in Command parameter

This is what i use now
{Command.COUNTRY} like {?Country}
?Country is a value entered by the user, this could be upper case or lower case and could be part of the country name.
What is the crystal reports equivalent to achieve the above.
something like
caseinsensitive {Command.COUNTRY} like {%?Country%}
CStr did not work do did
{Command.COUNTRY} like  '%'{?Country}'%'

Things are a little different in CR...
#1) The wildcard you're looking for is "*" not "%"
#2) Use the "&" to concatenate strings. Save the "+" for addition
#3) Using a hard coded string, the formula would look like this...
{Command.COUNTRY} like "*erman*"
#4) Unfortunately, sticking wildcard characters to either end of a parameter doesn't work the same as it does with hard coded values.
#5) Fortunately, you're using a command... So #4 doesn't matter... Assuming of course that you are trying to create a record selection formula.
#6) You're do doing your record selection in the wrong place... If you're using a command, you need to add the parameter to the WHERE clause of your SQL query...Again, working with the assumption that this is for record selection.
#7) How to accomplish #6...
- 1) Right click and choose Edit... to open the command in edit mode.
- 2) Add the parameter to the parameter list. Make sure to spell it EXACTLY the same as you have it spelled in the designer (otherwise you'll create a 2nd, unrelated parameter)
- 3) Add or modify the WHERE clause to the command SQL. In your case (assuming MS SQLServer based on the syntax you posted).
It should look something like this...
WHERE TableName.Country LIKE '%{?Country}%'
CR will drop the parameter values into the SQL replacing the parameter name with the parameter value before sending it to the server. No need to write dynamic SQL!!!
The code sent to the server would look something like this...
WHERE TableName.Country LIKE '%Germany%'
#8) If you're wandering why it matters or why you don't want to use the Selection Expert when using a command?
Answer: When you use a command, CR is no longer able to push it's logic back to the server. So the command will pull EVERY record without any filtering back to your local workstation where it will be filtered locally. Adding the where clause to the command itself avoids the issue altogether.
HTH,
Jason

Similar Messages

  • Crystal Reports 2008 - passing a parameter in the Command Object

    Hi,
    I am using Crystal Reports 2008. I have 4 Command Objects where I have the following queries.
    select emrace, count(empl_id) cntFCiv  from emmain where emtype='CIV' and emsex ='F' and emdateterm is null group by emrace
    select emrace, count(empl_id) cntFSw  from emmain where emtype='SWOR' and emsex ='F' and emdateterm is null group by emrace
    select emrace, count(empl_id) cntMCiv from emmain where emtype='CIV' and emsex = 'M' and emdateterm is null  group by  emrace
    select emrace,count(empl_id) cntMSw from emmain where emtype='SWOR' and emsex = 'M' and emdateterm is null  group by emrace
    I want to pass a parameter  to all these command objects. I want the user to select a parameter from a list of values. So, I created a parameter object, Bureau. (I get the values for the parameter with this command object: select code_agcy, descriptn from systab1 where code_key = 'UNIT'). I want the user to be able to get the counts for each bureau.
    How do I pass the parameter that the user picked to those command objects. I tried doing this:
    select emrace, count(empl_id) cntFCiv  from emmain where emtype='CIV' and emsex ='F' and emdateterm is null
    and emunit = '{?Bureau}' group by emrace
    But it did not work. Any help will be greatly appreciated.
    Thanks.

    Hi,
    I am using Crystal Reports 2008. I have 4 Command Objects where I have the following queries.
    select emrace, count(empl_id) cntFCiv  from emmain where emtype='CIV' and emsex ='F' and emdateterm is null group by emrace
    select emrace, count(empl_id) cntFSw  from emmain where emtype='SWOR' and emsex ='F' and emdateterm is null group by emrace
    select emrace, count(empl_id) cntMCiv from emmain where emtype='CIV' and emsex = 'M' and emdateterm is null  group by  emrace
    select emrace,count(empl_id) cntMSw from emmain where emtype='SWOR' and emsex = 'M' and emdateterm is null  group by emrace
    I want to pass a parameter  to all these command objects. I want the user to select a parameter from a list of values. So, I created a parameter object, Bureau. (I get the values for the parameter with this command object: select code_agcy, descriptn from systab1 where code_key = 'UNIT'). I want the user to be able to get the counts for each bureau.
    How do I pass the parameter that the user picked to those command objects. I tried doing this:
    select emrace, count(empl_id) cntFCiv  from emmain where emtype='CIV' and emsex ='F' and emdateterm is null
    and emunit = '{?Bureau}' group by emrace
    But it did not work. Any help will be greatly appreciated.
    Thanks.

  • Crystal Report: failed to read parameter object

    Hello -
    I have a report that consists of numerous static parms and one dynamic parm. I can save the report to my desktop but cannot save it to BO 3.1 CMC Personal Folder (or any folder for that matter).
    The dynamic parm does not use a LOV based on Business Views. A table associated with the same data source as the stored proc on which the Report itself is based provides two fields - a code field that is used in the Value and a name field which is used in the Description.
    The specific error is:
    "Failed to read data from report file <file name> Reason: failed to read parameter object".
    All the normal things have been checked -
    - VERIFied the database
    - Ensured 'No Printer' is checked
    - Ran the report (successfully) on the desktop (locally)
    The data source is Oracle. The report can be saved to the CMC and run without problem if the dynamic parameter is deleted from the report.
    The version of Crystal Reports is CR 2008 vers 12.04
    I've seen numerous postings regarding LOVs and Business Views, especially surrounding security issues, but I've yet to see a note about a dynamic parameter based on a table....
    Thanks

    Hi!
    Thanks for the response....
    Re: check the "Enable Repository Refresh" checkbox
    The SAVE failed with the Failed to read data from report file error.
    When I went to the Bus View mgr, I found the LOV. It was set as a cascading prompt (not what I wanted when I set the parm) and could not edit it. No permissions.
    I went back to the report and tried to edit the parm into which I had stuffed the LOV I can't touch in Bus Views, and found I can't open in the report canvas without logging into the repository.... which I did.... and went to edit the parm...can't open in the report canvas without logging into the repository.... which I did.... and went to edit the parm... You get the idea....
    What I had WANTED to do is take a table with 2 fields in it - a NAME and a CODE field, create a dynamic parm, use the CODE field as the Value and the NAME field as a description. When I brought in the LOV, it came in as a cascading LOV... I needed to have the Description as the user fronted piece... but I can't seem to get there from here.....

  • Crystal Report Prompt For Enter Parameter Values

    Hi,
    I did a report with 2 subreports embeded in VS2005 using VB and it worked fine but when I ported the whole application to VS2008 the above problem occurs. Here are some codes:
        Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click
            Dim viewer As New frmReportPreview
            Dim rpt As New ReportDocument
            Try
                rpt.Load("C:\Report\crptMain.rpt")
                rpt.SetParameterValue("Code", Me.cbxCode.Text)
                rpt.SetParameterValue("Code", Me.cbxCode.Text, "crptSubReport1.rpt")
                rpt.SetParameterValue("Code", Me.cbxCode.Text, "crptSubReport2.rpt")
                viewer.report = rpt
                viewer.WindowState = FormWindowState.Maximized
                viewer.ShowDialog()
            Catch crptEx As CrystalDecisions.CrystalReports.Engine.EngineException
                MessageBox.Show(crptEx.Message, "Crystal Report Errors...")
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Crystal Report Errors...")
            End Try
        End Sub
    Private Sub frmReportPreview_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            Try
                Me.CrystalReportViewer.ReportSource = m_report
                Me.CrystalReportViewer.RefreshReport()
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error...")
            End Try
        End Sub

    Subreport Parameters are contained within the Main Report's ParameterFieldDefinitions collection. Passing Subreport Parameter values directly to the Subreport will result in the values not being applied and the user being prompted at runtime to provide new values.
    Ludek

  • Crystal reports 2008 Set optional parameter value

    Hi,
    I'm working with .net Visual Studio 2008 C# and Crystal reports 2008 (Crystal.Decisions) and when I try to set a parameter to optional and set its value to no value, it returns the error: "Invalid parameter name", here is my code:
    foreach (CrystalDecisions.Shared.ParameterField param in Report.ParameterFields)
                            if (!param.HasCurrentValue &&
                                !Report.DataDefinition.ParameterFields[param.Name].IsLinked())
                                switch (param.ParameterValueType)
                                    case ParameterValueKind.NumberParameter:                                  
                                        param.IsOptionalPrompt = true;
                                        param.CurrentValues.IsNoValue = true;                                  
                                        break;
    I'm doing this because some of the parameters can be left null, and in this case I don't want to show the parameter prompt.
    In past versions of Crystal (such as Crystal Reports 11.5) we had the chance to left the parameter value null and did not showed the parameter prompt dialog, and this behavior repeats in a lot of reports.
    thanks in advanced

    Please don't post the same question more than once. This is a public forum so be patient.
    Install SP4 and test again.
    Try these samples:
    http://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsSDKSampleApplications
    Don

  • Crystal Reports Viewer 2008 and parameter fields

    Hello,
    I saw this product on the main Crystal Reports site this afternoon and decided to download it to try it out.  I have a number of users who would benefit from being able to preview their report results prior to actually running the report.  This seems like the perfect product.  I have a large number of Crystal Reports which were created in Crystal version XI.  I also downloaded the free 30 day version of Crystal Reports 2008 yesterday to see what new features are there.
    While testing Crystal Reports Viewer, I tried to run one of my reports which needs a parameter to run properly (account number).  This type of parameter is needed for probably 98% of this business' reports. 
    The problem: Crystal Reports Viewer does not prompt me to input the parameter.  In my actual Crystal Report, I had the box "Save Data with Report' left unchecked, as the account number frequently changes.  However, if that box is left unchecked, Crystal Reports Viewer will give me the error message "No Saved Data.  This report file does not contain saved data and cannot be viewed.  To get data into the report, please open and re-save it in the Crystal Reports designer application with the "Save Data with Report" option selected."
    Thinking that possibly it was the version of Crystal Reports in which the report was created (XI), I downloaded the free trial of Crystal 2008 and created a very simple test report with one parameter for account number where the account number is retrieved from our database.  And I am having the same trouble. 
    The "Help" section of Crystal Reports Viewer tells me that I can select my parameters in the parameter panel.  I do not see anything in my parameter panel other than the words "Current Data Set Last refreshed: 04/12/10 2:58 PM".  The help tells me that I can "select the parameter directly in this panel by entering a new value", but there is no option to do so.
    Any help would be appreciated.
    thanks,
    Noel

    What I've learned is that I was originally using Crystal Viewer XI and upon opening it I received a message indicating there was an update.
    I ran the update which put me on Crystal Viewer 2008.
    Since then I have not been able to refresh my screen to bring up the parameters.
    See the attached forum for another post concerning this same issue. 
    Paramter Prompts in Crystal Viewer

  • Crystal Reports 2008 SP3 Additional parameter values are needed

    I recently upgraded to Crystal Reports 2008 SP3, and now when I try an export a report from the Crystal Reports Designer, I get the error "Additional parameter values are needed before this report can be saved or viewed with data.  Click 'Ok' to enter the missing values or 'Cancel' to proceed without data".  I am trying to export the report to Crystal Reports format.  The report is getting data from a MS SQL 2005 stored proc. I tried building a new simple report (just took all the fields in the result set and put them in the details section) using the same stored proc, and get the same error when I try to export.  
    FYI, before I try to export I always preview the data in the report, so the parameters are defiantly set correctly.
    This was working correctly in Crystal Reports 2008 SP2.

    Please re-post if this is still an issue or purchase a case and have a dedicated support engineer work with you directly:
    http://store.businessobjects.com/store/bobjamer/DisplayProductByTypePage&parentCategoryID=&categoryID=11522300?resid=-Z5tUwoHAiwAAA8@NLgAAAAS&rests=1254701640551

  • Problem with Crystal Reports not displaying all parameter values

    Hello,
    A co-worker of mine is developing a report in Crystal version 11.5.8.826.  One of the requirements from his user is that they would like to select from a list of users for applicable criteria to appear in the report.  He created a parameter with a dynamic list of values, entered prompt group text, selected "existing" as the data source (and chose the corresponding field from the table).  This dropped the UserID field into the "value" field in the table and linked the table to the parameter.  We selected "allow multiple values" as "true" and "allow discrete values" as "true". 
    Here is the problem.  When Crystal prompts us to select the parameters, it doesn't show all of the applicable list of users (it shows 8 out of 12 users).  When we run the query in a standalone sql generating tool (Toad or Golden), we see the full list of users.  Crystal Reports appears to be filtering the selection list of users for some unknown reason.  We have tried changing most every option that we could find within the parameter, but no luck. 
    The problem definitely appears to lie within the parameter- if we run the report without the parameter, we see the full list of users.  Once we add the parameter and attempt to select one or many users, the problem appears.
    Any thoughts?  What am I missing?  Any help is appreciated.
    thanks,
    Noel

    I'll answer my own question in case somebody is curious or happens to find this message via google or another search engine.  See this link.  You need to set your upper threshold within your Registry Editor.
    http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=8029

  • Crystal Reports 2011 - SQL commands

    I upgraded to Windows 7 (64 bit) and was obliged to upgrade Crystal Reports to CR2011. All reports (so far) have run as expected - except those with SQL commands containing self-referencing tables. These reports have prompted me to re-map the field references!
    Background. In Crystal XI, these SQL commands, containing self-referencing tables automatically labelled secondary, tertiary etc.. instances of the same field with suffixes as follows SAMEFIELD, SAMEFIELD(1), SAMEFIELD(2) etc., so that the same field had a unique name depending on which table it was from. This was easily referenced in the record selection,, and other formula.
    Crystal Reports 2011. The same SQL commands do not result in automatically suffixed field names, and so the same field (but from a different table) will be labelled exactly the same, so SAMEFIELD, SAMEFIELD, SAMEFIELD etc. (NOTE. The SQL command does not allow me to do any alasing). When trouble-shooting the problem, I discovered that even when adding the respective instances of SAMEFIELD to a report, only the first instance of the field would actually be added (according to the Field Explorer), and the field entry would just be duplicated. I actually can't believe that it appears that I'm going to have to re-write some of my reports because of this.
    1. Has anyone else discovered this?
    2. Can anyone advise how I can get an alias for the duplicating field names?
    3. I upgraded to CR 2011 thinking that the newest version would be the most sophisticated, should I have only upgraded to CR 2008 - does this problem exist in CR 2008?
    Thanks.

    This doesn't work - Sorry
    Additionally, without aliases in the resulting table, as outlined in my post, when placing instances of 'SAMENAME' in the report, secondary instances of SAMENAME (which infact represent other values) only show values that the first instance represents.
    To clarify, if the resulting table shows SAMENAME, SAMENAME, SAMENAME, but the field represents Level1, Level2, Level3, when the top (first instance) of SAMENAME is placed in the report, it will show a value representing Level1, when the next SAMENAME is added to the report, that also shows a value representing Level1. The Field Explorer will indicate a tick against the first instance of SAMENAME but not subsequent additions.

  • Using Crystal Reports formulas in Command Objects

    Post Author: Hamish
    CA Forum: Formula
    Is this possible?
    When I try and reference a formula in a command object
    something like
    select * from tablenamewhere id in (@testFormula)
    @testFormula prints out as 1,2 on the report if I remove the reference in the command object
    I get an error Incorrect syntax near @testFormula from SQL Server
    (I'm using CR XI and SQL Server 2005)

    Post Author: bryanflora
    CA Forum: Formula
    In a matter of fact, Formula is for you to calculate the result you get from DB.And if there's anything you want to pass to DB before you get result, it's Parameter.

  • Crystal reports with static list parameter : blank dropdown menu

    Hi,
    I've created a very simple report displaying customer order (ordr and rdr1)
    it has :
    parameter DocKey@  used in the selection formula    DocKey@=DocEntry
    It also has another parameter : static list with 2 entries
          - 1 : normal presentation
          -  2 : proforma presentation
    The user has to choose between option 1 or 2 before displaying the report
    Using the report in the Crystal application is OK : i can choose between option 1 and 2 in a dropdown list
    If i use the Addin Menu // preview in SAP : i can choose in the dropdown menu
    If i import my report in SAP and i try to preview it : the dropdown menu is empty and i cannot select anything
    Anyone has the same problem ?
    I use SAp SBO 8.8 pl 00 hotfix 14
    I 've the same report worrking on a sap sbo 8.8 sp 00 pl 11
    thanks for your help

    Hi and thanks for your help
    I've tried with and without default values : no changes
    I've tested with the last pl (18) and it works fine : no blank dropdown menu , i can select a value for my static parameter !
    Edited by: Antoine TESSIER on Jan 6, 2011 11:47 AM

  • Crystal reports from command line

    Post Author: DrewJ
    CA Forum: General
    Hi,
    I need to run Crystal reports from the command line.
    Does anyone know how to pass parameter arguments when launching the application?
    I have tried cr32w.exe c:\reports\report.rpt arg="099909"
    (which launches the right report, but does not pass in the arg) 
    Is it possible?
    Thanks in advance,
    Drew Johnston

    Hi,
    Thanks for the reply.  The application would not be on the same server as the machine.  So if I used the command that you gave me would that actually run the report (ie refresh the data and then save the report ,as instructed in the settings, on to the network location).  Or would it just open up the report.  Also, how would I send parameters to the report, eg Dates or Status.
    This is the scenario.  At the moment a user would input data on to database via an external applicaion.  After inputting all the data, they would then have to log into Crystal Infoview.  Navigate to the report.  They would then click on the Schedule hyperlink.  They would change the parameters eg Start Date and End Date.   And then press the Schedule button.  The report would then refresh the data, and as specified in the Destination, it would write out to a network location.
    So we want the external app to write a command line prompt, so that the user did not have to log onto Crystal at all.  The application would send the relevant parameters and run the crystal report automatically without the user having to log into Crystal at all.
    Regards,
    Prakash

  • SAP parameter token - Crystal Report 8.8

    Hi,
    When I want to create a parameter for selection of BPCode, myparameter@select * from OCRD works well.  The idea of filtering with properties etc is fantastic.
    However, what I need is to create a parameter with value in AddID in OCRD.
    I have tried myparameter@select AddID from OCRD, but, it is not displaying the list for AddID capture in OCRD, instead, it display the same UI as myparameter@select * from OCRD.
    How do I get by this?
    I have tried, range, multiple value, does not work at all.
    Did I miss something?

    Gordon,
    Thanks for replying.
    I want to create parameter, as simple as that.  Parameter should not be restricted with key value.
    In standard Crystal Report, you can create parameter, if you set it as Dynamic, set it to refer to any table field,  and use it in report, when running the report, the parameter will be populated with value of the referred field.
    How does this work with SAP 8.8?
    Are we suppose to use syntax like myparameter@select AddID from OCRD or we just create dynamic parameter as normal?
    I have tried both and it does not seems to work properly.
    1. If i use myparameter@select AddID from OCRD, it comes out with selecting for OCRD will all those properties, which I am not interested.
    2. If I create a dynamic parameter, when runnign the reprot within SAP, nothing has come out on the list for selection.
    Has anyone tried that? 
    No, SQL Command is not what I am interestded,

  • Crystal Report not taking parameter propery

    Hi,
    I am facing a unique issue in reports.The report is not taking the parameter entered by the user instead it is taking the value which was used for testing the report initially.
    Save data with report in uncheked.
    The report is shwing correct data on CMS and with designer also.
    The problem arises when report is viewed java based web application.
    I am usng Crystal Reports XI and Business Objects 12 CMS.
    Regards,
    Misra P.

    Hi,
    what does single time mean? Only the first time when you start the report from your code and the second time it is like before? You may need to empty the report's parameters before giving new ones... If I could see the relevant part of your code, I could give a hint. There are also lots of samples hwo to paramterize a report from java code, which usually work fine...
    There is also an option in the crystal reports designer to keep parameter values as they were set in the CMC when saving a report to BOE...
    Regards,
    Harald

  • Select multiple items from a list box as values for a parameter of crystal report and Oracle procedure

    -  I have a  Product list box (asp.net) used as multiple selected values for  a parameter. 
    - The Product ID is defined in the Oracle procedure as NUMBER data type. 
    -  In my crystal report, I have a parameter field allow multiple values as p_product_id type as Number.  This is the code in my Record Selection Formula for the report:
    ({?p_product_id}[1] = -1 OR {Procedure_name.product_id} in {p_product_id})
    -  In C#, this is my code
    List<decimal?> productUnit = new List<decimal?>();
    int counter = 0;
    decimal prod;
    for (int i = 0; i < lstProducts.Items.Count; i++)
                  if (lstProducts.Items[i].Selected)
                                if (decimal.TryParse(lstProduct.Items[i].Value, out prod))
                                    productUnit.Add((decimal?)prod);                              
                                    counter++;
           if (counter == 0)
                       productUnit.Add(-1);                      
    ReportingDAO rDataFactory = new ReportingDAO();
    retVal = rDataFactory.GetProductReport(productUnit);
    public CrystalDecisions.CrystalReports.Engine.ReportDocument GetProductReport(List<decimal?> productUnit)
              CrystalDecisions.CrystalReports.Engine.ReportDocument retVal = new rptProductDownload();
              ReportLogon rptLog = new ReportLogon();
             rptLog.Logon(retVal, "RPT_PRODUCT_DOWNLOAD");
             retVal.SetParameterValue("p_product_id", productUnit); 
    I keep having the "Value does not fall within the expected range" when I debug.  My question is, is the data type I used for procedure/Crystal report/ and C# correct ?  I always have problem with the data type.  Any help would be
    appreciated
    Thank you

    Hi progGirl,
    Thank you for your post, but Microsoft doesn't provide support for CrystalReport now. Please post your question in SAP official site here:
    http://forums.sdn.sap.com/forum.jspa?forumID=313
    Thank you for your understanding.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for