Same copybook for two files (input/output)

230 views Asked by At

I'm in a situation where it would be helpful to use the same copybook for two different files in an EZT program. I know in COBOL you can use OF to specify which file you would like to get and/or set fields for (i.e. VAR1 OF INFILE). Does Easytrieve have this capability, or do I need to manually define fields with unique names within the program?

Tried using syntax I thought existed where I could add a character to the end to seperate, but tit looks like I'm using that incorrectly.

FILE INFILE
%COPYBOOK 1 I.
FILE OUTFILE
%COPYBOOK 1 O.
2

There are 2 answers

0
AudioBubble On

A colon to refer to filename:fieldname should work.

0
Martin Pala On

There are two ways:

  1. either the use filename qualification as suggested by @user2675083 (see files and fields for more details)

  2. or you can use macro parameter substitution to add e.g. prefix to a field name and make it unique, example:

MSTART MYMAC
MACRO PARM1                
  DEFINE &PARM1.FLD W 10 A   VALUE 'HELLO'
MEND                       
*                          
JOB INPUT NULL
  %MYMAC 'TST'          
  DISPLAY TSTFLD
  STOP

The 'TST' is is passed to the MYMAC macro as positional argument (PARM1), which is used to make the field name unique (the &PARM1.FLD becomes TSTFLD after substitution).

See process macros for more details