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

how many times value in string

Hi,

I'm looking for method to get know how many times char '1' appears in string '0011111001111100111110010011001'.

I need to get information how many working days is in month, so I found field TFACS-MON12 and how to count this?

or another method or table to find working day in month?

Regards,

Joanna

Message was edited by:

Joanna Lazarz

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 01:22 PM

    Hi,

    Use this program

    data: text(50) type c value  '0011111001111100111110010011001',
          len type i,
          ind type i,
          pos type i,
          cnt type i.
    
    len = strlen( text ).
    
    do len times.
     ind = sy-index.
     pos = sy-tabix.
     if text+ind(pos) = '1'.
      cnt = cnt + 1.
     endif.
    enddo.
    write cnt.

    Regards,

    Satish

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      every thing is corect and thaks for help but there should be little change if someone wolud like to use this code :

      len = strlen( text ).

      <b>len = len + 1.</b>

      do len times.

      ind = sy-index.

      pos = sy-tabix.

      <b>ind = ind - 1.</b> because first sign is 0(1) not 1(1) <- is second 😊

      if text_a+ind(pos) = '1'.

      cnt = cnt + 1.

      endif.

      enddo.

      write cnt.

      thnks one again for hepl,

      regards

      Joanna

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.