Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Split string to numbers and characteristics

Former Member
0 Likes
1,480

Hi all.

Does anyone know a FM that splits a string to numbers and characteristics ?

For example - string "56ddfdfhh hjhj 12 ggh fss 33s-yuyu" will give the following internal table:

56

ddfdfhh hjhj

12

ggh fss

33

s-yuyu

Thanks all,

Rebeka

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,180

Hello

Try this code:


data: str(100),
      len type i,
      counter type i,
      symb.
data: begin of itab occurs 0,
      flag,
      str(20),
      end of itab.
data: begin of xtab occurs 0,
      str(20),
      end of xtab.
str = '56ddfdfhh hjhj 12 ggh fss 33s-yuyu'.
len = strlen( str ).
do len times.
  symb = str+counter(1).
  itab-str = symb.
  if symb CO '0123456789'.
    itab-flag = 'N'.
  else.
    itab-flag = 'C'.
  endif.
  append itab.
  counter = counter + 1.
enddo.

loop at itab.
  at new flag.
    clear xtab.
  endat.

  concatenate xtab-str itab-str into xtab-str.

  at end of flag.
    append xtab.
  endat.
endloop.

2 REPLIES 2
Read only

naimesh_patel
Active Contributor
0 Likes
1,180

You can use the FM

FIEB_EXTRACT_NUMBERS to extract the numbers

FIEB_EXTRACT_CHARACTERS to extract the characters.

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
1,181

Hello

Try this code:


data: str(100),
      len type i,
      counter type i,
      symb.
data: begin of itab occurs 0,
      flag,
      str(20),
      end of itab.
data: begin of xtab occurs 0,
      str(20),
      end of xtab.
str = '56ddfdfhh hjhj 12 ggh fss 33s-yuyu'.
len = strlen( str ).
do len times.
  symb = str+counter(1).
  itab-str = symb.
  if symb CO '0123456789'.
    itab-flag = 'N'.
  else.
    itab-flag = 'C'.
  endif.
  append itab.
  counter = counter + 1.
enddo.

loop at itab.
  at new flag.
    clear xtab.
  endat.

  concatenate xtab-str itab-str into xtab-str.

  at end of flag.
    append xtab.
  endat.
endloop.