09-11-2008 9:59 AM
Dear all
I have a problem with the split string to detach the numeric and character
For example:
Str1=u2019123.456 abcdu2019
I want the return value is u2018123.456u2019 ,removed the u2018abcdu2019
In this example the character u2018abcdu2019 maybe dynamic bits or value.
It can u2018abcu2019 or can u2018abcdeu2019 or can u2018abdu2019 etc..
How do to do it ?
Thanks
Sun
09-11-2008 10:22 AM
Are the letters always in the end? And starting in position 8? Or having the space between numbers and letters? This is usefull info that could allow us to give you the BEST solution.
However, I'll give you a generic solution that will allways work (I hope ).
DATA: lenght TYPE i,
pos(2) TYPE n,
str1 TYPE char255 VALUE '123.456 abcd'.
lenght = strlen( str1 ).
CLEAR pos.
DO lenght TIMES.
IF NOT str1+pos(1) CO '0123456789.'.
CLEAR str1+pos(1).
ENDIF.
ADD 1 TO pos.
ENDDO.
CONDENSE str1.
Regards.
Valter Oliveira.
09-11-2008 10:01 AM
09-11-2008 10:12 AM
09-11-2008 10:16 AM
Hi Rainer,
sure, but has the value allways a lenght of 7 or does it has an dynamic lenght??
Do you know the answer?
regards, Dieter
09-11-2008 10:10 AM
data : var(10) type n,
var1(10) type c value '12.34VBFG'.
move var1 to var.
write var.
09-11-2008 10:12 AM
09-11-2008 10:22 AM
Are the letters always in the end? And starting in position 8? Or having the space between numbers and letters? This is usefull info that could allow us to give you the BEST solution.
However, I'll give you a generic solution that will allways work (I hope ).
DATA: lenght TYPE i,
pos(2) TYPE n,
str1 TYPE char255 VALUE '123.456 abcd'.
lenght = strlen( str1 ).
CLEAR pos.
DO lenght TIMES.
IF NOT str1+pos(1) CO '0123456789.'.
CLEAR str1+pos(1).
ENDIF.
ADD 1 TO pos.
ENDDO.
CONDENSE str1.
Regards.
Valter Oliveira.
09-11-2008 10:47 AM
09-11-2008 12:28 PM
09-11-2008 10:24 AM
Hi,
Try following code:
IF <field> CA sy-abcde.
length = sy-fdpos - 1.
string = <field>+0(leneth).
ENDIF.
Regards,
Kunjal