Chapter 16. Improving Program Productivity Using The COPY, CALL, and Other Statements

OBJECTIVES

To familiarize you with

  1. The COPY statement for copying parts of a program that are stored in a library.

  2. The CALL statement for executing called programs as subroutines.

  3. Text manipulation with the STRING and UNSTRING statements.

COPY STATEMENT

Introduction

A COPY statement is used to bring into a program a series of prewritten COBOL entries that have been stored in a library. Copying entries from a library, rather than coding them, has the following benefits: (1) it could save a programmer a considerable amount of coding and debugging time; (2) it promotes program standardization since all programs that copy entries from a library will be using common data-names and/or procedures; (3) it reduces the time it takes to make modifications and reduces duplication of effort; if a change needs to be made to a data entry, it can be made just once in the library without the need to alter individual programs; and (4) library entries are extensively annotated so that they are meaningful to all users; this annotation results in better-documented programs and systems.

Most often, the COPY statement is used to copy FD and 01 entries that define and describe files and records. In addition, standard modules to be used in the PROCEDURE DIVISION of several programs may also be stored in a library and copied as needed.

Organizations that have large databases or files that are shared make frequent use of libraries ...

Get COBOL for the 21st Century now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.