Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Crystal Code error

I have the following code in a Formula Field

WhilePrintingRecords;

Shared numberVar counter;

//increments the loop so that all parameter entries can be displayed

Shared stringVar CC_display;

select HasValue({?PF_EqClassCode})

case true :

CC_display := "Class Codes: " + Chr(10);

for counter := 1 to Count({?PF_EqClassCode}) do

(

CC_display := CC_display + ToText({?PF_EqClassCode}[counter],0,"") + " | ";

)

case false :

CC_display := "Class Codes: All";

CC_display;

When I test it the last three lines are highlighted and I get the message:

"The remaining text does not appear to be part of the formula."

I cannot figure out what I am doing wrong.

Thanks

Former Member
Former Member replied

Try making this change:

WhilePrintingRecords;
Shared numberVar counter;
//increments the loop so that all parameter entries can be displayed
Shared stringVar CC_display;
select HasValue({?PF_EqClassCode})
case true : ( //Add open paren
CC_display := "Class Codes: " + Chr(10);
for counter := 1 to Count({?PF_EqClassCode}) do
(
CC_display := CC_display + ToText({?PF_EqClassCode}counter,0,"") + " | ";
)
)  //Add close paren
case false : (//Add open paren
CC_display := "Class Codes: All";
) //Add close paren
CC_display;

The issue is that you're trying to run two lines of code within the first part of the case statement, so Crystal doesn't recognize the second part.

If this doesn't work, you'll have to move the For loop so a separate formula that returns a string and change the code to somethign like this:

WhilePrintingRecords;
Shared numberVar counter;
//increments the loop so that all parameter entries can be displayed
Shared stringVar CC_display;
select HasValue({?PF_EqClassCode})
case true :
CC_display := "Class Codes: " + Chr(10) + {@NewForLoopFormula};
case false :
CC_display := "Class Codes: All";
CC_display;

-Dell

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question