Skip to Content
0
Dec 21, 2007 at 03:35 AM

how to find, "how many times the purticular word is appearing in a string?"

34 Views

Hai guys,

is there any keyword available in abap to find , "how many times the purticular word is appearing in a string?"

this is my example coding.

DATA : STR(40) VALUE 'INDIA WAS GREAT WAS WAS'.

DATA : LEN TYPE I.

LEN = STRLEN( STR ).

DO LEN TIMES.

REPLACE 'WAS' WITH 'IS' INTO STR.

ENDDO.

WRITE : STR.

in this coding length of the sting in 23.Here the word "WAS" is appearing 3 times. bcoz of the length 23 the "DO........ENDDO" loop is processing 23 times.

insted of doing this, i want to find, hw many times the word "was" is appearing in the string? if i found that, "DO........ENDDO" loop will process 3 times only. then the processing time will be very very less.

NOTE : USEFUL GUDELINE WILL BE REWARDED.

Rgards,

shafi.