-1

Please help me in understanding what does the below code really mean?

CASE WHEN REPLACE(tablename.columnname,CHR(13),'') <> '' 
THEN 
  REPLACE(tablename.columnname,CHR(13), '')
ELSE 
  REPLACE(tablename.columnname,CHR(13),'')

For your reference:

tablename.columname = mara.matnr

mara is a table and matnr is a field name in the table Mara.

mustaccio
  • 18,234
  • 16
  • 48
  • 57

1 Answers1

0

CHR(13) is a carriage return, sometimes seen in text fields. I've worked on a number of solutions where I had to strip those out of strings so that when I displayed them on a reporting front-end (such as Excel), they didn't go to a new row. That is essentially what this code is doing - removing carriage returns by replacing them with a zero-length string.

The CASE expression you reference above is essentially useless, since it is using the same expression in both the THEN and ELSE. The entire script could be rewritten as:

REPLACE(tablename.columnname,CHR(13),'')
AHiggins
  • 7,029
  • 6
  • 36
  • 54