Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
COBOL Table Question

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: COBOL Table Question
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: 8479
Location: Dubuque, Iowa, USA

PostPosted: Thu Mar 07, 2019 10:05 pm    Post subject: Reply to: COBOL Table Question
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    Post subject: Reply to: COBOL Table Question
Reply with quote

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

Active Member


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

PostPosted: Wed Mar 13, 2019 11:35 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. COBOL/CICS with real time MQ Series u... BPranav CICS 2 Mon Sep 16, 2019 9:19 pm
No new posts Blksize question darioits JCL & VSAM 6 Tue Sep 10, 2019 8:32 pm
This topic is locked: you cannot edit posts or make replies. Compare two files logic in COBOL Nishant Singhal COBOL Programming 4 Sun Aug 25, 2019 2:25 am
No new posts Query to Truncate value in table bhaskar_kanteti DB2 2 Mon Aug 12, 2019 3:26 pm
This topic is locked: you cannot edit posts or make replies. Upgrade to Enterprise COBOL 6 JPVRoff COBOL Programming 4 Thu Aug 01, 2019 7:21 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us