01-11-2007 7:39 AM
hi all,
my requirement is :
i have a string 'NAKUL,AGARWAL'.
i want to read each alphabet of this string and then check if ',' comes ,i have to do certain coding and change it to '.'.
can you help me?
01-11-2007 7:41 AM
data : v_name(15) value 'NAKUL,AGARWAL'.
search v_name for ','.
if sy-subrc eq 0.
replace ',' with '.' into v_name.
endif.
01-11-2007 7:42 AM
Perhaps you could try any of these
REPLACE ',' WITH '.' INTO string.
SPLIT string at ',' INTO string1 string2.
regards
01-11-2007 7:45 AM
01-11-2007 7:50 AM
you can use search and replace .
else
data : len type i,
v_chr ,
pos type i.
compute len = strlen( str1 ).
do len times.
v_chr = str1+pos(1).
if v_chr = ','.
<do coding>
endif.
pos = pos + 1.
enddo.
regards
shiba dutta
01-11-2007 7:52 AM
refer demo code
Character occurance in a String -
PARAMETERS : P_CHAR TYPE C LOWER CASE.
data str type string.
dATA: LEN TYPE I,
COUNT TYPE I,
PASS TYPE I VALUE '0'.
str = 'amita'.
CONDENSE STR.
LEN = STRLEN( STR ).
DO LEN TIMES.
IF P_CHAR = STR+pass(1).
COUNT = COUNT + 1.
ENDIF.
pass = pass + 1.
ENDDO.
01-11-2007 7:51 AM
Hi,
v1 = 'NAKUL,AGARWAL'.
Replace all occurrences of ',' with '.' in v1.
01-11-2007 7:56 AM
Hi Nakul,
Check the code for u r requirement,
REPORT ZEX31 .
PARAMETER : str1(20) .
DATA : v2(20),
d TYPE i,
e TYPE i,
f TYPE i.
d = 0.
e = 0.
f = strlen( str1 ).
WHILE d NE f.
IF str1+d(1) ne ','.
v2e(1) = str1d(1).
d = d + 1.
e = e + 1.
ELSE.
v2+e(1) = '.'.
e = e + 1.
d = d + 1.
ENDIF.
ENDWHILE.
write : / str1.
write : / v2.
01-11-2007 8:51 AM
01-11-2007 11:07 AM
Hi,
use this statement,
replace all occurences of ',' with '.' in v_string.
Regards,
Aman