Is it possible to declare condition variable inside an array



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

Is it possible to declare condition variable inside an array

Postby hariharan_bk » Fri Sep 23, 2016 4:32 pm

Hi All,

I have a scenario where i need to compare fields from an array against a table. While looping the array fields to compare every occurence with respective table field, i need to set MATCH/MISMATCH IND to TRUE.

My question is -
In order to set the match/mismatch statuses for every occurences, i thought of using a 88 level variable to serve the purpose. But not sure if we can have condition variables to the fields in an array.

Please confirm if this is possible? If possible, please let me know how we set these fields?



01 WS-TABLE.
   05 WS-PHONE-MATCH-IND OCCURS 100 TIMES.
      10 WS-VAR1-MAT PIC A(1).
           88   Match1        Value 'Y'.
           88   Mis-Match1    Value 'N'.
      10 WS-VAR2 PIC A(1).
           88   Match2        Value 'Y'.
           88   Mis-Match2    Value 'N'.
 


can we set this way?

SET MATCH1 (i) TO TRUE
 


Please advise. I dont have an environment ready to test this in my end. Currently working on Pseudo code for design documents. Please help here.
Many Thanks,
Harry
hariharan_bk
 
Posts: 73
Joined: Thu Mar 29, 2012 11:13 am
Has thanked: 5 times
Been thanked: 0 time

Re: Is it possible to declare condition variable inside an a

Postby Robert Sample » Fri Sep 23, 2016 6:45 pm

I tested with Enterprise COBOL 5.1.1 and you can use 88 levels under an array. You use a subscript or index on the 88 level just like any other variable:
IF  MATCH1 (WS-SUB)
    <DO WHATEVER>
END-IF
You can use the SET TO TRUE or a MOVE to the array element -- whichever you want to do.

These users thanked the author Robert Sample for the post:
hariharan_bk (Fri Sep 23, 2016 8:51 pm)
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Is it possible to declare condition variable inside an a

Postby hariharan_bk » Fri Sep 23, 2016 8:48 pm

Many thanks, Robert.

Got a relief to design now, to have a Condition variable for each occurrence of an array element.
Many Thanks,
Harry
hariharan_bk
 
Posts: 73
Joined: Thu Mar 29, 2012 11:13 am
Has thanked: 5 times
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post