Print Page | Close Window

Printing parameter value for Range and Multiple

Printed From: Crystal Reports Book
Category: General Information
Forum Name: Talk with the Author
Forum Discription: Ask Brian questions about his books and give him your comments. Like the book? Hate the book? Have suggestions? Let me know!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=10739
Printed Date: 17 May 2024 at 7:35pm


Topic: Printing parameter value for Range and Multiple
Posted By: rbarekere
Subject: Printing parameter value for Range and Multiple
Date Posted: 04 Aug 2010 at 12:36pm
This is the question about printing parameter value for range and multiple value type.
 
I got the sample formula from Crystal Reports Encyclopedia.
 
NumberVar Index;
StringVar Output;
StringVar LowerValue; StringVar UpperValue;
for Index:=1 to UBound({?[0S_GLACC]}) Do
(
    //Add a comma to seperate values
    if Output <> "" Then
        Output := Output &", ";
    LowerValue :="";
    UpperValue :="";
    //Get the upper and lower values
    if HasLowerBound({?[0S_GLACC]}[Index]) Then
        LowerValue := Minimum({?[0S_GLACC]}[Index]);
    if HasUpperBound({?[0S_GLACC]}[Index]) Then
        UpperValue :=Maximum({?[0S_GLACC]}[Index]);
    //Discrete values have the same upper and lower bound
    if LowerValue = UpperValue Then
        Output := Output & LowerValue
    Else
//Print the range values
    (if LowerValue <> "" Then
        Output := Output + " From " & LowerValue;
     if UpperValue <> "" Then
        Output := Output + " To " & UpperValue;)
);
Output := Output;
 
This works perfectly alright. Problem here is this report is SAP BW specific.
Like all other classic crystal parameters, we can enter value or select the value from picklist. Since this is a SAP specific there is a difference in us entering value for range or multiple and selecting the value from picklist.
1) Entering value in parameter will have the format like 1234567 (7 digit)
2) selecting value from picklist will have [0GL_Account].[00100001234567]
 
So I edited above formula to find if the value include "[" in the string if so then get the part of string other wise get the actual string.
 
NumberVar Index;
StringVar Output;
StringVar LowerValue; StringVar UpperValue;
StringVar LowerValue1; StringVar UpperValue1;
for Index:=1 to UBound({?[0S_GLACC]}) Do
(
    //Add a comma to seperate values
    if Output <> "" Then
        Output := Output &", ";
    LowerValue :="";
    UpperValue :="";
    LowerValue1 := "";
    UpperValue1 := "";
      //Get the upper and lower values
    if HasLowerBound({?[0S_GLACC]}[Index]) Then
        LowerValue := Minimum({?[0S_GLACC]}[Index]);
    if HasUpperBound({?[0S_GLACC]}[Index]) Then
        UpperValue :=Maximum({?[0S_GLACC]}[Index]);
    //Discrete values have the same upper and lower bound
    if LEFT(LowerValue,1) = "[" Then
        LowerValue1 := (Mid(LowerValue, Instr(LowerValue,".")+6, 10))
    //if Mid(LowerValue,1,1) <> "[" Then
    Else
        LowerValue1 := (LowerValue);
   // Else LowerValue1 := LowerValue;
    if Left(UpperValue,1) = "[" Then
        UpperValue1 := (Mid(UpperValue, Instr(UpperValue, ".")+6, 10))
    Else
    //if Mid(UpperValue,1,1) <> "[" Then
        UpperValue1 := (UpperValue);
    if LowerValue = UpperValue Then
        //Output := Output + Cstr(LowerValue1,"#")
        Output := Output & LowerValue1
    Else
//Print the range values
    (if LowerValue <> ""  Then
        // Output := Output + " From " & CStr(LowerValue1,"#");
        Output :=Output +" From " & LowerValue1;
     if UpperValue <> "" Then
        //Output := Output + " To " & CStr(UpperValue1,"#");)
        Output :=Output +" To " & UpperValue1;)
);
Output := Output;
 
This formula is partially correct, but it returned 2 set of same value, one with formatted value and one without formatted value. I have no idea where i am going wrong.
 
Any help is appreciated.



Print Page | Close Window