MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

zero value in a subscript

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
pcmoonbeam
Beginner


Joined: 21 Nov 2005
Posts: 31
Topics: 10
Location: Orange County, California

PostPosted: Mon Nov 21, 2005 5:49 pm    Post subject: zero value in a subscript Reply with quote

I have a production COBOL II program in which a subscript reaches a value of zero yet does not cause the program to abend. I have put displays in the code to verify this, because I couldn't believe that the program could continue to execute with a subscript pointing to a zero occurrance. This zero subscript is computed as shown here:
Code:
COMPUTE ELIG-SB = TABLE-SUB - 8.


It is then used to search a table:

Code:
IF E-MEM-TYPE (ELIG-SB) = ' ' OR '0'               
     MOVE E-LAST-MEM-TYPE TO E-MEM-TYPE (ELIG-SB)   
      DISPLAY '22021 E-MEM-TYPE IS CHANGED TO '     
      E-MEM-TYPE(ELIG-SB).




Here is the display:
    CHG-SUB 05
    IN 22021-SKIP-HOURS
    TABLE-SUB 07
    ELIG-SB BEFORE CALC 02
    ELIG-SB AFTER CALC 01
    22021 E-MEM-TYPE IS
    22021 E-MEM-TYPE IS CHANGED TO B
    IN 22020-GET-NEEDED-HOURS.
    TABLE-SUB 08
    CHG-SUB 05
    IN 22021-SKIP-HOURS
    TABLE-SUB 08
    ELIG-SB BEFORE CALC 01
    ELIG-SB AFTER CALC 00
    22021 E-MEM-TYPE IS
    IN 22020-GET-NEEDED-HOURS.
    TABLE-SUB 09
    CHG-SUB 05
    IN 22021-SKIP-HOURS
    TABLE-SUB 09
    ELIG-SB BEFORE CALC 00
    ELIG-SB AFTER CALC 01
    22021 E-MEM-TYPE IS B


How can this be? Sad
_________________
Thanks,
PCMOONBEAM
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Mon Nov 21, 2005 7:06 pm    Post subject: Reply with quote

pcmoonbeam,

Add the following line as the first line in your program(before ID Division) and then try again.

Code:

CBL SSRANGE


Check this link for a detailed explanation of compiler parameter SSRANGE

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG10/2.4.48?DT=20020923143836

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pcmoonbeam
Beginner


Joined: 21 Nov 2005
Posts: 31
Topics: 10
Location: Orange County, California

PostPosted: Tue Nov 22, 2005 11:22 am    Post subject: Reply with quote

Thanks Kolusu,
I checked the compile options that we use and wouldn't you know it, NOSSRAGNE is in effect.
_________________
Thanks,
PCMOONBEAM
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Tue Nov 22, 2005 11:39 am    Post subject: Reply with quote

pcmoonbeam,

Now are you clear as to why your program did not abend?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pcmoonbeam
Beginner


Joined: 21 Nov 2005
Posts: 31
Topics: 10
Location: Orange County, California

PostPosted: Tue Nov 22, 2005 12:00 pm    Post subject: Reply with quote

Yes, crystal clear, thanks!
We are about to embark on a decision in our shop as to whether or not we should change this option to be in effect. If we do, it will have a huge impact when we recompile existing programs. Crying or Very sad
_________________
Thanks,
PCMOONBEAM
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Tue Nov 22, 2005 12:02 pm    Post subject: Reply with quote

Just as an aside, there are times when not checking subscript ranges can be useful: reading prefixes of control blocks for example.

Array index use is just a storage address calculation: address of structure + (index -1)*length of element

Using that, you can define a simple array of pointers containing OCCURS n TIMES based at address 0 where n is any positive number and access any location in storage by simply manipulating the index. Not good programming practice because it is hard to maintain, but in a quick-and-dirty programming situation, it can be very useful.

Also, note that the logic of the program should avoid out of range conditions. If you need SSRANGE to catch the error, you are adding runtime overhead to everything inorder to catch a design flaw in the program. (Yes, that is a philosophical point, but that is my opinion on it)
Back to top
View user's profile Send private message Visit poster's website
pcmoonbeam
Beginner


Joined: 21 Nov 2005
Posts: 31
Topics: 10
Location: Orange County, California

PostPosted: Tue Nov 22, 2005 6:00 pm    Post subject: Reply with quote

