complex conditions, 78
varying phrase, 175
END-IF vs. period, 82
WRITE statement, 143
relation conditions, 74
reading and writing to employee file, 145
sign conditions, 78
WRITE..FROM, 143
implied subjects, 80
writing record and reading file, 143–144
nested IF statements, 81
writing records to file end, 144–145
practical exercises, 102
Sequential file organization
Sequential file(s), 138, 157, 205
advantages, 466
CLOSE statement, 139
disadvantages, 466
control-break processing, 206
SET verb, 304
detection, 208
Sign conditions, 78
program writing, 208
Software System creation, 399
specifications required, 207
CALL verb
template, 209
CANCEL verb, 406
three-level control break ( see Control break
external subprogram, 408, 414
processing)
getting state information, 420
typical control break ( see Control break
IS COMMON PROGRAM Clause, 407
processing)
IS EXTERNAL Clause ( see IS EXTERNAL Clause)
data organization, 205
IS EXTERNAL Data Items ( see IS EXTERNAL
file organization vs. method of access, 205
Data Items)
file update program, 232
IS GLOBAL Clause, 407
program implementation, 232
IS INITIAL Phrase, 404
test data file, 236
knowledge game, 417
method of access, 205
metalanguage, 400
multiple record types, 157
parameter passing and data visibility, 409
implications, 157
parameter-passing mechanisms, 401
problem specifications, 157
subprograms ( see Subprograms)
record buffer, 159
uses, 400
type code ( see Type code)
using COMMON Subprogram, 412
OPEN statement, 139
COPY verb
ordered and unordered files, 206
copy library, 425
practical exercises, 149, 152
COPY Statement, 426
printer files, 166
COPY Statements with REPLACEMENT
multiple record types, problems, 168
Text, 427
multiple record types, solutions, 168
data resource, 425
554
■ index
library statement, 424
LINKAGE SECTION, 403
metalanguage, 425
literal value, 402
REPLACING phrase, 426
Subroutines
subprograms, 399–400
closed subroutines, 112
Solace solar, 477
COBOL subroutines, 112
first page, 478–479
open subroutines, 110, 112
PROCEDURE DIVISION, 480
specification, 478
� T
�
�
tasks, 479
String concatenation, 370
Tables
definition, 371
ANS 85, 270
STRING verb
DriverTable, 270
DELIMITED BY SIZE clause, 372
group name, 270
JUSTIFIED clause, 372
INITIALIZE verb, 271
metalanguage, 371
metalanguage, 270
ON OVERFLOW clause, 371
REDEFINES clause, 270
Pointer#i, 372
StateDrivers, 270
reference modification, 380
VALUE clause, 270
rules, 371
vs. arrays, 247
statement, 372, 393, 396
average sales, 253
WITH POINTER phrase, 372
candy sales, 250, 252–253
String manipulation, 361
control-break problem, 250
String splitting
data program, 255
COUNT IN clause, 373
declaration, 248
definition, 373
OCCURS clause rules, 248
program, 379
subscript rules, 249
TALLYING clause, 373
definition, 247
UNSTRING verb
diagrammatic representation, 251
ALL phrase, 375
differences, 248
COUNT IN clause, 375–376
display statements, 250
DELIMITED BY clause, 374–375
EVALUATE statement, 250
DELIMITER IN phrase, 375, 378–379
granularity levels, 253
END-UNSTRING, 374
multidimensional, 256
metalanguage, 374
definition, 256
ON OVERFLOW clause, 375, 377
depiction, 260
reference modification, 380
granular data, 256
statement, 374
hierarchical structure, COBOL, 257
TALLYING clause, 375
program, 257
WITH POINTER clause, 375
record description, 256
STRING verb
three dimensional ( see Three dimensional)
DELIMITED BY SIZE clause, 372
prefilled table
JUSTIFIED clause, 372
creation, 263
metalanguage, 371
Electronics2Go sales file, 265
ON OVERFLOW clause, 371
program, 264, 266–269
Pointer#i, 372
REDEFINES clause, 263
reference modification, 381
two-dimensional, 264
rules, 371
procedure, 250
statement, 372, 393, 396
program, 254
WITH POINTER phrase, 372
sales-report program, 253
Strongly typed languages, 38
StateSalesTable, 251
Subprograms
StateSalesTotal, 251
contained subprograms, 403
Three dimensional
vs.external subprograms, 404
AgeCategory, 261
EXIT PROGRAM, 403
CensusFile, 261
555
■ index
Three dimensional ( cont. )
numeric data, 286
population totals, 261
PACKED-DECIMAL, 290
structure, 262
SYNCHRONIZED clause, 291
Transaction file (TF), 219
USAGE IS COMP, 411
Truth tables, 79
Type code, 159
� V
�
�
graph representation, 160
program implementation, 160
Variable-length tables, 319
record descriptions, 160
declaration, 319
specification required, 164
OCCURS clause, 319
SEARCH ALL verb, 320
� U
�
�
� W
� , X, Y
�
UNSTRING verb
ALL phrase, 375
WHEN branch rules, 97
COUNT IN clause, 375–376
WRITE statement, 169
DELIMITED BY clause, 374–375
ADVANCING clause, 170
DELIMITER IN phrase, 375, 378
metalanguage, 170
END-UNSTRING, 374
PAGE option, 170
metalanguage, 374
program implementation, 171
ON OVERFLOW clause, 375, 377
reading
and writing to employee file, 145
reference modification, 380
Report Writer, 173
statement, 374
WRITE..FROM, 143
TALLYING clause, 375
writing record and reading file, 143–144
WITH POINTER clause, 375
writing records to file end, 144–145
USAGE clause, 286
advantages, 288
� Z
�
�
COMP, 290
considerations, 289
Zodiac signs compatibility
disadvantages, 286
cusp problem, 429
extensions, 292
information file, 429
memory storage, 288
processing, 430
metalanguage syntax, 288
zodiac table, 429
556
Beginning COBOL for
Programmers
Michael Coughlan
Beginning COBOL for Programmers
Copyright © 2014 by Michael Coughlan
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s location, in its current version, and permission for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law.
ISBN-13 (pbk): 978-1-4302-6253-4
ISBN-13 (electronic): 978-1-4302-6254-1
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
President and Publisher: Paul Manning
Lead Editor: Steve Anglin
Development Editor: Matthew Moodie
Technical Reviewer: Massimo Nardone
Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Louise Corrigan, Jim DeWolf,
Jonathan Gennick, Jonathan Hassell, Robert Hutchinson, Michelle Lowman, James Markham,
Matthew Moodie, Jeff Olson, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft,
Gwenan Spearing, Matt Wade, Steve Weiss
Coordinating Editors: Anamika Panchoo and Melissa Maldonado
Copy Editor: Tiffany Taylor
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected], or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this text is available to readers at www.apress.com. For detailed information about how to locate your book’s source code, go to
www.apress.com/source-code/.
To my students in grateful thanks for everything you taught me.
Contents
About the Author ��������������������������������������������������������������������������������������������������������������� xxi
About the Technical Reviewer ����������������������������������������������������������������������������������������� xxiii
Acknowledgments ������������������������������������������������������������������������������������������������������������ xxv
Preface ��������������������������������������������������������������������������������������������������������������������������� xxvii
Chapter 1: Intr
■
oduction to COBOL ��������������������������������������������������������������������������������������1
What Is COBOL? �����������������������������������������������������������������������������������������������������������������������������1
COBOL’s Target Application Domain ����������������������������������������������������������������������������������������������������������������������� 1
COBOL’s Fitness for Its Application Domain ����������������������������������������������������������������������������������������������������������� 2
History of COBOL ���������������������������������������������������������������������������������������������������������������������������3
Beginnings ������������������������������������������������������������������������������������������������������������������������������������������������������������� 3
COBOL Standards �������������������������������������������������������������������������������������������������������������������������������������������������� 4
The Argument for COBOL (Why COBOL?) ���������������������������������������������������������������������������������������5
Dominance of COBOL in Enterprise Computing ����������������������������������������������������������������������������������������������������� 5
Danger, Difficulty, and Expense of Replacing Legacy COBOL Applications ������������������������������������������������������������ 5
Shortage of COBOL Programmers: Crisis and Opportunity ������������������������������������������������������������������������������������ 7
COBOL: The Hidden Asset �������������������������������������������������������������������������������������������������������������������������������������� 8
Advantages of Bespoke Software �������������������������������������������������������������������������������������������������������������������������� 9
Michael Coughlan Page 69