Page 1 of 1

Compare multiple fields

PostPosted: Wed Oct 01, 2014 8:30 pm
by rockstar2020
As shown in the below code, my requirement is that I want to check whether EMPMARK occurring from 1 to 1000 has same values or not. If all the fields has same value,
I will set a flag, else i will not. Can anyone let me know the best approach/logic to find out whether all the fields has same value?

Some complex suggestions where IF EMPMARK(1) = EMPMARK(2) = EMPMARK(3) .......... = EMPMARK(1000)

01  EMP-TABLE                     VALUE SPACES.   
    10  EMP-TBL-MARKS    OCCURS 1000 TIMES.       
        15  EMPMARK                    PIC X(04).     
                                       

Re: Compare multiple fields

PostPosted: Wed Oct 01, 2014 9:20 pm
by BillyBoyo
Check first value to second: if the same, loop checking each value to first value, stopping just before you fall off the table or when you get a mismatch; if not the same, they're not the sane,

There is a way to do it other than that, but I think you and your colleagues will be happier about having an explicit loop that does it.