04-17-2009 12:51 PM
Hi all,
How can i split a string character by character?
Best regards,
Munur
04-17-2009 12:53 PM
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
04-17-2009 12:55 PM
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.
04-17-2009 12:56 PM
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
04-17-2009 12:57 PM
04-17-2009 1:03 PM
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
04-17-2009 1:06 PM
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.