Skip to Content
0
Former Member
Jan 27, 2009 at 09:16 AM

Splitting a string in different substrings

1183 Views

Hallo,

I want to split a string of any length in new substrings and want to save these substrings in different variables.

I tried as following:

data:
      string type string value 'Hallo SAP world',  "This could be any string with any lenght
      offset type i value 0,
      str_len type i,
      new_str type string.

str_len = strlen( string ).

do 5 times.
  new_str = string+offset(3).
  write : new_str.
  write : ' '.

  offset = offset + 3.
   enddo.

1_ Has anyone any idea, how to save the new substrings in different variables?

2_ Since the new substring has length 3. So how many times should the do-loop run?

Thanks

ama