What is the difference between Copy and Include?

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
sivasaras
Member
Posts: 45
Joined: Tue Jun 15, 2010 3:07 pm

What is the difference between Copy and Include?

Post by sivasaras » Tue Jun 15, 2010 3:16 pm

Hi all,

What is the difference between Copy and Include?

Thanks in Advance.


Regards,
Siva

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

Post by Natarajan » Tue Jun 15, 2010 4:40 pm

Look like .. it is a interview question.

ok. here is the answer. function of COPY & INCLUDE is the same.
But the difference is .. cobol compiler can able to understand COPY statement.
INCLUDE statement normally uses in DB2 programs to include DCLGEN copy books. At that time, pre-compiler (we use this in db2 programs compilation process ) will process these include statements.
Natarajan
Chennai

sivasaras
Member
Posts: 45
Joined: Tue Jun 15, 2010 3:07 pm

Post by sivasaras » Wed Jun 16, 2010 5:37 pm

Hi Natarajan,

Thanks for your reply.

Regards,
Siva

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

Post by Natarajan » Wed Jun 16, 2010 5:48 pm

u r welcome :)
Natarajan
Chennai

User avatar
simOnic
Member
Posts: 12
Joined: Wed Jul 14, 2010 9:15 pm

Post by simOnic » Mon Aug 02, 2010 10:34 pm

One more point;

If we are using any copybook variables with embedded SQL statements in the COBOL program, then we should INCLUDE that copybook for expanding at pre-compilation time.

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Mon Aug 02, 2010 11:45 pm

COPY is a compiler directive
INCLUDE is a DB2 pre-compiler directive.

if you want the copybook 'expanded during pre-compilation' use INCLUDE.
if you want the copybook 'expanded during compilation' use COPY.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

dipakgoyal
Member
Posts: 1
Joined: Fri May 09, 2008 4:22 pm

COPY vs INCLUDE in non-DB2 program

Post by dipakgoyal » Fri Sep 07, 2012 5:54 pm

Hi all,

From the above answers,
does it mean that for a non-DB2 Cobol program,
both COPY and INCLUDE are same
both functionally as well as during compiling
(since there is no pre-compile, INCLUDEd copybooks will also be expanded during compile) ?
Thanks and regards,
Dipak Goyal

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Sep 07, 2012 5:57 pm

Well. why don't you try out your theory?

Perhaps re-read dbz's points when it doesn't work.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Sep 07, 2012 9:36 pm

both COPY and INCLUDE are same
both functionally as well as during compiling
Ah, No . . .

You have misunderstood what has been explained.

The COBOL compiler does not support INCLUDE. Things INCLUDEd must be in the source before it is seen by the compiler. There is other software that can deal with INCLUDE but you do not need to be concerned with this just now (and maybe never :wink: ) .

Suggest you re-read what DBZ has posted (and WC mentioned).
Have a good one

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Tue Sep 18, 2012 1:01 pm

dipakgoyal -- If you use, CA-Panvalet, your question might make some sense but then, that has not been mentioned yet...(perhaps, that's what DikDude has also indicated).
Regards,
Anuj

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Tue Sep 18, 2012 1:57 pm

Oh, I give in - INCLUDE is also a PL/1 compiler directive to include code from another source into your program at compile time - actually pre-compile time which, I believe (could be wrong - willing to learn!), would be the first pass of the compiler.
Regards
Nic

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others