Page 1 of 1

3-dimensional array

PostPosted: Fri Jun 04, 2010 9:23 pm
by Vikrant Survase
i want to create a 3or more than 3 dimensional array, how do i create it and add some content in it? :?:

Re: 3-dimensional array

PostPosted: Fri Jun 04, 2010 10:06 pm
by Robert Sample
Enterprise COBOL supports arrays up to 7 dimensions. Just define the OCCURS variables, set your subscripts (or indexes) and use the array elements just like any other array in COBOL.

Re: 3-dimensional array

PostPosted: Sat Jun 05, 2010 2:58 am
by dick scherrer
Hello and welcome to the forum,

Is this just out of curiosity or do you have some requirement? Is this a solution in search of a requirement?

Re: 3-dimensional array

PostPosted: Sun Jun 06, 2010 5:17 pm
by Vikrant Survase
actually ths was our assingment so would u plz help me?

Re: 3-dimensional array

PostPosted: Sun Jun 06, 2010 5:50 pm
by Vikrant Survase
Robert Sample wrote:Enterprise COBOL supports arrays up to 7 dimensions. Just define the OCCURS variables, set your subscripts (or indexes) and use the array elements just like any other array in COBOL.


ya i know we hv to use OCCURS clause but for 3 dimensional it must be written 3 times as shown

01 table.
   02 tab1 occurs 5 times.
    03 tab2 occurs 4 times.
     04 tab3 occurs 3 times.
      05 num pic 9(4).


is this correct?
if not would u please tell me the proper code..!

and hw does we access it.

Re: 3-dimensional array

PostPosted: Sun Jun 06, 2010 8:20 pm
by Robert Sample
Your definition is exactly right. You would need to define subscript variables for each dimension, set them appropriately, then use them to access NUM. For example,
77  WS-I1 PIC 9.
77  WS-I2 PIC 9.
77  WS-I3 PIC 9.


MOVE 4 TO WSI1.
MOVE 3 TO WS-I2.
MOVE 2 TO WS-I3.
MOVE NUM (WS-I1, WS-I2, WS-I3) TO ...
or you could define an INDEXED BY for each OCCURS clause and use the indexes instead of subscripts.

Re: 3-dimensional array

PostPosted: Mon Jun 07, 2010 12:08 am
by Vikrant Survase
Robert Sample, thanks thats was helpful