IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

COBOL Table Question


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
GAPX1

New User


Joined: 12 May 2007
Posts: 9
Location: arizona

PostPosted: Thu Mar 07, 2019 9:48 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8569
Location: Dubuque, Iowa, USA

PostPosted: Thu Mar 07, 2019 10:05 pm
Reply with quote

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
View user's profile Send private message
GAPX1

New User


Joined: 12 May 2007
Posts: 9
Location: arizona

PostPosted: Thu Mar 07, 2019 10:09 pm
Reply with quote

Many thanks!
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 696
Location: Whitby, ON, Canada

PostPosted: Wed Mar 13, 2019 11:35 pm
Reply with quote

Sometimes you get lucky and no abend occurs. I call this "working by coincidence" and it is NOT a good thing.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. Passing a field name to COBOL program COBOL Programming 10
No new posts COBOL Performance Tuning COBOL Programming 6
No new posts JCL for replacing code in Cobol JCL & VSAM 7
No new posts COBOL VS SORT Utility for file format... COBOL Programming 6
No new posts XML Parsing in COBOL creating "h... COBOL Programming 0
Search our Forums:

Back to Top