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

Former Member
0 Likes
970

Hi all,

How can i split a string character by character?

Best regards,

Munur

6 REPLIES 6
Read only

Former Member
0 Likes
804

hi there ....

get the length of the string... then put a loop on the length...

use SPLIT command for index 1 till the loop ends...

i hope this helps...

regards

Read only

Former Member
0 Likes
804

Below is the syntax:

SPLIT <c> AT <del> INTO <c1>... <cn> INTO TABLE <itab>.

This statement searches the character field <c> for delimiter strings <del> and the parts before and after the delimiters are placed in the target fields <c1> ...> u2026 <cn>, or into a new line of the internal table <itab>. In Unicode programs, you must specify whether the statement is a character or byte operation, using the IN BYTE MODE or IN CHARACTER MODE (default) additions.

Try to use this if this could help you.

Read only

Former Member
0 Likes
804

Hi

DATA: lv_string TYPE string VALUE 'sathar',
      lv_lines TYPE i,
      lv_char TYPE c,
      lv_offset TYPE i.

lv_lines = STRLEN( lv_string ).

do lv_lines TIMES.

  lv_char = lv_string+lv_offset(1).
  WRITE : / lv_char.

  add 1 to lv_offset.

enddo.

Regards

Sathar

Read only

Former Member
0 Likes
804

Press F1 on SPLIT. You will get syntax for the same.

Read only

Former Member
0 Likes
804

Hi,

Refer following code

DATA : NAME TYPE STRING.

DATA : COUNT TYPE I,

CNT TYPE I.

data ch.

COUNT = STRLEN( NAME ).

do.

if cnt = count

exit.

endif.

ch = name+cnt(1).

cnt = cnt + 1.

enddo.

regards,

Pritish

Read only

Former Member
0 Likes
804

You want to split character by character, do it this way.

len = strlen( p_string ).
do len times.
ch = p_string+0(1) " here you get character by character in p_string+0(1) in every cycle, manipulate according to your need
shift p_string circular.
enddo.

Regards,

Lalit Mohan Gupta.