SSRANGE

SSRANGE: Arrays in COBOL are known as tables. An array is a linear data structure and is a collection of individual data items of the same type. Data items of a table are internally sorted. Let’s say we have an array of 100 occurrences and program tried to access 101 occurrences of the array then program will give a subscript out of range error unless compiler option SSRANGE is specified.

If you specify the SSRANGE compiler option, the VS COBOL II compiler generates additional code that makes certain a table subscript or index does not address an area outside the boundaries of the associated table. This compiler option also generates code to ensure that OCCURS DEPENDING ON values, which are set dynamically by VS COBOL II source code statements, do not go beyond the maximum boundaries initially defined for the associated variable-length table.

To invoke this option, you need to code the parameter COPT=SSRANGE on the compile step of your job. If you have compiled your program with the SSRANGE compiler option, subscript range checking will occur during program execution for all tables as they are referenced. If an “out of bounds” condition occurs, a diagnostic message is generated, and the program is abnormally terminated. Subscript range checking occurs when a program is being executed because most table elements are referenced using computed subscripts or indexes rather than numeric literals. The default VS COBOL II compiler option is NOSSRANGE.

If your program is compiled with the SSRANGE option, you have the option to cancel the checking performed at execution time. This is accomplished by specifying the NOSSRANGE execution time option as follows:

//RUN EXEC PGM=MYPROG,PARM='/NOSSRANGE'

You can tell NOSSRANGE is a run-time option rather than a compiler option because of the slash. It is recommended that you use the SSRANGE compiler option when you are testing programs. However, because script range checking involves the execution of additional code, your program executes a little slower than it might. Therefore, when programs are ready to be handed over for production running, they should have the default compiler option of NOSSRANGE.

COBOL Blog: Click Here IBM Reference:Click Here

Scroll to Top