Qualifying variables in COBOL
Qualifiers are combinations of load modules, compile units, blocks,
section names, or paragraph names punctuated by a combination of greater-than
signs (>), colons, and the COBOL data qualification notation, OF
or IN
,
that precede referenced statement numbers or variable names.
When qualifying objects on a block level, use only the COBOL form
of data qualification. If data names are unique, or defined as GLOBAL
,
they do not need to be qualified to the block level.
load_name::>cu_name:>block_name:>object;
If required, load_name is the name of the load module.
It is required only when the program consists of multiple load modules
and you want to change the qualification to other than the current
load module. load_name can also be the z/OS® Debugger variable %LOAD
.
If required, cu_name is the name of the compile unit.
The cu_name must be the fully qualified compile unit name.
It is required only when you want to change the qualification to
other than the currently qualified compile unit. It can be
the z/OS Debugger variable %CU
.
If required, block_name is the name of the block.
The block_name is required only when you want to change
the qualification to other than the currently qualified block. It
can be the z/OS Debugger variable %BLOCK
. If block_name is
case sensitive, enclose the block name in quotation marks (")
or apostrophes ('). If the name is not inside quotation marks
or apostrophes, z/OS Debugger converts the name to upper case.
MAIN
⋮
01 VAR1.
02 VAR2.
O3 VAR3 PIC XX.
01 VAR4 PIC 99..
****************MOVE commands entered here****************
SUBPROG
⋮
01 VAR1.
02 VAR2.
O3 VAR3 PIC XX.
01 VAR4 PIC 99.
01 VAR5 PIC 99.
****************LIST commands entered here****************
main
and subprog
blocks
using qualification. If you enter the following MOVE
commands
when main
is the currently executing block:
MOVE 8 TO var4;
MOVE 9 TO subprog:>var4;
MOVE 'A' TO var3 OF var2 OF var1;
MOVE 'B' TO subprog:>var3 OF var2 OF var1;
and the
following LIST
commands when subprog
is the
currently executing block:
LIST TITLED var4;
LIST TITLED main:>var4;
LIST TITLED var3 OF var2 OF var1;
LIST TITLED main:>var3 OF var2 OF var1;
each LIST command results
in the following output (without the commentary) in your Log window:
VAR4 = 9; /* var4 with no qualification refers to a variable */
/* in the currently executing block (subprog). */
/* Therefore, the LIST command displays the value of 9.*/
MAIN:>VAR4 = 8 ⁄* var4 is qualified to main. *⁄
/* Therefore, the LIST command displays 8, */
/* the value of the variable declared in main. */
VAR3 OF VAR2 OF VAR1 = 'B';
/* In this example, although the data qualification */
/* of var3 is OF var2 OF var1, the */
/* program qualification defaults to the currently */
/* executing block and the LIST command displays */
/* 'B', the value declared in subprog. */
VAR3 OF VAR2 OF VAR1 = 'A'
/* var3 is again qualified to var2 OF var1 */
/* but further qualified to main. */
/* Therefore, the LIST command displays */
/* 'A', the value declared in main. */
The above method of qualifying variables is necessary for commands files.