Compare multiple fields

Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Compare multiple fields

Postby rockstar2020 » Wed Oct 01, 2014 8:30 pm

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).     
Posts: 32
Joined: Wed Jan 08, 2014 3:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Compare multiple fields


Re: Compare multiple fields

Postby BillyBoyo » Wed Oct 01, 2014 9:20 pm

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.
Global moderator
Posts: 3738
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 255 times

Return to IBM Cobol


  • Related topics
    Last post