05-14-2009 7:05 AM
Hi,
Is there any function in ABAP which can read a string character by character.
E.g: String = "ABCDEF"
With 1st iteration it should return: "A"
With 2nd iteration it should return: "B"
.
.
.
With 2nd iteration it should return: "F"
Thanks,
Ravi
Edited by: Ravi Mehta on May 14, 2009 8:06 AM
05-14-2009 7:11 AM
Try these codes .Function module at times hamper the performance of your program as it loads the Function group memory at runtime into your program.
Parameters:p_char(30) type string.
data: w_len type i,
w_len1 type i.
w_len = strlen( P_char ).
Do w_len times.
Write : p_char+w_len1(1).
add 1 to w_len1.
Enddo.
Regards,
Gurpreet
05-14-2009 7:09 AM
Hi Ravi!
maybe following coding may help you:
len = strlen(l_var_string)
do len times.
pos = sy-index - 1.
result = l_var_string+pos(1).
enddo.
Regards
Peter
05-14-2009 7:11 AM
Try these codes .Function module at times hamper the performance of your program as it loads the Function group memory at runtime into your program.
Parameters:p_char(30) type string.
data: w_len type i,
w_len1 type i.
w_len = strlen( P_char ).
Do w_len times.
Write : p_char+w_len1(1).
add 1 to w_len1.
Enddo.
Regards,
Gurpreet
05-14-2009 7:21 AM
Hi,
You can acheive it like this.
DATA : string TYPE char6,
char TYPE c,
place type i,
cntr1 TYPE i.
string = 'ABCDEF'.
cntr1 = STRLEN( string ).
WHILE sy-index le cntr1.
place = sy-index - 1.
char = string+place(1).
ENDWHILE.