Easytrieve Macro Arguments

Macro arguments are the values callers pass when invoking %MACRONAME. They feed the preprocessor substitution engine that replaces ampersand references in the macro body with actual text before compile continues. Positional arguments rely on order—the first value maps to the first positional parameter declared on the MACRO prototype. Keyword arguments use NAME=value syntax and override defaults declared on the prototype. Mixed macros require positional-count so the preprocessor knows how many bare values to consume before reading keyword pairs. Beginners confuse arguments with PROC parameters; macro arguments exist only at compile time and never appear in the running load module as a parameter block. This page explains positional versus keyword design, default values, invocation ordering rules, substituting field names versus literals, special character considerations, and documenting parameter contracts for enterprise FILE macros shared across payroll, HR, and finance programs.

Progress0 of 0 lessons

Positional Arguments

Positional parameters are declared as names on the MACRO line after optional positional-count. Invocation supplies values in the same order without naming them. Use positional arguments for the most common, stable inputs callers always provide—record keys, numeric constants, target field names. Positional invocation is compact: %CUBE 5 CUBE-OUT instead of NUMBER=5 RESULT=CUBE-OUT.

text
1
2
3
4
5
6
7
MACRO 2 NUMBER RESULT DEFINE CUBE_WORK S 6 N VALUE 000000 CUBE_WORK = &NUMBER * &NUMBER * &NUMBER &RESULT = CUBE_WORK MEND %CUBE 5 CUBE-OUT

NUMBER receives 5; RESULT receives CUBE-OUT. Expanded source assigns into field CUBE-OUT because &RESULT substitutes the identifier text.

Keyword Arguments and Defaults

Keyword parameters declare as name default-value pairs on the prototype. When invocation includes DEPT=920, that value replaces &DEPT in the body. When invocation omits DEPT, the default from the prototype applies—critical for optional layout tweaks without breaking existing callers.

text
1
2
3
4
5
6
7
MACRO 0 RECLEN 150 BLKSIZE 1800 LRECL 150 FILE PAYROLL FB(&LRECL &BLKSIZE) PAY-ID 1 9 N MEND %PAYROLL-FILE %PAYROLL-FILE RECLEN=200 BLKSIZE=2400 LRECL=200
Keyword argument behavior
SituationWhat &KEYWORD becomes
Keyword omitted on invocationPrototype default value
KEYWORD=value suppliedSupplied value text
Empty value KEYWORD=Follow site Macro Facility rules for empty actuals

Mixed Positional and Keyword Invocation Order

Broadcom requires all positional actual parameters before any keyword pair. Violating order makes the preprocessor attach values to wrong parameters—often producing bizarre FIELD names in listings.

text
1
2
3
4
5
6
7
8
9
MACRO 1 FILENAME DDNAME PERSNL RECLEN 150 FILE &FILENAME FB(&RECLEN 1800) MEND * Valid %FILEMAC PAYROLL DDNAME=PAYROLL RECLEN=200 * Invalid — keyword before positional completes * %FILEMAC DDNAME=PAYROLL PAYROLL

Ampersand Substitution Mechanics

The preprocessor scans model statements for &PARAMETER tokens. Each token replaces with invocation text verbatim—no automatic quoting. If you pass O'BRIEN as a character value needing quotes in DEFINE, include quotes in the actual parameter or in the model around &NAME. Concatenation happens when literals abut tokens: PREFIX&SUFFIX with PREFIX=ACCT and SUFFIX=NUM yields ACCTNUM in expanded source.

Passing Field Names Versus Literals

Argument intent
You passTypical use in bodyExample
Numeric literal 5Arithmetic or VALUE clauseCUBE_WORK = &NUMBER * &NUMBER
Field name CUBE-OUTAssignment target or DEFINE name&RESULT = CUBE_WORK
File name PAYROLLFILE statement identifierFILE &FILENAME FB(...)
Quoted literalTITLE text or constantTITLE 01 '&TITLE-TEXT'

Designing Parameter Contracts

Put stable high-volume inputs positional

Every caller passing file name first benefits from short invocation. Document order in header comments on the macro member.

Put optional overrides keyword

Record length changes for special runs become RECLEN=200 without forcing all legacy programs to add a new positional slot.

Avoid too many positionals

Beyond three positional parameters, callers mis-order values. Shift rarely changed inputs to keywords with defaults.

Actual Parameter Length and Special Characters

Actual parameters are tokenized per Macro Facility rules. Commas, quotes, and continuation lines may require escape or continuation columns depending on release and installation. When expansion produces invalid syntax, enable full macro listing (avoid NOMACROS) to inspect generated lines. Log ambiguous cases to your site research file if documentation is unclear.

Arguments Versus PROC Parameters

Macro arguments vs PROC parameters
AspectMacro argumentPROC parameter
LifetimeCompile-time onlyRuntime working storage
MechanismText substitutionField references in logic
Invocation%MACRO valuesPERFORM with USING fields
Change without recompileNo—must recompileYes—values per call

Common Argument Mistakes

  • Keyword before positional on invocation line.
  • Wrong positional-count after adding keyword parameters to prototype.
  • Expecting runtime validation of argument values—only expanded syntax is validated at compile.
  • Omitting quotes so character literals break DEFINE after substitution.
  • Using ampersand on prototype line—ampersand belongs in body only.
  • Changing positional order without versioning macro name—silent wrong bindings in callers.

Explain It Like I'm Five

Positional arguments are filling blanks in order: first blank gets first sticker, second blank gets second sticker. Keyword arguments are stickers with labels: you put the red one on the spot marked color even if it is the third spot. Defaults are stickers already on the card until you replace them with a new one.

Exercises

  1. Design a FILE macro with one positional file name and keyword RECLEN default 80.
  2. Write valid and invalid invocation lines for a mixed macro.
  3. Explain why &RESULT can become a field name in assignment.
  4. Convert a three-positional macro to one positional plus two keywords without breaking callers.
  5. Document a parameter header comment block for a shared PERSNL macro.

Quiz

Test Your Knowledge

1. On invocation, positional values must appear:

  • Before any keyword=value pairs
  • After all keywords
  • Only in JCL
  • Inside MEND

2. Keyword parameter defaults apply when:

  • Invocation omits that keyword
  • JOB starts
  • Runtime PERFORM runs
  • MEND executes

3. Body references substitute parameters with:

  • Ampersand before parameter name
  • Percent sign
  • Dollar sign only
  • At sign

4. Positional-count on MACRO tells the preprocessor:

  • How many positional values to read on invocation
  • Macro body line count
  • FILE record length
  • Number of JOB activities

5. Passing a field name as positional argument lets the body:

  • Generate assignments or DEFINE names dynamically
  • Change JCL DDNAME at runtime
  • Skip compile
  • Invoke CICS
Published
Read time18 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve Report Generator 11.6 macro positional and keyword parametersSources: Broadcom Easytrieve 11.6 Define Macros, Macro Invocation, parameter substitutionApplies to: Easytrieve macro parameter passing