Thank you for your interest. However, my biggest problem is that I'm taking on a position from an individual who didn't test thoroughly, so now I'm having to do damage repair. Having SSRANGE in place on compiles (at least for testing purposes) points directly to the problems that were created.
_________________
Thanks,
PCMOONBEAM
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Tue Nov 22, 2005 6:21 pm    Post subject: Reply with quote

Hmmm I thought all programming was an excersise in damage repair. I know it is when I write code Smile
Back to top
View user's profile Send private message Visit poster's website
edkir98
Beginner


Joined: 27 Aug 2007
Posts: 102
Topics: 42
Location: Chennai

PostPosted: Tue Mar 11, 2008 1:00 am    Post subject: Reply with quote

I was browsing the forum on SSRANGE and got hold of this topic.

In our system, we dont specify the compiler options. The cobol compiler does not work. We do it thru endevor. If we would want to compile a code then we would add it to ENDEVOR(Version Control Tool). There they have the default compiler options listed and it compiles like that.

I'm able to see from the compiler listing that SSRANGE parameter is set while compiling.

I had used an two dimensional array (Internal Table) and in a particular paragraph, the array index was set as (1,0). This caused memory overlap and hence a wrong value had moved to another variable and hence it caused a S0C7 abend.

Why is that, although SSRANGE parameter was set why dint the program abend when it referenced a invalid starting position? Why dint it do the "range-checking"?

Am I clear with my question? Please advise if there are any additional options that would override this paramer?
Back to top
View user's profile Send private message Yahoo Messenger
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Tue Mar 11, 2008 6:45 am    Post subject: Reply with quote

Hi, semigeezer.

Quote:

Just as an aside, there are times when not checking subscript ranges can be useful: reading prefixes of control blocks for example.

Array index use is just a storage address calculation: address of structure + (index -1)*length of element

Using that, you can define a simple array of pointers containing OCCURS n TIMES based at address 0 where n is any positive number and access any location in storage by simply manipulating the index. Not good programming practice because it is hard to maintain, but in a quick-and-dirty programming situation, it can be very useful.

Also, note that the logic of the program should avoid out of range conditions. If you need SSRANGE to catch the error, you are adding runtime overhead to everything inorder to catch a design flaw in the program. (Yes, that is a philosophical point, but that is my opinion on it)



What do you suggest to avoid tha above?

Please explain it in detail.

TIA.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Tue Mar 11, 2008 7:27 am    Post subject: Reply with quote

SSRANGE also produces extra code in the program, which is why we con't use it for production compiles.
Back to top
View user's profile Send private message
edkir98
Beginner


Joined: 27 Aug 2007
Posts: 102
Topics: 42
Location: Chennai

PostPosted: Tue Mar 11, 2008 7:50 am    Post subject: Reply with quote

Craig.. You are correct!! I see NOSSRANGE is defined in the PROD environment. But why is that?
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Tue Mar 11, 2008 8:18 am    Post subject: Reply with quote

A limited sample to be sure, but the shops I've visited in my career enable SSRANGE for the test environments and then NOSSRANGE for production. The thought being that adequate testing will reveal out of range conditions prior to rolling out the code to production.

edkir
Please be careful when you make a statement like
Quote:
The cobol compiler does not work. We do it thru endevor.

Endevor is not a compiler. It is a source manager that submits compiles. If SSRANGE is not detecting something that you think should be an out of range index, it's because the effective address is within the table.

To explain the behavior you mentioned, note the comments about the effective address.
Code:
Use SSRANGE to generate code that checks if subscripts (including ALL subscripts) or
indexes try to reference an area outside the region of the table. Each subscript or
index is not individually checked for validity; rather, the effective address is
checked to ensure that it does not cause a reference outside the region of the table.
Variable-length items will also be checked to ensure that the reference is within
their maximum defined length.


One last comment. The SSRANGE code can be enabled/disabled at run time.
Code:
If SSRANGE is in effect at compile time, the range-checking code is generated. You
can inhibit range checking by specifying CHECK(OFF) as a run-time option. This
leaves range-checking code dormant in the object code. The range-checking code
can then be optionally used to aid in resolving any unexpected errors without
recompilation.
Back to top
View user's profile Send private message
acevedo
Beginner


Joined: 03 Dec 2002
Posts: 127
Topics: 0
Location: Europe

PostPosted: Tue Mar 11, 2008 8:45 am    Post subject: Reply with quote

CraigG wrote:
SSRANGE also produces extra code in the program, which is why we con't use it for production compiles.


same here.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group