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

check whether value in a field is odd or even

Hi folks,

I have some value in a field 'count'. I want to check if the value in that field is even or not. I need to put a IF loop saying that if the value in 'count' is even then execute the loop. How can I do this.

I appreciate the efficient method to check this. Thanks

Waiting.............

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Aug 02, 2006 at 12:29 AM

    hi

    try using the below logic..

    data even type i.

    even = count mod 2.

    if even eq 0.

    <execute your loop here>.

    endif.

    Cheers,

    Abdul Hakim

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 02, 2006 at 12:42 AM

    hi

    has your problem solved??

    Cheers,

    Abdul Hakim

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 02, 2006 at 12:46 AM

    You can do something like this.

    
    report zrich_0002 .
    
    
    data: i type i value 48.
    data: remainder type i.
    
    remainder = i mod 2.
    if remainder = 0.
      write:/ 'This is an even number'.
    else.
      write:/ 'This is an odd number'.
    endif.
    
    

    Ooops, Abdul beat me to it.

    Regards,

    Rich Heilman

    Message was edited by: Rich Heilman

    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.