Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Discrete parameter value display problem

Status
Not open for further replies.

rbarekere

Technical User
Mar 2, 2009
29
US
Displaying parameters chosen using a formula
faq767-5684

Using the help of code mentioned in above FAQ, I wrote a code for displaying date prompt which include range and multiple value selection. datatype for the parameter is "STRING"!

Possible way of user entering the value is select from picklist or typing the date range or multiple values in mm/dd/yyyy.

I dont have problem when user select value from picklist or (LOV).

Problem when user types the value in mm/dd/yyyy especially when starting month > ending month for ex (starting date 10/01/2001 to ending month 06/30/2013) then it will display like "06/30/2013 to 10/01/2001"


Here is the code snippet which is used while user enters the value

//---If user type the Letting Date---
Output:= Output & minimum({?[S_LETDTE]}[Counter])& " to "& maximum({?[S_LETDTE]}[Counter])&chr(13)


I have attached te full code below



----------------------------------
whileprintingrecords;
stringvar Output:="";
numbervar Counter;
For Counter := 1 to ubound({?[S_LETDTE]}) do(
if minimum({?[S_LETDTE]}[Counter])= maximum({?[S_LETDTE]}[Counter]) then
( if (Mid(Minimum({?[S_LETDTE]}[Counter]),1,1)="[")then
Output:= Output & Mid(split(Minimum({?[S_LETDTE]}[Counter]),".")[2],6,2)&"/"& Replace(Right(split(Minimum({?[S_LETDTE]}[Counter]),".")[2],3),"]","/")& Mid(split(Minimum({?[S_LETDTE]}[Counter]),".")[2],2,4)&chr(13)
else
Output:= Output & minimum({?[S_LETDTE]}[Counter])&chr(13)
)
else
( if (Mid(Minimum({?[S_LETDTE]}[Counter]),1,1)="[") and (Mid(Maximum({?[S_LETDTE]}[Counter]),1,1)="[")then
Output:= Output & Mid(split(Minimum({?[S_LETDTE]}[Counter]),".")[2],6,2)&"/"& Replace(Right(split(Minimum({?[S_LETDTE]}[Counter]),".")[2],3),"]","/")& Mid(split(Minimum({?[S_LETDTE]}[Counter]),".")[2],2,4)&" to " & Mid(split(Maximum({?[S_LETDTE]}[Counter]),".")[2],6,2)&"/"& Replace(Right(split(Maximum({?[S_LETDTE]}[Counter]),".")[2],3),"]","/")& Mid(split(Maximum({?[S_LETDTE]}[Counter]),".")[2],2,4)&chr(13)
Else if (Mid(Minimum({?[S_LETDTE]}[Counter]),1,1)="[") and (Mid(Maximum({?[S_LETDTE]}[Counter]),1,1)<>"[") then
Output:= Output & Mid(split(Minimum({?[S_LETDTE]}[Counter]),".")[2],6,2)&"/"& Replace(Right(split(Minimum({?[S_LETDTE]}[Counter]),".")[2],3),"]","/")& Mid(split(Minimum({?[S_LETDTE]}[Counter]),".")[2],2,4)& " to "&maximum({?[S_LETDTE]}[Counter])&chr(13)
Else if (Mid(Minimum({?[S_LETDTE]}[Counter]),1,1)<>"[") and (Mid(Maximum({?[S_LETDTE]}[Counter]),1,1)="[")then
Output:= Output & minimum({?[S_LETDTE]}[Counter])& " to "&Mid(split(Maximum({?[S_LETDTE]}[Counter]),".")[2],6,2)&"/"& Replace(Right(split(Maximum({?[S_LETDTE]}[Counter]),".")[2],3),"]","/")& Mid(split(Maximum({?[S_LETDTE]}[Counter]),".")[2],2,4)&chr(13)
Else
output:= Output & minimum({?[S_LETDTE]}[Counter])& " to "& maximum({?[S_LETDTE]}[Counter])&chr(13)
)
);
left(Output,len(Output)-1)

 
So your date field is a string? Why not convert it to a date and then use a date parameter? Then all of this complexity goes away.

-LB
 
This prompt is coming from backend, (SAP BW, dont want to mention though)!

We cant have this prompt in Crystal Report due to performance consideration :)
 
Could you convert the Parameter to a date for the display formula? Again this would be much simpler. I guess I'm unclear whether this is actually a CR parameter.

-LB
 
This is not CR parameter, this is the parameter created in backend, it converts to string type in crystal report.
 
I tried to convert the array value to date datatype. But it didnt work may be due to a fact that Minimum and maximum assignment is done while array assignment
 
Is there any way to convert the prompt output to date type and then use it in array?
 
Try (from your initial post):

Output:= Output & date(minimum({?[S_LETDTE]}[Counter])) & " to " & date(maximum({?[S_LETDTE]}[Counter])) &chr(13)

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top