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

  •   kiranmayi
    March 27th, 2012 at 11:18 am

    Could you please tell the difference between list on and list off??

  •   Karthik
    March 28th, 2012 at 3:45 am

    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.

  •   Lakshmy
    May 29th, 2013 at 6:47 am

    Hi Karthik,

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

  •   Karthik
    May 29th, 2013 at 6:56 am

    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.

  •   Lakshmy
    May 31st, 2013 at 11:16 am

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

  •   Karthik
    May 31st, 2013 at 11:27 am

    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

  •   Karthik
    May 31st, 2013 at 11:31 am

    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.

  •   Lakshmy
    June 3rd, 2013 at 4:45 am

    Thanks that was helpful.I really appreciate your help.

  •   Jerry
    January 1st, 2014 at 12:57 am

    Can you pass parms/overrides to an instream macro?

Who Linked To This Post?

  1. Easytrieve – File Handling and File Declaration

Share your thoughts, leave a comment!