on ‎2021 Oct 01 8:13 AM
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
Request clarification before answering.
Or, easier than going through all of that, in the Formula Editor, change the null handling for this formula to "Default values for nulls" instead of "Exception for nulls". This will automatically replace a null field value with an empty string. Replace will work with any string value - even an empty string - but it throws an error on a null.
-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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","_")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.