abap-cleaner icon indicating copy to clipboard operation
abap-cleaner copied to clipboard

Feature Request: Replace REPLACE with replace()

Open jan-jezek opened this issue 1 year ago • 1 comments

REPLACE ALL OCCURRENCES OF PCRE '<([^\/>]+)\/>' IN variable WITH '<$1></$1>'.

https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abapreplace.htm could be replaced with:

variable = replace(
    val  = variable
    pcre = `<([^\/>]+)\/>`
    with = `<$1></$1>`
    occ  = 0 ).

https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abenreplace_functions.htm

Similarly, I think there can be many new rules based on "old" and "new" string syntax. https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abenstring_functions.htm

jan-jezek avatar Apr 03 '24 10:04 jan-jezek

Hi Jan,

thanks for the idea! We'd have to take a close look on exactly which cases of REPLACE could be replaced with replace() :-), but the hint in the documentation on REPLACE sounds encouraging:

"To replace parts of a character string in an operand position, a replace function can be used that includes some of the functions of the statement REPLACE"

For more cleanup rules that introduce newer string syntax, see #36!

Kind regards, Jörg-Michael

jmgrassau avatar May 30 '24 09:05 jmgrassau