Skip to Content
author's profile photo Former Member
Former Member

how to search occurance of a character in a string

for example in a word Mississippi, find the frequency of character S. it should be 4 as it contains four s.

what is a code.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Jul 21, 2014 at 04:42 AM

    Hi,

    Use FIND ALL OCCURRENCES OF Statement

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 21, 2014 at 04:55 AM

    Hello Abaper,

    use RegX that is regular expression to find occurance of any parten in string

    before Start coding please have a look below link.

    http://help.sap.com/abapdocu_702/en/abenregex_search.htm

    DATA result_tab TYPE match_result_tab.
    FIND ALL OCCURRENCES OF regex 'd*od*' IN 'doobedoddoo'
    RESULTS result_tab.

    Add a comment
    10|10000 characters needed characters exceeded

    • Its useful when you use SEARCH keyword

      SEARCH dobj FOR pattern

      This statement searches the data object dobj according to the search pattern specified in pattern. The additions allow to search subareas, shortened patterns and marking of places of finding.

      The search ends at the first hit and sy-fdpos is set to the offset of the found pattern or to the word in the search area. If the pattern is not found, then sy-fdpos is set to value 0.

      Reward if helpful.

      http://scn.sap.com/thread/897854

  • author's profile photo Former Member
    Former Member
    Posted on Jul 21, 2014 at 05:10 AM

    Hi Shri Vas,

    Please check these links...I am sure it will help you 😊

    https://help.sap.com/saphelp_46c/helpdata/en/fc/eb33cc358411d1829f0000e829fbfe/content.htm

    Regards,

    Shahir Mirza

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 21, 2014 at 05:39 AM

    Hi shri vas,

    data: result type match_result_tab,

    w_result type LINE OF match_result_tab,

    num type c.

    FIND ALL OCCURRENCES OF 's' in 'Mississippi' results result.

    loop at result INTO w_result.

    num = num + 1.

    endloop.

    WRITE num.


    Regards,

    Seshu

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.