cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP Crystal Report - Replace formula syntax

0 Likes
9,215

Hi,

Please share the syntax for REPLACE function in SAP Crystal Report. We have SQL datafield BOOK NO . it is STRING. I need to FIND character , and REPLACE with EMPTY string

REPLACE({CurrentFieldValue},",","") -> throws error

View Entire Topic
0 Likes

Hi, I couldn't quite understand the question.

If you were to replace any type of character within a string the syntax of the replace function would be the same in this example.

Inside the {Command.test} I have a string with the value := "123.abc.456"

If I use -> replace({Command.test},".","")

The result will be the treated string would be "123abc456" without the point it was asked to take.

Now if what you need is to treat an empty or null-valued string, I suggest treating it with a condition first, because as the value is empty you cannot pass an empty value to the function, in the function it will read as if you had not passed it parameter.

IF ISNULL({Command.test}) OR {Command.test} = "" THEN "NOT_string"

ELSE {Command.test}

Then in this case you would have a value to pass as a parameter of the replace function, which would be the "NOT_string", but this case is very specific, because with the condition you did, what the replace function would do.

REPLACE(

(IF ISNULL({Command.test}) OR {Command.test} = "" THEN "NOT_string"

ELSE {Command.test}),"NOT_string","_")