Loading

Easytrieve MACROs (Copybook)

Easytrieve MACROs are similar to COBOL Copybooks. i.e, they are used to reuse the layout of a file.

A Sample Macro:

 MYDATA.SET.MACROS(MYFILE)
 MACRO
 INFILE
 IN-REC  1 80 A
 IN-KEY  1   8 A

The first line of a Macro should be MACRO.

How to use this in an Easytrieve program?

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 LIST ON
 FILE INFILE FB(80 200)
 %MYFILE
*
 JOB INPUT NULL
 GET INFILE
...
 STOP.

The statement %INFILE includes the Macro MYFILE, into the program.
The dataset containing the Macros should be mentioned in the JCL as

//PANDD DD DSN=MYDATA.SET.MACROS,DISP=SHR

Macros with Parameters:
Macros can take some parameters.
See the example below.

 MYDATA.SET.MACRO(MYFILE)
 MACRO FNAME PREFIX
&FNAME.
&PREFIX.-REC  1 80 A
&PREFIX.-KEY  1   8 A

FNAME and PREFIX are the parameters. Use an &VARIABLE. to substitute a variable (An Ampersand in the beginning and a dot in the end).

How to use this in an Easytrieve program?

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 LIST ON
 FILE INFILE FB(80 200)
 %MYFILE IN IN
*
 JOB INPUT NULL
 GET INFILE
...
 STOP.

%MYFILE IN IN substitutes as FNAME=IN, PREFIX=IN

If you miss the PANDD in the JCL, or MACRO statement in the MACRO member, you will see an error as

*******B006 MACRO SYSTEM - PDS , ERROR IN MACRO FILE

Related Posts




blog comments powered by Disqus

There's 10 Comments So Far

Share your thoughts, leave a comment!