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

What is Copybook in COBOL?


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

New User


Joined: 10 Feb 2006
Posts: 7

PostPosted: Mon Feb 13, 2006 3:36 pm
Reply with quote

hii ..

can u please tell about COPY BOOK ..

what is it use ..

where it residue..
all stuff regd copy book..
Back to top
View user's profile Send private message
Nirmala

New User


Joined: 13 Feb 2006
Posts: 3

PostPosted: Mon Feb 13, 2006 3:49 pm
Reply with quote

Hi,
I guess u r very new to Mianframe.. copy book generally contains date fileds or procedure code which can be used in more than one program in common. And whereever we require the same data fields or code just we will specify the copy book as
COPY < copy book name >

If u will observe after compilation the given copy book will expand and we can those fields or code as if it is declared in the currently used program itself..

Best regards
Nirmala
Back to top
View user's profile Send private message
Nirmala

New User


Joined: 13 Feb 2006
Posts: 3

PostPosted: Mon Feb 13, 2006 4:00 pm
Reply with quote

Morover when we declare fields in the copy book (EMPTABL) like below

01 EMP-TABLE;
03 EMP-NAME; PIC X(10).
03 EMP-CODE; PIC 9(5).

Pls note ; (semi colon), then in the program where u r using this we can rename that fileds by using REPLACE command.

Ex. COPY EMPTABL REPLACING ==;== BY ==-TCS==.

Then that copy bok when it got expanded after compilation in ur program
the fileds wil be defined as
01 EMP-TABLE-TCS
03 EMP-NAME-TCS PIC X(10).
03 EMP-CODE-TCS PIC 9(5).

That is the main advantage also..
without having declared copy book varaible by ending ; (semi colon) also we can REPLACE by using the coomands like

Copy Book Name: EMPTABL
01 EMP-TABLE
03 EMP-NAME PIC X(10).
03 EMP-CODE PIC 9(5).


COPY Example REPLACING LEADING ==EMP== BY ==TCS-EMP==.

But all the compliers doesn't support this option.

Cheers
Nirmala
Back to top
View user's profile Send private message
harshavmr
Currently Banned

New User


Joined: 10 Jun 2005
Posts: 3
Location: Hyderabad

PostPosted: Thu Feb 16, 2006 11:29 am
Reply with quote

Do we have to compile the copy books?
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Thu Feb 16, 2006 12:02 pm
Reply with quote

Copybooks are inserted into your program during compilation. Actually, it's one of the compiler's functions - insert copybooks into the source. After that, there is no 'copybook', you have just your full source. Take a look at the listing of the compiler.

O.
Back to top
View user's profile Send private message
smiley
Warnings : 1

New User


Joined: 08 Feb 2006
Posts: 27

PostPosted: Thu Feb 16, 2006 1:29 pm
Reply with quote

Apart from variables and datanames we can use copybook for code which are being used in many programs.
Back to top
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Sat Mar 04, 2006 2:00 pm
Reply with quote

harshavmr wrote:
Do we have to compile the copy books?


In most of the big applications , there are large no. of programs
and maximum of them use a particular record structures and routines such as date validation routines are generally used by several programs.In such cases its important to ensure that each program has the same file description, record structure or code. And maintaining several copies of the same thing leads to errors and also time consuming.
Each time you modify one copy , you also modify all tha other copies. So to avoid all these we use COPYBOOK. The COPY statement inserts the copybook from the copylibrary into the source program during compilation. Your Compiler option "LIB" should be in effect.
Back to top
View user's profile Send private message
Mane Sagar

New User


Joined: 12 Jul 2005
Posts: 41
Location: mumbai

PostPosted: Sat Mar 04, 2006 4:49 pm
Reply with quote

Hi,

Copybooks are like defining the variables we wanna use in the pgm in copies tha are copied to the program duriing compilation.. Copybooks are generally used when there are large number of variables to be used and are easier to modify.

Regds,
Sagar.
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top