Page 1 of 1

2D array going beyond subscript

PostPosted: Wed Aug 06, 2014 3:54 pm
by AbhiKulkarni
Hi,

This is what I am facing :-

Array declaration -
05 WS-D1 OCCURS 10 TIMES INDEXED BY D1-IX.
     10 WS-P1.
         15 WS-P1-CNT PIC S9(04) COMP.
         15 WS-P1-TBL.
             20 WS-P1-ARRAY OCCURS 05 TIMES INDEXED BY P1-IX.
                  25 WS-P1-ID PIC S9(09) COMP.
     10 FILLER X(10).


The P1 array is of (10,5) size.

Now when i do MOVE WS-P1-ID(WS-IX1, WS-IX2) TO WS-TEMP-ID in a perform (a badly coded perform), it allows me to do this till the value of WS-IX2 is 75.
i.e. when it does MOVE WS-P1-ID(1, 76) TO WS-TEMP-ID it abends. :o

Now, more confusing part. I increased the FILLER from X(10) to X(100) in the above declaration. And now it is allowing the array to be performed till WS-IX2 is 84.

I may have sounded confused here (which i am actually..!!), so please let me know if you need more information.

Thank you,
Abhishek.

Code'd

Re: 2D array going beyond subscript

PostPosted: Wed Aug 06, 2014 5:34 pm
by BillyBoyo
If you look at the Programming Guide documentation of SSRANGE (I assume the abend you are talking about is caused by SSRANGE) you should discover that SSRANGE will abend if you attempt to reference data outside the table, but it will not validate individual subscript values. So you may feel that 20 is an invalid value, but if its use refers to data within the table as a whole, SSRANGE is not going to complain.

You can calculate what you'd expect the maximum lower-level subscript to be, given the table size. Extending the FILLER just extended the size of the table, so allowed your unchecked subscript to get even larger.