COMMON statement
Syntax
COM[MON] [/name/] variable [ ,variable ...]
Description
Use the COMMON statement to provide a storage area for variables. Variables in the common area are accessible to main programs and external subroutines. Corresponding variables can have different names in the main program and in external subroutines, but they must be defined in the same order. The COMMON statement must precede any reference to the variables it names.
A common area can be either named or unnamed. An unnamed common area is lost when the program completes its execution and control returns to the InfoSphere® DataStage® command level. A named common area remains available for as long as the user remains in the InfoSphere DataStage environment.
The common area name can be of any length, but only the first 31 characters are significant.
Arrays can be dimensioned and named with a COMMON statement. They can be redimensioned later with a DIMENSION statement, but the COMMON statement must appear before the DIMENSION statement. When an array is dimensioned in a subroutine, it takes on the dimensions of the array in the main program regardless of the dimensions stated in the COMMON statement. For a description of dimensioning array variables in a subroutine, see the CALL statement.
When programs share a common area, use the $INCLUDE statement to define the common area in each program.
Example
Program:
COMMON NAME, ADDRESS (15, 6), PHONE
Subroutine:
COMMON A, B (15, 6), C
In this example the variable pairs NAME and A, ADDRESS and B, PHONE and C are stored in the same memory location.