If there are two copybooks which have same variables and we
are using both the copybooks in our program. will there be
an error and if i move values to the variable which copybook
varibales gets the values i move in.

Answers were Sorted based on User's Feedback



If there are two copybooks which have same variables and we are using both the copybooks in our pro..

Answer / lu

you write like this :
01 Copybook1.
02 ADDRESS pic x(03).
01 Copybook2.
02 ADDRESS pic x(03).

move 'AAA' to ADDRESS OF copybook1
move 'BBB' to Address OF copybook2

never forget the 'OF'

Is This Answer Correct ?    17 Yes 1 No

If there are two copybooks which have same variables and we are using both the copybooks in our pro..

Answer / arpan

Or we can use replace option with the copybook in the COBOl
PGM.

For e.g..
Copy Copybook1.
Copy Copybook2 replacing ADDRESS with ADDRESS1.

Correct me if I am wrong.

Is This Answer Correct ?    9 Yes 2 No

If there are two copybooks which have same variables and we are using both the copybooks in our pro..

Answer / jagan

There won't be any error if we have similar variables in
different copybooks and use them in a same program. One
thing i would like to ensure here is before using a copybook
variable in a program , you will need to mention the name of
the copybook followed by the variable...
eg., there are 2 copybooks. RESIDENT and OFFICE and both
of them have the variable ADDRESS in it .


(i) RESIDENT
(ii) OFFICE

We need to refer them in the program by


RESIDENT-ADDRESS and OFFICE-ADDRESS.

In case any data is to be moved to these fields then you can
do it by below stmts.

MOVE PERM-ADD TO RESIDENT-ADDRESS
MOVE TEMP-ADD TO OFFICE-ADDRESS

Hence there shouldn't be any problem in referring to similar
fields in different copybooks .

Is This Answer Correct ?    10 Yes 6 No

Post New Answer

More COBOL Interview Questions

I have a PS file and I would like to manually insert the binary values (like a COMP format) into the file. How can i do that? the way do in COMP-3 format.. suppose i want to insert -12345 in to file in comp-3 format. simply we can open a file in edit mode and do HEX-ON and insert the value . SEE BELOW-- 135 24D in 3 bytes - this will be COMP-3 presenatation of -12345.

1 Answers  


What is the difference between structured cobol programming and object alternativelyiented cobol programming?

0 Answers  


What is difference between static and dynamic call in cobol?

0 Answers  


What are the cobol coding sheets?

0 Answers  


what are the utilities for load and unload the DB2 tables

1 Answers   L&T,


write a cobol logic. i have file that has 10 records .1 record go to first output file and second record goes to 2 output and etc

0 Answers  


if i am reading a file with some 50000 records and moving to a DB2 table and suddenly the program abends in between, is there anyway i could restart from the exact record at which the job failed once the program restarts.

2 Answers   UST,


What is 77 level used for ?

12 Answers   IBM, iGate,


What is the difference between a DYNAMIC and STATIC call in COBOL?

2 Answers  


How do you reference the following file formats from cobol programs?

0 Answers  


can you declare redefine in level 01?

8 Answers   Patni,


What are 77 levels used for?

0 Answers  


Categories