Page 1 of 1

COBOL logic to find Multiples of a value

PostPosted: Wed Jan 16, 2013 4:33 pm
by luckyboyroh
Hi,

My requirement is to check whether the input data is in multiples of another input field, if it so, then i need to set an indicatior to "YES", else it is "NO" .

Example: If input data (50) is in multiples of quantity field (5) , then i need to set indicator to yes.

Input DATA =50,
Quantity = 5
then Indicator to be set to YES.



Can someone help me with the logic to build this.

Re: COBOL logic to find Multiples of a value

PostPosted: Wed Jan 16, 2013 5:16 pm
by tivrfoa
Hi,

You need to divide input data by quantity and check if the remainder is equal zero, then you set the indicator to YES.
http://publib.boulder.ibm.com/infocente ... 4ls109.htm

Re: COBOL logic to find Multiples of a value

PostPosted: Wed Jan 16, 2013 5:44 pm
by enrico-sorichetti
where do You face problems
the logic :o or the code ???

Re: COBOL logic to find Multiples of a value

PostPosted: Wed Jan 16, 2013 5:49 pm
by BillyBoyo
If you put an 88 on the field you define for the remainder, you can make it much clearer. Indeed, unless requiring storing on a file, you could just use the 88 for your YES/NO in a "logical" sense.

If you are doing "a lot" (many millions) of these, then note that with some divisors you can tell by looking at the last 1-3 digits whether or not it is "exact".

Re: COBOL logic to find Multiples of a value

PostPosted: Wed Jan 16, 2013 6:00 pm
by luckyboyroh
Thanks all for ur suggestions. It worked.