DATA mystr  TYPE string.

 mystr = 'liujincai is a good person'.


DATA ilen TYPE i.


WRITE mystr.
ULINE.

perform count_in_str USING  mystr 'i' ilen.


WRITE ilen.



*&---------------------------------------------------------------------*
*&      Form  countInStr
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_STR      text
*      -->P_COUNT    text
*----------------------------------------------------------------------*
FORM count_in_str USING value(p_str) p_char p_count.
   DATA: ilen1 TYPE i,ilen2 TYPE i.
   ilen1 = STRLEN( p_str ).
   REPLACE ALL OCCURRENCES OF p_char IN p_str  WITH ''.
   ilen2 = STRLEN( p_str ).
   p_count = ilen1 - ilen2.
ENDFORM.                    "countInStr