Skip to Content
0
Former Member
May 31, 2013 at 04:03 PM

String concatenate Issue (space is not adding)

36 Views

Hello Experts,

I've wrote a custom string function to remove commas in Names or address fields. The following code works fine if there is NO SPACE in the given string as it remove all the commas. (i.e D,J,UICE = DJUICE). However, issue happens if I provide a string like this (D,J JE,FF S,AM ,D,ONE.). Instead of making it (DJ JEFF SAM DONE) it makes it like this (DJJEFFSAMDONE).

Any clue how I can convert it into my desired output, which is DJ JEFF SAM DONE.

Here is my code.

FORM REMOVE_COMMAS CHANGING pgv_change_text TYPE string.

DATA: i type i,
gv_length type i,
stest(100),
sakt(1),
str1(100).

CONSTANTS: c_deli TYPE c value ' '.

"Check length
gv_length = strlen( pgv_change_text ).

WHILE i < gv_length.
sakt = pgv_change_text+i(1).
if sakt = ','.
sakt = ''.
elseif sakt = ' '.
sakt = c_deli.
endif.
"shift stest.
concatenate str1 sakt into str1.

i = i + 1.
ENDWHILE.
pgv_change_text = str1.


ENDFORM.

Many thanks in advance.