Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Same Copy Book for 2 different files? 1

Status
Not open for further replies.

wellster34

Programmer
Sep 4, 2001
113
CA
Hi,

Is there a way to have one copy book used for different files? i.e. A copy book called TESTING, contains
05 ED-JUST-TESTING.
10 ED-ID PIC X(3).

For the first file I will use it as is. But the second file I want to use the same layout but want to replace the ED with JW:
05 JW-JUST-TESTING.
10 JW-ID PIC X(3).

Is there a way without creating a brand new Copy Book??? Because right now, it fails on the compile stating non-unique identification of ED-ID. Do you have any ideas or
suggestions?

Thanks. [dazed]
 
The only way I could think of if you don't want to change the copybook member is to use qualification on each reference of a dataname. You could copy the copybook in one file replacing the 01 name with INPUT-REC for example. Then you could copy the same copybook in the other file replacing the 01 with OUTPUT-REC for example.

In your code you would use:

MOVE ED-ID OF INPUT-REC TO ...


IF you want to change the copybook you could use something called pseudo-text.

Example copybook:
01 :TAG:-RECORD.
03 :TAG:-FIELD-1 PIC X(03).
03 :TAG:-FIELD-2 PIC S9(02).


COPY copybook REPLACING ==:TAG:== BY ==ED==.

Results are:
01 ED-RECORD.
03 ED-FIELD-1 PIC X(03).
03 ED-FIELD-2 PIC S9(02).

 
Here is the trick used with most compilers. Your copybook would contain:
Code:
05  (PREFIX)-JUST-TESTING.
  10 (PREFIX)-ID                PIC X(3).
Then for the first instance you use:
Code:
    COPY CPYBOOK REPLACING ==(PREFIX)== BY ED.
I'll leave the second instance as an exercise for the reader. Tom Morrison
 
This can even be expanded with newer syntax where you can specify LEADING or TRAILING:

COPY "TESTING"
REPLACING LEADING ==ED== by ==JD==.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top