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 the words into letters

Former Member
0 Likes
1,795

How do i split the words in letters?

example 'aaab' into a a a b

i need to find out the maximum value and minimum value for a sentence or word.

example: aaab

aaac

aaad

aaab will be minimum value.

aaad will be maximum value.

How do i split the words in letters?

example 'aaab' into a a a b

i need to find out the maximum value and minimum value for a sentence or word.

example: aaab

aaac

aaad

aaab will be minimum value.

aaad will be maximum value.

4 REPLIES 4
Read only

harimanjesh_an
Active Participant
0 Likes
962

hi jocelyn,

To check which is maximum you can use greater than

operator.

example:

data: w_one(4) type c value 'aaab',

w_two(4) type c value 'aaad',

w_great(4) type c.

if w_one > w_two.

w_great = w_one.

else.

w_great = w_two.

endif.

'>' or 'gt' operator can be used on character types.

Regards,

Harimanjesh AN

Read only

Former Member
0 Likes
962

DATA : l_var(10) VALUE 'AAAB',
       l_final TYPE string,
       str_len TYPE i,
       pos TYPE i.

str_len = STRLEN( l_var ).

l_final = l_var+0(1).
DO str_len TIMES.
  pos = sy-index.
  CONCATENATE  l_final l_var+pos(1)  INTO l_final SEPARATED BY space.
ENDDO.

WRITE :/ l_final.


"maximum and minimum values you can find by comapring values just like numerics.

Read only

Former Member
0 Likes
962

ANSWERS

How do i split the words in letters?

example 'aaab' into a a a b

U can use offsets

first find out the length of the word, loop that no-of times, take each character using offset

i need to find out the maximum value and minimum value for a sentence or word.

for this u can use < or > operators

Reward if useful

Narendra

Read only

Former Member
0 Likes
962

Hello Jocelyn,

You can split the words into letter using the follwing code.

REPORT zsample.

DATA: text(10).

DATA: BEGIN OF itab OCCURS 0,
        letters(1),
      END OF itab.

text = 'abcdef'.

WHILE NOT text IS INITIAL.

  itab = text+0(1).
  APPEND itab.

  SHIFT text LEFT BY 1 PLACES.

ENDWHILE.

LOOP AT itab.

  WRITE: / itab.

ENDLOOP.

comparing the sentence:

REPORT zsample.

DATA: text1(10), text2(10).

text1 = 'abcde'.
text2 = 'abcd'.

IF text1 < text2.
  WRITE: / text2, 'is having more avlue'.
ELSEIF text1 > text2.
  WRITE: / text1, 'is having more havlue'.
ELSE.
  WRITE: / 'equal'.
ENDIF.

Reward If Helpful.

Regards

--

Sasidhar Reddy Matli.