difference

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
mkarthikmca
Member
Posts: 2
Joined: Wed Jun 03, 2009 6:17 am

difference

Post by mkarthikmca » Wed Jun 03, 2009 6:27 am

can any one help me to know what is the diff between copy and include statement in cobol?
Thanks,
M.Karthik

User avatar
arcvns
Member
Posts: 28
Joined: Sat May 30, 2009 10:19 pm
Location: Chennai, India

Post by arcvns » Wed Jun 03, 2009 7:46 am

Karthik,

COPY statement allows pieces of prewritten code to be included in your program just by specifying the member-name without having to rewrite the entire code again.

I am not sure which 'INCLUDE' you're referring to. If you've CA-PANVALET, a "++INCLUDE member-name" does the same function as that of a "COPY".
An EXEC SQL INCLUDE member END-EXEC helps including DB2 copybooks such as DCLGENs,SQLCA etc in a COBOL-DB2 program.
Arun

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

Post by Anuj Dhawan » Wed Jun 03, 2009 10:57 am

Here is a bit extension of what Arun has said: COPY statement

DB2 Pre Compiler requires that all referenced working storage areas be available during the Pre Compile. If you include the copybook as

Code: Select all

EXEC SQL 
    INCLUDE COPYBOOK 
END EXEC. 
the DB2 Pre Compiler will expand the copybook. If you were to include the copybook via. COBOL COPY

Code: Select all

    COPY COPYBOOK. 
the copybook does not get expanded until the COBOL Compiler gets control, and you get Pre Compiler Errors, AFAIK.
Regards,
Anuj

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

Post by Anuj Dhawan » Wed Jun 03, 2009 10:58 am

And M.Karthik, why didn't you choose a better subject title?
Regards,
Anuj

User avatar
arcvns
Member
Posts: 28
Joined: Sat May 30, 2009 10:19 pm
Location: Chennai, India

Post by arcvns » Wed Jun 03, 2009 5:06 pm

Anuj D. wrote:If you include the copybook as

Code: Select all

EXEC SQL 
    INCLUDE COPYBOOK 
END EXEC. 
the DB2 Pre Compiler will expand the copybook. If you were to include the copybook via. COBOL COPY

Code: Select all

    COPY COPYBOOK. 
the copybook does not get expanded until the COBOL Compiler gets control, and you get Pre Compiler Errors, AFAIK.
Anuj,

AFAIK, COPY membernames get copied at Compile-time whereas DB2 INCLUDEs get included at Pre-compile time and the difference is just the timing.

It is a common practice to INCLUDE DCLGENs in order to capture errors such as mispelled table names in the early Precompile step itself rather than finding it later in the BIND step.
Arun

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