IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Copybook in Many times in a pgm


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
gigs

New User


Joined: 08 Aug 2005
Posts: 27
Location: USA

PostPosted: Mon Sep 05, 2005 11:41 am
Reply with quote

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
View user's profile Send private message
ikumar

New User


Joined: 02 Aug 2005
Posts: 81

PostPosted: Mon Sep 05, 2005 12:57 pm
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Sep 05, 2005 10:51 pm
Reply with quote

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
View user's profile Send private message
ikumar

New User


Joined: 02 Aug 2005
Posts: 81

PostPosted: Wed Sep 07, 2005 7:23 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts Build a record in output file and rep... DFSORT/ICETOOL 11
No new posts Trying to change copybook in online c... CICS 4
No new posts Help to Filter File Manager Copybook ... DFSORT/ICETOOL 14
No new posts Updating a 1 byte thats in occurs mul... DFSORT/ICETOOL 6
Search our Forums:

Back to Top