Application Development 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: 

String Function in ABAP?

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

3 REPLIES 3

Peter_Lintner
Participant
0 Kudos

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

Former Member
0 Kudos

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

former_member555112
Active Contributor
0 Kudos

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.