View previous topic :: View next topic
|
Author |
Message |
GAPX1
New User
Joined: 12 May 2007 Posts: 9 Location: arizona
|
|
|
|
Hello:
This MAY belong in the beginner's forum, but I thought I would ask here.
Running IBM Enterprise COBOL for Z/OS 5.2.0.
Vendor code defines the following table:
Code: |
01 ZIO-LGTH-FILE-TABLE.
** REC
** TYP KEY KEY MAX
** LOC LOC LEN LEN
05 ZIO-LGTH-FILE-001 PIC X(16) VALUE '045 009 036 5000'.
05 ZIO-LGTH-FILE-002 PIC X(16) VALUE '057 009 048 4096'.
05 ZIO-LGTH-FILE-003 PIC X(16) VALUE '063 009 054 4096'.
05 ZIO-LGTH-FILE-004 PIC X(16) VALUE '045 009 036 5000'.
05 ZIO-LGTH-FILE-005 PIC X(16) VALUE '000 009 047 0635'.
.
.
.
05 ZIO-LGTH-FILE-091 PIC X(16) VALUE '___ ___ ___ ____'.
05 ZIO-LGTH-FILE-092 PIC X(16) VALUE '000 002 028 0170'.
05 ZIO-LGTH-FILE-093 PIC X(16) VALUE '053 009 050 0700'.
05 ZIO-LGTH-FILE-094 PIC X(16) VALUE '053 009 060 0160'.
01 ZIO-LGTH-FILE-ARRAY REDEFINES ZIO-LGTH-FILE-TABLE.
05 ZIO-LGTH-FILE-ENTRY OCCURS 2 TIMES.
10 ZIO-LGTH-OFFSET PIC 9(03).
10 FILLER PIC X(01).
10 ZIO-LGTH-KEY-LOC PIC 9(03).
10 FILLER PIC X(01).
10 ZIO-LGTH-KEY-LEN PIC 9(03).
10 FILLER PIC X(01).
10 ZIO-LGTH-MAX-LRECL PIC 9(04).
ZIO-CB-FILE-NO contains 093
MOVE ZIO-LGTH-MAX-LRECL (ZIO-CB-FILE-NO)
TO ZIO-CB-REC-LEN-MAX.
|
This is working, despite the fact that the subscript ZIO-CB-FILE-NO contains 093, which exceeds the OCCURS 2 in the REDEFINES.
Questioning why no S0C4, S0C7 is not happening, and how this is working at all. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
Questioning why no S0C4, S0C7 is not happening, and how this is working at all. |
Why would it not work?
COBOL tables, unless the compiler option SSRANGE is used, can use whatever subscript they want -- and as long as the subscript remains in the range of the table there is no issue. What the code does is define a table that overlays the first two lines of ZIO-LGTH-FILE-TABLE. The other 90-odd lines of ZIO-LGTH-FILE-TABLE are still in memory and available so a subscript of 93, for example, is still within the memory locations of ZIO-LGTH-FILE-TABLE and hence will return the appropriate values. If the code used 5093 as a subscript, then you'd likely get a S0C7 or S0C4 error, but not for 94 or less.
The whole point of compiler option SSRANGE is to check indexes and subscripts against the size of the table at runtime. If the code is not compiled with SSRANGE, then there is no check on whether a particular subscript is within the table limits or not and hence the code displayed will work perfectly fine. |
|
Back to top |
|
|
GAPX1
New User
Joined: 12 May 2007 Posts: 9 Location: arizona
|
|
|
|
Many thanks! |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
Sometimes you get lucky and no abend occurs. I call this "working by coincidence" and it is NOT a good thing. |
|
Back to top |
|
|
|