Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to split the numeric and character in string?

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 ?



Former Member
Former Member replied

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).
  ADD 1 TO pos.


Valter Oliveira.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question