cancel
Showing results for 
Search instead for 
Did you mean: 

Can SAP Crystal Reports accept a blank parameter?

leon_laikan
Participant
0 Kudos

Hi!

I used SAP Crystal Reports 2008 to design a report.

I have 2 parameter fields which are displayed in the Selection Criteria Screen when the report is run:

        (a) @Project

        (b) PrefrdSortOrder

(a) For @Project, the User selects his project from a drop-down list

(b) For PrefrdSortOrder, the user can select one of 2 values :

                         - Original Order or

                         - Description

  i.e the user can select how he wants the report to be sorted.

Normally, most users want the report to be sorted by "Original Order". Only rarely will a user want the report to be sorted by "Description"

My report works well until I make the following change....

If the User does not select a value, i.e if he leaves the "PredrdSortOrder" prompt BLANK, I want CR to behave as if the User has selected "Original Order", and sort the report in Original Order

However, I get this error message:

      Error in Formula 'YourPreferredSortOrder_sv' 

       Parameter has no value

------------------

Note :

'YourPreferredSortOrder_sv is a Shared variable and its code is:

WhilePrintingRecords;
Shared StringVar YourPreferredSortOrder_sv;

IF     {?PrefrdSortOrder} = 'Original Order' THEN 'Original (Line Num) Order'
ELSE IF
 
TOTEXT ({?PrefrdSortOrder}) = " "           THEN 'Original (Line Num) Order'         //    <- Apparently the error is here!

ELSE IF
   {?PrefrdSortOrder} = 'Description'        THEN 'By Item Desc (Alphabetic)'

---------

Can anyone help me?

Thanks

Leon lai

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Leon,

Try this formula ,

IF     {?PrefrdSortOrder} = 'Original Order' THEN 'Original (Line Num) Order'
ELSE IF
 
Not  hasvalue ({?PrefrdSortOrder})            THEN  'Original (Line Num) Order'     

ELSE IF
   {?PrefrdSortOrder} = 'Description'        THEN 'By Item Desc (Alphabetic)'


Make sure that parameter Optional Prompt is True.


-Rajesh N


leon_laikan
Participant
0 Kudos

Hi Rajesh,

Thanks for your reply.

I tried your suggestion, but I still get that error message.

Best Regards

Leon

Former Member
0 Kudos

Hi Leon ,

Did you set Optional Prompt is True for that parameter??

-Rajesh N

leon_laikan
Participant
0 Kudos

Hi Rajesh

Yes, I set Optional Prompt = True

Hope this will help

Leon

Former Member
0 Kudos

Hi leon,

  close this thread  if you got solution .

-Rajesh N

abhilash_kumar
Active Contributor
0 Kudos

Where do you get this error? Does this work in the CR Designer?

-Abhilash

leon_laikan
Participant
0 Kudos

Hi Rajesh,

I experimented with your suggestion in all possible ways. I am glad to inform you that I found the answer by accident.

We must simply put the HASVALUE formula FIRST ON THE LIST like this:

IF Not  hasvalue ({?PrefrdSortOrder})            THEN  'Original (Line Num) Order'     

ELSE IF     {?PrefrdSortOrder} = 'Original Order' THEN 'Original (Line Num) Order'

ELSE IF
   {?PrefrdSortOrder} = 'Description'        THEN 'By Item Desc (Alphabetic)'

THEN IT WORKS PERFECTLY.

I don't know why, but it works.

It seems that the HASVALUE formula must always be evaluated FIRST

So, many thanks for hinting the correct solution, and I'm marking your answer as CORRECT (even if not 100% correct)!

BEST REGARDS

Leon

DellSC
Active Contributor
0 Kudos

It works this way because "Has Value" checks for a null value.  Null is not a value as such and comparing anything to null doesn't evaluate to either true or false.  For more information about how this works, you can see my post here:  What is Null and Why is it Important for Crystal Reports | SAP BI BLOG

-Dell

leon_laikan
Participant
0 Kudos

Hi Dell Stinnett-Christy

Thanks a lot for your enlightening explanation and your pdf article.

My code makes more sense to me now.

Best Regards

Leon

Answers (0)