Difference among COPY, INCLUDE and ++INCLUDE.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
User avatar
Akshya Chopra
Registered Member
Posts: 77
Joined: Mon May 20, 2013 11:32 pm
Algeria

Difference among COPY, INCLUDE and ++INCLUDE.

Post by Akshya Chopra »

Hi all,

What is the difference between COPY and INCLUDE and ++INCLUDE. I was under the impressions that ++INCLUDE was obsolete.

Thanks,
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: COPY and INCLUDE and ++INCLUDE.

Post by Robert Sample »

All of them copy code from another data set into the source for the compile. ++INCLUDE is used by PANVALET, INCLUDE is used by DB2 precompiles (and possibly others), and COPY is the COBOL compiler directive. They are used at different points but the end result is the same for all of them -- source code is compiled with additional statements not in the source file.
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: Difference among COPY, INCLUDE and ++INCLUDE.

Post by Anuj Dhawan »

COPY is a COBOL dialect and INCLUDE is of DB2; while ++INCLUDE/INC are of Panvelet.

It is a requirement of DB2 pre-compiler that all the referenced working storage areas are available during the pre-compile. Ad you use:

Code: Select all

EXEC SQL 
    INCLUDE COPYBOOK 
END EXEC. 
This way DB2 pre-compiler expands the "copybook". However, if you "include" the copybook using COBOL COPY verb like this: COPY COPYBOOK. - the copybook does not get expanded until the COBOL Compiler gets control, and it's obvious that you'll get pre-compiler errors.

++INCLUDE, as said earlier, is a Panvelet command. It's "same" as COBOL COPY Verb, but it can expand the "text in it" right away as it retrieves the program from the Source repository. Therefore, the Copybook is available in its expanded form at pre-compile time, and is not necessary to be included vial EXEC SQL.

COBOL has used the COPY statement in 1959 and it was the language of the time, so many other languages have included a similar feature, often using "include" as a keyword. The term “copybook” is mainly used in an IBM mainframe context; however, other languages too have different names for it. To summarize:
COPY text-name. (COBOL),
include ... (Fortran),
%include ... (PL/I),
#include ... (C and C++),
<!--#include ... --> (HTML SSI),
<%@ include ... %> (JSP).

And that's where all this confusion arises...

Hope this helps.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
dick scherrer
Former Team Member
Posts: 62
Joined: Wed Aug 07, 2013 6:43 pm

Re: Difference among COPY, INCLUDE and ++INCLUDE.

Post by dick scherrer »

CA-Roscoe and CA-Librarian also have include-ability.
Hope this helps,
d
User avatar
Akshya Chopra
Registered Member
Posts: 77
Joined: Mon May 20, 2013 11:32 pm
Algeria

Re: Difference among COPY, INCLUDE and ++INCLUDE.

Post by Akshya Chopra »

Thanks Robert, Dick and Anuj - this is one of the best explanations I've ever got for this question. Great! :)

Regards,
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Difference among COPY, INCLUDE and ++INCLUDE.

Post by William Collins »

How about posting the other best explanations so others can benefit. Why did you ask again if you already have several best explanations?
User avatar
Akshya Chopra
Registered Member
Posts: 77
Joined: Mon May 20, 2013 11:32 pm
Algeria

Re: Difference among COPY, INCLUDE and ++INCLUDE.

Post by Akshya Chopra »

Hi William,

I should have said "read" instead of "got". However, I can get the links if you want me to but some of them are from other forums so mentionijng them here is not correct, I think.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”