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

Help

Former Member
0 Likes
360

Give the code for removing redundency of character's in a word.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
341

hI..

Data:

w_string(30) type c, " Copy Input String.

w_length type i, " Length of string.

w_char type c. " Character to check.

w_length = strlen( p_string ).

w_string = p_string.

write : /'Given string is:'(001),w_string.

write : /'Distinct Chars :'(002).

condense w_string no-gaps.

while w_length gt 0.

w_char = w_string+0(1).

write: w_char.

replace all occurrences of w_char in w_string with space.

condense w_string no-gaps.

w_length = strlen( w_string ).

endwhile.

Message was edited by:

Rammohan Nagam

2 REPLIES 2
Read only

Former Member
0 Likes
342

hI..

Data:

w_string(30) type c, " Copy Input String.

w_length type i, " Length of string.

w_char type c. " Character to check.

w_length = strlen( p_string ).

w_string = p_string.

write : /'Given string is:'(001),w_string.

write : /'Distinct Chars :'(002).

condense w_string no-gaps.

while w_length gt 0.

w_char = w_string+0(1).

write: w_char.

replace all occurrences of w_char in w_string with space.

condense w_string no-gaps.

w_length = strlen( w_string ).

endwhile.

Message was edited by:

Rammohan Nagam

Read only

Former Member
0 Likes
341

hi,

*"Selection screen elements............................................

PARAMETER

p_string(20) TYPE c. " String

*" Data declarations...................................................

"----


  • Work variables *

"----


DATA:

w_index TYPE i , " Index

w_index1 TYPE i VALUE 1, " Index

w_strlen TYPE i. " String length

IF P_STRING CO 'ABCDEFGHIJKLMNOPQRSTUVWXYZ '.

w_strlen = STRLEN( p_string ).

*finding all distinct characters....................................

DO w_strlen TIMES.

IF w_index NE 0.

w_index1 = w_index - 1.

DO w_index TIMES.

IF p_stringw_index(1) EQ p_stringw_index1(1).

EXIT.

ENDIF. " ENDIF P_STRING..

SUBTRACT 1 FROM w_index1.

ENDDO. " ENDDO W_INDEX..

IF w_index1 EQ -1.

WRITE p_string+w_index(1).

ENDIF. " ENDIF W_INDEX1..

ADD 1 TO w_index.

ELSE.

WRITE p_string+w_index(1).

ADD 1 TO w_index.

ENDIF. " ENDIF W_INDEX..

ENDDO. " ENDDO W_STRLEN..

ELSE.

WRITE 'ENTER CHARACTERS ONLY'(001).

ENDIF.

regards,

ananth