COBOL REDEFINES | COBOL Redefines Clause | COBOL Redefines statement | Redefines examples.

Опубликовано: 07 Октябрь 2024
на канале: Topictrick
4,417
120

#COBOL #topictrick #tutorial

COBOL REDEFINES Tutorial. The REDEFINES clause allows you to use different data description entries to describe the same computer storage area. COBOL Redefines Clause or Redefines clause in COBOL be used to redefine fields in COBOL copybook or directly in COBOL programs. You can use COBOL Redefines clause to redefine alphanumeric to numeric. You can also use COBOL Redefine clause to redefine occur clause in COBOL table or array.

COBOL REDEFINES and RENAME are different in terms of use, so don't get confused with them. COBOL REDEFINES define and redefine same memory location but COBOL RENAMES is used to regroup data items into a new group.

► Index Details ◄
0:00 Welcome to COBOL REDEFINES Statement.
0:48 REDEFINES statement in COBOL.
2:47 COBOL REDEFINES Clause syntax.
4:18 COBOL REDEFINES Clause Example.
7:39 Mainframe Tutorial Ends.

COBOL Redefines Syntax:
Level number {data-name-1, FILLER} REDEFINES data-name-2.

COBOL REDEFINES Rules:
1. Level number, data-name-1 and FILLER are not part of the REDEFINES clause itself and are included in the format only for clarity.
2. Level-numbers of data-name-1 and data-name-2 must be identical and must not be level 66 or level 88.
3. Data-name-1, FILLER identifies an alternate description for the same area and is the redefining item or the REDEFINES subject.
4. Data description entry for the redefined item cannot contain an OCCURS clause.
5. More than one redefinition of the same storage area is permitted. The entries giving the new
descriptions of the storage area must immediately follow the description of the redefined area without intervening entries that define new character positions.
6. Multiple redefinition must all use the data-name of the original entry that defined this storage area.
7. Redefining entry (identified by data-name-1) and any subordinate entries, must not contain any VALUE clauses.

Now, let look at couple of cobol redefines example on cobol redefines, redefine clause in cobol, redefines in cobol example.

Example 1: REDEFINES in cobol alphanumeric to numeric
.
01 WS-REDEFINES-EX.
05 WS-TODAYS-DATE PIC X(08) VALUE “20200717”.
05 WS-CURR-DTE REDEFINES WS-TODAYS-DATE.
10 CC PIC 9(02).
10 YY PIC 9(02).
10 MM PIC 9(02).
10 DD PIC 9(02).

Example 2: REDEFINES multiple time.
01 EMP-REC.
05 EMP-REC-LY PIC X(30).
05 EMP-NAME-DTL REDEFINES EMP-REC-LY.
10 EMP-FNAME PIC X(15).
10 EMP-LNAME PIC X(15).
05 EMP-DPT-NME REDEFINES EMP-REC-LY.
10 EMP-DPT PIC X(10).
10 EMP-ADD PIC X(15).

Example 3: REDEFINE in COBOL TABLE/ARRAY.

01 MONTH-TBL.
05 MNTH-NME.
10 FILLER PIC X(03) VALUE 'JAN'.
10 FILLER PIC X(03) VALUE 'FEB'.
10 FILLER PIC X(03) VALUE 'MAR'.
05 FILLER REDEFINES MNTH-NME.
10 MONTH-NME OCCURS 3 TIMES.
15 MNTH PIC X(03).

►Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. ◄

Also, Please visit below mention the link to stay connected with Topictrick on -

► Official Website : https://www.topictrick.com
► Youtube : topictrick
► Follow us on Twitter :   / topictrick  
► Facebook :   / topictrick  
► Linkedin :   / topictrick  
► Reddit :   / topictrick  
► Mainframe Blog : https://mainframe-forum.blogspot.com
► Medium Blog :   / topictrick  

Thank you for your support.
Topictrick™