This is more of a gripe than a question, but Ive marked it as a question anyway in case someone can shed some light. It is prompted by a couple of recent forum questions.
Suppose you have a character string with spaces in it and want to replace all the spaces with dashes. The following program uses the REPLACE statement a couple of ways to try to do this:
REPORT ztest MESSAGE-ID 00. DATA: f1(20) VALUE 'ABCDEF GHIJK LMNO'. * OK WHILE sy-subrc = 0. REPLACE space WITH '-' INTO f1. ENDWHILE. * REPLACE_INFINITE_LOOP REPLACE ALL OCCURRENCES OF space IN f1 WITH '-'.
The first attempt using a WHILE/ENDWHILE works, but if you try to do this all at once in the second it dumps with REPLACE_INFINITE_LOOP because it thinks that SPACE or ( ) has zero length.
But if SPACE has zero length, how can it do the replacement correctly in the first case? Is this a bug or a "design feature" of ABAP?
I thought I would bump this to the top to see if there were any further ideas before closing it.
Message was edited by: