View previous topic :: View next topic
|
Author |
Message |
PSS Sankar
New User
Joined: 08 Oct 2008 Posts: 6 Location: Pune
|
|
|
|
Hi,
I Havebeen asked in interview regarding Tables in Cobol.
What happens if we use SSRANGE and NOSSRANGE,If any body nose explain in detail if possible with an example.
Thanks. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
The IBM COBOL compiler defaults to NOSSRANGE (no subscript range) to avoid performance problems. So even if you fed index greater than tables range your program will not abend.
If you want your program to abend on index greater than tables range you have to give compiler option SSRANGE. |
|
Back to top |
|
|
PSS Sankar
New User
Joined: 08 Oct 2008 Posts: 6 Location: Pune
|
|
|
|
So if we give NOSSRANGE as compiler option,and when program trying to access out of index value,The program wont get abend??. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Quote: |
So if we give NOSSRANGE as compiler option,and when program trying to access out of index value,The program wont get abend??.
|
No. You will fetch garbage. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Quote: |
No. You will fetch garbage.
|
Which may yet cause an abend. . .
d |
|
Back to top |
|
|
PSS Sankar
New User
Joined: 08 Oct 2008 Posts: 6 Location: Pune
|
|
|
|
Then suggest me... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
Back to top |
|
|
PSS Sankar
New User
Joined: 08 Oct 2008 Posts: 6 Location: Pune
|
|
|
|
Ohh...My dear friend,
I need One practical example... |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Quote: |
Quote:
No. You will fetch garbage.
Which may yet cause an abend. . .
|
But not while fetching value.
May be further usage of that value in the program cause abend due to other reasons. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
PSS Sankar wrote: |
Ohh...My dear friend,
I need One practical example... |
Why dont you try this out yourself to see what happens practically. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hello,
As suggested many times, IBM COBOL compiler defaults to NOSSRANGE (no subscript range) to avoid performance problems. There is additional object code, storage, and CPU overhead associated with using the SSRANGE feature. If you use CA-InterTest for initial monitoring in production, it's advisable not to combine them, the combined overhead of both CA-InterTest and SSRANGE will not be a good idea.
Since you may have specific concerns about your programs, you may want to go ahead and specify the SSRANGE option in your job to compile these programs for production. With the SSRANGE option set, at run time, when the program has an index that exceeds the range, the program will terminate with an ABEND USER=4038 and generate an error message.
IBM’s COBOL processing for table subscripts and indexes is documented in the following manual: COBOL MVS & VM V1R2M2 Programming Guide (SC26-4767-03), found at publibz.boulder.ibm.com:80/cgi-bin/bookmgr_OS390/BOOKS/IGYPG104/
Search on the keywords SSRANGE or NOSSRANGE. There should be a fair amount of text discussing the use of SSRANGE compiler option to enable checking for subscripts or indexes trying to reference an area outside the region of the table. The manual also discusses the performance impact of the additional code generated when enabling the SSRANGE option. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Code: |
01 VINTEMP.
02 VIN PIC X(40) VALUE 'ABCD 12 IUTOER 545 JLLDF 1 '.
02 VIN1 REDEFINES VIN PIC X OCCURS 40 TIMES.
'
'
MOVE 41 TO NUMVAL.
DISPLAY VIN1(NUMVAL).
|
if
PARM='NOSSRANGE' then MAXCC=0 CN(INTERNAL)
if
PARM='SSRANGE' then Abend with below message
IGZ0006S The reference to table VIN1 by verb number 01 on line 000070 addressed an area outside the region of the
table.
From compile unit ARITH at entry point ARITH at compile unit offset +00000B8E at entry offset +00000B8E at
address 15F01926.
Check this link also..
publib.boulder.ibm.com/infocenter/zos/v1r9/index.jsp?topic=/com.ibm.zos.r9.ceea100/ceea118083.htm |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hello again,
Just a little thought on the use of SSRANGE..If there is any programming which sets a subscript to be above the maximum value on purpose (eg. to exit a perform-varying) then the program will bomb. eg:
Code: |
perform varying sub from 1 by 1 until sub > max-allowed
if tab-element(sub) = 'whatever'
move tab-element(sub) to save-element
compute sub=max-allowed + 1
end-if
end-perform |
..and yes, I've seen programs like that..
PS. Sambhji, I didn't see your post, however I'll keep mine here as well, it's just other example. |
|
Back to top |
|
|
PSS Sankar
New User
Joined: 08 Oct 2008 Posts: 6 Location: Pune
|
|
|
|
ok..Thanks!!! alot |
|
Back to top |
|
|
|