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

10 thoughts on “Easytrieve MACROs (Copybook)”

  1. Hi Kiran,
    LIST ON specifies that all subsequent program statements are to be printed in SYSPRINT (this is the default option).
    LIST OFF suppresses the printing of statements.

  2. Hi Karthik,

    Is there any way to inlclude the whole easytrieve program in a ps file and calling it in JCL…

  3. yes, your easytrieve program can be dynamically written into a PS file, and can be executed by a JCL step. I have done that many times.

  4. Can you pls gimme the code for that…I mean can you pleaseshow the same using an example

  5. in your first step, create your Easytrieve code into a PDS (you can use SORT, Cobol, or another Easytrieve program to create this)
    In the second step, where you want to run the generated Easytrieve, pass the DD name that has the Easytrieve code in SYSIN DD.

    JCL step should look like,
    //STEP01 EXEC WHATEVER
    //OUTFILE DSN=MY.EASYTRIV.CODE
    // DISP=(NEW,CATLG,DELETE),
    // SPACE=(CYL,(100,50),RLSE),
    // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
    //*
    //STEP02 EXEC PGM=EZTPA00
    //SYSOUT DD SYSOUT=*
    //SYSPRINT DD SYSOUT=*
    //SYSIN DD DISP=SHR,DSN=MY.EASYTRIV.CODE

  6. Lakshmy,

    Did you ask about creating Easytrieve code dynamically, or only how to have the code in a separate PDS member and use it JCL step?

    Anything that we provide inline in the JCL using DD *, can be present in a PDS, and you can pass its DSN in the DD statement.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.