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: 

reading string character by character

former_member181959
Contributor
0 Kudos
2,271

hi...

how can i read a srting character by character. for example if i have a string like srikanth i want to get all the characters like 's' 'r' 'i' 'k' 'a' 'n' 't' 'h' .

thanku all...

prasad.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
219

Hi, maybe this problem has already been solved.

But I have a interesting solution for it.

Paste in following:

DATA: STR(100) TYPE C,

ITAB TYPE STANDARD TABLE OF CHAR1.

STR = 'HELLO WORLD'.

CALL FUNCTION 'RKD_WORD_WRAP'

EXPORTING TEXTLINE = STR

OUTPUTLEN = 1

TABLES OUT_LINES = ITAB.

BREAK-POINT.

4 REPLIES 4

Former Member
0 Kudos
219

hi,

LOOP.

IF i < STRLEN( <string> ).

chr = <string>+i(1).

i = i+1.

ELSE.

exit.

ENDIF.

ENDLOOP.

Regards,

Andrej.

Former Member
0 Kudos
219

Hi,

You can read it like this.

Data : len type i,

a type c,

b type i.

i = strlen( string ).

Do i times.

b = sy-index - 1.

a = string+b(1).

write a.

enddo.

Regards,

Gagan

0 Kudos
219

Well depending on you character set you really have to take into account the fact that you might be dealing with a multibyte character set.

The best bet would be to transform your string into a char[] character array and walk through it. This should hopefully negate the differences between multibyte and single byte character sets.

Enjoy

Former Member
0 Kudos
220

Hi, maybe this problem has already been solved.

But I have a interesting solution for it.

Paste in following:

DATA: STR(100) TYPE C,

ITAB TYPE STANDARD TABLE OF CHAR1.

STR = 'HELLO WORLD'.

CALL FUNCTION 'RKD_WORD_WRAP'

EXPORTING TEXTLINE = STR

OUTPUTLEN = 1

TABLES OUT_LINES = ITAB.

BREAK-POINT.