Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Dynamic Parameter DB Lookup Help Post Reply Post New Topic
Author Message
JennyB
Newbie
Newbie


Joined: 26 Dec 2012
Online Status: Offline
Posts: 24
Quote JennyB Replybullet Topic: Dynamic Parameter DB Lookup Help
     Posted: 05 Nov 2013 at 4:38am
Hi,

Crystal reports newbie, and I'm a bit stuck, hoping there's an obvious answer to this.. :)

I have a query which uses a command to pull my data and which has a parameter accepting multiple values. I'd like users to be able to select these values rather than having to type themselves. The parameter is a 6 character 'scheme code', codes always begin with PP, the next 2 digits are e.g. 14 for season 2013/14, and then 01 to 09, e.g PP1401, PP1402.. are this year's codes. I want to set up this report to run for the next few years so don't want to make a static list, and I'm trying to find a way to make this list populate each time.

In Access, I've set my report to ask for the 'Season Code', this ends in 2 characters which equal characters 3 and 4 in my Scheme Code, e.g. Season Code of ST1314 means all associated Scheme Codes will be PP1401, PP1402 etc. I don't see how I can do that in Crystal though.

All of my codes are stored within a table in my database, so I've created another command which isn't linked to my initial one and doesn't have any fields used in the report which looks up the database and brings back all of these scheme codes, but when I try to create a dynamic parameter based on the results of this command I don't get any results.

So how can you look up a database for a dynamic list of parameter values? I found this thread on the SAP website - http://scn.sap.com/thread/3344125 - and someone has posted this info, but I've tried a few ways and it's not working for me. I'm using CR 2008 standalone, no server etc. Thank you in advance for any advice..

You can use Dynamic Parameters in Crystal Reports.

 

It's explained beautifully in the free booklet "How to Work with Crystal Reports in SAP Business One"

in the section on Selection Criteria Token. Just do a search and download the PDF.

 

You have to create your parameter fields in Field Explorer (Parameter Fields):

@DatePeriod,

 

@DataParam

 

Then you must edit the name @DataParam so that it reads as follows:

@Select internalSN from OINS JOIN .... WHERE....etc  ...

Write your SQL as you would normally would.

But note:

1.The SQL must not be too long, there's limited space.

2.There must be no space between @ and Select.

 

Then, you run your report in SAP B1 (Preview External Crystal Reports File)

And.. presto - You get the dropdown list from which you can select internalSN.

 

Hope it works

Regards

Leon


IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 05 Nov 2013 at 6:22am
try creating a dynamic parameter
in field explorer
right click parameter field >>new
under list of values select dynamic
then click on yellow folder sign
select field for parameter
IP IP Logged
JennyB
Newbie
Newbie


Joined: 26 Dec 2012
Online Status: Offline
Posts: 24
Quote JennyB Replybullet Posted: 05 Nov 2013 at 10:13pm
Hi,

Thanks, I've got that far though I just can't get my dynamic parameter to look up my database table or figure out how I could put in a formula that would give me the values I need in the drop down. I want report users to be able to select from a few scheme codes, which I'd like to either generate myself as they follow a pattern, but two digits change in them year on year and I can't see how to create them with a formula, or I'd like the parameter to look up a table in my database, I've got a bit of SQL to give the results I want but I can't put it directly into the parameter and I've put it into a command (not linked to any of my other tables/commands or used in the report) and used the command fields in the parameter but it comes up empty when I run my report.

I'm referencing this parameter within my main query in a command as I thought this would make the report faster than if it had to run and then was filtered at report level, so that's maybe the problem, but it just seems like something that you must be able to do, somehow.. :)

Jenny
IP IP Logged
JennyB
Newbie
Newbie


Joined: 26 Dec 2012
Online Status: Offline
Posts: 24
Quote JennyB Replybullet Posted: 05 Nov 2013 at 11:01pm
;) Glad to report that I'm just a pudding, there was an error in my SQL and it's now working fine, DB2 doesn't like * wildcards and I'd used it instead of %, when I fixed the SQL it now works perfectly and my parameter now has a drop down with all my scheme codes for users to select from. Hooray!!

For anyone else having similar trouble I created a command to give the values I wanted in the drop down for my parameter, didn't link it to any other commands/tables in the report or use any fields from it, and created my dynamic parameter with the codes and descriptions from this command, and it works perfectly. :)
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum