View previous topic :: View next topic
|
Author |
Message |
gigs
New User
Joined: 08 Aug 2005 Posts: 27 Location: USA
|
|
|
|
Hi All,
Can I place a Copybook(file Lay out ) in two different output file in same cobol pgm. If possible , How?
Regards,
Sumanta |
|
Back to top |
|
|
ikumar
New User
Joined: 02 Aug 2005 Posts: 81
|
|
|
|
You can use COPY with REPLACING to have the multiple copies of copybook with the same layout in a COBOL program...
For example, write in the FD section in place of file-record as,
COPY EMPLCPBK REPLACING ALL "XX" BY "EMPL".
COPY EMPLCPBK REPLACING ALL "XX" BY "HEAD".
where, EMPLCPBK is the output layout in COBOL program. you can have fields within EMPLCPBK as, XX-ID, XX-NAME, XX-PHONE etc.
And within the program you can use these fields as, EMPL-ID, EMPL-NAME, EMPL-PHONE and HEAD-ID, HEAD-NAME, HEAD_PHONE etc...
Thanks
Kumar. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Sorry Kumar,
You can't replace a prefix (e.g. abc-) the way you show it. That only allows you to replace "words" not "strings" (parts of "words"). A word would be something like PIC or ZEROS; a string, something like XYZ- or OS (the last part of ZEROS).
You must design the original copybook using "separarors", something like :TAG: as the variable you want to REPLACE in the copy stmt. For example a copybook written as:
Code: |
01 :TAG-:oh-one-level.
05 :TAG-:oh-5-level pic x(003) value all "A".
|
can be used in a pgm as follows:
Code: |
COPY tagcpybk replacing ==:TAG:== by ==FD-== |
this produces:
Code: |
01 FD-oh-one-level
05 FD-oh-5-level pic x(003) value all "A". |
and
Code: |
COPY tagcpybk replacing ==:TAG:== by ==WS-== |
produces:
Code: |
01 WS-oh-one-level.
05 WS-oh-5-level pic x(003) value all "A". |
|
|
Back to top |
|
|
ikumar
New User
Joined: 02 Aug 2005 Posts: 81
|
|
|
|
Sorry, I forgot to use the seperators, Thanks:)
To the original poster,
you can use seperators like :TAG: or (TAG)...etc...please correct. |
|
Back to top |
|
|
|