In today's tutorial I'll discuss about the term called RENAME in COBOL, it is used for re-grouping the data items.
I will cover RENAME syntax with example and rule which you should keep in mind while using COBOL RENAME CLAUSE. So, let's start with the tutorial.
COBOL RENAMES clause (66-level). |
What is RENAMES in COBOL?
The COBOL RENAMES clause specifies alternative, possibly overlapping and groupings of elementary data items. In layman term it is used for Regrouping the data items. The RENAMES in COBOL is defined at special level-number i.e. 66-level. It's possible to write one or more COBOL RENAMES entries can be written for a logical record.
RENAMES in COBOL syntax.
66 data-name-1 RENAMES data-name-2 THROUGH or THRU data-name-3.
RENAME in COBOL example:
01 EMP-SAL-REC.
05 EMP-FIX-PAY.
10 EMP-BASIC-PAY PIC 9(06)V(02).
10 EMP-OTH-ALLOWNCE PIC 9(06)V(02).
05 EMP-ADDITNL-PAY.
10 EMP-HOUSE-RENT PIC 9(04)V(02).
10 EMP-MNTHLY-INCITV PIC 9(03)V(02).
05 EMP-DEDUCTIONS.
10 EMP-PF-DED PIC 9(03)V(02).
10 EMP-IT-DED PIC 9(04)V(02).
10 EMP-OTR-DED PIC 9(03)V(02).
66 EMP-SAL-OTHR-COMP RENAMES
EMP-OTH-ALLOWNCE THRU EMP-MNTHLY-INCENTIVE
66 EMP-TAX-DEDUCTIONS RENAMES
EMP-PF-DEDUCT THRU EMP-IT-DEDUCT.
RENAME in COBOL example explanation - In the above example, EMP-SAL-OTHR-COMP will become a new group consisting of EMP-OTH-ALLOWNCE, EMP-HOUSE-RENT and EMP-MNTHLY-INCITV. Now the new group EMP-SAL-OTHR-COMP would overlap with existing group.
In similar term, EMP-TAX-DEDUCTIONS would be new group that is overlapping existing
COBOL 66 RENAME Clause example:
01 RECORD-1.05 FIELD-1 PIC X(05).
05 FIELD-2 PIC X(05).
05 FIELD-3 PIC X(05).
05 FIELD-4 PIC X(05).
66 RECORD-2 RENAMES FIELD-1 THROUGH FIELD-3.
COBOL RENAMES THRU clause example:
01 RECORD-3.05 FIELD-1.
10 FIELD-11 PIC X(05).
10 FIELD-12 PIC X(05).
05 FIELD-2 PIC X(05).
66 RECORD-4 RENAMES FIELD-12 THROUGH FIELD-2.
In above RENAMES in COBOL example, RECORD-2 and RECORD-4 would be re-group the existing data items.
COBOL RENAMES Clause Rules.
- ALL COBOL RENAMES clause should declared immediately after the last record description.
- RENAMES in COBOL should be defined at level 66 only. Otherwise you will get compiler error.
- Data-name-2 and data-name-3 can be the names of elementary items or group items. They however can’t be items of levels 01,66,77 or 88
- Neither data-name-2 nor data-name-3 can have an OCCURS clause in its description entry, nor can they be subordinate to an item that has an occurs clause in its data description entry Data-name-3, if mentioned, must follow data-name-2, in the record and must not be one of its sub fields.
What is COBOL REDEFINE Clause ?
RENAMES Clause Share |
This comment has been removed by a blog administrator.
ReplyDelete