Renames clause is used to give different names to existing data items. It is used to re-group the data names and give a new name to them. The new data names can rename across groups or elementary items. Level number 66 is reserved for renames.
Following is the syntax for Renames clause.
01 WS-OLD. 10 WS-A PIC 9(12). 10 WS-B PIC X(20). 10 WS-C PIC A(25). 10 WS-D PIC X(12). 66 WS-NEW RENAMES WS-A THRU WS-C. |
Explanantion:
Renaming is possible at same level only. In the above example, WS-A, WS-B, and WS-C are at the same level.
Renames definition must be the next data description you want to rename.
Do not use Renames with the level numbers 01 or, 77.
The data names used for renames must come in sequence.
IDENTIFICATION DIVISION. PROGRAM-ID. CBLRNAME. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-DESCRIPTION. 05 WS-NUM. 10 WS-NUM1 PIC 9(2) VALUE 11. 10 WS-NUM2 PIC 9(2) VALUE 22. 05 WS-CHAR. 10 WS-CHAR1 PIC X(2) VALUE 'XX'. 10 WS-CHAR2 PIC X(2) VALUE 'YY'. 66 WS-RENAME RENAMES WS-NUM2 THRU WS-CHAR2. PROCEDURE DIVISION. DISPLAY "WS-RENAME : " WS-RENAME. GOBACK. |
When you compile and execute the above program, it produces the following result.
WS-RENAME : 22XXYY |
RENAMES clause is used for regrouping elementary data items and gives one name to it. REDEFINES clause allow you to use different data descriptions entries to describe same memory area.
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!