&SYSECT System Variable Symbol
Use &SYSECT in a macro definition to generate the name of the current control section. The current control section is the control section in which the macro instruction that calls the definition appears. You cannot use &SYSECT in open code.
The local-scope system variable symbol &SYSECT is assigned a read-only value each time a macro definition is called.
The value assigned is the symbol that represents the name of the
current control section from which the macro definition is called.
Note that it is the control section in effect when the macro is called.
A control section that has been initiated or continued by substitution
does not affect the value of &SYSECT for the expansion of the
current macro. However, it might affect &SYSECT for a subsequent
macro call. Nested macros cause the assembler to assign a value to &SYSECT
that depends on the control section in force inside the outer macro
when the inner macro is called.
Notes:
- The control section whose name is assigned to &SYSECT can be defined by a program sectioning statement. This can be a START, CSECT, RSECT, DSECT, or COM statement.
- The value of the type attribute of &SYSECT (T'&SYSECT) is always U.
- The value of the count attribute (K'&SYSECT) is equal to the number of characters assigned as a value to &SYSECT.
- Throughout the use of a macro definition, the value of &SYSECT is considered a constant, independent of any program sectioning statements or inner macro instructions in that definition.
The next example shows these rules:
MACRO
INNER &INCSECT
&INCSECT CSECT Statement 1
DC A(&SYSECT) Statement 2
MEND
MACRO
OUTER1
CSOUT1 CSECT Statement 3
DS 100C
INNER INA Statement 4
INNER INB Statement 5
DC A(&SYSECT) Statement 6
MEND
MACRO
OUTER2
DC A(&SYSECT) Statement 7
MEND
-------------------------------------------------------------------
MAINPROG CSECT Statement 8
DS 200C
OUTER1 Statement 9
OUTER2 Statement 10
-------------------------------------------------------------------
Generated Program
-------------------------------------------------------------------
MAINPROG CSECT
DS 200C
CSOUT1 CSECT
DS 100C
INA CSECT
DC A(CSOUT1)
INB CSECT
DC A(INA)
DC A(MAINPROG)
DC A(INB)
In this example:
- Statement 8 is the last program sectioning statement processed
before statement 9 is processed. Therefore, &SYSECT is assigned
the value
MAINPROG
for macro instructionOUTER1
in statement 9.MAINPROG
is substituted for &SYSECT when it appears in statement 6. - Statement 3 is the program sectioning statement processed before
statement 4 is processed. Therefore, &SYSECT is assigned the
value
CSOUT1
for macro instructionINNER
in statement 4.CSOUT1
is substituted for &SYSECT when it appears in statement 2. - Statement 1 is used to generate a CSECT statement for statement
4. This is the last program sectioning statement that appears before
statement 5. Therefore, &SYSECT is assigned the value
INA
for macro instructionINNER
in statement 5.INA
is substituted for &SYSECT when it appears in statement 2. - Statement 1 is used to generate a CSECT statement for statement
5. This is the last program sectioning statement that appears before
statement 10. Therefore, &SYSECT is assigned the value
INB
for macro instructionOUTER2
in statement 10.INB
is substituted for &SYSECT when it appears in statement 7.