Rules for occurs clause, COBOL Programming

RULES FOR OCCURS CLAUSE:

The rules apply for the OCCURS clause and the subscripts are as shown below.

(1) The integer in the OCCURS clause should be a positive integer.

(2) The OCCURS clause can be identified for an elementary item or for a group item. The clause causes adjoining fields to be set up internally. Each field is alike to the elementary or group item for which the OCCURS clause has been identified. The number of fields which are set up is equivalent to the integer in the OCCURS clause. The OCCURS clause cannot be identified for an item whose level numbers are 01, 66, 77 or 88.

(3) Whenever a data name is defined with occur clause which the data name as well as any of its subordinate items cannot be referred to in the PROCEDURE DIVISION without a subscript. It may be a positive integer constant, a numeric integral data or an arithmetic expression. For illustration, an element of the above INCOME-TAX-RATE table, can be referred to the PROCEDURE DIVISION as

      TAX-RATE (I)    or as (3*J)

In the initial situation, a data name I has been used as the subscript. If the current value of I is, 5, then the TAX-RATE (I) will refer to the fifth element of the table. In the second situation, an arithmetic expression has been used as the subscript. The value of the expression is used to specify the particular element of the table. Therefore, if the present value of J is 1, TAX-RATE (3*J) will refer to the third element of the table.

(4) The maximum value which a subscript can take is the one specified in the OCCURS clause. For any table, the minimum value of a subscript is implicitly supposed to be 1. By the range of a subscript we mean the range of values from 1 to the maximum possible value of the subscript. In the above illustration, the range of the subscript is 1-10. If during the execution of a program, the value of subscript is found to be outside its range, then an execution error occurs and the program is finished by the system.

(5) The subscripts must be enclosed in a set of parentheses. In common, blank space may not follow the left parenthesis while there should be a space preceding the left parenthesis and following the right one.

(6) When a data name with the OCCURS clause needs any qualification by its higher level, the subscripts to be written after the final qualified name. For illustration, if TAX-RATE must be qualified, it should appear as TAX-RATE OF INCOME-TAX-RATE (I) and not as the TAX-RATE (I) OF INCOME-TAX-RATE.

(7) Whenever an entry is defined with the OCCURS clause, the VALUE clause cannot be identified for that specific item or any item subordinate to it.

(8) The REDEFINES clause cannot appear in similar data description entry that contains an OCCURS clause. Though, the REDEFINES clause can appear for a group item whose subordinate items are defined with occur clause.

(9) The OCCURS clause can appear in the data description entry in any order. 

Posted Date: 10/18/2012 1:33:31 AM | Location : United States







Related Discussions:- Rules for occurs clause, Assignment Help, Ask Question on Rules for occurs clause, Get Answer, Expert's Help, Rules for occurs clause Discussions

Write discussion on Rules for occurs clause
Your posts are moderated
Related Questions
THE SIMPLE SORT VERB: The process of sequencing the records in some preferred manner is termed as sorting. The Sorting is done upon some key data item in the record. For illus

Format for COBOL Programs: The COBOL is a high-level language. Therefore, a COBOL program can be executed on a computer for which a COBOL compiler exists. The compiler transla

Illustration of Perform with varying option: A) Perform para-3 varying the k from 1 by 1 until k > 10. Here para-3 will be constantly executed 10 times (For k=1,2,3, .....1

Comparison of the Numeric Operand with Nonnumeric Operand: The numeric operand can be compared to the nonnumeric operand subject to the restrictions which are as follows.

BLANK WHEN ZERO: BLANK WHEN ZERO is an editing clause that may be used along with a picture. This will set the whole data item to blanks of its value is equal to zero. Though,

MULTIPLY VERB:   The Multiply Verb causes one or more multiplicands to be multiplied by the multiplier and to store the products. The form of the MULTIPLY verb is as shown be

LEVEL NUMBERS: The COBOL makes use of the level number concept to explain the hierarchical data structure. A level number is a 2 digit number. The permitted level numbers a

PERFORM WITH TIMES OPTION: The format of a PERFORM TIMES statement is as shown below: Illustration:   A)  Perform the para-2 5 times. In this situation the specifie

RULES FOR OCCURS CLAUSE: The rules apply for the OCCURS clause and the subscripts are as shown below. (1) The integer in the OCCURS clause should be a positive integer.

SEQUENTIAL FILES:   The purpose of the proposed section is to introduce the concepts such as File characteristics, File Description for Fixed-Length Records, File-Control