UNF COP 3531 - The Copy and Call Statements

Unformatted text preview:

The Copy and Call StatementsThe Copy statementThe copy statement is used to bring into a program a series of prewritten Cobol entries that have been stored in a library. . saves time (keying and debugging). promotes standardization. reduces modification time if changes need to be made across an organization. are extensively annotated so that entries are meaningful to all users.Result is better documented programs and systems.Most often, copy is used to copy fd and 01 entries that describe files and records.Also used for standard modules.Can copy environment, data, and/or procedure division statements into yoursource program.File Section.copy text-name {of/in} library-nameor copy Aa:\file-name.cpy@copy Aa:\inventory-file-rec-description.cpy@or others...different formats and styles. see textbook.source listing in some systems puts a ‘c’ in col 7 unlessusing free format. fd employee-file.... .1c copy empfile.cpyc 01 ef-record.c 05 ef-customer-name ...c 05 ef-customer-address ...c ....where c => entry copied from library...Can exchange text entries via text substitution:copy text-name [{of/in} library-name]==pseudo-text-1 ==}identifier-1 [replacing literal-1 by word-1==pseudo-text-1 == identifier-1literal-1 word-1 ]the replacing option allows virtually any library entry to be changed when it is being copied into the user's source program.copy customer replacing cust-no by cust-nbr, ==x(5) == by ==x(6) ==.here, changing a five position field to six.Another example of use of copy:a complicated table - error prone to construct each time 2individually. thus, in a copy library:example: csrem.cpy 05 t-change-status-remarks. 10 t-change-status-groups. (assumes col 72…) 15 t-cs-grp1 pic x(156) value "number of inpu - "t transactions: number of adds: - " number of changes: - " number of deletes: ". 15 t-cs-grp2 pic x(156) value "number of inva - "lid transactions: number of records in ol - "d master file: number of records in new master - "file: number of records in new list: ". 15 t-cs-grp3 pic x(39) value "number of reco - "rds in old list: ". 10 t-cs-rem redefines t-change-status-groups occurs 9 times pic x(39).Another example of a standard table used for table look-ups. 05 t-grade-expand. 10 t-grade-groups. 15 t-grd-grp1 pic x(100) value "2nd Lieutenant - " 1st Lieutenant Captain Ma - "jor Lt colonel ". 15 t-grd-grp2 pic x(80) value "colonel - " brigadier general major general li - "eutenant general ". 10 t-grade redefines t-grade-groups occurs 9 times pic x(20).Still another example: month-table.cpy 05 t-month-names value "janfebmaraprmayjunjulaugsepoctnovdec". 10 t-month occurs 12 times pic xxx.3Lastly: accept-date.cpy accept w-date from date. move t-month (w-month) to p-h1-month move w-day to p-h1-day move w-year to p-h1-yearIn use: in the program file.cbl: fd master-sorted-file label records are standard record contains 80 characters. (Discuss FD clauses!!) copy Amastrecord.dat@ or Amaster-rec.cpy@ replacing mfschool-record by mstr-sorted-rec {this above is the 01 entry.....} mf-first-init by ms-first-init mf-middle-init by ms-middle-init mf-last-name by ms-last-name mf-grades by ms-grades mf-salary by ms-salary mf-grade by ms-grade mf-age by ms-age mf-echelon by ms-echelon mf-class by ms-class mf-college by ms-college mf-gpa by ms-gpa mf-hours-comp by ms-hours-comp mf-posnbr by ms-posnbr. and from a live program: ******************************************************************************************************** * 4* * called from 1000-main-module. calls 2000-load-stats-table, * * 3000-generate-o-master-report, 4000-generate-n-master-report, * * 5000-generate-chng-lst-report, and 6000-generate-err-list- * * report. * * * * opens sorted files, copies accept date code which accepts * * the system date and moves it to the header, calls the * * sub-routines, closes the files, and exits the program. * ******************************************************************************************************** 1000-main-module. open input master-sorted-file new-master-file change-list-file ce-remark-file output print-reports-file. copy acceptda.cpy. <<======= perform 2000-load-stats-tables. perform 3000-generate-o-master-report. perform 4000-generate-n-master-report. perform 5000-generate-chng-lst-report. perform 6000-generate-err-list-report. close master-sorted-file new-master-file change-list-file ce-remark-file print-reports-file. exit program. 5The Call StatementWhy use call statements?There are many advantages of using calls1. Each module may be written, compiled, and perhaps even tested independently;2. The modules may be written in different stages, in a top-down manner. They may even be coded by different programmers.3. If a specific module needs to be modified, the entire logical flow should still function properly without the need for extensive revision to other parts of the program.4. Helps regression testingTypically, Cobol programs are stored in a library in much the same way as other routines that may be "copied."In microfocus: subdirectories normBut each environment has its own nuances that must be considered.. Can think of paragraphs as "subroutines," if wish. . Cobol: no subroutines


View Full Document

UNF COP 3531 - The Copy and Call Statements

Download The Copy and Call Statements
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view The Copy and Call Statements and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view The Copy and Call Statements 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?