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 comment
10|10000 characters needed characters exceeded

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 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 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 comment
    10|10000 characters needed characters exceeded