‎2007 Jul 25 1:45 PM
Hello ,
my requirement is if i have a string i want to chec if the 4th character from right is a dot or not.....if yes then replace it with comma.
if str = '123.546.236'
then it shud be 123.546,236.
also the contents of field are not of fixed length.ie. str = 12.365 or 12356.000.
Kindly provide the solution
regards
Pranali.
‎2007 Jul 25 1:50 PM
Use this code:
data len type i.
compute len = strlen( str ).
len = len - 4.
if str+len(1) eq '.'.
str+len(1) = ','.
endif.Please mark points if the solution was useful.
Regards,
Manoj
‎2007 Jul 25 1:49 PM
Hi,
use the Function module
STRING_REVERSE to reverse the string
and then use
REPLACE FIRST OCCURANCE OF '.' IN str WITH ','.
Again use
STRING_REVERSE
Regards,
Sesh
‎2007 Jul 25 1:50 PM
Use this code:
data len type i.
compute len = strlen( str ).
len = len - 4.
if str+len(1) eq '.'.
str+len(1) = ','.
endif.Please mark points if the solution was useful.
Regards,
Manoj
‎2007 Jul 25 1:50 PM
DATA : LV_CHAR TYPE C,
STR(10) TYPE C.
STR = 'Hel.oo'.
LV_CHAR = STR+3(1).
IF LV_CHAR EQ '.' .
STR+3(1) = ','.
ENDIF.
WRITE STR.
Thanks,
Mahesh
‎2007 Jul 25 1:51 PM
Hey Pranali,
Try this out,
Get the lenght of your string str
len = strlen( str ).
Less 4, to get the right position
len = len - 4.
*Using offset get one caracter at that position, if it is a dot, change to comma
if str+len(1) = '.'.
str+len(1) = ','.
endif.
Hope this helps.
Regards,
Marcelo Moreira
‎2007 Jul 25 1:51 PM
‎2007 Jul 25 1:52 PM
if str cs '.'.
REPLACE '.' WITH ',' INTO str.
endif.
reward if usefull.....
‎2007 Jul 25 1:54 PM
REPORT ztest.
DATA : v_str TYPE string VALUE '123.546.236',
v_char(250),
v_len TYPE i.
v_char = v_str.
v_len = STRLEN( v_char ).
v_len = v_len - 4.
IF v_char+v_len(1) EQ '.'.
v_char+v_len(1) = ','.
ENDIF.
v_str = v_char.
WRITE : v_str.
‎2007 Jul 25 1:54 PM
v_len = stelen (str).
v_len = v_len - 3.
if str+0(v_len) = '.'.
replace str+0(v_len) with ','.
endif.
‎2007 Jul 25 1:55 PM
If str+3(1) = '.'. " If dot
str+3(1) = ','. " replace with comma
endif.reward if useful
Regards
Prax