REDEFINES: Sometimes, it may be found that two or more storage areas defined in the DATA DIVISION are not in use simultaneously. In such cases, only one storage area can serve the purpose of two or more areas if the area is redefined.
The REDEFINES clause allows the same memory area to be described by different data items. In program if we are sure that 2 or more date names are not in use at the same time then we go for redefines clause.
Advantage: Conservation of Storage space
Format:
>>-level-number--+--------+--REDEFINES--data-name-2-------><
+-data-name-1-+
'-FILLER------'
(Level-number, data-name-1, and FILLER are not part of the REDEFINES clause, and are included in the format only for clarity.)
When specified, the REDEFINES clause must be the first entry following data-name-1 or FILLER. If data-name-1 or FILLER is not specified, the REDEFINES clause must be the first entry following the level-number
Rules:
01 WS-NAME. 05 WS_FST-NAME PIC X(05) VALUE “John”. 05 WS_FST-NAME PIC X(05) VALUE “Mike”. 01 WS-TOTAL-NAME REDEFINES WS-NAME PIC X(10). In above example WS-TOTAL-NAME will use same memory area allocated to WS-NAME. So WS-TOTAL-NAME will have “John Mike”
01 PAY-REC. 05 FIXED-PAY. 10 BASIC-PAY PIC 9(6)V99. 01 WS-NAME. 05 WS_FST-NAME PIC X(05) VALUE “John”. 05 WS_FST-NAME PIC X(05) VALUE “Mike”. 01 WS-TOTAL-NAME REDEFINES WS-NAME PIC X(10).
In above example WS-TOTAL-NAME will use same memory area allocated to WS-NAME.So WS-TOTAL-NAME will have “John Mike”
IDENTIFICATION DIVISION. PROGRAM-ID. REDEFINES. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-DESCRIPTION. 05 WS-DATE-DOJ VALUE '19990815'. 10 WS-YEAR PIC X(4). 10 WS-MONTH PIC X(2). 10 WS-DATE PIC X(2). 05 WS-DATE-TERM REDEFINES WS-DATE-DOJ PIC 9(8). PROCEDURE DIVISION. DISPLAY “DEFAULT DATE IS : " WS-DATE-DOJ. COMPUTE WS-DATE-TERM = FUNCTION DATE-OF-INTEGER (365 + FUNCTION INTEGER-OF-DATE (19990815)) DISPLAY “NEW DEFAULT DATE IS : " WS-DATE-DOJ. DISPLAY "TERM DATE IS : " WS-DATE-TERM. STOP RUN. RESULTS: DEFAULT DATE IS : 19990815 NEW DEFAULT DATE IS : 20000814 TERM DATE IS : 20000814
RENAMES: Sometimes a re-grouping of elementary data items in a record may be necessary so that they can belong to the original as well as to the new group.
RENAMES: Sometimes a re-grouping of elementary data items in a record may be necessary so that they can belong to the original as well as to the new group.
Format:
>>-66–data-name-1–RENAMES–data-name-2————————> >–+————————–+——————————–>< ‘-+-THROUGH-+–data-name-3-‘ ‘-THRU—-‘
Rules:
01 PAY-REC. 05 FIXED-PAY. 10 BASIC-PAY PIC 9(6)V99. 10 DEARNESS-ALLOWANCE PIC 9(6)V99. 05 ADDITIONAL-PAY. 10 HOUSE-RENT PIC 9(4)V99. 10 MNTHLY-INCENTIVE PIC 9(3)V99. 05 DEDUCTIONS. 10 PF-DEDUCT PIC 9(3)V99. 10 IT-DEDUCT PIC 9(4)V99. 10 OTHER-DEDUCT PIC 9(3)V99. 66 PAY-OTHER-THAN-BASIC RENAMES DEARNESS-ALLOWANCE THRU MNTHLY-INCENTIVE 66 IT-AND-PF-DEDUCTIONS RENAMES PF-DEDUCT THRU IT-DEDUCT.
In the above example, PAY-OTHER-THAN-BASIC will become a new group consisting of DEARNESS-ALLOWANCE, HOUSE-RENT, and MNTHLY-INCENTIVE. Note that the new group overlaps on two original groups, namely, part of FIXED-PAY and the entire ADDITIONALPAY. Such overlapping is allowed provided the elementary items are all contiguous. In a similar way, IT-AND-PF-DEDUCTIONS has two elementary items PF-DEDUCT and ITDEDUCT. This new group is formed out of the original group DEDUCTIONS. Alternatively, the same thing can also be done in the original group description by placing like this
05 DEDUCTIONS. 10 IT-AND-PF-DEDUCTIONS. 15 PF-DEDUCT PIC 9(3)V99. 15 IT-DEDUCT PIC 9(4)
IDENTIFICATION DIVISION. PROGRAM-ID. RENAMES. DATA DIVISION. WORKING-STORAGE SECTION. 01 PAY-REC. 05 FIXED-PAY. 10 BASIC-PAY PIC 9(6)V99. 10 DEARNESS-ALLOWANCE PIC 9(6)V99. 05 ADDITIONAL-PAY. 10 HOUSE-RENT PIC 9(4)V99. 10 MNTHLY-INCENTIVE PIC 9(3)V99. 05 DEDUCTIONS. 10 PF-DEDUCT PIC 9(3)V99. 10 IT-DEDUCT PIC 9(4)V99. 10 OTHER-DEDUCT PIC 9(3)V99. 66 PAY-OTHER-THAN-BASIC RENAMES DEARNESS-ALLOWANCE THRU MNTHLY-INCENTIVE. 66 IT-AND-PF-DEDUCTIONS RENAMES PF-DEDUCT THRU IT-DEDUCT. PROCEDURE DIVISION. MOVE 200 TO BASIC-PAY MOVE 100 TO DEARNESS-ALLOWANCE MOVE 20 TO HOUSE-RENT MOVE 8 TO MNTHLY-INCENTIVE MOVE 5 TO PF-DEDUCT MOVE 4 TO IT-DEDUCT MOVE 3 TO OTHER-DEDUCT DISPLAY "PAY-OTHER-THAN-BASIC : " PAY-OTHER-THAN-BASIC. DISPLAY "IT-AND-PF-DEDUCTIONS : " IT-AND-PF-DEDUCTIONS. STOP RUN. RESULT: PAY-OTHER-THAN-BASIC : 0001000000200000800 IT-AND-PF-DEDUCTIONS : 00500000400
RENAMES clause is used for regrouping elementary data items and gives one name to it. REDEFINES clause allows you to use different data descriptions entries to describe the same memory area.
COBOL Blog: Click Here IBM Reference: Click Here
A well-maintained product backlog is crucial for successful product development. It serves as a single…
Incremental value to the customer refers to the gradual delivery of small, functional parts of…
A Product Market refers to the group of potential customers who might be interested in…
The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…
The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…
Choosing the right Scrum Master Certification depends on your current experience and career goals. If…