Digital PDFs
Documents
Guest
Register
Log In
AA-C986A-TE
January 1979
394 pages
Original
27MB
view
download
OCR Version
21MB
view
download
Document:
VAX-11 COBOL-74
User's Guide
Order Number:
AA-C986A-TE
Revision:
0
Pages:
394
Original Filename:
OCR Text
dlifgliltall | il VAX-11 COBOL-74 User’s Guide Order No. AA-C986A-TE ifnl [N | M January 1979 This document describes how to use the VAX-11 COBOL-74 compiler. VAX-11 COBOL-74 User’s Guide Order No. AA-C986A-TE OPERATING SYSTEM AND VERSION: VAX/VMS V01.5 SOFTWARE VERSION: VAX-11 COBOL-74 V04 To order additional copies of this documént, contact the Software Distribution Center, Digital Equipment Corporation, Maynard, Massachusetts 01754 digital equipment corporation - maynard, massachusetts The and information in this document should not be construed for any errors Corporation. is subject to change without notice as a commitment by Digital Equipment Digital Equipment Corporation assumes no responsibility that may appear The software described and may be used or in this document. in this document is furnished under copied only in accordance with the a license terms of such license. Digital Equipment Corporation assumes no reliability of its software on responsibility equipment that for the use or is not supplied by Digital. Copyright (©) 1979 by Digital Equipment Corporation The postage-prepaid READER'S COMMENTS form on the last page of this document requests the user's «critical evaluation to assist us in preparing The future documentation. following are trademarks of Digital Equipment Corporation: DIGITAL DECsystem-10 DEC DECtape OMNIBUS PDP DIBOL 0S/8 DECUS EDUSYSTEM PHA UNIBUS FLIP RSTS CHIP MASSBUS COMPUTER LABS FOCAL RSX COMTEX DDT DECCOMM ASSIST-11 INDAC LAB-8 DECSYSTEM-20 RTS-8 TYPESET-8 TYPESET-11 TMS-11 ITPS-10 VAX VMS SBI DECnet IAS 5/79-14 CONTENTS Page 2 USING 2.1 CREATING A 2.1.2 2.2 USING 2.2.1 The 2.2.2 Command THE Error Common COMPILER Line Format Qualifiers Message LINKING 2.4 EXECUTING A Setting The RUN COBOL Errors IMAGE and Resetting Command DATA Program Switches HANDLING N FIELDS Tests of WU N Classes The Data Comparison Class Operation Tests MOVEMENT MOVE Group (WO WNDDdDDDNHE SNk - CHARACTERS NON-NUMERIC STATEMENT Moves Elementary Moves Edited Moves Justified Moves Multiple Receiving Subscripted Fields Moves Common Errors, MOVE Format 2, CORRESPONDING THE bW WNDNDN SPECIAL TESTING HEHE OO (WO Items Elementary Items DATA SO U WWWWWWWWWWWWWWWWW I o ORGANIZATION Group Relation STRING MOVE Statement STATEMENT Multiple Sending Fields The POINTER Phrase The DELIMITED BY Phrase The OVERFLOW Phrase Subscripted Common THE — [} WUIES S BB D WNDNDN o [ e e o e o [} IO OO OO e ® NN [} DATA THE [] [] Line PROGRAMS INTRODUCTION NN o Command COBOL-74 NON-NUMERIC e Summary COBOL-74 2.3 WWWWWWwWwWwWwwWwWwwwWwwwwwwwwwwwwwww FILE Reference Format Source Program - 2.2.3 3 a a SYSTEM Command 2.2.4 2.4.2 COBOL-74 SOURCE Choosing Entering 2.4.1 CHAPTER VAX-11 w | 2.1.1 THE Fields Errors, UNSTRING Multiple | CHAPTER (VSIN \O \§) INTRODUCTION = 1 NN DNDNDNDNDDDNDND | | | HHEFOOOWNDNDNDE CHAPTER — XiVv i ACKNOWLEDGMENTS o Xxiii = PREFACE in STRING STRING STATEMENT Receiving 1ii Statements Statement Fields CONTENTS (Continued) w N [ [ [ > W N o [] [4 ® [ [} LN+ [) [ [ e The Replacement Argument List Interference in Replacement Argument Common INSPECT Lists Statement CHARACTER HANDLING DISPLAY COMPUTATIONAL COMPUTATIONAL-3 DECIMAL SCALING POSITION Y wN = Errors, L T L N N B DR BN WM ] SoooaooooutuumuunewwwwpnH WNH ARITHMETIC R |R R A N T N A N iv N N N U N O STATEMENTS Intermediate Results The ROUNDED Phrase The SIZE ERROR Phrase | SBWNOH [] [) [] ® STATEMENT Moves Elementary Numeric Moves Elementary Numeric Edited Moves Common Errors, Numeric MOVE Statements THE [] MOVE Group N Relation Tests Sign Tests Class Tests THE [] FIELDS N [] [] WNH CONVENTIONS ILLEGAL VALUES IN NUMERIC TESTING NUMERIC FIELDS [J SIGN N | [] [} |J [J [] |] [ [] [] ® [ [] ® @ e ® ® [J [ [ [ [] [ o ® [} [ [} NN NNOOOOTUNIUTUNT R WNH [] [) STATEMENT REPLACING Phrase Search Argument Replacement Value Replacement Argument NUMERIC USAGES [] [ [ ® SO NG N [] N ® [ QY S [] S [] [] QI O SO S Y ° G |] S [} [4 S S [] ST ® e [ [] [ [ ® The The o The ® Statements Statement The Tally Argument List Interference in Tally Argument Lists [ [] INSPECT UNSTRING 3-29 The BEFORE/AFTER Phrase Implicit Redefinition The INSPECT Operation Setting the Scanner Active/Inactive Arguments Finding an Argument Match Subscripted Fields in INSPECT Statements The TALLYING Phrase The Tally Counter The Tally Argument The G SO SO CHAPTER Errors, 3-25 — = HEH=WOOOONINNoOhoOutde o> w W [\ o o e THE [4 ® OWoOoOJoUde O WOWWOWWOWWOWWWWWWWWOWOWWLWILWLOLOILWWLOLWO 0O 0 o o WWWWWWwWwwwWwwwwwwwwwwuwuwuwuwwuwuwuwwww - [ ® Common W [ [} The DELIMITED BY Phrase Multiple Delimiters The COUNT Phrase The DELIMITER Phrase The POINTER Phrase The TALLYING Phrase The OVERFLOW Phrase Subscripted Fields in UNSTRING [] Page 4-15 CONTENTS (Continued) The The The ADD The DIVIDE The COMPUTE GIVING Phrase Multiple Operands 4-16 in ADD and SUBTRACT Statement MULTIPLY Statement R R DD DWW NN N | [] |] =N [] [] [} [] o [] [4 [} [ o [] HWOOJO UL & WN - [] ] BB B Statements PROCESSING - Format 1 Phrase - Format 2 ELEMENTS Initializing Tables AND Subscripting INDEXING with Literals Operations Performed by the Software Subscripting with Data-Names Operations Performed by the RTS Subscripting with Indexes Operations Performed by the Relative Indexing | U Phrase OCCURS TABLE 4-20 4-21 TABLES OCCURS MAPPING 4-20 '—l Arithmetic HANDLING SUBSCRIPTING B LJ [] 4-19 Statement EXPRESSION INTRODUCTION o Statement Errors, DEFINING [] 4-17 4-18 4-18 G, N MO NG, N, NG, | | (N D R A HHEFOJWWND - [ [ [) [ [] [J H WO = O N RN B [) B [] [ O~ o e ol N B SUBTRACT Common The The 4-16 Statement ARITHMETIC TABLE (SR NG R RO NG RG RN NG NGRS NGES NSNS, NG, CHAPTER [ ] I~ Statements (SANCNC RO ® Ul The Jo o e [ = N Page RTS Index Data Items The SET Statement Referencing a Variable-Length Table The SEARCH Verb - Format 1 The SEARCH Verb - Format 2 Files on Magnetic Sequential Files Relative Files Indexed Files on Disk - o N ° w RECORD Effects Sharing on AREA Output Operations of Input Operations Record Areas Tape WWNDN = O O - Sequential Effects o Control > W N [ ® [] [4 [] BLOCKING ® RECORD CURRENT Time HHEMFHEEEOOSOAUTD (VST (O [} Variable-length Variable with Fixed-length [} [] FORMAT SIZE [] RTS Fixed-length RECORD ® at PROCESSING [} [} RECORD [} BB BB WWWWWHN Group NSO OYOYOY O | — > W= o o at RTS Time Referencing a Dynamic The SEARCH Verb INPUT-OUTPUT AN OO ONOYO OYOY CHAPTER (o) G RGEE, NS, [} e o [=~ N = Element CONTENTS (Continued) COMPATIBILITY Data Type Differences Data Record Formatting Differences Special Control Characters I/0 ERROR PROCESSING LOW-VOLUME I/0 (ACCEPT AND DISPLAY) Mnemonic-Names (SPECIAL-NAMES Paragraph) Logical Name "Devices" Statement wN - @ e (NN ° TO DEBUG A PROGRAM SET LANGUAGE COBOL Command MODULE Commands: SET, SHOW, SCOPE Commands: SET, SPECIFYING LOCATIONS Location Types Resolving Location vi SHOW, | w ww N o | TM CONCEPTS PREPARING ) e [] DEBUG | PROGRAMS o COBOL wWwwNppNhhDDD -+ oo DEBUGGING o O A Guideline 1 (Data Item Definition) Guideline 2 (Reference Format) Guideline 3 (Unique Referability) Qualified Procedure References Qualification and Compiler Performance PROGRAM WO WOWWOWOWO | REFERENCES References UTILITY O ~ STATEMENT CONDITION NAMES - LEVEL-88 and and Ambiguities CANCEL CANCEL b OF [ e HHFEFOWOWJOULUI O USE USE OF. QUALIFIED Qualified Data STATEMENT N NN N PERFORM PROGRAM (N ALTER THE 6-27 6-28 NN THE OF 6-27 [ ONOOHNOOUT OF USE 6-25 6-25 6-26 N WD [] ® [] ® [ ® PRACTICES USE 6-24 6-24 6-25 6-29 Statement PROGRAMMING 6-19 6-20 6-22 | | (R T I WD DISPLAY 6-17 6-17 YW WYWWYWWOWOO ACCEPT 6-14 6-14 6-14 WO WO (VS I (O [\ I oy D> Wi+ w N w N > o o e . o e [ o o o [] [] [] [] . - o o o o [] File Specifications Logical Names ASSIGN and VALUE OF ID Clauses File Switches (PDP-11 COBOL Compatibility) FILE 6-13 6-13 6-13 6-16 Execution FILES ~J — = HFHHOOOOONdNJIJJooourtgnorin FILES I/0 Operations OPEN Statement NAMING Clause) (SAME AREA Clause) REFORMAT L CHAPTER OPENING Buffers FORMATTING THE SOURCE USE OF PUNCTUATION O CHAPTER Sharing GOOD [ CHAPTER 1/0 BUFFERS RMS Buffer Defaults Multiple Buffers (RESERVE NNNNNNNNNN N (o) NN O OO O OO O Page CONTENTS (Continued) Page 9.4 9.4. 9.4. 9.4. WATCH Commands: SET, SHOW, and CANCEL GO and STEP Commands CTRL/Y Command (Interrupting the Image) 9-7 9-8 9-9 9.4. EXIT 9-9 9.5. CHAPTER SET, SET, SHOW, SHOW, and and CANCEL CANCEL Command SHOW CALLS Command EXAMINING AND CHANGING EXAMINE 9-5 9-6 9-9 9-10 DATA Command 9-10 9.5. 9.6 DEPOSIT Command SAMPLE DEBUG SESSION 9-10 9-11 10 ERROR MESSAGES 10-1 10.1 COMPILE-TIME 10-1 ERROR MESSAGES 10.1.1 Severity Levels 10-2 10.1.2 10.1.3 Error Message Printing Internal Compiler Errors 10-3 10-3 10.2 10.2.1 10.2.2 SYSTEM MESSAGES Link-Time Error Messages Run-Time Error Messages 10.2.2.1 10.2.2.2 CHAPTER Commands: Commands: 9-5 BREAK TRACE 9.4. 9.5 CHAPTER CONTROLLING PROGRAM EXECUTION 9.4. 9.4. Faulty Program File I/0 Error 11 SORTING 11.1 VAX-11 IN A Logic Error Procedures COBOL System Errors 10-4 10-5 10-5 Procedures PROGRAM 11.2 11.2.1 11.2.2 SORT SUBROUTINE I1/0 INTERFACE METHODS File I/0 Interface Record I/0 Interface 11.3 KEY 11.4 11.5 KEY BUFFER SORT SUBROUTINES DATA AND -- 10-5 10-7 11-1 PACKAGE 11-1 11-2 11-2 11-2 RECORD AREAS 11-3 11-4 11-6 11.5.1 11.5.2 11.5.3 SOR$PASS FILES SORSINIT SORT SORSRELEASE_REC 11-6 11-7 11-8 11.5.4 11.5.5 11.5.6 SOR$SORT MERGE SORSRETURN_REC SORSEND SORT 11-9 11-10 11-11 11.6 PROGRAMMING 12 USING 12.1 12.2 Creating The COPY 12.3 12.4 12.5 The 12-4 The 12-6 THE EXAMPLE LIBRARY 11-12 FACILITY a COBOL Library Statement File COPY REPLACING Statement Source Listing Common Errors in Using the Library vii 12-1 12-2 12-2 Facility 12-7 CONTENTS (Continued) Page CHAPTER 13 OPTIMIZATION 13-1 13.1 13.1.1 OPTIMIZING FILE DESIGN Sequential Files Relative Files Indexed Files General Rules for Indexed Files Bucket Size Index Depth Overhead Accumulation OPTIMIZING PROGRAM ORGANIZATION Sequential Reading of Indexed Files Caching Index Roots Multi-block Reading and Writing OPTIMIZING COMPUTATION 13-2 13-2 13-2 13-3 13-5 13-6 13-7 13-7 13-8 13-8 13-8 13-9 13-9 APPENDIX A THE A-1 APPENDIX B COMPILER APPENDIX C SOURCE APPENDIX D DIAGNOSTIC APPENDIX E RUN-TIME ERROR MESSAGES APPENDIX F INTERNAL COMPILER ERRORS APPENDIX G PROGRAMMING G.1 G.1l.1 CALLING A FORTRAN SUBROUTINE The COBOL Program, GETROOT G-1 G-1 G.1l.2 G.1l.3 G.2 G.2.1 G.2.2 G.3 G.3.1 G.3.2 G.4 G.4.1 G.4.2 The FORTRAN Program, SQROOT Sample Run of GETROOT CALLING VAX-11] RUN-TIME PROCEDURES The COBOL Program, RUNTIME Sample Run of RUNTIME USING TERMINAL ESCAPE SEQUENCES The COBOL Program, ESCAPE Sample Run of ESCAPE CALLING VAX/VMS SYSTEM SERVICES The COBOL Program, SYSTSVC Sample Run of SYSTSVC G-3 G-3 G-4 G-4 G-5 G-5 G-6 G-9 G-10 G-10 G-13 13.1.2 13.1.3 13.1.3 13.1 13.1. 13.1. 13.2 13.2.1 13.2.2 13.2.3 13.3 COBOL FORMATS IMPLEMENTATION LIMITATIONS B-1 PROGRAM LISTINGS C-1 ERROR MESSAGES D-1 E-1 -- SYSTEM EXAMPLES INDEX ERRORS F-1 G-1 Index-1 FIGURES FIGURE 1-1 3-1 3-2 Building a COBOL Task Image Field Sizes Redefining Special Characters viii 1-2 3-3 3-4 CONTENTS FIGURE (Continued) Relation Condition The Meanings of Relational Operators Class Condition, General Format Data Movement with Data Movement with Subscripted Sample MOVE STRING Editing Symbols No Editing Statements Statement Concatenation Literals Indexed Sample with the STRING Sending Fields as Sending POINTER Fields Phrase Delimiting with SPACE Delimiter as a Statement the Word SIZE Repeating the DELIMITED BY Phrase Delimiting with More Than One Space The ON OVERFLOW Phrase Various STRING Statements Overflow Condition STRING Statement Subscripting Subscripting with with with the the Character Illustrating the Pointer Pointer Delimiter Sample UNSTRING Statement Multiple Receiving Fields Delimiting with a Space Character Delimiting with Multiple Receiving Fields Delimiting with an Identifier Multiple Delimiters The COUNT Phrase The DELIMITER Phrase The POINTER Phrase Examining the Next Character by Using the Pointer Data Item as a Subscript Examining the Next Character by Placing It Into a One-Character The TALLYING The POINTER and TALLYING Together 3-37 Using the 3-44 the Data Used COUNT Phrase with the Item OVERFLOW Phrase Sequence of Erroneously 3-43 Phrases - Subscripting TALLYING Field Phrase Subscript Repeating Evaluation the Word INTO Sample INSPECT...TALLYING Sample Sample INSPECT...REPLACING Statement INSPECT...BEFORE Statement Statement Matching the Delimiter Characters Characters in a Field Sample INSPECT Statement 3-45 Sample REPLACING Argument 3-46 Sample AFTER 3-47 Where Delimiter Arguments Become ix to the Phrase Active in a Field CONTENTS (Continued) Page FIGURE 3-48 Sample 3-49 3-50 Format of the Tally Argument CHARACTERS Form of the Tally Argument Subscripted 3-51 Results 3-52 3-53 Condition Argument List Adding Argument List Adding 3-54 Counters Argument 3-55 3-56 3-57 3-58 of Argument Counting the 3-48 3-48 LEADING into One Tally Counter into Separate 3-50 An 3-60 Two Arguments Tallying Asterisk Attempt to Tally the Character B 3-63 3-64 3-65 3-66 3-50 3-51 3-51 3-52 3-52 with 3-52 3-53 Groupings Placing the LEADING Condition in the List Reversing the Argument List 1in Figure Argument 3-62 3-49 3-50 Tally List (with Delimiters) Adding into Separate Tally Counters Results of the Scan in Figure 3-55 Two Tallying Arguments that Do Not Interfere with Each Other Two Tallying Arguments that Do Interfere with Each Other Two Tallying Arguments that, Because of Their Positioning, Only Partially Interfere with Each Other 3-59 3-61 with 3-47 An Argument List Statement Counting Leading that Counts Words in 3-62 a Tab or Space Characters Counting the Remaining Characters with the CHARACTERS Argument Format of the Search Argument 3-67 Format 3-68 3-69 The Replacement Argument Replacement Argument List of the Replacement 3-70 Over the Entire Field Replacement Argument List that Ones for Zeroes and Zeroes for "Swaps" Ones 3-71 Replacement Becomes Argument Inactive with Character the Value 3-54 3-55 3-55 3-56 3-57 3-58 that List is Active 3-58 that Occurrence of a 3-58 Space 3-59 3-72 Argument List with Three Become Inactive with the Space 4-1 Memory Storage of COMP 4-2 Memory Storage of COMP-3 4-3 Truncation 4-4 Zero 4-5 Alignment Numeric Editing 4-6 4-7 Rounding Rounding Caused Filling 3-53 3-54 by Caused Truncated Truncated Arguments that Occurrence of a 3-59 Data Items Data Decimal by 4-2 Items Point Decimal 4-3 Alignment 4-9 Point 4-10 4-12 Decimal Decimal Point Positions Scaling Positions 4-14 4-15 CONTENTS FIGURE Explicit (Continued) Programmer-Defined Temporary Work Area Arithmetic Statement Intermediate Result Field Attributes Determined from Composite of Operands Arithmetic Expression Intermediate Result Field Attributes Determined by ImplementorDefined Rules Defining a Table Mapping a Table into Memory Synchronized COMP Item in a Table Adding a Field without Altering the Table Size Adding One Byte which Adds Two Bytes to the Element Length Forcing an 0dd Address by Adding a 1-Byte FILLER Item to the Head of the Table The Effect of a SYNCHRONIZED RIGHT Clause Instead of Figure 5-6 a FILLER Item as Shown 1in Initializing Tables Initializing Mixed Usage Fields Initializing Alphanumeric Fields Literal Subscripting Subscripting a Multi-Dimensional Table Subscripting Rules for a Multi-Dimensional Table Subscripting with Data-Names Index-Name Item Subscripting with Index-Name Items Relative Indexing Index Data Item Legal Data Movement with the SET Statement Example of Using SEARCH to Search a Table Unqualified Data Item Reference Qualified Data Item Reference General Format of a Qualified Data Reference General Format of a Qualified Procedure Reference Merging Library Text Three-Level Primary Key Index TABLES TABLE Command Qualifiers LLegal Non-Numeric Elementary Moves Results of the Preceding Sample Statements Results of the Preceding Sample Statements Values Moved into the Receiving Fields Based on the Value in the Sending Field Handling a Sending Field that is Too Short X1 CONTENTS TABLE (Continued) Results Results Fields of of Delimiting Delimiting with an Asterisk Multiple Receiving Results Results Results of of of Delimiting Delimiting Delimiting with with with Two Asterisks ALL Asterisks ALL Double Asterisks Results of the in Figure 3-29 Multiple Delimiters Shown Original, Altered, and Restored Values Resulting from Implicit Redefinition The Resulting ASCII Character from a Sign and The I/0 Digit Sharing the Same Byte Sign Tests Statements Grouped by File Organization, Access Mode, and Open File Specification Compatibility COPY REPLACING Mode Switches for PDP-11 Matches Commercial Engineering Publications typeset this manual using DIGITAL’s TMS-11 System. 956ALL Xx1ii PREFACE MANUAL OBJECTIVES This manual describes the relationships between modules and executable User's Guide supplements language in the INTENDED AUDIENCE This manual of of the VAX-1l1l is VAX-11l the compiler. description COBOL-74 designed COBOL-74 COBOL-74 the COBOL-74 1language, images, and VAX/VMS and for language Language programmers and who of the who have familiar into and <chapters features discusses the compiler, object utilities. The COBOL-74 Reference are It the its programming Manual. a with working the basic knowledge concepts VAX/VMS. STRUCTURE OF THIS DOCUMENT The User's Guide 1is describe functions, language system. ASSOCIATED organized concepts, and appendixes that of the VAX-1l1 COBOL-74 DOCUMENTS This manual supplemental refers to the following documents, information that is relevant to which VAX-1l1] contain COBOL-74 programming: e VAX-11l COBOL-74 e VAX/VMS Command @ VAX-1l1l @ Introduction To VAX-1ll e VAX-11l Symbolic Debugger e VAX-1l1l Sort ® VAX/VMS CONVENTIONS Linker Reference Manual Language User's Guide Reference Reference Manual Record Management Reference Services Manual Manual Operator's Guide USED The syntactic discussed 1in Manual. Language IN THIS DOCUMENT conventions used Chapter 1 of the 1in general format examples are VAX-1l COBOL-74 Language Reference Xiii ACKNOWLEDGMENT COBOL is an or group industry language and is not the property of any company of companies, or of any organization or group of organizations. No warranty, expressed or implied, is made by any contributor or by the CODASYL COBOL Committee as to the accuracy and functioning of the programming system and 1language. Moreover, no responsibility is assumed by any contributor, or by the committee, 1in connection therewith. The authors and copyright holders of the <copyrighted material wused herein are: FLOW-MATIC (trademark of Sperry Rand Corporation), Programming for the UNIVAC (R) I and 1II, Data Automation Systems copyrighted 1958, 1959, by Sperry Rand Corporation; IBM Commercial Translator Form No. F28-8013, copyrighted 1959 by 1IBM; FACT, DSI 27A5260-2760, copyrighted 1960 by Minneapolis-Honeywell. They have specifically authorized the use of this material, in whole or 1in part, in the COBOL specifications. Such authorization extends to the reproduction and use of COBOL specifications in programming manuals or similar publications. Procedures have been established for the maintenance of COBOL. Inquiries <concerning the procedures for proposing changes should be directed to the Chairman of the CODASYL COBOL Committee, P.O. Box 1808, Washington, DC 20013. X1iv CHAPTER 1 INTRODUCTION The VAX-11l COBOL-74 compiler translates ANS-74 COBOL source programs into relocatable object modules; it runs under the supervision of VAX/VMS. To run a COBOL program, you follow o Prepare a source program ) Compile a source program ) Link ) Execute object modules the into a four-step process: an executable image file image The VAX-11 COBOL-74 compiler accepts COBOL source statements from source input files. This means that you must manually enter your source statements onto an acceptable medium prior to the compilation process. Once you have decided upon an input medium and format for your source input files and have created them, you compile the source program. The VAX-11l COBOL-74 compiler reads source statements from the source input file and translates them into an object module consisting of program listing sections (PSECTs). It can also with optional special-purpose produce a source program 1listings, such as a map and cross-reference. Chapter 2 describes the procedure for compiling programs and specifying compiler options. The compiler can compile only one source program or subprogram at a time. Therefore, a program that consists of a main program and one or more subprograms requires multiple executions of the compiler. Each compilation generates a separate listing and object module. The compiler produces an object module, which must be VAX-11 Linker to produce an executable image file. 1linked by the The linker can combine several independently compiled object modules 1into a single executable image; the ability to compile COBOL subprograms to produce linkable object modules enables you to create modular programs. The image is an executable form of the declarations and instructions in your COBOL source programs. It includes subprograms that were included by the linker as a result of your commands. It also includes routines from the COBOL run-time system (RTS), which is a library of predefined generalized procedures that perform standard functions for your program. Figure 1-1 execution. shows the process of preparing COBOL SOURCE COBOL program COBOL SOURCE PROGRAM | a LIBRARY | _J VAX-11 COBOL-74 COMPILER OTHER OBJECT VAX-11 COBOL-74 OBJECT RUNTIME SYSTEM MODULE MODULES L ' | VAX-11 LINKER VAX-11 IMAGE FILE H-MK-00043-00 Building 1-2 INTRODUCTION Figure 1-1 an Executable Image for CHAPTER USING THE VAX-11] 2 COBOL-74 SYSTEM This chapter discusses the procedures linking, and executing COBOL programs. 2.1 CREATING A Before you reference SOURCE can compile format and for <creating, compiling, PROGRAM a COBOL prepare program, you must decide on the your source program for input source the to compiler. 2.1.1 The Choosing VAX-11 or COBOL-74 formats in library). Reference COBOL-74 conventional VAX-11 a the compiler terminal Reference same source Format can accept reference source programs format (both are Manual). However, you cannot program (including text in either described mix copied in the reference from a COBOL Terminal format was designed to be easily used by programmers at interactive terminals; therefore, the compiler accepts terminal reference format as a default and allows you to use a command qualifier to specify conventional format. The terminal format can reduce the amount of file space needed to store source programs. In addition, it is usually easier to edit source programs written in terminal You your may format, want COBOL to because select program spacing the was requirements conventional originally are reference written more flexible. format, that way however, for if another compiler. You can convert a terminal format program to conventional using the REFORMAT utility, which is described in Chapter also use REFORMAT to match the formats of source files library files if they are not the same. format by 8. You can and COBOL 2.1.2 Entering a Source Program You can create a source program file by wusing the VAX/VMS CREATE command or a text editor. CREATE can be used only for a new file; you must use a text editor to change existing source files. Most users rely on text editors for both creating and updating source files. Unless you specify a file command 1line, which is assumes COB as a default; naming source files with type for the source program file 1in the described in the next section, the compiler therefore, you can simplify compiling by the default file type. The CREATE command is described in the VAX/VMS Command Language User's Guide; the VAX/VMS Text Editing Reference Manual discusses the SOS and SLP 2.2 text USING editors. THE COMPILER The VAX-11 COBOL-74 compiler translates source statements into object modules that contain relocatable code. It can also produce a listing of source statements and other information if you use the appropriate command qualifiers. This section describes the procedure for compiling your source program; it discusses the COBOL command line and the error message summary. Finally, it lists some common errors to avoid in entering compiler command lines. Appendix C discusses the components of the source program listing. 2.2.1 The Command Line The VAX-11 COBOL-74 COBOL/C74 Format command line has [/command-qualifiers] the following format: file-spec where: COBOL/C74 specifies /command-qualifiers specify compiler file-spec specifies the file that contains the COBOL source program. If you do not supply a file type in the file specification, the compiler uses Do COB not the VAX-11] COBOL-74 as the use specification. 2-2 USING THE VAX-11 COBOL-74 SYSTEM compiler. options. default. wild cards in the file 2.2.2 Command Qualifiers VAX-11 COBOL-74 provides a series of command qualifiers use to select or suppress compiler options. Table 2-1 qualifiers, which are then described in detail. that you summarizes can the Table 2-1 Command Qualifiers Qualifier Default /[NO]ANSI_FORMAT - / [NO]ICOPY LIST /[NO]CROSS_REFERENCE / [NO]DEBUG /NOANSI_FORMAT /COPY LIST /NOCROSS_REFERENCE /NODEBUG /[NOJLIST[=file-spec] / [NO]MAP /NOMAP / [NO]JOBJECT [=file-spec] /[NO]VERB_LOCATION / [NO]WARNINGS /NOVERB_LOCATION /WARNINGS /ANSI FORMAT /NOANSI FORMAT Indicates whether the source program is format or in DIGITAL's terminal format. in ANSI (conventional) For conventional format, the compiler expects 80-character images with optional sequence numbers in character positions 1-6, indicators in position 7, Area A beginning in position 8, Area B beginning in position 12, and the identification area 1in positions 73-80. By default, the compiler assumes that the terminal format; that is, Area A begins in source file 1is record position 1. /COPY LIST /NOCOPY_LIST Controls whether statements included by COPY statements source program are printed in the listing file. /COPY LIST statements is in the default: the the source listing. compiler includes all 1in 1in the source /NOCOPY LIST suppresses the listing of text copied from library files; only the COPY statement appears in the listing file. /CROSS REFERENCE /NOCROSS REFERENCE Controls whether cross-reference the source program listing includes a SYSTEM 2-3 listing. USING THE VAX-11] COBOL-74 /CROSS REFERENCE produces a cross-reference listing as part the listing file. The compiler sorts data-names of and procedure-names into ascending order and 1lists them with the source program line numbers on which they appear. On the listing, the symbol # indicates the source line on which the name is defined. Note that the use of /CROSS REFERENCE significantly slows down the compilation of large programs. By default, the compiler does not <create a cross-reference listing. /DEBUG [=TRACEBACK] /NODEBUG Controls whether the compiler produces traceback local symbol table information for the debugger. /DEBUG allows you to Procedure Division information and refer to data items by data-name, and to 1locations by line number; it generates both traceback and symbol table information. /DEBUG=TRACEBACK produces traceback information only; /NODEBUG generates neither. The default is /NODEBUG. Chapter 9 Symbolic discusses COBOL program /LIST[=file-spec] /NOLIST Controls whether If you use compiler, If the the you the compiler COBOL/C74 by default, the COBOL/C74 default. When debugging wusing does command specify /LIST, is you produces command not create executed can an in a output file /MAP /NOMAP /MAP causes the listing file: 2-4 VAX/VMS listing. interactive listing from control output file. a batch the type always compiler e ® @ Data Division Map Procedure Map External Subprograms e Data and Control ®@ RTS ® Segmentation Routines /NOMAP is USING THE to defaults to produce the Referenced PSECTs Referenced Map the default. VAX-11] COBOL-74 SYSTEM job, defaults the output file specification by where you place the command, as described in the VAX/VMS Command Guide. The the Debugger. mode, the /LIST is applied to the qualifier in Language User's LIS. following reports in the /OBJECT [=file-spec] /NOOBJECT Controls whether the compiler produces By default, the compiler produces file name as the input file and a an object file. file with the same of OBJ. The compiler also uses the default file type of OBJ when you include a file specification with the /OBJECT qualifier that does not have a file an object file type type. /VERB_LOCATION /NOVERB_LOCATION Indicates whether the output listing produced by the compiler shows the object location of each verb in the source program. The location appears on the line before the source line the verb is The default the compiler prints /NOWARNINGS Consider the which is /NOVERB_LOCATION. /WARNINGS /NOWARNINGS Controls whether the compiler messages as well as warning default, in used. to suppress following them. command prints informational diagnostic and fatal diagnostic messages. By informational diagnostics; line specify examples: COBOL/C74/DEBUG PROGA Produces an object module file PROGA.COB. file PROGA.OBJ from the source object module COBOL/C74/LIST/DEBUG/OBJECT=TESTB Al2 Uses the source TESTB.OBJ and a file source Al2.COB listing COBOL/C74/LIST/CROSS_REFERENCE in to produce file Al2.LIS. PAYROLL Uses the source file PAYROLL.COB to produce object module PAYROLL.OBJ and a source 1listing with cross reference in file PAYROLL.LIS. The debugger cannot reference data items by data-name 1in this module because the /DEBUG qualifier is not specified. COBOL/C74/LIST=RPTB.REP/DEBUG/MAP REPORTB.TXT Uses the source file REPORTB.TXT to produce object module REPORTB.OBJ and a source listing with map in file RPTB.REP. USING THE VAX-11] COBOL-74 SYSTEM 2-5 2.2.3 Error Message Summary If the compiler detects any errors during a compilation, it an error message summary on the system output device. message summary has the following format: C74 -- nnnnn ERROR(S), nnnnn displays The error FATAL NOTE If any fatal errors occur, the compiler does not generate an object file. 2.2.4 Some 2.3 Common COBOL-74 common errors to Command avoid Line when Errors entering COBOL-74 ) Omitting the /ANSI FORMAT qualifier are in conventional format. ° Including /LIST. contradictory ® Omitting want to file. version numbers compile other ° Forgetting to use a file you 1intend to use or default file type. LINKING COBOL-74 for qualifiers, from file than the type in <create command source such as lines programs /MAP are: that without specifications when you latest version of a source the a file specification when file with other than the PROGRAMS After you have compiled one or more source programs to produce object modules, vyou must link the object module(s) to create a program image that can then be executed. Linking resolves symbolic references 1in the object code and establishes absolute addresses for them. This section describes the procedure for creating executable images from object modules using the VAX/VMS LINK command. You will find further information in the VAX/VMS Command Language User's Guide and the VAX-11l Linker Reference Manual. To link object modules, LINK 2-6 enter a [/command-qualifiers] USING THE VAX-11 COBOL-74 LINK command file-spec(s) SYSTEM in the following format: [/file-qualifiers] where: /command-qualifiers specify output file options. file-spec specifies the /file-qualifiers specify input file options. input file(s) to be linked. You can enter multiple file specifications separated from each other by commas or plus signs (which are equivalent). Regardless of how many file specifications you specify, the LINK command produces only one executable image. If you do not specify a file type in an input file specification, the Linker assumes default file types, depending on the nature of the file. OBJ. of type file For example, object files are assumed to have a The VAX/VMS Command Language User's Guide discusses VAX-1l Linker default file types in detail. Default file types for output Command Language User's Guide. files are discussed in the VAX/VMS Consider the following command line: LINK TESTA,TESTB,SYSSLIBRARY:C74LIB/LIB This line causes the compiler to use two object modules TESTB.OBJ) to produce a single executable image (TESTA.OBJ and (TESTA.EXE). NOTE The command 1line must specify the library that contains the COBOL-74 RTS. The examples in this chapter specify: SYSSLIBRARY:C74LIB/LIB You can also specify the optional sharable RTS, which results in a smaller image file and sharing of physical memory when two or more COBOL images run at the same time. Link with the sharable RTS by specifying: SYSSLIBRARY:C74LIB/OPT use Before you can system manager must image, The SYS$SSYSTEM:C74LIB.EXE, procedure VAX/VMS your option, this install the sharable is as described SHARED. 1in the Operator's Guide. USING THE VAX-11] COBOL-74 SYSTEM 2-7 The following qualifiers However, you qualifiers qualifiers discussion that you will are find describes most complete in the references are discussed: Command the likely command to use for discussions already qualifiers qualifiers linking of all mentioned. and file COBOL modules. LINK The command following Default /BRIEF /[NO]CROSS_REFERENCE / [INO]DEBUG[=file-spec] / [NO]EXECUTABLE [=file~spec] /FULL / [NO]JMAP[=file-spec] / [NO] TRACEBACK /NOCROSS_REFERENCE /NODEBUG /EXECUTABLE /NOMAP /TRACEBACK File qualifiers /INCLUDE=module-name[,...] /LIBRARY /OPTIONS Command Qualifiers: /BRIEF Produces a you also line. The brief brief memory allocation map /MAP; /BRIEF must specify form of the map summary contains: l. A 2., A list of all object modules included in‘the image. 3. A summary of file. Use /BRIEF only 1if fellow /MAP on the command of the image link-time characteristics. performance statistics. Example LINK/MAP/BRIEF PROGA,SYSSLIBRARY:C74LIB/LIB ~/CROSS_ REFERENCE /NOCROSS REFERENCE Controls whether the Linker the memory allocation map. produces Use /CROSS REFERENCE only if /CROSS_REFERENCE must follow /MAP on 2-8 USING THE VAX-1ll COBOL-74 SYSTEM a symbol cross-reference you also the command specify line. on /MAP; Example LINK/MAP/CROSS_REFERENCE PROGA ,SYSSLIBRARY:C74LIB/LIB The the symbol cross-reference 1image, its value, and lists each global symbol all modules in the image referenced that refer in to it. The default is /NOCROSS REFERENCE. /DEBUG[=file-spec] /NODEBUG Controls whether the Linker includes a debugger in the image. If the object module contains local symbol table information for the Debugger, specify /DEBUG to include the information in the image as well. You can include the optional file specification to specify a user-defined debugger; the default file type is OBJ. 1If you specify /DEBUG without a file specification, the default VAX/VMS Debugger is linked with the 1image. You will £find more information on using /DEBUG in the VAX/VMS Symbolic Debugger Reference The Manual. default Chapter 9 is /NODEBUG. discusses COBOL program debugging. /EXECUTABLE [=file-spec] /NOEXECUTABLE Controls whether the optionally supplies Linker <creates an executable image and a file specification for the output image file. By default, the Linker creates an executable file name as the first input file and a file image with the type of EXE. Use /NOEXECUTABLE to see the results of linking the Linker would need to create an image file. same in less time than Examples: LINK/EXECUTABLE=NEWPROG.IMG/MAP PROGA,SYSSLIBRARY:C74LIB/LIB LINK/NOEXECUTABLE/MAP PROGA,SYSSLIBRARY:C74LIB/LIB /FULL Produces a full memory allocation map listing. Use /FULL only 1if you also specify /MAP; /FULL must follow /MAP on the command line. USING THE VAX-11l COBOL-74 SYSTEM 2-9 A full map listing contains: 1. All information contained 2. Detailed descriptions of each program section and image 3. Lists of global section in the image in the brief listing. file. symbols by name and value. Example LINK/MAP/NOEXEC/FULL PROGA,SYSSLIBRARY:C74LIB/LIB /MAP[=file-spec] /NOMAP Controls whether the Linker produces a memory allocation map listing. You can specify the file specification otherwise, the name of the output file the first input file, with a file type to name the is the same as of MAP. map file; the name of When you specify /MAP, you can also specify /BRIEF, /FULL, or /CROSS REFERENCE to control the contents of the map. 1If you specify none of these qualifiers, the map contains: 1. All 2. A list of user-defined 3. A list of user-defined program The default the information contained global symbols sorted by name. sections. is /NOMAP. /TRACEBACK /NOTRACEBACK Controls whether the Linker image in the brief listing. includes traceback information in the file. By default, the Linker includes traceback information so the system can trace the call stack when an error occurs. If you specify /NOTRACEBACK, you will get no traceback reporting when errors occur. If you specify /DEBUG, the Linker also assumes /TRACEBACK. File Qualifiers /INCLUDE=module-name[, ...] Indicates that the associated file specification refers object module library (the default file type is 2-10 furthermore, it the module(s). specified USING THE causes VAX-11l the COBOL-74 Linker SYSTEM to unconditionally to an OLB) ; include only You must specify at least one module-name. Specify more by separating them with commas and enclosing the than 1list one 1in parentheses. You can also specify /LIBRARY when you specify /INCLUDE to cause the Linker to search the library for unresolved references it unconditionally includes the specified module(s). after Examples: LINK PROGA,LIBA/INCLUDE=MODA,SYSSLIBRARY:C74LIB/LIB The Linker MODA produce LINK links from PROGA.OBJ the 1library and the file module LIBA.OLB to PROGA.EXE. PROGA,LIBA/INC=(MODA,MODB)/LIB,SYSSLIBRARY:C74LIB/LIB The Linker MODA links and LIBA.OLB. from Because of qualifier, the LIBA.OLB any in PROGA.OBJ MODB for PROGA.OBJ, the Linker other MODA, and the the file /LIBRARY file will also unresolved and modules library search references MODB. /LIBRARY Indicates that the file specification refers to a library file to be searched to resolve any undefined symbols in the input file(s). If the file Linker specification assumes the library as the first /INCLUDE qualifier does default not include file input file to indicate type a file OLB. unless vyou which modules Do type, not the specify also specify in the library a the are to be unconditionally included in the image. You <can use both /INCLUDE and /LIBRARY; this causes the Linker to include the specified modules, then search the 1library for unresolved references. Examples LINK PROGA,LIBA/LIBRARY,SYSSLIBRARY:C74LIB/LIB The Linker references LINK searches in LIBA.OLB PROGA.OBJ to for unresolved create PROGA.EXE. LIBA/LIB/INCLUDE=MOD1/EXEC=PROG,SYSSLIBRARY:C74LIB/LIB The Linker LIBA.OLB, includes then the module searches unresolved references in MODI. is an executable image PROG.EXE. USING THE VAX-11] MOD1l LIBA.OLB COBOL-74 The SYSTEM from for result 2-11 /OPTIONS to options of 1list a contains Indicates that the input file /OPTIONS file specification does not the If 1linking. control OPT. include a file type, the Linker uses the default file type Linker 2.4 Reference are file The contents of the option described in VAX-1l the Manual. EXECUTING A COBOL IMAGE an executable «create to 1linked When the object modules have been image in the the execute to command RUN the use can you image, SPECIAL-NAMES the in OFF If you specified SWITCH ON or process. paragraph of the COBOL source program, you can specify the status of image execution. switches before or during Setting and Resetting Program Switches 2.4.1 COBOL program switches exist as the logical name be defined program switches: can for COBSSWITCHES, process, group, or system. the command (you can also use the ASSIGN command) which Use the DEFINE to change the status of "switch-list" DEFINE COBSSWITCHES switch numbers where switch-list is a list of one or more program be enclosed 1in must 1list entire The commas. by separated (1-16) switch-list; A switch is set ON if its number appears in the quotes. otherwise, it is set OFF. Examples DEFINE COBSSWITCHES "1,5" Sets switches 1 and 5 ON; sets all others OFF. DEFINE COBSSWITCHES "4,5,6,7,8,9,10,11,12,13,14,15,16" Sets all switches ON except 1, DEFINE COBSSWITCHES Turns OFF all " 2, and 3. " switches. The order of evaluation of 1logical name assignments 1is: process, System and group logical name assignments (including system. group, (or changed are they COBOL program switch settings) continue until Process logical name assignments exist until either they deassigned). terminates. process the until or deassigned) (or changed are of system and group assignments of aware be should you Therefore, COBSSWITCHES before executing an image 1if you do not define 1t yourself 2-12 in your process. USING THE VAX-11l COBOL-74 SYSTEM You can guarantee setting switches can confirm SHOW You can the use DEASSIGN DEASSIGN also COBOL by an using image the program switches that them. following uses by You command: COBSSWITCHES process; active: of executing settings the then l. switch status before your from can intended just LOGICAL name You the command to the group status of remove or the system switch-setting logical name 1logical (if any) is COBSSWITCHES change Interrupt the the image with command to switches CTRL/Y during execution: or STOP a literal COBOL statement. 2. Use 3. a DEFINE Continue the do force not command 2.4.2 Use The the If you command do a CONTINUE interrupted executes to another execute [/command-qualifier] not specify command uses The command RUN with the switch settings. command. image to Be exit sure by that you entering a image. RUN Command RUN RUN that image change the a default has two file file an image: file-spec type 1in type EXE. optional file command the RUN if the qualifiers: /DEBUG Specify /DEBUG to request the debugger at image was not linked with the debugger. /DEBUG if /NOTRACEBACK was specified when /NODEBUG Specify /NODEBUG if you do time for an image that was specification, execution time However, you cannot use the image was linked. not want the debugger at execution linked with the /DEBUG qualifier. Examples RUN PROGA Executes PROGA.EXE. RUN PROGB.ABC Executes the RUN/NODEBUG You can separate also use process. PROGA the RUN (See image named PROGB.ABC. Executes PROGA.EXE without the that may have been linked with (Process) the VAX/VMS command to Command USING THE execute Language VAX-11 the image User's COBOL-74 debugger it. as a Guide.) SYSTEM 2-13 CHAPTER NON-NUMERIC 3.1 CHARACTER HANDLING INTRODUCTION COBOL programs hold their data in fields their source programs. These compilation to remain the same size resulting object program. The data descriptions of the as belonging to any of three or 3 numeric class. Numeric whose sizes fields are throughout are described thus "fixed" the 1lifespan in during of the fields in a COBOL program describe them data classes -- alphanumeric, alphabetic, class data items contain only numeric values, alphabetic <c¢lass only A-Z and space, but alphanumeric class data items may contain values that are all alphabetic, all numeric, or a mixture character of alphabetic from the ASCII bytes, character numeric bytes, or, in fact, any set. Further, these three classes are subdivided into five categories: alphabetic, numeric, numeric edited, alphanumeric edited, and alphanumeric. Every elementary item except for an index data item belongs to one of the classes and further to one of the categories. The class of a group item is treated at run time as alphanumeric regardless of the classes of subordinate elementary items. For alphabetic and numeric (data 1items) class and category are synonymous. An alphabetic (A-Z and field space) is a field declared to contain only alphabetic characters. An alphanumeric class field that is character is called an alphanumeric declared to contain category field. any ASCII If the data description of an alphanumeric class field specifies that certain editing operations will be performed on any value that is moved into it, that field is called an alphanumeric or numeric edited category When reading between the field. item the the class contains following or sections category should of always of this chapter, a data item and be kept in mind. the this actual distinction value that and alphanumeric, alphabetic, to refers text the Sometimes This is to alphanumeric edited data items as non-numeric data items. distinguish them from items that are specifically described as numeric items. Regardless of the class of an item, it is usually possible to store a value 1in the item, at run time, that is "illegal". Thus, non-numeric into a field described as numeric ASCII characters can be placed class, and an alphabetic class field may be loaded with non-alphabetic characters. the To increase readability, the following sections occasionally omit however, the reader should item; an when describing "class" word as regard the descriptive word, numeric, alphabetic, or alphanumeric, to specifically applies it unless item an of <class the to referring the value in the item. This chapter discusses non-numeric class data and the non-arithmetic, non-input-output operations that manipulate this type of data. 3.2 DATA ORGANIZATION group 1into organized Usually, the data areas in a COBOL program are A group item is a data item items with subordinate elementary items. with items) (elementary items that is followed by one or more data valued higher no has item elementary An numbers. level valued higher subordinate number. level (except for certain All of the data areas used by COBOL programs registers and switches) must be described in the Data Division of the The compiler allocates memory space for these fields source program. and fixes them in size at compilation time. on a general discuss, The following sub-sections (3.2.1 and 3.2.2) level, how the compiler handles group and elementary data items. 3.2.1 Group Items The size of a group item is the total size of the data area occupied The compiler considers group items. elementary subordinate its by software the Thus, items. DISPLAY alphanumeric be to items they had been described as PIC X() if as items manipulates group items, and ignores the structure of the data contained within them. 3.2.2 Elementary Items The size of an elementary item is determined by the number of For allowable symbols it contains that represent character positions. example, 3-2 consider NON-NUMERIC figure 3-1. CHARACTER HANDLING 01 TRANREC. 03 FIELD-1 03 FIELD-2 PIC X(7). PIC S9(5)V99. Figure 3-1 Field Sizes Both fields seven consume seven bytes of memory; alphanumeric bytes while FIELD-2 however, FIELD-1 two 8-bit of may refer bytes). Thus, a word with no to that field. In effect, not words. with the Records items the OCCURS (a 01 that I/0 verbs field may begin in the left on the function of any effect the compiler sees memory as a continuous This becomes particularly important when clause level have Procedure the a decimal contains and an operational sign. Although certain verbs handle these two classes of data differently, the data, in either case, occupies seven bytes of VAX-1l memory. COBOL operations on such fields are independent of the mapping of the field into VAX-11 memory words (l6-bit words that hold byte contains Chapter entry and level number Division require VAX-1l1 a (see of of records file be system Table its 77 automatically that COBOL-74 all 5, aligned reads on entries) literal even on word and right-hand that a bytes, table Handling). all begin or operations array of declaring subordinate and digits byte values data in addresses. boundaries writes and given integral because numbers of words. Non-input-output verbs do not require alignment of the data. However, when two fields are aligned identically, the processing verb can sometimes increase its efficiency by processing them a word at a time rather that a byte at a time. In all cases, automatic word alignment of literals, records, and/or items increase the opportunity for more efficient processing. 3.3 SPECIAL CHARACTERS COBOL ASCII allows the character characters devices. a 77 manner can alphabetic to manipulate any as alphanumeric are control characters, Generally, alphanumeric that move user set attaches and and compare numeric no "meaning" these of the data 128 even characters of though many of which usually control data manipulations are to control an 8-bit characters input/output performed in byte. Thus, in same the the the the user manner as characters. Although the object program can manipulate all ASCII characters, certain control characters cannot appear in non-numeric literals since the compiler uses them to delimit the source text. Further, the keyboards of the console and keypunch devices have no convenient input key for place many them of into the special non-numeric characters, thus making it difficult to literals. NON-NUMERIC CHARACTER HANDLING 3-3 Special program characters may be by placing the numeric COMP Consider the field the even and placed binary redefining following byte of a into value word example of that of corresponds field to the of as the object into a character alphanumeric DISPLAY. (Keep in mind bits of a binary character as a 1l-word low-order that | 01 LF-COMP 01 LF PIC 999 01 01 01 01l HT-COMP PIC 999 COMP VALUE 9. TAB REDEFINES HT-COMP PIC X. CR-COMP PIC 999 COMP VALUE 13. CR REDEFINES CR-COMP PIC X. REDEFINES COMP LF-COMP Redefining sample coding COMP 1item with (The second byte level, since sized fields.) Use fields special redefinition. word.) The data the the in of the Set Reference PIC 3-2 introduces then redefinition at table Manual in to 10. X. Figure 3-2 Special Characters value, redefinition Character Language Figure a decimal VALUE this each redefines need not level does Appendix determine B the be it a single described not of as require the decimal at 01 identically VAX-11] value byte. for the COBOL-74 any ASCII character. 3.4 TESTING NON-NUMERIC 3.4.1 FIELDS Relation Tests An IF statement that contains a relation condition (greater-than, less-than, equal-to, etc.) can compare the value in a non-numeric data item with another value and use the result to alter the flow of control in the program. An IF statement either cannot the of be with a relation which may be literals. 1If relation condition an the has relation a truth Figure (The not or exists value of a compares literal, between two except the two operands, that both operands, true. 3-3 illustrates the general format of a relation condition. relational <characters ">," "<," and "=," although required, are underlined to avoid confusion with other symbols such as greater-than-or-equal-to.) 3-4 <condition identifier NON-NUMERIC CHARACTER HANDLING IS IS IS IS identifier-1 literal-1 arithmetic-expression-1 [NOT] [NOT] [NOT] [NOT] GREATER THAN LESS THAN EQUAL TO > IS [NOT] < IS [NOT] = identifier-2 literal-2 arithmetic-expression-2 Figure 3-3 Relation Condition When coding a relational reserved word. considers it relational meanings of When and the operator the operator, the next that leave reserved key word defines relational a word or the space NOT relational character Figure 3-4 greater than [NOT] GREATER THAN The first IS [NOT] > (or not The first (or not The (or first operand not equal to) of Figure 3-4 the Relational [NOT] LESS < IS [NOT] IS [NOT] EQUAL = THAN TO The 3.4.1.1 class Classes operands each class comparison of of Meanings of Data and - each software to be one shows the MEANING IS [NOT] after the comparison. | IS and present, operators. OPERATOR IS before is COBOL operand greater operand less allows non-numeric is than) class is than) the less the second operand. than second operand. is equal to the second operand. Operators comparison operands; data slightly differently. For two numeric operands regardless of both however, numeric it example, it of the formats handles allows a specified in their respective USAGE clauses, but requires that all other comparisons (including comparisons of any group items) be between operands with the same usage. It compares numeric class operands with respect to their algebraic non-numeric) class operands values and non-numeric (or a numeric and a with respect to a specified collating sequence. If only item or manner one an in of the integer which non-numeric the operands literal is and software operand. numeric, it must handles Consider the it must be an be DISPLAY usage; numeric operands following two integer depends types data further, of on the the non-numeric operands: l. If the non-numeric operand 1is an elementary item or a literal, the software treats the numeric operand as if it had been moved into an alphanumeric data item (which is the same size as the numeric operand) and then compared. This causes any operational sign, whether carried as a separate character or as an overpunch, to be stripped NON-NUMERIC from the numeric CHARACTER HANDLING item; 3-5 thus, it appears to be an unsigned quantity. 1In addition, if the picture-string of the numeric item contains trailing P characters indicating that there are assumed integer positions that are not actually present, these are filled with zero digits during the operation of stripping any sign that 1is present. Thus, an item with a picture-string of S9999PPP is moved to a temporary 1location where it 1is described with a picture-string of 9999999. 1If its value is 432J (-4321), the value in the temporary location will be 4321000. The numeric part in the comparison. 2. digits, | stored as ASCII bytes, take If the non-numeric operand is a group 1item, the software treats the numeric operand as if it had been moved into a group item (which is the same size as the numeric operand) and then compared. This 1is equivalent to a "group move". The software ignores the description of the numeric field (except for length) and, therefore, includes any operational sign, whether carried as a separate character or as an overpunch, 1in its length. (Overpunched characters are never ASCII numeric digits, but characters in the range of from A through R, , or .) Thus, the sign and the digits, stored as ASCII bytes, take part in the comparison, and zeroes are not supplied for P characters in the picture-string. The compiler will not accept a comparison between a non-integer numeric operand and a non-numeric operand, and any attempt to compare these two items will cause a diagnostic message at compile time. 3.4.1.2 The Comparison Operation - If the two operands are acceptable, the software compares them byte for byte starting at their left-hand end. It proceeds from 1left to right, comparing the characters in corresponding character positions until it either encounters a pair of unequal characters or reaches the right-hand end of the longer operand. If the software encounters a pair of unequal characters, it considers their relative position in the collating sequence. The operand with the character that is positioned higher in the collating sequence 1is the greater If the though ASCII If operand. operands have the shorter spaces all of the (hex different lengths, the comparison operand were extended on the right 20) pairs of to make them characters both compare equal. 3-6 NON-NUMERIC the CHARACTER HANDLING same proceeds as by sufficient length. equally, the operands are 3.4.2 Class Tests An IF statement ALPHABETIC) can DISPLAY only) and the use to that test contains the value determine result to if alter it the a class 1in a contains flow of condition (NUMERIC or non-numeric data item (USAGE numeric control in or alphabetic the data program. Figure 3-5 illustrates the general format of a class condition. If the data item consists entirely of the ASCII characters 0123456789 with or without the operational sign, the <class condition would determine that it 1is NUMERIC. If the item consists entirely of the ASCII characters A through Z and space, the <class condition would determine that it is ALPHABETIC. NUMERIC identifier IS [NOT] ALPHABETIC Class Figure 3-5 Condition, General Format When the reserved word, NOT, is present, the software considers it and the next Kkey word as one class condition that defines the class test to be executed; for example, NOT NUMERIC 1is a truth test for determining if an operand contains at least one non-numeric byte. If the item being tested was described as a numeric data item, it may only be tested as NUMERIC or NOT NUMERIC. (For further information on using class conditions with numeric items, see Chapter 4.) The NUMERIC test cannot examine an item that was described either as alphabetic or as a group item containing elementary items indicate the presence of operational signs. 3.5 whose data descriptions DATA MOVEMENT COBOL provides three statements (MOVE, STRING, and UNSTRING) that perform most of the data movement operations required by business-oriented programs. The MOVE statement simply moves data from one field to another. The STRING statement concatenates a series of sending fields into a single receiving field. The UNSTRING statement disperses a single sending field into multiple receiving fields. Each has its uses and 1its 1limitations. This section discusses data movement situations which take advantage of the versatility of these statements. The MOVE statement handles the majority of data movement operations on character strings. However, the MOVE statement has limitations in 1its ability to handle multiple fields; for example, it cannot, by itself, concatenate a series of sending fields into a single receiving field or disperse a single sending field into several receiving fields. NON-NUMERIC CHARACTER HANDLING 3-7 Two MOVE together been statements will, into a third "subdivided" sending fields with 1in however, bring the contents of two fields (receiving) field if the receiving field has subordinate size. 1If the third field and they then the receiving field will elementary other fields items are to that match be the concatenated differ in size from the first two require additional subdivisions two into fields, (through redefinition). Another method subdivide "table" are the of a of concatenation receiving single characters field character 1in the with the into single field that receiving MOVE statement character occurs field, and fields, as many execute Two MOVE statements sending field can the move then can left-most second also several end MOVE be used to receiving of the disperse fields. sending concatenation handled quite and The THE MOVE MOVE following dispersion easily following sections in detail. 3.6 statement by (3.6, the 3.7, and can field move the The to the data movement wusing contents a MOVE of a one statement receiving right-most a there as time, field. first to field; the sending field to another receiving field. (The second receiving field must first be described with the JUSTIFIED clause.) Characters from the middle of the sending field cannot easily be moved to any receiving field without extensive redefinitions of the sending field or a character-by-character movement loop (as with concatenation). The the to times a loop which moves each sending field, a character at a subscript that moves continuously across the receiving 1is creating limitations of STRING and UNSTRING the MOVE 3.8) discuss these end of statement are statements. three The statements STATEMENT statement moves illustration Format Format the contents shows the two of one formats field of into the another. MOVE The statement. 1 MOVE FIELDl1 TO FIELD2 MOVE CORRESPONDING 2 FIELD1 TO FIELD2 NOTE Format FIELDl is receiving contents size, the name field. of FIELDl class, or 2 1is discussed NON-NUMERIC Section of the sending field and The statement causes into FIELD2. usage; and the two fields they may be CHARACTER HANDLING 3.6.6. FIELD2 The items. 3-8 in is the software need either name to not be group or of move the the the same elementary If the them two on fields one end are or not the the same length, other -- other end. The movement items is discussed below. and of group the A point alter to the 3.6.1 remember contents Group when of will the software truncate items and or pad will (with non-numeric align spaces) elementary using the MOVE statement is that it will character position in the receiving field. every Moves If either the sending or receiving field is a group item, the software considers the move to be a group move. It treats both the sending and receiving fields in a group move as if they were alphanumeric class fields. If the sending field is a group item and the receiving field 1s an elementary item, the software ignores the receiving field description JUSTIFIED editing 3.6.2 (except clause); on the for the size therefore, receiving the description, software in conducts field. bytes, no and any conversion or | Elementary Moves If both fields of a MOVE statement are elementary items, their data description clauses control their data movement. (If the receiving field was described as numeric or numeric edited, the rules for numeric moves -- see Chapter 4, Numeric Character Handling -- control the data movement.) The following table elementary moves. shows the 1legal Table SENDING Legal Non-Numeric FIELD CATEGORY (and illegal) non-numeric 3-1 Elementary Moves RECEIVING FIELD CATEGORY ALPHABETIC ALPHANUMERIC ALPHANUMERIC EDITED ALPHABETIC Legal Legal ALPHANUMERIC Legal Legal Legal Legal ALPHANUMERIC EDITED NUMERIC INTEGER (DISPLAY ONLY) Illegal Legal EDITED Illegal Legal NUMERIC NON-NUMERIC CHARACTER HANDLING 3-9 In all of the legal moves shown above, the software treats the sending field as though it had been described as PIC X(). If the sending field description contains a JUSTIFIED clause, the clause will have no effect on the move. If the sending field picture-string contains editing characters, the software uses them only to determine the field's size. Numeric class data must be in DISPLAY (byte) format and must be an integer. If the description of the numeric data item indicates the presence of an operational sign (either as a character or an overpunch) or if there are P characters in the picture-string of the numeric data itenm, the software first moves the item to a temporary location. During this move, it removes the sign and fills out any P character positions with =zero digits. It then uses the temporary value (which may be shorter than the original if a separate sign were removed, or 1longer if P character positions were filled in with zeroes) as the sending field as if it had been described as PIC category were alphanumeric. X(), that 1is, as 1if 1its If the sending item is an unsigned numeric class field with no P characters 1in its picture-string, the software does not move the item to a temporary A numeric location. integer data item sending justification of the receiving field. shorter than the receiving field, the field with In legal, spaces. field has no effect on the 1If the numeric sending field is software fills the receiving non-numeric elementary moves, the receiving field actually controls the movement of data. All of the following items, in the receiving field, affect the move: (1) the size, (2) the presence of editing characters in 1its description, and (3) the presence of the JUSTIFIED RIGHT clause in its description. The JUSTIFIED clause and editing characters are mutually exclusive; therefore, the two classes are discussed separately below. When a field that contains no editing characters or JUSTIFIED clause in its description 1is wused as the receiving field of a non-numeric elementary MOVE statement, the statement moves the characters by starting at the 1left-hand end of the fields and scanning across, character-by-character to the right. If the sending item 1is shorter than the receiving 1item, the software fills the remaining character positions with 3.6.2.1 editing spaces. Edited Moves - Alphabetic or alphanumeric fields may characters. Consider the following insertion characters. Alphabetic fields will accept however, alphanumeric fields will accept all B -- blank insertion position 0 -- zero insertion position / —=- slash insertion position. 3-10 NON-NUMERIC CHARACTER HANDLING contain editing only the B character; three characters. When a field that contains an insertion editing character 1in 1its picture-string is used as the receiving field of a non-numeric elementary MOVE statement, each receiving character position that corresponds to an editing character receives the insertion byte value. Figure 3-6 illustrates the use of such symbols with the statement, MOVE FIELD1l TO FIELD2. (Assume that FIELDl was described as PIC X(7).) FIELD?2 FIELDI PICTURE-STRING CONTENTS AFTER MOVE “ 070476 XX/99/XX 07/04/76 04JUL76 99BAAAB99 04 JUL 2351212 XXXBXXXX/XX/ 235 1212/ 123456 0XBOXBOXBOX 01 Figure Data Movement with 02 76 03 [/ 04 3-6 Editing Symbols Data movement always begins at the left end of the sending field, and moves only to the byte positions described as A, 9, or X in the receiving field picture-string. When the sending field is exhausted, the software supplies space characters to fill any remaining character positions (not insertion positions) in the receiving field. If the receiving field becomes exhausted before the last character is moved from the sending field, the software ignores the remaining sending field characters. 3.6.2.2 Justified Moves - A JUSTIFIED RIGHT clause 1in the data description of the receiving field causes the software to reverse its usual data movement conventions. (It starts with the right-hand characters of both fields and proceeds from right to left.) If the sending field is shorter than the receiving field, the software fills the remaining 1left-hand character positions with spaces. Figure 3-7 illustrates various data description situations MOVE FIELD1 TO FIELD2, with no editing. XXX CONTENTS the statement, FIELD2 FIELD1 PICTURE-STRING | for PICTURE-STRING (AND JUST CLAUSE) ABC XX AB XXXXX ABC XX JUST BC XXXXX JUST Figure CONTENTS AFTER MOVE ABC 3-7 Data Movement with No Editing NON-NUMERIC CHARACTER HANDLING 3-11 3.6.3 If a Multiple MOVE moves It has Receiving statement is Fields written with more the same sending field value to essentially the same effect as statements that subscripted fields, all have see the same section than one receiving field, it each of the receiving fields. a series of separate MOVE sending field. (For information on 3.6.4.) The receiving fields need have no relationship to each software checks the legality of each one independently, an independent move operation on each one. other. The and performs Multiple receiving fields on MOVE statements provide a convenient way to set many fields equal to the same value, such as during initialization code at the beginning of a section of processing. For example: 3.6.4 MOVE SPACES TO LIST-LINE, MOVE ZEROES TO EOL-FLAG, MOVE 1 TO COUNT-1, EXCEPTION-LINE, EXCEPT-FLAG, CHAR-PTR, NAME-FLD. NAME-FLAG. CURSOR. Subscripted Moves Any field of a MOVE statement may be subscripted and the referenced field may also be used to subscript another name 1in the same statement. When more than statement, the affects the situations: one receiving order results in of which the field the 1is named software move. Consider Situation 1 MOVE FIELD1(FIELD2) Situation 2 MOVE FIELDl TO TO FIELD2 1in the evaluates the FIELD2 the same MOVE subscripts following two FIELD3. FIELD3(FIELD2). Figure 3-8 Subscripted MOVE Statements In situation 1, the software evaluates FIELDl(FIELD2) only before it moves any data to the receiving fields. 1In effect it if the statement were replaced with the following statements: 3-12 MOVE FIELD1 (FIELD2) MOVE TEMP TO FIELD2. MOVE TEMP TO FIELD3. NON-NUMERIC TO TEMP. CHARACTER HANDLING once, is as In situation 2, the software before moving the data into it to FIELD2). Thus, it subscript wvalue. with the following 3.6.5 uses the In effect, statements: evaluates (but after newly stored it as is if MOVE FIELDl1 TO FIELDZ2. MOVE FIELD1 TO FIELD3(FIELD2). Common Errors, MOVE FIELD3(FIELD2) moving the data value the of immediately from FIELD1 FIELD2 statement were as the replaced Statement A most important thing to remember when writing MOVE statements 1is that the compiler considers any MOVE statement that contains a group item to be a group move. It is easy to forget this fact when moving a group 1item to an elementary item, and the elementary item contains editing characters, or a numeric integer. These attributes of the receiving field (which would determine the action of an elementary move) have no 3.6.6 Format Format 2 of - MOVE statement. in the action statement one When the 1in the receiving of a group move. CORRESPONDING from 1items the on MOVE items elementary items 2 the elementary MOVE effect allows group the programmer item to <corresponding sending field field whose another, phrase are 1is moved data-names to are to move multiple by using a wused, those single selected elementary identical. For NON-NUMERIC CHARACTER HANDLING 3-13 example: 01 A-GROUP. 02 MOVE 01 B-GROUP. FIELDI. 02 FIELD2. 03 A PIC X. 03 A PIC X. 03 B PIC 9. 03 C PIC XX. 03 C PIC XX. 03 E PIC XXX. 03 D PIC 99. 03 E PIC XXX. CORRESPONDING A-GROUP TO B-GROUP OR MOVE CORRESPONDING FIELDl TO FIELD2 The preceding examples are equivalent to the following series of MOVE statements: MOVE A OF FIELD1 TO A OF FIELD2 MOVE C OF FIELDl TO C OF FIELD2 MOVE E OF FIELDl TO E OF FIELD2 3.7 THE The STRING fields The STRING STATEMENT statement into a single statement function, has to a MOVE many the 1is forms; TO FIELDl software STRING does the MOVE of two simplest 1is or more sending statement. equivalent, Consider the 1in following size, or if the 1is equivalent sending to the FIELD2. DELIMITED BY Figure STRING Sample If the sending field difference between contents two fields are the same 1larger, the statement FIELDl1 STRING the field. non-numeric illustration; if field (FIELDl) statement, concatenates SIZE INTO FIELD2. 3-9 Statement is shorter than the receiving field, an important the STRING and MOVE statements emerges: the not fill statement may the receiving leave field some with portion of spaces. the Thus, receiving the field unchanged. Additionally, field with description. fills the insertions. 3.7.1 An the receiving field must be an elementary alphanumeric no JUSTIFIED clause or editing characters in 1its Thus, the data movement of the STRING statement always receiving field from 1left-to-right with no editing Multiple important Sending Fields characteristic of concatenate a sending Consider the following STRING FIELD1A series of example FIELD1B the of STRING the FIELD1IC INTO 3-14 NON-NUMERIC with STRING into is one DELIMITED BY SIZE 3-10 the CHARACTER HANDLING STRING its Statement ability receiving statement: FIELD2. Figure Concatenation statement fields to field. In this sending sample STRING statement, FIELDl1A, FIELD1B, and FIELD1C are all fields. The software moves them to the receiving field (FIELD2) in the order in which they appear in the statement, from left to right, resulting in the concatenation of their values. If FIELD2 is not large enough to hold all three items, the operation stops when it is full. 1If this occurs while moving one of the sending fields, the software ignores the remaining characters of that field and any other sending fields not yet processed. For example, if became full while receiving FIELD1B, the software would ignore rest of FIELD1B and all of FIELDIC. FIELD2 the If the sending fields do not fill the receiving field, the operation stops with the movement of the last character of the last sending item (FIELDIC in Figure 3-10). The software does not alter nor space-fill the remaining character positions of field. the the contents receiving The sending fields may be non-numeric 1literals and figurative constants (except for ALL literal). For example, the following statement sets up an address label with the literal period and space between the STATE and ZIP fields: STRING CITY SPACE STATE DELIMITED BY fields may statement (A-TABLE) subscript wuses into or also be INTO Figure 3-11 an STRING single as ZIP Sending subscripted. subscripts a " SIZE Literals Sending ". to field ADDRESS-LINE. Fields For concatenate (A-FOUR). (I, example, the of the elements course, following of a must table be a index-name.) A-TABLE(I) DELIMITED A-TABLE(I+1l) BY SIZE INTO A-TABLE(I+2) A-TABLE (I+3) A-FOUR. Figure 3-12 Sending Fields Indexed 3.7.2 The POINTER Phrase Although the STRING statement normally starts at the the receiving field, with the POINTER phrase it is it scanning at however, remains another point within the field. left-hand end of possible to start (The scanning, left-to-right.) NON-NUMERIC CHARACTER HANDLING 3-15 MOVE 5 TO P. STRING FIELDl1A FIELD1B INTO FIELD2 DELIMITED BY WITH POINTER SIZE P. Figure 3-13 Sample POINTER Phrase When the POINTER phrase 1is wused, the value of P determines the starting character position in the receiving field. In Figure 3-13, the 5 in P causes the software to move the first character of FIELDIA into <character position 5 of FIELD2 (the left-most character position of the receiving through 4 field is character position 1) and leave positions 1 unchanged. When the STRING operation is complete, the software leaves P pointing to one character position beyond the last character replaced in the receiving field. 1If FIELD1A and FIELDIB in Figure 3-13 are both four characters 1long, P will contain a value of 13 (5+4+4) when the operation is complete (assuming that FIELD2 is at least 12 characters long). 3.7.3 The DELIMITED BY Phrase Although the sending fields of the STRING statement are fixed in size at compile time, they frequently contain variable-length items that are padded with spaces. For example, a 20-character «city field may contain only the word MAYNARD and 13 spaces. A valuable feature of the STRING statement is that it may be used to move only the useful data from the 1left-hand end of the sending field. The DELIMITED BY phrase, written with a data-name or literal, performs this operation. (The delimiter instead of the word SIZE, may be a literal, a data item, a figurative constant, or the word SIZE. It may not be ALL literal since ALL literal has an indefinite length. When the phrase contains the word SIZE, the software moves each sending field, 1in total, until receiving Consider it either exhausts the the following STRING CITY field, or fills the example: SPACE STATE DELIMITED BY ". " SIZE Figure Delimiting AYER NON-NUMERIC \ MA. ZIP INTO ADDRESS-LINE. 3-14 with the Word If CITY is a 20-character field, the shown in Figure 3-14 might look like 3-16 sending field.) result of the the following: 01432 16 spaces CHARACTER HANDLING SIZE STRING operation A far more attractive operation produce the AYER, To on MA. printout can following: be produced 1 TO STRING DELIMITED INTO ", " BY STATE INTO ". " BY sample coding SPACE as a of pointing delimiter uses the position WITH POINTER P. WITH POINTER P. SIZE Figure character constant ZIP ADDRESS-LINE SPACE one STRING SPACE ADDRESS-LINE DELIMITED This the P. CITY STRING having 01432 accomplish this, use the figurative the sending field; thus, MOVE by as 3-15 a Delimiter pointer's beyond characteristic the last character replaced in to the receiving field to enable the second STRING statement to begin at a position one character past where the first STRING statement stopped. (The first STRING statement moves data characters until it encounters a space character STRING statement another literal, The delimiter statement names the to by separate and can it effect source operation simplifies a be match the the the lines, the for Thus, shown of the statement, debugging.) STRING CITY ZIP " a the shorter (Placing example, improves second field, single STRING has field statement the no program sending has operands effect on on the readability and | BY STATE SPACE ". DELIMITED INTO after following The STATE | within example. but DELIMITED "’ field.) phrase this SPACE. 2-character field BY the in delimiter the each preceding as the ZIP DELIMITED applies. as of 1literal, 5-character varied repeating which same -- adds n BY SIZE ADDRESS-LINE. Figure Repeating 3-16 DELIMITED BY the Phrase The sample STRING statement in Figure 3-16 cannot handle 2-word city names, such as New York, since the software would consider the space between the two words as a match for the delimiter SPACE. A longer delimiter, such as two or three solve this problem. Only when a delimiter will the movement stop spaces (non-numeric sequence of for data that NON-NUMERIC characters literal), can matches the item. CHARACTER HANDLING 3-17 With a 2-byte delimiter, the same statement simpler form: can | STRING CITY ", " STATE ". " DELIMITED BY " Delimiting be rewritten 1in a ZIP " INTO ADDRESS-LINE. Figure 3-17 with More Than One Space Character Since only the CITY field may contain two consecutive spaces (the entire STATE field is only two bytes long), the delimiter's search of the other fields will always be unsuccessful and the effect 1is the same as moving the Data movement under slower in execution full field (delimiting control of a data-name speed by SIZE). or literal than movement delimited 1s by SIZE. generally The example in Figure 3-17 illustrates a frequent source of error 1in the wuse of STRING statements to concatenate fields. The remainder of the receiving field is not space-filled as with a MOVE statement. If ADDRESS-LINE is to be printed on a mailing label, for example, the STRING statement should be preceded by the statement, MOVE SPACES TO ADDRESS-LINE. This guarantees a space fill to the right of the concatenated result. Alternatively, the last field concatenated by the STRING statement can be a field previously set to SPACES. (This sending field must be moved under control of a delimiter other than SPACE, of course.) 3.7.4 The OVERFLOW Phrase When the SIZE option of the DELIMITED BY phrase controls the STRING operation and the pointer value is either known or the POINTER phrase is not used, the programmer can tell, by simple addition, 1if the However, field is large enough to hold the sending fields. receiving if the DELIMITED BY phrase contains a literal or an identifier, or 1if the pointer wvalue is not predictable, it may be difficult to tell whether the size of the receiving field is adequate, and an overflow may occur. The ON OVERFLOW phrase at the end of the STRING statement tests for an overflow condition: STRING FIELD1A FIELD1B DELIMITED BY "C" INTO FIELD2Z2 WITH POINTER PNTR ON OVERFLOW GO TO PN57. The '3-18 Figure 3-18 ON OVERFLOW Phrase NON-NUMERIC CHARACTER HANDLING Overflow occurs when the receiving field is full and the software |is either about to move a character from a sending field or is considering a new sending field. Overflow may also occur if, during the initialization of the statement, the pointer contains a value that is either less than 1 or greater than the 1length of the receiving field. In this case, the software moves no data to the receiving field and terminates the operation immediately. The ON OVERFLOW phrase cannot distinguish the overflow caused by a bad initial value in pointer PNTR from the overflow caused by a receiving field that is too short. Only a separate test, preceding the STRING statement, can distinguish between the two. The following examples illustrate the overflow condition: DATA DIVISION. 01 FIELD1A 01 FIELD2 19 > W N - PROCEDURE . XXX VALUE STRING FIELDl1A STRING FIELD1A QUOTE DELIMITED BY SIZE INTO FIELD2. FIELD1A DELIMITED BY SIZE INTO FIELD2. STRING FIELDI1A FIELD1A DELIMITED STRING FIELD1A FIELD1A FIELD1A DELIMITED STRING FIELDlA BY "B" INTO FIELD1A "C" "AC" FIELD2 of POINTER INTO FIELD2. BY "C" executing the numbered Table Preceding "C" P. Figure 3-19 STRING Statements the Overflow Condition Results statements follow: 3-2 of Sample the Statements Value of FIELD2 after the STRING operation l. 2. 3. 4, 5. 6. "C" FIELD2. DELIMITED DELIMITED BY WITH Various Illustrating results BY FIELDI1A FIELDZ2. MOVE 2 TO P. STRING FIELD1A INTO The "ABC". XXXX. DIVISION. INTO 6. PIC PIC Overflow? ABC" ABCA ABAB AAAA ABAB AABA No Yes No No Yes No NON-NUMERIC CHARACTER HANDLING 3-19 3.7.5 All the Subscripted Fields in STRING Statements data-names used in the STRING statement may pointer value may be used as a subscript. be subscripted, and Since the pointer value might be used as a subscript on one or more of the fields 1in the statement, it is important to understand the order in which the software evaluates the subscripts and exactly when it updates the pointer. (The use of the pointer as a subscript is not specified by ANS-74 COBOL. Before using it, read the note at the end of this subsection.) The software updates the pointer of each sending field. Consider MOVE 1 STRING after it moves the last character the following sample coding: out TO P. "ABC" SPACE "DEF" INTO DELIMITED BY R WITH POINTER STRING SIZE P. Figure 3-20 Statement with Pointer During the movement of "ABC" into the receiving field (R), the pointer value remains at 1. After the move, the software increases the pointer value by 3 (the size of the sending field literal "ABC") and it takes on the wvalue 4. The software then moves the figurative constant SPACE and increases the pointer value by 1 and it takes on the wvalue 5. "DEF" is then moved and, on completion of the move, the software increases the pointer to its final value for this operation, 8. Now, consider the to subscripting: MOVE 1 STRING updating TO characteristics of the pointer when applied P. CHAR (P) CHAR (P) CHAR (P) CHAR(P) INTO DELIMITED R WITH BY POINTER SIZE P. Figure 3-21 Subscripting with the Pointer If CHAR is a l-character field in a table, the pointer increases by after each field has been moved and the software will move them into R as if they had been subscripted as CHAR(1), CHAR(2), CHAR(3), and CHAR(4). 1If CHAR is a 2-character field, the pointer increases by one two after if they each had field been has been moved and the fields will move into R as subscripted as CHAR(1l), CHAR(3), CHAR(5), and CHAR(7) . 3-20 NON-NUMERIC CHARACTER HANDLING Thus, the software evaluates the subscript of a sending immediately before it considers the item as a sending item. item once, The software evaluates the subscript of a receiving item only once, at the start of the STRING operation. Therefore, if the pointer is used changes occurring to the field, as a subscript on the receiving statement will not alter STRING the of execution pointer during the the choice of which receiving string is altered. and it too can be be subscripted, The software re-evaluates the delimiter Even the delimiter field can subscripted with the pointer. subscript once for each sending field, immediately before it compares Thus, by subscripting it with the pointer the delimiter to the field. This has value, the delimiter can be changed for each sending field. the peculiar effect of choosing the next sending field's delimiter based on the position, in the receiving field, into which its first For example, consider the following sample character will fall. coding: 01 DTABLE. 03 MOVE 1 STRING 7 X OCCURS D PIC TO TIMES. P. "ABC" |lABCl| "ABC" INTO DELIMITED BY D(P) R WITH POINTER P. Figure 3-22 Subscripting the Delimiter The following table shows the value that will arrive in the field shown (R) in receiving from the three "ABC" literals if DTABLE contains the values the left-hand column: Table Results 3-3 of the Sample Statements Preceding DTABLE Value R Value ABCDEFG (Unchanged) BCDEFGH AABABC CDEFGHI CCCCCCCC - ABABCABC ABABAB NON-NUMERIC CHARACTER HANDLING 3-21 NOTE The rules in this section, concerning subscripts 1in the STRING statement, are rules that are not specified by 1974 American National Standard COBOL. Dependence on these rules, particularly those involving the use of the pointer field as a subscript, may programs that will not perform way on other COBOL compilers. If the pointer subscript on produce the same field is not used any of the fields as a in the statement, the point at which software evaluates the subscripts immaterial to the execution of the is the statement. Thus, by avoiding the use of the pointer as a subscript, uniform results can be expected from all COBOL compilers that adhere to 1974 ANS COBOL. 3.7.6 The most common ® using ° 3.8 The The STRING Statement errors the made when word "TO" forgetting to write ) forgetting to initialize ° initializing ° forgetting when it is THE UNSTRING STATEMENT UNSTRING field to Common Errors, instead of STRING the pointer for disperses receiving to pointer; 0 instead space the fill of of contents UNSTRING FIELD1l equivalent sizes of the INTO Sample 3-22 NON-NUMERIC 1; the of receiving a single field sending fields. has many forms; the simplest is non-numeric MOVE statement. Consider the the sample statement 1s regardless of the relative are: SIZE"; statement a statements "INTO" "DELIMITED BY to provide desirable. statement into multiple the writing to two following MOVE FIELDl1 fields. FIELD2. Figure 3-23 UNSTRING Statement CHARACTER HANDLING equivalent in function illustration; TO FIELD2, sending The field be may (FIELDl1l) either a group item or an The receiving alphanumeric, or alphanumeric edited elementary item. field (FIELD2) may be alphabetic, alphanumeric, or numeric, but it cannot specify any type of editing. The If the receiving field is numeric, it must be DISPLAY usage. the of any contain may field receiving numeric picture-string of a the legal numeric description characters except for P and, of course, editing characters. The UNSTRING statement moves the sending field to numeric receiving fields as if the sending field had been described as an unsigned fills as it further, integer; automatically truncates or 2zero required. If the receiving field is not numeric, the software follows the rules It left-justifies the for elementary non-numeric MOVE statements. data in the receiving field, truncating or space-filling as required. (If the data-description of the receiving field contains a JUSTIFIED or truncating data, the software right-justifies the clause, space-filling to the left as required.) 3.8.1 Multiple Receiving Fields An important characteristic of the UNSTRING statement 1is 1ts ability Consider to disperse one sending field into several receiving fields. multiple with written statement UNSTRING the of example the following fields: receiving UNSTRING FIELDl1 INTO FIELD2A FIELD2B FIELD2C. Figure 3-24 Multiple Receiving Fields software The In this sample statement, FIELDl is the sending field. performs the UNSTRING operation by scanning across FIELDl from left to right. When the number of characters scanned is equal to the number of characters ‘in the receiving field, the software moves the scanned characters into the receiving field and begins scanning the next group of characters for the next receiving field. Assume that each of the receiving fields in the preceding illustration is five characters long, and that and FIELD2C) FIELD2B, (FIELD2A, of FIELD2A determines the size The long. FIELD1 is 15 characters number of characters for the first move. The software scans across FIELD] until the number of characters scanned equals the size of It then moves those first five characters to FIELD2A, (5). FIELD2A to the next (sixth) character position in FIELDI. scanner the sets and The size of FIELD2B determines the size of the next move. The from character across FIELDl software begins this move by scanning the size equals characters scanned of number the until six, position of FIELD2B (5). NON-NUMERIC CHARACTER HANDLING 3-23 The software FIELD2B, then moves and position-in sets FIELDl. this example) moved into and FIELD2C, the the sixth scanner through the to next the FIELD2C determines the causes characters 11 thus terminating this tenth characters (eleventh) size of the through UNSTRING 15 last move of to character FIELD1l (for to be operation. Each data movement acts as an individual MOVE statement, the sending field of which is an alphanumeric field equal in size to the receiving field. 1If the receiving field is numeric, the move operation will convert the would happen and were data if the to the numeric form. fields under discussion manipulating the values shown in For had the example, the consider what descriptions data following table: Table 3-4 Values Moved Into the Receiving Fields Based on the Value in the Sending Field FIELDI1 FIELD2A FIELD2B FIELD2C PIC PIC PIC PIC X(15). VALUE 1IS: is S9(5) LEADING ABCDE1234512345 XXXXX0000100123 FIELD2A X(5) ABCDE XXXXX an alphanumeric conducts an characters. elementary +12345 +00001 field and, S999Vv99 SEPARATE 3450 1230 therefore, non-numeric move the with software the simply first FIELD2B, however, has a leading separate sign that is not included its size. Thus, the software moves only five numeric characters generates a positive sign in the separate sign position. FIELD2C has an implied decimal point the right of it, plus an overpunched five 1in and two character positions to on the low-order digit. The sending field should supply five numeric digits; but, since the sending field 1is alphanumeric, the software treats it as an unsigned integer; it truncates the two high-order digits and supplies two zero digits for the decimal positions. Further, it supplies a positive overpunch sign, making the 1low-order digit a +0 (or the ASCII character, sign If { ) . character the sending (There or field receiving fields, If it reaches the of one of the characters remaining a into that character NON-NUMERIC point shorter in the than the sending sum the software ignores the end of the sending field receiving fields, the decimal point aligns for numeric data. 3-24 is no simple way to have UNSTRING recognize a decimal is with sign receiving field. positions with and zero fills CHARACTER HANDLING of field.) the sizes of the remaining receiving fields. before it reaches the end software moves the scanned It left-justifies and fills the spaces for alphanumeric data, or the remaining character positions Consider the following examples of a sending field that is too short. (The statement is UNSTRING FIELD1 INTO FIELD2A FIELDZ2B. FIELD2A is a 3-character alphanumeric field, and receives the first three characters of FIELDl (ABC) in every operation. FIELD2B, however, runs out of characters every time before filling. Since FIELD2A always contains the characters ABC, it is not Table VALUE 3-5 a Sending Field that Handling FIELDI PIC X(6) shown.) FIELD2B PICTURE 1IS: is Too Short FIELD2B Value after UNSTRING Operation 1IS: — DEF XXXXX ABCDEF 0024F 600 +0246 $99999 S9V999 S9999 ABC246 LEADING 3.8.2 SEPARATE The DELIMITED BY Phrase The size of the data to be moved can be rather phrase than by supplies UNSTRING figurative the the size of delimiter delimiters constants are controlled the receiving by field. a delimiter, The DELIMITED BY characters. quite flexible; (including ALL they can literal), or be 1literals, identifiers (identifiers may even be subscripted data-names). This sub-section discusses the use of these three types of delimiters. Subsequent sections cover multiple delimiters, the COUNT phrase, and the DELIMITER phrase. Subscripting delimiters is discussed at the end of this section under Consider figurative the Subscripted Fields following constant, sample SPACE, as in UNSTRING Statements. UNSTRING a delimiter: UNSTRING FIELD1 DELIMITED BY SPACE Delimiting Figure 3-25 with Space a statement; it | uses the INTO FIELDZ2. Character In this example, the software scans the sending field (FIELD1), searching for a space character. 1If it encounters a space, it moves to space all of the scanned (non-space) characters that precede that the receiving field (FIELD2). moves the entire sending field. If it finds no space character, it When it has determined the size of the contents of that field software moves the field, sending the following the rules for the MOVE Statement, truncating or zero filling as required. NON-NUMERIC CHARACTER HANDLING 3-25 The following table shows the results of an UNSTRING operation that delimits with a 1literal asterisk (UNSTRING FIELDl DELIMITED BY "*" INTO FIELD2). Results Table 3-6 Delimiting with of FIELD1 FIELD2 PIC PICTURE X(6) VALUE an Asterisk FIELD2 1IS: VALUE IS: AFTER UNSTRING ABCDEF XXX ABC X(7) ABCDEF XXX JUSTIFIED DEF * %k % % &k & XXX * ABCDE Ax*x%* XXX JUSTIFIED A 246%** S9999 12345%* S9999 XXX 024F SEPARATE 2345+ TRAILING 2468** S999V9 SEPARATE +4680 LEADING *246** If the 9999 delimiter 0000 matches the first character in the sending software considers the size of the sending field to movement operation still takes place, however, and fills field with spaces or zeroes depending on its class. A delimiter may also be applied multiple receiving fields: UNSTRING FIELDl1l INTO sample FIELDl finds instruction searching a match, scanner to the next that matched. It then matches the delimiter. 3-26 a it moves NON-NUMERIC an BY UNSTRING statement Figure 3-26 character the scanned character resumes the that has SPACE FIELDZ2B. Figure 3-26 with Multiple Receiving in for DELIMITED FIELD2A Delimiting The to field, be zero. The the receiving causes the that matches characters position scanning CHARACTER HANDLING Fields to the FIELDl software the to FIELD2A right for to delimiter. a of and the scan If sets it the character character that If the software finds a match, between the character that it moves all of first matched the the characters delimiter that and lie the character that matched on the second scan, and sets the scanner to the next character position to the right of the character that matched. (The DELIMITED BY phrase could handle additional receiving fields 1in the same manner as it handled FIELD2B.) The following table shows the results of an UNSTRING applies a delimiter to multiple receiving fields DELIMITED BY "*" INTO FIELD2A FIELD2B). Table operation that (UNSTRING FIELDl 3-7 Results of Delimiting Multiple Receiving Fields FIELD1 VALUES AFTER UNSTRING OPERATION PIC X (8) VALUE IS: FIELD2A PIC X (3) FIELD2B PIC X(3) ABC*DEF* ABCDE*FG A*XBkxkk* ABC ABC A DEF FG B *AB*CD** **ABCDEF A*BCDEFG AB A ABC**DEF A*kkkkkkp ABC A BCD The last two examples illustrate delimiter. Accordingly, the character and it may be preceded the limitations of delimiter may be by the word ALL. a single character longer than one The following table shows the results of an UNSTRING operation uses a 2-character delimiter (UNSTRING FIELDl1 DELIMITED BY "**" that INTO FIELD2A FIELD2B) : Table 3-8 Results of Delimiting with Two Asterisks FIELD1 PIC X (8) VALUE f VALUES AFTER UNSTRING OPERATION FIELD2A FIELD2B 1IS: PIC 4' XXX PIC XXX JUSTIFIED ABC**DEF ABC A*B*C*D* A*B AB***C*D AB**C*D* AB**CD* * AB***CD* AB*****CD AB AB AB AB. AB DEF C*D *D* CD CD* NON-NUMERIC CHARACTER HANDLING 3-27 Unlike the STRING statement, the UNSTRING statement accepts the ALL literal as a delimiter. When the word ALL precedes the delimiter, the action of the UNSTRING statement remains essentially the same as with one delimiter until the scanning operation finds a match. At this point, the software scans farther, looking for additional consecutive strings of considers the characters repetitions of that "ALL delimiter" the delimiter also match to be one, the two, delimiter three, or more item. It adjacent item. The following table illustrates the results of an UNSTRING operation that uses an ALL delimiter (UNSTRING FIELDl DELIMITED BY ALL "*" INTO FIELD2A FIELD2B). Table 3-9 Results of Delimiting with ALL Asterisks FIELDI PIC VALUES X (8) VALUE 1IS: AFTER UNSTRING OPERATION FIELD2A FIELD2B PIC PIC XXX XXX JUSTIFIED ABC*DEF* ABC DEF ABC**DEF ABC DEF Akkkkkk[ A F AXFx*xkk*k A F A*CDEFG A EFG The next table illustrates the results of an UNSTRING operation that combines ALL with a 2-character delimiter (UNSTRING FIELD1 DELIMITED BY ALL "**" INTO FIELD2A FIELDZ2B). Table 3-10 Results of Delimiting with ALL Double Asterisks FIELDI1 PIC X (8) VALUE 1IS: 3-28 VALUES AFTER UNSTRING OPERATION PIC XXX PIC XXX JUSTIFIED ABC**DEF H ABC DEF AB**DE* * l AB DE AkkkDkk* A *D INEEEE T A * NON-NUMERIC CHARACTER HANDLING In addition to unchangeable delimiters, such as figurative constants, delimiters may be designated Identifiers (which may even be subscripted data-names) delimiting. Consider the following sample statement: literals and by identifiers. permit variable UNSTRING FIELDl1 DELIMITED BY DELI INTO FIELD2A FIELDZ2B. Figure Delimiting with The data-name, DELl, must be 3-27 an Identifier alphanumeric. It may be a group or elementary item, and it may be edited. (Since the delimiter is not a receiving field, any editing characters will not effect its use, other than contributing to the size of the item.) If the delimiter a side effect of is discussed contains a subscript, the subscript may be varied as the UNSTRING operation. The evaluation of subscripts later in this section. 3.8.2.1 Multiple Delimiters - The UNSTRING statement has the ability to scan a sending field, searching for a match from a list of delimiters. various must be This list may contain ALL delimiters sizes. The connected by only requirement of the list the word and delimiters of is that delimiters OR. The following sample statement separates a sending field into three receiving fields. The sending field consists of three strings separated by the following: (1) any number of spaces, or (2) a comma followed by a single space, or (3) a single comma, or (4) a tab character, or (5) a carriage return character. (The ", " must precede the "," in the list if it is ever to be recognized.) UNSTRING FIELDl1 ALL " , " , DELIMITED BY SPACE " OR OR n" OR TAB OR CR INTO FIELD2A FIELD2B Figure Multiple Table 3-11 illustrates the (represented by the letter letter ASCII r) characters horizontal tab FIELD2C. 3-28 Delimiters potential of this statement. The tab t) and carriage return (represented by the represent single character and carriage return fields containing the characters. NON-NUMERIC CHARACTER HANDLING 3-29 Results of Table 3-11 the Multiple Shown Figure Delimiters 3-28 FIELD1 FIELD2A FIELD2B FIELD2C PIC PIC PIC PIC X(12) A,0,Cr XXX 9999 A 0000 A 0456 A 0003 9 AttBr A 0000 B A,,C A 0000 C ABC 4321 // At456, A E 3 ABCD, 9 4321,7% t--tab character, The COUNT Phrase 3.8.3 The in COUNT phrase stores the keeps length in a r--carriage track of return the user-supplied size data | XXX C | E character of the sending string and area. The length 0f a delimited sending field may vary widely (from zero to the full length of the field) and some programs may require knowledge of this length. For example, if it exceeds the size of the receiving field (which 1is fixed 1in size) some data may be truncated and. the program's logic may require this information. To use words the phrase, simply COUNT IN and an follow the receiving field 1identifier. Consider the name with the following sample statement: UNSTRING FIELD1l DELIMITED BY ALL "*" INTO FIELD2A COUNT IN COUNT2A FIELD2B COUNT IN COUNT2B FIELD2C. Figure 3-29 COUNT Phrase The In this sample statement, characters between in FIELD1l and place the the 3-30 size of delimiter the software will count the left-hand end of FIELD]l and that value into COUNT2A; thus, the first sending string. in the count (as it is not NON-NUMERIC CHARACTER HANDLING the number the first COUNT2A of asterisk contains The software does not include a part of the string). The software then counts the number of characters sending field and places that value into COUNT2B. in the second The phrase should be used only where needed; in this example the length of the string moved to FIELD2C is not needed, so no COUNT phrase follows it. If the field, receiving field is shorter than the value placed in the count the software truncates the sending string. (If the number of integer positions in a numeric field is smaller than the value placed into the count field, high-order numeric digits have been lost.) If the software finds a delimiter match on the first character it examines, it places a zero in the count field. The count field must be described as a numeric integer, either COMP or DISPLAY usage, with no editing symbols nor the character P in its picture-string. The software moves the count value 1into the count field according to the rules for an elementary numeric MOVE statement The COUNT phrase may be used only in conjunction with the DELIMITED BY phrase. 3.8.4 The DELIMITER Phrase The DELIMITER phrase causes the actual character or characters that delimited the sending field to be stored in a user-supplied data area. This phrase is most wuseful when: (1) the statement contains a delimiter 1list, (2) delimited the field, any and (3) one of the items in the list might have program logic flow depends on which one found a match. In fact, the DELIMITER and COUNT phrases could be used together and program logic flow could depend on both the size of the sending string and the delimiter character that terminated it. To use the DELIMITER phrase, simply follow the receiving field name with the words DELIMITER IN and an identifier. (The software places the delimiter character in the area named by the identifier.) Consider the following sample UNSTRING statement: UNSTRING FIELD1 ALL DELIMITED BY SPACE "," OR TAB OR OR CR INTO FIELD2A DELIMITER IN DELIMA DELIMITER IN DELIMB FIELDZ2C. FIELD2B Figure The After moving the 3-30 DELIMITER Phrase first sending string to FIELD2A, the software takes the character (or characters) that delimited that string and places it in DELIMA. DELIMA, then, contains a comma, or a tab, or a <carriage return, or any number of spaces. Since the delimiter string is moved under the rules of the elementary non-numeric MOVE statement, the software truncates or space fills with left or right justification (depending on its data description). NON-NUMERIC CHARACTER HANDLING 3-31 The software places its then moves the delimiting second character sending into string to FIELD2B and DELIMB. When a sending string is delimited by the end of the sending field (rather than a match on a delimiter) the delimiter string is of zero length. This causes the DELIMITER item to be space filled. The phrase should be used only where needed; in this example, the character that delimits the last sending string is not needed, sO no DELIMITER phrase follows The data item named alphanumeric item. be a group FIELD2C. in the DELIMITER phrase must be described as an It may contain editing characters and it may even item. When the DELIMITER and COUNT phrases appear 1in 3.8.5 The the <correct order are used together, they must (DELIMITER phrase preceding the COUNT phrase). Both of the data items named 1in these phrases may be subscripted or indexed. If they are subscripted, the subscript may be varied as a side effect of the UNSTRING operation. (The evaluation of subscripts is discussed in section 3.8.8.) Although of POINTER Phrase the UNSTRING the sending statement field, normally character position in the sending field scanning. (The starts at the the POINTER phrase permits the scanning, however, for the 1left-hand user software end to select a remains left-to-right.) to begin when a sending field 1is to be dispersed into multiple receiving fields, it often happens that the choice of delimiters, the size of subsequent receiving fields, etc. depend on the value in the first sending string or the character that delimited that string. Thus, the program may need to move the first field, hold 1its place 1in the sending field, and examine the results of the operation to determine how to handle the sending items that follow. This is done by using an UNSTRING statement with a POINTER phrase that fills only the first receiving field. When the first string has been moved to a receiving item, the software updates the pointer data item with a new position (one character beyond the delimiter that caused the interruption) to begin the next scanning operation. The program may then examine the new position, the receiving field, the delimiter wvalue, the sending string size, and resume the scanning operation by executing another UNSTRING statement with the same sending field and pointer data item. Thus, the UNSTRING statement can move one sending string at a time, with the form of each move being dependent on the context of the preceding string of data. | The POINTER phrase accompanying POINTER phrases statement. 3-32 must follow the 1last receiving item 1in the Consider the following two UNSTRING statements with their NON-NUMERIC and tests: CHARACTER HANDLING MOVE 1 TO UNSTRING P. FIELDl1 DELIMITED BY ": OR TAB OR CR OR ALL INTO FIELD2A DELIMITER IN SPACE DELIMA COUNT IN LSIZEA WITH POINTER PNTR. IF LSIZEA IF DELIMA IF = 0 GO TO NO-LABEL-PROCESS. = ":" IF PNTR > 8 GO TO BIG-LABEL-PROCESS ELSE GO TO LABEL-PROCESS. DELIMA = TAB GO TO BAD-LABEL PROCESS. UNSTRING FIELD1l DELIMITED BY The ... WITH POINTER PNTR. Figure 3-31 POINTER Phrase PNTR contains the current position of the scanner in the sending field. The second UNSTRING statement uses PNTR to begin scanning the additional sending strings in FIELDI. Since the software considers the left-most character position one, the to be character value returned by PNTR may be used to examine the next character. To do this, simply use PNTR as a subscript on the sending field (providing that the sending field is also described as a table of characters). For example, consider the following sample coding: 01 FIELDI. 02 FIELD1-CHAR OCCURS UNSTRING TIMES. FIELDI WITH IF 40 POINTER PNTR. FIELD1-CHAR(PNTR) = "X" ... Figure 3-32 Examining the Next Character By Using the Item as a Pointer Data Subscript Another way to examine the next character of the sending field 1is to use the UNSTRING statement to move it to a l-character receiving field. Consider the sample coding in figure 3-33. NON-NUMERIC CHARACTER HANDLING 3-33 UNSTRING FIELDI WITH POINTER PNTR. UNSTRING FIELDl1 INTO CHAR1 WITH SUBTRACT 1 FROM PNTR. IF CHAR1 = "X" ... POINTER PNTR. Figure 3-33 Examining the Next Character By Placing It Into a 1-Character Field The program must decrement PNTR in order for this case the one illustrated in Figure 3-32, since statement will increment the pointer value by 1. the to second work 1like UNSTRING The program must initialize the POINTER phrase data 1item before the UNSTRING statement uses it. The software will terminate the UNSTRING operation if the initial value of the pointer 1is. less than one or greater than the length of the sending field. (A pointer value that is less than one or greater than the 1length of the sending field causes an overflow condition. Overflow conditions are discussed in section 3.8.7.) | ‘ The POINTER and TALLYING phrases may be used UNSTRING statement; but, when both are used, together in the same the POINTER phrase must precede - 3.8.6 the TALLYING phrase. The TALLYING Phrase The TALLYING phrase counts the number received data from the sending field. of receiving fields that When an UNSTRING statement contains several receiving fields, the possibility exists that there may not always be as many sending strings as there are receiving fields. The TALLYING phrase provides a convenient method for keeping a count of how many fields were acted upon. MOVE 0 TO RCOUNT. UNSTRING FIELD1 DELIMITED BY INTO FIELD2A "," OR ALL SPACE FIELD2B FIELD2C FIELD2D FIELDZ2E TALLYING The 3-34 IN RCOUNT. Figure 3-34 TALLYING Phrase NON-NUMERIC CHARACTER HANDLING If the software has moved only three sending strings when it reaches the end of FIELDl, it adds 3 to RCOUNT. The first three fields (FIELD2A, FIELD2B, and FIELD2C) contain data from the operation, and the last two (FIELD2D and FIELD2E) do not. The TALLYING data item always contains the sum of its initial contents the number of sending strings acted upon by the UNSTRING command plus tally Thus, the programmer may want to initialize the just executed. count before each use. When used in the same statement with a POINTER phrase, the TALLYING phrase must follow the POINTER phrase and both phrases must follow all of the field names, the DELIMITER and COUNT phrases. The data 1items for both phrases must contain numeric integers, that is, be without both picture-strings; in their editing characters or the letter P or signed be may They usage. DISPLAY or COMP either be may items data unsigned and, if they are DISPLAY usage, they may contain any desired sign option. The data items for both phrases may be subscripted or indexed, or they may be used as subscripts on other fields in the statement. (The evaluation of subscripts is discussed in section 3.8.8.) A convenient use of the TALLYING phrase data item is as a subscript of a receiving field. Consider the following sample coding, which causes program control to execute the UNSTRING statement repeatedly until it exhausts the sending field. MOVE PARl1. 1 TO PNTR, TLY. UNSTRING FIELDl1 DELIMITED BY "," OR CR INTO FIELD2(TLY) DELIMITER IN DEL2 WITH POINTER PNTR TALLYING IF DEL2 = "," IN GO TO TLY. PARI. Figure 3-35 The POINTER and TALLYING Phrases Used Together This sample coding causes program control to loop through the UNSTRING FIELDl with across scan to PNTR, the pointer, using statement, until string sending a Each comma isolates successive executions. control reaches either a carriage return character or the end of FIELDl. If it reaches the end of the field without encountering a space into the a places software the character, return carriage delimiter field, DEL2, and control falls through the IF statement and out of the loop. Since the TALLYING data item, TLY, is increased by 1 after each data 1In effect it serves as a subscript on the receiving field. movement, array an this causes the software to unpack the value in FIELDl into Further, an array of COUNT data items can be fields. fixed-size of the supplied and loaded by the UNSTRING/TALLYING statement by adding to the coding in Figure 3-35, as is shown in Figure IN phrase COUNT 3-36. NON-NUMERIC CHARACTER HANDLING 3-35 COUNT IN C(TLY) Figure 3-36 Subscripting the COUNT Phrase With the TALLYING Data Item The TALLYING data item, in number of receiving fields is because the data to be used as above example, is one greater than upon by the UNSTRING operation. item must be initialized to a value of subscript for the first receiving item. order 3.8.7 the acted one the This in a The OVERFLOW Phrase The OVERFLOW phrase detects the overflow imperative statement to be executed when overflow condition exists when either of condition and provides an it detects the condition. An the following two situations occurs: l. The UNSTRING statement is about pointer data item contains a to be executed and its value of 1less than one or greater than the size of the sending field. When it detects this situation, the software executes the OVERFLOW phrase before it moves any data. Thus, the values of all of the receiving 2. fields remain unchanged. The UNSTRING statement has filled all of the receiving fields and data still remains in the sending field that has not been matched as a delimiter or included in a sending string. When it detects this situation, the software executes the OVERFLOW phrase after 1t has executed the UNSTRING statement. Thus, the values of all of the receiving fields are updated, but some data has not been moved. If the UNSTRING operation causes the scanner the sending field (thus exhausting it), the the to move off the software will not OVERFLOW phrase. end of execute » Consider the following set of instructions, which <cause program control to execute the UNSTRING statement repeatedly until it exhausts the sending field. The TALLYING data item is a subscript indexing the receiving field. (Compare this 1loop with the one in Figure 3-35, which accomplishes MOVE PARl. 1 the TO UNSTRING same TLY PNTR. FIELDl1 INTO WITH DELIMITED BY FIELD2(TLY) POINTER PNTR TALLYING ON IN OVERFLOW Using 3-36 thing.) "," OR CR TLY GO TO PARI. Figure 3-37 the OVERFLOW Phrase NON-NUMERIC CHARACTER HANDLING NOTE The overflow condition also occurs if a pointer data item lies of value the outside the sending field at the start of execution of the UNSTRING statement. (The pointer value must not be less than 1, nor greater than the length of the sending field.) This type of overflow is the overflow from distinguishable not condition described at the start of this section, except that this condition to statement UNSTRING the causes terminate before any data movement takes all of values the Then, place. receiving fields remain unchanged. Subscripted Fields in UNSTRING Statements 3.8.8 1is enhanced by flexibility of the UNSTRING statement Since the and indexing and particularly by subscripting with other subscripting field fields within the statement (such as subscripting the receiving the TALLYING data item as discussed above), it is important to with these evaluates software the understand how often and exactly when This sub-section discusses the frequency and and indexes. subscripts times of subscript evaluation. The software evaluates subscripts and indexes on the following items only once, at the initiation of the UNSTRING statement; thus, any change in subscript values during the execution of the statement has no effect on these fields: l1. Sending field, 2. POINTER data 3. TALLYING data item, item. The software evaluates subscripts and indexes on the following 1items immediately before it moves data into the item. It moves the data to these items in the order in which they are 1listed 1in the statement (which is the same order as below): field, l. Receiving 2. DELIMITER data 3. COUNT data item, item. The software evaluates any subscripts and indexes on the data-names in the DELIMITED BY phrase (delimiters) immediately before it scans each sending string looking for a delimiter match. Thus, it re-evaluates these data-names once for each receiving field in the statement. NON-NUMERIC CHARACTER HANDLING 3-37 If any of the following items are used as subscripts on any receiving fields, the programmer must be aware of the point at which these items are updated: ® POINTER data-item, ® TALLYING data-item, ° COUNT data-item, ® Another Figure 3-38 receiving illustrates, field. with a flow chart, the sequence of evaluation operations: (s ) - < EVALUATE ALL SCANNING FOR SUBSCRIPTS MATCHES DELIMITER w CONTINUE &c a REPETITIVE el D 7 POINTER STORE IN SCANNER FIELD PRESENT DATA ITEM RECEIVING o SUBSCRIPT é PHRASE POINTER X [« W o SCAN SENDING FIELD FOR DELIMITER DELIMITER MATCH ? STORE = UPDATE =s IMITER IN OTRING w FIELD - EVALUATE & FIELD RECEIVING w a) SCANNER CIELD SUBSCRIPT T SUBSCRIPT PRESENT COUNT < g\ééémflé IF RALLYING ADD 1 TO TALLYING DATA ITEM SENDING FIELD EXHAUSTED YES ? & < o I a. ALL DELIMITER MOVE SENDING = STORE COUNT RE’(::|EEIl\-/[I)NG 3 COUNT FIELD STRING TO 3 ? VALUE IN w VMORE RECEIV NG FIELDS ? <: END ) H-MK-00046-00 Figure Sequence of 3-38 NON-NUMERIC 3-38 Subscript Evaluation CHARACTER HANDLING NOTE The rules in this section concerning the exact point at which the software evaluates the identifiers in the DELIMITED BY phrase and the point at which it updates the POINTER and TALLYING data items, are rules that are specified by 1974 American National Standard COBOL, as opposed to the STRING statement where these are not SO specified. 3.8.9 Common Errors, UNSTRING Statement The most common errors made when writing UNSTRING statements are: ) Leaving the OR connector out of a delimiter ° Misspelling or interchanging the list; words, DELIMITED and DELIMITER; ® Writing the DELIMITER and COUNT phrases in the wrong when both are present (DELIMITER must precede COUNT); ® Leaving out the word INTO or writing ® Repeating the word INTO where it order it as TO; is not needed; thus: UNSTRING FIELD1l DELIMITED BY SPACE OR TAB INTO FIELD2A DELIMITER IN DELIMA INTO FIELD2B DELIMITER IN DELIMB INTO FIELD2C DELIMITER IN DELIMC. Figure 3-39 Erroneously Repeating the Word ° Writing the POINTER and TALLYING phrases (POINTER must 3.9 The THE in the wrong order TALLYING). INSPECT STATEMENT INSPECT statement examines counts that precede INTO or replaces certain the character characters positions in a field (or groups of characters) and in field. Like the STRING and UNSTRING operations, INSPECT operations scan across the field from 1left to right; further, 1like those two statements, the INSPECT statement features a phrase which allows it to begin or terminate the scanning operation with a delimiter match. (Thus, the operation can begin within the field 1instead of at the left-hand end, or it may begin at the left-hand end and terminate within the field.) NON-NUMERIC CHARACTER HANDLING 3-39 The and TALLYING operation (which counts certain the REPLACING operation (which replaces characters in the characters field) in the certain field) are quite versatile and may be applied to all of the characters in the delimited area of the field being inspected, or they may be applied only to those characters that match a given character string under which stated conditions. both cause a scan of INSPECT FIELD]1l Consider the following the complete field: TALLYING TLY Figure 3-40 INSPECT...TALLYING Sample This statement scans FIELD]1l looking finds a B, it increments TLY by 1. INSPECT FOR ALL FIELD1 REPLACING ALL Figure Sample for One contain statement phrase. can However, when "B". the character : SPACE BY B. Each time it Wherever it ZERO. 3-41 looking for replaces it INSPECT statements, Statement INSPECT...REPLACING This statement scans FIELD1 finds a space character, it REPLACING sample Statement space with both used characters. zero. a TALLYING together, the phrase TALLYING must precede the REPLACING phrase. An INSPECT statement with phrases is equivalent to two separate INSPECT statements and, in and a phrase both fact, the software compiles such a statement into two distinct INSPECT statements. (To simplify debugging, therefore, it 1is best to initially write the two phrases in separate INSPECT statements.) 3.9.1 The BEFORE/AFTER Phrase The BEFORE/AFTER phrase the area The following precede of the the field sample percent acts being as statement sign (%) a delimiter and (possibly) in would count only FIELDI. INSPECT FIELDl TALLYING TLY FOR ALL Sample 3-40 NON-NUMERIC restricts inspected. ZEROES BEFORE "g%". Figure 3-42 INSPECT...BEFORE CHARACTER HANDLING Statement the =zeroes that The delimiter (the percent sign in the preceding sample statement) can be a single character, a string of characters, or any figurative Further, it can be either an identifier or a literal. constant. ) If the delimiter is an identifier, it must be an elementary It may be alphabetic, DISPLAY usage. of item data editing may contain it and, alphanumeric, or numeric, it had if as item the treats always compiler The s. character (It does this by been described as an alphanumeric string. implicit redefinition of the item, as described in Section 3.9.2.) ° If the delimiter is a literal, it must be non-numeric. The software repeatedly compares the delimiter characters against an If none of equal number of characters in the field being inspected. characters nt insufficie if or the characters matches the delimiter, remain in the field for a full comparison (at the right-hand end), the software considers the comparison to be unequal. 1illustrate the The examples of the INSPECT statement in Figure 3-43, way the delimiter character finds a match 1in the field being (The portion of the field the statement ignores as a inspected. result of the BEFORE/AFTER phrase delimiters is crossed out with a slash, and the portion it inspects is underlined.) FIELD]1 VALUE INSTRUCTION ABCDRPBHZY INSPECT FIELDl...BEFORE "E". INSPECT FIELDl...AFTER "E". ZBCZPEFGHI INSPECT FIELDl...BEFORE "K". INSPECT FIELDl...AFTER "K". ABCDEFGHI RBZPEYBHA INSPECT FIELDl...BEFORE "AB". INSPECT FIELDl...AFTER "AB". KBCPRFGBHZ XBCDEFGHI INSPECT FIELDl...BEFORE "HI". INSPECT FIELDl...AFTER "HI". ABCDEFGRZ Y KBCDEFGA ". INSPECT FIELDl...BEFORE "I ". INSPECT FIELDl...AFTER "I ABCDEFGHI KBLZPEYBHE The ellipsis represents the position of the TALLYING or REPLACING phrase. Figure 3-43 Matching the Delimiter Characters to the Characters in a Field NON-NUMERIC CHARACTER HANDLING 3-41 The the software scans the field for a delimiter match before inspection operation (TALLYING or REPLACING), thus the limits of Section 3.9.3 3.9.2 The the operation before beginning the further discusses the importance of it scans for establishing actual inspection. the separate scan. Implicit Redefinition software statement requires be that certain alphanumeric fields fields. referred If one to o0f by these the INSPECT fields was described as another data class, the compiler redefines that field so the INSPECT statement can handle it as a simple alphanumeric string. This implicit redefinition is conducted as follows: ) If the field was described as alphabetic, alphanumeric edited, or unsigned numeric, the compiler simply redefines it as alphanumeric. This is a compile-time operation; no data movement ° occurs at run time. If the field was described as signed numeric, the compiler first removes the sign and then redefines the field as alphanumeric. If the sign 1is a separate character, the compiler ignores that character, essentially shortening the field, and that character does not participate in the implicit redefinition. If the sign is an "overpunch" on the leading or trailing digit, the compiler actually removes the sign value and leaves the character with only the numeric value that was stored in it. The compiler alters the digit position containing the sign before beginning the INSPECT operation and restores it to its former value after the operation. If the sign's digit position does not contain a valid ASCII signed numeric digit, the action of the redefinition causes the value to change. Table 3-12 shows these original, altered, and restored values. The compiler never moves an implicitly redefined position. All redefinition occurs in place. The position not affect 3-42 of an implied implicit NON-NUMERIC decimal point redefinition. CHARACTER HANDLING on item numeric from its storage quantities does Original, Altered, Table 3-12 and Restored Values Resulting from Implicit Redefinition ORIGINAL VALUE P ALTERED VALUE RESTORED VALUE —— (41) (42) (43) (44) (41) (42) (43) (44) 1 2 3 4 (31) (32) (33) (34) A B C D E (45) F (46) G (47) 5 6 7 (35) (36) (37) E (45) F (46) G (47) } (7D) 0 (30) N (4E) O (4F) P (50) 5 6 7 (35) (36) (37) N (4E) O (4F) P (50) R (52) 9 (39) R (52) 0 (30) 0 (30) H I J K L M 8 9 (48) (49) H I (38) (39) (4A) (4B) (4C) (4D) 8 (38) 1 (31) 2 (32) 3 (33) 4 (34) (48) (49) } (7D) J K L M 1 (31) 2 (32) 3 (33) 4 (34) Q (51) (43) (4B) (4C) (4D) Q (51) { (7B) 1 (31) 2 (32) 3 (33) 4 (34) A B C D (41) (42) (43) (44) 5 (35) 5 (35) E (45) 7 (37) 7 (37) G (47) F (46) 6 (36) 6 (36) H (48) I (49) 8 (38) 9 (39) 8 (38) 9 (39) All other values 3.9.3 { (7B 0 (30) { (7B) A B C D 0 (30) { (7B) The INSPECT Operation Regardless of the type of REPLACING), the NON-NUMERIC CHARACTER HANDLING 3-43 inspection (TALLYING or INSPECT statement has only one method for inspecting the characters in the field. This section describes this method. However, before discussing how the inspection let's analyze the INSPECT statement itself: INSPECT FIELDl1 TALLYING TLY The field being——u//' FOR ALL "B" is BEFORE conducted, "A",. The afggment inspected The operation operation The delimiter phrase Sample phrase Figure 3-44 INSPECT Statement The format of the INSPECT statement requires that a field be named which 1is to be inspected (FIELDl1 above); the field name must be followed by an operation phrase (TALLYING TLY above); and, that phrase must be followed by one or more identifiers or literals ("B" above). These identifiers or literals comprise to be compared to the field being inspected). makes up the "argument list". ® TALLYING the More "arguments" (items than one argument Arguments Each argument in an argument 1list can have other fields associated with 1it. Thus, each argument that is used in a TALLYING operation must have a tally counter (TLY above) associated with it. The software increments the tally counter group ® each time of it matches the characters in the argument with a character or field being inspected. REPLACING Arguments INSPECT FIELD1 REPLACING ALL replacing Figure Sample "O" BY "S". argument 3-45 REPLACING Argument Each argument in an argument list that is used in a REPLACING operation must have a replacement item ($ above) associated with it. The software uses the replacement item to replace each string of characters in the field used with that matches the argument. Each argument in an argument list or REPLACING operation) may phrase) associated with it. 1If (that is either have a delimiter field the delimiter field 1is a TALLYING (BEFORE/AFTER not present, the software applies the argument to the entire field. If delimiter field is present, the software applies the argument only that portion of the field specified by the BEFORE/AFTER phrase. 3-44 NON-NUMERIC CHARACTER HANDLING the to 3.9.3.1 Setting the Scanner - The INSPECT operation begins by setting the scanner to the leftmost character position of the field being inspected. It remains on this character until an argument has been matched with a character (or characters) or until all arguments have failed to find a match at that position. 3.9.3.2 Active/Inactive Arguments - When BEFORE/AFTER phrase associated with it, that in participate to and may not be eligible position of the scanner. Thus, each argument an argument has a argument has a delimiter every at comparison a in the argument list has an active/inactive status at any given setting of the scanner. For example, an argument that has an AFTER phrase associated with it starts the INSPECT operation in an inactive state. The delimiter of the AFTER phrase must find a match before the argument can participate the delimiter finds a match, the software When comparison. the in string; character retains the character position beyond the matched the scanner reaches or passes this position, the argument when then, becomes active. INSPECT FIELDl1 FOR ALL TALLYING "B" TLY AFTER "X". Figure 3-46 Sample AFTER Delimiter If FIELD]l in Figure 3-46 has a value of Phrase "ABABXZBA", the argument B remains inactive until the scanner finds a match for the delimiter X. character scans Thus, argument B remains inactive while the software At character position 5, the delimiter X finds positions 1 through 5. a match, and since the character position beyond the matched delimiter character is the point at which the argument becomes active, argument B is compared for the first time at character position 6. It finds a successful match at character position 7 and this causes TLY to be incremented by 1. The examples in Figure 3-47 illustrate arguments and/or the delimiters are (Consider the sample statement to be an other 1longer situations than one INSPECT...TALLYING where the character. statement that 1is scanning FIELDl, tallying in TLY, and 1looking for the arguments and delimiters in the left-hand column. Assume that TLY 1is initialized to 0.) NON-NUMERIC CHARACTER HANDLING 3-45 ARGUMENT AND DELIMITER FIELD1 ARGUMENT CONTENTS VALUE ACTIVE TLY AT OF AFTER SCAN POSITION "B" AFTER "XX" "X" AFTER "XX" "B" AFTER "XB" "BX" AFTER "XB" BXBXXXXBB 6 2 XXXXXXXX BXBXBBBBXX 3 never 0 0 BXBXXBXXB XXXXXXXX BBBBBBXX 6 3 never 2 6 0 BXYBXBXX XBXBXBXB 7 3 0 3 BBBBBBXB never 0 XXXXBXXXX 6 0 XXXXBBXXX XXBXXXXBX 6 4 1 1 Where When an argument has an Figure 3-47 Arguments Become Active associliated BEFORE in a Field delimiter, the inactive/active states reverse roles: the argument is in an active state when the scanning begins, and becomes inactive at the character position that matches the delimiter. Additionally, regardless of the presence of the BEFORE delimiter, an argument becomes inactive when the scanner approaches the right-hand end of the field and the remaining characters are fewer in number than the characters in the argument. (In such a case, the argument cannot possibly find a match in the field so it becomes inactive.) Since the BEFORE/AFTER delimiters are found on a separate scan of the field, the software recognizes and sets up the delimiter boundaries before it scans for an argument match; therefore, the same characters can be used as arguments and delimiters in the same phrase. 3.9.3.3 Finding an Argument Match - The software selects arguments from the argument list in the order in which they appear in the 1list. If the first one it selects is an active argument and the conditions stated 1in the INSPECT statement allow a comparison, the software compares it to the character at the position of the scanner. If the active argument does not £find a match, the software takes the next active argument from the list and compares that to the same character. If none of the active arguments finds a match, the scanner moves one position to the right and begins the inspection operation again with the first active argument in the 1list. The inspection operation terminates at the right-hand end of the field.. 3-46 NON-NUMERIC CHARACTER HANDLING When an active argument does find a match, the software ignores any remaining arguments in the list and conducts the TALLYING or REPLACING operation on the character. The scanner moves to a new position and the next inspection operation begins with the first argument in the list. (The INSPECT statement may contain additional conditions, which are described later in this section; this discussion, however, assumes that the argument match is allowed to take place and that inspection is allowed to continue following the match.) The software argument to updates 1it. the scanner by adding the size of the matching This moves the scanner to the next character beyond the string of characters that matched the argument. Thus, once an active argument matches a string of characters, the statement does not inspect those character positions again unless program control executes the entire statement again. 3.9.4 Subscripted Any identifier indexed. Fields named in in an INSPECT Statements INSPECT statement may be subscripted or The software evaluates all subscripts in an INSPECT statement once, before the inspection begins; therefore, if the action of the INSPECT statement alters one of the subscripts, the new subscript value has no effect on the selection of operands during that inspection For example, consider the following illustration: MOVE 1 TO TLY. INSPECT FIELD]1l FOR ALL operation. TALLYING TLY X(TLY). Sample Figure 3-48 Subscripted Argument In this sample statement, the software evaluates the address of X(TLY) only once, before it begins inspecting the field; hence, it will evaluate X(TLY) as X(1). The alteration of TLY by the action of inspecting and tallying has no effect on the choice of the X operand. (X(1) will be used throughout the operation.) NOTE When subscripting an INSPECT statement that contains both a TALLYING and a REPLACING phrase, keep in mind that the statement will be compiled into two separate INSPECT statements. Therefore, any field that is altered by the action of the INSPECT...TALLYING statement will be 1in 1its altered state if used as a subscript by the INSPECT. ..REPLACING statement. NON-NUMERIC CHARACTER HANDLING 3-47 3.9.5 An The TALLYING Phrase INSPECT statement occurrence conditions. here, a of It tally that various keeps the contains a character count in a TALLYING phrase strings under wuser-designated counts certain field the stated called, counter. 3.9.5.1 The Tally Counter - The identifier that follows the word TALLYING designates the tally counter. The identifier may be subscripted or indexed. The data item must be a numeric integer with no editing or P characters; it may be COMP or DISPLAY usage, and it may be signed Each time (separate the inspected, tally the or overpunched). argument software adds 1 matches to the the tally delimited The programmer can initialize the tally counter (The INSPECT statement does not initialize it.) 3.9.5.2 The Tally Argument - The character-string and a condition compared figure to the shows delimited the format ALL } LEADING of string the string being counter. to any numeric value. tally argument specifies a under which that string should be being tally inspected. The following argument: identifier} literal CHARACTERS Format Figure 3-49 of the Tally Argument The CHARACTERS form of the tally argument specifies that every character in the delimited string being inspected should be considered to match an imaginary character that serves as the tally argument. This increments the tally counter by a value that equals the size of the delimited string. For example, the statement in the following illustration causes TLY to be incremented by the number of characters that precede the first comma, regardless of what those characters might be. INSPECT FIELD1 TALLYING TLY CHARACTERS BEFORE CHARACTERS 3-48 FOR ",". Figure 3-50 Form of the Tally Argument NON-NUMERIC CHARACTER HANDLING When an active argument does find a match, the software ignores any remaining arguments in the list and conducts the TALLYING or REPLACING operation on the character. The scanner moves to a new position and the next inspection operation begins with the first argument in the list. (The INSPECT statement may contain additional conditions, which are described 1later in this section; this discussion, however, assumes that the argument match is allowed to take place and that inspection is allowed to continue following the match.) The software argument updates to it. the This scanner moves by the adding scanner the to size the of next the matching character beyond the string of characters that matched the argument. Thus, once an active argument matches a string of characters, the statement does not inspect those character positions again unless program control executes 3.9.4 the entire Subscripted Any identifier indexed. The statement Fields named in in an again. INSPECT Statements INSPECT statement software before the evaluates all subscripts in an inspection begins; therefore, if may be subscripted or INSPECT statement once, the action of the INSPECT statement alters one of the subscripts, the new subscript value has no effect on the selection of operands during that inspection operation. For example, consider the following illustration: MOVE 1 INSPECT TO TLY. FIELD1 TALLYING FOR ALL TLY X(TLY). Sample Figure 3-48 Subscripted Argument In this sample statement, the software evaluates the address of X(TLY) only once, before it begins inspecting the field; hence, it will evaluate X(TLY) as X(1). The alteration of TLY by the action of inspecting (X(1) will and tallying has no effect on the be used throughout the operation.) choice of the X operand. NOTE When that subscripting an contains both REPLACING phrase, statement will separate INSPECT any INSPECT statement a TALLYING and a keep be in mind compiled statements. that the into two Therefore, field that is altered by the action INSPECT...TALLYING statement will in its altered state if used as a subscript by the INSPE . .REPLACING CT. of be the statement. NON-NUMERIC CHARACTER HANDLING 3-47 3.9.5 An The TALLYING Phrase INSPECT statement occurrence conditions. here, a that contains of various character It keeps the count in a tally a TALLYING phrase counts the strings under certain stated user-designated field called, counter. 3.9.5.1 The Tally Counter - The identifier that follows the word TALLYING designates the tally counter. The identifier may be subscripted or indexed. The data item must be a numeric integer with no editing or P characters; it may be COMP or DISPLAY usage, and it may be signed (separate Each time the overpunched). string being The programmer can initialize the tally counter to any numeric value. inspected, (The the tally or argument software adds 1 matches to the the INSPECT statement does not initialize 3.9.5.2 The Tally Argument - The character-string and a condition compared to the figure shows delimited the format of ALL } LEADING string the delimited tally counter. it.) tally argument specifies a under which that string should be being inspected. tally argument: The following identifier} literal CHARACTERS Figure 3-49 Format of the Tally Argument The CHARACTERS form of the tally argument specifies that every character in the delimited string being inspected should be considered to match an imaginary character that serves as the tally argument. This increments the tally counter by a value that equals the size of the delimited string. For example, illustration causes TLY to be that precede the first comma, might the statement in be. INSPECT FIELD1 TALLYING TLY FOR CHARACTERS BEFORE ",". Figure 3-50 CHARACTERS Form of the Tally Argument 3-48 the following incremented by the number of characters regardless of what those characters NON-NUMERIC CHARACTER HANDLING Thus, the after scan first argument is initially inactive and scanner encounters an A; the second the in the active encountered; of state and the but third becomes becomes inactive after a argument is during the active active argument only begins has the been entire scan B FIELDl. Figure 3-55 shows various values of FIELD1l and the contents of three tally counters after the scan. Assume that the counters initialized to 0 before the INSPECT statement. VALUE u T1 T2 T3 A.C;D.E,F 1 2 1 A.B.C.D 0 1 0 A,B,C,D 3 0 0 A;B;C;D 0 0 3 Results 4 Figure 3-55 the Scan in Figqure of 3-54 The BEFORE/AFTER phrase applies only to the argument and delimits the field for that argument only. the causes field 3.9.5.4 for a separate scan of its corresponding Interference arguments A " CONTENTS OF TALLY COUNTERS AFTER SCAN FIELD1 phrase the are contain or more field to determine the limits of argument. in Tally one the that precedes it, Each BEFORE/AFTER Argument Lists identical - When characters several that are tally active at the same time, they may interfere with each other (i.e., when one of the arguments finds a match, the scanner is stepped past the matching character (s) which prevents those character(s) from being considered for any other match). The example in Figure 3-56 illustrates two identical tally arguments that do not interfere with each other since they are not active at the same time. (The first A in FIELD]l causes the first argument to become inactive and the second argument to become active.) MOVE 0 INSPECT TO T1 T2. FIELDl1 TALLYING FOR ALL "," BEFORE "A" T2 FOR ALL "," AFTER "A". Figure 3-56 Tallying Arguments Two Do The two identical | Tl Not tally Interfere arguments in with that Each Figure Other 3-57 will interfere each other since both are active at the same time. position of the scanner, the arguments are applied to order in which they appear in the statement. When one match, the scanner moves to the next position NON-NUMERIC with (For any given FIELDl1 in the of them finds a and ignores CHARACTER HANDLING the 3-51 remaining arguments in the argument list.) Each comma in FIELDl causes Tl to be incremented by 1 and the second argument to be ignored. Thus, Tl will always contain an accurate count of all of the commas in FIELD]l, and T2 will always be unchanged. INSPECT FIELD1 TALLYING Tl FOR ALL "," T2 FOR ALL "," AFTER "A". Figure 3-57 Two Tallying Arguments that Do Interfere with Each Other The following statement achieves the same results as the statement in first argument does not become active until the The 3-56. Figure scanner encounters an A. The second argument tallies all commas that precede the A. After the A, the first argument counts all commas and causes the second argument to be ignored. Thus, T1 contains the number of commas that precede the first A and T2 contains the number of commas that follow the first A. This statement works well as written, but could be more confusing to debug than the one in Figure 3-56. INSPECT FIELDl1 TALLYING T2 FOR ALL Tl FOR ALL "," AFTER "A" ",". Figure 3-58 Two Tallying Arguments that, Because of their Positioning, Only Partially Interfere with Each The preceding Other three examples show that one INSPECT statement cannot count any character more than once. Thus, when using the same character in more than one argument of an argument list, consider the nature of the interference and choose the order of the arguments very carefully. The solution to the problem may require two or more INSPECT statements. Consider the following problem: INSPECT FIELDl TALLYING Tl FOR ALL "AB" T2 FOR ALL "BC". Figure 3-59 An Attempt to Tally the with Character B Two Arguments If FIELDl contains "ABCABC", after the scan Tl will be incremented by The successful matching of the argument the to scanner Each match resets the right of the B, and causes the second a 2 and T2 will be unaltered. includes each B in the field. character position to the 3-52 NON-NUMERIC CHARACTER HANDLING argument to never be successfully matched. Reversing the order of the arguments has no effect, the results remain the same. Only separate INSPECT statements can develop Sometimes the programmer the INSPECT statement sample argument the desired counts. can use the interference characteristics of to good advantage. Consider the following list: MOVE 0 TO T4 T3 T2 T1. INSPECT FIELD]1 TALLYING T4 FOR ALL "***xTMn T3 T2 Tl FOR ALL FOR ALL FOR ALL "***TM" "**" "*", Figure 3-60 Tallying Asterisk Groupings The argument list in Figure 3-60 counts all of the asterisks in FIELDI but in four different tally counters. T4 counts the number of times that four asterisks occur together; T3 counts the number of times three asterisks appear together; T2 counts double asterisks; and T1 counts singles. If FIELD]l contains a string the argument 1list breaks them in T4. It then counts of more than four consecutive asterisks, the string into groups of four, and counts the less-than-four remainder in T3, T2, or Tl. Reversing the order of the arguments in all of the asterisks and T2, T3, and T4 this list causes Tl to remain unchanged. to count When the LEADING condition is used with an argument 1in the argument list, that argument becomes inactive as soon as it fails to be matched in the field being inspected. Therefore, when two arguments in an argument 1list contain one or more identical characters and one of the arguments has a LEADING condition, the argument with the LEADING condition should appear first. Consider the following sample statement: MOVE 0 TO INSPECT Tl T2. FIELDl1 Tl TALLYING FOR LEADING "*" T2 FOR ALL "*", Figure Placing in The placement of Tl to only other count character argument asterisks to in the LEADING leading stops become FIELDI. the the condition asterisks this 3-61 LEADING Condition Argument List counting 1inactive. T2 in in this sample statement FIELDl; the occurrence and keeps causes a count the of first any causes of any tally remaining NON-NUMERIC CHARACTER HANDLING 3-53 Reversing the order of argument list that can INSPECT the arguments in this never increment Tl. statement results 1in an FIELD1 TALLYING T2 FOR ALL "*" Tl FOR LEADING "*", Figure 3-62 Reversing the Argument List in Figure 3-61 If the first character in FIELD]l is not an asterisk, neither argument can match it and the second argument becomes inactive. If the first character in FIELD]l is an asterisk, the first argument matches and causes the second argument to be ignored. The first non-asterisk character in FIELDl will fail to match the first argument and the second argument will become inactive. (The second argument becomes inactive because it has not found a match in all of the preceding characters.) An argument with both a LEADING condition and sometimes sucessfully "delimit" the field being a BEFORE inspected: phrase can MOVE 0 TO Tl T2. INSPECT FIELD]1l TALLYING Tl FOR LEADING SPACES T2 FOR ALL " " BEFORE "." T2 FOR ALL " " BEFORE "." T2 FOR ALL " " BEFORE ".". IF T2 > 0 ADD 1 TO T2. An Figure 3-63 Argument List that Counts Words in a Statement The statements in Figure 3-63 count the number of "words" 1in the English statement in FIELDI. (This assumes that no more than three spaces separate the words in the sentence and that the sentence ends with a period.) When FIELDl has been scanned, T2 contains the number of gaps between the words. Since a count of the gaps renders a number that 1is one less than the number of words, the conditional statement adds one to the count. The first argument removes any leading spaces, counting them in a different tally counter. This shortens FIELDl1 by preventing the application of the second through the fourth arguments until the scanner finds a non-space character. The BEFORE phrase on each of the other arguments causes them to become 1inactive when the scanner reaches the period at the end of the sentence. Thus, the BEFORE phrases "shorten" FIELDl by making the second through the fourth arguments inactive before the scanner reaches the right-hand end of FIELDl1. If the sentence in FIELD1l is indented with tab characters instead of spaces, a second LEADING argument can count the tab characters. Figure 3-64 illustrates this technique: 3-54 NON-NUMERIC CHARACTER HANDLING INSPECT FIELD1 TALLYING Tl FOR LEADING SPACES Tl FOR LEADING TAB T2 FOR ALL Counting " " Figure Leading Tab etc. 3-64 or Space Characters When an argument list contains a CHARACTERS argument, it should be the last argument in the 1list. Since the CHARACTERS argument always matches the field, it prevents the application of any of the following arguments 1in the list. However, as the last argument in an argument list, it can count the remaining characters in the field being inspected. Consider the following illustration. MOVE 0 TO INSPECT Tl T2 T3 T4 T5. FIELDl1 TALLYING Tl FOR LEADING SPACES T2 T3 T4 FOR ALL FOR ALL FOR ALL "." "+" "-" BEFORE BEFORE BEFORE TS5 FOR CHARACTERS "," "," "," BEFORE ",". Figure 3-65 Counting the Remaining Characters With the CHARACTERS Argument If FIELD1l is input data, known to contain a number in the form frequently used to it may contain a plus or minus sign, and a decimal point; further, the number may possibly be preceded by by a comma. If this statement were compiled deliver the following results: T1 would contain the number of leading T2 would contain the number of periods, T3 would contain the number of plus T4 would contain the number of minus TS5 would contain be the 3.9.6 sum The numeric), of Tl occupied the number of spaces and and terminated executed, it would spaces, signs, signs, remaining characters (assumed to and through T5 (plus 1) gives by the terminating comma. the character position REPLACING Phrase When an INSPECT statement contains selectively replaces characters designated field. a REPLACING phrase, that statement or groups of characters 1in the NON-NUMERIC CHARACTER HANDLING 3-55 The REPLACING phrase names a search argument consisting of a character string of one or more characters and a condition under which the string may be applied to the field being inspected. Associated with the search argument is the replacement value, which must be the same length as the search argument. Each time the search argument finds a match in the field being inspected, under the condition stated, the replacement value replaces the matched characters. A BEFORE/AFTER phrase may be used to delimit the area of the field being inspected. A search argument applies only to the delimited area of the field. 3.9.6.1 The Search Argument - The search argument of the REPLACING phrase names a character string and a condition under which the character string should be compared to the delimited string being inspected. Figure 3-66 shows the format of the search argument: ALL LEADING identifier literal FIRST CHARACTERS Format of Figure 3-66 the Search Argument The CHARACTERS form of the search argument specifies that every character in the delimited string being inspected should be considered to match an imaginary character that serves as the search argument. Thus, the replacement value replaces each character in the delimited string. (The replacement value, in this case, must be one character long.) The ALL, LEADING, particular and character FIRST forms string, of the search argument specify a which may be represented by a literal or an identifier. The search argument character string may be any length. However, each character of the argument must match a character in the delimited string before the software considers the argument matched. ) A literal character string must be either non-numeric or a figurative constant (other than ALL literal). A figurative constant, such as SPACE, ZERO, etc., represents a single character and can be written as " ", "0", etc. with the same effect. Since a figurative constant represents a single character, the replacement value must be one character 1long. ° An identifier must represent an elementary item of DISPLAY usage. It may be any class. However, if it is other than alphabetic, the software performs an implicit redefinition of the item. (This redefinition is identical to the BEFORE/AFTER delimiter redefinition discussed 1in Section 3.9.1.) 3-56 NON-NUMERIC CHARACTER HANDLING The words ALL, LEADING, and FIRST delimit the inspection operation: ) supply conditions which further The word ALL specifies that each match that the search argument finds in the delimited string is to be replaced by the replacement value. When a literal follows the word ALL, it does not have the same meaning as the figurative constant, ALL literal. (The figurative constant meaning of ALL "," is a string of consecutive commas, as many as the context of the statement requires.) ALL "," as a search argument of the REPLACING phrase means, "replace each comma without regard to adjacent characters." ) The word LEADING specifies that only adjacent matches of the search argument at the 1left-hand end of the delimited character string be replaced. At the first failure to match the search argument, the software terminates the replacement operation and causes the argument to become inactive. ) The word FIRST specifies that only the 1leftmost string that matches the search argument is to be After the replacement operation, the search containing this condition becomes inactive. 3.9.6.2 The Replacement Value - Whenever the search character replaced. argument argument finds match in the field being inspected, the matched characters replaced by the replacement value. The word BY followed by identifier or literal specifies the replacement value. a are an identifier literal Format The replacement value search argument. If replacement must same size than replacement DISPLAY value usage. alphanumeric, the is an identifier, It may be software character as its the 1item. (This redefinition redefinition discussed in Section it must any class. conducts 1is the 3.9.1.) an string, associated be of literal the ALL the the is a be must item value always either a non-numeric literal or a figurative constant (other than literal). A figurative constant represents as many characters as length that the search argument requires. If the Figure 3-67 the Replacement Value of an However, implicit same be as it if elementary it is other redefinition the of BEFORE/AFTER NON-NUMERIC CHARACTER HANDLING 3-57 3.9.6.3 of the The Replacement Argument - The search replacement argument value, and (with an ALL its optional ";" BY replacement condition and argument character consists string), the BEFORE/AFTER phrase. SPACE BEFORE "." search/////' BEFORE/AFTER argument phrase (optional) replacement value The 3.9.6.4 The Replacement Figure 3-68 Replacement Argument Argument List - One INSPECT. ..REPLACING statement can contain more than one replacement argument. Several replacement arguments form an argument list, and the manner in which the 1list 1is processed affects the action of any given replacement argument. The following examples show INSPECT statements argument lists. The text following each one tells be processed. INSPECT y FIELDl1 REPLACING ALL "," BY SPACE ALL "." BY ALL ";" BY SPACE. SPACE Figure 3-69 Replacement Argument List Active Over the Entire These three SPACE, and Thus, space this replacement are active arguments over the statement replaces and leaves characters; INSPECT with replacement how that list will FIELDl1 all entire all all have field " 0 " BY n l " ALL 11} 1 n BY n 0 n . same being replacement value, inspected. commas, periods, characters other Figure 3-70 Replacement Argument Ones the and semicolons unchanged. with REPLACING ALL "Swaps" that is Field for Zeroes Each and List that Zeroes for Ones of these two replacement arguments has its own replacement value, and 1is active over the entire field being inspected. This statement exchanges zeros for ones and ones for zeroes, and 1leaves all other characters unchanged. 3-58 NON-NUMERIC CHARACTER HANDLING NOTE When a search argument finds a match in the field being inspected, the software replaces that character string and scans to the next position beyond the replaced characters. It ignores the remaining arguments and applies the first argument in the list to the character string in the new position. Thus, it never inspects the new value that was supplied by the replacement operation. Because of this, the search arguments may have the same values as the replacement arguments with no chance of interference. INSPECT FIELD1 REPLACING ALL "0" BY "1" BEFORE ALL "1" BY "O" BEFORE SPACE SPACE. Figure 3-71 Replacement Argument List that Becomes Inactive with the Occurrence of a Space Character This sample statement is identical to the statement in Figure 3-70, except that, here, the first occurrence of a space character in FIELDI causes both arguments to become inactive. INSPECT FIELDl1l REPLACING ALL "0" BY "1" BEFORE ALL "1" BY "0" CHARACTERS BY SPACE BEFORE "*" SPACE BEFORE SPACE. Figure 3-72 Argument List with Three Arguments That Become Inactive with the Occurrence of a Space Just as in the argument list in Figure 3-71, the first space character causes all of these replacement arguments to become inactive. This argument 1list exchanges zeroes for ones, ones for zeroes, and asterisks for all other characters that are in the delimited area. If the BEFORE phrase is removed from the third argument, that argument will remain active across all of FIELDl. Within the area delimited by the first space character, the third argument replaces all characters except ones and zeroes with asterisks. Beyond this area, it replaces all characters (including the space that delimited FIELDl for the first two arguments and any zeroes and ones) with asterisks. NON-NUMERIC CHARACTER HANDLING 3-59 3.9.6.5 Interference search arguments identical in that characters, consequently have interference arguments of is active they an one Replacement are may effect search similar at Argument the on the the Lists - When several time contain one with each other, and replacement operation. This the matching of other interfere argument with to same interference that occurs or more search between tally arguments. The action of a search argument is never affected by the delimiters of other arguments, since the software scans matches before it scans for replacement operations. The any action of a replacement characters again Interference of the search during between arguments, status of replacement Tally arguments Place end 3. The will the Errors, INSPECT depends and discussion Lists, the 1in errors ) Leaving the Section applies, order 3.9.5.4 generally, to well.) help minimize with arguments interference LEADING with the or in FIRST CHARACTERS the order contain of replacement conditions condition at at the appearance of any more 1identical one made when FOR out of word writing an "WITH" INSPECT or statements INSPECT...TALLYING instead of "BY" '@ Failing to initialize the tally counter. ® Omitting the word INSPECT NON-NUMERIC the active-inactive in "ALL" FIELDl1 the e.g.: TALLYING CHARACTER HANDLING TLY FOR are: statement. phrase. 3-60 statement. on INSPECT Statement common the the list; most Using by the characters of inspect the replaced therefore, arguments, (The Consider, very carefully, search arguments that characters. Common ® the arguments the list; several of of Argument as Place search the start of 2. 3.9.7 values affected not does of arguments, arguments. 1in The following rules argument lists: l. execution search the the Interference argument is never since the scanner value, BEFORE/AFTER for delimiter SPACES. REPLACING CHAPTER 4 CHARACTER HANDLING NUMERIC This chapter discusses numeric class data and the COBOL operations It is assumed that you be performed on numeric data items. can that have read Chapter 3, and that you understand the concept of COBOL data classes. 4.1 USAGES The USAGE of a numeric class item specifies the form in which the data is stored in data storage: memory. DISPLAY DISPLAY-7), COMPUTATIONAL (abbreviated COMP-3). 4.1.1 VAX-11 COBOL-74 has four formats for numeric (which 1is equivalent to DISPLAY-6 and (abbreviated COMP), and COMPUTATIONAL-3 DISPLAY Items with DISPLAY usage are stored as strings of characters (bytes) in decimal radix with an assumed decimal point and optional sign. 4.1.2 COMPUTATIONAL COMPUTATIONAL usage is the standard VAX-1ll binary format. A COMP item is stored as a binary value with an assumed decimal scaling position; it is automatically SYNCHRONIZED on a word boundary and stored in memory (in one, two, or PICTURE four words) RANGE S(9) to S9(4) S9(5) to S9(9) S9(10) to S9(18) as follows: STORAGE 1 word 1l longword 1 guadword (2 bytes) (4 bytes) (8 bytes) Figure 4-1 indicates the significance of each by the number in parentheses. For example, byte contains the lowest-valued address (the first-referenced corresponds The number the data example of to the low byte of bits. byte) the least Observe that the computer of each COBOL data 1item significant in parentheses also item 1is redefined a two-word COMP indicates the order as an alphanumeric item: 01 COMP-ITEM 01 GROUP-ITEM REDEFINES COMP-ITEM. 03 CHARACTER-ITEM PIC X OCCURS PIC 9(9) USAGE The subscripts of CHARACTER-ITEM parentheses in Figure 4-1. IS word. of characters item. Consider 4 TIMES. correspond to the high | low byte | byte high | low byte | byte (2) (2) (1) (2) (1) Addressed (4) (3) (4) (3) Next (6) (5) Next word (8) (7) Next word (1) COMP Two-word COMP item item Memory if an COMP. high | low byte | byte One-word 4.1.3 byte in a COMP data item "(1)" indicates that the numbers in word word Four-word COMP item Figure 4-1 of COMP Storage Data Items COMPUTATIONAL-3 COMP-3 specifies packed-decimal data items. decimal digits per byte (byte-aligned) with position. The sign the rightmost byte. is contained in the They are an assumed rightmost half stored decimal (four as two scaling bits) of The maximum size of a COMP-3 item is 18 decimal digits, regardless of the decimal scaling position. 1In the following example, both NUM-1 and NUM-2 represent COMP-3 items of maximum size: 03 03 NUM-1 PIC S9(18) USAGE IS COMP-3. NUM-2 The description of character-string. 4-2 NUMERIC PIC a S9(6)V9(12) COMP-3 data CHARACTER HANDLING USAGE item must IS COMP-3. have a sign in its PICTURE When you specify an even number of digits, the the leftmost four bits of the leftmost byte. Signs resulting from operations specified as COMP-3 are: in which "4 binary 1100 hexadecimal n_w C binary 1101 hexadecimal F value the Positive signs- binary binary signs- binary 1011, hexadecimal vy Negative binary 1101, hexadecimal Figure 4-2 represents the memory and three digits: two, lst byte 5 ‘lst + PICTURE value: hexadecimal hexadecimal hexadecimal hexadecimal (w binary binary 1010, 1100, 1110, 1111, byte 0 2nd 3 S9 of in receiving item is but they are not data items of one, byte 2 2nd 6 byte 2 + PICTURE S9(3) value: +262 -32 Storage stored 4-2 COMP-3 Data Items DECIMAL SCALING POSITION The as lst - Figure 4.2 COMP-3 S9(2) value: Memory of byte 2 PICTURE +5 storage is OE O The following signs are also recognized as valid, generated as a result of program operations: zero assumed part of decimal an control operations field description: 01 scaling actual on VAX-11 COBOL-74 stores contains the integer scaling factor. 1In this integer COBOL than RTS the knows that programmer value. numeric ORDER-PRICE that position, numeric PIC data 99V99 the scaling factor, is not stored is by the RTS it items. Consider COMP this item as wvalue 1234 this has or However, VALUE used the to following 12.34. a l-word binary number. The word and another location contains the example, the scaling factor records the fact two decimal fractional positions. Thus, the stored intends it binary to integer is 100 times 1larger be. NUMERIC CHARACTER HANDLING 4-3 I1f the compiler encounters the following statement: ADD 1 TO ORDER-PRICE. The it generates instructions to add a 1 to the 1234 in ORDER-PRICE. scales the literal 1 up by two decimal places and adds however, RTS, Thus, after the resultant literal, 100, to the number in ORDER-PRICE. (which is 1334 value new the contains ORDER-PRICE the ADD operation, actually 13.34 with the stored decimal scaling position). Thus, the VAX-11 COBOL-74 compiler and RTS manipulate the data 1in All four and COMP-3 data items in much the same way. COMP, DISPLAY, usages have exactly the same accuracy and precision, and can be freely To illustrate, if a DISPLAY usage number and a in a program. mixed involved in the same arithmetic statement, both are number usage COMP the RTS converts them to a common radix with no loss of information. of loss 1if necessary, with no It also converts the result, significance. The only effect of specifying a binary or packed-decimal usage is that space required for most numbers and can speed up the it reduces the execution of 4.3 arithmetic statements. SIGN CONVENTIONS COMP-3 data items must be signed; however, DISPLAY AND COMP numeric Unsigned numbers can contain values items can be signed or unsigned. that range from zero to the largest positive value allowed by their Negative values are not allowed. All VAX-1l declared precision. When the RTS yield signed results. operations arithmetic COBOL-74 must store such a result, whether positive or negative, in an unsigned Thus, data item, it stores only the absolute value of the result. unsigned items always contain zero or positive values. They This guide does not recommend unsigned numbers for general use. less handled are and errors, programming of are usually a source efficiently than signed quantities by the RTS. Signed quantities always contain a numeric value and an operational The RTS stores the sign with the numeric value in a variety of sign. ways depending on the usage of the item and the presence of the SIGN clause. NOTE If numeric data is into read a field described using the picture character S, an include must data that then operational format 4-4 to pass sign of the the NUMERIC NUMERIC CHARACTER HANDLING appropriate test. VAX-11 COBOL-74 always stores signed COMP items 1in two's complement binary form. Thus, the high-order bit indicates the sign of the item. Sign representation for COMP-3 data items 1is described 1in Section 4.1.4. VAX-11 COBOL-74 byte positions the sign in the extra, When byte the numeric on RTS always either stores digit, the the the signed high-order sign sign changes the value of ASCII character that same stores containing numeric high-order byte, the as causes part a DISPLAY items as a ASCII characters. low-order byte, or or low-order of value a byte change end of that in sequence the also that of It may include as a separate, byte item. contains and, a hence, the numeric digit. Table 4-1 shows the actual results when a numeric value and a sign share the byte. Table 4-1 The Resulting ASCII Character From a Sign and Digit Sharing the Same Byte DIGIT VALUE SIGN A byte containing A byte containing either a { or a either a |} When RTS the actual 2B) or 4.4 All a +0 stores as hexadecimal 7B, which prints as a -0 stores as hexadecimal 7D, which prints as the sign [ depending on the printing device. or a ] depending on the printing device. stores ASCII character the graphic minus ILLEGAL VALUES VAX-11] COBOL-74 as a separate that it stores sign (hex 2D). IN NUMERIC FIELDS arithmetic operations is distinct the store character, graphic legal plus values sign in the (hex their result fields. However, it is possible, by reading invalid data or through redefinition and group moves, to store data in numeric fields that do not obey the descriptions of those fields. (For example, it 1s possible non-numeric to place signed values into unsigned fields, and to place or improperly signed data into signed numeric DISPLAY fields.) The results of arithmetic operations that use invalid data in fields are numeric unpredictable. NUMERIC CHARACTER HANDLING 4-5 4.5 TESTING NUMERIC FIELDS COBOL provides the following numeric 1. 2. 3. The three kinds of Relation tests, numeric value; for evaluating Sign tests, that examine the field's sign to positive or negative; Class tests, legal that compare the field's contents to and, that inspect the numeric values. field's following sub-sections explain these tests 4.5.1 tests fields: digit see if another it positions is for in detail. Relation Tests A relation test compares two numeric quantities and determines if the specified relation between them is true. For example, the following statement compares FIELDl to FIELD2 and determines if the numeric value of FIELDl is greater than the numeric value of FIELD2. If so, the relation condition is true and program control takes the True path of the statement. IF FIELDl > FIELD2 ... the or 1literal numeric a Either field in a relation test may be ZERO or 0.0, 00, 0, literals numeric (The constant, ZERO. figurative are all equivalent, both in meaning and in execution speed.) The sizes of the fields in a numeric relation test do not have to be the same (this includes the sizes of numeric 1literals). The comparison operation aligns both fields on their assumed decimal positions (through actual scaling operations in temporary locations or by accessing the individual digits) and supplies leading or trailing (as required) zeroes to either or both fields. The comparison operation always compares the signs of non-zero fields and considers positive fields to be greater than negative fields. However, since it does not compare them, positive zeroes and negative zeroes are equal. (A negative zero could arrive in a field through redefinition of the field or a MOVE to a group 1item.) Further, the operation considers unsigned numeric fields to be positive. The form of representation of the number usage) effect on numeric relation For comparison purposes, 4-6 COMP-3, or DISPLAY tests. the operation converts any illegal characters stored in DISPLAY usage fields to zeroes. the (COMP, and the various methods of storing DISPLAY usage signs have no actual values in those fields. NUMERIC CHARACTER HANDLING It does not, however, alter 4.5.2 8Sign Tests The sign test compares a numeric quantity to zero and determines if it is greater (positive), less (negative), or equal (zero). Both the relation test and the sign test can perform this function. For example, consider the following relation test: IF FIELDl Now consider the IF Both of at the and shows, 0 ... following FIELDl these same > sign POSITIVE test: ... tests accomplish the same thing and would always arrive result. The sign test, however, shortens the statement at a glance, Table 4-2 shows the applied to FIELDI. that it is testing the sign. sign tests and their equivalent relation tests as | Table 4-2 The Sign Tests SIGN TEST EQUIVALENT IF IF IF FIELDl1 FIELD1 FIELD1 POSITIVE ... NOT POSITIVE NEGATIVE ... IF IF IF FIELD1 FIELDl1 FIELD1 NOT NEGATIVE ZERO ... NOT ZERO ... ... ... RELATION IF IF IF FIELDl1 FIELD1 FIELD]l > 0 NOT < 0 ... > 0 ... IF IF IF FIELD]1 FIELDl1 FIELDl1 NOT = 0 NOT < 0 ... = 0 TEST ... ... ... Sign tests have no execution speed advantage over relation tests. The compiler actually substitutes the equivalent relation test for every correctly written sign test. (Sections 4.2.1 and 4.2.2 discuss the acceptable sign values and the treatment of illegal sign values.) 4.5.3 Class Tests The class test contains numeric interrogates or a alphabetic numeric data, and field uses flow of control in a program. For example, determines if FIELD1l contains numeric data. is true and IF program FIELDl control IS takes NUMERIC the true to the determine result to if it alter the the following statement If so, the test condition path of the statement. ... When reading in newly prepared data, it is often desirable to check certain fields for valid values. Relation tests and sign tests can only determine if the field's contents are within a certain range, and these tests both treat illegal characters in DISPLAY usage items as zeroes. Thus, some data preparation errors could pass both of -these tests. NUMERIC CHARACTER HANDLING 4-7 The NUMERIC class fields for If field the overpunch valid test being or as checks numeric a numeric (or alphanumeric) DISPLAY tested contains separate a sign character), the (whether test <carried checks it sign value. 1If the character position carrying the sign illegal sign value, the NUMERIC class test rejects program control takes the false path of the IF The for ALPHABETIC class test checks alphabetic (or wvalid alphabetic characters and the space the character positions the item of passes control to take the true information concerning Section 3.3.2.) 4.6 THE MOVE the the path the field contain ALPHABETIC a If an and the digit positions in class test passes the IF statement. characters test an valid contains the item alphanumeric) character. 1If ASCII class as for statement. character position contains a valid sign and all the field contain valid numeric digits, the NUMERIC the item and program control takes the true path of space), usage digits. and (A-Z causes o0of the IF statement. ALPHABETIC class test, fields all of or program (For further see Chapter 3, STATEMENT The MOVE statement moves following sample MOVE the contents of one field into statement moves the contents another. of FIELDl The into FIELD2. MOVE FIELDl1 TO FIELD2. Section 3.5 discusses the basic MOVE statement. This section considers MOVE statements as applied to numeric fields. These MOVE statements can be grouped into the following three categories: The l. Group 2. Elementary moves with numeric receiving 3. Elementary moves with numeric edited following each 4.6.1 of these Group moves, three sub-sections categories (4.4.1, fields, receiving 4.4.2, and and fields. 4.4.3) discuss separately. Moves The software considers a move to be a group move field or the receiving field is a group item. in a group move as alphanumeric class fields and an alphanumeric to alphanumeric elementary move. if either the sending It treats both fields performs the move as If either field in a group move is a numeric elementary item, the RTS treats the storage area occupied by that item as a field of alphanumeric bytes; thus, it ignores the USAGE, sign, and decimal point location characteristics of the numeric item. 4-8 NUMERIC CHARACTER HANDLING Only the item's allocated size, in bytes, affects the move operation. The RTS considers a separate sign character to be part of the item and moves it with the numeric digit positions. 4,.6.2 Elementary Numeric Moves the and items statement are elementary If both fields of a MOVE the move to be an the RTS considers 1is numeric, field receiving (The sending field may be either numeric or elementary numeric move. receiving field may be DISPLAY, COMP, or numeric The alphanumeric.) The elementary numeric move converts the data format of COMP-3 usage. the sending field to the data format of the receiving field. An alphanumeric sending field may be either an elementary data item or other than the figurative constants SPACE, 1literal any alphanumeric The elementary "literal". ALL or HIGH-VALUE, LOW-VALUE, QUOTE, numeric move accepts the figurative constant ZERO and considers it to It treats alphanumeric be equivalent to the numeric 1literal 0. sending fields as unsigned integers of DISPLAY usage. If necessary, the numeric move operation converts the sending field to the data format of the receiving field and aligns the sending field's It then moves the decimal point on that of the receiving field. sending field digits to their corresponding receiving field digits. If the sending field has more digit positions than the receiving the decimal point alignment operation truncates the sending field, truncated The end field, with the resultant 1loss of digits. depends upon the number of sending field (high-order or 1low-order) digit positions that find matches on each side of the receiving If the receiving field has fewer digit field's decimal point. positions on both sides of the decimal point, the operation truncates Thus, if a field described as PIC sending field. the of both ends 999V999 is moved to a field described as PIC 99V99, it loses one digit Figure 4-3 illustrates the left end and one from the right end. from this alignment operation (the carat (" ) indicates the stored decimal scaling position): | 01 AMOUNT1 MOVE Before After 99V99. PIC 123.321 execution execution TO AMOUNTI. 00 0O 23 32 Figure 4-3 Truncation Caused By Decimal Point Alignment NUMERIC CHARACTER HANDLING 4-9 If the sending field has fewer digit positions than the receiving field, the move operation supplies zeroes for all unfilled digit positions. Figure 4-4 illustrates this alignment (the carat (») indicates the stored decimal scaling position): 01 Before After TOTAL-AMT PIC MOVE TOTAL-AMT. TO execution execution Zero The 1 following 999Vv99. 000 00 001 00 Figure 4-4 Caused By Decimal Filling statement produces MOVE Consider the truncating and 001.00 TO the same TO MOVE "00100" results: statements STATEMENT 00100 Alignment TOTAL-AMT. following two MOVE zero-filling effects: MOVE Point and TOTAL-AMT their AFTER TOTAL-AMT 100 00 TO TOTAL-AMT 100 00 resultant EXECUTION Literals with leading or trailing zeroes have no significant advantage in space or execution speed with VAX-1l1l COBOL-74, and the zeroes are often lost by decimal point alignment. The MOVE moved. moved field statement's A signed receiving DISPLAY field usage dictates receiving how field the sign causes the will sign to be be as a separate quantity. An unsigned DISPLAY usage receiving causes no sign movement. A COMP usage receiving field, whether signed or unsigned, causes the sign to be moved; however, 1if the receiving field 1is wunsigned, the RTS sets its value to absolute. A COMP-3 receiving field always causes the sign to be moved. 4.6.3 Elementary Numeric The VAX-11 move to COBOL-74 4-10 NUMERIC a Edited run-time receiving field Moves system of considers numeric an elementary edited category numeric be an elementary numeric edited move. The sending field of an elementary numeric edited move may be either numeric or alphanumeric and, if numeric, its usage can be DISPLAY, COMP, or COMP-3. The RTS treats alphanumeric sending fields 1in numeric edited moves as unsigned DISPLAY usage integers. CHARACTER HANDLING the to The RTS considers the receiving field to be numeric edited category if it is described with a BLANK WHEN ZERO clause, following or a combination of the symbols: B Space P Decimal \Y Location of assumed decimal point; Z Leading numeric character position to be if insertion position; the scaling position; position contains a replaced by a space zero; insertion position; 0 Zero 9 Position contains a numeric character; / Slash insertion position; , Comma insertion position; . Decimal * Leading numeric character position to be asterisk if the position contains a zero; + Positive - Negative editing CR Credit editing DB Debit editing cs Currency symbol point insertion position; editing sign control symbol; sign control symbol; sign control sign control ($) by an symbol; symbol; insertion position. A numeric edited field may contain 9, those symbols without an editing numeric replaced V, and P, character but combinations of do not make the field edited. The numeric edited move operation first converts the sending field to DISPLAY usage and aligns both fields on their decimal point locations, it until field sending the zeroes) (with padding truncating or of digit positions on both sides of the number same the contains resulting the then moves It decimal point as the receiving field. digit wvalues to the receiving field digit positions following the COBOL editing rules. The COBOL editing rules allow the numeric edited perform any of the following editing functions: @ move operation to Suppress leading zeroes with either spaces or asterisks; NUMERIC CHARACTER HANDLING 4-11 e Float a sign and inserting currency suppressed zeroes, or minus sign through sign at either end of the plus the field; ®@ Insert zeroes and spaces; @ Insert commas and a Figure 4-5 MOVE FLD-B illustrates TO decimal several of TOTAL-AMT. point. these (Assume functions that with FLD-B the 1is statement, described as S9999v99.) TOTAL-AMT FLD-B PICTURE STRING CONTENTS AFTER 0023 0085 00 90 2227.99 ++++.99 23.00 -85.96 1234 0012 0000 1234 0012 00 34 34 00 34 2,27272.99 $,$$$.99 $,$$89.99 $$,585.99 $$9,999.99 1,234.00 $12.34 S0.34 $1,234.00 $0,012.34 0012 34 $$$$,555.99 $12.34 0000 00 $$$,$55.55 ++++.99 -12.34 0012 34 Skkxx *kxkx Qg9 Skkxkkkx] 2 34 0012 3M MOVE Figure 4-5 Numeric Editing The the currency symbol floating only more occurrences 4.6.4 Common The most the Errors, common Placing numeric Moving of ($) and the editing symbols. To float errors sign control symbols them, enter a string (+ of -) are two or symbol. Numeric made when an incorrect edited item. non-numeric MOVE Statements writing number data Trying to float the $ decimal point to force spaces. (Use $$.99 or into of numeric MOVE replacement numeric fields statements characters are: in a with group moves. or + insertion characters zero values to appear as .00 ++.99.) past the instead of Forgetting that the $ or + insertion characters require an additional position on the 1leftmost end that cannot be replaced by a digit (unlike the * insertion character which can 4-12 be completely replaced). NUMERIC CHARACTER HANDLING 4.7 THE ARITHMETIC STATEMENTS The COBOL arithmetic statements, COMPUTE on allow numeric data. ADD, SUBTRACT, MULTIPLY, DIVIDE, and COBOL programs to perform simple arithmetic operations This section covers the use of the COBOL arithmetic statements. The first five sub-sections (4.7.1 through 4.7.5) discuss the common features of the statements and the last five (4.7.6 through 4.7.10) discuss the individual arithmetic statements themselves. 4.7.1 Intermediate Results Most forms of the arithmetic statements perform their operations 1in temporary work 1locations, then move the results to the receiving fields, aligning the decimal points and truncating or zero filling the resultant values. This temporary work field, called the intermediate result field, has a max imum size of 18 numeric digits. The actual size of the intermediate result field varies for each statement, and is determined at compile time based on the sizes of the operands used by the statement. When the compiler determines that the size of the field Thus, exceeds 18 digits, intermediate a program that requests a multiplication operation following two between the fields, PIC 9(18) and PIC V99. (which would otherwise <cause the compiler to set up a intermediate result field -- 9(18)V99) actually causes the intermediate result it truncates the excess high-order digits. result PIC 20-digit following field 9(16)V99. VAX-11 COBOL-74 truncates high-order digits or low-order digits to the right of the decimal point, based on the assumption that most large data declarations are larger than ever need be, so zeroes occupy most of their high-order digit positions. Numeric data may be declared as PIC 9(12) or PIC 9(15) but the values that are placed in these fields will probably not exceed nine digits of range (1 billion) in most applications. When using large numbers (or numbers with many decimal places) that are close to 18 digits long, examine all of the arithmetic operations that manipulate those numbers to determine if truncation will occur. NUMERIC CHARACTER HANDLING 4-13 If truncation is a possibility, reduce the size of the number by dividing it by a power of 10 prior to the arithmetic operation. (This scaling down operation causes the low-order end to lose digits, but these are probably 1less critical.) Then, after the arithmetic operation, multiply the result by the same power of 10. To save the low-order digits temporary 1location before in such an operation, move the field to a the scaling DIVIDE, perform separate, identical arithmetic operations on both the original and the temporary fields, then, after the scaling MULTIPLY, combine their results. 4.7.2 The ROUNDED Phrase Rounding-off is an important tool The ROUNDED phrase causes the with RTS to most arithmetic round-off the operations. results of COBOL arithmetic operations. The phrase may be wused on any COBOL arithmetic statement. Rounding-off takes place only when the ROUNDED phrase requests it, and then only if the intermediate result has more 1low-order digits than the result field. VAX-11 COBOL-74 digit of stores that Consider of the rounds-off by adding absolute value of a 5 the to the 1leftmost truncated intermediate result before it result. the following illustration and assume an intermediate result 54321.2468: Coding: 01 FLD-A PIC S9(5)V9999, 01 FLD-B PIC S9(5)V99. ADD FLD-A Intermediate PIC The TO result FLD-B ROUNDED. field: S9(6)V9999. ROUNDED operation: Truncated Intermediate result field: 054321.24 F‘é 6&‘\ digits LEFT-MOST ROUNDED: FLD-B's ROUNDED Rounding 4-14 NUMERIC (ADD) result: Figure 4-6 Truncated Decimal CHARACTER HANDLING .00 054321.25 Point |50 |18 Positions truncated digit The following position (P). discusses the ROUNDING example rounds-off Assume an intermediate result GIVING phrase in numeric to the decimal of 24680. operations.) scaling (Section 4.7.4 Coding: 01 AMOUNT1 01 AMOUNT2 PIC PIC MULTIPLY 9999. 9999PP. AMOUNT1 BY GIVING AMOUNTZ2 Intermediate result PIC 999999, The 10 ROUNDED. field: ROUNDED operation: ,Truncated Intermediate result ROUNDED 4.7.3 The in The The 0246 (ADD) : AMOUNT2's Rounding field: ROUNDED result: |80. 50. 0247 Figure 4-7 Truncated Decimal Scaling |30. Positions SIZE ERROR Phrase SIZE ERROR phrase detects the loss of high-order the results of COBOL arithmetic operations. phrase digits may be used on any COBOL arithmetic non-zero digits statement. When the execution of a statement with no SIZE ERROR phrase results in a size error, the RTS truncates the high-order digits and stores the result without notifying the user. When the execution of a statement with a SIZE ERROR phrase results in a size error, the RTS discards the entire result (it does not alter the receiving fields in any way) and executes If the rounds the SIZE-ERROR statement the result imperative contains before both it phrase. ROUNDED checks and SIZE ERROR phrases, for a size error. NUMERIC CHARACTER the HANDLING RTS 4-15 The phrase cannot be used on numeric MOVE statements. program moves a numeric quantity to a smaller numeric inadvertently lose high-order following MOVE of a field to a digits. For smaller field: 01 AMOUNT-A PIC 9(8)V99. 01 AMOUNT-B PIC 9(4)V99. MOVE AMOUNT-A example, Thus, if a field, it may consider the TO AMOUNT-B. This MOVE operation always loses four of AMOUNT-A's high-order digits. Either of the following two statements could determine whether these digits are zero or non-zero, l. and could be tailored to any size field: 1IF AMOUNT-A NOT > 9999.99 MOVE AMOUNT-A TO AMOUNT-B 2. ELSE ... ADD ZERO ON SIZE TO AMOUNT-A ERROR GIVING AMOUNT-B ... Both of these alternatives allow the MOVE operation to occur only 1if AMOUNT-A loses no significant digits. If the value in AMOUNT-A is too large, both alternatives avoid altering AMOUNT-B and take the alternative execution path. 4.7.4 The GIVING Phrase The GIVING phrase moves the intermediate result field of an arithmetic operation to a receiving field. (The phrase acts exactly like a MOVE statement with the intermediate result serving as a sending field and the data item following the word GIVING (in the statement) serving as a receiving field.) The phrase may be used on the ADD, SUBTRACT, MULTIPLY, and DIVIDE the word GIVING is a numeric edited field, statements. If the data the item following RTS performs 4.7.5 the editing Multiple Operands the same way in ADD and it does for MOVE SUBTRACT Statements Both the ADD and SUBTRACT statements may contain a string one operand preceding the word TO, statements. FROM, or of more than GIVING. Multiple operands in either of these statements cause the RTS to add the string of operands together and use the intermediate result of that operation as a single operand to be added to or subtracted from, the 4-16 receiving NUMERIC field. CHARACTER HANDLING The following software three executes l. equivalent the multiple <c¢oding operand Statement: ADD A Equivalent 2. groups coding: B CDTOEF ADD A B, Statement: coding: C, GIVING TEMP. TEMP, D, GIVING TEMP. ADD TEMP, E, ADD TEMP, F GIVING F. ADD TEMP, G GIVING G. ADD TEMP, H GIVING H. B, (Just as with optional.) Only is statement the 4.7.6 only The The ADD result. The In 3 may 3) of a GIVING D D GIVING E. B GIVING TEMP. GIVING ADD TEMP C GIVING TEMP. ADD TEMP D GIVING E. any commas edited D. TEMP. FROM ADD A in these receiving D. statements field, are since it a GIVING phrase. and the adds more operands together contain multiple operands (with the two ROUNDED following or and SIZE ADD FIELDl ...TO Format 2. ADD FIELDl FIELD2 Format 3. ADD CORRESPONDING 1, the addends. These In 2, the receiving must not and the ERROR phrases. It stores the exception of may be written formats: 1. Format C TEMP C Format Format FROM B numeric containing C, ADD A statements, have B, E. ADD Statement statement may one COBOL statement statement Format in all coding: GIVING GIVING TEMP. TEMP, SUBTRACT Equivalent the GIVING TEMP. ADD ADD A, Statement: how H. TEMP, ADD 3. G ADD SUBTRACT A, Equivalent illustrate statements: be receiving fields in the fields addends. They may either be this format, omit the word TO. FIELD2 FIELD3 ... ...GIVING FIELD3 FIELD1 FIELD2. (FIELD2, numeric (FIELD3, numeric or TO FIELD3) edited . FIELD4 are of . the category. FIELD4) are numeric edited. NUMERIC one ... not one of the When using CHARACTER HANDLING 4-17 In Format 3, the receiving field (FIELD2) is one of the addends. Both FIELD]l] and FIELD2Z must be group items. The corresponding elements of FIELD]l are added to the corresponding elements of FIELD2. 4.7.7 The SUBTRACT Statement The SUBTRACT statement subtracts one, or operands from another operand and stores the sum of the result. The statement may contain multiple operands (with Format 3) and the ROUNDED and SIZE ERROR phrases. in one of the following formats: Format 1. SUBTRACT FIELDl ... FROM Format 2. SUBTRACT FIELDl ... GIVING FIELD3 FIELD4 Format 3. SUBTRACT CORRESPONDING two or more, the exception of It may be written FIELD2 FIELD3 ... . FROM FIELDZ2 ... . FIELD1 FROM FIELDZ2. In Format 1, the receiving fields (FIELD2, FIELD3) are both subtrahend and the difference (the result). These must not be in numeric edited category. In Format store the 2, the receiving result. fields (FIELD3, They may be either FIELD4) numeric or are used only the the to numeric edited. In Format 3, the receiving field (FIELD2) is both the subtrahend and the difference (results). Both FIELDl and FIELD2 must be group items. The corresponding 4.7.8 elements of FIELD2. The MULTIPLY Statement The MULTIPLY the result. statement multiplies one operand by another and stores The statement may contain the ROUNDED and SIZE ERROR phrases. It may contain multiple receiving operands. It may be written in either of the following formats: Format 1. MULTIPLY FIELDl1 BY FIELDZ2, Format 2. MULTIPLY FIELD1 BY FIELD2 In Format 1, multipliers. In Format multiplier edited. 4=18 the receiving fields (FIELD2, These must not be in the numeric 2, nor the receiving multiplicand. NUMERIC CHARACTER HANDLING FIELD3 ... . GIVING FIELD3, FIELD4 FIELD3) are also edited category. fields (FIELD3, FIELD4) are These may be either numeric or ... the neither numeric . COBOL's "near English" format could cause a problem with the statement, since it 1is common to speak of multiplying (multiplicand) by another number (multiplier) and to think result as a new value MULTIPLY for the EARNINGS multiplicand; BY MULTIPLY a number thus: of the 0. 24. Multiplier Multiplicand This statement is incorrect since the RTS stores the result in the multiplier field, and this multiplier is a literal. The compiler could diagnose this error, but would not diagnose it if the multiplier were a data item. Consider this multiplier written as a data item: MULTIPLY The compiler store the EARNINGS would statements TAX-RATE. not diagnose result using MULTIPLY ensures that BY of the this operation statements is to the result 1is safely MULTIPLY capture TAX-RATE. results: BY 0.24 BY TAX-RATE error, A good always write them ©properly stored. their EARNINGS statement's in in and when Format 2. This The following two | GIVING would practice - EARNINGS. or 4.7.9 The MULTIPLY EARNINGS DIVIDE Statement The DIVIDE statement divides one GIVING operand into EARNINGS. another and result. stores the The statement may contain the ROUNDED and SIZE ERROR phrases. With the exception of Formats 4 and 5, it may not contain multiple receiving operands. It may be written in any of the following formats: Format 1. DIVIDE FIELDl1 INTO FIELD2 FIELD3 ... Format 2. DIVIDE FIELDl1l INTO FIELD2 GIVING FIELD3 Format 3. DIVIDE FIELDZ BY Format 4. DIVIDE FIELDl1 INTO FIELDl BY FIELDl GIVING FIELD2 . FIELD3 GIVING FIELD4 FIELD4 FIELD3 ... ... . REMAINDER FIELD4. Format 5. DIVIDE FIELD2 GIVING FIELD3 REMAINDER FIELDA4. In Format dividends. 1, the receiving These must not be fields in the (FIELD2, numeric NUMERIC FIELD3) edited are also the category. CHARACTER HANDLING 4-19 are (FIELD3, FIELD4 ... ) fields receiving In Formats 2 and 3, the numeric or numeric either be may These neither dividends nor divisor. edited. In Formats 4 and 5, the receiving field (FIELD3) is neither a dividend nor a divisor. FIELD4 is the remainder. The receiving field and the remainder may be either numeric or numeric edited. The COMPUTE Statement 4.7.10 The COMPUTE statement computes the value of an and stores the value expression arithmetic in the result. It The statement may contain the ROUNDED and SIZE ERROR phrases. contain following multiple receiving operands. may The COMPUTE statement has the format: COMPUTE FIELDl1 FIELD2 ... = arithmetic-expression. The receiving fields (FIELD1l, FIELD2) may be either numeric or numeric edited. 4.7.11 Common Errors, Arithmetic Statements The most common errors made when using arithmetic statements are: ® Using an alphanumeric class field in an arithmetic statement. The MOVE statement allows data movement between alphanumeric class fields and certain numeric class fields, but arithmetic statements require that all fields be numeric. ) Writing the ADD or SUBTRACT phrase, edited ® but field. Writing a Format 2 ADD statements without the GIVING put the result into a numeric statement with the to attempting word TO; For example: ADD A TO B GIVING C. ) Subtracting a 1 from a numeric counter that was described as an unsigned quantity, and testing for a value of less than Zero. ) Forgetting that the MULTIPLY statement, without the GIVING phrase, stores the result back into the second operand (multiplier). 4-20 NUMERIC CHARACTER HANDLING ° Performing a series generate an when final the of calculations intermediate result result will be that fewer in such is larger digits. a way than (The as 18 to digits programmer should be careful to intersperse divisions with multiplications or to drop non-significant digits that result from multiplying large numbers (or numbers with many decimal places). ° Performing greater happen an than only operation the if on precision the field a field of its was that data contains a description. disarranged by a group value This can move or redefinition. ° Forgetting that, multiple specified ° in receiving for each an arithmetic fields, receiving the statment ROUNDED field that Forgetting that, in an arithmetic multiple receiving fields, the ON is containing phrase to be must be rounded. statement containing SIZE ERROR phrase, if specified, applies to all receiving fields. Only those receiving operands for which a size error condition is raised are left unaltered. The ON SIZE ERROR statement is executed after all the receiving fields are processed by the RTS. 4.8 ARITHMETIC COBOL provides EXPRESSION language arithmetically. statements ADD, In PROCESSING facilities particular, SUBTRACT, for the MULTIPLY, manipulating language and DIVIDE user-defined data provides the and facilities the arithmetic of arithmetic expressions wusing the +, -, *, /, and ** operators. 1In simple terms, a given arithmetic functionality may be expressed in one of several ways. For example, consider a total yearly sales of a salesman are to the the of four individual sales quarters. Figure expressing a solution to this problem in MOVE 0 ADD 2ND-SALES 3RD-SALES TO TEMP. 4TH-SALES TO TEMP 4-8 Explicit the statements to of TOTAL-SALES. Programmer-Defined COBOL programmer to develop computing develop GIVING the TOTAL-SALES, the partial chooses final a sums Temporary Work to value COBOL (i.e., program. That is, the attributes to a series (i.e., be maintained) NUMERIC Area of TOTAL-SALES. called intermediate important point here is that the programmer the temporary work area TEMP in integer and decimal places by the COBOL programmer. use for data-name, declares COBOL one method TEMP. TEMP. ADD process used TO TO ADD 4-8, 4-8 illustrates COBOL: TEMP. 1ST-SALES figure ADD TO ADD Figure In COBOL application in which be computed as the sum of single 1In the TEMP, is results). The explicitly defines the data division of class, are USAGE, specified and the number of explicitly CHARACTER HANDLING 4-21 Figure 4-9 below illustrates another way of expressing a the solution to problem: ADD 1ST-SALES, 2ND-SALES, 3RD-SALES, 4TH-SALES GIVING TOTAL-SALES. 4-9 FIGURE ARITHMETIC STATEMENT INTERMEDIATE RESULT FIELD ATTRIBUTES DETERMINED FROM COMPOSITE OF OPERANDS IN THIS EXAMPLE, THE PROGRAMMER CHOOSES TO COMPUTE TOTAL-SALES with a Analogous to the previous example, an statement. ADD single required to develop the partial sums of is field result ate intermedi the four quarterly sales quantities. 1In Figure 4-8, the programmer is cognizant of this requirement, but chose to define the intermediate result area TEMP explicitly in the data division of his COBOL program. However, for the example in intermediate 4-9, Figure the compiler defines the result field in a manner transparent to the COBOL source program. That is, the compiler allocates storage for and assigns various attributes to this "transparent" intermediate result field according to a well-defined set of rules defined by the COBOL language of attributes the particular, In specification. number-of-integer-places, number-of-decimal-places, and USAGE assigned by the software to the intermediate result field are a function of the (The reader should composite of source operands in the ADD statement. concerning the details for Manual Reference COBOL-74 VAX-11 the read composite of operands for the arithmetic statements.) The important point here is that the ANS-74 COBOL language standard prescribes rules for determining the attributes of intermediate result fields for the arithmetic statements, and the language processor, the VAX-11 COBOL-74 compiler, must implement those rules. As a final example, consider the following solution to our problem: COMPUTE TOTAL-SALES = 1ST-SALES + 2ND-SALES + 3RD-SALES + 4TH-SALES. Figure 4-10 Arithmetic Expression Intermediate Result Field Attributes Determined by Implementor-Defined Rules In Figure 4-10, the programmer solves the problem by using COMPUTE statement with an embedded arithmetic expression. a single Again, an intermediate result field is required and, as 1in Figure 4-9, 1is However, in defining the attributes of defined by the software. intermediate result fields for COBOL arithmetic expressions, the ANS-74 COBOL 1language standard is not as helpful to the user as it could be. 1In fact, the COBOL language standard gives almost complete to the implementor in defining the " attributes of the freedom The only rules arithmetic expression intermediate result fields. imposed by the ANS-74 COBOL language specifications are: 4-22 NUMERIC CHARACTER HANDLING 1. Arithmetic operations are to be combined without restrictions 2. Each on the composite of operands and/or implementor will arithmetic receiving indicate techniques fields. used in handling expressions. Thus, the user can and should expect differences between various implementations of ANS-74 COBOL. The rest of this section describes how the VAX-11 COBOL-74 compiler computes the sizes of intermediate result fields. The compiler computes the size of an each intermediate result component operation of an arithmetic expression. can be stated OP1 field for Each operation as: OPR OP2 where: 0):21 is the OPR is an arithmetic operator OP2 is the first operand second operand The size of an intermediate result is described in terms of the number of integer places (IP) and the number of decimal places (DP). The symbol DPEXP represents the maximum number of decimal places 1in the entire arithmetic expression. OPR + and - max(IP(OPl), IP(OP2)) DP = max (DP(OPl1), IP = DP(OP2)) + * IP= IP(OP1l) DP = DP(OPl) / IP = IP(OPl) + DP(OP2) DP = max (DPEXP, max (DP(OPl), * % For 1 + IP(OP2) + DP(OP2) DP(OP2) + 1)) exponents that convert to one-word values, a = 0P2 b = OP2 + DP(OP1) Otherwise, a=9, if IP(OP2) =1, otherwise, a = 19 b = DPEXP and IP DP = IP(OPl) * a = max (DPEXP, DP(OPl) * b) NUMERIC CHARACTER HANDLING 4-23 CHAPTER TABLE 5.1 5 HANDLING INTRODUCTION With COBOL, as with any other language, any data item program refers must be uniquely identified. identification of data items is usually accomplished unique name to each item. However, to which the This unique by assigning a 1in many applications this 1is tedious and inconvenient; often programs require too many names for of type same the contain but names different have that items information. Tables provide a simple solution to this problem. VAX-11] COBOL-74 includes full table handling capabilities as outlined for standard COBOL in the 1974 ANSI Standards. A table is a repetition of one item (element) in memory. This repetition is accomplished by the use of the OCCURS clause in the data description entry. The literal value in the OCCURS clause causes the software to duplicate the data description entry as many times as indicated by that value, thus creating a matrix or table. The elements may be initialized with the VALUE clause or with a or synchronized contain may They instruction. procedural unsynchronized data. They may be accessed only with subscripted procedural instructions. A subscript is a parenthesized integer or data name (with an integer value). The integer value represents the desired occurrence of the element. This chapter discusses how to set up tables and access them accurately and efficiently. It attempts to cover any problems that may be encountered while handling tables. Read it through carefully before setting 5.2 up tables with VAX-11 COBOL-74. DEFINING TABLES To define a table with VAX-11] COBOL-74, simply complete a standard data description for one element of the table and follow it with an OCCURS clause. The OCCURS clause contains an integer which dictates the number of times that element will be repeated in memory, thus creating a table. The OCCURS phrase has Format 1 OCCURS integer-2 two formats: TIMES ASCENDING KEY IS data-name-2 [, data-name-3] ... oo DESCENDING [ INDEXED BY index-name-1 Format 2 OCCURS integer-1 TO ASCENDING integer-2 [, index-name-2] ...] TIMES KEY IS data-name-2 [, data-name-3] ... J oo DESCENDING [ INDEXED BY index-name-1 [, index-name-2] ...] In either format, the accommodate integer-2 system generates occurrences of the the amount allocated of storage The of storage required software will DEPENDING ON data-name-1 to repeat in the a buffer 1large data description. either data automatically map the mapping a table into memory, the mapping which depend on whether the items or not. If they do not contain number 50 of occurrences bytes of 01 (5X10 for the is equal to integer-2 elements the amount times. into memory. When software follows the rules for element contains synchronized synchronized items, the software maps them into adjacent memory locations be easily calculated by multiplying the or case entry enough to Therefore, and the size of table size of the the element illustrated in table times Figure can the 5-1, memory). A-TABLE 03 A-GROUP PIC X(5) OCCURS 10 TIMES. Figure 5-1 Defining a Table 5.2.1 The OCCURS Phrase When Format 1 is used, a (number of occurrences) - Format 1 fixed length table is is equal to the value generated, whose length specified by integer-2. This format is useful for storing large amounts of frequently used reference data whose size never changes. Tax tables, used in payroll deduction programs, are an excellent example of where a Format 1 (fixed 5-2 length) TABLE table might HANDLING be used. 5.2.2 The OCCURS Phrase - Format 2 Format 2 is used to generate variable length tables. When table whose 1length (number of occurrences) 1is equal to specified by data-name-1l is generated. used, a the value NOTE Data-name-1 must always be a positive integer whose value 1is equal ¢to or greater than integer-1 than integer-2. Unlike format format 2 1 tables, tables can be the number but not greater of occurrences dynamically expanded or of data reduced to items satisfy 1in user needs. By generating a variable length table, the user is, in effect, saying; "build me a table that can contain at least integer-1 occurrences, but no more than integer-2 occurrences, and set its number of occurrences equal to the value specified by data-name-1". Data-name-1 user always access. To use) of a table, accordingly. reflects expand the the the user number size need of (number only occurrences of increase Likewise, reducing the value in data-name-1 occurrences available for user access. available occurrences the value will reduce available of the for for data-name-1 number of 5.3 MAPPING TABLE ELEMENTS Section 5.2, when the software unsynchronized item, it maps the adjacent locations in memory. of a simple table and the way 01 A-TABLE. 03 Memory Map: words JI bytes |zr|1rr| A-GROUP av|v Jvr fJ{ 11 J 1 0 J001 P A-GROUP description | A-GROUP Mapping PIC X(5) {viz]vriiz 1] A-GROUP | N OCCURS |1x |1 A-GROUP Figure 5-2 a Table into 10 TIMES. —— Description: Consider the following data it is mapped into memory: —1 >< Table detects an OCCURS table elements into L As mentioned in clause 1in an e Memory TABLE HANDLING 5-3 The data description in Figure 5-2 causes the items of five bytes each (elements) ascending memory locations for a total of software to set up ten and place them in adjacent 50 character positions, thus creating a table. Since the length of each A-GROUP element is odd (5), the memory addresses of each subsequent element will alternate between odd and even locations. The SYNCHRONIZED clause causes the software to add a fill byte to items that contain an odd number of bytes, thereby making the number of bytes in that item even. This ensures that each subsequent occurrence of addresses, of that element element. SYNCHRONIZED A-GROUP the but will map the clause, were will same If the the software synchronized, not (odd data it alternate or even) description would would map it expand between as the of A-GROUP quite its odd first and even repetition contained differently. length to three a If words. The item will, by default, be synchronized to the left occupying the first five <characters of the three words. The software supplies a padding character to fill out the third word. This padding character is not a part of the A-GROUP element and table instructions referring to A-TABLE will not detect the presence or absence of the character. The padding character does, however, affect the group item and, hence, the table. Without A-TABLE required only 50 character positions; it requires 60 character positions. (This padding Although character the -- following the SYNCHRONIZED clause overall tenth element has length of the the SYNCHRONIZED clause, now, with the clause, length includes the last 1little in the value table.) when used with alphanumeric fields, an understanding of the concept is essential before attempting to use COMP and INDEX data items in tables. The software automatically synchronizes all COMP and INDEX usage data items, and will most probably alter the size of any table (often drastically) that contains these data types. Consider the following illustration of a synchronized data item being mapped by the software: Table Description: 0l A-TABLE. 03 A-GROUP OCCURS 20 05 ITEM1 PIC X. 05 ITEM2 PIC S999 TIMES. 1--ITEM1 2--ITEM?2 COMP. S--SLACK BYTE Memory words bytes Map: | 1 IT] 1T | 111] (212 01T | 1IVv] ) P 1 A-GROUP A-GROUP Figure COMP Synchronized 5-4 TABLE HANDLING [ viz|vizz] ... [2[20 %] P Ol A-GROUP Vv | VI (2720 3i] 5-3 Item [2[2 A-GROUP in a Table [ | .-- ... Since the software synchronizes the ITEM2 fields (COMP), these fields each occupy a single word in memory; thus, a slack byte follows each occurrence of ITEM1l. Each repetition of A-GROUP consumes four bytes of memory -- one byte for ITEM1l, one byte for the slack byte, and two bytes for ITEM2. A-TABLE, then, requires 80 bytes of memory (20 elements of four bytes each). Now, consider the effect of adding a l-byte field to A-TABLE. If we place the field between ITEM1 and 1ITEM2, it will take the space formerly occupied by the slack byte. This has the effect of adding a data byte but leaving the size of the table unchanged. Consider the following illustration: Table Description: 01 A-TABLE. 03 A-GROUP OCCURS 20 TIMES. 05 ITEM1 PIC X. 05 ITEM3 PIC X. 05 ITEM2 PIC S999 COMP. 1--ITEM1 Memory Map: f words |1 bytes |11t Jrrr|v [ v 2--ITEM2 3--ITEM3 Jvil].. [I[3[2[2f1[3[2[2[1][3[2][]... | D . A-GROUP Adding a A-GROUP Field ) . A-GROUP J) Figure 5-4 without Altering the Table Size If, however, we place the l-byte field after ITEM2, it has the effect of adding 1its own length plus another slack byte. Now, each element requires six full bytes and the complete table consumes 120 bytes of memory (6X20)! This is due to the fact that the first repetition of ITEM]1 falls on an even byte and, in order to keep the mapping of each A-GROUP element the same, the software allocates each successive repetition of ITEM1 to an even byte address. Thus, it assigns ITEM3 to the even byte of the third word and adds a slack byte to guarantee that the next element begins on an even byte. Consider the following illustration: Table Description: Memory Map: Odd Even or words bytes E O 01 A-TABLE. 03 A-GROUP OCCURS 20 05 ITEM1 PIC X. 05 05 ITEM2 ITEM3 PIC PIC S999 X. TIMES. COMP. E I| N E I . oo .o & A-GROUP Adding One Byte Figure which Adds Two 5-5 Bytes to the Element TABLE Length HANDLING 5-5 NOTE The illustrations in this section show each byte with an even address (E) as the leftmost byte, and each byte with an odd address (0) as the rightmost byte. (The two bytes, odd and even, are reversed in actual memory.) If, however, we ITEM1 to occur use a FILLER byte to force the first allocation of on an odd byte, A-GROUP again requires only four bytes and no slack bytes. item byte. even occupies the The software number synchronized are needed A-TABLE of 5-6 illustrates this. bytes in 1length in only 81 the FILLER order to guarantee that the bytes. Description: 01 A-TABLE. 03 FILLER PIC X. 03 A-GROUP OCCURS 20 05 ITEM1 PIC X. 05 ITEM2 PIC S999 05 Memory Map: odd even or Since item(s) will map onto word boundaries. No slack bytes and A-GROUP elements are again only four bytes long, and requires Table Figure even byte of the first word, ITEMl1l falls on an odd requires that each repetition of ITEM1 must be an words bytes E O EO I IT FI1 ]| 2121 FILLER’ /L Forcing A-GROUP EO ITEM3 PIC TIMES. COMP. X. EO EO EO EO .oo IITI | IV 3¥1 ] 2121 | \'/ 311] — VI VII 2]21]3 .o oo A-GROUP A-GROUP Figure 5-6 an 0dd Address By Adding a 1-Byte Item to the Head of the Table FILLER If we try to force ITEM1 onto an odd byte with a SYNCHRONIZED RIGHT clause, the software maps ITEMl1l into the odd byte, but prohibits all repetitions of the element from using the even byte. Thus, the first repetition of A-GROUP has a slack byte at its beginning and, so that the next element can begin (with a slack byte) at an even address, another slack byte (odd) following ITEM3. This expands the element length to six bytes and the table length to 120 bytes. 5-6 TABLE HANDLING Table Description: 01 A-TABLE. 03 Memory Map: Odd or words Even EO EO EO |IT | III I bytes 1] 2]2] A-GROUP 05 ITEM2 PIC SYNCHRONIZED S999 COMP. 05 ITEM3 PIC X. EO EO V I VI 1]2]2] of To determine how the following two rules: a of a X EO EO EO JVII|VIII|IX | 3 1]2]2 A-GROUP Figure Effect software Item as will |3 A-GROUP RIGHT. « oo ... . oo ... 5-7 SYNCHRONIZED FILLER TIMES. PIC A-GROUP The 20 ITEM1 EO ]IV 3 OCCURS 05 RIGHT shown map in a Clause Figure given Instead 5-6 table, apply l. software maps all items in the first table element into memory words as with defined with a data description, obeying explicit synchronization requirements. 2. If the first repetition contains any elementary items implicit or explicit synchronization, the software maps The successive same way slack repetition as the byte, if first of the element repetition. necessary, to make into It the repetition of a any item properly any implicit or memory words does the this size of by with each in the adding one the element even. 5.3.1 1Initializing Tables If a table contains only DISPLAY items, it can be set initial value (initialized). To initialize a table, VALUE OCCURS phrase on clause. initialized the record The tables: level sample preceding data the definitions, item to any desired simply specify a containing below, will TABLE HANDLING set the up 5-7 Table Description: Memory - 01 A-TABLE VALUE IS "JANFEBMARAPRMAY JUNJULAUGSEPOCTNOVDEC", 03 MONTH-GROUP PIC XXX USAGE DISPLAY OCCURS 12 TIMES. Map: [x1 [T words [rzzfzv [ v [vi Jvizfvizzix | x —1 MONTH-GROUP —— ! MONTH-GROUP MONTH-GROUP MONTH-GROUP [x1 [ X171} [U[N}J|UJL|A[U[G] byte contents [J[A[N[F[E[BIM|A[R]A]P[R{M[A]Y]J _”MONTH-GROUP MONTH-GROUP MONTH-GROUP MONTH-GROUP Figure 5-8 Initializing Tables Often a table is too long to initialize with a single literal, or it that cannot be initialized (numeric, alphanumeric, or items contains the These items can be individually initialized by redefining COMP). contains the OCCURS clause. that 1level the preceding level group Consider the following sample table descriptions: 01 A-RECORD-ALT. 05 FILLER PIC XX VALUE "AX". 05 FILLER PIC 99 COMP VALUE 1. 05 FILLER PIC XX VALUE "BX", 05 FILLER PIC 99 COMP VALUE 2. Table Description: 01 A-RECORD REDEFINES A-RECORD-ALT. 03 A-GROUP OCCURS 26 TIMES. 05 05 Memory Map: ITEM1 PIC ITEM2 PIC Binary 1 words 1 byte contents at initialization time 1 I L AfXT | A-GROUP A-GROUP =% Figure COMP. Binary 2 [tz [11z[1v | ... 1 X. S99 —— B X - ... 5-9 Initializing Mixed Usage Fields In the preceding example, the slack bytes in the (ITEM1) 5-8 are being TABLE initialized HANDLING to X. alphanumeric fields Table Description: 01 A-RECORD-ALT. 03 FILLER PIC X(30) VALUE 1IS "AAAAAAAAAABBBBBBBBBBCCCCCCCCCC". 03 FILLER PIC X(30) VALUE 1S "DDDDDDDDDDEEEEEEEEEEFFFFFFFFFF". (etc.) 01l A-RECORD 03 Memory ITEM1 REDEFINES PIX X(10) A-RECORD-ALT. OCCURS 26 TIMES. Map: word | 1 byte {11 [z1xf{1v | v |vI |viz|vizzfzx | x [ATATATA[ATA|ATA|ATA[B[B|B[B[B[B contents at | ] initialization[__ time l g ITEM1 Figure 5-10 Initializing Alphanumeric example, each FILLER item ... J v ITEM1 In the preceding table elements. |x1 | ... [B[B|B[B|C[C| oo Fields initializes three 10-byte When redefining or initializing table elements, allow space for any slack bytes that may be added due to synchronization (implicit or explicit). The slack bytes do not have to be 1initialized; however, they may be and, if initialized to an uncommon value, they may even serve as a debugging aid for situations such as a statement referring to the record 1level above the OCCURS clause or another record redefining that level. Sometimes the length and format of table items are such that they would best be initialized by statements in the Procedure Division. Once the program OCCURS must clauses have able to be established access the the necessary elements of individually. Subscripting and indexing are by COBOL for accessing individual elements. 5.4 the two tables, the tables those methods provided SUBSCRIPTING AND INDEXING To refer name of to a the particular element within a table, desired element with a parenthesized simply follow the subhscript or index. A subscript is an integer or a data-name that has an integer value; the 1integer value represents the desired occurrence of the element -an integer value of 3, for example, refers to the third occurrence of the element. An index 1is a data-name that has been named in an INDEXED BY phrase in the OCCURS clause. TABLE HANDLING 5-9 5.4.1 Subscripting with Literals A literal subscript is simply occurrence represents the A-TABLE, I-RECORD. a whose integer parenthesized number of the desired element. value In figure causes the (2) instruction 5-11, the literal subscript in the MOVE the contents of the second element of the table, software to move to 0l Table Description Procedural A-TABLE. _ 03 A-GROUP PIC X(5) OCCURS TO I-RECORD. MOVE A-GROUP(2) Instruction Figure 10 TIMES. 5-11 Literal Subscripting If the table has more than one level (or dimension), follow the name item with a list of subscripts, one for each OCCURS the desired of The first subscript in the clause to which the item is subordinate. item is first OCCURS clause to which the the list applies to the 1in A-GROUP -level encompassing most the is (This subordinate. second subscript in the list applies to the The example.) following the to next most encompassing level, and the last subscript applies occurrence desired the (or accessed being OCCURS clause 1level lowest number of the item named in the procedural instruction -- ITEM5 in the following example). the subscripts (2,11,3) in the MOVE instruction Consider Figure 5-12; repetition of ITEM5 in the third the to move software the cause to A-GROUP of eleventh repetition of ITEM3 in the second repetition I-FIELDS. (For illustration simplicity, I-FIELD5 is not defined.) the 1in ITEM5 of (ITEM5(1,1,1) would refer to the first occurrence table and ITEM5(5,20,4) would refer to the last occurrence of ITEMS.) 01 A-TABLE. 03 Table Description | | A-GROUP OCCURS 5 05 ITEM1 PIC X. 05 ITEM2 PIC 99 COMP OCCURS 20 05 Procedural Instruction TIMES. TIMES. ITEM3 OCCURS 20 07 ITEM4 X. 07 ITEMS5 PIC XX OCCURS MOVE ITEM5(2, PIC 11, 3) 5-10 TABLE HANDLING 4 TIMES. TO I-FIELDS. Figure Subscripting 5-12 a Multi-Dimensional TIMES. Table NOTE Since an ITEM5 is not occurrence permitted in subordinate number the for subscript to ITEM2, ITEM2 is Figure 5-13 summarizes the subscripting rules for items and shows the size of each field in bytes. NAME FIELD THE FIELD NAMED ITEM1 ITEM2 ITEM3 ITEM4 ITEMS slack NONE 1110 ONE 222 1* TWO 2 TWO 9 TWO 1 THREE 2 byte Figure 5-13 Subscripting Rules Multi-Dimensional Operations Performed by the for a Table Software When a literal subscript is used to refer to an item software performs the following steps to determine of the item: l. The compiler 2. The not be converts the literal to compiler a range checks the subscript less than 1 nor greater than the specified by the OCCURS clause) and message if above OF FIELD ONE a the SIZE A-TABLE 5.4.2 of OF SUBSCRIPTS REQUIRED TO REFER TO A-GROUP Plus each NUMBER OF * not list. the value is out of in a the l-word table, exact the address binary value. value (the value must number of repetitions prints a range. diagnostic The compiler decrements multiplies it by the the value of the subscript by 1 and size of the item that contains the OCCURS clause corresponding to this subscript, thus forming an index value; it then stores this value, plus the literal subscript, in the object program. At run time, for a fixed length table, the RTS adds the index value (from 3 above) to a base address, thus determining the address of the desired item. For a variable length table reference, the procedure for by the procedure described in fixed length tables Section 5.4.6. TABLE is preceded HANDLING 5-11 Subscripting with Data-Names 5.4.3 As discussed earlier in this section, subscripts may also be specified To use a data-name as a instead of literals. using data-names (COMP or DISPLAY) . subscript, simply define it as a numeric integer the time it is used at positive be must It may be signed, but the sign as a subscript. The sample subscripts in accessed in Figure 5-12, figure (2, Data Descriptions of Subscript data-names Procedural 11, to refer 5-14 3). the element same 01 KEY1l PIC 99 USAGE DISPLAY. 01 KEY2 PIC 99 USAGE COMP. 01 KEY3 PIC MOVE 2 MOVE MOVE 11 TO KEY2. 3 TO KEY3. Instructions TO S99. KEY1. GO TO TABLERTN. TABLERTN. ITEMS (KEY1l KEY2 KEY3) MOVE TO I-FIELDS. Figure 5-14 Subscripting with Data-Names Operations Performed by the RTS 5.4.4 When a data-name subscript is used to refer to an item in a table, the RTS performs the following steps at run time: 1. If data-name's data type 1is DISPLAY, the software 2. the the software range checks For fixed 1length tables, less than 1 nor (the value must not be subscript value greater than the number of repetitions specified by the and terminates the image (with a diagnostic OCCURS clause) For variable length tables, message) if it is out of range. 5.4.6 is followed. Section in the procedure described 3. The software decrements the value of the subscript by 1 and it by the size of the item that contains the multiplies thus forming OCCURS clause corresponding to this subscript, an 4. 5-12 the converts it to a l-word binary value. index value. to a Dbase The software adds the index value (from 3 above) item. desired the of address the determining thus address, TABLE HANDLING 5.4.5 Subscripting with The same rules apply for subscripts except that phrase of the OCCURS Indexes the specification the index must of be indexes named in as the apply to INDEXED BY clause. An index-name item (an item named in the INDEXED BY phrase of the OCCURS clause) has the ability to hold an index value. (The index value is the product formed the software for 1literal location, within the table, The compiler allocates an INDEXED BY normal data a phrase. items; they in step 3 of the operations performed by or data-name subscripts -- the relative of the desired item.) 2-part data These cannot item for index-name be moved each items about, name that cannot be as to a file, etc. However, the SET verb can change their values and relation tests can examine their wvalues. One part of the 2-part index-name item contains a subscript value and the other part contains an index value. Consider the following illustration: INDEX PART > SUBSCRIPT PART > redefined, follows accessed written Figure 5-15 Index-Name Item Whenever a SET statement software performs an the index part. Only or receiving field. places a new value in the subscript part, index value computation and stores the the subscript part of the item acts as The 1index part is never altered by operation and is never moved to another item. It is used only the 1index-name 1is used as an index referring to a table item. sample MOVE statement in Figure 5-16 would move the contents of third repetition of A-GROUP to I-FIELD. once again, I-FIELD is not defined.) 0l Table Description (For illustration A-TABLE. 03 A-GROUP OCCURS 5 INDEXED Procedural Instructions SET IND-NAME MOVE A-GROUP Figure 5-16 Subscripting With Index-name TO the result in a sending any other when The the simplicity, TIMES BY IND-NAME. 3. (IND-NAME) | TO I-FIELD. Items TABLE HANDLING 5-13 5.4.6 The Operations Performed by the RTS performs the RTS following steps when it statement: executes the SET ; 1. The RTS converts the contents of the statement to a l-word binary value. 2. The RTS range checks the value (the sending value field must of not the be SET . less than 1 nor greater than the number of repetitions specified in the OCCURS <clause) and terminates the image with a diagnostic message if it is out of range. 3. For The RTS decrements the value by 1 and multiplies size of the 1item that contains the OCCURS forming an index value. fixed the once the SET software has encountered length tables, the index-name statement has been item as an it by clause, the thus executed and index, it only has to add the index value (from 3 above) to a base address to determine the address of the desired item. Since this is the only action performed, the execution speed of a procedural statement with an indexed data-name 1is equivalent to a reference with a literal subscript. For a variable length table, when the index-name is encountered as an index, the procedure described in Section 5.4.6 is invoked before following the fixed length table logic. However, the SET statement itself 1is not impacted by the fixed/variable characteristic of the associated table. VAX-11 COBOL-74 initializes the value of all index-name items to subscript value of 1 (index value of 0), hence an attempt to use index-name item as an index before it has been the receiving field a SET verb will not result in an out-of-range termination. a an of NOTE Initialization of index-name items is an extension to the ANSI COBOL standards. Users concerned with writing COBOL programs. that adhere to standard COBOL should 5.4.7 Relative not rely on this feature. Indexing To perform relative indexing, when referring to a table item, simply follow the index-name with a plus or minus sign and an integer literal. Relative indexing, albeit easy to use, causes additional overhead to be generated each time a table item is referenced in this fashion. At compile time, the compiler has to compute the index value corresponding to the specified literal; and transfer this index value to the object file. At run time, the index value for the 1literal is added to (+) 5-14 TABLE or subtracted HANDLING from (-) the index value of the index-name. The resulting index value is stored in a temporary location. The RTS adds this temporary index value to the base address of the table to determine the address of the desired table item. At this point, a range check 1is performed on the temporary index value to insure that the resulting index is within the permissible range for the table. For fixed 1length tables, this index straightforward. The size of the table and this size is passed along to the RTS compare against this fixed value is all if For The a given a index value is within manipulation 1is relatively is known at compilation time, in the object file. A simple that is required to determine the permissable range for the table. variable length table, however, the process 1is more 1involved. current number of occurrences (data-name-1) for the table must be determined and range checked; the index value corresponding to the current number of occurrences must be calculated; then the temporary index value must be range checked using the current number of occurrence's index value. The run-time overhead required for the relative indexing of variable length tables 1is significantly greater than that required for fixed length tables. 1In either case, the index portion of the index-name is not altered. range) value, If any of execution the 1is range checks reveals terminated with an an illegal (out of apropriate error message. The sample MOVE of A-GROUP to verb. instruction in Figure 5-17 I-FIELD 1if 1IND-NAME has moves the fourth not been altered MOVE TO A-GROUP (IND-NAME + 3) repetition with a SET I-FIELD. Figure 5-17 Relative Indexing The actual operation of accessing a table element is shorter at run time since the compiler has calculated the index value of the literal at compile time and has stored it in the object program ready for use. Relative indexing, therefore, involves two additions and a range check dat run time. It leaves the index-name item unaltered. 5.4.8 Index Data Items Often a program will require that the value of an index-name item be stored outside of that item. It 1is for this purpose that VAX-11 COBOL-74 provides the index data item. Index data 1items are l-word binary integers with implicit synchronization. (The 1-word size corresponds to the subscript part of the index-name item.) They must be declared with a USAGE IS INDEX phrase and they may be modified (explicitly) only by the SET statement. TABLE HANDLING 5-15 Subscript Part - | Figure 5-18 Data Item Index Since index data items are considered to contain only the subscript part of an index-name item, when a SET statement "moves" an index-name item to an index data item, only the subscript part 1is moved. Likewise, when a SET statement "moves" an 1index data item to an index-name item, a new index value is computed by the software. This is done to guarantee that an index-name item will always contain a good index value. The only advantage gained by using index data items over items 1is that the data description is shorter, easier moreself-documenting. Further, the restrictions placed index items may be usefulTMin debugging the program. 5.4.9 The SET numeric, COMP to write, and on access to Statement The SET statement alters the value of index-name 1items and copies their value 1into other items. When used without the UP BY/DOWN BY clause, it functions like a MOVE statement. Figure 5-19 illustrates the legal data movements that the SET INDEX-NAME NUMERIC | NUMERIC (COMP [ DATA LITERAL statement ITEM __ (INDEX PART) _ _ INDEX || (SUBSCRIPT PART) [*—] NAME INDEX-NAME OR DISPLAY Legal can perform. ITEM ] ITEM __(INDEX PART) | ] Data DATA (SUBSCRIPT PART) Figure 5-19 Movement with the SET Statement The SET statement may be used with the UP BY/DOWN BY clause to alter the value of an index-name item arithmetically. The numeric literal is added to (UP BY) or subtracted from (DOWN BY) the subscript part, and the index part 1is recalculated by the software after the appropriate range check against the number of repetitions for the table. The SET statement 1is not affected by whether the table is fixed or variable length. 5-16 TABLE HANDLING 5.4.10 Referencing a Variable~Length Table Element at Run Time At run time, when a procedural reference involves an variable length table, the following procedure is used: 1. Determine the number of occurrences in the table (the contained in data-name-1), and verify its legality. (integer-1 2. Verify that the (subscript <= data-name-1 subscript appropriate error <= 1in a value integer-2) is within the legal range. <= data-name-1) If any of the above checks fails, 5.4.11 element execution 1is terminated with an message. Referencing a Dynamic Group at Run Time A dynamic group is defined as a group item that contains a subordinate item that is a wvariable length table. At run time, when a dynamic group is 1. referenced, the following procedures are followed: The number of occurrences of the subordinate variable 1length table is determined, and checked for 1legality; i.e., integer-1<=data-name-1<=integer-2. If this check fails, execution terminates and the appropriate error message is issued. 2. The size of the dynamic group is calculated. The number of occurrences of the variable 1length table (data-name-1l) 1is multiplied by the size of one table entry. The resulting number is then added to the fixed size of the dynamic group. NOTE The size fixed of including 5.4.12 The The SEARCH sequential size of the the a dynamic group group variable up to length is but the not table. SEARCH Verb verb has search of two the formats: specified index setting; and Format 2 search of the specified table, Format 1, which performs a table beginning with the current which performs a selective (binary) beginning with the middle of the table. Both formats allow the programmer to specify imperative statements within the SEARCH verb. At run time, an imperative statement contained within a search verb is executed only when one of the exit paths (success or failure) is taken. TABLE HANDLING 5-17 The failure path is defined either explicitly by the AT END statement, in which case the imperative statement which follows it is executed; or by default, in which case control is passed to the next procedural sentence. In either case (success or failure), after an imperative statement is executed, control 1is passed to the next procedural sentence. 5.4.13 The SEARCH Verb - Format 1 directs the The OCCURS clause INDEXED by phrase. Format 1 RTS to search the indicated table sequentially. for the table being searched must contain the Unless otherwise specified 1in the SEARCH statement, the first index 1is the controlling index for the table search. The search begins with the current 1index setting, and progresses through the table, augmenting the index by one as each occurrence 1is interrogated. If any of the specified conditions is true (success), the associated imperative statement is executed; the search exits; and the index remains at the current setting. If the before possible number of occurrences any of the specified conditions exit path is taken. That 1is, either specified) 1is taken, or <control 1is for the are met, table 1is exhausted the specified failure the AT END passed to the exit path (if next procedural sentence. Figure 5-20 contains table in a serially. an example of using the SEARCH verb Associated with Format 1 is the optional VARYING phrase. can be specified by using any of the following methods: 1. default - phrase 2. VARYING index-name-n 3. VARYING identifier-2 4, VARYING index-name-2 to search This a phrase omitted NOTE a. The following above methods is is An associated index name augmented by serial search. the allowable true used. regardless with the of table one, by the RTS, for This controlling index, number of occurrences which of the 1is methodically each when for cycle of the compared to the table, dictates the permissible range of search cycles at time. When an exit occurs (success or failure), index remains at the current setting. 5-18 TABLE HANDLING run this b. The RTS will not initialize the index when the search begins. It 1is the programmers responsibility to insure that the initial index setting is the appropriate one. The RTS will begin processing the table with the setting it finds when the search is initiated. When method 1 is used, the first index name with the table is used as the controlling (index-name-l1) associated index. Only this index is set to consecutive values by the RTS serial search processor. Figure 5-20, Example 2, for an example of using method 1. See When method 2 is used, index-name-n is any index that 1is associated with the table being searched. It becomes the controlling index for the table. It alone is set to consecutive values by the RTS search processor. See Figure 5-20, Example 3, for an example of using method 2. When method 3 is used, identifier-2 is augmented by one each time the first index (controlling index) for the table is augmented by one. Identifier-2 1is not a substitute index. It merely allows the programmer to maintain an additional pointer to elements within a table. See Figqure 5-20, Example 4, for an example of method 3. When method 4 is used, index-name-2 is an index that 1s associated with a table other than the one being searched. Each time the controlling index (1lst index for the table) of the searched table 1is augmented, index-name-2 1is also augmented. See Figure 5-20, Example 5. 5.4.14 The SEARCH Verb - Format 2 Format 2 is used to direct the selectively. The selective RTS to search the indicated table (binary) search is predicated upon the ASCENDING/DESCENDING KEY attributes of the table being searched. Therefore, an ASCENDING and/or DESCENDING KEY (s) must be specified in the OCCURS clause that defines the table, to inform the RTS that the keys are stored within the table in ascending or descending order. The INDEXED BY phrase must also be specified. When the binary search is executed, the RTS uses the first or only index associated with the table as the controlling index for the search. The selective (binary) search is implemented in the RTS as follows: l. The RTS examines the range of permissible values for the index of the table being searched; selects the median value; and assigns this median value to the index. 2. The RTS then proceeds to process for equality, beginning with the the median value. 3. If all of search is executed; current the sequence of first, with the simple tests index set to the tests for equality are true (success), the terminated; the associated imperative statement is the search exits; and the 1ndex retains 1its value. TABLE HANDLING 5-19 4. If any of results the tests for equality 1is false, the following occur. a. The RTS determines if all of the possible occurrences for the table have been tested. If the table has been exhausted, the imperative statement which accompanies the AT END statement (if specified) is executed. In either case, control is passed to the next procedural statement. b. The RTS will now determine which half of the table is to be eliminated from further consideration. This determination is predicated on whether the key being tested 1is 1in ascending or descending order, and whether the test failed because of a greater than or less than comparison. For example, if the key values being tested are stored in ascending order, and the median table element being tested 1is greater than the value being tested for equality, the RTS will assume that all key elements following the one tested are also greater than the value being tested for equality. Therefore, the lower half of the table, those items which follow the current index setting, are no longer in contention. See Once the direction of search is determined, half of the table 1is eliminated from further consideration. A new range of permissible index values is computed from the remaining half of the table. d. Processing Figure Format 5-20 C. 2 of TABLE 5-20, the Example begins 6, SEARCH verb. HANDLING for all over again an example of from step 1. searching a table using FED'TAX'TABLESn 22 ALLOWANCE=DATA, Ay FILLER "0Q@1440 "Q202889 PIC X(7@) VALUE "2304320 "3405760 "ARAT200 "A6Q86U0Q "AT110089 "oa11520 "2912960 e "{1aiu4pan, ALLOWANCE=TABLE REDEFINES A3 FED=ALLOWANCES OCCURS ASCENDING INDEXED KEY IS ALLOWANCE=NUMBER IND=i, PIC XX, 04 ALLOWANCE SINGLES=DEDUCTIONeDATA, PIC 999V99, A3 PIC X(112) P4 ae RBRY ALLOWANCE=DATA, 12 TIMES ALLOWANCE=NUMBER FILLER "p2590067000220016 VALUE "2670211500067227 "11500183020163223 "1830024000319621 "2URAND2T90B0RU393 26 - "279P0834600548730 "I46PA99999TUITIAM, SINGLES=DEDUCTION=TABLE A3 ge REDEFINES SINGLES=DEDUCTION=DATA,. SINGLES=TABLE OCCURS 7 TIMES ASCENDING KEY IS SeMINeRANGE S=MAX®RANGE INDEXED RY IND=2, TEMPe]INDEX, 04 S=MINeRANGE PIC 999V99, A4 A4 @4 SeMAX=RANGE SeTAX S=PERCENT PIC PIC 999Va9, 99V9e9, PIC V99, FILLER "A4BAA09607020Q0017 "o96mR1730ARR8L622 PIC X(119) MARRIED-DEDUCTION=DATA, 23 VALUE "17300264000235617 "264003460023902325 "3460P0433000595328 "4330050002PR3B932 Qe "EAPPA999991A53336 ", MARRIED=DEDUCTION=TABLE REDEFINES @3 MARRIED=TABLE OCCURS 7 TIMES ASCENDING INDEXED RY KEY IS IND=Q, M=MINeRANGE MARRIED=DEDUCTIONeDATA, M=MAX=RANGE INDe3, @4 MeMINeRANGE PIC P4 999Vv99, P4 MeMAX@RANGE MeTAX PIC PIC 999Va9, 999vae9, A4 MePERCENT PIC Vo9, TEMPeINDEX USAGE INDEX, Figure 5-20 Example of Using SEARCH To Search a Table TABLE HANDLING 5-21 Example 1 SINGLE, IF TAXABLE=INCOME < 32499 GO TO ENDeFED=COMP, SET IND=2 TO (. SEARCH SINGLES=TABLE VARYING GO TO TABLE=2=ERROR WHEN TAXABLE=INCOME MOVE 3 IND=2 AT END SoMIN=sRANGE(IND=2) SeTAX(IND=2) TN FED=TAX=DEDUCTION QUTPUT=MASTER STORE=FEDwTAX WHEN OF GO TO TAXABLE=INCOME ¢ S=MAXeRANGE(INDe=2) SUBTRACT SeMINeRANGE(IND=2) FROM TAXABLE=INCOME MULTIPLY TAXABLE=INCOME BY S=PERCENT(IND=2) ROWUNDED ADD TAXABLE=INCOME TO FENwTAX=DEDUCTION OF OUTPUT=MASTER, Example SINGLE, 2 IF TAXABLE=INCOME < p2499 GO TO ENDeFED=COMP, SET IND=2 TO {, SEARCH SINGLES=TABLE VARYING WHEN MOVE GO WHEN AT END S«TAX(INDw2) TO TO FEDeTAX«DEDUCYION OF OQUTPUT=MASTER STORE=FED=TAX TAXABLE=INCOME SUBTRACTY ¢ S=MAX®«RANGE(INDe2) S=MIN=RANGE(IND=2) FROM TAXABLEeINCOME MULTIPLY TAXABLE=INCOME ADD Example INDe=2 GO TO TABLE=2=ERROR TAXABLE=INCOME 3 S«MIN=RANGE(INDe=2) TAXABLE=INCOME TO BY S=PERCENT(IND=2) FEDeTAX«DEDUCTION ROUNDED OF QUTPUT=MASTER, 3 MARRIED, IF TAXABLE=INCOME < Q4799 MOVE ZEROS TO FED=TAX«=DEDUCTION GO TO END=FED=COMP, SET IND=3 TO 1§, SEARCH MARRIED=TABLE VARYING INDw3 AT WHEN MOVE END GO TO TAXABLE®INCOME M=TAX(IND=3) OF OUTPUT=MASTER, TABLE=3=ERROR = M=MINeRANGE(IND«3) TO FED=TAX=DEDUCTION OF OUTPUTeMASTER, GO TO STORE=FEN=TAX, WHEN TAXABLE=INCOME ¢ MwMAX=RANGE(IND=3) MOVE M=TAX(IND=3) TO FEDeTAXeDEDUCTION OF OUTPUT=MASTER, SUBTRACT MeMIN=RANGE(INDw3) FROM TAXABLE=INCOME ROUNDED, MULTIPLY TAXABLE=INCOME BY MePERCENT(IND=3) ROUNDED, ADD TAXABLE=INCOME TO FED=TAX=DEDUCTION NF OUTPUTeMASTER ROUNDED, GO TO STOREeFED=TAX, Figure 5-20 (Cont.) Example of Using SEARCH, To Search a Table 5-22 TABLE HANDLING Example 4 SINGLE, IF TAXABLE=INCOME GO SET IND=2 SEARCH TO YO 1, VARYING TABLE=2«ERROR TO TAXABLE=INCOME MOVE GO WHEN Q2499 SINGLES=TABLE GO WHEN ¢ END=FEDeCOMP, 3 TEMPeINDEX END S=MINeRANGE(IND=2) S=TAX(INDw2) TO FED=TAX=DEDUCTION QUTPUT=MASTER STNREeFEDeTAX YO TAXABLE=INCOME ¢ S»=MINeRANGE(IND=2) MULTIPLY TAXABLE=INCOME TAXABLE=INCOME TO BY FROM TAXABLEeINCOME S«PERCENT(IND=2) FEDwTAX«DEDUCTION QUTPUT=MASTER, Example SINGLE, NF S=MAXwRANGE(IND®2) SUBTRACT ADD AT ROUNDED OF 5 IF TAXARLE=INCOME GO TO < Q2499 ENDN=FED=COMP, SET INDw2 TO 1{, SEARCH SINGLES=TABLE GO WHEN TO IND=@ AT END | TABLE=2=ERROR TAXABLE=INCOME = S=MINeRANGE(IND=?2) SeTAX(IND=2) TO FEDeTAX=DEDUCTION MOVE GO WHEN VARYING TO TAXABLE=INCOME € SeMAX=RANGE(IND=2) SUBRTRACT SeMIN=RANGE(IND=2) MULTIPLY TAXABLE=INCOME ADD OF QUTPUT=MASTER STORE=FED®TAX TAXABLE=INCOME TO BY FROM TAXABLE«INCOME S=PERCENT(IND=2) FEDeTAX=DEDUCTION ROUNDED OF OUTPUT=MASTER, Example 6 FED=DEDUCT=COMPUTATION, SET IND=§ TO ¢, SEARCH ALL FED=ALLOWANCES WHEN AT OUTPUT=MASTER, SUBTRACT ALLOWANCE(IND=y) GIVING IF END ALLOWANCE«NUMBER(IND=1) GO TO FROM TAXARLE=INCOME MARRITAL~STATUS OF = GO TO TABLE=i{=ERROR NR«DEPENDENTS OF GROSS=WAGE OQUTPUTeMASTER OF RQUNDED, OUTPUTeMASTER = "MTM MARRIED, Figure 5-20 Example To of (Cont.) Using Search a SEARCH Table TABLE HANDLING 5-23 CHAPTER INPUT-OUTPUT 6 PROCESSING This chapter relates COBOL-74 I/0 concepts to the features and requirements of VAX/VMS and Record Management Services (RMS), which is the file and record access subsystem of the VAX/VMS operating system. Rather than being a complete description of RMS and COBOL-74 I/0O, this chapter provides a bridge between the concepts and facilities of both. For more detailed information: l. 2. The VAX-11l COBOL-74 I/0 concepts and language. The basic Language Reference Manual describes the statements that are part of the COBOL concepts of RMS, such as file organization, access the physical attributes of file devices, are the Introduction to VAX-1ll Record Management modes, and discussed in Services. Most of the following discussion relates to input-output 1is largely device-independent file handling. However, in the VAX-11 system; the logical name translation facility of VAX/VMS allows you to specify I/O in a generalized and flexible way. Therefore, sections of this chapter describe file naming techniques and conventions, relating them to both file-associated 1I/0 statements (like OPEN, READ, and WRITE) and the low-volume I/0 statements (ACCEPT and DISPLAY), which in many systems apply only to terminal devices. FILE ATTRIBUTES A file is an organized collection of maintained on an accessible medium, Both RMS and COBOL-74 support a records that 1is stored and such as disk or magnetic tape. variety of devices, file organizations, access methods, and storage techniques. Programs communicate with RMS by using a set of conventions and structures that allow compatibility of file definitions and operations among all users of RMS. File attributes are characteristics that determine how a file's The records are organized and how they can be stored and accessed. attributes are specified when a file is created, either by a program you write or by the RMS DEFINE Utility. RMS stores the file whenever available are they so 1itself, file the in attributes When a program accesses a file is accessed. the file through RMS, it must use the attributes that were defined when For example, a program cannot read a sequential the file was created. it also file as an indexed file, since the indexes do not exist; blocking different a specifies it cannot correctly access a file if for factor or record format (fixed-length instead of variable-length, instance) than was originally defined. through specify file attributes COBOL programs Divisions: Data and Environment the in statements a combination 1. The SELECT statement specifies the file organization. 2. File-description-entries specify record blocking of record and format. specify 6.1 specify Record-description-entries 3. record record sizes and can format. RECORD FORMAT records The RMS record format determines whether the size of a file's can vary; and if RMS stores control fields with records on the storage medium. The compiler determines the record format attribute from a combination of record-description-entries, the RECORD CONTAINS clause, and clauses that specify print-controlled files. 6.1.1 Fixed-length Files with the fixed-length record format contain records that are all The compiler generates the fixed-length record format the same size. file attribute when: The file has only one record description, or it has multiple a "RECORD CONTAINS record descriptions, all of which are the same size; AND The file integer-1 description TO integer-2" does not phrase; AND 6-2 INPUT-OUTPUT PROCESSING contain The program does of the following 6.1.2 Files vary of @ The ®@ An APPLY @ A LINAGE ADVANCING phrase in a WRITE PRINT-CONTROL clause clause file in the in file by using any statement the Environment Division description Variable-length with the variable-length record format can contain in size. RMS stores a record length field before each @ ® data record. records that the beginning For disk files, the record length field is a 2-byte binary value that specifies the length of the record (excluding the record length field). For tape value files, that (including The not specify a print-controlled to refer to the file: compiler the record specifies the generates The file has more records described length the record length the field 1length of is a 4-byte the record (l-word) in bytes decimal in bytes field). variable-length attribute for than one record description, and fgr the file are the same size; a file when: not all OR the file description contains TO integer-2" phrase. 6.1.3 a "RECORD CONTAINS integer-1 Variable With Fixed-Length Control Variable with fixed-length control records are similar to variable-length records; however, they contain a fixed-length control field between the record length field and the variable-length data record. The and compiler generates this attribute only for print-controlled files for files that are opened by a DISPLAY statement; the RTS stores print-control values in the fixed-length control field, which is two bytes 1long. Section 6.1.1 describes the COBOL language specification of print-controlled files. INPUT-OUTPUT PROCESSING 6-3 6.2 RECORD SIZE The space needed for a record on a storage medium depends on the record format, the file organization, and the size of the COBOL record description that is used to write the record. The maximum @ size For of a record depends on fixed-length records, the record format: maximum size 1is the record size. e For variable-length records, the maximum size is the size of the file's 1largest record description in the COBOL program that created the file, plus the number of overhead bytes needed for the storage medium. In relative files, all records are stored in fixed-length "cells". Cell size is one byte larger than fixed-length record size; the extra byte is a delete flag, which RMS uses to determine if a cell contains a record. For variable-length records, cell size is three bytes larger than the maximum record size; it includes the delete flag and the 2-byte record In sequential save Sspace. and RMS length field. indexed stores files, however, records variable-length contiguously records whenever can possible; therefore, a variable-length record requires 1less space than a fixed-length record of maximum size if its length differs from the max imum record size by more than its variable-length overhead. The size of a data record written by a COBOL program is determined only by the effective size of the record description named in the WRITE statement. In the following example, the first WRITE statement causes 56 bytes to be written to the file specified by ACCOUNT-FILE; the second WRITE statement transfers 42 bytes: FD ACCOUNT-FILE 01 ACCT-FLAG-REC. 01 6-4 03 FILLER 04 ACCT-FLAG ACCT-REC. 03 ACCT-NUM 03 ACCT-NAME 03 ACCT-LIMIT 03 ACCT-DISCOUNT 03 ACCT-DATE PIC PIC X (40). 9(2). PIC PIC PIC PIC PIC 9(10). X (30). 9(6). 99V99. 9(6). WRITE ACCT-REC. WRITE ACCT-FLAG-REC. INPUT-OUTPUT PROCESSING If the records are written to a relative file whose maximum record size 1is 56 bytes, the RTS still transfers 56 bytes and 42 bytes; however, the space needed for each record is 58 bytes, excluding the delete flag. For the 42-byte record, RMS transfers the 2-byte record length field and the 42-byte data record, 1leaving 14 unused (and inaccessible) bytes, excluding the delete flag. 6.3 RECORD BLOCKING Record blocking can increase the execution speed of programs that perform many file 1I/0 operations. In general terms, a block is the unit of data transfer between a program and a file storage device. A block can contain one or more records; if it contains many records, I/0 speed can increase -- the program requires only one transfer from the device to memory in order to consecutively read records in the same The block. COBOL language characters. expresses The actual by the storage medium, the term "block" can uses terminology Physical that block size of the size in terms unit of data record format and file have several meanings, is more specific: of transfer records is organization. the rest of this or affected Because chapter Block A group of consecutive the bytes of data treated as a unit by storage medium. On magnetic tape, a physical block can vary in size; it is the number of bytes between two interrecord gaps. On disk, a physical block is a 512-byte unit. A physical block can contain one or more contain part of a record; records can boundaries. Physical block is synonymous block. with records, or it can span physical block the VAX-11 RMS term, Bucket For relative and indexed files, the RMS unit of transfer between storage devices and I/0 buffers in memory. A bucket can contain one or more records: however, records cannot span Record Unit buckets. Size The storage medium in a file. For fixed-length length. space records, (in bytes) record needed unit to size For variable-length records, record unit record length plus the size of the count store 1is size is field. INPUT-OUTPUT the a record record the maximum PROCESSING 6-5 For variable with fixed-length control records, record unit the maximum record length, the count sum of the is size (two field field size, and the size of the print-control - bytes). In COBOL, you can specify blocking in terms of records or characters, or you can use the compiler's default. The following sections discuss the three methods separately for each file organization. The examples refer to the following samples of COBOL file and record descriptions: A Sample FD TEST-FILE 01 01 REC-1 REC-2 Sample LABEL RECORDS ARE STANDARD. PIC X(100). PIC X(511). B FD TEST-FILE BLOCK CONTAINS 50 RECORDS LABEL RECORDS ARE STANDARD. PIC X(20). REC-1 01 Sample C TEST-FILE FD BLOCK CONTAINS 512 CHARACTERS LABEL RECORDS ARE STANDARD. PIC X (494). REC-1 01 Sequential Files on Magnetic Tape Default The physical block size is determined when the volume is mounted; is not used with the VAX/VMS MOUNT the /BLOCK=n qualifier if command, the RMS default is 2048 characters. BLOCK CONTAINS n - RECORDS The compiler computes the physical block size as n multiplied the record unit size. Example: Sample B 6-6 Physical block size 1000 bytes INPUT-OUTPUT PROCESSING (50%*20) by BLOCK CONTAINS n CHARACTERS If n is less than the record unit size, the record unit size as the and uses the ignores n compiler physical block size. Records cannot span Otherwise, the physical block size equals n. a physical block can contain only therefore, blocks; physical A physical block (regardless of record format). the magnetic tape device when the to (written) complete records transferred is program tries to add a record cannot that into fit I1/0 the the unwritten record begins the next physical block. buffer; Example: Sample Physical block size C 512 bytes (18 unused) Sequential Files on Disk 6.3.2 Records are packed together in each physical no are block; there for sequential unused bytes in any block, and the records can span block boundaries. Default The RMS default determines record blocking disk files. BLOCK CONTAINS n RECORDS 512-byte physical blocks, in terms of in terms of INPUT-OUTPUT PROCESSING 6-7 data The compiler computes the unit of transfer, as follows: Unit of data transfer = (n*record unit size/512), rounded up Example: Sample B Unit of data transfer 2 = (50*%*20/512), rounded up BLOCK CONTAINS n CHARACTERS The compiler computes the unit of 512-byte physical blocks, as data transfer, follows: Unit of data transfer = n/512, rounded up Example: Sample C Unit of data transfer 1 = 512/512, rounded up 6.3.3 Relative Files In each of the following methods for computing bucket size, one byte is added to the record unit size. RMS adds one byte to each cell in a relative file to indicate whether the cell contains a record or 1is empty. Bucket size is expressed in terms of 512-byte physical blocks. The bucket the file, created. size you The following 6.3. is a file attribute; therefore, each time you access must specify it the same way as when the file was examples refer to the COBOL samples presented in Section Default The compiler by computing Bucket tries it as size = to make the follows: ((l+record bucket unit size as small size)/512), as rounded possible up Example: Sample Bucket A BLOCK CONTAINS The 2 n compiler Bucket = size ((1+(2+511))/512), rounded up RECORDS computes size = the bucket (n*(l+record size unit as follows: size)/512), rounded up Example: Sample Bucket B BLOCK CONTAINS The 3 n compiler Bucket = size (50*(1+20)/512), rounded up CHARACTERS computes size = the bucket size as follows: n/512 Where: 6-8 @ n must equal or exceed (l+record unit size). If it 1is less than that quantity, the compiler issues a warning diagnostic and uses the default method to compute the bucket size. @ n must be a multiple warning diagnostic 512. INPUT-OUTPUT PROCESSING of 512. 1If and rounds not, the n up to compiler 1issues a the next multiple of Example: Sample Bucket C 6.3.4 1Indexed 1 Files Each of the methods for considers overhead bytes Record Bucket The the bucket file, size overhead size for bucket: indexed files bytes bytes 7 15 overhead size you computing bucket for each record and is a file attribute; therefore, each time you access must specify it the same way as when the file was created. In each of the following methods, 512-byte physical blocks. samples presented in Section bucket Again, 6.3. size the is expressed examples refer in to terms the of COBOL Default The compiler by computing Bucket tries it as size to make the follows: bucket ((15+(7+record size unit as small as size))/512), possible rounded up Example: Sample Bucket A BLOCK CONTAINS The 2 n compiler Bucket = size ((15+(7+(2+511)))/512), rounded up RECORDS computes size = the bucket ((15+(7+record size as unit follows: size)*n)/512), rounded up Example: Sample B Bucket 4 = size ((15+(7+20)*50)/512), rounded INPUT-OUTPUT up PROCESSING 6-9 BLOCK CONTAINS The n CHARACTERS compiler Bucket computes size the = n/512 or exceed bucket size as follows: Where: @ n must equal less than diagnostic (1l5+(7+record unit size)). If that quantity, the compiler issues and uses the default method to compute a the it 1is warning bucket size. ® n must be warning a multiple diagnostic of 512. and If not, the n to rounds up compiler the issues a next multiple of 512. Example: Sample Bucket C size 2 n*(512) is 1less than +the minimum required by the first rule; therefore, the compiler uses the default method. 6.4 CURRENT RECORD AREA A file's current available to descriptions record area is the a COBOL program; that follow the 1location in which records are it 1is defined by the record file description. COBOL I/O and 1its between manages 6.4.1 The statements appear to transfer data directly between a file current record area. Actually, I/0O statements transfer data the current record area and the file's I/0 buffer. RMS the I/0 buffers and transfers data between them and files. Effects on Output Operations current record area includes file's record descriptions: described for the file. The size o0of a determined by total 1is as area INPUT-OUTPUT PROCESSING described large record written by a COBOL the record description named statement. 6-10 the it as the by all largest of a record program, however, 1is in the WRITE or REWRITE 6.4.2 Effects of Input Operations The RTS does not clear the current record area before executing a READ operation; therefore, the contents of the current record area after a READ are determined by the length and contents of the record. For example, when the program reads a record that is smaller than the largest record described for a file, area beyond the end of the the operation does not change the incoming record. the Consider an example in which record current contains area 20 If the next READ the first record read from a file. from characters returns a l2-character record, the remaining 8 character positions are not changed: Current record area after Contents of next record: 6627402CHAIR Current record area after next READ: 6627402CHAIRET, It is not considered a good COBOL programming practice this condition. 6.4.3 FILE first READ: | 0239394CABINET, FILE to depend on for each Sharing Record Areas The compiler normally allocates file's current allocation has 1. area. storage This space method of separately two potentially undesirable effects: current record area Each file's current record area requires storage 1in the number of files and the the If Division. Data program's could size Division sizes of their records are large, Data is which limitation, size Division Data COBOL-74's approach 65,535 2. record bytes. Reading records from one file and requires an data intermediate writing current record area to the other. this records of number large transfer them from to one another file's 1If the program processes a movement data the way, operations could add significant processing overhead. Files can share current record areas, thus reducing both address space and processing overhead. You specify current record area sharing by using the SAME RECORD AREA clause in the I-O-CONTROL paragraph of the Environment Division. For all files clause, the compiler assigns the beginning to a common location; the leftmost bytes coincide in the same way that the leftmost file share one location. Records need not the maximum sizes of each current record named in a SAME RECORD AREA of the current record areas of each current record area bytes of each record for a be the same size; nor must area be the same. Figure 6-1 shows the effect of current record area sharing 1in a program that reads records from one file and writes them to another. However, it also shows a drawback: current record area sharing is INPUT-OUTPUT PROCESSING 6-11 equivalent separately the output available. directly. to -- implicit therefore, file, the Remember redefinition; if the program original that you the records do changes the record input cannot not defined file record 1is file's access a Figure 6-1 Sharing Record Areas Program Without Sharing Program With Sharing I-O-CONTROL. SAME RECORD AREA INP-FILE PROCEDURE DIVISION. READ INP-FILE MOVE INP-REC DIVISION. Process With Sharing ... TO OUT-REC. Process Without Sharing L[ | INP-FILE | | buffer READ READ (move) (move) INP-REC MOVE INP-REC OUT-REC OUT-REC L | WRITE WRITE (move) (move) L 6-12 [ | OUT-FILE INPUT-OUTPUT PROCESSING buffer FOR OUT-FILE. PROCEDURE for no I/0 buffer 6.5 I/0 BUFFERS An I/0 buffer is an intermediate memory transfers between a program and its dynamically; that buffers until program closes is, storage files. 1location for data RMS assigns buffers it does not allocate address space for a file's vyour program opens the file. Furthermore, when your a file, RMS releases the I/0 buffer's address space. Using buffers, RMS can perform I/0 operations with 1little regard to the program's description of records and files: it can read or write more data (or Buffer is necessary for use less) in each operation than the program record blocking; for requests. example, when your program reads a record that 1is part of a logical block, only that record is made available in the current record area. The rest of the records buffer, in the 1logical block are still available in the file's I/0 and RMS can often make them available to your program accessing the file without again. Multi-buffering (allocating more than one buffer for file operations) can increase the speed of I/O operations. Using multi-buffering, RMS can reduce your program's record access time by storing large of data in the program's address space between I/0O requests. amounts If the program tries to access a record that is already in the buffer, RMS must only move the record to the current record area, regardless of how the file is blocked. You can take advantage of multi-buffering by using the RMS defaults or by specifying multiple buffers with the RESERVE 6.5.1 clause. RMS Buffer Defaults RMS uses default multi-buffer counts when they are not specified by your program. Defaults for sequential, relative, and indexed files can be set on a system-wide basis; however, you can also define RMS defaults for your process by using the SET RMS DEFAULT command. You can display the defaults with the SHOW RMS DEFAULTS command. The VAX/VMS Command Language User's Guide describes both commands. 6.5.2 Multiple Buffers (RESERVE Clause) You can use the RESERVE clause in the SELECT statement to specify the number of I/0 buffers that RMS will use for a file. The RESERVE clause specification overrides the RMS default, allowing you to reserve more buffers for programs in which I/0O speed is important. You can specify up to 127 areas in the RESERVE clause; however, 1if record or block sizes are large, heavy multi-buffering could cause the buffers to take a large proportion of the process address space. INPUT-OUTPUT PROCESSING 6-13 6.5.3 Sharing Buffers (SAME AREA Clause) The SAME AREA clause specifies that two or more files are to same memory area (I/O buffers) during processing. It is not have more than one of the files open at the same time; reports RMS a run-time allocates file), so I/O error buffers buffer more than one the same time, file A program operation OUTPUT, I-O, statements and you that can be used by the RTS 6.6.1 must on used Three are in a not ensure not SAME condition. (when save your program resources; AREA actually that this clause shared. specific cannot However, files opens therefore, are be you closed a since open at can use before OPENING FILES COBOL I/0 to detects would specified buffers it dynamically sharing the SAME AREA clause others are opened. 6.6 when use the valid to the RTS explicitly it. You open can a file open before files in it can perform four modes: any INPUT, EXTEND; the choice of open mode determines which I/0 wuse. This section summarizes the I/0O statements for each open mode; it also discusses the procedures can and RMS when you open files. I/0 Operations conditions perform on a determine the 1I/0 operations that a program can file: l. File organization 2. Access 3. Open mode mode The relationships among file organization, access mode, open mode, and I/0 statements are hierarchical: file organization determines which access modes are valid; the combination of organization and access mode determines valid open modes; and the combination of all three enables or disables I/0 statements. Table 6-1 shows these relationships by indicating I/0 statement availability for each valid combination. 6-14 INPUT-OUTPUT PROCESSING Table 6-1 I1/0 Statements Grouped by File Organization, Access Mode, File Organization Access Mode SEQUENTIAL SEQUENTIAL | READ and Statement DYNAMIC INDEXED INPUT| Open Mode OUTPUT I-0 No Yes No Yes No No Yes No No No No Yes Yes Yes START WRITE Yes [ NO No Yes Yes NoO DELETE READ REWRITE WRITE No Yes No No NoO No No Yes Yes Yes Yes Yes DELETE READ NoO Yes No NoO Yes Yes READ Yes SEQUENTIAL | DELETE READ REWRITE RANDOM Mode Yes REWRITE WRITE RELATIVE Open NEXT No No Yes Yes No REWRITE NoO NoO Yes START Yes No Yes WRITE NoO Yes Yes SEQUENTIAL | DELETE READ REWRITE START WRITE No Yes NoO Yes NoO NoO No NoO No Yes Yes Yes Yes Yes NoO RANDOM DELETE READ No Yes No No Yes Yes WRITE No Yes Yes No Yes Yes NO Yes NO No NoO No NoO No Yes REWRITE DYNAMIC DELETE READ READ NEXT REWRITE START WRITE No No EXTEND NO No Yes N/A Yes N/A Yes Yes Yes Yes Yes Yes INPUT-OUTPUT PROCESSING 6-15 6.6.2 OPEN Statement Execution This section discusses the file by the following conditions: An @ File ® Access ® Open mode ®@ RTS error detection ®@ RMS error detection @ Existence OPEN attempt how it is affected mode of USE procedures causes the the file make RTS to following procedure begin available detected, the OPEN fails: the RTS procedure (if the program has terminates the image. The and organization statement to open procedure starts a to series the of procedures program. If an that error either performs the applicable one) or issues an error message when a COBOL program reaches an is USE and OPEN statement: l. The RTS checks already open, 2. The RTS builds the VALUE components OF of the the a current OPEN file status of the file. If it 1is contents of fails. specification ID identifier, if the ASSIGN clause by any, file using the to replace or specification add to the default. 3. If the file was named in a the status of all other are open, the OPEN fails. 4. The RTS calls RMS, requesting that it open the file. If RMS detects an error in its procedures, it reports the error condition to the RTS and the OPEN fails. 5. RMS 6. passes the file specification translation routine, which replaces with the translation, if one exists. If the file specification names an detects any other error the error to the RTS. 7. SAME AREA clause, the RTS files named in the clause. If RMS the cannot program find the specified in the file, the file it to a the file logical name specification invalid device, or if specification, | it reports notifies file checks If any as the RTS; OPTIONAL then, (valid RMS 1f for sequential files only) and the open mode is INPUT, the RTS the file for an AT END condition, considers the OPEN successful, and returns control to the program. Otherwise, if RMS reports that it cannot find the file, the OPEN fails. marks 6~-16 INPUT-OUTPUT PROCESSING 8. If the RTS detects a significant difference between an existing file's attributes and those specified during an open for input (such as different file organization), the OPEN fails. 9. If the program the program is opening contained PRINT-CONTROL clauses, a sequential file for output, and either the LINAGE or APPLY the RTS 1initializes the LINAGE counters. 10. Before returning OPEN, the RTS control marks as to the enabled program or after disabled a all the successful program's I/0 statements that refer to the file, depending on the file organization, access mode, and open mode. (See Table 6-1.) 6.7 In NAMING FILES a COBOL you program, specify CLOSE in statements. exists outside clause of the specification; particularizes you the However, to a file use in the you refer the program, with SELECT statement the VALUE OF 1ID the file This section discusses are described your COBOL programs It relates techniques refer FD and by its file-name: SELECT, OPEN, the physical to READ, the name START, file, as and it a file specification. The ASSIGN contains the default file clause in the file description specification. file in detail in specifications the VAX/VMS the ASSIGN and VALUE and recommends a and 1logical Command names, which Language User's Guide. OF ID clauses to the two file convention that you can follow naming to make device-independent. NOTE The term "system" is used when important to differentiate VAX/VMS and 1its subsystems it is not between (RMS, for example). 6.7.1 File Specifications File specifications provide the system with needs to uniquely identify a file or device. The general form of the file specification all the information it is: node: :device: [directory] filename. type;ver INPUT-OUTPUT PROCESSING 6-17 The punctuation marks specification. The and brackets fields separate the fields of the file are: node A network network, names are node name identifies a 1location on the 1if vyour system 1is connected to one. Node from one to six characters long. device Each hardware device in the system has name specification in the format: a unique device devcu: where dev is a mnemonic controller designation; directory 1is a This field names a directory file, which contains the identifications and 1locations of a user's files on a disk device. Directory names must be enclosed 1in either square brackets ([ and ]) or angle brackets (< and filename >). This type field, ver in combination with the file type and version number, directories. The characters long. uniquely identifies file name can be from The of identify a file in terms be from one to three For example, the file type of is usually EXE. file its files within one to nine type is often used to contents. It can characters executable 1long. images Version numbers are decimal numbers from 1 to 32767 that differentiate between versions of a file. For example, if you create a file with the same file name and type as one that already exists in the same directory, the system assigns one dgreater than the must put a semicolon or number. All fields are default values example, log in; File for the device type; c and u is a unit number. a version number highest existing a period before that is version. You the version optional in a file specification. The system supplies for all omitted fields, except file name and type. For default device vyou can change Specification and directory them with the names are established SET DEFAULT command. when you Examples: DBAl: [SMITH]ACCOUNT.DAT Refers to ACCOUNT.DAT local 6-18 system the in 1latest version directory name (node name INPUT-OUTPUT PROCESSING default). (default) [SMITH] on of the file device DBAl: named on the PAYROL.NEW; 23 Refers to version number default directory on the File 23 of the file named default device. PAYROL.NEW in ID can the Switches File specifications in the ASSIGN or VALUE OF <clause followed by "file switches". These specifications are defined by VAX-1l1l RMS; however, the RTS accepts them translates them to VAX-1ll RMS parameters. COBOL-74 accepts switches for compatibility with PDP-11 COBOL. (They discussed in Section 6.8.5). 6.7.2 Logical be not and file are Names Logical names allow you to write programs physical file specifications. They also specify files that you refer to frequently. that are provide a independent of shorthand way to When the system gets a file specification, it tries ¢to find an equivalence name to replace the leftmost component. If the leftmost file specification component is not a logical name -- it might be a directory name, for example -- the system does not translate it. You can assign logical names with described 1in the VAX/VMS Command the ASSIGN command, which is Language User's Guide. When a logical name is assigned, it and its equivalence name are placed in one of three 1logical name tables, depending on whether they are assigned for the current process, on the group 1level, or on a system-wide basis. To translate a logical name, the system searches system); therefore, by defining it for order (process, group, system-wide logical name the you your three tables in can override a group or your process. Logical system name translation is a recursive procedure; that is, when translates a logical name, it uses the equivalence name as argument for manner until For example, and you use ASSIGN If your another logical name translation. It continues it cannot translate the equivalence name. assume the FILEA program that ASSIGN the equivalence name of FILEA is in the the this ALPHA.DAT, command: MYFILE tries to open a file whose file specification is "MYFILE", the system translates "MYFILE" to its equivalence name, "FILEA", then uses "FILEA" as the argument for a second translation to "ALPHA.DAT". If you had not established "MYFILE" as a logical name, the system named would use it as a file specification and look for a file PROCESSING 6-19 "MYFILE.". INPUT-OUTPUT ASSIGN and VALUE OF 6.7.3 ID Clauses You can use the SELECT statement ASSIGN clause alone or in combination the VALUE OF ID clause to supply file specifications and logical with The ASSIGN clause literal can contain three types of names for files. file names: 1. Complete file specification same whenever the If you want the file specification to be you can use a complete explicit file you run the program, specification in the ASSIGN clause. For example: SELECT WORK-FILE ASSIGN TO "DBAl: [WORKACCT]WORK1l.TMP". You need not use the VALUE OF ID clause if you choose this technique. Partial file specification If part of the file specification can change from one run another, you can use a partial file specification: SELECT INPUT-FILE ASSIGN TO to .DAT". "DBAl: If you do not use the VALUE OF ID clause, the system uses the However, if you use default directory and a null file name. the ACCEPT use and clause identifier IS ID OF the VALUE statement to get the file name at run time, the contents of replace all or part of the the identifier "fill in" .or partial file specification: identifier contents file specification [JONES]A PERSONNEL DBAl: [JONES]A.DAT DBAl: PERSONNEL.DAT [WILLIAMS] | spaces DBAQ: [SMITH]WEEK.LIS | . TMP Logical DBAl: [WILLIAMS] .DAT DBAl: .DAT DBAQ: [SMITH]WEEK.LIS DBAl:.TMP name file specification A logical name can look like a partial However, if the fact, can be used in the same way. in and, so 1ID) name is not changed (by the contents of the VALUE OF recognizes it as a file specification, the system the that system tries to translate 6-20 INPUT-OUTPUT PROCESSING it. For example, to the assume that -equivalence statement the name logical name "MYFILE" "PERSONNEL.DAT". If translates the is: SELECT SELECT INP-FILE ASSIGN TO "MYFILE". and the program accepts input at run time to fill the VALUE OF ID 1identifier, 1logical name translation may or may not take place, depending on the input: identifier contents file . DAT MYFILE.DAT spaces PERSONNEL. DAT [SMITH] [SMITH]MYFILE. You can often increase program recompilations by wusing 1logical Consider an accounting system with ten master access files. another specification set It of could versatility and avoid "one-time" names in the ASSIGN clause literal. 20 programs that access the same be necessary to use the files at the start of a accounting years are active, same master example, when two organization's accounts must also be maintained. involved in converting the programs would depend naming conventions: new or programs The on to year, for when another amount of the programs' work file @ If complete file specifications are used in the ASSIGN clause, and the programs do not accept file specifications at run time, all 20 programs need to be edited (ten file specification changes in each), linked, and probably renamed to avoid confusion with the originals. The obvious risk of error requires that the programs be tested. @ If the would programs accept not to file specifications at run time, they changed. However, assuming they run as command procedure needs to be changed, and need be batch jobs, each probably renamed. operators would If need to the be programs taught to run wuse interactively, the correct file specifications for each program, depending on which set of files was to be used. 1In addition to being cumbersome, this procedure would 1likely result in file specification errors, and perhaps damage to data files. e If logical would jobs, case, at the not names are need to used be in the changed. ASSIGN clause, If programs the programs run as batch for each the command procedures are simpler than in the previous since logical name assignments need be made only once program; beginning i1f of multiple the procedure command instead procedures could all execute a single command nothing but assign 1logical names. interactively, the operator needs only procedure to assign all logical names files. the of were used, they procedure that does If the programs run to execute one command for the correct set of INPUT-OUTPUT PROCESSING 6-21 6.7.4 File Switches (PDP-11 COBOL Compatibility) PDP-11 COBOL allows the use of switches (qualifiers) in file communicate options to the file management system, to specifications them The RTS translates these switch specifications to make RMS-11. thus, you can recompile most PDP-11 COBOL compatible with VAX-11 RMS; programs with VAX-11 COBOL-74 and execute them without change. Table 6-2 describes the PDP-11 COBOL file specification switches. the terminology and concepts are not the same as of that -some Note are values that numeric also Note system. VAX-1ll the those in specified as either decimal or octal, not hexadecimal. Table 6-2 File Specification Switches for Compatibility with PDP-11 COBOL SWITCH /AL:n MEANING 1is created. Allocate n disk blocks to the file when it available before are that n blocks ensures This to switch the also use You can processing begins. If file. entire the hold can volume the the that ensure the rightmost character of n is a decimal point, the RTS otherwise, as a decimal number; the value interprets the RTS treats n as an octal value. The blocks allocated need not be contiguous. /CL:n The RTS treats this switch identically to the /WI The /CL switch is included for compatibility switch. the RSTS/E under with PDP-11 COBOL programs running operating /CO:n system. specifies it further This switch complements /AL:n; rightmost the If contiguous. be blocks all that interprets RTS the character of n is a decimal point, otherwise, the RTS number; a decimal as the value treats n as an octal value. /DQ:n Specifies an extension quantity of n blocks when the A large extension quantity minimizes is created. file If the rightmost character of n is a extend operations. decimal point, the RTS interprets the value as a decimal number; otherwise, the RTS treats n as an octal value. /DW as full, Causes I/0 buffers to be written only when the default case, in which every write to contrasted option This operation causes a physical I/0 operation. is available only for files that are not write-shared. /LO the when specified Causes RMS to use the fill numbers to file the cause can numbers Fill created. was file contain free space to allow later record insertion. 6-22 INPUT-OUTPUT PROCESSING Table /MI 6-2 (Continued) indexed an (into insertion This switch optimizes the of records sorted in order of ascending prime key file) for Mass insertion eliminates the index search values. in implemented 1is feature This subsequent writes. RMS-11. /SH available Specifies sharing of the file, making it writing by other processes running concurrently with allowed not 1is switch This COBOL program. files, types of other For files. sequential following 1. rules apply: If the /SH is specified for one process sharing all for specified be it must file, the processes sharing 2. the file. output or I/0 If a file is opened for input without the /SH If a file is being opened for specified, switch /SH the with file processes currently using the have the /SH switch specified. 3. switch for 4. for the for the set, output or other all also must no other process can use the file I/O. /SH the If a file is opened for input without using currently other process no set, switch the file can have the /SH switch set. If access is denied because one of these rules has been the in 91 of value a stores RTS the violated, FILE-STATUS data-item associated with the file, assuming contains a file the for statement SELECT that +the FILE-STATUS /WIzn clause. | Sets the number of retrieval pointers in the window used virtual block numbers to logical block numbers. map to Kknow you if The acceptable values range from 1 to 102 pointers are present on disk for the how many exactly as pointers file, or 255, which requests assignment of needed. CAUTION The /WI:n switch can cause loss of data and file the system crashes while a buffer if integrity is being filled. INPUT-OUTPUT PROCESSING 6-23 6.8 FILE COMPATIBILITY VAX-11 COBOL-74 programs cases, therefore, your that was created through RMS-based programs use VAX-1ll1l RMS to access all files. In most COBOL programs can read records from any file (or can be accessed by) RMS; and other can read records from files that your program creates. The ability to read records, however, does not imply a ability to transfer data between programs written in languages -- at least not without some special processing. universal different The most common compatibility issues are differences in data types, data record formats, and special control characters in records that are written to record-oriented devices. 6.8.1 Not Data Type all data utilities. e ' Differences types For are COBOL-74 does Therefore, point data @ supported by all programming languages and all example: not support the floating COBOL programs cannot (FORTRAN real variables) VAX-1l1l SORT does not Therefore, problems COMPUTATIONAL key whose support arise in picture is point data easily process in files. type. floating quadword binary items. sorting a file on a in the range S9(10) to S9(18). ® FORTRAN does Therefore, be used by support the COMPUTATIONAL-3 not data packed-decimal in COBOL files data type. cannot easily FORTRAN programs. The fact that data types differ should not keep you from transferring data between programs written in different languages. You can use two techniques to overcome data type incompatibilities: l. ©Use in ASCII character representation, if possible, for all data files intended for use across languages: ASCII representation (USAGE IS DISPLAY, universally recognized. All VAX-1l1l support this data type. 2. Convert the data in your program to in COBOL) is almost languages and utilities a data format you can use. Even 1if you cannot use a data type directly, you can convert it to a usable form if you know the specifications for its internal representation. Data conversion may be complex and may prevent your operating on the converted data as easily as on a "native" data type. Nevertheless, conversion is always possible. For example, a FORTRAN for double-precision value may have representation fraction and INPUT-OUTPUT any exponent COMPUTATIONAL data 6-24 in items. PROCESSING COBOL can be data too large type; represented in a magnitude however, the COBOL two by 6.8.2 Data Record Formatting Differences Programming languages may use different conventions to format their data records, causing incompatibilities 1in otherwise transportable files. For example, FORTRAN programs normally place a carriage control character before the first data character in a formatted file record. Similarly, other languages could format print-controlled (and other) records differently than COBOL does. You can avoid this incompatibility, in some cases, print-controlled files. 1In FORTRAN, for example, with the "CARRIAGE CONTROL='NONE'" specification. a file by not can be using opened If you cannot "normalize" the format of a file's records, you can still read it by defining record descriptions that match the actual format. For example, you can read data from a FORTRAN file that |wuses carriage control by defining a one-character data item before the first "real" data item in each record description. When you read a record, the one-character field will <contain the carriage control character, which your program can either interpret or ignore. 6.8.3 Special Control Characters Some characters in the computer character the carriage return, form feed, and line of non-graphic control characters. set have special meaning; feed characters are examples Control characters may be included in a file's records by convention; for example, COBOL-74 print-controlled records have a carriage return in the byte following the last data character. In other cases, a program can inadvertently include control characters in a record by using a data type other than ASCII (or DISPLAY). For example, if your program writes COMPUTATIONAL data to a file, individual bytes of the binary data could contain control characters. Consider a one-word COMPUTATIONAL data 1item that contains the wvalue 3085, which is equivalent to the hexadecimal value 0COD; taken as two bytes, 0COD represents a form feed followed by a carriage return, which could be interpreted 6.9 as the end of a record. I/O ERROR PROCESSING When your program reaches a file I/0 statement, the RTS begins a complex procedure that includes 1its own internal status checks and interaction with RMS. 1I/0 exceptions can be detected by RMS or the RTS. This section briefly describes how the RTS handles exception conditions and the techniques you can use to handle I/0 errors. INPUT-OUTPUT PROCESSING 6-25 When your program reads a sequentially accessed file, RMS reports an AT END condition to the RTS if there are no more records to return. For a randomly whenever RMS accessed file, determines an that INVALID the KEY file condition does 1is not contain an I/O reported the record specified by the value of the key your program supplied. The AT END and INVALID KEY conditions are not errors; you specify program action on those conditions in the AT END and INVALID KEY clauses of 1/0 statements. An I/0O fail. error is any other condition that causes statement to If your program contains a USE procedure that applies to the file for which the I/0 operation failed, the RTS performs the procedure, and it does not display an RMS error message; otherwise, it displays the RMS error message and terminates the image. A USE procedure can sometimes avoid program termination. For example, if the file status data item contains the value "91", which indicates that the file is locked by another process, you might decide to try opening the file again after performing other procedures. In other cases, procedure can processing in an for example. when program continuation is not desirable, the USE perform "housekeeping" operations that conclude orderly way, by saving data or informing the user, Before the RTS performs a USE procedure, it places a value in the file status data item, if you specified one in the file's SELECT statement. Most file status values are defined by the 1974 ANSI COBOL Standard; in most cases, they do not provide as much information as RMS error messages. If you need to see the RMS error message for an error that was handled the USE 6.10 by a USE procedure, you must procedure and run it again. LOW-VOLUME I/0O recompile the program without (ACCEPT AND DISPLAY) The COBOL language provides low-volume I/O operations. and and two statements (ACCEPT and DISPLAY) for Usually, these statements transfer data to from a user's terminal device. In COBOL-74, however, the ACCEPT DISPLAY statements refer to VAX/VMS logical names. This section discusses the VAX/VMS 1logical names; and 6-26 DISPLAY association of your own mnemonic-names to it continues with discussions of the ACCEPT statements. INPUT-OUTPUT PROCESSING 6.10.1 Mnemonic-Names (SPECIAL-NAMES Paragraph) The ACCEPT and DISPLAY statements transfer data between your program If you do not use the and the object of VAX/VMS 1logical names. are COBSINPUT and names logical default the , clauses FROM/UPON COBSOUTPUT. in The FROM/UPON clauses refer to mnemonic-names that you can Youdefine a define n. Divisio ment Environ the in ph paragra -NAMES the SPECIAL the , example for "; mnemonic-name by equating it to a "device following clause equates STATUS-REPORT to the device LINE-PRINTER: LINE-PRINTER IS STATUS-REPORT You could then use the mnemonic-name in a DISPLAY statement: DISPLAY "File contains " REC-COUNT UPON STATUS-REPORT. 6.10.2 Logical Name "Devices" The device names in logical names: the SPECIAL-NAMES paragraph SPECIAL-NAMES Device Logical Name CARD-READER PAPER-TAPE-READER | CONSOLE LINE-PRINTER COBSCARDREADER COBSPAPERTAPEREADER COBSCONSOLE COBSLINEPRINTER PAPER-TAPE-PUNCH represent VAX/VMS COBSPAPERTAPEPUNCH You could, do not necessarily represent devices. The logical names with a VMS ation specific file a to name logical a for example, assign ASSIGN command: ASSIGN [ALLSTATUS]STATUS.LIS COBSLINEPRINTER no Because a logical name does not 1imply a device, it <carries a upon display can program a re, implication of "open mode"; therefo a from accept or DER CARD-REA to mnemonic-name that refers mnemonic-name that refers to LINE-PRINTER. to In COBOL, the ACCEPT and DISPLAY statements do not refer do files closing and opening of concepts the e, therefor es; file-nam However, the RTS uses RMS for all 1I/0 operations, not apply. including ACCEPT and DISPLAY. The RTS therefore implicitly "opens" ta logical name when it is first used in an ACCEPT or DISPLAY statemen in any COBOL module in the image. INPUT-OUTPUT PROCESSING 6-27 NOTE When the RTS DISPLAY opens a logical statement, it variable with fixed-length format to allow carriage RTS does opens a not use logical statement. The VFC name record name for specifies a the control (VFC) control: the format when it for an ACCEPT format attribute is wused for all operations until the image terminates; therefore, if vyour program contains both ACCEPT and DISPLAY statements name, DISPLAY before it to the same execute first if they when you will execute ACCEPT not occur and the statements names as the WITH NO ADVANCING phrase. condition does without DISPLAY FROM/UPON refer (COBSINPUT to and statements clause: different the logical COBSOUTPUT). ACCEPT Statement 1 of the ACCEPT statement transfers the object of a VAX/VMS logical name use the FROM clause, the RTS uses otherwise, it wuses the 1logical name SPECIAL-NAMES ACCEPT paragraph statement. COBSCONSOLE: that small amounts is In CONSOLE PROCEDURE ACCEPT IS DIVISION. INPUT-OUTPUT PROCESSING data from referred to by the mnemonic-name 1in the following example, the RTS uses WHATS-HIS-NAME PARAMETER-AREA of to a data item. If you do not the 1logical name COBSINPUT; implied by the key word in the SPECIAL-NAMES. 6-28 a ACCEPT. statements use the the should carriage DISPLAY This Format refer Otherwise, DISPLAY statement control will be 1lost; all contained 6.10.3 that logical FROM WHATS-HIS-NAME. 6.10.4 DISPLAY Statement The DISPLAY statement transfers the contents of data items and If you do not use literals to the object of a VAX/VMS logical name. the UPON clause, the RTS uses the logical name COBSOUTPUT; otherwise, it uses the logical name implied by the key word in the SPECIAL-NAMES paragraph that is referred to by the mnemonic-name in the DISPLAY In the following example, the RTS uses COBSLINEPRINTER: statement. SPECIAL-NAMES. LINE-PRINTER IS ERROR-LOG PROCEDURE DIVISION. 'DISPLAY ERROR-COUNT, " phase 2 errors, ", ERROR-MSG UPON ERROR-LOG. For the DISPLAY statement, the RTS uses the variable with fixed-length control record format. INPUT-OUTPUT PROCESSING 6-29 CHAPTER GOOD 7.1 7 PROGRAMMING PRACTICES FORMATTING THE SOURCE PROGRAM Since most COBOL programs are usually 1long, the programmer needs techniques that will help him to simplify and improve the readability of his COBOL programs. The guidelines in this chapter, 1if followed, will help produce source programs that are easy to read and maintain. Before considering these guidelines, consider that are available with VAX-11 COBOL-74: l. The Conventional 2. The Terminal the Conventional Although (ANS) the reference formats format. format. format produces ANS compatible programs, it also produces source printouts that are somewhat more cluttered than those produced by the Terminal format. These guidelines, therefore, recommend the use of Terminal format and all of the following suggestions and examples assume the use of that format. Besides the obvious advantage of an uncluttered printout, the Terminal format has other programming advantages: l. It requires less 2. It requires no 3. Its storage line area. numbers. statements may be aligned with tab characters. Further, whenever required, the REFORMAT utility program will Terminal format programs to the Conventional format. (The utility program is discussed in Chapter 8). convert REFORMAT The following suggestions should help most complicated source programs. l. Begin division, Although these Insert the a blank purpose on 5 tab the following or the file) separate AREA lines to of A . or more before a the and begin over typical 5 ¢ each Area tab of to a phrases and skip over typical Area file AREA l ® A.) ¢ SELECT ¢ o e L] o TO both the items Indent, File in by IS RELATIVE SEQUENTIAL. description statement in column 5. (Use on them the following the illustration ® o o ® ® ® |J MASTER-FILE DATA In the B LABEL level column entry: RECORDS VALUE OF 4. in Consider "DBl:" IS Consider 5 them the SELECT o ASSIGN AREA FD in the statement: MASTER-FILE description A of A). SELECT of the file begin each of lines of B ACCESS Place the separate the (describing statement phrases ORGANIZATION 3. even listing. When (Column 1 then lines SELECT skip AREA . comment each Place character illustration 1. simplify a much more readable and - in column 1. one paragraph. statement (use line, of FILE-CONTROL further section, and paragraph names in column 1. names may start anywhere in Area A, aligning them in column 1 produces required, place the * becomes column 0.) 2. to and RECORD Working-Storage column four ID ARE STANDARD IS MASTER-FILE-NAME IS MASTER-RECORD. sections, begin all 01 1. columns, all subordinate items with higher-valued 1level numbers. (For example, if the item that is subordinate to a 0l-level record description is 05, begin the record description 1level number in column 1 and the 05 level number in column 5.) Use the tab character for the first indentation, a tab and four spaces for the second, two tabs for the third, etc. When indented in this manner, the listing will show, <clearly and neatly, the hierarchical relationships of all of the data names in the program as well as their level number values. Increment level necessary to numbers 1insert by inserted without having to items that are subordinate 7-2 GOOD PROGRAMMING PRACTICES 5; then additional change to later, group the level that group. if 1items, it they numbers becomes may of be all If desired, write the level numbers as single digits l instead of (such as 01). Working-Storage the 1in 77 of Use level number 01 instead (77, as a level number has the same meaning as 01, Section. and 77 may eventually be omitted from the COBOL standard.) Since all elementary items, except for index data items, require PICTURE clauses, these clauses fill a good part of the source program 1listing. However, the PICTURE clause itself may be simplified to enhance the listing's readability as follows: a. Use PIC as an abbreviation for PICTURE. b. Omit c. Align the PIC clauses on successive lines. the noiseword character to IS. align the clauses.) (Use the tab Put all paragraph name declarations in the Procedure Division on lines separate from the statements in the paragraph. This not only makes the program more readable, it also makes modification of the first statement in the paragraph easier. Follow all imperative statements with a period, making them l-statement sentences. Place only one statement on a line. In addition to making the lines shorter and more readable, this will prove quite helpful when debugging the program. For example, if the program contains a coding error, it will modify without to -easier therefore and 1line one on be the further, affecting the other portions of the sentence; diagnostic messages will refer to the correct line and their meanings will be clearer. the enhance any program in Since left-aligned statements starting of habit the develop program, that of readability to character (Use the tab all COBOL sentences in column 5. skip over Area A.) Some statements, however, should be further indented, as explained in the following paragraphs. another If the true path of a conditional statement contains statement or more than one imperative statement, conditional immediately 1lines on place all statements in the true path conditional statement and indent them to show the following Consider the following their dependence upon that statement. illustration of an IF statement and IF COMPUTED-TAX > its true path: TAX-LIMIT SUBTRACT TAX-LIMIT FROM COMPUTED-TAX GIVING EXCESS-TAX MOVE TAX-LIMIT TO COMPUTED-TAX ADD EXCESS-TAX TO TOTAL-EXCESS-TAX. word If the statement has an ELSE (or false) path, align the preceding IF and indent all statements that the under ELSE are dependent on the ELSE statement. | GOOD PROGRAMMING PRACTICES 7-3 Thus: IF condition true path statement true path statement ELSE Be false path statement false path statement. sure to Another only If a place good method single the separate path the period for after the simplifying imperative statement last statement conditionals in the true is or only! to write false path. path requires more statements, place them in a paragraph and either PERFORM the paragraph from the GO to it. This technique avoids the possibility of or inadvertently placing a period at the end of a statement within the path, thereby terminating it prematurely. When writing a GO TO procedure name on Consider GO the TO ... a DEPENDING statement, place 1line and indent them separate readability of the following sample each all. statement: P35 P40 P45 P60 P65 DEPENDING 8. When grouping the following ON P-SWITCH. statements into paragraphs organizational ideas: and sections, use Group together logical units of processing into a section. Select a section name that reflects the type of processing being conducted within that section (such as TAX-COMPUTATION SECTION, PRINT-LINE-FORMATTER SECTION, etc.). Follow section name with sufficient comment 1lines to explain processing that is carried out by the statements within section. Make paragraph names as numbered abbreviation the the that short and simple as possible. A of the section name often suffices. Thus the paragraph names in the TAX-COMPUTATION section might be TCl1l0, TC20, TC30, etc. Use paragraph names sparingly, placing them only where the true and false paths of conditional statements require branch points for GO TO statements. longer in If name an that paragraph, usually When simple arises reflect the type of processing lines instead. (Comment lines to comment information, numbered characters portion of the inserted later temptation attempt use convey more using numeric 7-4 the in to paragraph sequential names increases by without disturbing GOOD PROGRAMMING PRACTICES more to give a paragraph a clearly.) names, assign paragraphs. If increasing the numeric 5 or 10, new ones may be the sequence of the names. Do not use If the paragraphs section the use the by of PERFORM a verb thru in the b must form, be themselves and PERFORM the THRU option. PERFORM performed, the a THRU place section, them b. in a avoiding thus Place single sections and verbs. Then, paragraphs that are to be performed into wuse the section name as the object of PERFORM if future design changes introduce complicated conditional 1logic into the paragraph, requiring additional paragraph names, the PERFORM statements need not be altered. The preceding guidelines divide the Procedure Division into modular blocks of coding. 1If these guidelines are used, the following additional techniques may be applied. a. Restrict entry to statement of section a b. "fall Ensure names through" that or USE Avoid They OF GO the sections by the TO through of a preceding statements names GO TO use that GO using the 1little 7.3 to the characters, readability aligned, as of discussed punctuation characters or USE OF to except accompany not an it is by executing alterable referenced GO l. the section comma and semicolon. programs that have earlier section in this their chapter. which can cause either ignore them with warning messages.) the proper that may be 1If control write the following places, they have it. Also, it wunless is of of control in a alterable GO an explicit difficult tell whether or All of quite this makes difficult. debugging programs that There are two other their branches one of switch as a the comments statements in what to ALTER used sample change the flow test the setting statement, by destinations might Dbe. contain these statements techniques only to THE ALTER STATEMENT Avoid using the ALTER statement to program. It 1is 1impossible to or flag best, even when used correctly and in effect on the meaning of the program. statement or statement. COBOL punctuation neatly incorrect first PERFORM, internal Further, it is quite easy to misuse'these characters, serious errors for many compilers. (Other compilers At no a section. refer are the TO, PUNCTUATION lend statements all all from paragraph containing 7.2 the possible place: two ways (i.e., a binary switch), conditional variable. Consider the coding: GOOD PROGRAMMING PRACTICES 7-5 P-SWITCH PIC S9 COMP VALUE 0. 01 88 NO-PRINT VALUE 1. MOVE 1 TO P-SWITCH IF NO-PRINT GO TO P40. P40. 2. 0 MOVE TO P-SWITCH. If control branches more than two ways, use MOVE to place integers into a data item, and a statements GO TO DEPENDING ... statement to test the data item and accordingly. Consider the following sample coding: 01 branch P-SWITCH PIC S9999 COMP VALUE O. MOVE 1 TO P-SWITCH MOVE 3 GO TO P-SWITCH. TO PART-TIME PIECE-WORK HOURLY SALARIED-WEEKLY SALARIED-OTHER * DEPENDING ON P-SWITCH. FALLTHROUGH IS A BUG DISPLAY "?217". STOP 7.4 RUN. USE OF THE PERFORM STATEMENT The general rules for the PERFORM statement following 1. are augmented with the rules: last The endpoint of a section and the endpoint of This points. paragraph in the same section are two distinct the means that it is possible to execute a PERFORM execute to active, still is PERFORM that while section, then a PERFORM of the last paragraph. 2. new On the start of a PERFORM, if the end point of PERFORM is the end point of an already active PERFORM, the RTS aborts the task and 7-6 GOOD PROGRAMMING PRACTICES issues an error message. 3. At the end of any procedure, a check is made to see 1if the procedure being ended is the end of the most recent PERFORM range. If so, the most recent PERFORM range is exited. If not, the end point of the most recent procedure is checked against the end point of all currently active PERFORMs. If the end point of the procedure 1is the end point of any currently active PERFORM range, the RTS 1issues an error message and aborts the task because the perform ranges are not were being exited entered. in the reverse of the order in which they NOTE The RTS Chapter 7.5 USE OF LEVEL-88 error 10. messages are discussed 1in CONDITION-NAMES Condition-names provide a convenient method for testing a value or range of values in a field. The use of condition-names makes programs easier to maintain, because it ensures a uniform method of testing fields and helps to reduce recoding when the specifications of the program change. The the following example illustrates the advantages inherent in their use. use of condition-names and shows Suppose the records of a file each describe a student 1in an educational institution (or an employee in a corporation). Some of the records contain categories of information which are not present in other records. A "code" field, which contains a digit or letter, indicates the presence (or type) of some categories; while a special value in the information itself (such as a numeric value being zero, negative, or maximum) indicates the presence of other categories. The processing of such a record may vary considerably depending on these indicator fields. The fields may require 1interrogation at various points in the program, and the interrogation may require more than a simple relation test. Consider a "code" field that holds one of seven values, coded as a mnemonic character. For example, S,1,2,3,4,G,P might be seven values that indicate student categories of Special, lst year, 2nd year, 3rd year, 4th year, Graduate, and Postgraduate. The field is described as follows: 05 STUDENT-CATEGORY PIC X. Program logic requires certain processing for enrolled undergraduates, different processing for special students, and still different processing for all students except enrolled undergraduates. GOOD PROGRAMMING PRACTICES 7-7 Without the aid of condition-names, follows to might be written IF STUDENT-CATEGORY NOT LESS THAN "1" IF STUDENT-CATEGORY NOT GREATER THAN "4" ... resolve this problem: IF STUDENT-CATEGORY = "S" statements as ... IF STUDENT-CATEGORY EQUAL TO "G" NEXT SENTENCE ELSE IF STUDENT-CATEGORY EQUAL TO "pP" NEXT However, if various SENTENCE entries 88 1level ELSE GO TO ... follow the STUDENT-CATEGORY description, as shown below, condition-names can simplify this coding. 05 STUDENT-CATEGORY PIC 88 "4". X. 88 UNDERGRADUATE VALUE "1" THRU "4". 88 SPECIAL-STUDENT VALUE "S". 88 GRAD-STUDENT VALUE "G" "P". SENIOR VALUE 88 NON-DEGREE-STUDENT VALUE Now, "S" "p". the following procedural statements can solve the problem: IF IF SPECIAL-STUDENT ... UNDERGRADUATE ... IF GRAD-STUDENT ... Procedural statements with condition-names are much easier to read and debug than those containing the complete test. For example, the procedural statements, IF UNDERGRADUATE ..., and IF STUDENT-CATEGORY NOT LESS THAN "1" 1IF -STUDENT-CATEGORY NOT GREATER THAN "4" both accomplish the same thing, but the first statement is simpler and less confusing. the test can ... In addition, the statement, IF NOT UNDERGRADUATE one any to equivalent is which undergraduate, an being not of category of the following IF NOT statements: (STUDENT-CATEGORY NOT < "1" AND STUDENT-CATEGORY NOT > "4") ... or IF STUDENT-CATEGORY STUDENT-CATEGORY < > "1" "4" OR ... or IF STUDENT-CATEGORY < "1" NEXT SENTENCE ELSE IF STUDENT-CATEGORY > "4" NEXT SENTENCE ELSE GO TO ... Statements such as these are tedious to write and a frequent source of coding the 7-8 errors. recoding Further, takes more if a change creates a new student category, time and GOOD PROGRAMMING PRACTICES is even more error prone. A careful and controlled use of condition-names forces a higher degree If the program logic does of programming control and checkout. GORY field, it can even be STUDENT-CATE the of n require the modificatio named FILLER thus removing the opportunity to shortcut the use of condition—-names. To apply condition-names, follow the description of the item to Dbe tested with a 1level 88 entry. The item being tested, known as the preceding the in (STUDENT-CATEGORY variable conditional but not usadge, ONAL COMPUTATI or DISPLAY either be illustrations), may INDEX usage; it may also be a group item. The compiler stores all of the values supplied by the level 88 entries (They are pooled with all in the object program exactly as written. of the literals from the Procedure Division.) A value supplied by a level 88 entry for a conditional variable of COMPUTATIONAL usage is stored in binary format to save conversion at run time. The compiler stores all other values as byte strings with the proper attributes. It not does make level the 88 entries equal to their This means that it neither truncates in size. conditional-variables it neither Further, non-numeric literals. nor pads (with spaces) s pads (with zeros) numeric literals, but stores them as nor truncate written or, if converted to binary, in the minimum size COMP item that It stores signs as trailing the converted value. hold will overpunches on numeric DISPLAY literals, and removes and remembers decimal points. Do not enter level 88 items under group items entries containing JUSTIFIED, 7.6 7.6.1 any COMPUTATIONAL, of the following that have clauses: subordinate SYNCHRONIZED, INDEX. USE OF QUALIFIED REFERENCES Qualified Data References The COBOL language provides facilities to define and reference user-defined data items. Data items are programmer-defined variables Such variables declared in the Data Division of a COBOL program. include, among others, file record descriptions and internal working areas. These data items are processed by procedural statements such as the WRITE, MOVE, and ADD statements. Procedural operations on these data are facilitated through references to the data items by name. GOOD PROGRAMMING PRACTICES 7-9 For example, pay amount to update a variable, YTD-GROSS-PAY, by a weekly gross WEEKLY-GROSS, write the program fragment shown in Figure 7-1. WORKING-STORAGE 01 01 SECTION. YTD-GROSS-PAY WEEKLY-GROSS PIC 9(5)V99. PIC 999Vv99. ADD WEEKLY-GROSS Unqualified TO YTD-GROSS-PAY. Figure 7-1 Data Item Reference In this example, YTD-GROSS-PAY and WEEKLY-GROSS are -defined 1in the Working Storage Section of the Data Division as COBOL variables with a level number of 0l. The variable representing the "year-to-date gross pay (YTD-GROSS-PAY)" is computed by incrementing its present value by the "weekly gross pay (WEEKLY-GROSS)" amount through reference to the appropriate data items in the ADD statement. References are made to the data items by the singular, unqualified names of YTD-GROSS-PAY and WEEKLY-GROSS. Since YTD-GROSS-PAY and WEEKLY-GROSS are defined with level numbers of 01 in the Working Storage Section, these variables must be unique in their spelling and, hence, can only be referenced by the spelling of each data item's name without any COBOL qualification. The example in Figure 7-1 1is artificial because the data item representing the "year-to-date gross pay" 1is defined as a level 1 variable 1in the Working Storage Section. More realistically, YTD-GROSS-PAY 1is defined as a field within an employee payroll record residing on an external master payroll file. The process of updating the "year-to-date gross pay" by a "weekly gross pay" amount is shown more appropriately in Figure 7-2. FILE SECTION. FD MASTER-IN 01 VALUE OF ID PAY-RECORD. LABEL 03 03 03 7-10 RECORD IS IS STANDARD "MASTER.PAY". NAME EMPLOYEE-NO YTD-GROSS-PAY GOOD PROGRAMMING PRACTICES PIC PIC PIC X(30). 9(9). 9(5)V99. FD MASTER-OUT LABEL RECORD IS STANDARD VALUE OF ID IS "MASTER.PAY". 01 PAY-RECORD. PIC X(30). PIC 9(9). PIC 9(5)V99. 03 NAME 03 EMPLOYEE-NO 03 YTD-GROSS-PAY WORKING-STORAGE SECTION. PIC 999Vv99. 01 WEEKLY-GROSS PROCEDURE DIVISION. INIT. OPEN INPUT MASTER-IN. OPEN OUTPUT MASTER-OUT. ADD WEEKLY-GROSS, YTD-GROSS-PAY OF MASTER-IN GIVING YTD-GROSS-PAY OF MASTER-OUT. Figure 7-2 Qualified Data Item Reference In this example, YTD-GROSS-PAY is defined as a field in both the input There are two separate data items and output record descriptions. whose spellings are identical. To reference each data item, it is necessary to qualify the name of each data item with sufficient information to constitute a unique reference. Thus, to reference the "year-to-date gross pay" amount in the output record, we write "YTD-GROSS—-PAY OF MASTER-OUT" where such a reference is called a qualified reference. The filename MASTER-OUT is functioning as a qualifier in the reference. The reserved word "OF" is the qualification connector and may be used interchangeabely with the reserved word "IN" in this context. Another way of referencing the same data item is to write "YTD-GROSS-PAY OF PAY-RECORD IN reference is called a completely gqualified This MASTER-OUT". possible qualifiers are specified 1in the all reference because reference. A reference of the form "YTD-GROSS-PAY" or "YTD-GROSS-PAY OF PAY-RECORD" is illegal since it does not uniquely identify which of such a reference 1is termed an the two data items 1is desired. ambiguous reference. | In the area of data item definition and referencing, COBOL 1is unlike other languages such as FORTRAN and ALGOL 60. While FORTRAN requires each data item to have a unique name (i.e., no two data items may have a name of identical spelling), COBOL relaxes this requirement to the GOOD PROGRAMMING PRACTICES 7-11 extent that each data item must be uniquely referable. That 1is, two or more data items may have their names spelled identically, but there must exist a way to reference each distinct data item. Thus, there is a distinction between a data item and its name. Central to understanding this distinction is understanding the concept of unique referability. The functionalities of data item definition and referencing may understood by stating three guidelines which relate the concepts data item definition, reference format, and unique referability. 7.6.2 Guideline 1 be of (Data Item Definition) Each data item has a name. Each name is immediately preceded by an associated positive integer called its level number. A name either refers to an elementary item or else it is the name of a group of one or more items whose names follow. 1In the latter case, each item in the group must the level 7.6.3 have number Guideline the same of the group level number, 2 (Reference Format) Data-name qualification is performed by condition-name by one or more phrases of a OF. 1IN and OF are logically equivalent. qualified refierence "name-0" is given in to an elementary Figure 7-3. name-0 OF name-l...0F Figure General Format of which must be greater than item. a following a data-name or qualifier preceded by IN or The general format of a item or group of items named name-m 7-3 Qualified Data Reference where m >= 0 and where, for 0 <= j < m, name-j is the name of some item contained directly or indirectly within a group item named "name-j+1". A reference of the form given in Figure 7-3 is called a (partially) qualified reference with name-1,name-2,...,name-m being called qualifiers. Such a reference is termed a completely qualified reference if "name-j+1" is the father of name-j for 0 <= j <= m-1. In the hierarchy of qualification, names associated with an FD indicator are the most significant, then the names associated with level-number 01, then names associated with level-number 02,...,49. The most significant name in the hierarchy must be unique and cannot be qualified. Subscripted or indexed data-names, unsubscripted data-names, and condition variables may be made unique by qualification. The name of a condition variable can be used as a qualifier for any of its condition-names. 7-12 GOOD PROGRAMMING PRACTICES Enough qualification must be mentioned to make the however, it may not be necessary to mention hierarchy as 7.6.4 the example Guideline 3 in Figure 7-2 demonstrates. reference unique; all 1levels of the (Unique Referability) If more than one data item is defined with the same name "name-0", there must be a way to refer to each use of the name by using qualification. That is, each definition of "name-0" must be wuniquely referable. A data item is uniquely referable if the complete set of qualifiers for the data item are not identical to any partial (including complete) set of qualifiers for another data item. 7.6.5 Qualified Procedure Statements The facility of qualification may be applied to procedure references. A procedure name is either a paragraph or section name. By definition, a paragraph name is unique only within a section containing the paragraph while, on the other hand, section names must be unique within a COBOL program. The general format of a qualified procedure reference is shown in Figure 7-4. paragraph-name OF Figure General section-name 7-4 Format of a Qualified Procedure Reference A paragraph name may be qualified by its containing section name; a section name may never be qualified in a procedure reference. When a paragraph name is referenced without an explicit section name qualifier, the paragraph name is implicitly qualified by the appropriate section name. I1f a paragraph name is unique within a COBOL program it 1is not necessary to qualify the paragraph name in the procedure reference. Finally, if a paragraph name is not unique within a COBOL program, the paragraph name must be qualified in a procedure reference when the reference is made outside of the section which contains the paragraph. 7.6.6 Qualification and Compiler Performance Qualification is a powerful language facility for the development of COBOL programs. Used wisely, it increases the readability of COBOL programs. However, the user pays a price for wutilization of this facility in lines unit per terms of of a slower compilation rate (i.e., COBOL source time). GOOD PROGRAMMING PRACTICES 7-13 Qualification requires a tree-structured symbol table at compile-time. The time required for building and looking up on a tree-structured symbol table is considerably longer than for a non-tree-structured symbol table. This translates into a general degradation of compiler performance. If qualification is not employed in a program compiled by the VAX-11 COBOL-74 compiler, compilation speed is not affected. However, when qualification is used, the due to the additional system overhead. compilation rate slows down In general, if there are deeper levels of qualification, there will be a slower compilation. This is especially so at the end of the Data Division text where duplicate data-name declarations are detected by the compiler. Run-time performance is not affected by usage of the qualification facility. 7-14 GOOD PROGRAMMING PRACTICES CHAPTER REFORMAT 8 UTILITY PROGRAM VAX-11 COBOL-74 accepts source programs that were coded using either the conventional 80-column card reference format or the shorter, terminal-oriented VAX-11 cobol terminal format. The REFORMAT wutility program reads source programs that were coded in the terminal format and converts them to 80-column conventional format source programs. The VAX-1ll COBOL Language Reference Manual discusses both formats in detail. Consider the two formats: @ The terminal format is designed for ease of use with text editors controlled from an on-line console keyboard and is compatible for use with the VAX-1l1l system. It eliminates the line-number and identification fields and allows horizontal tab characters and short lines. @ The conventional format produces source programs compatible with the reference format of other COBOL throughout the industry. REFORMAT lets you write source programs in if compatibility 1is ever required for provides a simple method for conversion to REFORMAT follows format coding to the the that are compilers the terminal format; then, any of those programs, it the conventional format. following steps to expand conventional format: each line o0f terminal @ It generates a 6-character line number of 000010, places that number 1in the first six character positions of the line, and increases it by 000010 for each subsequent line. @ It places any continuation or character position 7. @ It places the coding from the terminal format character positions 8-72, thereby <c¢reating conventional format coding. ®@ It replaces space 5, 13, line. @ any horizontal comment tabs with symbols the (-,*, or a appropriate /) into 1line into 1line of number of characters to simulate tab stops at character positions 21, 29, 37, 45, 53, 61, and 66 of the terminal format It moves spaces into any last character of coding character positions left between and character position 73. the @ It places either supplied positions @ identification at program 73-80. It right justifies (at continued non-numeric literal will remain the format. @ It right justifies word that is It creates space run that Command String causes requests to be file the following REFORMAT to file type a 1In you desire response for through this as 80-character following output records to first 1line of a guaranteeing that the it was in the default first (/) through 1in 72 part of any 7 and position for every form-feed command: execution. for its two the two prompting REFORMAT files messages, 80 and output) type in the files. SPEC: successfully opened both files, for an identification entry in an immediately (input SPEC: FILE identification places of each 73 TO entry, these output type REFORMAT types the columns 73 through in from characters, line. 1If no one 1left to eight justified, entry is in required, 80: response, REFORMAT records, in reads the conventional messages; produced and RFM-nnnnn LINES RFM-INPUT FILE the first the second input file reference REFORMAT UTILITY indicating requesting and writes it format. the REFORMAT number another displays (nnnnn) input of file. PROCESSED. SPEC: If there is another file to be with the specifications for terminate execution. 8-2 were character the When it has processed the last record in the file, the they into return. RFM-COLS Following your FILE REFORMAT carriage begin specifications When the system has following request 73 slash 8 (if spaces RFM RFM-INPUT columns a positions the specifications If containing in enter RFM-OUTPUT 80. 72) 1literal, thus same length as encounters. processed. characters. position it REFORMAT, MCR This line character REFORMAT To a characters or (at position 72) the split over two lines. COBOL @ characters initialization) PROGRAM reformatted, the next follow the file. 1If not, same type sequence CTRL/Z to Error REFORMAT Messages If any of the responses to the prompting messages contain detectable the indicating following messages the REFORMAT displays errors, problem. RFM-ERROR IN OPENING RFM-TRY AGAIN INPUT FILE SPEC: RFM-INPUT FILE The system could not open the input file. Either the file 1is not the device specified (the default device is SYSSDISK) or present on messages error I/0 wusual The the file name is typed incorrectly. precede this message. To continue processing that file, examine the input file spec and type To process another file, type in a new input a corrected version. in To terminate execution, type CTRL/Z. file specification. RFM-ERROR IN OPENING OUTPUT FILE RFM-TRY AGAIN RFM-OUTPUT FILE SPEC: The system could not open the output file. An incorrectly typed file specification wusually causes this error. (The default device is SYSSDISK.) continue, The usual examine corrected version. RFM-INPUT RFM-INPUT I/0O error messages the output file FILE FILE IS EMPTY SPEC: precede this specification and but the To terminate execution, The system successfully opened the input type CTRL/Z. file, statement encountered the AT END condition. message. 1in first READ To continue, type in a new input file specification for another To terminate execution, RFM-ERROR RFM-INPUT type CTRL/Z. IN READING FILE SPEC: INPUT To type a file. FILE The first attempt to read the input file was unsuccessful. This error is wusually caused by an input record length exceeding 86 characters. 1in characters (Although terminal format records should not exceed 66 REFORMAT provides a record area of 86 characters and ignores length, the right-most 20 characters.) To continue, type in a new input file specification for another To terminate execution, file. type CTRL/Z. RFM-ERROR IN READING INPUT RFM-REFORMATTING ABORTED RFM-nnnnn LINES PROCESSED RFM-INPUT FILE SPEC: FILE REFORMAT UTILITY PROGRAM 8-3 While reading input records (other was unsuccessful in an attempt execution and closes both files. the read first record), REFORMAT a record. It terminates To process another file, type in a new input continue with the prompting message sequence. file specification and To terminate execution, type than to CTRL/Z. RFM-ERROR IN WRITING OUTPUT FILE RFM-REFORMATTING ABORTED RFM-nnnnn LINES RFM-INPUT FILE REFORMAT was terminates unsuccessful execution and PROCESSED SPEC: in an attempt to write an output record. closes both To process another file, type in a new input continue with the prompting message sequence. type CTRL/Z. 8-4 REFORMAT UTILITY PROGRAM It files. file specification and To terminate execution, CHAPTER DEBUGGING 9 COBOL PROGRAMS Debugging is the process of finding and correcting errors in programs that have been successfully compiled and linked. In some cases, you need to debug a program because it produces incorrect results: other programs may operations. terminate abnormally as a result of attempting illegal This chapter introduces the VAX-1l1 Symbolic Debugger (DEBUG) for COBOL-74 programs. You will find a complete description of the DEBUG facility in the VAX-11] Symbolic Debugger Reference Manual; enough information is included here to get you started debugging a COBOL program. 9.1 DEBUG CONCEPTS DEBUG 1s LINK command. a module that (See you can include Chapter 2.) It in an allows executable you to image examine with and the change the contents of your program's data items; vyou can also control the order of statement execution and regain control when execution errors occur. The VAX-1l1l Symbolic Debugger is called symbolic because it allows you to refer to data items by the symbols you assigned, that is, data-names. You can refer to Procedure Division locations by source listing line numbers rather than VAX-11 memory addresses. To use symbolic object module. references, the Although this compiler adds no must store the symbols in the address space requirement to the executable image, it does require space in the image program. do why symbol tables are not stored automatically -to be stored by using the /DEBUG command qualifier use the If you debugger, not but you specify /DEBUG cannot refer at to compile data and prompts you for a command with the prompt: that cause is them when you compile a time, you can still items To summarize, use the /DEBUG command qualifier at and link time. Then, when you execute the image, file; you must symbolically. both DEBUG DBG>. compile time takes control 9.2 The PREPARING TO DEBUG A PROGRAM following environment for sections debugging SET LANGUAGE SET MODULE SHOW commands The that commands establish are: the COBOL MODULE SCOPE SHOW SCOPE CANCEL 9.2.1 the COBOL programs. MODULE CANCEL SET describe SCOPE SET LANGUAGE COBOL Command This command tells DEBUG that the debugging dialog applies to a COBOL program. It allows symbols that contain hyphens, for example. The format of SET the command LANGUAGE is: COBOL You may want to debug an image that contains modules written 1in more than one language; the SET LANGUAGE command allows you to change language conventions during the debugging session. DEBUG's default 9.2.2 is the language of MODULE Commands: SET, SHOW, the main program. and CANCEL DEBUG maintains a table of symbols defined in the program with which it 1is 1linked; the table contains the name of each data item defined in the program, its data type, and its location. The table <can hold about 2000 symbols at a time. Therefore, if an image contains modules that have a total of more than 2000 symbols, the table may not be able to hold all of them at once. You cannot refer to a symbol unless it is in the active symbol table. Use the MODULE commands to control the contents of DEBUG's active symbol table when the image you want to debug contains multiple modules. SET MODULE The commands are: Places the symbols defined in the specified (program) into the active symbol table. The format of the SET MODULE SET MODULE module-name 9-2 DEBUGGING COBOL PROGRAMS command 1is: [,module-name] ... module SHOW MODULE Displays the currently in The format SHOW DEBUG CANCEL MODULE names the of of the active the SHOW modules symbol MODULE are command is: responds by displaying the names of the modules linked with 1it; symbols are in the space they occupy. it also indicates active symbol table which modules' and how much Removes symbols the active command is: The a module's format of CANCEL SCOPE symbols MODULE from table. 9.2.3 whose table. Commands: SET, the CANCEL MODULE MODULE module-name SHOW, and [,module-name] symbol ... CANCEL The SCOPE commands control the default that DEBUG uses to resolve references to symbols. When you use the EXAMINE command, for example, you can either name the module in which the symbol is defined, or you can omit the module name. If you omit the name, DEBUG uses a default; it can't find the symbol in the default scope, it attempts to £find unambiguous symbol in the remaining modules. If DEBUG cannot resolve the reference, it displays a message. if an Until you use name of The SCOPE SET SCOPE the a SET SCOPE first module commands are: command, with Specifies The SET SHOW SCOPE CANCEL SCOPE the SCOPE current SCOPE the format CANCEL command SET of scope the is: default SHOW SCOPE module name. command is: current default module name. SCOPE command, DEBUG uses the first module default. The SET the default module-name SHOW the as linked. the of another was module. format Cancels use of it default SCOPE Displays The the format DEBUG uses which the with which CANCEL it SCOPE Until you the name of was 1linked command is: as the PROGRAMS 9-3 SCOPE DEBUGGING COBOL 9.3 SPECIFYING LOCATIONS Several DEBUG commands use locations as parameters; you tell to locations allow data you want to look at or where you want what DEBUG for example. control transferred, 9.3.1 For Location Types COBOL can Yyou programs, three use location of types specifications: Data—-name refers to a data item in the Data Division. type of location is often called a symbol. For This example: INPCHAR EXAMINE tells DEBUG that you want to see the contents of the commands the data item whose data-name is INPCHAR. You cannot qualify data-names in DEBUG If you refer to a data-name in COBOL. way you can DEBUG in the module, once than more defined is that applies the reference to the definition that appeared last in source program. the You can use subscripts in DEBUG commands as in COBOL except for data-names appearing in the statements, usually access you can however, Linkage Section; the to referring by items Section Linkage corresponding non-Linkage Section data-name in the calling program. specifies the beginning of Line a source The format of a line location is: $LINE program line. n The value of n corresponds to a compiler—-assigned line number on the program's source listing. Absolute specifies a numeric memory address. absolute location as an integer. For an example: EXAMINE 1200 tells DEBUG to display the contents of located 9-4 Specify at address DEBUGGING COBOL PROGRAMS 1200. the longword 9.3.2 Your Resolving program Location Ambiguities can consist of more than one main program called a subprogram. If module are in DEBUG's symbol table, and symbol reference could be ambiguous. module were linked with DEBUG, then ambiguous. DEBUG uses however, other For a defaults than the example, your Because scope SLINE not resolve depending command. can override specifying GO the 9.4 if a Furthermore, 1line numbers than also references. scope in an if more could In some one be cases, location to refer program, TESTA, to the you consist wanted to of a main transfer control to line and 36 in command: specify a module the default as and part of name, the had resolve the DEBUG uses the default default could be either TESTA or previously used a SET SCOPE the ambiguity vyourself by location: TESTB\36 you EXAMINE might If the ambiguity -on whether you scope SLINE Similarly, program use TESTB, You the would than one then a ambiguous specify it 36 you did to to TESTB. you might GO resolve as default module. subprogram, TESTB, to you may want module, the symbols from more if duplicates exist, can specify the scope in symbolic data-name locations: TESTB\ACCNT-NUM CONTROLLING PROGRAM EXECUTION This section describes monitor, and resume commands SET SHOW SHOW BREAK BREAK BREAK SET WATCH EXIT SHOW WATCH SHOW GO TRACE STEP TRACE BREAK Commands: CTRL/Y SET, SHOW, and CANCEL The BREAK commands A breakpoint is breakpoints execution and breakpoint, or data change CALLS CANCEL WATCH TRACE CANCEL 9.4.1 allow you to suspend, specific points. The are: CANCEL SET DEBUG commands that program execution at control the location of a location where you return control to you; at a values, or you can change want the a in the program program's you to can program. suspend examine execution DEBUGGING COBOL PROGRAMS path. 9-5 The BREAK commands SET BREAK are: Specifies a location at which to suspend execution. The format of the SET BREAK command SET BREAK location [DO is: ] (DEBUG commands) is If the program reaches the specified location, it the instruction located executing before suspended commands perform You can request that DEBUG there. the DO wusing by reached 1is breakpoint the when option. For example: SET BREAK $LINE 210 DO (EXAMINE TOT-AMT) causes DEBUG to display the contents of the data-name TOT-AMT whenever it suspends the program at line 210. Displays SHOW BREAK all breakpoints set currently in the program. The format of the SHOW BREAK command SHOW CANCEL BREAK 1is: BREAK Removes specified breakpoints.: The format of the CANCEL BREAK command 1is: CANCEL BREAK/ALL or CANCEL BREAK location 9.,4.2 SET, TRACE Commands: [,location] ... SHOW, and CANCEL The TRACE commands control the location of tracepoints in the program. a breakpoint, except that program execution resembles A tracepoint continues after DEBUG displays the <current 1location. Tracepoints allow you to monitor the sequential flow of a program. Tracepoints and breakpoints supersede each other;, that is, a tracepoint cancelled. The TRACE SET TRACE o commands are: Specifies a location at which to display location information, suspend and continue. The format of the SET TRACE command SET TRACE location 9-6 if you set , breakpoint is the at the same location as a breakpoint DEBUGGING COBOL PROGRAMS 1is: execution, SHOW TRACE Displays the program locations at are currently which The format of the SHOW TRACE command SHOW tracepoints set. 1is: TRACE order DEBUG displays tracepoints in newest-to-oldest -- newest is the last tracepoint set. CANCEL TRACE Removes specified tracepoints. The format of the CANCEL TRACE command is: CANCEL TRACE/ALL or 9.4.3 [,location] CANCEL TRACE location WATCH Commands: SET, SHOW, ... and CANCEL The WATCH commands allow you to monitor program locations, called watchpoints, for attempts to change their contents. If an instruction. attempts to change the contents of a watchpoint, DEBUG suspends the program, displays the location of the instruction, and prompts for a command. is being The WATCH SET WATCH Watchpoints are useful when you need to know if a data inadvertently changed. commands item are: Specifies locations to be monitored. The format of the SET WATCH command SET WATCH The identifier is: identifier specifies the location to be monitored. NOTE the When a watchpoint is set, DEBUG protects When access. write from page memory entire (your 1level mode user at instruction an to change the contents of attempts program) any location on the protected page, DEBUG access for watchpoint action; the evaluates write to however, if a system service tries it returns an error. page, protected a to Therefore, if watchpoints are set on the same File Section record description, a as page 1input RMS during occur can access errors operations. DEBUGGING COBOL PROGRAMS 9-7 Displays SHOW WATCH The current watchpoints. format of the SHOW WATCH command is: SHOW WATCH DEBUG displays newest-to-oldest watchpoint set. Removes CANCEL WATCH The the order specified format of current watchpoints newest 1s the in 1last watchpoints. the CANCEL WATCH command is: CANCEL WATCH/ALL or CANCEL WATCH 9.4.4 GO The and GO GO and identifier STEP Commands STEP commands initiate and continue program Resumes program execution, either location or another location. The format GO If of the GO command execution. at the current 1is: [location] you omit the location, location. execution starts at the current If you specify to the new an location, DEBUG transfers control location. You can specify the location as a source program line number (GO %line 38, for example); however, you cannot resume execution at a 1line boundary if the current location 1is other than the beginning of a line. If the current location is not a line boundary --- a use common the occurrence when STEP command to boundary before attempting a watchpoints reach GO %$line the are reached next 1line command. NOTE Exit from DEBUG before restarting from the beginning. The results GO command to restart a program beginning are undefined. 9-8 DEBUGGING COBOL PROGRAMS a program using a from the of STEP Continues execution at the specified number of steps. The current format of the STEP command STEP for a steps to is: [n] The value of n execute, 1location specifies the number If you do not specify n, DEBUG assumes a value of 1 of or you specify O, as a default. DEBUG evaluates n for each step in the execution of a STEP command. Therefore, if n has a large value, overhead. DEBUG your program runs slower because of reduce this overhead by using the SET BREAK can You to want you and GO commands (instead of STEP) when execute more 9.4.5 CTRL/Y Command than a (Interrupting few steps. the Image) You can use the CTRL/Y command at any time to return to the VAX/VMS system command level. Press the CTRL key and the Y key at the same time; VAX/VMS displays the $ prompt at the terminal; a STOP 1literal statement in your program produces the same result. You can then return to DEBUG with the DEBUG command. Use the CTRL/Y command when you believe your program is in an infinite loop, or when you want immediate control. When you return to DEBUG, you can use the SHOW CALLS command to see the program's location the CTRL/Y command interrupted execution. when EXIT Command 9.4.6 The EXIT command terminates the debugging session. The format of the EXIT command 1is: EXIT DEBUG terminates the program and returns control command 9.4.7 to the VAX/VMS system level. SHOW CALLS Command The SHOW CALLS command displays information about the current level of and format of the content The performs. including calls, nested 1is described information are similar to the traceback display, which in Chapter 10. DEBUGGING COBOL PROGRAMS 9-9 The format of the SHOW CALLS SHOW CALLS 1is: [n] If you do not specify n, determines the number of 9.5 command DEBUG displays all call levels; levels that DEBUG reports. otherwise, n EXAMINING AND CHANGING DATA This section describes commands that allow you to see and to change the contents of data items during program execution. You may want to change values to correct errors or to test a hypothesis during a debugging session. The commands are: EXAMINE DEPOSIT 9.5.1 EXAMINE The EXAMINE The format Command command of EXAMINE the displays EXAMINE the contents command of specified location. is: [location] You will usually specify the location as a for example). However, you can display address (such as EXAMINE 1000). 9.5.2 a data-name (EXAMINE SUBI1, contents of an absolute the DEPOSIT Command The DEPOSIT The format command of DEPOSIT the changes DEPOSIT the contents command of a specified location. is: location=value Examples: DEPOSIT ITEMA=12 Places the numeric data-name ITEMA. DEPOSIT WORDX="NOW IS value THE 12 into the data DEBUGGING COBOL PROGRAMS named by into the TIME" Places the characters in the alphanumeric data item named by the data-name WORDX. 9-10 item literal DEPOSIT TOP="662K" Places the value -6622 into DISPLAY data item, TOP. the four-digit signed numeric NOTE The DEPOSIT command functions 1in the same way as the COBOL ACCEPT statement for DISPLAY data items. Therefore, you must be aware of the internal representation of your program's data items when you use the DEPOSIT command. 9.6 SAMPLE DEBUG SESSION This section contains an annotated debugging session that demonstrates the use of many DEBUG features. Following it are sample listings of a COBOL program (TESTA) and a subprogram (TESTB); the debugging session refers to these listings. Program TESTA accepts a character it to TESTB. TESTB reverses the its length) to TESTA. string from the terminal and character string and returns The following debugging session does not demonstrate the actual program errors; it 1s designed to show the features. Responses from DEBUG and VMS appear l) 1in RUN location of use of DEBUG red. We use the RUN command to start the session. Note that we do not need the /DEBUG qualifier, since the programs were compiled and 1linked with DEBUG. DEBUG takes control; it displays 1its standard header, showing wus that the default language is COBOL and that the default scope and module are TESTA. DEBUG returns control by displaying 1its prompt, ¢ passes it (and DBG>. TESTA VAX/VMS DEBUG V1.5 $DEBUG-I-INITIAL, language 04 is January COBOL, 1979 scope and module set to 'TESTA' DBG> DEBUGGING COBOL PROGRAMS 9-11 2) Using the that SHOW MODULE DEBUG's command, active contains symbols from the main program. part of the RTS; it we symbol see table only one module, The last module is was 1linked from C74LIB.OLB. DBG>SHOW module MODULE name symbols language size TESTA yes COBOL TESTB no COBOL 164 316 CBFLSW no BLISS 128 total modules: 3 remaining size: 60948. 3) We try to set a TESTB. DEBUG because TESTB's active DBG>SET BREAK symbol DBG>SET MODULE routine at line 26 of find 1line 26, are not 1in the table. 'TESTB' has 4) add TESTB's MODULE command. We no %line 26 symbols with the SET TESTB 5) Then, we confirm been added. DBG>SHOW MODULE module name symbols language TESTA TESTB yes yes COBOL COBOL 164 316 CBFLSW no BLISS 128 modules: remaining cannot symbols $LINE TESTB\26 $DEBUG-W-NOLINE, total breakpoint that | the symbols have size 3. size: 60724. 6) Now, we can set the breakpoint with no problem. DBG>SET BREAK $LINE TESTB\26 7) We resume execution continues prompt and DBG>GO routine start at TESTA\TESTA ENTER WORD 9-12 DEBUGGING COBOL PROGRAMS execution. starting until waits DEBUG displays the point. The image TESTA displays its for a response. 8) We enter the word to be reversed. Execution continues until the image reaches the breakpoint at 1line 26 of module TESTB. We two BACKWARD break at TESTB\TESTB %$line 26 9) DBG>SET BREAK %LINE 40 DBG>SET BREAK $LINE 34 set breakpoints. When line 40 of TESTB is reached, DEBUG will execute the parentheses; it will commands 1in data 1items, then resume display two execution. DO(EX HOLD-WORD;EX SUB-1;GO) 10) We display the DBG> SHOW BREAK breakpoint at TESTB\TESTB %$line 34 breakpoint at TESTB\TESTB %line 26 breakpoint at TESTB\TESTB %line 40 DO 11) We set a TESTA is active breakpoints. (EX HOLD-WORD;EX SUB-1;GO) tracepoint the default at line 22 of TESTA. scope. DBG>SET TRACE SLINE 22 12) We set a watchpoint on the data-item DISP-COUNT. When the an instruction attempts to change the contents of DISP-COUNT, DEBUG will return control to us. DBG> SET WATCH DISP-COUNT 13) We resume execution. Whenever 1line 40 in TESTB 1s about to be executed, DEBUG executes the contents of the DO command that we entered at step 9; it displays the contents of HOLD-WORD and SUB-1, then resumes execution. DBG> GO start at TESTB\TESTB %line 26 break at TESTB\TESTB %line 40 TESTB\TESTB\HOLD-WORD (1:20) : TESTB\TESTB\SUB-1(1:2): 8 start at TESTB\TESTB %line 40 break at TESTB\TESTB %line 40 TESTB\TESTB\HOLD-WORD (1:20) : . DR TESTB\TESTB\SUB-1(1:2): 7 start at TESTB\TESTB %line 40 DEBUGGING COBOL PROGRAMS 9-13 break at TESTB\TESTB %line 40 TESTB\TESTB\HOLD-WORD (1:20) : TESTB\TESTB\SUB-1(1:2): 6 start at TESTB\TESTB %line break at TESTB\TESTB %$line DRA 40 40 TESTB\TESTB\HOLD-WORD (1:20) : TESTB\TESTB\SUB-1(1:2): 5 start at TESTB\TESTB %$line break at TESTB\TESTB %$line 40 40 TESTB\TESTB\HOLD-WORD(1:20) : TESTB\TESTB\SUB-1(1:2): 4 start at TESTB\TESTB %line 40 break at TESTB\TESTB %1line 40 TESTB\TESTB\HOLD-WORD(1:20) : TESTB\TESTB\SUB-1(1:2): 3 start at TESTB\TESTB %$line 40 break at TESTB\TESTB %line 40 TESTB\TESTB\HOLD-WORD(1:20) : TESTB\TESTB\SUB-1(1:2): 2 start at TESTB\TESTB %$line 40 break at TESTB\TESTB %1line 40 TESTB\TESTB\HOLD-WORD(1:20): TESTB\TESTB\SUB-1(1:2): 1 start at TESTB\TESTB %$line 40 break at TESTB\TESTB %$line 34 14) DRAW DRAWK DRAWKC DRAWKCA DRAWKCAB We deposit the value 10 into the data item SUB-1l. Note that we do not need to enclose the value in quotes since SUB-1 is a COMP item. DBG>DEPOSIT SUB-1=10 15) We examine the contents of SUB-1. indicates that value (1:2) it 1is DEBUG displaying contained in bytes of the data item. 1 the through 2 DBG>EXAMINE SUB-1 TESTB\TESTB\SUB-1(1:2): 10 16) " DBG>DEPOSIT SUB-1= a COBOL of bytes. ACCEPT statement: as a stream | " 17) DBG>EXAMINE SUB-1 TESTB\TESTB\SUB-l(l:Z): 9-14 Here, we deposit another wvalue 1into SUB-1, wusing a quoted string. DEBUG deposits the value in the same manner as DEBUGGING COBOL 32 PROGRAMS When we look at SUB-1, we see that it now has 32 as 1its wvalue; 32 is the decimal value of the ASCII space character. DBG>DEPOSIT DBG>EXAMINE 18) We deposit a value into data item SUB-2, whose usage 1is COMP-3. The quoted string is needed because usage is other than COMP. 19) We then examine SUB-2, value is now -42. SUB-2="-42" and see that 1its picture 1is SUB-2 TESTB\TESTB\SUB-2(1:2): -0000000000000000000000000000042 20) We look at CHARCT, whose 99Vv9a9. DEBUG displays the contents as 0800; it is not aware of the 1implied decimal point. DEBUG treats all DISPLAY data items as alphanumeric. DBG>EXAMINE CHARCT TESTB\TESTB\CHARCT (1:4): 0800 21) We deposit four characters into DBG>DEPOSIT CHARCT="1500" | 22) DBG>EXAMINE CHARCT now has value "1500" (15.00). another value, omitting 1500 23) Here, the we deposit quotes. CHARCT=42 24) DBG>EXAMINE the CHARCT TESTB\TESTB\CHARCT(1:4): DBG>DEPOSIT CHARCT. We examine CHARCT and see contains an asterisk (decimal followed by three spaces. that value it 42) CHARCT TESTB\TESTB\CHARCT (1:4): * 25) We deposit the quoted value "15" into PROGRAMS 9-15 CHARCT. DBG>DEPOSIT CHARCT="15" DEBUGGING COBOL Since a without 26) quoted string conversion, we is see deposited that CHARCT now contains "15 ". If we left this value 1in CHARCT (invalid for a numeric data item), an error would occur later in the run. DBG)> EXAMINE CHARCT TESTB\TESTB\CHARCT(1:4): 15 27) So, we deposit a valid value. 28) We resume execution. The program TESTA displays the reversed word. When the image reaches line 22 1in TESTA, DEBUG DBG> DEPOSIT CHARCT="0800" detects that an instruction has changed the contents of DISP-COUNT. Since we set a watchpoint on DISP-COUNT, DEBUG displays the old and new values, then returns control to us. Note that we don't know the current location in terms of line number; the displayed location is in the RTS. DBG> GO start trace at at TESTB\TESTB TESTA\TESTA %line %line 34 22 DRAWKCAB write to TESTA\TESTA\DISP-COUNT(1:2) o0ld value = new value 08 at PC CVT_P ANY+67 To see the image's current location, we try the SHOW CALLS command. DEBUG displays the active call frames, but we still don't know the line number in our 29) program. DBG> SHOW module CALLS name routine name line relative 0000004F 00001414 22 0000007C 00004748 CVT_P_ANY TESTA DISP-COUNT. DBG>STEP at stepped 9-16 CVT_P ANY+79 to TESTA\TESTA DEBUGGING COBOL %line absolute PC We use the STEP command until we reach a line boundary. DEBUG indicates that the image has reached line 28 of TESTA, the line following the reference to 30) start PC 28 PROGRAMS 31) TESTA executes 1its We resume execution. final DISPLAY. DEBUG regains control when the STOP RUN is executed. DBG>GO start 08 at TESTATESTA %$line 28 CHARACTERS $DEBUG-I-EXITSTATUS, is '$SYSTEM-S-NORMAL, 32) normal successful completion’ At this session, the continue point, we can by examining the contents of data items, for example; or, we can terminate the image with the EXIT command. DBG>EXIT S Program Listings: 00001 00002 PROGRAM-1ID. TESTA. 00003 DATE-WRITTEN. JANUARY 00004 00005 DATE-COMPILED. 00006 00007 00008 00009 00010 00011 00012 00013 00014 ENVIRONMENT 00015 IDENTIFICATION 15-Jan-1979 vaX-11. VAX-11. DATA DIVISION. WORKING-STORAGE LET-CNT PIC 9(2)V9(2). 01 IN-WORD PIC X(20). 01 DISP-COUNT PROCEDURE PIC 9(2). DIVISION. SECTION. 00018 DISPLAY 00019 00020 MOVE 00028 SECTION. 0l GETIT 00027 SECTION. OBJECT-COMPUTER. BEGINIT. 00027 . SOURCE-COMPUTER. 00016 00024 00025 00026 1979. DIVISION. CONFIGURATION 00017 00021 00022 00023 DIVISION. "ENTER WORD". SPACES ACCEPT CALL TO "TESTB" PERFORM STOP IN-WORD. IN-WORD. USING IN-WORD LET-CNT. DISPLAYIT. RUN. DISPLAYIT SECTION. SHOW-IT. DISPLAY MOVE POSSIBLE IN-WORD. LET-CNT LOW DISPLAY ORDER TO DISP-COUNT. RECEIVING DISP-COUNT " FIELD TRUNCATION. CHARACTERS". DEBUGGING COBOL PROGRAMS 00001 IDENTIFICATION 00002 PROGRAM-1ID. TESTB. 00003 00004 00005 DATE-WRITTEN. JANUARY 00006 ENVIRONMENT 00007 00008 00009 CONFIGURATION DIVISION. 15-Jan-1979 DIVISION., SECTION, SOURCE-COMPUTER. OBJECT-COMPUTER. 00010 00011 WORKING-STORAGE 00012 00013 00014 01 01 01 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 9-18 1979. DATE-COMPILED. DATA DIVISION. SUB-1 PIC SUB-2 PIC HOLD-WORD. 03 SECTION. 9(2) COMP. S9(2) COMP-3. HOLD-CHAR PIC LINKAGE 01 VAX-11. VAX-11. X OCCURS 20 TIMES. SECTION. TEMP-WORD. 03 TEMP-CHAR PIC X OCCURS 20 TIMES. 01 CHARCT PIC 99Vv99. PROCEDURE DIVISION USING TEMP-WORD, CHARCT. CONVERT-IT SECTION. STARTUP. IF TEMP-WORD MOVE GO TO PERFORM 0 TO = SPACES CHARCT GET-OUT. LOOK-BACK VARYING SUB-1 FROM 20 BY -1 UNTIL TEMP-CHAR (SUB-1) NOT MOVE SUB-1 TO CHARCT. MOVE SPACES PERFORM TO HOLD-WORD. MOVE-IT VARYING SUB-2 FROM 1 BY 1 UNTIL SUB-1 = 0. MOVE HOLD-WORD TO TEMP-WORD. GET-OUT. EXIT PROGRAM. MOVE-IT. MOVE TEMP-CHAR (SUB-1) TO HOLD-CHAR (SUB-2). SUBTRACT 1 FROM SUB-1. LOOK-BACK. EXIT. DEBUGGING COBOL PROGRAMS = SPACE. CHAPTER 10 ERROR MESSAGES Errors can COBOL-74 occur while program. briefly discusses lists compiling, This their compile-time chapter associated diagnostics; 1linking, defines or these diagnostic Appendix running messages. E a different 1lists VAX-1l1 errors run-time messages. 10.1 COMPILE-TIME LINE ERR D error . ERROR MESSAGES If the VAX-11 COBOL-74 compiler detects an error, it diagnostic message either before or after the erroneous line. Diagnostic messages look like this: X and Appendix X--———===- TEXT will print source a program ——====————————m X ——error message error source message number program severity level line - number informational (I), warning (W), fatal (F) The of following a program example named shows diagnostic messages "SAMPLE": 00001 00002 IDENTIFICATION DIVISION. PROGRAM-ID. SAMPLE. 00003 00004 ENVIRONMENT DIVISION. SOURCE-COMPUTER. VAX-11. in the source 1listing 00005 00006 OBJECT-COMPUTER. 00007 WORKING-STORAGE 00008 00009 00010 00011 00012 01 DATA SECTION. TABLE-VALUES. 05 TAB-VAL OCCURS 01 SAVE-VAL PROCEDURE DIVISION. MAIN 00013 00014 VAX-11. DIVISION. 9 TIMES PIC X. PIC X. SECTION. PARA 0622 TERMINATOR MISSING AFTER PROCEDURE NAME. IF 00014 00015 SAVE-VAL = SPACE ADD 1 TO SAVE-VAL. Y 00015 0714 MISSING OR INVALID OPERAND FOR ARITHMETIC VERB 00016 0616 PROCESSING RESTARTS AFTER TERMINATOR. MOVE TAB-VAL STOP RUN. 00016 00017 00018 (9) TO SAVE-VAL. EXIT. W 00018 0103 .EXIT. 10.1.1 Severity Levels WAS NOT THE ONLY VERB IN PARAGRAPH. Some errors do not affect program compilation, while others abort 1it. The compiler therefore issues three types of diagnostic messages to reflect varying severity levels: Informational (I), Warning (W), and Fatal (F). Consider the program in Section 10.1: I 00014 0622 following messages, taken from the SAMPLE TERMINATOR MISSING AFTER PROCEDURE NAME The compiler issues informational messages to pinpoint suspect conditions in your source program. In program SAMPLE, the paragraph name PARA does not end with a period. The compiler displays the message: "TERMINATOR MISSING AFTER PROCEDURE NAME." to describe the error. Because the compiler can recover from the error in a manner consistent with your intentions, it issues an informational message only. NOTE line You can use the /NOWARNINGS command suppress informational error messages. 10-2 ERROR MESSAGES qualifier to W 00018 0103 .EXIT. WAS NOT THE ONLY VERB IN PARAGRAPH. Warnings, like informational errors, pinpoint source program mistakes from which the compiler can recover. In program SAMPLE, for instance, the warning indicates that EXIT must be the only statement in the paragraph. The compiler can take corrective action, however. But this action may not be consistent with your intentions, even though the code produced will be executable. The compiler therefore flags the object file to denote that warnings occurred. F 00015 450 REFERENCE TO UNDEFINED DATANAME. IGNORED. The compiler cannot recover from fatal errors in a manner that reflects your intentions. On line 15 of program SAMPLE, SAVE-VAL is defined as alphanumeric; therefore, it cannot be used 1in an arithmetic statement. The compiler cannot take <corrective action, file. and so it issues a fatal error and does not create an However, reports it analyzes all remaining object source program lines errors. NOTE You cannot warning or 10.1.2 Error use a command line qualifier to suppress fatal messages -- they are always printed. Message Printing The compiler displays the diagnostic error message either before or after the erroneous source program line. There are two exceptions to this rule: 1. Diagnostic messages can appear after the last entry in the DATA DIVISION before the PROCEDURE DIVISION header. These messages reflect errors the compiler cannot report until it has 2. processed the entire DATA DIVISION text. Diagnostic messages can appear after the 1last 1line of the PROCEDURE DIVISION. These are messages that the compiler cannot issue until it has processed the entire PROCEDURE DIVISION. 10.1.3 1Internal Compiler Errors -- System Errors The compiler performs consistency contents of data checks on program flow and the fields. ERROR MESSAGES 10-3 If the compiler detects an inconsistency, 1t prints a terminates compilation. The system error message format message is: and C74--<error message> C74--SYSTEM ERROR NNNNNN The six-digit system error code represents the probable cause of the error. When a system error occurs, the compiler closes its input file and does not generate an object file. Appendix F lists system error codes and their meanings. If an I/0 error occurs during compilation, and the compiler cannot continue processing, an I/0 system error message is displayed; the compiler then terminates. The format of the I/O system error message is: C74--<error message> C74--1I0 ERROR -NN The number (VAX/AME) 10.2 (-NN) is an RSX-11M Application Migration Executive code. SYSTEM MESSAGES VAX/VMS provides a centralized error message facility. When you type a command at your teminal or execute an image, and an error results, the system displays an error message. The general format for error messages is: $FACILITY~-L-CODE, [-FACILITY-L-CODE, TEXT TEXT] where: FACILITY is For L a VAX/VMS example, facility, %C74 or represents component COBOL-74. is a severity level indicator; the following values: Level Meaning S Success I W Information Warning E Error F Fatal, or CODE is an abbreviation of TEXT is severe 10-4 takes the form ERROR MESSAGES it has one of error the message text. a descriptive message. If VAX/VMS displays more than one message for an error, message name. "-FACILITY-L-CODE, TEXT". the additional You will find a full discussion of system messages 1in the VAX/VMS The following Messages and Recovery Procedures Manual. System or run-time 1link-time for issued messages sections discuss system errors. Link-time Error 10.2.1 Messages be first 1linked. they nonexecutable; The object modules produced by the compiler are must Two kinds of link-time error messages occur: in the object module by the (1) warning error messages, imbedded errors detected by system (2) and 10.1.1), (see Section compiler invoked by the linker. facilities warnings, If the compiler flags an object file as having detects the flag and issues the following diagnostics: $LINK-I-WRNERS, MODULE <{name> has linker the warnings compilation $LINK-W-DIAGSISUED, Completed but with dianostics 1if an error occurs If a system facility error occurs (for example, is put on a message it facility), RMS the invokes when the 1linker stack and the linker displays it. you typed the command line: LINK Consider the following example. = XXXX and no object file existed with the name XXXX, the following would appear S LINK If at your messages terminal: XXXX $LINK-W-OPIDERR, PASS 0 failed to open file "DBl: [ACCOUNT]XXXX.OBJ;" $LINK-W-UNMCOD, Initial file name was "XXXX", RMS error code = {code> $RMS-F-FNF, file not found ~SYSTEM-W-NOSUCHFILE, no such file $LINK-E-FATALERROR, Fatal error message issued "$RMS-F-FNF, file not found" is generated by VAX-1ll the RMS system of faulty facility. 10.2.2 Run-time Error Messages When you execute a program, errors can occur as program logic or file I/O problems. a result occur at Faulty Program Logic Error Procedures - If errors 10.2.2.1 system (RTS) displays a message on run-time COBOL-74 the run-time, your terminal. Additionally, the system TRACEBACK facility displays a list of routines that were active when the error occurred. ERROR MESSAGES 10-5 For example, if 00001 you create this program: IDENTIFICATION DIVISION. PROGRAM-ID. PERF. ENVIRONMENT DIVISION. 00002 00003 00004 DATA DIVISION. PROCEDURE DIVISION. ROUTINE-A. 00005 00006 00007 00008 00009 PERFORM ROUTINE-B. ROUTINE-B. PERFORM ROUTINE-C. 00010 00011 ROUTINE-C. PERFORM ROUTINE-A. it will it, the compile without any detectable errors. following will appear on your terminal: S RUN PERF ¥C74-F-RECPERDET, However, if vyou run recursive PERFORM detected symbolic dump follows $TRACE-F-TRACEBACK, module name routine line relative PC absolute PC PERF PERF 7 PREF 0000002C PERF 11 PERF 0000005C PERF 0000C6A8 9 00000044 PERF 0000C62F PERF 7 0000002C 0000C678 0000C678 The RTS displays "C74-F-RECPERDET, recursive PERFORM detected" to show that program PERF contains a statement (PERFORM ROUTINE-B) that, if executed, will cause a PERFORM statement to try and perform itself. If a fatal error occurs, and the program was /TRACEBACK qualifier (linker default), TRACEBACK symbolic dump of all call frames that were active occurred. or a the A call frame PERFORM statement. module name the source program program-counter represents For each one call (program-id), (2) line where number execution frame, the name error information. a the produce a the error subroutine CALL displays: (1) (program-1id), occurred, The initial line of the preceding TRACEBACK dump shows detected a fatal error on line 7 of program PERF. created that will cause the PERFORM on source program executed with will when TRACEBACK routine the of linked and (3) (4) that the RTS A loop has been line 7 to be twice without an intervening EXIT. The remaining lines of symbolic dump show the sequence in which the PERFORMs were executed, starting with the most recently executed statement. the If program PERF subprogram: 00005 10-6 were modified PROCEDURE ERROR MESSAGES as DIVISION follows, USING. it would become a <callable A program could then be written to call PERF: IDENTIFICAION DIVISION. 00001 00002 00003 00004 00005 00006 00007 PROGRAM-ID. DRIVER. ENVIRONMENT DIVISION. DATA DIVISION. PROCEDURE DIVISION. PARA. CALL "PERF". If you run DRIVER, the following would appear at your terminal: S RUN DRIVER $C74-F-RECPERDET, recursive PERFORM detected $TRACE-F-TRACEBACK, symbolic dump follows module name routine PERF PERF PERF PERF DRIVER PERF PERF DRIVER PERF PREF line relative PC absolute PC 7 0000002C 0000C678 9 7 7 00000044 0000002C 0000002F 0000C62F 0000C678 0000C62F 11 0000C6AS8 0000005C The symbolic dump now contains a fifth line, which shows the calling program DRIVER as the initial entry on the nested PERFORM stack. 10.2.2.2 File I/0 Error Procedures - If an error operations, the following procedure is used: 1. occurs: during I/O I1f the file status key for the file is present, the RTS sets it to the code for the error condition. Appendix C of the VAX-11 COBOL-74 Reference Manual 1lists file status key values. If an INVALID KEY imperative condition is specified for the I1/0 operation, the RTS performs the associated imperative statement. The RTS performs no other processing 1in the file The USE procedure 1is not the current statement. for performed. If no INVALID KEY imperative condition is specified for the I/0 operation and a USE procedure is declared for the file, the RTS performs the USE procedure and returns control toc the The RTS performs no further processing for the program. file. ERROR MESSAGES 10-7 4. If no AT END is specified for a sequential file, and a USE procedure 1is present, the RTS performs the USE procedure and returns 5. The control to the program. If no AT END, and no INVALID KEY, messages will be displayed as a no USE procedure 1is result. following example shows a program that procedure and declared for the file, an error condition exists; the program terminates with a C74 error status. Both C74 and RMS for a file that is opened for does 00001 IDENTIFICATION 00002 00003 00004 PROGRAM-ID. TESTIO. ENVIRONMENT DIVISION. CONFIGURATION SECTION. 00005 00006 00007 00008 SOURCE-COMPUTER. VAX-11. OBJECT-COMPUTER. VAX-1l. INPUT-OUTPUT SECTION. FILE-CONTROL. 00010 00011 00012 DATA DIVISION. FILE SECTION. FD NOFILE 00013 00014 00015 LABEL RECORDS ARE STANDARD. 01 FILE-REC PIC X. PROCEDURE DIVISION. PARA. OPEN INPUT NOFILE. 00009 not contain a USE INPUT: DIVISION. SELECT NOFILE ASSIGN TO "NOFILE.DAT". 00016 00017 If you execute the program and RMS does not find the file (NOFILE.DAT) in the default directory on the default device, the following messages will appear at your terminal: $C74-F-OPNERRFIL, OPEN error on file: (NOFILE.DAT) $RMS-E-FNF, file not found $TRACE-F-TRACEBACK, symbolic stack dump follows module name routine name TESTIO TESTIO 10-8 ERROR MESSAGES line relative PC absolute PC 17 00000030 0000C630 The following procedure for a 00001 00002 00003 00004 example shows a program that file that is opened for INPUT: IDENTIFICATION 00005 00006 00007 00008 00009 00010 TEST2IO. ENVIRONMENT DIVISION. VAX-11. OBJECT-COMPUTER. VAX-11. USE SECTION. FILE-CONTROL. SELECT NOFILE ASSIGN TO DATA "NOFILE.DAT". DIVISION. 00011 00012 00013 FILE FD NOFILE 00014 00015 00016 01 FILE-REC SECTION. LABEL PROCEDURE RECORDS ARE STANDARD. PIC X. DIVISION. DECLARATIVES. 00017 00018 00019 USE-SECTION USE SECTION. AFTER STANDARD ERROR PROCEDURE ON INPUT. does not USE-IT. 00020 00021 00022 00023 00024 DISPLAY STOP END "INVALID FILE OPEN". RUN. DECLARATIVES. PARA. OPEN INPUT NOFILE. If you execute this program and the file "NOFILE.DAT" the USE procedure will display the following message: "INVALID a SECTION. SOURCE-COMPUTER. INPUT-OUTPUT contain DIVISION. PROGRAM-ID. CONFIGURATION does FILE OPEN". Thus, if you use a USE procedure, display error messages. the VAX/VMS See RTS error Appendix exist, E for a full list of error facility will not messages. ERROR MESSAGES 10-9 11 CHAPTER SORTING IN A COBOL PROGRAM VAX-11 SORT is a native-mode utility that provides a wide range of sorting capabilities and options; it can be used as an independent utility program or, through COBOL-74, as a set of callable subroutines. VAX-11 SORT 1is described in detail in the VAX-11 SORT | User's Guide. - This chapter introduces the describes how to use them to VAX-1l1l SORT callable subroutines sort records in COBOL programs. 1l1.1 PACKAGE VAX-1l1l SORT SUBROUTINE and The SORT subroutines are part of the standard VAX/VMS 1library, and they conform to the VAX/VMS calling standards. Therefore, any native-mode VAX-1ll program can call them. In COBOL, you communicate with the subroutines through the CALL statement. The subroutines, because they are in the VMS library, are 1linked automatically with modules VAX-11 that call them. SORT provides SORSPASS FILES six subroutines opens file. are SORSINIT SORT an to perform sorting input file and This routine is functions: creates an output used only when files sorted. initializes the SORT work areas and work files, wusing the arguments you pass in the CALL statement. A program calls SORSINIT SORT once at the beginning of each sort. SORSRELEASE REC passes a record to the SORT after your program has processed it. A program calls this subroutine once for each record to be included in the sort. SORSSORT MERGE performs the sort-merge operation. SORSRETURN_REC returns a record sorting. once for to A program each record your calls to be program this after subroutine returned from the the end sort. SORSEND _SORT 11.2 I/0 The VAX-11l performs functions as SORSEND SORT once at the you to at <closing files and A program calls end of each sort. INTERFACE METHODS SORT subroutine package terms of an entire file or one called I/0 interface methods. I/0 interface methods. 11.2.1 housekeeping of a sort, such releasing memory. sorts 1in record at a time; these techniques This section briefly describes the allows specify are two File I/0 Interface Using this method, you request VAX-1l1l SORT to sort all records in a file to create a re-ordered output file. This technique is comparable of the - SOR$PASS FILES SORSINIT SORT SOR$SORT_MERGE SORSEND SORT > The [4 each W N Call SORT...USING...GIVING ] the [] to . programming method l11.2.2 for the following example second Record I/0 in sort syntax of subroutines Section 11.6 the ANSI-74 once in uses the the COBOL SORT order shown: file I/0 Module. interface operation. Interface Using this method, your program processes each record before releasing it to the SORT. After all records have been released, they are sorted into the specified order; SORT then returns one record at a time to the COBOL program. This SORT with technique input and is output functionally identical procedures. ll-2 e o |] . ® NdWwN = Call each of the following routines in the order shown: SORTING SORSINIT SORT SOR$RELEASE_ REC SOR$SORT MERGE SORSRETURN_ REC SORSEND SORT IN A COBOL PROGRAM to the ANSI-74 SE and SOR$RETURN_REC once for Call SORSRELEAREC subroutines only once in each sort. the other each record; The programming example in Section 11.6 uses the record I/0 method for the first sort operation. 11.3 call interface KEY DATA AND RECORD AREAS the to that you pass record the interface, I/0 For the record (key data) Kkeys sort the consists of subroutine SORSRELEASE REC The key data must followed by the record to be sorted (record area). buffer, which is key the in specified fields key the all contain specify the furthermore, you should described in the next section; key fields in the same sequence and in the same way (for example, the not Do same size and data type) that they appear in the key buffer. leave space between the key fields. The record area immediately follows the key data. It defines the that VAX-1l1 Sort returns -- the subroutine SORSRETURN_REC does record not return the key data. : You can specify from one to ten keys for each sort. If you need more in a single sort, you may be able to combine some key keys ten than fields to reduce the number of specifications. For example, 1f the first three keys were all the same type, and if they all were to be sorted in ascending order, you might be able to combine them this way: Original 01 keys: SORT-RECORD. 03 03 Combined 01 SORT-KEYS. 05 05 05 05 SORT-KEY-1 SORT-KEY-2 SORT-KEY-3 SORT-KEY-4 PIC X(10). PIC X(5). PIC X(20). PIC S9(5) COMP-3. 05 LAST-KEY PIC S9(6). SORT-DATA. keys: SORT-RECORD. 03 SORT-KEYS. 05 03 COMBINED-KEY-1. 05 PIC X(10). SORT-KEY-1 07 07 SORT-KEY-2 PIC X(5). PIC X(20). SORT-KEY-3 07 SORT-KEY-4 PIC S9(5) COMP-3. 05 LAST-KEY PIC S9(6). SORT-DATA. SORTING IN A COBOL PROGRAM 11-3 The total size of the key area cannot exceed 255 character positions. However, it 1s often possible to reduce the size of fields from the record area by using a different data type to specify the key. Compare the storage requirements of the following data descriptions: 03 03 ACCOUNT-NUM ACCOUNT-KEY PIC PIC 9(1l1). S9(11) 03 03 COSsT COST-KEY PIC PIC 9(7)V99. 9(7)V99 COMP. COMP-3. Requires Requires 11 characters. 6 characters. Requires Requires 9 4 characters. characters. The record I/0 interface subroutines allow only three key data types: character, packed-decimal, and word or longword binary. They do not allow other types, such as separate sign, overpunched sign, or quadword binary. However, 1if you can define such keys in the key area types. In the following use the record I/0 interface, you with one of the allowable key the data descriptions on the left examples, are not defined by a valid key type for subroutines. The data descriptions on key area for those data items: Description PIC in record area the record 1I/0 interface the right can be used in the Description in key data PIC S9(5) SIGN LEADING SEPARATE S9(5) SIGN TRAILING SEPARATE S9(17) COMP PIC PIC PIC S9(5) COMP S9(5) COMP-3 S9(17) COMP-3 PIC S9(5) PIC S9(5) PIC l1.4 COMP-3 KEY BUFFER The key buffer Define it as a describes each key to the SORSINIT SORT subroutine. (0l-level) in the Working-Storage Section. record The first data item in the key buffer specifies the number of individual keys; define it as a one-word COMP data item -- its PICTURE must be in the range 9(1) to 9(4). The following example of the beginning of a key buffer specifies that records will be sorted on three keys: g 01 Follow KEY-BUFFER. 03 NUMBER-OF-KEYS the number-of-keys definitions. Each preceding the one-word COMP items key type data COMP VALUE record —-- area. PICTURE the 9(1) data up IS to ten key field The 9(4): type of <consists the are key of key valid of as four field. following data interface: 1 character (alphanumeric) binary (COMPUTATIONAL) packed-decimal (COMPUTATIONAL-3) IN A COBOL PROGRAM types | "blocks" that you defined block to 3. The I/0 4 SORTING specifies one Specifies 2 1l1-4 9(4) specification with block key data PIC for the. record key order specifies the order 0 1l start position sorting this key field: = ascending = descending character position in the record (not the buffer) at which this key field begins. to value of this data item can range from 1 maximum length for record key The the size. specifies the size of the key field in digits, for packed-decimal (COMPUTATIONAL-3) items, or character positions for all other data items. For with COMPUTATIONAL items, PICTURE ranges to lengths associated are: PICTURE 9(1) the 1in key-length 2 9(4) 9(5) to 9(9) 9(10) to 9(18) 4 | cannot be sort key In the following example, the key buffer specifies three sort Kkeys. The data items 1in each key definition block are assigned data-names for clarity; however, you can specify them as FILLER if you do not need to refer to them explicitly, since they are passed as a record to SORSSORT INIT. WORKING-STORAGE 01 01 SECTION. KEY-BUFFER. 03 NUMBER-OF-KEYS 03 KEY-1-TYPE 03 KEY-1-ORDER 03 KEY-1-START 03 KEY-1-LENGTH 03 KEY-2-TYPE 03 KEY-2-ORDER 03 KEY-2-START 03 KEY-2-LENGTH 03 KEY-3-TYPE PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC 9(4) 9(4) 9(4) 9(4) 9(4) 9(4) 9(4) 9(4) 9(4) 9(4) 9(4) 9(4) 9(4) 03 KEY-3-ORDER 03 KEY-3-START 03 KEY-3-LENGTH SORT-RECORD. 03 SORT-KEYS. 05 KEY-INDUSTRY 05 KEY-NUMBER-OF-EMPLOYEES 05 KEY-DOLLAR-VOLUME 03 SORT-DATA. 05 NUMBER-OF-EMPLOYEES 05 05 05 FILLER INDUSTRY DOLLAR-VOLUME COMP COMP COMP COMP COMP COMP COMP COMP COMP COMP COMP COMP COMP PIC PIC PIC VALUE VALUE VALUE VALUE VALUE VALUE VALUE VALUE VALUE VALUE VALUE VALUE VALUE 3. 1. 0. 10. 25. 4. 1. 1. 5. 2. O. 35. 2, X(25). S9(5) COMP-3. 9(4) COMP. "PIC S9(5) COMP-3. CZ) - PIC 0 PIC PIC X(6). X(25). 9(4) COMP. 1 SORTING IN A COBOL PROGRAM 11-5 11.5 SORT SUBROUTINES Each of the subroutines described and necessary function. The arguments for each in this section performs a subroutine are described as separate they occur. However, each subroutine returns a 1longword COMPUTATIONAL result value, which your program can test to detect success and failure conditions. The result status codes are described for each subroutine; however, to make them available to your program, you must include the otherwise optional GIVING phrase in the CALL statements. For example: CALL "SORSEND SORT" GIVING SORT-RESULT. causes the result status for the clean-up routine to be available 1in the COMPUTATIONAL data item, SORT-RESULT, which you have defined in the Working-Storage Section with a PICTURE 9(9). Sorting is a set of logically ordered procedures, each of which 1is performed in VAX-1l1 SORT by a separate subroutine. Therefore, the order in which you call the Sort subroutines is important. Furthermore, because sorting is a set of procedures, you must complete one sort before beginning another. You can have as many separate sorts as you need in a single COBOL program; however, if you do not complete a sequence of sort subroutine calls before starting another, results. an error The following Sort subroutines are discussed in the must be called. 11.5.1 SOR$PASS_FILES For the file I/0 interface, input and output The general CALL files this subroutine passes the to VAX-1ll form of the CALL order that names of they the Sort. is: "SOR$PASS_FILES" USING BY DESCRIPTOR <input file> <output file> [GIVING <result status>] Arguments input file is the data-name of a data item that contains the file specification (or logical name) of the input file. output file is the data-name of a data item that contains the file specification (or 1logical name) of the output 11-6 file. SORTING IN A COBOL PROGRAM Result Status Values Hex Value Symbolic NORMAL SORT_ON VAR FIX Decimal Value 1 1l 1C802C 1867820 1C8064 Meaning Success. A 1867876 sort is this call You cannot records is in in the change to 1867868 1Inconsistent OPENIN 1C109C 1839260 Cannot open input OPENOUT 1C10A4 1839268 Cannot open output 11.5.2 error data for records. file. file. file. codes. SOR$INIT SORT This subroutine and areas, passed or sequence. variable-length 1C805C RMS progress wrong fixed-length INCONSIS All The already by the general CALL begins and it a sort. It interprets initializes the the parameters Sort's work (arguments) files that are program. form of the CALL is: "SORSINIT_SORT" USING <key buffer> <LRL> [ <file size> ] [ <work files> ] [GIVING <result status>] Arguments key buffer is the have data-name defined key buffer LRL is ' File the in is of the the key buffer, Working-Storage discussed in Section longest record length data item, which vyou is data-name - a you The 11.3.2. one-word the of a one-word defined COMP the Working-Storage Section, that specifies the longest record 1length (in character positions). Record length does not include the key area. size have which Section. COMP 1in data item that specifies the size, in blocks, of the input file. This argument is not required, but it can increase Sort efficiency. SORTING IN A COBOL PROGRAM 11-7 one-word - COMP is the data-name of a files work data item. specifies the number of work files the Sort Valid values are 0 and 2 through 10; should use. that The Sort expects this argument is 2. however, define it in item; binary one-byte a as the default COMPUTATIONAL item - PICTURE as a one-word COBOL 9(1) to 9(4). Result Status Values Symbolic Hex Decimal Value Value Meaning Success. 1 1l SORT ON 1C802C 1867820 A sort is already in progress or this MISS_ KEY 1C8004 1867780 No key definition specified. BAD TYPE 1C806C 1867884 An BAD LRL 1C8084 1867908 An invalid LRL was specified. NORMAL call is in the wrong invalid sequence. sort process was specified. LRL MISS 1C8074 1867892 No LRL was specified. BAD FILE 1C808C 1867916 Invalid file size. WORK_DEV 1C800C 1867788 Work file device not random access or not local node. VM FAIL 1C801C 1867804 SORT failed to get needed virtual memory. WS FAIL 1C8024 1867812 NUM_KEY 1C803C 1867836 KEY LEN 1C80AC 1867948 All 11.5.3 RMS error SORT failed to get needed workingset size. Invalid number of keys specified. Must be 1-10. Invalid key length specified. codes. SORSRELEASE_REC This subroutine passes, or releases, a record to vAX-11 Sort for record I/0 interface. the REC, your program Before calling SORSRELEASE Usually, must construct the sort keys in the key data area. constructing the keys involves nothing more than moving their values from the fields in the record area to the fields in the key area. exception the record area, or if you compute key values in some other way. 11-8 An might be when you construct keys by combining data items in SORTING IN A COBOL PROGRAM Call this subroutine once for each the sort. This call is comparable in an Input Procedure. The general CALL form of the call record to the you want to be included 1in ANSI COBOL RELEASE statement is: "SOR$RELEASE_REC" USING BY DESCRIPTOR <key data> [GIVING <result status>] Argument key data is the record-name of the key data area. The key data record-name includes both the key data and the record area; therefore, this argument gives the subroutine all the information it needs to access Result Status Values Symbolic Hex Value NORMAL SORT_ ON both Decimal Value 1 1l 1C802C 1867820 the 1C8084 1867908 A sort is is Record the data. already in the length was in progess or wrong is longer specified 1C8094 1867924 1Invalid KEY LEN 1C80AC 1867948 1Invalid key length specified. EXTEND 1C80A4 1867940 Failed MAP 1C809C 1867932 1Internal NO_ WRK 1C8014 1867796 11.5.4 to area than work map sort data work LRL address. extend Sort the SORSINIT SORT. ADR Cannot key to this sequence. BAD Need For and Success. that This keys Meaning call BAD LRL sort file. error. in memory. files. SOR$SORT MERGE subroutine performs the final phases of the sort-merge process. the record I/0 interface, call it once, after the last record has released to the Sort, and before attempting to return the first been of the sorted SOR$SORT MERGE once records. For the file after calling SOR$INIT SORT. The the general CALL form of call I/0 1interface, call is: "SOR$SORT MERGE" [GIVING <result status>] SORTING IN A COBOL PROGRAM 11-9 Arguments None. Result Status Values Decimal Hex Value Value Symbolic Meaning Success. 1 1 SORT_ ON 1C802C 1867820 A sort is already in progress, Or EXTEND 1C80A4 1867940 Failed to extend work file. NO_WRK 1C8014 1867796 Cannot sort data in memory. MAP 1C809C 1867932 1Internal Sort map error. " READERR 1C10B4 1839284 Cannot read an input file record. WRITEERR 1C10D4 1839316 Cannot write an output file record. BADFIELD 1C1l01C 1839132 Bad data in key field. NORMAL this call Need work is in the wrong sequence. files. SOR$RETURN_REC 11.5.5 This subroutine returns one record to your program from the Sort. places record the record in the record area data item; It it also returns the length. You cannot from the subroutine. <call Call this subroutine calling the sort-merge Sort. The general form of the call CALL before REC once for each record to be returned SORSRETURN is: REC" "SORSRETURN USING BY DESCRIPTOR <record area> BY REFERENCE <record length> [GIVING <result status>] Arguments record area into which the the area is the data-name of Usually, it is placed. be should record returned released; it was from which area same the however, 'you can specify another data-name. record length is the data-name of a one-word COMPUTATIONAL data item into which the subroutine will place the actual size of the returned record. 11-10 SORTING IN A COBOL PROGRAM Result Status Values Symbolic Decimal Hex Value Value Meaning Success. A record has been returned. 1 1 870 2160 MAP 1C809C 1867932 Internal Sort map error. EXTEND 1C8084 1867940 Failed to extend work file. NORMAL ENDOFFILE 11.5.6 : No more records to return. SORSEND_SORT releases 1its: :work This subroutine deletes the Sort's work files and SORSEND SORT before beginning another sort; call You must areas. however, it is good programming practice to call this subroutine at the end of any sort to release work file space and memory. The general form of the call is: CALL "SORSEND SORT" [GIVING <result status>] Arguments None. Result Status Values Decimal Hex - Symbolic NORMAL UP CLEAN 11.6 Value Value 1 1l 1C80B4 1867956 . Meaning Success. Failed to delete work files and reinitialize work areas. PROGRAMMING EXAMPLE The program in this section reads a sequential mailing list file, and writes a new filei. It uses the detect duplicates, attempts to an artificial record I/0 interface Sort technique, after constructing to return identically-keyed records together, so key, identification After it writes the new file, the program 'uses’ they can be compared. the file I/0 interface to sort the file into its original order. One of the descending record is start date) (subscription keys sort order, because the designer assumes probably the most accurate. as specified 1is that the earliest SORTING IN A COBOL PROGRAM | 11-11 The comparable comments for ANSI-74 COBOL SORT module statements comparison. IDENTIFICATION DIVISION. PROGRAM-1ID. MLIST. DATE-WRITTEN. DATE-COMPILED. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. OBJECT-COMPUTER. INPUT-OUTPUT VAX-11. VAX-11. SECTION. FILE-CONTROL. SELECT MAILING-FILE ASSIGN SELECT TO "MAILLIST". NEW-FILE ASSIGN TO "NEWLIST". SELECT SORT-FILE * * ASSIGN DATA FILE TO "SORTF". DIVISION. SECTION. *SD SORT-FILE * *01 LABEL RECORDS SORT-REC. * * * 03 03 * * * * * * * * * * 03 03 05 S-CITY-KEY 05 FILLER FILLER PIC PIC PIC 03 S-START PIC FD MAILING-FILE 01 MAILING-REC. LABEL 03 03 03 1l-12 OMITTED. S-Z1IP S-LAST-NAME. 05 S-NAME-1 05 S-NAME-2 05 FILLER 05 S-NAME-4 05 FILLER S-FIRST-NAME S-STREET. 05 S-STREET-KEY 05 FILLER S-CIT¥. 03 03 * * * ARE RECORDS ARE PIC 9(5). PIC X. PIC PIC PIC PIC PIC X. X. X. X(1l2). X(12). PIC PIC X(4). X(1l6). X(4). X(1l6). XX. | 9(6). STANDARD. MAILING-KEY. 05 ZIP-CODE PIC 9(5). 05 LAST-NAME. 07 LAST-NAME-CHAR OCCURS 16 PIC 05 FIRST-NAME PIC X(16). 05 STREET PIC X(20). 05 CITY PIC X(20). STATE SUBSCRIP-START SORTING IN A COBOL PROGRAM PIC PIC X(2). 9(6). X(1). are included as FD NEW-FILE 01 NEW-REC LABEL RECORDS ARE STANDARD. PIC X (85). WORKING-STORAGE SECTION. 01 01 MAILING-FILE-ID NEW-FILE-ID PIC X(8) PIC X(8) 01 FIRST-IN PIC 01 FIRST-KEY. 03 03 01 FIRST-COMPARE FILLER VALUE PIC S9(5) 05 KEY-ZIP 05 NAME-ADDRESS-GROUP. 07 KEY-LAST. KEY-LAST-CHAR 09 07 KEY-STREET 07 KEY-CITY 05 KEY-START SORT-DATA. 05 LAST-IN 05 SPACES. COMP-3. OCCURS 3 PIC PIC X(4). PIC X(4). PIC 9(6). PIC X(1). X(85). LAST-KEY. 07 07 01 X(85) PIC X(14) VALUE SPACES. PIC X(6) VALUE SPACES. SORT-RECORD. 03 SORT-KEYS. 03 VALUE "MAILLIST". VALUE "NEWLIST". LAST-COMPARE FILLER PIC PIC X(14). X(6). KEY-BUFFER. 03 NUMBER-OF-KEYS PIC 9(4) COMP VALUE 3. 03 03 03 FILLER FILLER FILLER PIC PIC PIC 9(4) 9(4) 9(4) COMP VALUE COMP VALUE COMP VALUE 4. 0. 75. 03 FILLER L PIC 9(4) COMP VALUE 5. AN N 03 FILLER 03 03 FILLER FILLER PIC 9(4) COMP VALUE 1. PIC 9(4)"COMP VALUE 1l. 03 FILLER PIC 9(4) COMP VALUE 1. 03 03 03 FILLER FILLER FILLER PIC PIC PIC 9(4) 9(4) 9(4) COMP VALUE 1. COMP VALUE 80. COMP VALUE 6. 03 FILLER PIC 9(4) PICN9(4) COMP VALUE 1. COMP VALUE 0. ~ 01 ORIGINAL-KEY-BUFFER. 03 FILLER PIC 9(4) COMP VALUE 1. 03 03 03 03 FILLER FILLER FILLER FILLER PIC PIC PIC PIC 9(4) 9(4) 9(4) 9(4) COMP COMP COMP COMP 1. 0. 1. 77. VALUE VALUE VALUE VALUE SORTING IN A COBOL PROGRAM 11-13 01 RESULT-STAT PIC 88 SUCCESSFUL 88 END-SORT VALUE VALUE 9(8) COMP. 1. 2160. 01 01 LRL PIC 9(4) COMP REC-LENGTH PIC 9(4) COMP. 01l FILE-STAT PIC 9(1) VALUE 0. COMP VALUE 88 01 01l 01 ENDFILE VALUE PIC 9(6) DISPLAY-DUPLICATES PIC 22%2,2Z9. DISPLAY-RESULT PIC 9(8). PROCEDURE 105. 1. DUPLICATES-DELETED MAINLINE VALUE 0. DIVISION. SECTION. SBEGIN. INPUT SORT ¥ % OPEN MAILING-FILE. SORT-FILE S-NAME-1 S-NAME-2 S-NAME-4 S-STREET-KEY % ¥ ¥ ¥ S-ZIP ¥ ASCENDING S-CITY-KEY % INPUT * % DESCENDING OUTPUT CALL S-START PROCEDURE PROCEDURE GET-AND-RELEASE RETURN-AND-WRITE. "SORSINIT SORT" USING KEY-BUFFER LRL GIVING IF NOT RESULT-STAT. SUCCESSFUL DISPLAY GO "INIT-SORT PERFORM GET-AND-RELEASE UNTIL ENDFILE., CLOSE MAILING-FILE. CALL "SOR$SORT MERGE" GIVING IF NOT RESULT-STAT. SUCCESSFUL DISPLAY "SORT-MERGE GO TO ABORT-RUN. OPEN OUTPUT PERFORM UNTIL CALL ERROR" NEW-FILE. RETURN-AND-WRITE END-SORT. "SORSEND SORT" GIVING 11-14 ERROR" TO ABORT-RUN. RESULT-STAT. SORTING IN A COBOL PROGRAM IF NOT SUCCESSFUL DISPLAY GO "END-SORT ERROR" TO ABORT-RUN. DUPLICATES-DELETED TO DISPLAY DISPLAY-DUPLICATES CLOSE NEW-FILE. SORT ¥ * MOVE DISPLAY-DUPLICATES. " Duplicates deleted". SORT-FILE ¥ S-STREET S-CITY USING NEW-FILE * ¥ S-FIRST-NAME ¥ ¥ S-ZIP S-LAST-NAME ¥ ASCENDING GIVING MAILING-FILE. CALL "SOR$PASS FILES" USING BY DESCRIPTOR NEW-FILE-ID MAILING-FILE-ID GIVING IF NOT SUCCESSFUL DISPLAY GO CALL RESULT-STAT. "PASS-FILES ERROR" TO ABORT-RUN. "SOR$INIT SORT" USING ORIGINAL-KEY-BUFFER LRL GIVING IF NOT RESULT-STAT. SUCCESSFUL DISPLAY "INIT-SORT GO TO ABORT-RUN. CALL "SOR$SORT MERGE" GIVING IF NOT CALL ERROR" "SORSEND SORT" NOT RESULT-STAT. SUCCESSFUL DISPLAY STOP "SORT-MERGE TO ABORT-RUN. GIVING IF RESULT-STAT. SUCCESSFUL DISPLAY GO ERROR" "END-SORT ERROR". RUN. SORTING IN A COBOL PROGRAM 11-15 GET-AND-RELEASE SECTION. SBEGIN. MOVE SPACES READ MAILING-FILE AT MAILING-REC. END MOVE GO MOVE * TO 1 TO TO FILE-STAT SEXIT. MAILING-REC TO SORT-DATA. MOVE LAST-NAME-CHAR (1) TO KEY-LAST-CHAR (1l). MOVE MOVE LAST-NAME-CHAR LAST-NAME-CHAR (2) (4) TO TO KEY-LAST-CHAR KEY-LAST-CHAR (2). (3). MOVE STREET MOVE CITY TO TO KEY-STREET. KEY-CITY. MOVE ZIP-CODE MOVE SUBSCRIP-START MOVE NAME-ADDRESS-GROUP RELEASE CALL TO KEY-ZIP. SORT-REC TO FROM KEY-START. TO LAST-KEY. MAILING-REC. "SORSRELEASE_ REC" USING BY DESCRIPTOR GIVING IF NOT SORT-RECORD RESULT-STAT. SUCCESSFUL DISPLAY "RELEASE-REC GO TO ABORT-RUN. ERROR" SEXIT. EXIT. RETURN-AND-WRITE SECTION. % AT * % % RETURN % SBEGIN. SORT-FILE INTO SORT-DATA END MOVE SPACES TO LAST-KEY GO TO COMPARE-KEYS. MOVE (data to keys for comparison). CALL "SORSRETURN REC" USING BY DESCRIPTOR SORT-DATA BY REFERENCE REC-LENGTH GIVING IF END-SORT MOVE GO IF RESULT-STAT. SPACES TO NOT 11-16 SORTING LAST-KEY SUCCESSFUL DISPLAY .GO TO COMPARE-KEYS. "RETURN-REC ERROR" TO ABORT-RUN. IN A COBOL PROGRAM COMPARE-KEYS. IF LAST-COMPARE | NOT = FIRST-COMPARE AND FIRST-COMPARE NOT = SPACES WRITE NEW-REC FROM FIRST-IN ELSE IF FIRST-KEY NOT = SPACES ADD 1 TO DUPLICATES-DELETED. MOVE MOVE LAST-KEY TO FIRST-KEY. LAST-IN TO FIRST-IN. SEXIT. EXIT. ABORT-RUN SECTION. SBEGIN. MOVE RESULT-STAT TO DISPLAY-RESULT. DISPLAY DISPLAY-RESULT. STOP RUN. SORTING IN A COBOL PROGRAM 11-17 CHAPTER 12 USING THE LIBRARY FACILITY The VAX-11l COBOL-74 library facility allows you to copy COBOL source language text from a 1library file into your COBOL program during compilation. One COPY statement can include large amounts of 1library source text 1in a program, eliminating a great deal of repetitious coding and the errors that often go along with it. The compiler treats the however, the in any way. The COBOL 1. copied text as if it were a part of the source program; copied material does not change the source program file library facility provides two important Standardization of File and Coding benefits: Conventions A data file is usually processed by more than one program. Each of those programs must describe the characteristics of the file, such as file-name, blocking factor and record descriptions. The programs are often written by one programmer, then maintained and updated by another. Because it 1is often difficult for a programmer to understand a program written by someone else, many organizations design and code standardized file descriptions, then keep them in COBOL libraries; programmers then COPY the file descriptions into their programs, frequently without having to understand (or even know) their details. This technique also applies to Procedure Division code that is used in many different programs. For example, a library could contain a standardized routine to <convert calendar dates to Julian dates, or to format standard report headings. 2. Saving Time and Reducing Errors Defining and coding file and record descriptions are both time-consuming and error—-prone activities. When the descriptions already exist in COBOL libraries, you can easily COPY them 1into a source program; you save time because you don't have to code them again, and you avoid potential errors in re-entering complex code. Changing the format of a file is another common time-consuming chore. When a file format changes, you usually must change and recompile all programs that use the file. If the file description is in a COBOL library, only the library must be changed; individual programs often then need only recompilation, since the library coding changes are included by the COPY. Putting commonly used Procedure yields the same benefits. 12.1 Creating Division code 1in 1libraries a COBOL Library File Each line of COBOL text a COBOL library file must form syntactically correct when it 1is merged into the source program. It can meet this condition by being itself syntactically correct or by becoming correct when it is merged with the source program. Library text must conform to the rules for the COBOL source reference format; for example, library text that will appear in Area A of the source program must be in Area A in the library file. You can write library text using either the conventional format or terminal format; however, the library text format must be the same as the source program into which it is merged. 12.2 COPY file is: The COPY Statement is a compiler-directing statement that merges a COBOL 1library 1into a COBOL source program. The simplest form of the statement COPY Text-name must - Remember regardless that text-name. be either the of where an COPY it alphanumeric statement must appears in the 1literal end source with or a file name. terminator a period program. If you specify a literal, the compiler uses 1its value as a file specification; therefore, you can include or omit all components of the file specification that are allowed in the VAX/VMS command language, such as device, directory, The only required component is the file For type, and itself. version number. example: COPY "[ACCTLIB]ACCFIL.XYZ;3". causes the compiler to in directory [ACCTLIB] If as file name access on the you use a file name in the default file type. 12-2 USING THE LIBRARY the version number 3 default device. COPY FACILITY statement, of the the file compiler ACCFIL.XYZ uses .LIB For example: COPY causes the ACCOUNT. compiler to the default ACCOUNT.LIB the access on device and latest Only four conditions require the use of the indicate the full file specification for the file 2. When the library file is not on the 3. When the library file is not in the default directory. 4. When the default directory Figure 12-1 demonstrates Division maintained when COBOL it Source and file than contains you want to default more device. than copy a one version version other the use of the COPY statement to Note that the format of the library included in the source program. Resulting Program Source DIVISION. PROCEDURE DIVISION. START-PROC SECTION. START-PROC SECTION. BEGIN-PROC. include text is BEGIN-PROC. TO-DATE FROM DATE. OPEN-FILES. COPY ACCEPT OPENF. CUST-FILE TO-DATE FROM DATE. OPEN-FILES. COPY OPENF. * OPEN I-O WORK-FILE. INPUT-LOOP. READ of than Program PROCEDURE ACCEPT to .LIB. code. is file alphanumeric 1literal copy statement: the Procedure other the When 1library latest. is of l. the the type version directory. ... OPEN INPUT OPEN I-O CUST-FILE. ORDERS. GET-VERSION. DISPLAY ACCEPT IF Library File (OPENF.LIB) "VERSION?". VER-NUM. VER-NUM NOT NUMERIC GO OPEN TO GET-VERSION. I-O WORK-FILE. INPUT-LOOP. OPEN INPUT OPEN I-O CUST-FILE. ORDERS. GET-VERSION. DISPLAY ACCEPT IF "VERSION?", VER-NUM. VER-NUM GO TO NOT NUMERIC GET-VERSION. Figure 12-1 Merging Library USING THE Text LIBRARY FACILITY 12-3 The COPY statement can appear anywhere that a COBOL word is allowed in a source program; therefore, you can use it in many ways to solve different problems. For example, if a 1library file <called MTG contains the single entry MORTGAGE-PAYMENT-AMOUNT, it could be copied in the Data Division: Source Statement: 03 COPY MTG. PIC 999V99. 03 MORTGAGE-PAYMENT-AMOUNT Resulting Source or in the Statement: Procedure Source PIC 999V99. Division: Statement: MULTIPLY COPY MTG. BY 12 GIVING ANNUAL-PAYMENT. Resulting Source Statement: MULTIPLY MORTGAGE-PAYMENT-AMOUNT BY 12 GIVING ANNUAL-PAYMENT. The periods following the COPY statements in these examples become part of the source text. If the library text punctuation, it must be included in the library file. do not requires NOTE The two preceding examples are not recommended uses of the COPY statement. They are included only to illustrate the mechanics of the COBOL library facility. 12.3 The COPY REPLACING Statement It is sometimes necessary to tailor library file text for wuse 1in a particular program. For example, if a record description in a library file has level-numbers incremented by 1 (01, 02, 03, ...) and you want them to be incremented by four (01, 05, 09, ...), you can change the level-numbers as the library text is merged into the source program. During the copying process, the COPY statement can replace all occurrences of a literal or word with an alternate 1literal or word. For example: COPY 03 ACCTREC BY 09, REPLACING 04 BY 02 BY 05, 13. This sample statement causes the compiler to scan the file ACCTREC searching for the character-string 02. Wherever it finds a 02, the compiler substitutes 05. A match occurs only if the compiler finds a 02; no match occurs for a 0 or a 2 alone. The compiler follows the same 12-4 procedure for occurrences USING THE LIBRARY of FACILITY 03 and 04. The following contains this 01 Example A. 02 02 02 02 02 examples text: B PIC C D E F PIC PIC PIC PIC COPY the 1library file named NEWSBOY, which 99. 99 VALUE 2. X(5) VALUE "ABCDE". 99V99 VALUE 3.75. 99 VALUE 02. 1 Statement: COPY NEWSBOY REPLACING B BY X. Result: 01l A. 02 02 02 02 02 Example X PIC C PIC D PIC E PIC F PIC 99, 99 VALUE 2. X(5) VALUE "ABCDE". 99V99 VALUE 3.75. 99 VALUE 02, 2 Statement: COPY NEWSBOY REPLACING 2 BY 6. Result: 01 A. 02 02 02 02 02 Example B PIC C PIC D PIC E PIC F PIC 99. 99 VALUE 6. X(5) VALUE "ABCDE". 99V99 VALUE 3.75. 99 VALUE 02. 3 Statement: COPY NEWSBOY REPLACING 02 BY 63. Result: 01 A. 63 63 63 63 63 B C D E F PIC PIC PIC PIC PIC 99. 99 VALUE 2. X(5) VALUE "ABCDE". 99V99 VALUE 3.75. 99 VALUE 63. USING THE LIBRARY FACILITY 12-5 In the last example, level-number 02 was changed to level-number 63, therefore, although both the which 1is not legal under COBOL rules; the COPY statement and the library text are syntactically correct, is merged text incorrect and would generate syntax errors. it must The REPLACING character-string can be a literal or a word; the entire with character, for character equally, compare Table 12-1 1illustrates the character-string in the library text. results of some character-string comparisons. REPLACING Literal Library Text or Word "ABC" "ABCD" No HRLY—RATE HRLY-RATE Yes 1 1 Yes "2 2 No "15" No "0l2" "12" No 012 12 No SUBTRACT SUBTRACT Yes "0l2" "01l2" Yes ACCT ACCT1 No 15" " Table 12.4 Match? 12-1 COPY REPLACING Matches The Source Listing Depending on how you write the COPY statement, library text can appear The compiler normally either before or after the COPY statement. prints a line of source text when it scans to the end of the line; recognizes a completed COPY statement when the compiler however, before the end of the line, 12-6 the it locates the library file, then: library text. 1. Prints 2. Scans the rest of the source program line. 3. Prints the entire source line. USING THE LIBRARY FACILITY Thus, 1f text (including the the source line contains spaces), the a COPY compiler statement prints source the followed library by other text before line containing the COPY statement: this results in a confusing 1listing. You can cause the compiler to produce a readable 1listing by making sure that vyou write each COPY somewhat more statement 12.5 Some as the Common of facility the last Errors more entry in on Using common a the source program line. Library Facility errors to are: avoid when using ) Failing to follow when creating the ° Merging a 1library file in one format terminal) with a source program written in ® Forgetting to the rules for library file. end the COPY Inadvertently they are duplicate defining also names. data-names defined COBOL statement period. ) the 1in the in library reference format (conventional the other. with the the a source 1library terminator program file, or thus when causing ) Writing library incorrect when it ) Merging the wrong versions exist, or ® Writing source text following the COPY statement on the same line, thus causing confusion in the source program listing. ® Forgetting in the that ) in numeric Forgetting and the that a literals option paragraph library it is to appear in that ends the COPY becomes syntactically source program. 1library file, either because of misspellings. REPLACING descriptions, matches file text that is merged with the (such replace or as because 02, 77, multiple ...) 1level-numbers, section names, when they file. period must appear in the the source program; the statement is replaced by USING THE library used picture file find if terminator period library text. LIBRARY FACILITY 12-7 CHAPTER 13 OPTIMIZATION Optimization is the process of designing or altering minimize space allocation or execution time, or effective trade-off between the two. a to program achieve to an This chapter provides guidelines for optimizing performance of COBOL programs. It emphasizes techniques, controllable at the COBOL source level, for optimizing file design, program organization, and computation. Many COBOL programs make heavy use of file 1I/0. Consequently, your methods of designing, populating, and handling files can either enhance or undermine system performance. When optimizing COBOL programs, aim to minimize I/0 activity. You can accomplish this . by the way you design files and structure your program. Your answers to the following questions should influence your choice of file organization, record type, buffer size and number, and your program organization: l. What kinds of I/0 operations are necessary to process the data? 2. How can you best place I/0 3. How should you structure necessary or desirable? 4. For each file, are frequent likely, or will file absolutely) stable? operations the file? record contents in the program? Are multiple updates remain You can also influence computational performance, formatting data to avoid data <conversions and specialized computational routines of the compiler. The following sections describe each of these For more information on optimization techniques you can use through Record Management Services (RMS) facilities, refer to appropriate RMS documentation. Kkeys and 1insertions relatively (or especially by utilize fast, optimization NOTE access techniques. 13.1 OPTIMIZING FILE DESIGN This section describes the effect of file design on performance. following suggestions apply to any type of file organization. 1. 2. Preallocate the entire file, contiguously if possible, the /CO:n or DEFINE utility. Select /AL:n file switch (see Table 6-2) or The wusing the RMS file, a suitable default extend quantity when you create the using the /EX:n file switch or the RMS DEFINE utility. (Refer extend to RMS documentation for a quantities and the RMS DEFINE description utility.) of default 3. Know the relationships between record size and file storage, and try to define a record size suited for efficient storage and retrieval. 4., Use the SAME RECORD AREA clause to save compute time and conserve address space. If records are being copied from one file to another, and both files share the same record area, no MOVE statement is needed to move record images between two record areas. The disadvantage is that records from both files cannot be available simultaneously unless one is moved to a work area. (Be careful not to confuse the SAME RECORD AREA and SAME AREA clauses; they appear similar, but have different effects.) 13.1.1 Sequential Sequential files for definition, of disk accesses Files have the simplest structure and the fewest options population, and handling. You can reduce the number by keeping record length to a minimum. With a sequential disk file, you can use the multi-block read and write facility to create a larger buffer area. To use this facility, specify the BLOCK CONTAINS n CHARACTERS <clause 1in combination with ORGANIZATION IS SEQUENTIAL. If you omit the BLOCK CONTAINS n CHARACTERS clause, the RMS default applies. 13.1.2 For Relative relative l. 13-2 Files files: Select a record space remaining OPTIMIZATION format and size that minimizes the empty in each record position and each bucket. 2. If you create select a the file realistic by wusing maximum the record RMS DEFINE number. utility, An attempt to insert a record with a number higher than the maximum will fail. Before inserting such a record, you must redefine and repopulate the file. 3. Be aware that, before writing a record into a relative file, RMS must have formatted all buckets up to and including the bucket into which the record 1insertion will occur. Thus, write operations have variable response times, depending on whether preliminary formatting is required, and how much. You might consider writing the highest-numbered record first to force formatting of the entire file only once. 13.1.3 Indexed Files Indexed files have the greatest potential for inefficient wusage. Therefore, carefully consider how well the design and use of the files map into the application. To do this, you must first understand how indexed files are organized and processed. As the name suggests, an indexed file contains, pointer information to facilitate access to the besides data records. records, All data records and record pointers are maintained in storage units called buckets. The bucket 1is the basic retrievable element of an indexed file. It consists of an integral number of contiguous 512-byte physical blocks, and the number of physical blocks is known as the bucket size. Every indexed file must have a primary key: a field 1in the record description that contains a unique value for each individual record. When RMS writes records into the indexed file, it arranges them in collated sequence, according to increasing primary key value, in a series of chained buckets. Thus, you <can access the records sequentially, if you wish, by specifying ACCESS SEQUENTIAL. As RMS writes the records, it constructs and maintains a tree-like structure of key-value and location pointers. (See Figure 13-1.) Each element of the index structure 1s a bucket, and the buckets are structured into a hierarchy of levels. The highest level of the index consists of a single bucket, called the root bucket. The root bucket contains location pointers to buckets at the next lower level. Thus, RMS scans one bucket at each level of the index for a pointer to a bucket at the next 1level, until it reaches the bottom level of the index; the bottom level is called the data level. 1In a primary Kkey index, this 1level contains the actual data records of the indexed file. The buckets in each level above the data level are called index buckets. OPTIMIZATION 13-3 13AT 0 13AITL 2anbtgT-€IXTOAST-9a<YlAxeuwta-gAayXopul————-A7 N\ X% \ N\ 13-4 OPTIMIZATION RMS also constructs an index for the contained file. Like in the file. the for each alternate key primary However, index, key you define indexes are alternate key indexes do not actual data records at the data level; to data records that alternate instead, contain they contain pointers in the data level of the primary index. successive levels of an index are numbered. The data 1level of the index 1is level zero, and the number of levels above level zero is the index depth. Thus, the level number of the root bucket equals the depth of the index. Each random access request begins by comparing a against the entries in the root bucket, specific key value seeking the first entry in the root bucket whose key value equals or exceeds the value of the access request Kkey. (This search 1is always successful, because the root bucket's highest key value is the highest possible value that the key field can contain.) Having located the proper key value, RMS uses the bucket pointer associated with that value to bring the target bucket on the next 1lower level into memory. This process is repeated for each level of the index. RMS thus searches one bucket at each 1level of the index until it reaches a target bucket at the data level. At this point, the desired data record 1location 1is determined; an existing data record can be retrieved or deleted, or a new record written. Duplicate primary key values are not allowed; if a record insertion would cause a duplicate primary key value, the attempted write causes an exception condition. There may be insufficient room in a data level bucket to accommodate a new record. When this occurs, RMS inserts a new bucket in the chain, moving enough records from the old bucket to preserve the key value sequence, known as while a bucket making room to write the new record. split. This action is In summary, each index of an indexed file provides the mechanism for random access to records. Sequential access to records is also possible, because the records of the primary index, or pointers of an alternate index, are collated in ascending key value order. 13.1.3.1 General Rules for following general rules for 1Indexed Files - You can apply the indexed files at the COBOL source code level. l. While alternate keys are often wuseful, define for an indexed file, the longer the more each WRITE , keys you REWRITE, or DELETE operation takes. However, multiple keys have little effect on READ timing and provide multiple access paths. Thus, they are most useful for files that are not subject to frequent additions and updates and are accessed in many different programs. 2. Select bucket sizes that reflect and provide a suitable depth Section 13.1.3.3, Index Depth.) anticipated of index file activity structure. (See OPTIMIZATION 13-5 3. Avoid allow excessive duplication duplicates on the alternate keys. The following subsections design and creation. deal with 13.1.3.2 Bucket Size - Bucket file performance markedly. size To RMS, bucket blocks, 512-byte bucket, size is expressed each 512 bytes 1long. bucket, while a bucket and so on. of key values. COBOL does not primary key, but permits them on the specifics selection as an Thus, size of <can indexed influence integral number a bucket size of of 2 specifies of 1 file indexed physical specifies a a 1024-byte The COBOL compiler passes bucket size values to RMS based on what you specify in the BLOCK CONTAINS clause. There, you indicate bucket size in terms of records or characters, not physical blocks. As a COBOL user concerned with file optimization, vyou should be aware of the mechanism by which COBOL record and file descriptions are used to derive bucket sizes, file description. so that you can predict how RMS If you express block size in records, the bucket contain more records than you specify, but never assume call that for BLOCK records Thus, file bucket CONTAINS This might bucket your each seem of 100 overhead to five a bucket each. each as However, bucket for a control bucket Record Overhead 7 9 bytes bytes per per record record size is Overhead Record Size + bytes 7 is Total Record Total Block bucket 100 and you of Space adds containing five as RMS record and follows: (fixed-length) (variable-length) calculated bytes Record each some cases For example, records, block purposes, per Bucket your follows: compiler bytes example, as 512-byte the 15 the 1in fewer. 100-byte records, Overhead in can treat RECORDS to define bytes as follows: 15 bytes 535 bytes 550 bytes Overhead 5 records is (100 specified Because 13-6 5 fixed-length contain Bucket for some (the contains to will by + user 7)*5, or physical blocks are 512 bytes long, and buckets are always integral number of physical blocks, the smallest buffer possible RMS default) in this case is two physical blocks (1024 bytes). OPTIMIZATION RMS, however, is not keyed to the BLOCK CONTAINS clause which from this bucket specification was derived, and puts as many records as will fit into each bucket. The bucket actually will contain nine records, not five. The CHARACTERS option of the BLOCK CONTAINS clause For example: specify bucket size more directly. BLOCK CONTAINS 2048 allows you to CHARACTERS This calls for a bucket size of four 512-byte physical blocks. The number of characters in a bucket is always a multiple of 512. 1If you specify a value that is not a multiple of 512, RMS rounds next higher multiple of it to the 512. 13.1.3.3 1Index Depth - The size of data records, key fields, and buckets in the file determines the depth of the index. 1Index depth, in turn, determines the number of disk accesses required to retrieve a particular record. In general, performance is best with an index depth of 3 or 4. A shallower index will require fewer accesses, but will reduce available address space because of the larger buffers required. 13.1.3.4 Overhead Accumulation - In selecting a bucket size, you should consider the 1likely frequency of random insert and delete operations. When a record is inserted, there must be sufficient room in the bucket Bucket splits can Otherwise, a bucket split occurs. it. contain to cause accumulation of storage overhead, thereby reducing usable space. The new bucket contains records moved from the original bucket (see record each For record. new Section 13.1.3) to make room for the bucket, a seven-byte pointer to the new original the of out moved location for that record remains in the original bucket. Thus, a bucket could accumulate overhead from bucket splits, possibly reducing usable space so much that it can no longer receive record insertions. most Under overhead. storage Record deletions also can accumulate the space that was occupied by the of most however, circumstances, orlglnal record Dbecomes available for reuse. Because duplicate primary keys are not allowed, RMS can reclaim all but two bytes of the deleted record space. This two-byte field is a flag indicating that a record has been There are record additions deleted. several ways to deal with the problem of overhead accumulation. First, determine or estimate the frequency of certain operations. If, for example, you expect only 100 records of a 100,000 record file to be added or deleted in an average month, your data base is stable enough that you might decide to allow some wasted space from and deletions. OPTIMIZATION 13-7 However, if following: l. you expect frequent Choose a bucket if possible. multiple 2. To of optimize space record record optimization), (using number and deletions, size that allows for overhead Avoid bucket sizes that are an your for additions try the accumulation, exact or near size. insertion first performance define the file (as with opposed a fill to number the RMS DEFINE utility or a MACRO program). A fill specifies the number of bytes in the buckets of the file that you want to contain record information when the file 1is populated. Then, populate the file, specifying the /LO switch (see Table 6-2 or RMS utilities documentation). Thereafter, the unused space 1is available for record insertions, with minimum bucket splitting. Make certain that programs /LO 13.2 performing such record insertions do not specify the switch. OPTIMIZING PROGRAM ORGANIZATION Program organization section suggests can influence 1I/0 performance greatly. This guidelines toward an efficient pregram structure. 13.2.1 Sequential Reading of Indexed Files If you access an indexed file sequentially, and the file is write-shared (using the /SH switch), performance improves if you use OPEN I-O instead of OPEN INPUT. Using OPEN I-O implies a possibility that you will write to the file--even though you have no intention of doing so. Reading from a file that is open for input-output improves performance by locking the bucket, allowing you to obtain subsequent records from the same bucket without rereading it. 13.2.2 Caching Index Roots RMS requires at least two buffer 1is large enough program RMS to does set not the contain including a RESERVE n file, you can <create processing of an indexed roots access of of any one record operation. 13-8 a RESERVE n AREAS indexed bucket. clause, the default. By the buffers to process an to contain a single OPTIMIZATION or file. If your compiler Each COBOL allows AREAS clause in the SELECT statement for a additional (but not fewer) buffers for the file. At run time, RMS will retain (cache) more indexes of the file in memory. The random through that index will then require | one less I/0 The following rules l. The 2. Allocate apply for file must not be caching shared index at run roots: time. one buffer for each key that your program uses to access file records, in addition to the two required buffers. For example, if the file contains a primary key and two alternate keys, and you use all of these keys to access records, allocate a total of five buffers. If you use only one key to access this file in a program, you need only one additional buffer area, or three in all. 3. Use the RESERVE n AREAS clause to obtain this allocation, where n is two more than the number of distinct keys used for access. For example, the clause RESERVE 5 AREAS causes allocation of the two required buffers, plus three buffer areas for caching the roots of three distinct file access keys. 13.2.3 Multi-block Reading and Writing The multi-block read and write facility applies only to sequential files on disk devices. It allows reading or writing of more than one 512-byte block at a time during a single I/0 operation, reducing the number of I/0 operations needed to process a file. However, the single buffer used to process the file must be correspondingly longer. To use this facility, be sure the file has SEQUENTIAL organization resides on disk. Then, in the FD entry for the file, specify: and BLOCK CONTAINS n CHARACTERS where n is a multiple of 512. Each multiple represents the number of physical blocks to be read or written during each access of the file. If n is not a multiple of 512, the compiler rounds the size to the next multiple 13.3 On of 512. OPTIMIZING COMPUTATION arithmetic movement (ADD, (MOVE) specialized code SUBTRACT, operations, MULTIPLY, the DIVIDE, and COMPUTE) compiler generates more and data efficient, if: 1. The data items involved in the computation (including receiving fields) have the same type and scaling. 2. You omit 3. LINKAGE SECTION data is not involved the ROUNDED and SIZE the ERROR phrases. in the computation. Also, in the case of COMPUTATIONAL data, the data items must be same size. Otherwise, the compiler uses slower, generalized code. OPTIMIZATION the 13-9 Certain data types allow faster computation than others. types, in order of most efficient to least efficient, are: The data Signed COMPUTATIONAL Unsigned COMPUTATIONAL COMPUTATIONAL-3 DISPLAY COMPUTATIONAL data items can be one, two, or four words 1long (see Chapter 4). To increase the efficiency of the generated code, define COMPUTATIONAL items with the same size; if necessary, make some items larger than you otherwise would. COMPUTATIONAL data items can have different PICTURE specifications and still be the same size. Items with PIC 9(1) to 9(4) are 1l-word binary; with PIC 9(5) to 9(9), 2-word binary; and with PIC 9(10) to 9(18), 4-word binary. On COMPUTATIONAL-3 (packed decimal) or DISPLAY data, operations are most efficient when performed on data items of minimal size. Different data size does not force the use of generalized code with these data types. The following situations also force opposed to more efficient code: l. Non-matching decimal receiving fields. 2. Use 3. Data of the ROUNDED or items defined point SIZE in the use of alignment generalized among the code, operands as and ERROR options. the LINKAGE SECTION of the source program. Generalized code is their addresses are necessary on not known at LINKAGE compile SECTION data time. items, because The following example illustrates the difference 1in execution between specialized ADD code and the generalized ADD code. 01 01 01 01 Of 30 A B C E PIC PIC PIC PIC time S9(4) USAGE COMP. S9(4) USAGE COMP. S9(4) USAGE COMP. S9(4)V9 USAGE COMP. the following two ADD statements, statement to 40 times faster than statement (2): (1) ADD A B GIVING C. (2) ADD A B GIVING E. (1) typically executes On MULTIPLY and DIVIDE operations, decimal point alignment has a different meaning than for ADD and SUBTRACT operations. Assuming that the data types are the same for all items involved, the compiler uses the more efficient code if: 13-10 OPTIMIZATION l. On of a MULTIPLY, the product field scale factor equals the the scale factors of the multiplicand and multiplier. example: 01 01 01 X Y Z PIC PIC PIC MULTIPLY 2. On a DIVIDE dividend example, example: S9(4)V9(2) S9(4)V9(3) S9(6)V9(5) USAGE USAGE USAGE X Z. GIVING operation, scale using DIVIDE Y Z BY the sum For COMP. COMP. COMP. quotient scale factor equals the factor minus the divisor scale factor. For the data descriptions from the previous X GIVING Y. When defining data to be used as subscripts, l-word signed COMPUTATIONAL 1is the most efficient. Try to avoid referencing tables by indexes unless you need to perform relative index references. The It use of arithmetic expressions increases use of temporary storage. also generates 1larger operands, and can cause the less-efficient generalized code to be used verb, and avoid using relational conditions. unnecessarily. Avoid wusing the COMPUTE arithmetic expressions when specifying OPTIMIZATION 13-11 APPENDIX A THE COBOL NOTATION USED IN FORMATS Underlined upper-case words Upper-case words Lower-case words Brackets COBOL FORMAT [] (key words) = required words; (not underlined) - optional words; = must be generic terms, supplied by the user; - enclosed portion is optional; if several enclosed words only one of them may be used; vertically stacked, are Braces {} - a selection must be made from the vertical stack of enclosed words; Ellipsis ... = the position at which repetition may occur; Comma and semicolon Period NOTE Shaded optional punctuation; required where items shown represent PDP-11 in the formats. COBOL extensions to the ANS-74 list of COBOL formats. IDENTIFICATION PROGRAM-ID, [AUTHOR. DIVISION, program=-name., [comment-entry]e..] [INSTALLATION. [comment-entryl...] [DATE-WRITTEN. [comment-entryl..e.] [DATE-COMPILED. [comment-entryl...] [SECURITY. [comment-entryl...] ENVIRONMENT DIVISION, CONFIGURATION SECTION, SOURCE-COMPUTER. VAX-11. = WORDS OBJECT-COMPUTER. VAX-11 MEMORY SIZE integer CHARACTERS MODULES [PROGRAM COLLATING SEQUENCE _] IS alphabet-name] [SEGMENT-LIMIT IS segment-number]. [SPECIAL-NAMES, [CARD-READER ISmnemonic-name=1] [CONSOLE ISmnemonic-name-2] [LINE-PRINTER ISmnemonic-name-3] [PAPER-TAPE-PUNCH ISmnemonic-name-4] [PAPER—TAPE-READER.Eg_mnemonic-name-S] [ SWITCH integer-1 i ON STATUS IScondition-name-1 [OFF STATUS E§_condition-name-2] OFF STATUS [ON STATUS IScondition-name=-1] NATIVE LAlphabet-name IS IS condition-name-2 {STANDARD-I’ [CURRENCY SIGN ISliteral-l] [DECIMAL-POINT ISCOMMA ].] [INPUT-OUTPUT SECTION, FILE-CONTROL. {file-control-entry}... Format 1l: SELECT [OPTIONAL] file-name ASSIGN TO literal-l [} RESERVE integer-1 . [; [AREA%]] AREA ORGANIZATION IS SEQUENTIAL] IS SEQUENTIAL] [; ACCESS MODE' [; Format FILE STATUS IS data-name-1l] . 2: SELECT file-name ASSIGN TO literal-l [, RESERVE integer-1 . ; ORGANIZATION IS [AREA%]] AREA RELATIVE - SEQUENTIAL ; ACCESS MODE IS RANDOM A-2 FILE STATUS THE IS data-name-2] COBOL FORMATS RELATIVE KEY IS data-name-l] RELATIVE KEY IS data-name-l L DYNAMIC [; [, . ] Format 3: SELECT file-name ASSIGN TO literal-l [. S integer-1 . ; RESERVE 3 ORGANIZATION ; ACCESS MODE [AREASJ] AREA - IS INDEXED SEQUENTIAL IS RANDOM DYNAMIC h— ; RECORD KEY IS data-name-l [; ALTERNATE RECORD KEY IS data-name-=2 [; FILE STATUS IS data-name-3] [WITH DUPLICATES] ] eee . | [I-O-CONTROL. [SAME [RECORD] AREA FOR file-name-1 {file-name-2}...}... [MULTIPLE FILE TAPE CONTAINS [file-name=4 [APPLY file-name-3 [POSITION integer-1] [POSITION integer=2]..e]ee. PRINT-CONTROL ON file-name-5 [file-name-6]...] ...]J DATA DIVISION., [FILE SECTION, [gg.file—name . . BLOCK CONTAINS [integer-1 -1 TO] T -2 integer CHARACTERS] [RECORD CONTAINS CHARACTERS] [integer-3 29} integer-4 LABEL ‘RECORDS ARE {OMITTED waLe oF 1p 15 | $3erenet ] RECORD [ F .PATA B ID I IS STANDARD data-name-1 . RECORD IS {RECORDS ARE LINAGE IS LINES AT TOP [CODE-SET data=-name-3 data-name-3| integer-5 — RECORDS . \pq l] { data-name=7 integer=7 [data=name=4] .cee | coe WITH FOOTING AT [LINES AT BOTTOM |data-name=6 integer-6 [data-name-B}] integer-8 IS alphabet=-name]. [record-description-entry]leeeleee] [WORKING~STORAGE SECTION. [77-level-description-entry] record-description-entry O‘.] THE COBOL FORMATS A-3 [LINKAGE SECTION., [77-level-description-entry] record-description—~entry ceol Data description entry: Format 1: level=number {data—name-l’ FILLER [REDEFINES data=-name-2] L{EiE?URE} IS character-string] COMPUTATIONAL COMP IONAL- i | [USAGE ISl§ COMP-3 DISPLAY § DISPLAY-6 DISPLAY=-7 INDEX ] N - j {SYNCHRONIZED’ _|SYNC _{JUST JUSTIFIED [SEPARATE CHARACTER] LEADING } TRAILING I [§£§§_IS] [LEFT ) RIGHT‘:] RIGHT | l [BLANK WHEN ZERO] [VALUE IS literal] integer-1 TO integer-2 TIMES DEPENDING ON data-name=-3 . OCCURS —_— integer-2 [{DESCENDING} ASCENDING - TIMES KEY IS data-name-4 [index-name=2] ...]] . [INDEXED BY index-name-1 Format [data—name-S]...] eoe 2: 66 data-name-1 RENAMES data-name-2 THROUGH THRU Format data-name-3|, 3: 88 condition-name [ iteral-3 { VALUE VALUES ISARE -— [{THRU PROCEDURE DIVISION [USING A-4 COBOL FORMATS l . THE THROUGH } : literal-1 [{ THRU THROUGH } literal-2] literal 4]] oo R 3 -— [data—-name-1] [,data=name-2] ooo]o Format 1: [DECLARATIVES. {section-name SECTION [segment-number] . declarative-sentence [paragraph-name. [sentenceleeelecelte.. END DECLARATIVES. ] {section-name SECTION [segment=-number]. [paragraph-name. [sentenceleeceleeeteee Format 2: {paragraph-name. [sentence]...}... STATEMENTS ACCEPT identifier [FROM mnemonic-name] DATE DAY ACCEPT identifier FROM TIME ADD Iig:g;;fiir-l, [i?igi;iizr-z] coe Eg.identifier-m [ROUNDED] [identifier-n[ROUNDED]]... [ON SIZE ERROR imperative-statement] ADD ‘identifier-l} — {identifier-Z} literal-l literal=-2 GIVING identifier-m [ROUNDED] [identifier-B] . literal-3 [identifier-n [ROUNDED]] ... [ON SIZE ERROR imperative-statement] CORRESPONDING ADD CORR identifier-1 zg.identifier-Z [ ROUNDED] [ON SIZE ERROR imperative-statement] ALTER procedure-name-l TO [PROCEED TO] procedure-name=-2 [procedure-name~-3 TO [PROCEED TO] procedure-name=-4].se CALL literal [BY REFERENCE ] BY VALUE USING BY BY [identifier-2] ... REFERENCE BY VALUE BY identifier-1 DESCRIPTOR identifier-3 [identifier-4] . ... coo DESCRIPTOR [GIVING identifier-5] - {REEL} . UNIT | -nameCLOSE file-name-1l N - 4 - [WITH gg_REWIND] [FOR REMOVAL , — NO REWIND LOCK — file-name-2 - [WITH gg_REWIND] UNIT | | FOR REMOVAL - L = REEL} NO REWIND LOCK — THE COBOL FORMATS XX J| A-5 COMPUTE identifier-1 [ROUNDED] = arithmetic-expression DELETE [identifier-2 file-name RECORD DISPLAY {literal-l } [11teral-2 ] DIVIDE identifier-2 [WITH NO ADVANCING] lldentlfler-l} . INTO literal-1l —_— identifier-1 ‘1iteral-l } . *e* identifier-2 [identifier—3[ROUNDED]] «ee DIVIDE ... [INVALID KEY 1mperat1ve-statement] identifier-1 [UPON mnemonic-name] [ROUNDED]] [ON SIZE ERROR imperative-statement] INTO [ [ROUNDED ] [ON SIZE ERROR imperative-statement] identifier-2 [11teral-2 } GIVING identifier-3[ROUNDED] : : i Fier— [identifier-4 [ROUNDED]]...[ON SIZE ERROR imperative-statement] DIVIDE identifier-l {literal-l } BY identifier-2 {literal-2 } ) . GIVING identifier-3[ROUNDED] [identifier-4 [ROUNDED]]...[ON SIZE ERROR imperative-statement] DIVIDE identifier-1 {literal-l ’ INTO identifier-2 {literal-Z } . L GIVING identifier-3[ROUNDED] REMAINDER identifier-4[ON SIZE ERROR imperative-statement] pIvIpE | rdentifier-l literal-1l BY —— identitier-2 literal-2 — GIVING identifier-3[ROUNDED] — REMAINDER identifier-4[ON SIZE ERROR imperative-statement] EXIT [PROGRAM] GO TO [procedure-name-1l] GO TO procedure-name-1l statement-1 IF condition INSPECT [procedure-name-2]...procedure-name-n DEPENDING ON identifier INEXT SENTENCE identifier-1 ELSE NEXT SENTENCE ALL LEADING lLEADING} ]. {literal-4 ’ . . lléentlfler-SI FTEEE—— literal-3 identifier-1 [=AFTER } BEFORE ) FOR Y - ‘literal-S } 1§ent1f1er-6, BEFORE — literal-4 AFTER ALL identifier-6 identifier=-5 — A-6 THE COBOL INITIAL . . e 1§ent1f1er-7 o literal=5 ldentifier-3 literal-1 BEFORE —— AFTER . [{AFTER 1 BEFORE —— INITIAL FORMATS identifier-6 | INITIAL identifier-4 ] literal-2 ‘literal-S ,] ceo e identifier-7 { {;—?—2%} “ literal-3 l B ‘literal-tl } [ AFTER — itera identifier-7 BY LEADING CTERS BY ‘literal-4 } CHARACTE . INITIAL e TALLYING CHARACTERS REPLACING . === ALL identifier-2 :ié:ntlflgr'4’] ... identifier-3 CHARACTERS identifier-6 ) {literal-l } [{igggiE} INITIAL ALL REPLACING CHARACTER® BY INSPECT [ELSE statement-2 identifier-1 TALLYING identifier-2 FOR INSPECT l BEFORE INITIAL {literal-S }:“ °° '} . . identifier-7 movg | identifier=ll literal . .. tifier-2 [identifier-3] ... —_— TO identifier-2 identifier-1 — NG} MOVE | CORRESPONDI Corr =— BY identifier-2 [ROUNDED] |identifier-l literal-l MuLTIPLY —_— [identifier-3 [ROUNDED]] ... identifier-1 [ON SIZE ERROR imperative-statement] . . identifier-2 ... [ON SIZE ERROR imperative-statement] EX. {literal-l MULTIPLY [identifier-4 [ROUNDED]] GIVING identifier-3 [ROUNDED] {literal-Z INPUT file-name=1l[WITH §9_REWIND] [file=-name=2 [WITH gg_REWIND]]... OUTPUT file-name-3[WITH NO REWIND] [file-name-4 [WITH NO REWIND]]... OPEN coe I-0 file-name=5 [file-name-6]... EXTEND file-name-7 [file-name-8]... PERFORM procedure-name-l lgfifigucfl} procedure-name-Zj PERFORM procedure-name-1l {igggUGH} procedure-name-Z: ‘igig;iifir-l PERFORM procedure-name-1 {gggSUGH} procedure-name-z: UNTIL condition-1 PERFORM procedure-name-1 {$g§3UGH} procedure-name-2q VARYING BY AFTER BY - [AFTER | ! FROM — a identifier-2 index-name-1l fr1 entlfler 4 | d FROM 1ndex-name- | literal-1l identifier-6 b | identifier-3 . index-name=2 . [ [ UNTIL condition-1 - {1dent1f1er-7 literal-4 TIMES —— } index-name-4 . literal=-3 UNTIL condition-=2 identifier-9 identifier-8 index-name=5 FROM , index-name-6 \ 1dent1f1er-10} UNTIL condition-%] ) literal=5 literal=-6 [AT END imperative-statement] READ file-name [NEXT]RECORD[INTO identifier] READ file-name RECORD[INTO 1dent1f1er] [INVALID KEY imperative-statement] READ file-name RECORD[INTO identifier] [;KEY IS data-name] [;INVALID KEY imperative-statement] REWRITE record-name [FROM 1dent1f1er][INVALID KEY imperative-statement] J - THE COBOL FORMATS A-7 SEARCH identifier-1 identifier-2 ‘.index-name=-1 ,J VARYING — —_— [AT END imperative-statement-1] ‘imperative-statement-2 WHEN condition-1 NEXT [WHEN conditione2 SENTENCE ‘1mperat1ve-statement-3]] L NEXT SENTENCE SEARCH ALL identifier-1[AT END imperative-statement-1] data-name-1 WHEN o — identifier-3 IS E IIS ;225& T O} . literal-1l arithmetic-expression-~1 condition-name-1 F identifier-4 data-name-~2 AND - 7 [IS EQHAE-TO] {literal-Z IS = . . . arithmetic-expression-2 condition-name=-2 cee imperative-statement-2 NEXT SENTENCE . SET . [identifier-2]... index-name-1l [index-name-2]... ] — . identifier-1 SET index-name-4 = . TO r index-name-3 e . integer-1 [index-name-5]... B EE-EXDOWN BY } {1dent1f1er-4} integer-2 IS EQUAL TO IS START file-name identifier-3 . KEY = ig SREATE RT HAN IS NOT LESS data-name THAN | IS NOT < — [INVALID KEY 1mperat1ve-statement] STOP literal} RUN . . e . sTRING | rdentifier-l — literal-l B identifier-4 literal-4 INTO identifier-7 . — (lgentlfler 2| | literal=-2 ... (lqentlfler'sj ... | literal~5 identifier-3 DELIMITED BY {literal-3 SIZE identifier-6 DELIMITED BY {literal-6 ces SIZE [WITH POINTER identifier-8] [ON OVERFLOW imperative-statement] SUBTRACT {literal-l identifier-1 } [literal-Z identifier=2 coe FROM identifier-m[ROUNDED] —_— . [identifier-n [ROUNDED]}]...[ON SIZE ERROR imperative-statement] A-8 THE COBOL FORMATS . o SUBTRACT [1dent1f1er-2] ‘1dent;f1er—l} .. FROM literal=2 literal-1l { identifier-m} literal-m GIVING identifier-n[ROUNDED] [identifier=o[ROUNDED]]... [ON SIZE ERROR imperative-statement] SUBTRACT RRESP S ONDING} {ggRR . . . . o [ROUNDED] FROM identifier-2 identifier-1 [ON SIZE ERROR imperative-statement] UNSTRING identifier-1 [DELIMITED BY [ALL] ‘lden . . r - 2} . tlfle literal-l {1den . t1.f.ier- 3}] o 0o ] [95 [ALL] literal=-2 INTO identifier-4 [DELIMITER IN identifier-5] [COUNT IN identifier-6] [identifier-7 [DELIMITER IN identifier-8] [COUNT IN identifier-9]]... [WITH POINTER identifier-10] [TALLYING IN identifier-11] [ON OVERFLOW imperative-statement] file-name-1l[file-name=2]... | PROCEDURE ON EXCEPTION ERROR USE AFTER STANDARD _—— — INPUT OUTPUT —_— I-0 EXTEND WRITE record-name [FROM identifier-1] BEFORE ADVANCING [XEEEE_} identifier-2 } [ LINE ]} T {{.integer LINES [PAGE] - ar } | END-OF~-PAGE EOP WRITE record-name COFX imperative-statement] [FROM identifier] lliteral-B} [INVALID KEY imperative-statement] text-name REPLACING ‘llteral-l word=1 NOTE: BY literal=2 —_— word=2 . A COPY statement may appear anywhere that a word appears in the COBOL source program, THE COBOL FORMATS A-9 APPENDIX COMPILER This appendix describes B IMPLEMENTATION the LIMITATIONS implementation limitations for the VAX-11 COBOL-74 compiler system (compiler and RTS). You should not confuse the term "limitation" with "restriction". A restriction is a language facility that 1is not implemented or should not be used due to known errors in its implementation. An implementation limitation quantifies the limits of a language facility that is supported by the system. Practical implementation limitations exist in result from the finite size of compiler structure representations, and so on. Since every compiler; tables, compiler the VAX-11 They data COBOL-74 compiler employs a Virtual Memory System to support many compiler data structures, the quantities specified for some implementation limitations are approximations. However, as a deneral rule, the following guidelines should not be exceeded COBOL in the development of a program. IMPLEMENTATION 1. The Data Division of a COBOL program cannot be 1larger 65K bytes. A file description entry cannot be larger 32K 2. LIMITATIONS than than bytes. A DISPLAY statement cannot contain more than 16 sending operands. 3. The maximum program 4, is number of approximately data-name definitions The maximum number of procedure-name definitions program is approximately 1in a COBOL in a COBOL 2000. 2000. 5. Because file description level-numbers can range from 01 to 49, 1level 88 condition-names can have no more than 50 qualifiers (FD through 49). Data-names declared in the File Section can have no more than 49 qualifiers (FD through 48). Data-names declared in the Working-Storage and Linkage Sections can have no more than 48 qualifers (01 - 48). 6. A GO TO operands. DEPENDING statement can have no more than 16 APPENDIX SOURCE PROGRAM C LISTINGS This appendix contains compiler listings first, STATB, calls three subprograms; the subprograms. The examples demonstrate some of the for the two COBOL programs. The second, DOCATS, is one of features of VAX-11 COBOL-74, such as: o The COPY statement °® The COPY REPLACING statement o The CALL ° The statement results qualifiers of The circled numbers on annotated in the text. clejicle Source - Listing The version and the the source /MAP and listings /VERB LOCATION indicate features compiler that are Features The source number. Date using of the file, time VAX-11 including when the COBOL-74 file compiler. type, compilation or extension, and version began. - The compiler command line. The contents of the command line can help to explain why the listing looks like it does and how the program runs. For example, this command 1line shows that the /VERB_LOCATION and /MAP qualifiers were used. O The IDENTification number assigned by the compiler. This number identifies the specific compilation of the program and is used as an additional identifier for the object module. ® Source line number assigned by the compiler. This number is used in RTS error message displays to indicate the location at which the error was detected. It also appears in error message @ displays that show nested Sequence number. If the source file wused conventional format (/ANSI_FORMAT), the sequence field (positions 1-6) appears here. Source text. This area contains the text that was processed by the compiler. 1If a line of text was too long, only the part that appears here was processed. The compiler also prints a © diagnostic message when Identification field. format, this area © 60 (positions it truncates a line of source text. If the source file used conventional would contain the identification field 73-80). Identifies a source line that: a) b) was copied from a library file. contains a COPY statement, or COBOL verb Identifies (appears only when /VERB LOCATION qualifier is used). the COBOL verb that 1is referred to by the other entries the on Segment number line. (/VERB_LOCATION qualifier only). Identifies program segment, or PSECT. Notice that this name; 1t is a consecutive number assigned to during programs. compilation and duplicates the segment numbers in © PSECTS other the is not the PSECT all procedural Offset (/VERB_LOCATION qualifier only). Specifies the hexadecimal offset (distance) from the beginning of the segment for the object code generated by the COBOL verb (number 11). ® ® PERFORMs. Offset (/VERB_LOCATION qualifier only) . Specifies the hexadecimal offset in hexidecimal bytes from the beginning of the (STATB). O entry-point Compiler diagnostic severity code. Describes the seriousness of the compiler diagnostic. This diagnostic is "informational"”, which means that the compiler can take corrective action. 6 program Diagnostic source line number. Identifies the source 1line to which the diagnostic applies. In this case, OPTIONS-AREA is defined as larger than CUSTOMER-FILE-ID; therefore, truncation 60 occurs. Compiler diagnostic number. Use this number to find ® Appendix D. Diagnostic message. SOURCE Identifies the specific diagnostic. a description of the diagnostic in A one-line description of PROGRAM LISTINGS the condition. ® Data Map. Describes the This section program. data-names and appears only ©® used. Level. An L ® © 0 Linkage Name. Contains Section The line. source line or the on a data Data used in not the that Class. that or data-name refer Length. to is defined the clause or implicit following abbreviations COMPUTATIONAL-3 INDX INDEX that the the to the data-name was usage the are of used: COBOL class of the data item. The «class from the PICTURE or level associated The following abbreviations are used: Alphabetic Numeric AN Alphanumeric ANEDIT Alphanumeric NMEDIT Numeric level. I ndicates Edited Edited the number data-name. Specifies Map. the This Procedure-name. this the NUM used. the USAGE The CMP3 Name program. on offset of data items, descriptor indicates because Division. DISPLAY the asterisks descriptor COMPUTATIONAL Procedure Division. a DISP ALPHA to contains CMP determines data-name. Occurrence is Identifies the hexadecimal offset of the the beginning of data PSECT. For Linkage offset is from the 0Ol-level. Procedure 1Identifies compiler with the the of the item. data-name is a the Division. generate USAGE. Corresponds to data item description. in qualifier level-number indicates item. location did used /MAP Directory location. 1Identifies the hexadecimal data item's descriptor. For Linkage Section offse 'is t from the 0l-level. The RTS uses the not ® file-name the 1if data-name. Division location. file or data-name from Section data-names, the compiler ®® ©® or Data A directory ® level item. The in level-indicator the file-name Source operate ® the preceding file-names t he length of the of data subscripts item in necessary decimal bytes. Describes section Thi S 1s the the procedure-names that appear appears only if the /MAP qualifier name as it appears SOURCE in PROGRAM the in is Procedure LISTINGS C-3 O 06 Source line. procedure-name 000 OO if less than 11), Segment-number. for the section Section. An line in which the followed by a three-digit number. Paragraph. Corresponds to the segment-number A in the in which the procedure-name appears. "S" section-name. indicates "P" that indicates the that procedure-name the procedure-name header is a |is a paragraph-name. Segmentation Map. is section. used. Section Name. Procedure This map appears only when the /MAP qualifier Describes the segmentation for each The name of the Procedure Division. Segment-number. header, or the The implied section segment-number segment-number as it specified 00. appears 1in in section the the PSECT Name. Indicates the name of the procedural PSECT generated for the section. If the generated code exceeds the code segment limit, the compiler generates additional PSECTs; their names are displayed beneath the O®® source Offset. Specifies the hexadecimal offset (distance) of the location of the procedure-name from the beginning of the PSECT. Division first. The size of the procedural PSECT in hexadecimal bytes. The size of the procedural PSECT in decimal bytes. Compiler-Generated generated by the execution OO®® the PSECT. Identifies the name of the executable code PSECT (program section) in which the procedure-name appears. PSECT name consists of the first 11 characters of PROGRAM-ID (padded on the right by "$" ®0® Identifies is defined. PSECT PSECTs. compiler initialization. Describes the (/MAP qualifier) procedural PSECT's to provide run-time name. The size of the PSECT in hexadecimal bytes. The size of the PSECT in decimal bytes. Referenced RTS Routines. Lists the that qualifier) (/MAP routines RTS All code. compiler-generated C74$<name>. SOURCE PROGRAM LISTINGS names of all COBOL RTS the by referenced are form: the have routines 000G G Data PSECT compiler PSECT Map. Lists the (/MAP qualifier). nonexecutable PSECTs size of the PSECT in hexadecimal the The size of the PSECT in decimal External Subprogram subprograms (/MAP bytes. References. qualifier) bytes. Lists referenced the by Error Severity Chapter 10 Count. severity Code. describes The level. the number Describes severity of the codes compilation names CALL program. @0 by name. The Error generated seriousness and their errors SOURCE of statements of all in the errors. meanings. detected PROGRAM for LISTINGS each C-5 {2=Jane1979 0814A11S VAXe*3i COBOL=74 va.;;-ol S1ATSB IDENT: STATB:COBga 212P86 /NOANST,FORMAT /MAP /DEBUG=TRACERBACK /COPY LIST /VERB,_LOCATION IONG <:) JLISTaSTATR /NOCROSS _REFERENCE /WARNINGS /OBJECTESTATB ® IDENTIFICATION DIVISION, STATB, vogoe PROGRAM.ID. a0d03 AUTHOR, R INSTALLATION, DATE=wWRITTEN, DATE=COMPILED, 10 JANUARY 20804 0R8RAsS oe2As 2m0a7 20010 onroie 00213 Q0014 @215 The weot17 20218 20419 22020 vavel 20029 272030 40831 "R YA 20033 40834 30235 1 LR Y program demonstrates FUNCTION Generates the acfe Gemngrates Gemerates an exception My {1{ng ‘¢ redit report, labels, l1imic’ letters, , DIVISION, iflfifitttttfittttfitt'tttifitfitttitfiitfii"fifiitfifififitifi*fi.ttii'fi.fi CONFIGURATION SECTION, VAX={1l, SOURCE=COMPUTER, OBJECT=COMPUTER, VAXell, itttttt*tifittttttQt'fifiiittfififlttfltt.tfifitfififii'itifiifitfifi***..i SECTION, And37 INPUT=OUTPUT FILE-CONTROL, 2004e SELECT CUSTOMER=FILE ASSIGN TO "CUSTOM" ORGANIZATION IS INDEXED A0Ad} @4 34043 ACCESS ACRAUY MODE IS DYNAMIC RECORD KEY IS CUST=CUST=NUMBER ALTERNATE RECORD KEY 1S CUST=CUSTOMER=NAME FILE STATUS IS CUSTOMEReFILE=STATUS, 20245 JAV4b6 22947 APIU8 SELECT STATEMENT=REPORT ASSIGN TO "STATEM" 2AA49 22¥50 FILE STATUS 20¥S1 20353 orograms NAME {2=Jan=1979 ENVIRONMENT dvals A0039 J4eYse this RN R R AR AR AN AT ARR RN AN R RRARRN AR RN A AR R R AN A ARANARRARANARANY 20024 20228 called EXCEPT DOCATS CREOLM P16 Quaes P27 COMPANY, 1979, options and the content s of date records) program generates various outputs, oea1 ¢ades programs, ORDER the effects and sdvantages of modular progranm Depending on operator=specified develooment, JA029 vAvee 200823 called Using 20408 FRIED JONES M AIL 1S STATEMENT-REPORT=STATUS, '*iifitttitfiitfitfitttfifitttfittQ*i*flfii'fififit't.fifi'fitfififititifi'fiflfl aPAS Y 4048595 AmrASe 20087 DATA FILE N RN R A RN R R R AR AR R R AN AR AR AR AR Axyss 47959 NIVISION, AN AN RN RNARRAR AR AR AR ARAARA AN SECTION, veded a2vel FO 20A62 VALUE t-r'rl-r‘rc—r'rt-r'rc—r'rt—r—r‘E” dvd63 LR CUSTOMER=FILE LABEL RECORDS UF ID IS ARE STANDARD CUSTOMEReFILE=ID, Y] A246S COPY CUSTRC., vPA66 L' 1-X4 20068 Wi CUSTGMER-FILE=RECORD, aRrd69 23 272470 3 veaTy 2Rd72 ATy 23 3 PrATY 23 d¢aTsS ?3 d0e76 CUST=PHONE, 29 L) 29 vWear7 C-6 CUST=CUST=NUMBER CUST=CJSTOMEReNAME CUST=ANDRESS=LINE=] CUSTeADDRESS=_ INE=? CUST=ANDRESS=LINE=3 CUST=ADDRESS=21P=CODE A¢v78 CUST=PHONE=AREA=CODE CUST=PHONE=EXCHANGE CUST=PHONE=LAST=4 R CUST=PHONE=NUMBER Anpnay "3 Jd82 ¢3 CUSTeATTENTION=LINE CUSTeCREDIT=LIMIT IRA79 ANC8e SOURCE PROGRAM LISTINGS REDEFINES CUSTePHONE PIC PIC PIC PIC PIC PIC PIC X(6), X(30), X(39), X(30), X(302), X(S), X(3), PIC PIC X(3), 9¢4), PIC 9(19), PIC PIC X(20), 9(18) V99, rFrrrrrrere o oc 22083 20084 20¢8S 00386 e3 CUST=HEADER=DATA e3 s FILLER 85 NEXTeACCTeNUMBER CUSTeOWE=AMT e3 CUSTeBOUGHNT REDEFINES CUST=CREDIT=LIMIT, 00087 20088 20089 20490 23 008914 00092 20093 2Pa9s CUSTeNEXTaPAYMENTeSEQUENCE FO STATEMENT=REPORT ®1 LABEL RECORDS ARE STANDARD, STATEMENTeREPORTeRECORD, 20094 20096 83 20097 @3 20098 80099 FILLER ADDRESSewINDOW @3 @3 FILLER ADDRESS=21IP 00120 3 00101 A3 "L B YT 00103 00104 va10s 21 eaioe en1e7 e@ios8 ee1t 9(4), PIC PIC X(S), X(30), PIC PIC X(1), X(S), FILLER PIC X(2s), FILLER @5 PIC FORMeDATE X(6), PIC x(a), 3 FILLER PIC X(15), REPORTeCREDIT PIC 20222,222,229,99, REPORTeYTD PIC 2,222,222,229,99, PIC Xx(12), X(10), X(32), 2,222,222,229,99, FILLER PIC SeReRel, ©3 STATEMENT=DATE 83 FILLER @3 STATEMENT«CAPTION @3 STATEMENT=BALANCE AR AR RN AR R AR 20118 X(10), PIC PIC PIC gat1e gots7 9(18)v99, 9(4), PIC @3 @3 9] 9(18)v99, AS FORMaNAME, 0o110 velle 22113 en11d 80115 PIC SeReRe?, @3 eeie9 X(6), 9(6), PIC PIC CUSTeNEXTeORDER=SEQUENCE o3 PIC PIC AR AR AR AR AN AR R AR R AN I AN VAR AR AR R R RN TN AR R AR R ARy 00119 00120 WORKING=STORAGE eei21 Wl 01 CUSTOMEReFILE=STATUS STATEMENTeREPORT«STATUS 21 CUSTOMEReFILE=]ID VALUE "CUSTOM,DAT", PIC X(14) ©1 @3 TODAYS=DATE TDR REODEFINES TODAYS=DATE, 33 TODAYeYEAR PIC 9(6), B3 PIC TODAY*MQONTH 9(2), @3 TODAYeDAY PIC 9(2)., 0oiee oej23 eeied 80125 20126 o027 00128 eey29 o139 20131 22132 A1 SECTION, PIC PIC X(e), X(2), PIC 9(2), PIC 29, 201313 TODAYSeREPORT=DATE, @3 TODAYeMQONTH 83 FILLER ?3 TOOAY=DAY PIC PIC 9(2)., VALUE "/", 0013y 02135 0Ai3e 83 @3 FILLER TODAY=YEAR PIC PIC X(1) VALUE 9(2)., "/°», PIC X(S@) 20137 1 STANDARD=MESSAGE ¥y DISPeMESSAGE, 0138 00139 20140 @3 FILLER eeldy 83 DISPeNUM 20142 00143 @1 VYTOeCATALOG=MINIMUM @y EXCEPTIONeINDICATORS, oRldy 0@14sS 82146 A3 eesd7 eQ148 21 2149 ®3 21 204153 "1 0@154 ¥v1iss A1 OPTIONS=AREA=CHAR OPTION=STORAGE, OPTION=ENTRY @3 OPTIONeVALUES FILLER ee1sy 20158 3 FILLER 83 FILLER @3 FILLER 23 FILLER 3 FILLER 88 20159 88 00162 vo163 88 88 0Qled 00165 88 2ale6é6 gRleée? REDEFINES VALUE SPACES, 1o@ew, PIC (1), OCCURS 30 PIC X(1), OCCURS 8 VALUE wWANTeSOME=«CATALOGS VALUE | VALUE | VALUE | A1 STATEMENTeCOUNT INVOICE=COUNT CREDIT«LIMITeCOUNT PIC THRU 9(1)., 9(1). 9, THRU PIC THRU 9(1)., 9, 9(1), 9, PIC WANT=CREDIT=LIMIT=LETTERS PAri69 | PIC PIC nWANTeALL-CATALOGS RECORDe=COUNT 9(2)., OPTION=STORAGE, WANTeINVOQICES @1 At @1 9(1@) VALUE @ WANTeSTATEMENTS ve168 2M170 0217 PIC PIC 23 eele61 X(39) 2(S), SPACES, NCCURS A=COUNT 20156 00160 PIC PIC VALUE OPTIONS=AREA, 20150 20151 001Se EXCEPT!ION=INDICATOR X(1) THRI) 9(1), 9, PIC VALUE 1 9(1)., THRU 9, PIC PIC PIC VALUE o, 9(S) VALUE @, VaAlLUE e, PIC 9(S) PIC 9(S) SOURCE X(3), 9(S) VALUE PROGRAM o, LISTINGS C-7 ap173 PROCEQURE 40176 4177 AR ey 78 w0179 er18¢ : DISPLAY : (PR2VBV24) SREGIN, (22000024) DISPLAY "]=0 ERRQR ON CUSTOMEReFILE, CODE (" vA18S CUSTOMER=FILE=STATUS ") w186 pe1R7 peoviey H H CISPLAY H STOP 20188 82189 PR2daC (P@200064) 22191 eveeua (PAQ0R2060) s e AY0024 SECTION, USE AFTER STANDARD ERROR PROCEOUKRE ON STATEMENT=REPORT, SBEGIN, DISPLAY "Je0 ERROR ON STATEMFNTREPORT, 20193 STATEMENTeREPORT=STATUS "), 90194 @n19s SToP RUN, STATEM=ERROK 20192 ee ~ (A200PQd4Y) oA190 USE IR RAR AR USE AFTER STANDARD ERROR PROCEDURE ON CUSTOMEReFILE, 27183 4184y STQP AR AR AR A RARARNN R AN AN N AR AR AR IR AN SECTION, CUSTOM=ERROR el18e 21 DIVISION, R RN AR AR AR A DECLAKATIVES, AC1ARY VSt R A RN RRARA R AN, AR AR AR R R RN R AN R R AR R AR PR AR R R R AN R AR NN AR RN AN AR en174 2178 9(S) VALUE @, PIC CATALOUG=COUNT 1 24172 (p2@PECO82) STOP we196 CODE (" RUN, 20197 END A0198 2¢199 ] veead $ evooey MOVE H 8 remd1 evuveuy 3 functions va2us STARTeUPeHOUSEKEEPING 30276 SBEGIN. (2020009C) wieey (PP@JVURY) ACCEPT (AYCORUEY) 20209 0ee1d aeet ae212 only, 49, SECTION TODAYS=DATE FROM DATE, MOVE CORRESPONDING TDR TO TODAYS=REPORTeDATE, "1 4. MOVE Thig section perterms housekeeping x * 40293 ACCEPTY OECLARATIVES, Qttttififitttt.tfifiittiQittt'tfitifiittfi'flttitttfitttt*ittifii'*ifi ov2e weeel e MOVE TO OPTIONS=AREA, SPACES Get CUSTOMER«<FILE mame, Use default * * {f none {s entered, 20213 ODISPLAY 3 (ABCAVREC) ACCEPT H (PpVPRR104) DISPLAY @e214 ACCEPT aneLs IF $ (22P00114) veetle MOVE - (reedo124) I 80217 MOVE, ENTER CUSTOMER OPTIONS=AREA MOVE ee217 FILE NAME (OR CR)", NOT = SPACES OPTIONS=AREA TO CUSTOME“-FILE'ID HIGH ORDER RECEIVING FIELD TRUNCATION, w371 H IF " OPTIONSeAREA, a3 P02994 (r2004132) MOVE wee18 2n219 20220 oneel 0222 SPACES TO OPTIONS=AREA, Get options from the Operator and store results, lgnore mon=standard ) ® * option {mput, 00223 DISPLAY H 23 P2A%An (00¢ve13C) DISPLAY 3 23 ePa28s8 DISPLAY ' a3 pogena (40P 154) en225 (2002816C) 20226 DISPLAY 3 23 PVP0ES DISPLAY H a3 peadten 20224 (rdR22184) aneaer (Adeee19C) 293224 DISPLAY : 23 wevl18 (102001RB4) ACCEPT H 23 aPailn MOVE t @3 e00e14n (eepo21CC) en23y (e0@0210C) @ee3y IF H 23 00014C DISPLAY H a3 eva1sC C-8 28229 SOURCE DISPLAY TM DISPLAY " § = Print CISPLAY " I =z Print DISPLAY TM CA a3 Ma{) al) DISPLAY " CO s Mai) gelective catalogs”, DISPLAY "TM CL ACCEPT ENTER OPTIONS:", statements"”, {nvoices", = Credit catalogs”, Y{mit letters", OPTIONSeAREA, MOVE ALL ZERO TO OPTION=STORAGE, (QRQeR1ES) 1 (ed0vP1F8) ve23il PROGRAM LISTINGS IF OPTIONS=AREA DISPLAY s SPACES "Discrepancy Report Omly" GO 3 82174 (2dV¥00219) MOVE 23 eedi7cC (0200V218) a3y INSPECTY 23 geQ1es (20000224) 28236 0002248 23 000258 (Q20002F4) 0¥244 STOP 23 200270 (PoRRR3AC) DISPLAY 23 Q00274 20246 (poeRA31Y) an247 4 4 23 poe@esc (20200328) I1F ¥a2u3 DISPLAY 23 20082AC 9 4 23 @¥e2Cd (@20008360) FOR ALL "1 (3) FNR ALL "CA" OPTIONENTRY OPTIONENTRY (4) (S) FORP FOR ALL alLlL "cCO" "CL", OPT]ONeSTORAGE 3 DISPLAY STOP DISPLAY DISPLAY 23 00g2Ed (PoQVO389) IF 03 0002FC (000022398) DISPLAY a3 o0031C (22000388) 03 200334 (2000A300) DISPLAY 23 000354 (PORVV3FA) IF e3 ©0036C DISPLAY e3 pealscC (28M0A428) 20256 (00PQ0428) IF wWANTeINVOICES " W4ANT=SOME-CATALOGS TM DISPLAY " ODISPLAY " 20259 CONFIRM«OPT]IONS, DISPLAY 03 20023AC ACCEPT e3 P0A3C4 (P92004Y43) 00260 (P0eRQu60) 411 catatoas", Selected Credit "CONFIRM 80262 IF OPTIONSeAREA=CHAR IF OPTIONSeAREA=CHAR o3 2@0304 (e0e@2472) 03 000414 (202@04RY) Ir o3 P0041C (e2000uBS) GO 00263 28264 letters", (Y)es or (M)o", OPTIONSeAREA, ACCEPTY IF 1imit OPTIQNS: 00261 6O catalogs”, IF WANTeCREDIT=LIMIT=_LETTERS 20257 00258 DISPLAY Invoices", IF DISPLAY 20254 Statements”, AANT=A_LL_=CATALOGS 20255 DISPLAY " IF 4P2sy recoanizea” "Selected optionstTM, WANTeSTATEMENTS DISPLAY 20252 (ERO options IF 20251 1F "No ALL RUN, DISPLAY 22250 TALLYING FOR ALL "S*" OPTION=ENTRY 20245 20248 (20008348) en2u9 A=CUUNT, (2) 23241 20242 (180N 2EY) 23 CONFIRM=NPTIONS, TO CPTIONSENTRY 20238 219 20240 IF TO ¢ INSPECT OPTIONS=AREA OPTION=ENTRY (1) 2n237 DISPLAY GO0 MOVE 22235 TO () NOT = "Y® AND O"N© CONFIRM=OPTIONS, (1) = "A" (000004D8) o3 P0@243C STOP e3 P004%54 (000004FQ) 00266 IF 03 P004sS8 (200034F4) DISPLAY 23 poQava (A009308514) DISPLAY 00265 STOP "ABQORTED BY OPERATOR" RUN, 20267 00268 IF wANT=INVOICES 20269 MOVE o3 a@g490 IF 03 0R0UAC DISPLAY 23 geadccC CISPLAY " e027@ f0274 (20000548) dv272 MOVE IF @ YO DISPLAY @BR4EY (20000580) OPEN 23 0004F4 (200005902) 20276 OPEN INPUT MOVE 23 eeoSeo (00000859C) 20277 (200Q085A8) MOVE "00@¥90" 28278 START 20274 28278 ACCEPT 20279 OPEN 23 90902528 OPTION=ENTRY "Enter 23 ee0eSac implemented" (2), WANT«STATEMENTS ACCEPY 23 not (00P002568) 20273 STARY INVOICES (2000052C) OPEN message or CR" STANDARD=MESSAGE, CUSTOMEReFILE, TO CUST«CUSTe=NUMSER, CUSTOMEReFILE KEY (200205C4) 20280 statement IS OUTPUT » CUST=CUSTe«NUMBER, STATEMENT=REPORT, 0028} READ 4 2R00%00 20282 00283 20284 20285 (P200WSES) 20286 00287 ' A AR R R MAINLINE R R ESESERRSEXSRSRRERRSRA RS RS RRRRR R R 2D RS SECTION, SBEGIN, READ CUSTOMEReFILE AT NEXT END SOURCE PROGRAM LISTINGS C-9 60 24 eege14 24 aeaeeiC (e220aSFC) 20288 (00Q0v60R4) on289 20290 GO ADD { TO TO END=PROCESS, RECORD=COUNT, 20291 Pri{nt statement {f required, vee9e IF a4 200028 (ov000612) PERFORM 04 2000238 (e0000620) o4 200048 (02020630) 20293 ADD e4 2eQesuy PERFORM It % o4 90098C (000V064A4) CUST«BOUGHT CALL ¥»» eo0ecs 24 020204 MOVE 04 @eeREy IF 24 200100 MOVE o4 e0eaiee IF o4 eee13C MOVE ed 20014C 1F o4 200168 MOVE 24 00@178 IF o4 200194 MOVE e4 900144 ELSE 24 92081Co 208316 (20000724) 00317 (e0002734) 00318 (030027509) 20319 (00280769) 07320 (e000977C) 20321 (e200@78C) 00322 (p@202@7A8) IF 24 00021C8 (22000787) MOVE 24 0A0Q1ES ALL ZERO MOVE YTD=CATALOGeMINIMUM USING CUSTOMER=FILERECORD CATALOG=COUNT, for discrepancies TO {n records the EXCEPTION=INDICATORS, | TO EXCEPTION=INDICATOR IF CUST=ADDRESS=LINE=] OR 1 CUSTePHONE MOVE IF | TO TO s | TO | TO > "202000a" EXCEPTION=INDICATOR EXCEPTION=INDICATOR NOT > (2), > (3), @ EXCEPTION=INDICATOR CUST=(ONE=AMT MOVE NOT (1), SPACES CUSTeCREDITe_IMIT MOVE IF = SPACES CUST=ADORESS=21P=CODE MOVE IF (4), CUSTeCREDIT=LIMIT EXCEPTION=INDICATOR (S) ELSE 208323 IF 00324 (020087009) 208325 (e00QQ7EC) 30326 CUSTeOWE=AMT [] MOVE F | TO > CUSTeCREDIT=LIMIT EXCEPTION=INDICATOR EXCEPTION=INDICATORS (220007FC) CALL 20327 NOT = ALL ~» A,8 (&), ZERO % the {s about hig ¥ 1imit {f » » "EXCEPT"TM USING CUSTOMER=FILE=RECORD EXCEPTION=INDICATORS, Gemerate a ‘credit customer has exceed letter’ exceeded IF WANTeCREDIT«_ IMIT=LETTERS AND CUST«OwE=AMT NOT 00336 (@220985C) GO 2337 TO < CUST=CREDLIT=_LIMIT + NDO=CR, ve3iss GO get » ee339 the mext record, N340 GO0 o4 e00e7C (00P2n864) VB34t GO TO MAINLINE, 0A3d2 ne3ay CaLL 00=CR, a4 00v28cC (a9nv0a874) a4 2002A4 (a0m2088C) UELY 20345 C-10 SOURCE or 1imie, » to (00020081C) 08334 40335 gegaerd <« customer’s (n2e2e708) ve333 24 for IF CUSTeCUSTOMEReNAME s SPACES 20312 (200086CC) 20313 (0002V6ESB) 00314 22315 98331 90332 GO TO Check MOVE 22311 (Ar000R6BC) 00328 20329 22332 NOT "DOCATS"TM t B 24 IF 800234 label (¢, * 2310 (PVY0V06BQA) MOVE a4 ADD 20306 eela7 ¢oles 203029 IF mailing WANTeALLeCATALOGS ¥e839s e4 & porint AMD ADD oem2ed need WANTeSOME=CATALOGS (00@0068C) pUReld we catalogr OR 0000A4 24 STATEMENT=COUNT, a IF eal3ae 00301 08302 003023 val3aeu o4 IF TO » (2220963C) CALL CALL PRINTeSTATEMENT »® { 0 > CUST=OWEeAMT ADD 20295 08296 00297 00298 90299 IF IF 00294 PROGRAM CALL ADD LISTINGS "CREODLM" | TO USING CUSTOMERe«FILE=RECORD, CREDITe_IMITeCOUNT, @,8 GO0 fd 204289 (Q0ved0898) d¢346 00347 00348 GO TO AR * * The 00351 * processed, END=PROCESS es 02008 CLOSE s ergoeC MOVE 2S poe018 Pn3Se (00R208C4) 008357 (200022800) (2000280C) DISPLAY 2S gnQe3s MOVE a5 603059 MOVE 2sS P00asC DISPLAY 05 020270 MOVE es g0Q088 MOVE 05 0VP094 DISPLAY es 0000A8 MOVE 25 eooecCa MOVE as anPvacc SBEGIN. CLOSE @S P020ER 2n3S9 (20007A8FQ) 8360 (r00009028) 00361 (00008914) 00362 (92000928) 20363 (P22009402) 08364 (ACRQA094C) MOVE 2s Q0Q0FA @5 eNnledy DISPLAY 2s ev0118 STOP es acat1l3nm (P2000989) 2”370 (P2V0098C) 20371 (00020909) 02372 (020209E8) 228373 vel3rd 28375 @376 eel77 TO DISP=MESSAGE, TO DISP=NUM, TO DISPeMESSAGE, TO DISPe=NUM, DISP=MESSAGE., MOVE "INVOICESTM TO OISP=MESSACGE, MOVE INVOICE=COUNT TO DISP=NUM, DISPLAY DISP=MESSAGE, MOVE "CATALOGS"TM MOVE CATALOGeCOUNT DISPLAY TO DISPeMESSAGE, TO DISP=NUM, DISPeMESSAGE, MOVE “CREDIT LIMIT LETTERS"TM TO DISP=MESSAGE, MOVE CREDITeLIMIT=COUNT DISPLAY STOP AR TO DISP=NUM, DISP=MESSAGE, RUN, AR AR EAN R AR ANRAR RN R R ANRRARNRR AR AR ARRANRRRARARRARANANAANEAY This section generates & statement * record, 0n389 * b4 " for 272381 n38e PRINT®STATEMENT an383 SBEGIN, enQLen (P02VGARY) gegeac (AVVB0AL02) n6 oeaa18 (P@Q30ALC) a6 0eQa3n (P2AYQA34) anla7 (BYAUAALD) 20384 a7 385 2@386 MOVE 26 00003C MOVE A6 PAQAUR MOVE A6 rgasy NRITE 26 BRad60 MOVE eé 00ae7C (rR0PRA82) ¥nl392 MOVE a6 gaovas (PZHOAABC) 26 20029y (AoPdrA98) 24388 (00m20A4C) ¢0389 (POPAAASS) ¥a392 (PARIRALY) @039 @A393 w3394 WRITE 26 800Q0AN (200Q0AAU) MOVE 6 20008C (Q0QVOACH) 8@395 40396 @evuca COUNT®TM . a6 a6 "RECORD RECORDeCOUNT 08379 a6 MOVE MOVE MOVE MOVE STATEMENTeCOUNT (P0002998) MOVE MOVE completely CUSTOMER=FILE, DISPLAY (02000960) 20366 (00002978) en3e7 (2000029484) MOVE MOVE been significant counts, 47, MOVE "STATEMENTS"TM 2036S 22378 WRITE has DISPLAY DISP=MESSAGE., 80369 MOVE SECTION Report CLOSE STATEMENTeREPORT, 20358 20368 DISPLAY CUSTOMER=FILE (av000888) CLOSE 202024 R R AR AR R R AN RARAANN AR AN RN RRRRRRARAAARS e 349 20354 30835S 2s MAINLINE, RN R A AN A RN AR 22359 28352 22353 MOVE AR N (3020 QAACC) rA397 WRITE a6 MDY (P0PPOADS) MOVE 26 QLPOBF (2JNA0AFY) vn3os 22399 MOVE SPACES MOVE WRITE the SECTION current CUSTOMEReFILE 48, TO STATEMENT=REPORT=RECORD, "STATEMENTTM TO FORM=NAME, STATEMENT=REPORT=RECORD MOVE SPACES AFTER ADVANCING PAGE, TO STATEMENT=REPORTeRECORD, MOVE CUST=CUSTOMEReNAME TO ADDRESS=wINDOW, MOVE "DATEi"TM MOVE TODAYS=REPORTeDATE TQ FORMeNAME, TO FORM=DATE, WRITE STATEMENTeREPORT~RECORD AFTER ADVANCING 1 LINE, MOVE CUST=ADDRESSeLINE=] TO ADDRESS=wINDOMW, MOVE "ACCT:"TM TO FORM=NAME, MOVE CUST=CUSTeNUMBER TO FORM®DATE, ~RITE STATEMENTREPORT=RECORD AFTER ADVANCING § LINE, MOVE SPACES TO STATEMENT=-REPORTeRECORD, MOVE CUST=ADDRESSe_INE=2 TO ADDPRESS=WINDOW, WRITE STATEMENTeREPORTRECORD AFTER ADVANCING 1 MOVE CUSTeADDRESSeLINE=3 TO LINE, ADDRESS=WINDOW, SOURCE PROGRAM LISTINGS C-11 MOvE 4] 20Q0FC (ecoovbes) mRITE ) avples (AvevenaC) ePue? dMuRy MOVE 26 avniad (deenrp2d) dnua MOVE 1) wAJL I (p2030v83%4) MOVE 26 araldd (2448 UB) PRdEl dNdRd RRITE hé Qcy15A ("o MOVE ne 020174 (ra¢dAB78) dMBSC) VALAS MOVE 26 MOVE e6 CUST«ADORESS=ZIP=CUODE *RITE MQVE SPACES MOVE CUST«CREDIT=LIMIT MOVE CUST=BOUGHT WRITE MOVE TODAYS=REPQORTeDATE MOVE CUST=OWE=AMT e2Nlan (eveoenay) MOVE "BALANCE de1aAC (P¢BVRBRA) mMOVE P6 eroiCh (vvn@avvnBCC) VAU w41 IF a6 afe10d (dderU@RLA) MOVE aé PUALEY (20Q22BES8) CL T B W] WRITE MOVE IF ELSE 26 PlAlFa (P2PQY28F4) IF A6 2VI1F8 (22@0@2BFC) dadtsS ¢o416 MOVE ) Yooels (seevocicC) ELSE 26 %0224 (ed0pvvCes) MOVE né 27022C (avad0C39) MOVE MOVE C-12 orva2esc SOURCE ADVANCING 6 LINES, STATEMENT=DATE, STATEMENTeBALANCE, TO STATEMENTeCAPTIUN, AFTER TO STATEMENT=REPCRT=RECORD, > CUST=CRED]IT=_IMITY CREDIT LIMIT EXCEEDED «=* "CONSIDER AN INCREASED CREDIT TO STATE4ENT=REPORT=RECORD LIMIT, " ELSE MOVE WRITE 422 0423 26 TO STANDARDeMESSAGE TO STATEMENT=REPORT<RECORD, (avePeC3C) P42 EXIT LINES, IF CUSTeOWE=AMT > CUST=CREDIT=LIMIT # @,8 oru2e evp238 8 ADVANCING ELSE AMU17 26 "#x AFTER TO STATEMENT=REPORT«RECORD 20418 0A419 TO ODUE"TM CUSTeOwE=AMT (TS ] ded1d LINE, TO STATEMENT«REPORTRECORD, STATEMENTREPORTeRECORD SPACES 3§ REPORT=CREDIT, STATEMENTeREPORT-RECORD (A @eYvBAdY) 40d a7 (220 @B899) 06 RRITE TO #eo18C nRITE ADVANCING TN REPQRTeYTD, SPACES AeYP9. AFTER TO STATEMENT=REPORTeRECORD, MOVE o182 TO AODDRESS<Z1P, STATEMENT=REPORT=RECURD Vadneg wodrg MOVF MOVE (WP aCeHY) 424 SEXIT, EXIT, PROGRAM LISTINGS STATEMENTeREPORTeRECORND AFTER ADVANCING 4 LINES, STATE IDENT; 012086 DATA LEVEL 12=Jan=1979 NAME @ @Lma D01V LoeN/ DIR Loc CUSTOMERFILE Ben61 0920824 ‘ ot STATEMENT=REPORT CUSTOMER«FILE=RECORD CUSTeCUSTeNUMBER P68 QVe69 CUSTePHONE=NUMBER AART9 03 [} o1 ot et CUSTeCUSTOMEReNAME CUST=ADDRESSelINE=} CUSTeADDRESSeL]INE=? CUSTeADDRESSeL]INE=]3 CUST«ADDRESS=21P=CODE CUST=PHONE CUSTePHONE=AREA=CODE CUSTePHONE=EXCHANGE CUSTePHONE=LAST=4 03 @3 83 @S 93 83 B3 03 CUSTeATTENTIONe|INE CUSTeCREDITe_LIMIT CUSTeHEADER=DATA NEXTeACCT=NUMBER CUST=OWE=AMT CUST=BOUGHT CUSTeNEXTeORDER=SEWUENCE CUSTeNEXT«PAYMENT-SEQUENCE STATEMENT=REPORT=RECORD ACABY VAR82 PUEBY 22285 P0R86 VP88 20090 00091 @2@95 SeReReQ PP1AS 83 3 @3 @S 23 #3 @3 03 O3 o1 o1 et o1 o1 o1 @3 23 @3 23 ®3 83 o1 [J ] o1 81 01 }| o1 OUB97 PPQA99 P213) 02103 AVALIFA 000238 YPR21E 29023C @4025A R0A278 420270 A0P2T70 ¥40287 QY283 @ ‘ AN e DISP AN ed DISP NUM e DISP DISP DISP DISP DISP DISP DISP DISP DISP Q00287 QLB29B QBV29Y Q@A02A1 QPAB2A7 VVY2B3 QVDI2BF BVUY2C3 @2¢2CA a+aane NRAARPEB sxanaw warawx PURAA6C 20n78 avamwn setasan 2040384 DISP NISP DISP DISP DISP 0ISP DISP DISP DISP PBA2CA avananx DISP VVU2CF QAVUREE A03334C PVYV3ie xasrex 20292 DISP 2°a@9C DISP 2020A8 OISP 20Q0OBY DISP AN AN AN AN AN AN AN AN NUM aaes 20 P PR Y9 00 er A6 PN e WEnul3d Y3~ Beulwn QPrels AANY5 wenta APl a3 veend AN NUM AN NUM NUM NUM NUM NUM AN Ar nQ Y Pd ue a8 e 20 we nangyY A2 et deens oele Apmie Kered ©veend odoesa AN Wl Bvaes? AN AN AN AN Pd wo Pe 20 0ot 00034 vanps @14 24008 STATEMENTeREPORT=STATUS CUSTOMER«FILE=1D 00122 dV03IE 208108 DISP 22123 280329 veAa11d DISP AN AN (Poude vani1d STANDARD=MESSAGE Ppe112 0Yv2CA nRP2Q08 DISP VP114 PV02ED OVUREYU DISP VV11S 000377 P0P@F4 OISP 20121 00R31C A290FC DISP 82125 ARrt126 20127 P0128 0¥ 129 V130 28131 ee133 0135 QVV3I2E VVAL124 DISP AGDI2E PR212C DISP UOA32E 394138 DISP Q00V33IA 224144 DISP QY332 ABA1ISV OISP P0V3I34 VeAaLISC DISP Aad2334 A0A168 DISP P0A337 BOA174 DISP Q00334 QV0188 DISP PN139 00141 PAI43 PVBIGE 00038C @o0392 PA137 03433C EXCEPTION=INDICATOR 00146 03 OPTIONS=AREA=CHAR A=COUNT EXCEPTIONeINDICATORS OPTIONS«AREA OPTIONeSTORAGE OPT]ION=ENTRY OPTIONeVALUES RECORD=COUNT STATEMENT=COUNT INVOICE=COUNT CREDITeLIMIT«COUNT CATALOG=COUNT A=} 28 vadie 4AuDle6 0007V TODAYS=DATE TOR TODAYeYEAR TOOAYeMONTH TOODAYeDAY TODAYSREPORT=DATE TODAYeMONTH TOOAYeDAY TODAYeYEAR _ VU4 waz2as NMEDIT g¢ NMEDIT wd AN 2 STATEMENTeDATE STATEMENTSCAPTION STATEMENT«BALANCE CUSTOMER=FILE=STATUS COROL=74d LENGTH @ . Va2@Aaid8 AQpp@P24 POVKW3Y 2vAR3C PLAAUB 204854 wxenax axwmex awawarn 2Y08270 0CC 2e) Agu@ey DISP pdaQ¢C CLASS 00147 009209 J00VUCA DISP P21739 PUPY2F3 @A@ACC DISP @0111 QUA2CA atnnew OISP @3 03 BVOLIFA USAGE REPORTeCREDIT REPORTeYTD §eoRe=R=] DISPeMESSAGE O0I8PeNUM YTOCATALOG=MINIMUM L 3 Y [} ADDRESS=WINOOW ADDRESS-Z1P FORMeNAME FORMeDATE QRATTM P20T1 00@72 PPATY 2074 2P07S PeATEe PP077 ARATE 63 o1 (J PC093 030229 29 3 @3 @3 93 3 ?3 S 0S 05 93 VAX=1] STATR,CORy4 MAP SCURCE FD FD wRL4UALLS 20V18C DISP AN AN NMEDIT AN NuM AN NUM NuM NUM AN NVEDIT NUM NUM AN A& Y p@ @0 70 a0 A8 A0 wa fa 0 2@uQe YRS danm2 o@nQee venae a0 “onesd @@ veesSo @0 a® ne vwAA198 DISP VPALAU DISP 002188 DISP AN NMEDIY NUM 0VQ39C Q0VI1C8 DISP NUM Pl BAL1U9 QP303IA6 VILFU AN ¢1 27151 OAU3CU4 @VA214 DISP 20145 PRV3I9C Q0BIRC OISP 24148 0A03A0 ACQA1E8 OISP A01S3 Q21S4 DISP AYa3Co 200220 DISP AA23C6 90222C DOISP 08155 ©4B3C6 *xansw DISP 20168 00169 00170 00178 MR172 PBA3ICE 230304 PA03DA 0023EG AVQ3IEL ©0A2B8 DISP 2202C4 DISP 220920V VISP vaE20C DISP MAVP2ES DISP AN AN NUM @yei2 @2@a3e 30e¢16 “onu? @@ @@ ¢33 fe ¥ Q@002 V@20 QoA AQ¥3S d@nusS oeeld @Qale AQu01 Q0039 ©vp00l P9 “eree a0 @eaes AN NiM QY 20008 BST 1B NUM NUM NUM NUM NUM Q0 A0 0 P8 *@ AN SOURCE 04092@S 0ares 9000esS Jenes PQavs PROGRAM LISTINGS C-13 12=Jan=1979 08140115 412086 SOURCE LINE PSECY OFFSET START«UP=HOUSEKEEPING SBEGIN CONFIRM=0OPTIONS MAINLINE SBEGIN D0=CR END=PROCESS SBEGIN PRINTSTATEMENT SBEGIN SEXIT 20184 STATHIS$3S83888a1 2QmAvPe 00 P2199 STATBSS$SSS$8S5002 wvo%Q0e @2 0@192 STATBSS$$3$58002 02000 @0 0320S P02¢06 2A259 PA284 202085 PO34Y 20354 03355 00382 23383 20423 STATBSSSSS8SAVUY STATBSS3$$$8203 STATBS$S$S8%003 STATBSSSS3SSSOUU STATBSSSS$880024 STATBSSSSSSSQ204 STATBISSSSSS205 STATB$S$3S3$SSV0AS STATBSSS$SSSSP06 STATBIS%3833306 STATBISSSSSSQ06 0700200 Qa000d 00Oa3AC 0Q0aR0Q 49 49 49 00 90 00 47 47 48 48 48 QU000 n@Q28C Q03000 aQec0d 0002AQ 0"QR00AO 0OM2SC 212086 @ SEGMENTATION SECTION NAME SEGMENT CUSTOMeERRDOR STATEMeERRQR pe STATBSSS$SSS80A1 STATBSS$$388022 STATBSS$S$$530a3 MAINLINE X, STATBSS$$5853294 ENDePRQCESS PRINTeSTATEMENT 47 48 STATB$$$835%0a5 STATBSSSSS88a%6 STATS GENERATED PSECTS ‘E} STATB3383$5%000 20024 C-14 P SIZE @9903C AP0 3C 00as54C SOURCE SI1ZE {:’ 20a36 PROGRAM LISTINGS nea6a 2060 21356 °e724a 233200 24,y dC ?e332 a0027e nR624 {2=Jan=1979 012086 NAME V4,00=01 ® 3 NAME NGO, 49 COMPILER PAR MAP 00 ING STARTeUP=HQUSEKEEP IDENTs SECT 12=Jan=1979 08340315 STATS IDENT: SEG @33182 STATBSSSSSSSUAl Ap0@3R Q0 CUSTOM=ERROR SBEGIN STATEMeERROR SBEGIN VAX=11 COBOL=74 STATB,C0834 MAP » NAME NAME V4,00=01 O PROCEDURE COBOL=74 VAX=y4 4 8$TATB,.COBj v STATH IDENTs 08140115 VAXei3 COBOL=74 STATB,C0834 81ATB JI0ENT; 12=Jen=1979 N834DL1S 012086 REFERENCED CT4SMGNE C743XEACC CT4SXINTG Cr4sCGPLY CTUSCFSNE CT48MCFSY CT4SXPRF OTS CT4SXREDN C743%60 CT4SXACCS C74$CGPLE C748C206GT CT4SMGLA C7T4SXWRIY CT4SXENDP CTUSXINITY C74SCSTEQ C748CGPGT C748AAF2D CT4SXSTAR C7438XSTPR C74sCZ0LT CTusCFSEQ C748MCAD C74SAMG3P VAXe11 V4,00=941 C748XCLOS CT4SXINSH crascezLY CT4SCSTNE C74SMJUSL C748S81IXY 12=Jan=§979 012086 DATA PSECT Vi,v0=01 ROUTINES C748X0PEN CT4SXED]S C748XINTD C748CZ0OLE C743CSTGY CT4SMGNG STATB IDENT; VAX=11 COBOL=74 8TATB,C0814 A8140115 COBOL=74 U §TATB,C0By MaAP 'GI} SIZE (::) NAME STATBS333838SDAT 8§TATBS3388330DD STATBSSSSSSSARG STATBS$383SSWRK STATBSSSSSSSLIT 200406 STATS IDENT; EXTERNAL DOCATS 007880 LT 00009 00001A eoeagecCe 000209 2000609 2e0020 0eo000 STATBSSSSSSSLTD STATB3338388ADTY STATBSSSSSSSUSE $CBXAL $CBFO1 eegead SEVERITY I e0e2é6 208704 00720 020029 eeal3e 22002 200804 12=Jen=1979 0212086 P84S VAXeyy COBOL=74 STATB,CO0B34 Vd,00=0} 12=Jan=1979 0AB8140S1S VAX={] COBOL=74 STATB,CO0B34 Vd,0¢=01 SUBPROGRAM REFERENCES CREOLM EXCEPY STATB IDENT: 21230 2se3al 0212086 ERROR COUNT 1 SOURCE PROGRAM LISTINGS C-15 DOCATS IDENT: 1o=Jam=1979 12086 T FORMAT /NOANS /MAP J0EBUG2TRACERACHK /COPY_ LIST /MNOCKOSS REFERENCE /VERR,LOCAT}ON /L1ISTZDOCATS /WARNINGS /ORJECT=DOCATS aaIN] IDENYIFICATION PROGRAM=]ID, 0Adu2 BB141122 VAXe11 COBOL=7d4 DOCATS,.C0B6 DIVISION, DCOCATS, 20423 Ay DATE=wRITTEN, WRAAAS DATE=COMPILEC, i JANUARY (979, » for dPYA9 % the werdt1e L * » AAI26 ARrIA7 dudng This sub=proqram each CUSTOMER=FILE prints callina & record mailing passed label from nrogram, 20d11 gnrale 40213 12=Jan={979 , ENVIRONMENT DIVISION, 12414 3¥9d1S 42816 CONFIGURATJON SECTION, SOURCE=COMPUTER, 9917 UBJECT=COMPUTER, VaX=1{1, ViXetl, 40218 229149 INPUT=QUTPUT Q20 FILE=CONTROL, a2y SELECT 20422 0223 SECTINN, : LABEL=REPORT ASSIGN FILE TO "LABEL" STATUS 1S LABEL-REPORT-STATU§. dvded 2P 22S PATA DIVISION, FILE ScCTION, vAYeh vea27 A2028 2pa29 FD 9”039 20A3 N3 My LABEL=REPORT=RECARD N1 LeR=DETAJL, 01 LeR=DETAILw? LABELePEPURT LABEL RECURDS 40433 a3y 403135 JRrdldy STANDARD, AA439 veddo FILLER PIC X(34), LR=ACCOUNT PIC X(6), FILLER 3 PIC LReZ1P VALUE X(S), SECTION, LABE_L=REPORT=STATUS o@0uR X(32), PIC WORKING=STORAGE 1 X(408), A% 3Nd38 arady PIC 3 23 2da36 ARE pIc Xx(2) "XXx", 20943 a4y LINKAGE SECTION, CrreerrrCCreCCrr e rrrerrrrcCc e r @ed4s d0346 COPY CUSTRC, 0047 goeus 0049 Il by @1 CUSTOMER=FILE<RECORD, A80S1 23 "3 CUST=CUSTeNUMBER CUST=CUSTOMER=NAME PIC PIC X(6), X(30), 3052 03 CUSTeADDRESS=L INEe1 PIC X(30), aMas3 f3 CUST=ADDRESS=L INE=2 40854 V1T LY PIC X(30), @3 CUST=ADORESS=LINE=3 PIC X(30), 23 20056 @ CUST=ADDRESS=2]P=CODE PIC X(S), aeas? 20458 : CUST=PHONE, 05 209%6@ CUST=PHONE=AREA=CODE s CUST=PHONE=EXCHANGE as veas9 CUST=PHONE=_LASTw4 03 CUST=PHONE=NUMBER 00062 "3 20063 a3 CUSTeATTENTIONeLINE CUST=CREDITeLIMIT 02064 e3 CUST-HEANER=DATA 02061 REDEFINES 200695 2@v66 480367 0oa68 20469 20879 " o3 FILLER NEXT=ACCT=NUMBER eAMT =0 PIC 03 23 Q0¥73 27074 PROCEDURE CUST=NEXT=ORDER=SEQUENCE CUSTeNEXTePAYMENT=SEQUENCE DIVISION X(3), X(3), 9(4), 9¢18), PIC X(20), PIC 9(10)V99, CUST=CREDITeLIMIT, UST=BOUGHT aea72 wearTs REDEFINES 25 cosTeone cost ¥eo71 08476 204717 CUSTePHONE s J PIC PIC PIC PIC XC6), PIC 9(6), PIC PIC 9¢12) V99, 9(10) V99, PIC 9¢4), PIC 9¢4), USING CUSTOMER=F I_E=RECORD, DECLARATIVES, 004878 USE C-16 0ee79 $ 21 @00vey SOURCE (00000028) REPORT=ERROR o080 USE 20081 SBEGIN, PROGRAM AFTER LISTINGS SECTION, STANDARD ERROR PROCEDURE ON LABEL=REPORT, V4,00=8} DISPLAY 1 01 022004 (Q20244¥e8) 00082 NISPLAY 0ev8} L "le( ERROR ON [ ABEL=REPUKT, CODE (" LABEL*REPURKTeSTATUS LY "y, 02488 20086 END DECLARATIVES, 00287 29088 MAINLINE 2n289 SBEGIN, ir t 02 0900007 (@3RA0V6Q) OPEN $ 92 002010 (m2200027923) MOVE ! 82 00001C (mPRQ2207C) 20992 (AQQd42088) MOVE ! 02 002028 1 02 000034 OPEN SPACES 20093 MOVE CUSTeCUSTeNUMBER (0000QQ94) 20494 WRITE 2089S ! 22 000052 80496 MOVE $ @2 000eSC (VJPQQeR8C) 00897 MOVE 1 02 000078 (@00ceads) 20999 MOVE NRITE ! 02 000084 (000V0GREY) 20192 WRITE 02 00200AQ o101} 0n102 t 02 00Q00AC (g@uvd21aC) 20103 MOVE § 82 0000C8 (Q22040128) MOVE ! A2 020004 (Q000@134) 0010¢ MOVE 201@S { 92 0©0PQP0En § 02 QQPQPBFC WRITE ! 92 000108 (20000140) 001@7 t 22 090124 ADVANCING WRITE LABEL=REPORT=RECNRD ADVANCING SPACES TO (Q20040184) 04f12 EXIT NAME LR=21P, LINE, LABFL=REPORTeRECORD, OOIV DIR LINE LOCN LOC AB029 AdRnee (LReZ]P 0PO3S 0037 CUSTOMER«FILE=KECORD P0R4]l A0AL1T76 A20024 00049 QA20V0 LReACCOUNT LABEL=REPORT«STATUS CUST«CUSTeNUMBER CUST«CUSTOMER®NAME CUST«ADORESSeLINE=1 CUST=ADDRESS=LINEe? CUST=ADDORESSeLINE=3 CUST«ADDRESS=Z1PeCODE CUSTePHONE CUST=PHONE«AREA=CODE CUSTePHONE=EXCHANGE CUSTePHONE=_AST=y4 CUSTePHONE=NUMBER CUSTeATTENTIONe| INE CUST=CREDIT=LIMIT CUST=KEADER=DATA NEXT=ACCT=NUMBER CUSTeOWEeAMT CUST=BOUGHT CUST=NEXT<ORDER=SEQUENCE CUSTeNEXT=PAYMENTeSEQUENCE VaX=11 COROL=74 ODNCATS.COR6 V4,PneQ} LISTINGS C-17 MAP SOURCE L*R=DETAILe? 83 83 83 83 @3 @3 83 @5 @S 0S5 83 @3 83 83 @S 83 93 03 63 LAREL=REPORT=RECORD, TO 12=Jan=1979 PR341122 00031 0032 L L L L L L L L L L L L L L L L L L L § TOD PROGRAM, LABEL=REPORT (| LALEL=REPORT=RECORN, WRITE LABEL=REPORT=RECNRD AFTER ADVANCING 2 LINES, LABEL=REPORTeRECORD LeReDETAIL 83 TO CUST=ADDRESS=ZIP-CODE o1 1 "} LAREL=REPORT=RECORD, LINE, CUST~ADDRESS=_LINE«3 FD 21 LABEL=REPORT=RECORD, TO MOVE MOVE DATA @3 1 CUSTeADDRESSeLINEw2 DOCATS IDENT; 012086 LEVEL TO LABEL-REPORT=RECORD AFTER (0092015C) vaie9 (N0M20168) 20110 0oLl EXIT LINE, MOVE Jo108 MOVE § WRITE LABEL=REPQORT=RECORD AFTER ADVAWCING | LINE, 00104 WRITE ADVANCING CUST=ADORESS=_LINEel AFTER (9%0000100) WRITE LN=ACCOUNT, ARITE LABEL=REPQRT=RECORD AFTER ADVANCING 2 LINES, 0ea98 § TO CUST=CUSTOMER=NAME WRITE MOVE LABEL=RFPNRTeRECQRD, LABEL=REPQRT=RECNRD AFTER (200000834) TO LABEL=-REPORT, MOVE , MOVE OQUTPUT "xxTM = IF LABEL=REPORT=STATUS 23090 00491 WRITE SECTION, @3014C 20014C USAGE 00459 PP2S1 20052 P@AS3 00054 BPASS 20056 @057 00058 AN059 2U060 Q0062 22063 00364 00066 PPR67 20369 PVBTL 372072 @2016C 04022272 Q007AQ6 AVYPA24 220042 908060 QUVRATE QYRQB3 0VA@B3 00086 Y20089 Q00283 AVAR8D AVPBAL QB0CAL BVOVDBAT Q0ANAD PYBRBY AVEACS AP23CO LENGTH A¢ ac HPAUD QAepdoy 6 02037 DISP DISP avxnax @AP@AL8 DISP DISP DISP AN A wawrxn DISP ¢AYRPPAY DISP AVPE@AC DISP UAUPL8 DISP BYR@24 DISP AN AN AN AN AN AY w0 a2 A ng Volee ¢“galn PMAR3Y Peale WBABIA WwRAR3IC #xawnr w*ewns *wamanx xawawe wnkawnr xxanax xeamax =wasxaw DISP DISP DISP DISP DISP DISP OISP #@ ek @4 0 fe @0 @l DISP DISP AN AN AN AN AN NUM NUM AN NUM AN oY 20 Yea3n 70005 ¥e0ni0 Qo3 0Q00ea3 AeALd QPa1N ©Pa2Y 0@ @ppge #ezzax xtanan axawra wwanawx xrxawn DISP DISP DISP DISP DISP NUM NUM NUM NUM NUM 20 N0 @ 7@ 20 00006 40012 e@eie dJenpuy QreQu DISP AN AN OCC 20020890 wxnmaw 00034 PUB16E 2PP¥AC DISP PBQ14C CLASS AN YT T AN AN 20 "0 20005 nAeeae VR8BS SOURCE PROGRAM DOCATS IDENT; {2=Jan=1979 @8141822 @312086 PROCEDURE NAME PSECT OFFSETY SEG DOCATSSSSSSSP021 DOCATSS$38$30021 ODOCATSSS$S$S8S0022 DOCATSSS3$SSSPA2 MEAQAD 02000 000000 20 20mAQ0 2o LINE REPQORT=ERROR SBEGIN Q3079 00081 03%88 @0089 MAINLINE SBEGIN DOCATS IDENT; SECTION NAME SEGMENT S VAX={}] Vd4,00=81 P P COBOL=74 DOCATS8,C0B896 DOCATSSSSSSs8001 DOCATSSSSSS%002 SIZE a2e038 22a13C 0eess 20316 12=Jan=1979 0834122 VAXeii COBOL=74 DOCATS,COBj6 V4,00-81 12°Jen=1979 Q8341122 VAX=1i COBOL=74 DOCATS,C0B8)y6 V4,00=01 {2eJane1979 281241122 VAXe{] COBOL=74 DOCATS,C0Bj6 V4,008=0} 12=Jon=1979 088341122 VAX=11 COBOL=74 DOCATS,CO0Bj 6 V4,00+0} GENERATED PSECTS NAME SIZE DOCATSsSsSS83000 000028 DOCATSSS$833003 0000490 DOCATS IDENT; 2094a 20064 @12086 REFERENCED CT4$XOPEN Cr48X8yBK DOCATS IDENT; o0 NAME 232086 COMPILER ) eq PARA MAP NO, 29 e REPORT<ERROR MAINLINE DOCATS IDENT; SECT {2=Jane 1979 08141122 @12086 SEGMENTATION V4,00°8} MAP NAME SOURCE VAX={] COBOL=74 DOCATS,C08)y6 OTS ROUTINES CT4SXWRIT CTUSXINIT CT4SXEDIS C743CSTNE C748xG0 Cr4sMJUSL o12086 C74SXENDOP CT4SMCFSY CT4SXEXIT CT4SMGLA DATA PSECT MAP NAME SIZE DOCATSSSSSSSDAT 200178 DOCATS338383000D 200030 DOCATS$S3$SSSWRK 20001A DOCATSS33S$SARG 90376 20048 000048 eeave 200082E 20046 DOCATSS$SSS$SSADT 200000 20003C 000689 $SCBXA{ $COBFO{ 000020 003000 200004 20ag00 20032 DOCATSgsSSSSSLIT DOCATSsS$SSSLTD DOCATS33SSSSUSE 22026 20009 2004 DOCATS IDENT; B12086 EXTERNAL SUBPROGRAM NO EXTERNAL NO ERROQRS C-18 REFERENCES SUBPROGRAM SOURCE REFERENCES PROGRAM LISTINGS APPENDIX DIAGNOSTIC D ERROR MESSAGES This Appendix contains a numerical listing of the diagnostic messages generated by the compiler. Following the text of most messages are explanations of the diagnostics, 1including descriptions of the compiler's recovery actions. 001 CONTINUE PUNCH WITH BLANK STATEMENT. A blank The 002 QUOTE OR CONTINUE PUNCH IGNORED. line has continue MISSING. a continue indicator QUOTE is indicator. ignored. ASSUMED. A non-numeric literal has no guote and the following 1line has no continuation indicator. at the end 003 VIOLATION OF AREA A. A of terminal quote the line. first non-blank character continued 1line occurs error is ignored. LINE LENGTH EXCEEDS assumed ASSUMED CORRECT. The 004 is INPUT BUFFER. 1in Area on A. a The TRUNCATED. Continuation lines cause a COBOL word to exceed the capacity of the input buffer. The word is truncated on the right; the number of characters retained depends on the 005 .IO CONTROL. WITHOUT .FILE An type of CONTROL. word processed. IGNORED. I-O-CONTROL FILE-CONTROL being paragraph paragraph I-O-CONTROL paragraph appears was is when present. ignored. no The 006 .STRING. DATA ITEM MUST HAVE DISPLAY USAGE. A data item in a STRING statement 1is defined with DISPLAY usage. Fatal. 007 NAME EXCEEDS 30 CHARACTERS. TRUNCATED TO not 30. A character-string that appears to be a name exceeds 30 characters in length. The string is truncated on the right to 30 010 NUMERIC LITERAL OVER 18 characters. DIGITS. TRUNCATED TO 18. A numeric literal exceeds 18 digits length. The literal is truncated on right, with any necessary adjustment scaling. The sign is retained. 011 NUMERIC LITERAL HAS MULTIPLE DECIMAL A numeric decimal 012 013 PICTURE CLAUSE .SELECT. NOT ILLEGAL FOUND. ON GROUP POINTS. 1literal has more than one point. LEVEL. IGNORED. A group level The clause is item has ignored. SENTENCE 1in the to a PICTURE clause. IGNORED. A FILE-CONTROL statement should begin with the word SELECT, but does not. All words up to the next period are ignored. 014 JUST.SYNC.BLANK CLAUSES WRONG AT A GROUP. group level JUSTIFIED, ZERO 015 FILENAME MISSING OR INVALID. A SELECT 1item may SYNCHRONIZED, clauses. SELECT IGNORED. The clause not or 1is contain BLANK WHEN ignored. IGNORED. statement user name or invalid. The either the the SELECT contains no user name statement 1is is ignored. 016 USAGE CONFLICTS WITH GROUP USAGE. The USES usage specified for the usage 1level. The used. differs from higher group usage D-2 DIAGNOSTIC ERROR MESSAGES is GROUP. this item stated group at a 1level 017 ILLEGAL NUMERIC DATANAME IN .STRING. A numeric statement Fatal. 020 .ALL. ILLEGAL IN CONTEXT OF data item in has an illegal .STRING. STATEMENT. An ALL literal has statement. Fatal. 021 SYNTAX ERROR OR NO TERMINATOR. a STRING description. CLAUSES been used in a STRING SKIPPED. A SELECT statement 1is missing its terminating period, or an error causes the statement to be processed before all clauses statement 022 NUMERIC LITERAL ILLEGAL IN A THIS SENDING LIST OMITTED IN The SELECT STATEMENT. STRING, contains 023 were found. is ignored. .STRING. UNSTRING, a numeric or INSPECT literal. statement Fatal. STATEMENT. A STRING statement fields before a contains no DELIMITED BY sending phrase. Fatal. 024 MORE THAN ONE FILENAME IN .ASSIGN. The non-numeric 1literal clause contains more specification. specification is 025 ILLEGAL DATANAME FOLLOWS .INTO. IN Only used. SUBSCRIPTING DEPTH EXCEEDS 3. OVER an ASSIGN one file the first .STRING. The receiving field statement is invalid. 026 of than 3 of Fatal. a STRING IGNORED. The OCCURS clause is nested more three deep. The clause is ignored. 027 VALUE ILLEGAL IN OCCURS ITEM. than IGNORED. A VALUE clause appears in an OCCURS clause or subordinate to an OCCURS VALUE clause is ignored. DIAGNOSTIC an item in an <clause. ERROR MESSAGES with 1item The D-3 030 VALUE ILLEGAL IN REDEFINES IGNORED. ITEM. A VALUE clause appears in an item that either contains a REDEFINES clause or is subordinate to an item with a REDEFINES clause. 031 NO TERMINATOR FOR PARAGRAPH. .IO CONTROL. The I-O-CONTROL paragraph is not The terminator by a period. terminated 032 .MAP. is assumed present. NO LONGER APPLICABLE. IGNORED. is An APPLY clause with the MAP. option and version this for applicable not The compiler. the future versions of APPLY clause 033 AN IO CONTROL CLAUSE WITHOUT 1s ignored. FILES. a A file-name is missing in paragraph. I-O-CONTROL the is 034 SYNTAX ERROR IN ignored. .APPLY. An APPLY clause has clause 035 INVALID ACCESS of <clause The clause MODE. TREAT AS is illegal syntax. The ignored. SEQUENTIAL. The SELECT statement contains an invalid SEQUENTIAL ACCESS mode is mode. ACCESS assumed. 036 INVALID FILE ORGANIZATION. TREAT AS SEQUENTIAL. The SELECT statement contains an invalid ORGANIZATION organization 037 NO SELECT Specification. is assumed. SEQUENTIAL STATEMENTS. A FILE-CONTROL paragraph either contains or none of those statements SELECT no wvalid. 1is present paragraph is ignored. 040 .ASSIGN. OMITTED FROM S ELECT. SELECT IGNORED A SELECT statement clause. ignored. D-4 DIAGNOSTIC ERROR MESSAGES The FILE-CONTROL The contains SELECT no ASSIGN statement is 041 DECIMAL PLACES TRUNCATED. Decimal places have been truncated from a numeric literal during conversion for use as an integer. The integer positions are used. 042 INTEGER EXPECTED, ZERO ASSUMED. An integer 1literal was fractional positions literal is ignored and is assumed. 043 INTEGER VALUE TOO BIG. LARGEST VALUE expected, but were found. a value of The zero USED. A numeric 1literal 1is too conversion as an 1integer in context. A value of 32,767 is 044 ERROR IN DATA RECORDS CLAUSE. The or The 045 ERROR IN LABEL RECORDS NO INTEGER IN BLOCK CLAUSE. SKIPPED. word DATA is not followed by RECORD RECORDS 1in the DATA RECORDS clause. DATA RECORDS clause is ignored. CLAUSE. The or The 046 CLAUSE CLAUSE SKIPPED. word LABEL is not followed by RECORD RECORDS in the LABEL RECORDS clause. LABEL RECORDS clause is ignored. CLAUSE SKIPPED. The BLOCK clause numeric literal. ignored. 047 BAD VALUE IN BLOCK CLAUSE. CLAUSE The big for the given used. does The not contain BLOCK clause SKIPPED. numeric literal in the BLOCK clause causes an illegal block size. The size in bytes must be greater than less than 32768. Clause ignored. 050 NO INTEGER IN RECORD CLAUSE. CLAUSE 051 block 0 and SKIPPED. The RECORD contain a CONTAINS a is CONTAINS clause numeric literal. clause is does not The RECORD ignored. INVALID VALUE IN RECORD CLAUSE. CLAUSE SKIPPED. X The numeric 1literal <clause 1is CONTAINS zero. The RECORD 1in not the greater CONTAINS RECORD than clause 1is ignored. DIAGNOSTIC ERROR MESSAGES D-5 052 INVALID FILENAME. FD SKIPPED. The word following FD is not valid as file-name. The FD entry is ignored. 053 FD TERMINATOR MISSING. ASSUMED PRESENT. The file description period terminator. ignored. 054 KEY WORD EXPECTED. REMAINING CLAUSES NO LABEL CLAUSE IN FD. .STANDARD. entry The contains error no is SKIPPED. A keyword that BLOCK, LABEL, The remainder ignored. 055 a begins a clause, such as DATA, etc., 1s missing. of the FD entry is ASSUMED. The FD entry contains no LABEL RECORD clause. LABEL RECORD IS STANDARD 1is assumed. 056 NO SELECT. FILE DELETED. The FD entry's file-name has no corresponding SELECT statement. The FD entry is ignored. All references to the file-name will be diagnosed as undefined. 057 ALLOCATED SPACE EXCEEDS LARGEST RECORD. The maximum record size specified by the RECORD CONTAINS clause exceeds the space required for any 01l entry under the same file. The value specified by the RECORD CONTAINS clause is used. 060 RECORD AREA EXTENDED TO CONTAIN LARGEST RECORD. The space required by the largest 01 record under a file description exceeds the space required by the RECORD CONTAINS <clause 1in the FD entry. The value derived from the 01 record description is used. 061 NO RECORD AREA. FILE DELETED. No record area description. ignored. All will D-6 DIAGNOSTIC ERROR MESSAGES be is allocated for a file The file description is references to the file diagnosed as undefined. 062 ILLEGAL DATANAME FOLLOWS PHRASE. .WITH POINTER. a in pointer a The data item used as STRING or UNSTRING statement is illegal. Fatal. 063 ILLEGAL SYNTAX IN STATEMENT. .STRING. STRING A syntax. 064 contains statement illegal Fatal. CHANGED TO O01l. 77 ILLEGAL IN FILESECTION. been has description item A 77 level The 77 level found in the FILE SECTION. is 065 ILLEGAL WORD FOLLOWS treated .DELIMITED BY. as an 01 level. PHRASE. expected is literal or A data-name phrase in a DELIMITED BY a following Fatal. STRING or UNSTRING statement. 066 ILLEGAL USE OF .ALL.. IGNORED. numeric an ALL clause, In the VALUE ALL is ignored by is detected. literal the 067 compiler. 88 CONDITION NAME MISSING OR INVALID. IGNORED. The condition-name in an 88 level invalid. or missing either is entire entry is 070 entry The ignored. TWO INDEXED KEYS START AT SAME OFFSET IN RECORD. the of The leftmost character position KEY RECORD ALTERNATE or KEY RECORD 1leftmost the to data-name corresponds position of some other RECORD character data-name. KEY KEY or ALTERNATE RECORD The 071 .REDEFINES. clause is ignored. ON 01 LEVEL IN FILE SECTION INVALID. the on The REDEFINES clause is present SECTION, where FILE the in 1level 01 REDEFINES implicit. 1is redefinition clause 072 PICTURE IGNORED FOR INDEX 1is ignored. ITEM. An item defined as PICTURE clause. USAGE INDEX has a The PICTURE clause 1is ignored. DIAGNOSTIC ERROR MESSAGES D-7 073 NONNUMERIC PIC ON COMP ITEM. TREATED An item has a AS DISPLAY. defined with non-DISPLAY usage picture-string with non-numeric characters. ignored. The The stated item is usage treated as is USAGE DISPLAY. 074 SUBSCRIPT OUT OF RANGE. ASSUME 1. A literal subscript is either less than l or greater than the maximum allowable value. A value of 1 is used. 075 .STATUS. OMITTED FROM .FILE STATUS.. The FILE STATUS syntax. 076 SOME FILES WITHOUT POSIT. NO. A IN ASSUMED. <clause The error MUL. FILE MULTIPLE FILE is has incorrect ignored. TAPE. TAPE clause contains file-names with POSITION clauses. Not all the file-names contain POSITION 077 .MULTIPLE FILE TAPE. clauses. The searching file. during SYNTAX A OPERAND CLASSES IN MULTIPLE an POSSIBLE RECEIVING ignored. will FIELD FILE error. TAPE The clause clause is or more invalid operands class. FEW SOURCE contains a ignored. in a statement FIELDS have Fatal. MOVE statement results in truncation of the receiving This is not an error and is TOO the TRUNCATION. A 102 File find CONFLICT. One 101 1is OPEN ERROR. syntax 100 error FOR ADD At right-hand field value. ignored. .GIVING.. least appear two in valid an source operands ADD...GIVING must statement. Fatal. 103 .EXIT. WAS NOT THE ONLY VERB An IN PARAGRAPH. EXIT statement statement D-8 DIAGNOSTIC ERROR MESSAGES statement 1in is a 1is not paragraph. ignored. the The only EXIT 104 SENDING ITEM INVALID OR OMITTED. or A MOVE statement contains an invalid missing sending operand. 105 .TO.. SENDING ITEM NOT FOLLOWED BY A MOVE keyword statement RECEIVING ITEM INVALID does not the following TO have OR OMITTED. receiving A MOVE statement has no valid operand. 107 Fatal. INVALID CLASS FOR DESTINATION FIELD. receiving operand numeric edited. Fatal. The SUBTRACT 110 the sending Fatal. operand. 106 Fatal. RELATIVE OR RECORD KEY OR STATUS statement 1is of not an ADD or numeric or NAME INVALID. KEY, RELATIVE The name referenced in a FILE or KEY RECORD TE ALTERNA KEY, RECORD The clause is STATUS clause is invalid. ignored. 111 .STOP. SYNTAX ERROR. The STOP statement is not followed by Fatal. literal or the word RUN. 112 .SIZE ERROR. STATEMENT INCORRECT. The word ERROR is not found SIZE clause. 113 .PROCEDURE DIVISION. the ON contain a for an in Fatal. OMITTED. The source program does PROCEDURE DIVISION. 114 a not Fatal. INTERMEDIATE RESULT TOO LARGE. HIGH ORDER TRUNC. An arithmetic statement calls intermediate result in excess of 18 is The intermediate result digits. with digits, 18 to left the truncated on a possible loss of high-order, digits at execution time. non-zero DIAGNOSTIC ERROR MESSAGES D-9 115 INTERMEDIATE RESULT TOO LARGE. LOW ORDER An arithmetic intermediate digits. The truncated with a non-zero 116 .DIVISION. OMITTED AFTER TRUNC. expression result in on calls for excess of intermediate result the right to possible 1loss digits execution at 18 of an 18 is digits, low-order, time. .PROCEDURE.. The word DIVISION PROCEDURE DIVISION 1is missing header. The in the error is from a ignored. 117 TERMINATOR MISSING AFTER DIVISION HEADER. The period terminator division header. The 120 LITERAL INCOMPATIBLE WITH ATTEMPTED is missing error is USAGE. Conversion of a literal from another has failed. Fatal. 121 DATANAME MUST FOLLOW .INTO. IN THIS A 122 NUMERIC SUBJECT data-name statement. Fatal. MUST BE one 1INTO in is not STRING or a 123 OPERANDS CONFLICT IN .SET...TO. A or object of this STATEMENT. SET...TO statement references invalid references invalid Fatal. SET...BY statement operands. ILLEGAL FILENAME LITERAL Fatal. OR FILENAME An ASSIGN statement DATANAME. statement or contains specification or statement is ignored. D-10 present UNSTRING OPERANDS CONFLICT IN .SET ...BY. STATEMENT. A 125 subject context Fatal. condition. operands. 124 to INTEGER. A numeric, non-integer is invalid in the relation form STATEMENT. valid following OR OBJECT ignored. DIAGNOSTIC ERROR MESSAGES a an VALUE 1invalid data-name. OF 1ID file The 126 INVALID SUBJECT OF SIGN CONDITION. The subject of a sign condition is not a Fatal. valid arithmetic expression. 127 ITEM IN TABLE MAY NOT BE USED AS A SUBSCRIPT. subscript 1is A STRING or UNSTRING statement has invalid WITH POINTER phrase. Fatal. an A data item used as itself a table element. 130 131 a Fatal. .POINTER. MUST FOLLOW .WITH. IN THIS STATEMENT. RELATIVE KEY INVALID FOR THIS FILE. IGNORED. A RELATIVE KEY clause has been applied omitted in to a file that does not have RELATIVE organization. The RELATIVE KEY clause is 132 ignored. SUBJECT OR OBJECT OMITTED IN RELATION CONDITION. The subject or object is COBOL relation condition. 133 Fatal. a UNIDENTIFIABLE WORD FOUND IN SUBSCRIPT. A subscript list contains a word that is data-name nor a humeric a neither literal. The remainder of the 1list or sentence is ignored. 134 Fatal. INVALID SUBJECT OR OBJECT IN RELATION CONDITION. The subject or object of a relation condition is an invalid operand. Fatal. 135 SUBSCRIPTS OMITTED. ASSUME VALUE OF 1. A reference to a table item contains no subscript list. Literal subscripts of 1 are supplied as defaults. 136 RELATIVE INDEX LITERAL OUT OF RANGE. INDEX USED. The literal value of a relative 1index causes an out-of-range reference to the table. The literal value 1is ignored, and only the index-name is used. DIAGNOSTIC ERROR MESSAGES D-11 137 SUBSCRIPTS GIVEN WHERE NOT REQUIRED. IGNORED. A reference is and a made to a non-table subscript list The subscript reference. the list is ignored. 140 TOO FEW SUBSCRIPTS GIVEN. ASSUME 1 FOR item, follows REST. A reference to a table item contains a subscript 1list with too few subscripts. Default 1literal subscripts of 1 are supplied for missing subscripts. 141 142 TOO MANY SUBJECT SUBSCRIPTS AND OBJECT GIVEN. USAGE IGNORE EXCESS. A reference to a many subscripts table item contains too in the subscript list. Extra are MUST subscripts ignored. MATCH. A relation condition between non-numeric operands requires the same usage for both 143 ARITHMETIC EXPRESSION operands. REQUIRED IN THIS Fatal. CONTEXT. An arithmetic expression is required 1in the context of the COBOL statement being compiled. The compiler has failed to recognize the arithmetic expression in this context. Fatal. 144 CONDITION EXPRESSION REQUIRED IN THIS CONTEXT. A condition expression is required in the context of the COBOL statement being compiled. The compiler has failed to recognize the condition expression in this context. Fatal. 145 ILLEGAL OPERAND FOUND IN COBOL EXPRESSION. An invalid found in data-name the or COBOL literal has been statement being compiled. The class or USAGE of data item may be 1invalid here reference in an expression. Fatal. 146 OPERATOR IS MISSING IN COBOL EXPRESSION. An operator specification is of omitted this COBOL The in D-12 DIAGNOSTIC ERROR MESSAGES expression. Fatal. the expression. compiler cannot recognize expression as a syntactically COBOL the as a this wvalid 147 ABSOLUTE VALUE STORED. A negative value has been supplied for an unsigned numeric item. The absolute value of the numeric literal 1is stored in 150 ILLEGAL WORD FOUND AFTER the .NOT. item. IN EXPRESSION. illegal an detected has The compiler expression operator following a NOT being expression COBOL keyword in the compiled. 151 VERB FOUND Fatal. ALLOWED. IN AREA A. A statement begins is 152 EXPECTED .RELATIVE KEY. in Area A. The error ignored. DATANAME NOT DEFINED. KEY RELATIVE a The data-name given in has not been defined in the Data clause Division. 153 .LINAGE. CLAUSE DATAITEM IS TOO LONG. A data item named in a LINAGE clause 1is declared 1in the Data Division with more of positions than four decimal integer precision. 154 PROCEDURE NAME DUPLICATES DATA NAME. A procedure data-name. can there ALLOWED. name is 1identical The error is ignored, 1in ambiguity no be to a since 1legal references. 155 STATEMENTS FOLLOWING .GO. CAN NEVER BE EXECUTED. GO A statement follows an unconditional The statements following the statement. GO are compiled, but cannot be executed. 156 NONSEQUENTIAL FILE MAY NOT BE OPTIONAL. specify may statement SELECT The on files with sequential only OPTIONAL is OPTIONAL word The organization. ignored. 157 FILE HAS IO CONTROL CLAUSE CONFLICTS. A file 1is given conflicting clause I-0O-CONTROL the in specifications paragraph of the INPUT-OUTPUT SECTION. DIAGNOSTIC ERROR MESSAGES D-13 160 FILE REQUIRES REL. KEY. TREATED A file random KEY to 161 INVALID INDEX DATAITEM USE AS SEQ. with or ACCESS. relative dynamic clause. The organization access access and has no RELATIVE mode is changed SEQUENTIAL. IN RELATIONAL. The compiler detects the invalid use of an 1index data item reference as the subject or object of a relation condition. Fatal. 162 UNKNOWN WORD. SCAN TO NEXT CLAUSE. An unknown word is encountered when a clause keyword 1is expected. All words are ignored up to the next valid clause. 163 CLAUSE DUPLICATED. SECOND OCCURRENCE A SELECT statement occurrences second 164 NO FD FOR THIS USED. of contains the same is used. occurrence two <clause. The SELECT. The file-name supplied in a SELECT statement is not further described in an FD in the Data Division. The SELECT statement is ignored, causing the file-name to become undefined. 165 DIFFERENT SAME REC. AREAS FOR The the AREA 166 .READ. WITHOUT .INVALID KEY. A SAME compiler detects SAME RECORD AREA 167 IO CONTROL CLAUSE HAS FILE .AT READ END. OR conflict and and NO contains the file applied no being to D-14 DIAGNOSTIC ERROR MESSAGES conditional read no references a it. has Fatal. .SELECT. I-O-CONTROL <clause file-name that was not named statement. The file-name is the between SAME the .USE. statement procedure WITH An a clause clause. clauses, USE AREA. I-O-CONTROL statement. in a SELECT ignored 1in 170 INTEGER OMITTED IN .RESERVE.. A DEFAULT RESERVE number clause INVALID SUBJECT OF CLASS to specify the buffer areas to reserve. The ignored, and the of clause is is used. 171 ASSUMED. fails RMS default CONDITION. The subject of a class condition is not a data item with an acceptable class. Fatal. 172 VALUE EXCEEDS FIELD CAPACITY. TRUNCATED. A numeric 173 NO DATA DIVISION a VALUE clause exceeds the length of the The value is right truncated and in the field. field. stored STATEMENTS literal INVALID GRP LEV NUM. REST OF A by PROCESSED. The Data entries. 174 supplied Division contains no valid This is an observation only. RECORD IGNORED. level-number is encountered that terminates a previous group item, but does not match any previous group item's level-number. All data -entries are skipped until the next 01 1level, level indicator or header. 175 INVALID PROCEDURE NAME DEFINITION IN AREA A. The compiler detects source text in Area the Procedure Division that does not conform to the rules for the definition of a legitimate paragraph or section name. Source text found in Area A of the Procedure Division is interpreted by the compiler as a user attempt to define a new paragraph or section name. The compiler supplies a system-defined procedure name and proceeds with the processing® of the source line text containing the invalid A of Area A procedure text. name inaccessible to The is system-defined transparent the DIAGNOSTIC and, thus, ERROR MESSAGES D-15 user. 176 MISSING QUOTE ON CONTINUE LINE. QUOTE ASSUMED. A non-numeric literal is continued, but the first non-space character is not a quote. The error is ignored by assuming a quote in front of the first non-space character. 177 COMPARISON OF LITERALS IS NOT PERMITTED. A relation condition has both subject and object. 200 COPY IGNORED WITHIN LIBRARY a 1literal Fatal. as TEXT. A COPY statement is encountered within library text. The COPY statement is ignored. 201 INVALID FILENAME ON COPY. COPY IGNORED. A COPY statement supplies specification that is invalid. statement is ignored. 202 COPY FILENAME NOT a file The COPY FOUND. A COPY statement supplies a valid file specification, but the file cannot be found on the specified device. The COPY statement is ignored. 203 PERIOD OMITTED AFTER .DECLARATIVES.. The word DECLARATIVES is not followed by a period. The error is ignored. 204 .DECLARATIVES. OMITTED FROM .END. The STATEMENT. word END is DECLARATIVES. END not followed by DECLARATIVES is assumed. 205 PERIOD OMITTED AFTER .END DECLARATIVES.. The words followed by END a DECLARATIVES period. The are error not is ignored. 206 SOURCE PROGRAM ENDS IN DECLARATIVES. The end of the source program occurs the Declaratives area. Fatal. D-16 DIAGNOSTIC ERROR MESSAGES 1in 207 DATANAME MUST FOLLOW .WITH POINTER. A STRING an 210 .OVERFLOW. MUST FOLLOW .ON. A 211 ILLEGAL SENDING FIELD or WITH IN STATEMENT. THIS or invalid DATANAME The IN ILLEGAL SYNTAX IN SIGN CLAUSES ON THIS ILLEGAL SYNTAX IN COBOL an class. UNSTRING Fatal. statement has invalid ITEM. than data description. one or SIGN clause appears (SEPARATE TRAILING.) The second compiler detects a syntax nature 1in the COBOL being CLAUSE ON 1in a follow clause EXPRESSION. The SIGN must used. general 215 contains Fatal. field of invalid an More is statement Fatal. LEADING 214 has UNSTRING syntax. MULTIPLE UNSTRING Fatal. STATEMENT. An 213 contains ON OVERFLOW phrase. sending .UNSTRING. statement POINTER phrase. .UNSTRING. statement 212 UNSTRING invalid STRING an PHRASE. NONNUMERIC compiled. error of a expression Fatal. ITEM. A SIGN clause appears in data description. The a non-numeric SIGN clause is ignored. 216 SIGN CLAUSE APPLIED TO NONDISPLAY ITEM. A 217 SIGN CLAUSE APPLIED TO SIGN clause description appears in a with usage DISPLAY. SIGN UNSIGNED The clause DELIMITING DATA ITEM An IN string. The numeric "S" in SIGN clause data its 1is .UNSTRING. UNSTRING invalid than ignored. DATAITEM. PICTURE ignored. ILLEGAL data other is A SIGN clause appears in a description that has no 220 numeric statement delimiter. DIAGNOSTIC references an Fatal. ERROR MESSAGES D-17 221 .ALL. .UNSTRING. FIGURATIVE CONSTANT ILLEGAL IN An UNSTRING statement literal 222 ILLEGAL RECEIVING DATANAME IN An reference. contains ALL an Fatal. .UNSTRING. UNSTRING statement item data receiving references that a 1is invalid. Fatal. 223 .DELIMITED. .UNSTRING. CLAUSE REQUIRED IN THIS contains statement UNSTRING An Fatal. DELIMITED BY clause. 224 DATANAME MUST FOLLOW .DELIMITER IN. PHRASE. UNSTRING An IN DELIMITER a contains statement 1illegal an with phrase .DELIMITER PHRASE. Fatal. reference. 225 ILLEGAL DATANAME FOLLOWS no IN. An UNSTRING statement contains a DELIMITER IN phrase referencing a data Fatal. item that is invalid. 226 DATANAME MUST FOLLOW .COUNT IN. PHRASE. COUNT a An UNSTRING statement contains 1illegal reference. an with phrase IN Fatal. 227 ILLEGAL DATANAME FOLLOWS .COUNT IN. PHRASE. An UNSTRING statement contains IN data 230 DATANAME MUST FOLLOW that phrase .TALLYING reference. ILLEGAL DATANAME FOLLOWS COUNT PHRASE. An UNSTRING statement with phrase TALLYING 231 a an invalid Fatal. item. IN. references .TALLYING contains a illegal an Fatal. IN. PHRASE. a contains statement UNSTRING An phrase referencing a data item TALLYING that 232 DATANAME MUST FOLLOW .INSPECT. is invalid. VERB. A valid data-name follow the D-18 DIAGNOSTIC ERROR MESSAGES Fatal. reference INSPECT keyword. does Fatal. not 233 ILLEGAL DATANAME FOLLOWS .INSPECT. VERB. An INSPECT statement references item that 1is invalid. Fatal. 234 ILLEGAL DATANAME PRECEDES .FOR. IN An INSPECT...TALLYING invalid. .FOR. OMITTED IN .INSPECT. a tally DATANAME MUST FOLLOW statement data item that is Fatal. STATEMENT. An INSPECT...TALLYING invalid syntax. Fatal. 236 data .INSPECT. references 235 a .TALLYING. statement has PHRASE. An INSPECT...TALLYING statement does not reference a tally data-name. Fatal. 237 ILLEGAL WORD FOLLOWS .FOR. IN .INSPECT. An INSPECT...TALLYING statement does not state a valid search condition. Fatal. 240 DATAITEM OMITTED AFTER .ALL. .LEADING. OR .FIRST. An INSPECT statement does a valid search argument. 241 .ALL. FIGURATIVE CONSTANT ILLEGAL IN .INSPECT. An ALL literal statement. 242 ILLEGAL DATANAME FOLLOWS .ALL. OR appears in ILLEGAL DATANAME FOLLOWS .BEFORE. 244 ILLEGAL DATANAME FOLLOWS OR INSPECT a valid not reference Fatal. .AFTER. statement delimiter does not ILLEGAL DATANAME reference in the BEFORE/AFTER Fatal. .BY. An INSPECT statement does not a valid replacement argument. 245 INSPECT .LEADING. An phrase. an Fatal. An INSPECT statement does a valid search argument. 243 not reference Fatal. PRECEDES reference Fatal. .BY. An INSPECT a legal the statement does not data-name or BY phrase. reference literal preceding Fatal. DIAGNOSTIC ERROR MESSAGES D-19 246 DATAITEM OMITTED IN .BEFORE. An OR .AFTER. INSPECT statement does not a legal data-name or BEFORE or 247 ILLEGAL SYNTAX IN PHRASE. .INSPECT. AFTER phrase. literal reference Fatal. after the STATEMENT. Both the TALLYING and are missing in the REPLACING keywords INSPECT statement. Fatal. 250 .BY. MUST FOLLOW .CHARACTERS. IN REPLACING LIST. The INSPECT...REPLACING have CHARACTERS specified. 251 DATAITEM OMITTED AFTER .BY. IN BY statement phrase must completely Fatal. .INSPECT. The INSPECT...REPLACING statement does not reference a legal data-name or literal after BY. Fatal. 252 DATAITEM FOLLOWING .BY. EXCEEDS In 1 an CHARACTER. INSPECT...REPLACING when: 1) the statement, CHARACTERS BY phrase is specified, or 2) a figurative constant preceding the BY keyword of the ALL, LEADING, or FIRST phrase 1is specified, the data-name or 1literal after the BY keyword must be defined as one character in 253 DATAITEMS BEFORE AND AFTER length. .BY. Fatal. UNEQUAL IN SIZE. In an INSPECT...REPLACING statement, the data items before and after the BY keyword of the ALL, LEADING, or FIRST phrase must be equal in length. Fatal. 254 .BEFORE. OR .AFTER. OPERAND EXCEEDS In an 1 CHARACTER. INSPECT...REPLACING CHARACTERS statement, the data-name or following the BEFORE or AFTER must be one character 255 ILLEGAL WORD FOLLOWS .REPLACING. IN - D=-20 DIAGNOSTIC ERROR MESSAGES Fatal. .INSPECT. A legal keyword was following REPLACING statement. in length. BY 1literal keyword Fatal. not recognized in the INSPECT 256 .BY. OMITTED AFTER REPLACING COMPARISON The keyword BY LEADING, separates OPERAND. is omitted in the or FIRST phrase operands to be ALL, where it compared. Fatal. 257 TOO MANY RIGHT PARENTHESES IN COBOL EXPRESSION. The compiler detects an excess of right parentheses in the COBOL expression being compiled. Parentheses must be specified in balanced pairs; that is, a left parenthesis must exist for each right parenthesis specified. Fatal. 260 TOO MANY LEFT PARENTHESES IN COBOL EXPRESSION. The compiler detects an excess of left parentheses in the COBOL expression being compiled. Parentheses must be specified in balanced pairs; that 1is, a right parenthesis must exist for each left parenthesis specified. Fatal. 261 MISSING OPERAND IN ARITHMETIC EXPRESSION. An operand 1is omitted 1in arithmetic expression. Fatal. 262 ILLEGAL OPERAND IN ARITHMETIC The a COBOL EXPRESSION. compiler detects an illegal operand in a COBOL arithmetic expression. The class or usage of the operand may be invalid in the context as a reference in an arithmetic expression. 263 NONINTEGER EXPONENT FOUND IN COBOL Fatal. EXPRESSION. The compiler detects a non-integer, numeric exponent in a COBOL arithmetic expression. is 264 SUBJECT OMITTED IN CLASS The considered arithmetic invalid. expression Fatal. CONDITION. The compiler detects the omission of the subject in a NUMERIC or ALPHABETIC class condition. 265 SUBJECT OMITTED IN SIGN Fatal. CONDITION. The compiler detects the omission of subject in a sign condition. Fatal. DIAGNOSTIC ERROR MESSAGES the D-21 266 OPERAND MISSING IN COMPLEX CONDITION. The compiler detects the operand in an AND condition. Fatal. 267 INVALID OPERAND IN COMPLEX omission of an or OR complex EXPRESSION. The compiler detects a complex condition operand that is not a simple condition, combined condition. 270 ILLEGAL SYNTAX IN NEGATED SIMPLE condition, Fatal. or complex CONDITION. The compiler detects illegal syntax in a COBOL negated simple condition. Fatal. 271 INVALID NEGATED SIMPLE CONDITION. The compiler detects the application of the NOT keyword to an invalid simple condition. 272 ILLEGAL SYNTAX IN .COMPUTE. Fatal. STATEMENT. The compiler detects illegal syntax in a COMPUTE statement. The left side of the assignment symbol or the assignment symbol itself may have been omitted. 273 .AT END. ILLEGAL FOR RANDOM Fatal. .READ. The file is specified with either ACCESS RANDOM or ACCESS DYNAMIC without the word NEXT being included in the READ statement. The AT END clause is treated as an INVALID KEY clause. 274 INVALID KEY ILLEGAL FOR SEQUENTIAL .READ. Either the file has ACCESS SEQUENTIAL or the READ statement contains the word NEXT. In either case, the INVALID KEY clause 1is illegal. It is treated as an AT END clause. 275 INDEX DATA ITEM ILLEGAL AS INDEX ON TABLE. An index data item is used as an index for a table. The index data 1item reference is ignored. A literal subscript of 1 replaces the index data item D-22 DIAGNOSTIC ERROR MESSAGES reference. 276 INDEX NAME NOT DEFINED FOR THIS TABLE. An index-name used in a subscript 1list 1is not defined for this table or either appears in the wrong logical position of the subscript list for this table. The index-name 1is ignored and a default value of 1 is assumed as the subscript. 277 RELATIVE INDEX IS INVALID. The 1literal component of a relative index is zero or less in value, or 1s an is Relative indexing invalid word. ignored and only the index-name is used. 300 PROGRAM NAME OMITTED AFTER .CALL. VERB. The program-name is key word CALL. 301 omitted Fatal. after the LINAGE 0 OR LESS THAN FOOTING. The LINAGE clause must specify a page body of at least one line, and the page dreater to or body size must be equal in the ed specifi size footing the than FOOTING phrase. 302 FILE CLOSED BUT NOT OPENED. A CLOSE statement was encountered for a file that is not opened in this program. Fatal. 303 PRINT CONTROL ON NON SEQUENTIAL FILE. IGNORED. An APPLY PRINT-CONTROL clause references a file that does not have SEQUENTIAL organization. The file-name 1is ignored in the APPLY clause. 304 DATANAME OMITTED IN .KEY IS. PHRASE. The KEY IS phrase of the START statement is not followed by a data-name. The prime RECORD KEY data-name is assumed present. 305 SECTION OR PARAGRAPH NAME MISSING. The Procedure Division does not start section or paragraph name, or a with a is not followed by a section header paragraph name. Fatal. DIAGNOSTIC ERROR MESSAGES D-23 306 .PROCEDURE. MISSING IN .USE. STATEMENT. The keyword USE .START. WITHOUT .INVALID PROCEDURE statement. processing 307 ASSUMED. KEY. OR 1is is It missing 1is in the assumed and continued. .USE. The INVALID the START is declared KEY option statement, for is or the missing no USE from procedure referenced file. Fatal. 310 .WRITE. WITHOUT .INVALID KEY. OR .USE. The INVALID the WRITE is declared KEY option statement, for is or the missing no USE from procedure referenced file. Fatal. 311 DATA DIVISION MUCH TOO LARGE. Too much buffer space is being used the files 1in this program. Too files are declared to be simultaneously. 312 . REDEFINES. SPECIFIES INVALID for many OPEN Fatal. REDEFINITION. The compiler detects the invalid application of REDEFINES to a data description entry that contributes new character positions between the data description entry containing the REDEFINES clause and the item being redefined. Also, the source of error may be the definition of another data description entry with a 1lower level number appearing between the data description entry containing the REDEFINES redefined. clause and the item The compiler ignores REDEFINES processing 313 ILLEGAL TO REDEFINE ANOTHER the being the clause and continues data description entry. REDEFINITION. The REDEFINES clause redefinition of a data specifies item whose the data description entry contains a REDEFINES clause itself. The compiler ignores the REDEFINES clause and continues processing D-24 DIAGNOSTIC ERROR MESSAGES the data description entry. 314 ILLEGAL TO REDEFINE A COBOL TABLE. the specifies clause REDEFINES The a data item whose data of redefinition description entry contains an OCCURS the ignores compiler The clause. continues and clause REDEFINES processing the data description entry. 315 .REDEFINES. APPLIED TO VARIABLE LENGTH DATAITEM. The compiler detects an application of a data item to the REDEFINES clause run time whose length is variable at it has a subordinate data item because whose data description entry contains an The. clause. ON DEPENDING OCCURS to clause application of the REDEFINES ally syntactic 1is item data a such the ignores compiler invalid. The continues and clause REDEFINES processing the data description entry. 316 .OCCURS DEPENDING ON. ILLEGAL IN REDEFINITION. The compiler detects a redefinition that entry description data a contains ON DEPENDING OCCURS an declared with DEPENDING ON clause OCCURS clause. The redefinition to contain a causes the 1length is variable at item whose data 1is The DEPENDING ON phrase run time. ignored and processing continues. 317 PICTURE EXCEEDS 30 CHARACTERS. PIC X ASSUMED. The unexpanded PICTURE string exceeds 30 compiler The 1length. in characters and PICTURE user-supplied ignores the as alphanumeric item data the treats with a "PICTURE X" declaration. 320 FILENAME MUST FOLLOW .CLOSE VERB. The data item following the was not a file-name. 321 .NO. MUST FOLLOW .WITH. Fatal. CLOSE verb IT IS ASSUMED. The keyword NO is missing in the WITH NO the CLOSE statement. of REWIND phrase NO is assumed present. DIAGNOSTIC ERROR MESSAGES D-25 322 . REWIND. MUST FOLLOW .NO. IT IS The ASSUMED. WITH NO statement 323 . REMOVAL. MUST FOLLOW It is assumed .FOR. IT IS The .LOCK. OMITTED AFTER be of the completely present. FOR REMOVAL must It is assumed .WITH. IT IS phrase be of the completely ASSUMED. CLOSE statement followed by one the keywords NO or LOCK. The phrase is assumed present. DATANAME SPECIFIED WHERE FILENAME The name 326 FILENAME MUST FOLLOW MODE some SPEC. WITH is of LOCK EXPECTED. used reference was CLOSE specified. present. The keyword WITH in a recognized but is not 325 CLOSE specified. ASSUMED. statement 324 REWIND phrase must a file other IN in an 1I/0 was not a data-name. verb file name to but Fatal. .OPEN. The OPEN statement does not reference a valid file name where a file-name reference is expected. Fatal. 327 ILLEGAL MODE SPECIFIED AFTER .OPEN. One of VERB. the OUTPUT, OPEN I-O, immediately 330 .END. MUST FOLLOW .AT.. IT IS mode or after keywords EXTEND the 1is OPEN verb. INPUT, required Fatal. ASSUMED. The keyword END was omitted in the END phrase of the READ statement. AT END phrase is assumed present. 331 FILENAME MUST FOLLOW .READ. AT The VERB. Either the file-name was omitted following the READ verb or the data item following the READ verb is not a wvalid file-name reference. Fatal. 332 DATANAME OMITTED AFTER . INTO. The INTO IN data-name keyword omitted. D-26 DIAGNOSTIC ERROR MESSAGES .READ. reference following the READ statement of Fatal. the was 333 RECORDNAME MUST .WRITE. FOLLOW OR .REWRITE. The 01 record-name reference immediately following the WRITE or REWRITE verb was 334 STATEMENT IGNORED DUE TO omitted. Fatal. ILLEGAL RECORDNAME. The data-name immediately following the WRITE or REWRITE verb is not a valid 01 record-name 335 .ADVANCING. OPTION OMITTED IN reference. .WRITE. Fatal. 1 ASSUMED. integer numeric A data-name reference, or the keyword PAGE reference, literal BEFORE/AFTER the was not recognized in ADVANCING phrase of A numeric the WRITE statement. integer literal value of 1 is assumed. 336 .EOP. MUST FOLLOW IT .AT.. IS ASSUMED. AT the 1in The keyword EOP was omitted The phrase of the WRITE statement. EOP AT EOP phrase 337 DATANAME OMITTED AFTER is assumed present. .FROM. The data-name reference the of keyword FROM statement was omitted. 340 .ADVANCING. INTEGER TOO BIG. TRUNCATED TO The numeric integer .NO REWIND. ILLEGAL WITH OR .I0. .EXTEND. the REWRITE Fatal. 63. phrase of ADVANCING is greater than 63. 341 following WRITE or in the BEFORE/AFTER the WRITE statement 63 1s assumed. MODE. An OPEN statement with the I-O or EXTEND mode specified cannot have the NO REWIND phrase also specified. Fatal. 342 ILLEGAL .ADVANCING. DATANAME. The 1 IS ASSUMED data-name ADVANCING in phrase of the BEFORE/AFTER the WRITE statement is not an elementary numeric data-name reference. A numeric literal value of 1 is assumed. integer integer DIAGNOSTIC ERROR MESSAGES D-27 343 FILENAME MUST FOLLOW .DELETE. VERB. Either the following the file-name was DELETE verb or omitted the data item following the DELETE verb is not valid file-name reference. Fatal. 344 FILENAME MUST FOLLOW .START. a VERB. Either the file name was omitted following the START verb or the data item following the START verb is not a valid file name reference. Fatal. 345 .LESS. OMITTED AFTER .NOT. IN .START. ASSUMED. The keyword LESS is omitted after NOT in the relational condition of the START statement. LESS is assumed present. 346 DATANAME OMITTED IN .KEY IS. PHRASE. ASSUMED. The RELATIVE KEY data-name for referenced file was omitted in the IS phrase of the START statement. RELATIVE KEY data-name is the KEY The assumed present. 347 RELATIONAL WORD OMITTED AFTER None .KEY of the GREATER, the 350 TERMINATOR IGNORED IN IS. or KEY PHRASE. relational NOT 1IS was phrase statement. Fatal. CONTROL. PARAGRAPH. .IO A clause is keywords recognized of terminated by EQUAL, following the a period, START but a header does not follow in Area A. The period is ignored. The compiler assumes it is still in the I-O-CONTROL paragraph. 351 TERMINATOR IGNORED IN .SPECIAL NAMES. PARAGRAPH A clause is terminated is not followed by a The period is ignored, continues processing by a period, but header in Area A. and the compiler the SPECIAL-NAMES paragraph. 352 .NATIVE. MISSING IN SPECIAL NAMES CLAUSE. The alphabet-name contain NATIVE alphabet-name D-28 DIAGNOSTIC ERROR MESSAGES clause does STANDARD-1. or clause is ignored. not The 353 SYNTAX ERROR IN .OBJECT COMPUTER. PARAGRAPH. contains paragraph The OBJECT-COMPUTER The compiler word. unrecognizable an 1is word until 'a scans over all words found 354 TERMINATOR OMITTED IN .OBJECT in Area A. COMPUTER. PARA. The OBJECT-COMPUTER paragraph 1is not terminated by a period. The compiler scans over all words wuntil a word is found 355 DATANAME FOLLOWING .KEY IS. in Area A. PHRASE IS ILLEGAL. The data-name following the KEY IS phrase of the START statement is not a RECORD KEY associated with the referenced indexed file, nor 1is it subordinate to a RECORD KEY whose leftmost character position corresponds to its own leftmost character position. Fatal. 356 INVALID USAGE ON CONDITIONAL VARIABLE. The level 88 condition variable be defined as USAGE INDEX. 357 ILLEGAL SEPARATOR IN COBOL STATEMENT. An 1illegal between two statement. cannot IGNORED. character was consecutive words The 1illegal of detected a COBOL character is ignored. 360 ILLEGAL CHARACTER FOUND WITHIN A COBOL WORD. Illegal <characters were found 1in an alphanumeric COBOL word, but not in an alphanumeric literal. The illegal characters are replaced by dollar signs in the internal representation of the COBOL word. 361 UNRECOGNIZABLE TEXT FOUND IN COBOL STATEMENT. In scanning the source text, the compiler was unable to recognize an alphanumeric COBOL word (a keyword or user-defined word) , an alphanumeric literal, or a numeric literal. The error 1s not internally corrected and usually will cause further error messages. DIAGNOSTIC ERROR MESSAGES D-29 362 COBOL WORD BEGINS WITH OR ENDS IN HYPHEN. In attempting to recognize a keyword user-defined word, the compiler detected that the COBOL word begins ends with a hyphen. 363 NONNUMERIC LITERAL TOO LONG. TRUNCATED An alphanumeric characters TO MAX. literal 1in 1length literal 1is truncated retaining the first the literal. 364 COBOL SOURCE LINE TOO LONG. TRUNCATED The more TO greater is The ignored, and the printed than detected. on 132 132 The the right, characters as MAX. indicated COBOL source than 65 characters format. or has or excess only COBOL line 1in contains terminal characters are those characters in source line are retained. 365 .BY. OMITTED IN REPLACING OPTION. The COPY IGNORED. keyword BY was COPY...REPLACING statement 366 TERMINATOR OMITTED IN .COPY. IT is IS not found in statement. a The ignored. ASSUMED. The required period terminating the COPY statement 1is omitted. It 1is assumed present. 367 . LINAGE. CLAUSE DATANAME MUST BE AN INTEGER. A data-name referenced 1in the the FILE SECTION is clause of with decimal WORKING-STORAGE 370 . LINAGE.CLAUSE DATANAME MUST A BE numeric data-name LINAGE <clause defined as DIAGNOSTIC ERROR MESSAGES in the SECTION. UNSIGNED. a of signed WORKING-STORAGE D=30 places LINAGE defined referenced the data SECTION. FILE 1in the SECTION 1is the item in 371 POSSIBLE HIGH ORDER RECEIVING FIELD TRUNCATION. information high-order of Truncation during a MOVE or an arithmetic operation possible. 1is field receiving a upon could cause unexpected truncation This be not results, and the message should ignored. 372 POSSIBLE LOW ORDER RECEIVING FIELD TRUNCATION. information low-order of Truncation during a MOVE or an arithmetic operation possible. 1is field receiving a upon could cause unexpected truncation This be not results, and the message should ignored. 373 PD HEADER NOT FOLLOWED BY AN AREA A WORD. PROCEDURE the following word The DIVISION header does not begin in Area A. The compiler scans over all words until a word is found in Area A. 374 OPEN OPTIONAL FILES ONLY IN .INPUT. MODE. An OPTIONAL file can be OPENed in INPUT mode only. The compiler assumes that INPUT 1in OPENed 1is the OPTIONAL file mode. 375 EXPECTED .FILE STATUS. DATANAME NOT DEFINED. A data-name referenced in a FILE STATUS the 1in clause SELECT a of phrase FILE-CONTROL paragraph is not defined in the WORKING-STORAGE SECTION of the DATA DIVISION. 376 EXPECTED .VALUE OF ID. DATANAME NOT DEFINED. OF VALUE The data-name referenced in a ID clause of an FD is not defined in the DATA the of SECTION WORKING-STORAGE DIVISION. 377 EXPECTED .LINAGE. CLAUSE DATANAME Fatal. NOT DEFINED. LINAGE the 1in referenced A data-name not 1is SECTION FILE the of clause SECTION WORKING-STORAGE defined in the of the DATA DIVISION. DIAGNOSTIC ERROR MESSAGES D-31 400 .RELATIVE KEY. DATANAME HAS INVALID CLASS. A data-name phrase of referenced in a RELATIVE a SELECT clause 1in KEY the FILE-CONTROL paragraph is defined with non-numeric class in the WORKING-STORAGE SECTION. 401 -.RELATIVE KEY. DATANAME HAS INVALID CLASS. A data-name phrase of defined referenced in a RELATIVE KEY a SELECT clause must not be with INDEX WORKING-STORAGE 402 .RELATIVE KEY. DATAITEM IS TOO usage in the SECTION. LONG. A numeric integer in a RELATIVE KEY data-name referenced phrase is defined with more than eight digits of precision in the WORKING-STORAGE SECTION. 403 .RELATIVE KEY. DATANAME MUST A BE AN INTEGER. numeric data-name RELATIVE KEY decimal places referenced phrase in 1is the in defined a with WORKING-STORAGE SECTION. 404 .FILE STATUS. DATANAME HAS INVALID CLASS. A data-name referenced 1in a the FILE STATUS phrase of a SELECT clause must be defined in with DISPLAY usage in the WORKING-STORAGE 405 .FILE STATUS. DATA NAME HAS INVALID A data-name phrase of with SECTION. USAGE. referenced a SELECT DISPLAY USAGE WORKING-STORAGE 406 LENGTH OF .FILE STATUS. DATAITEM IS in a FILE clause is STATUS defined in the SECTION. ILLEGAL. An alphanumeric a FILE STATUS data-name phrase of referenced a SELECT in clause must be defined in the WORKING-STORAGE SECTION as an alphanumeric variable consisting of two characters. 407 .VALUE OF ID. DATANAME HAS INVALID A data-name clause of CLASS. referenced an non-alphanumeric WORKING-STORAGE D-32 DIAGNOSTIC ERROR MESSAGES FD in 1s class SECTION. a VALUE OF 1ID defined with in the 410 .VALUE OF ID. DATANAME HAS INVALID USAGE. A data-name referenced in a VALUE OF 1ID clause of an FD must be defined with DISPLAY usage 1in the WORKING-STORAGE SECTION. 411 LENGTH OF .VALUE OF ID. DATAITEM An IS ILLEGAL. alphanumeric data-name referenced 1in a VALUE OF 1ID clause of an FD must be defined in the WORKING-STORAGE SECTION as an alphanumeric variable whose length, L, characters. 412 .LINAGE. CLAUSE DATANAME HAS falls in Fatal. the range 9<=L<=150 INVALID CLASS. A data-name referenced 1in the LINAGE of the FILE SECTION is defined non-numeric class in the clause with WORKING-STORAGE .LINAGE. CLAUSE DATANAME HAS INVALID SECTION. USAGE. A data-name referenced 1in the LINAGE clause of the FILE SECTION must be defined with COMPUTATIONAL USAGE in the WORKING-STORAGE 414 INVALID RECEIVING OPERAND IN .SET.. IGNORED. A receiving is invalid. 415 NO RECEIVING OPERAND SPECIFIED No OMITTED OR ILLEGAL OPERAND AFTER .TO. SYNTAX IN .SET. the MUST FOLLOW .UP. OR statement are specified no wvalid in a IN .SET.. has sending Fatal. words TO, UP receiving statement. .BY. SET STATEMENT. The 420 a Fatal. statement operand. ILLEGAL of operands statement. A SET 417 operand Fatal. .SET.. receiving SET 416 IN SECTION. .DOWN.. The DOWN do operands not of follow a SET Fatal. ASSUMED. keyword UP or assumed or BY does DOWN 1in present. a DIAGNOSTIC not SET follow the statement. ERROR MESSAGES word BY 1is D-33 421 OMITTED OR ILLEGAL OPERAND AFTER The BY 422 423 NO OPERANDS SETTING .BY. IN .SET.. operand following the UP BY or DOWN phrase in a SET statement is invalid or omitted. No operands the keyword Fatal. SPECIFIED INDEX NAME OUT OF RANGE. were recognized DISPLAY. Fatal. .SET. IGNORED. A SET statement is index name wusing large. Fatal. 424 .IF. TRUE PATH OMITTED. ASSUME .NEXT following attempting a literal to set that is an too SENTENCE.. The true path code is omitted from the IF statement. NEXT SENTENCE is assumed as the true path of the IF statement. 425 CONFLICTING SIGN SYMBOLS IN PICTURE STRING. The compiler recognizes both the + and sign symbols in this PICTURE string. The compiler ignores the user-supplied PICTURE and treats the data 1item as alphanumeric with a "PICTURE X" declaration. 426 ZERO SUPPRESSION CONFLICTS IN PICTURE STRING. The compiler recognizes both the 2 and * zero suppression symbols in this PICTURE string. The compiler ignores the user-supplied PICTURE and treats data item as alphanumeric with "PICTURE X" declaration. 427 ILLEGAL CHARACTER IN THE PICTURE the a STRING. A character that is not string character set the PICTURE recognized in the compiler. The the user-supplied this PICTURE by compiler ignores PICTURE and treats alphanumeric with declaration. D-34 DIAGNOSTIC ERROR MESSAGES in 1is the a data item "PICTURE as X" 430 .BLANK WHEN CONFLICTS WITH ZERO. ZERO SUPPRESS. recognized is field specified compiler The string. PICTURE in the BLANK WHEN ZERO clause and the ignores continues with its processing. A BLANK WHEN with a zero 431 PARENTHESIZED SPECIFIER EXCEEDS 18 ZERO clause suppression DIGITS. the inside The specification contained of a PICTURE string exceeds parentheses compiler The length. 1in digits 18 PICTURE and wuser-supplied the ignores data treats the with a 432 INSIDE SPECIFIER MISSING "PICTURE X" item alphanumeric as declaration. PARENTHESES. contained inside The specification PICTURE string is parentheses of a ignores the missing. The compiler treats the user-supplied PICTURE and with a alphanumeric as item data "PICTURE X" 433 ILLEGAL SYMBOL PRECEDES LEFT The PAREN. declaration. IN compiler PICTURE. recognizes an S, V, CR, DB, left a preceding character "." or parenthesis in a PICTURE string. The error is ignored and processing continues. 434 TERMINATOR OMITTED IN .NOTE. PARAGRAPH. The compiler detected a NOTE paragraph that does not end with a period. 435 INVALID OPERAND IN .VARYING. OR .AFTER. PHRASE. The expected operand is not a valid name reference in the VARYING or AFTER phrase of this PERFORM VARYING statement. Fatal. 436 INVALID OPERAND IN .FROM. OR .BY. The FROM VARYING PHRASE. or valid operand 437 TOO MANY .AFTER. PHRASES IN BY statement .PERFORM. phrase does reference. of not a PERFORM contain a Fatal. STATEMENT. The compiler detects more than two AFTER phrases in the PERFORM VARYING statement Fatal. being compiled. DIAGNOSTIC ERROR MESSAGES D-35 440 .FROM. OR .BY. OR .UNTIL. MISSING IN PERFORM. The compiler detects keywords FROM, BY, PERFORM 441 ILLEGAL CONDITION EXPRESSION IN VARYING THE the or omission of UNTIL 1in statement. statement. NONPOSITIVE LITERAL IN .FROM. OR Fatal. PERFORM. The compiler detects condition expression 1in 442 the the an the invalid PERFORM Fatal. .BY. PHRASE. The compiler detects a non-positive, numeric integer literal in this PERFORM statement. 443 INVALID RELATION CONDITION IN Fatal. .SEARCH ALL. The compiler detects either a syntax error or an invalid operand in the restricted form of a relation condition in the SEARCH ALL statement. Fatal. 444 NONINTEGER DATA CONFLICTS WITH INDEXNAME USAGE. The compiler detects a non-integer data item reference 1in a PERFORM VARYING statement in which the VARYING, AFTER, and/or FROM phrase contains an index-name reference. Fatal. 445 IMPLICIT REFERENCE TO BAD CONDITION VALUES. Through a reference to a condition-name, the compiler detects a reference to an associated condition-value that is improperly declared in the Data Division. Fatal. 446 IMPLICIT REFERENCE TO BAD CONDITION VARIABLE. Through a reference to a condition-name, the compiler detects that the associated condition-variable is improperly declared 447 TOO MANY NAMES IN COBOL PROGRAM. in the Data Division. Fatal. RECOMPILE. The COBOL program being compiled has too many data-names or procedure-names. This condition has caused a compiler table to compilation. D-36 DIAGNOSTIC ERROR MESSAGES overflow, aborting the 450 REFERENCE TO UNDEFINED DATANAME OR ILLEGAL SYNTAX compiled being statement COBOL The an undefined to reference a contains the ignores compiler The data-name. may be diagnostic This reference. other with conjunction in issued diagnostics for the erroneous statement. Fatal. 451 QUALIFIED REFERENCE ILLEGAL IN THIS CONTEXT. qualified a detects compiler The an which in context a in reference required. The 1is unqualified reference compiler permits the qualified reference the with in this context and continues compilation of the statement containing the 452 reference. QUALIFIER OMITTED IN QUALIFIED REFERENCE. A data-name is omitted after the keyword OF or IN in a qualified reference in the The compiled. being statement COBOL diagnostic ignored. This 1is reference other may be issued in conjunction with diagnostics for the statement in error. 453 TOO MANY QUALIFIERS IN QUALIFIED REFERENCE. than more detects compiler The qualifiers in a qualified reference. in ignored are excess qualifiers 48 The the reference. 454 UNDEFINED QUALIFIER IN QUALIFIED REFERENCE. qualified a detects compiler The 1is a qualifier a which in reference reference to an undefined data-name. The entire qualified the ignores compiler reference. This diagnostic may be issued other diagnostics with conjunction in containing statement for the erroneous the 455 reference. COBOL STATEMENT CONTAINS AMBIGUOUS REFERENCE. to reference a detects compiler The uniquely not is that data COBOL referenceable through qualification. The compiler uses a reference that satisfies COBOL the the reference in the text of This diagnostic may be issued program, diagnostics other with in conjunction for the statement in error. DIAGNOSTIC ERROR MESSAGES D-37 456 DATANAME REFERENCE EXPECTED IN THIS The CONTEXT. compiler detects a reference to a data item that 1is not alphabetic, numeric, alphanumeric-edited, alphanumeric, or numeric-edited. The context of this reference requires that the reference be to one of these classes of data items. This diagnostic may be issued in conjunction with other diagnostics for the statement in error. 457 ILLEGAL REFERENCE DETECTED IN THIS CONTEXT. The compiler detects a item that 1is invalid its usage. issued in diagnostics reference to in the context an of This diagnostic may be conjunction with other for the statement in error. Fatal. 460 PARENTHESIZED SPECIFIER LARGER THAN 65387 The specification parentheses in a greater assumes 461 EXTRA OPENING QUOTE ON LITERAL IS than 65387 contained PICTURE string in is 65387. The compiler and continues processing. IGNORED. The compiler detects a superfluous quote at the beginning of a non-numeric literal specification. The compiler ignores the extra quote and continues processing 462 PROGRAM NAME MUST BE A NONNUMERIC the non-numeric LITERAL. The program-name key word CALL literal. Fatal. 464 LITERALS ARE ILLEGAL IN ARGUMENT literal. LIST OF literal 1is not following the a nonnumeric .CALL.. Literals are not allowed in the argument list of a CALL statement. Fatal. 465 ARGUMENT LIST OMITTED AFTER .USING. IN .CALL.. The required argument after the key word statement. D-38 DIAGNOSTIC ERROR MESSAGES Fatal. 1list USING is in missing the CALL 470 ILLEGAL SYNTAX IN .CODE SET. CLAUSE. IGNORED. A valid alphabet-name reference is omitted in the CODE-SET clause. The compiler ignores the CODE-SET clause and continues to process the remainder of the 471 DATANAME IN .KEY PHRASE IS. FD. NOT The ALPHANUMERIC. data-name following the KEY IS phrase 1in a START statement referencing an indexed file must be alphanumeric. Fatal. 472 .RECORD KEY. DATAITEM LENGTH GREATER THAN 255. A data-name referenced in a RECORD KEY or ALTERNATE RECORD KEY phrase of a SELECT clause in the FILE-CONTROL paragraph must be defined in the FILE SECTION as an item whose length is 1less than or equal to 255. 473 474 DATANAME .RECORD IN KEY. .KEY IS PHRASE IS SUBSCRIPTED OR INDEX. The data-name phrase in a following the READ or START referencing an subscripted or indexed file must not indexed. Fatal. DATAITEM MUST NOT BE A COBOL KEY IS statement Dbe TABLE. A data-name referenced in a RECORD KEY or ALTERNATE RECORD KEY phrase of a SELECT clause in the FILE-CONTROL paragraph must not be defined in the FILE SECTION with an OCCURS clause or be subordinate to an item with an OCCURS clause. 475 . RECORD. OMITTED FROM .ALTERNATE RECORD. ASSUMED. The reserved word RECORD is missing the ALTERNATE RECORD KEY clause. error is ignored. 476 UNDEFINED .ALTERNATE RECORD KEY. from The DATANAME. The data-name given 1in an ALTERNATE RECORD KEY clause has not been defined in the Data Division. DIAGNOSTIC ERROR MESSAGES D-39 477 .ALTERNATE RECORD KEY. CLAUSES In ARE the SELECT RECORD the KEY with LINKAGE SECTION ITEM APPEARS A KEY TWICE the ALTERNATE interleaved among VALUE SECTION of clauses. This error .USING.. more header. .SEGMENT-LIMIT. IN LINKAGE phrase ILLEGAL are other clauses. The ALTERNATE RECORD clauses should follow one another appear 501 statement clauses no intervening ignored. is 500 SEPARATED. data than a item once must in PROCEDURE not the USING DIVISION USING Fatal. IGNORED. The segment-limit 1is not a numeric literal or 1is a numeric literal whose value is outside of allowed segment-limit range. 502 INTEGER 1 BEYOND AREA A TREATED AS An 01 Area 503 MULTIPLE PICTURES FOR SAME CLOSING PARENTHESIS item was and accepted as ITEM. LAST item PICTURE clause The right A SUBPROGRAM .PROGRAM. An more than compiler beyond Area A. one used PICTURE the 1last specified. parenthesis string. last four string. NOT in PICTURE. PICTURE 505 has The IN detected if USED. clause. MISSING NUMBER. level A A data 504 LEVEL The is missing compiler characters of the in the uses the PICTURE IGNORED. EXIT PROGRAM has been detected, the COBOL program being compiled is a subprogram. Because EXIT PROGRAM but not is meaningful only in a subprogram, the word PROGRAM is ignored, and the statement 1is treated as if it were a simple D-40 DIAGNOSTIC ERROR MESSAGES EXIT statement. 506 EXPANDED PICTURE STRING TOO LONG. PIC X ASSUMED. string PICTURE a of expansion The that string a produces specification The exceeds implementation limitations. user-supplied the ignores compiler if as PICTURE and treats the data item it had a "PICTURE X" declaration. 507 SPECIFIER OMITTED BEFORE LEFT PAREN. IN PIC. string The first character of a PICTURE The compiler parenthesis. left a is and PICTURE user-supplied ignores the as alphanumeric item data the treats "PICTURE X" declaration. with a 510 SECTION NO. 49 GREATER THAN 49. TREATED AS A segment number greater the word treated 511 as if SECTION. it were than 49 The 49. follows segment 1is INVALID ITEM LENGTH IN PARENTHESES OF PICTURE. a The parenthesized length specifier in PICTURE contains non-numeric characters. wuser-supplied the The compiler ignores item as data the treats and PICTURE "PICTURE X" a with alphanumeric declaration. 512 VALUE CLAUSE NOT ALLOWED IN LINKAGE SECTION. data 1in The VALUE clause cannot appear The only in the LINKAGE SECTION. items place the VALUE clause can appear in the 1is in a condition name SECTION LINKAGE definition. 513 OPERAND IN .USING. MUST BE LINKAGE SECTION Only level 01 or ITEM. 77 LINKAGE SECTION may appear in the USING phrase of items Fatal. a PROCEDURE DIVISION header. 514 MULTIPLE FLOATING FIELDS IN NUMERIC EDIT ITEM. multiple contains string PICTURE The The compiler ignores fields. floating the user-supplied PICTURE and treats the a with alphanumeric as item data "PICTURE X" declaration. DIAGNOSTIC ERROR MESSAGES D-41 515 MULTIPLE ZERO SUPPRESS FIELDS IN PICTURE STRING. Multiple zero suppression fields are detected in a PICTURE string. The compiler ignores the user-supplied PICTURE and treats the data item as alphanumeric with a "PICTURE X" declaration. 516 ZERO SUPPRESSION ILLEGAL WITH FLOATING The PICTURE floating and The compiler PICTURE FIELD. string contains both =zero suppression fields. ignores the user-supplied and treats the alphanumeric with a data item "PICTURE as X" declaration. 517 ILLEGAL SYNTAX IN PICTURE STRING. The PICTURE string is not specified correctly according to the rules of PICTURE string syntax. The compiler ignores the wuser-supplied PICTURE and treats the data item as alphanumeric with 520 MULTIPLE DECIMAL POINTS IN a "PICTURE X" declaration. PICTURE. The PICTURE string contains multiple decimal point specifications (V's, P's, or periods). The compiler ignores the user-supplied PICTURE and treats the data item as alphanumeric with a "PICTURE X" declaration. 521 OPERAND IN USING MUST BE LEVEL 01 Only level items a 522 INVALID USAGE. OR 77. 01 or may appear PROCEDURE 77 in DIVISION the LINKAGE SECTION USING phrase header. of Fatal. IGNORED. The USAGE clause contains an 1invalid word. The compiler ignores the entire USAGE 523 MULTIPLE USAGE CLAUSES. LAST clause. USED. The defined data-name has multiple USAGE clauses specified. The last USAGE clause specified is used by the compiler. D-42 DIAGNOSTIC ERROR MESSAGES 524 MULTIPLE OCCURS CLAUSES. LAST USED. multiple has data-name defined The The compiler <clauses specified. OCCURS uses the last OCCURS clause specified. 525 OCCURS SPECIFICATION ERROR. 1 ASSUMED. clause OCCURS The integer entry of the either non-numeric or non-integer or is The 4095. to 1 range is not in the compiler assumes an integer value of 1. 526 DATANAME OMITTED IN DATA DESCRIPTION ENTRY. omitted is declaration data-name The data the in level-number a after description entry. The compiler supplies system-defined name and proceeds with a description data the processing of the is name system-defined entry. The to 1inaccessible transparent and, thus, the 527 INVALID INDEX NAME. user. IGNORED. The compiler did not recognize valid a INDEXED BY phrase. the in name index BY INDEXED the ignores compiler The phrase. 530 USAGE OPTION NOT YET IMPLEMENTED. The IGNORED. compiler detected COMP-1 1in the not is option This clause. USAGE The default implemented and is ignored. the by wused is DISPLAY of USAGE compiler. 531 TERMINATOR OMITTED AFTER DATAITEM DESCRIPTION. DATA the 1in entry A data description period. a by terminated not 1is DIVISION period the assumes compiler The present and continues processing. 532 INVALID SIGN IN NUMERIC is PICTURE. a 1in detected The sign character S is leading the than other position PICTURE character position of a numeric the ignores compiler The string. the treats and PICTURE user-supplied a with alphanumeric as item data "PICTURE X" declaration. DIAGNOSTIC ERROR MESSAGES D-43 533 PICTURE CLAUSE OMITTED ON ELEMENTARY ITEM. An elementary item 1is recognized with its PICTURE clause omitted in the description. The compiler treats the data item as alphanumeric with a PICTURE X declaration. 534 NUMERIC ITEM EXCEEDS 18 DIGIT MAX. TRUNCATED. A numeric field 1is defined 1in this PICTURE with more than 18 digits of precision. The numeric field is truncated to 18 digits. 535 COMP ITEM EXCEEDS 18 DIGITS. ASSIGN 4 WORDS. A COMPUTATIONAL data item exceeds digits in its specification. compiler truncates it and allocates words for its run-time storage. 536 INDEX ITEM HAS ILLEGAL 18 The four CLAUSE. The compiler SYNCHRONIZED, recognized VALUE, a JUSTIFIED, PICTURE, or SIGN clause on a data-item description that has INDEX USAGE. The compiler ignores the offensive clause. 537 NUMERIC VALUE FOR DISPLAY ITEM. IGNORED. The VALUE clause initialization data-item that is USAGE. The VALUE 540 VALUE TOO LONG. specifies for a numeric value non-numeric defined with DISPLAY clause is ignored. TRUNCATED. The non-numeric 1literal in the VALUE clause 1is 1longer than the associated data-item. The literal is truncated on the right to fit in the storage allocated to the data-item. 541 CLAUSE DUPLICATION. IGNORED. This clause has recognized for this clause 1s ignored. 542 INVALID WORD IN .BLANK WHEN ZERO.. been previously item. The duplicate IGNORED. The keyword ZERO was not recognized 1in the BLANK WHEN ZERO clause. The entire clause 1is ignored. D-44 DIAGNOSTIC ERROR MESSAGES 543 LEVEL NUMS UNEQUAL IN .REDEFINES. CLAUSE IGNORED. A REDEFINES clause attempts to redefine two items of different level numbers. The 544 POSSIBLE OVERLAP OF REDEFINES clause DEPENDING ON ignored. ITEM AND TABLE. The DEPENDING ON length table are LINKAGE SECTION. SECTION items is items 1item both and variable defined in the Because LINKAGE are associated with data appearing in a CALL statement, there is no way at compile time to ensure that the DEPENDING ON items and table do not overlap. The COBOL run-time RTS does not check for overlap of the DEPENDING ON item and the table during execution. It 1is, therefore, your responsibility to ensure that overlap does 545 LEVEL ILLEGAL AFTER 77. TREATED AS not occur. O0l. An invalid level number (02-49) it is not a valid group item. follows a 77 1level item. The 77 level item is treated as an 01 1level item. This can cause further diagnostics if action 546 PERIOD OMITTED AFTER .EXIT PROGRAM. followed The words EXIT PROGRAM are not by a period. The error is ignored. 547 L(EXIT PROGRAM. NOT LASTSTMT OF SENTENCE. An EXIT PROGRAM statement appears 1in a sequence of statements within a sentence. But, 1t 1is not the 1last statement. following it be executed. 550 REDEFINING LENGTH SHOULD MATCH ORIGINAL The length of item 1is the item is 551 REDEFINITION OF All of the statements are compiled, but can never .OCCURS. LENGTH. a non-01 1level REDEFINES not the same as the length of it REDEFINES. The new length used. ITEM. IGNORED. Items with OCCURS redefined. REDEFINES is cannot ignored. DIAGNOSTIC ERROR MESSAGES be D-45 552 PROCESSING RESUMES AFTER BAD FD. Prior to issuing this message, the compiler discovered bad syntax in the FD of the FILE SECTION. The compiler at that time issued an error message identifying the syntax error. Then the compiler attempted to recognize another FD, the WORKING-STORAGE SECTION header or the PROCEDURE DIVISION. Upon recognizing one of these three 1language elements, the compiler 1issues this diagnostic to indicate that normal processing has resumed. 553 INVALID CLAUSE KEYWORD. OTHER CLAUSES SKIPPED. A reserved clause keyword was expected at this point in a data item description entry of the DATA recognized by compiler skips to data 554 INVALID WORD FOLLOWING DIVISION, but was not the compiler. The the next level number item description. .VALUE.. IGNORED. The VALUE clause contains an invalid word for this data description. The entire VALUE clause is ignored. 555 VALUE CONFLICT. GROUP VALUE USED. The VALUE clause assigns a value to an item subordinate to a group item that also has a VALUE subordinate VALUE clause 556 LEVEL NUMBER OMITTED. ITEM clause. is ignored. The IGNORED. The level number has been omitted in a data-item description. All source text is ignored up to and including the next period. 557 NO VALUE AFTER CONDITION NAME. 88 IGNORED. An 88 level condition—-name has no clause specified. The entire 88 data-item is ignored. 560 SYNTAX ERROR IN SWITCH CLAUSE. The its the D-46 DIAGNOSTIC ERROR MESSAGES CLAUSE VALUE level IGNORED. SWITCH clause has a specification. The entire clause. syntax error 1in compiler ignores 561 .NO. MISSING IN ADVANCING PHRASE. ASSUMED. ADVANCING .ADVANCING. MISSING AFTER .NO.. phrase missing of the in the DISPLAY NO 1is assumed present. statement. 562 1is NO keyword The ASSUMED. The keyword ADVANCING is missing in of phrase ADVANCING ADVANCING statement. the is the DISPLAY assumed present. 563 DUPLICATE DATANAME DECLARATION DETECTED. DATA In the ENVIRONMENT DIVISION and/or DIVISION, a data-name is defined that is even with not uniquely referenceable complete qualification. 564 PAR IGNORED. ILLEGAL PARAGRAPH HEADER ID DIV. 1in appears An illegal paragraph header The DIVISION. ON IDENTIFICATI the paragraph 565 ILLEGAL PARAGRAPH HEADER ENV DIV. is ignored. PAR IGNORED. 1in appears An illegal paragraph header The paragraph the ENVIRONMENT DIVISION. is 566 ignored. NUMERIC LITERAL ILLEGAL ON GROUP ITEM. IGNORED. the 1in 1illegal is 1literal A numeric The VALUE VALUE clause of a group item. clause 567 .ENVIRONMENT. NOT FOLLOWED BY ignored. 1is .DIVISION.. The word ENVIRONMENT is not followed the word DIVISION. by DIVISION is assumed present. 570 TERMINATOR MISSING AFTER .DATA DIVISION. HEADER. The DATA DIVISION header is not followed 1is assumed period The by a period. present and processing continues. 571 TERMINATOR MISSING AFTER PARAGRAPH HEADER. A paragraph header ENVIRONMENT or in the IDENTIFICATION not is DIVISION The terminated by a period. and present assumed 1is period processing continues. DIAGNOSTIC ERROR MESSAGES D-47 572 -.RENAMES. SPECIFIES STORAGE OVERLAP ON RIGHT. In processing the RENAMES clause, the compiler detects the condition in which the end of the storage allocated to the data-name after the THRU keyword is not to the right of the end of the storage allocated to the data-name after the RENAMES keyword. The compiler ignores the entire RENAMES data description entry. 573 .SECTION. OMITTED FROM SECTION An ENVIRONMENT not followed error 574 TERMINATOR MISSING AFTER HEADER. is SECTION An LEVEL NUMBER. ENVIRONMENT TREAT AS section word DIVISION terminated section by ignored. a TERMINATOR MISSING AFTER ENV DIV NOT FOLLOWED BY The 01-49, 66, The 1level HEADER. DIVISION header a period. present and assumed continues. .DATA. header period. 0l. The ENVIRONMENT terminated by 602 is The | This level number is not an 77, or 88 1level number. number is assumed to be 01l. 601 name SECTION. HEADER. not error is ILLEGAL the ignored. is 600 DIVISION by is not The period is processing .DIVISION. The word word DATA is DIVISION. not followed DIVISION 1is by the assumed present. 603 ENVIRONMENT DIVISION HEADER OMITTED. The program DIVISION processing 604 UNRECOGNIZABLE COBOL PROGRAM - contains header. FORMAT. at the next no ENVIRONMENT compiler paragraph resumes header. ABORT. The compiler is reserved word first word The unable to recognize IDENTIFICATION as the the required in a COBOL source Failure to recognize this required reserved word may be due to one of the following reasons: program. D-48 DIAGNOSTIC ERROR MESSAGES omitted fact, (1) IDENTIFICATION is, in file, source the of word first the as a (2) the user is attempting to compile conventional in program source COBOL the specifying without format switch, or (3) the format conventional file a compile to user is attempting The program. source 1is not a COBOL that diagnostics compiler issues a string of and then aborts the compilation. 605 . IDENTIFICATION. .DIVISION.. NOT FOLLOWED BY followed The word IDENTIFICATION is not 1is DIVISION DIVISION. word the by present. assumed 606 TERMINATOR OMITTED AFTER .ID DIVISION. HEADER. DIVISION The IDENTIFICATION terminated by a period. not and present assumed is is header The period processing continues. 607 . PROGRAMID. EXPECTED AFTER DIVISION HEADER. The IDENTIFICATION followed not DIVISION by error The paragraph. processing continues. 610 TERMINATOR OMITTED AFTER .PROGID. PARA the 1is header 1is PROGRAM-ID 1ignored and HEADER. not 1is paragraph-name PROGRAM-ID The is period The period. a by terminated processing and present assumed continues. 611 INVALID PROGRAM NAME IN . PROGRAM The ID. program PARAGRAPH. name of the PROGRAM-ID contains an invalid character paragraph The 1length. maximum the exceeds or processing and ignored is error continues. 612 TOO MANY FILES FOR LUNS OR TEMPORARY SPACE. that The compiler has discovered either 30 files are declared in the than more program or that more than 30 SAME RECORD the 1in specified are clauses AREA limit a The compiler imposes program. the because <cases, both in 30 of time run and/or compiler associated table space is exhausted. DIAGNOSTIC ERROR MESSAGES D-49 613 INVALID WORD SUSPENDS PROCESSING. SCAN FORWARD. An unidentifiable verb is expected. a verb, 614 period, word The is found where compiler scans word in Area A. or a to PROCESSING RESTARTS ON VERB. Due to a previous syntax error, the compiler scanned forward for the next verb, period, or Area A word at which to resume compilation. The compiler recognized a verb and resumes normal compilation at this point. This message is an observation only. - 615 PROCESSING RESTARTS ON PROCEDURE NAME. Due to a previous syntax error, the compiler scanned forward for the next verb, period, or Area A word at which to resume compilation. The compiler recognized an Area A word and resumes compilation at this point. This message is an observation only. 616 PROCESSING RESTARTS AFTER TERMINATOR. Due to a previous syntax error, the compiler scanned forward for the next verb, period, or Area A word at which to resume compilation. The compiler recognized a period and resumes normal compilation on the word following the period. This is an observation only. 617 .IDENTIFICATION. KEYWORD NOT IN AREA A. The compiler detects IDENTIFICATION keyword A. The compiler ignores continues processing. 620 PARAGRAPH period. processing .LINAGE. the not the in Area error and TERMINATOR ASSUMED OMITTED. A paragraph 621 that 1is INVALID FOR THIS FILE. was terminated The period continues. CLAUSE 1is without assumed a and IGNORED. The LINAGE clause must not be specified for a file that has RELATIVE or INDEXED organization. The LINAGE clause is ignored. D-50 DIAGNOSTIC ERROR MESSAGES 622 TERMINATOR MISSING AFTER PROCEDURE NAME. A section or paragraph terminated by a period. assumed present and continues. 623 .ELSE DOES NOT HAVE ASSOCIATED .IF.. The word statement. 624 VERB EXPECTED TO FOLLOW ELSE.. IGNORED. ELSE The .ELSE. has ELSE no associated is ignored. .JUSTIFY. WITH NUMERIC OR EDITED ITEM. 1IF IGNORED. A sentence ends with ELSE is ignored. 625 name 1is not The period is processing the word ELSE. The IGNORED. The JUSTIFIED clause must not be specified for a numeric or numeric-edited data item. The JUSTIFIED clause is ignored. 626 .BLANK WHEN ZERO. ILLEGALLY SPECIFIED. IGNORED. The BLANK WHEN ZERO clause must be specified only for a numeric or numeric—-edited data item. The clause 1is ignored. 627 INVALID OR MISSING DATANAME AFTER .REDEFINES.. The compiler detects the omission of a valid data-name reference following the keyword REDEFINES. The compiler ignores the REDEFINES clause and continues processing the data description entry. 630 .REDEFINES. MUST FOLLOW DATA NAME. IGNORED. The REDEFINES keyword appears 1in the wrong position of a data description entry. The REDEFINES clause is ignored. 631 DEPTH OF NESTED .IF. EXCEEDS LIMIT. A nested max imum compiler depth. IF statement depth of ignores DIAGNOSTIC has 30 beyond the The this ERROR MESSAGES D-51 nesting exceeded levels. 632 DUPLICATE PROCEDURE NAME DETECTED. In the Procedure Division, a paragraph or section-name 1is defined that is not uniquely referenceable even with qualification. 633 REFERENCE TO UNDEFINED PARAGRAPH In the NAME. Procedure Division, an explicit qualified reference is made to a paragraph-name that is undefined in the section specified by the qualifier. 634 FILENAME LITERAL TOO LONG. TRUNCATED. A file specification in the ASSIGN clause exceeds 150 characters in length. It is truncated to 150 characters. 635 ILLEGAL SYNTAX IN .GO TO. STATEMENT. The the 636 INVALID INTEGER OR compiler detects GO TO statement. illegal Fatal. syntax in DATANAME. In the LINAGE clause, the compiler failed to recognize a non-negative integer literal or a numeric 1integer data-name. This phrase of the LINAGE clause is ignored. 637 .GO TO. HAS MULTIPLE PROCEDURE A GO ON NAMES. TO statement without the phrase has more procedure-name. 640 INVALID WORD FOLLOWS .DATA Fatal. DIVISION. The word following the header either does not or is not one of the FILE, The compiler source text FILE, WORKING-STORAGE, PROCEDURE DIAGNOSTIC ERROR MESSAGES DATA DIVISION start in Area A reserved words WORKING-STORAGE, PROCEDURE. D-52 DEPENDING than one 1is until one recognized. of LINKAGE, or skips all the keywords LINKAGE, or 641 INVALID WORD IN FILE SECTION. SCAN FORWARD. An invalid word was detected in the FILE SECTION where the keyword FD 1is expected. The compiler skips all source text until one of the keywords FD, WORKING-STORAGE, is 642 .OMITTED LABELS LINKAGE, IGNORED WITH .VALUE OF a file. Warning. .SECTION. The STANDARD keyword TERMINATOR EXPECTED AFTER SECTION The not is OR are .ID. MISSING IN SECTION, or LINKAGE terminated assumed OF and IN AREA A. SCAN after the OR LINKAGE present and by a WORKING-STORAGE SECTION period. processing header The 1is period continues. 1ID.. of the keywords the VALUE OF Their presence continues. ILLEGAL WORD omitted It is assumed continues. FILE . VALUE is WORKING-STORAGE, One or both omitted in 647 1is for assumed. HEADER. SECTION, .OF. 1labels SECTION FILE, SECTION. processing 646 ARE OMITTED clause OF ID is specified EXPECTED AFTER HEADER WORD. word 644 PROCEDURE 1ID. The LABEL RECORDS ignored if VALUE 643 or recognized. is assumed OF or ID is 1ID clause. and processing FORWARD. In the WORKING-STORAGE SECTION, an 01 or 77 level number or the PROCEDURE keyword was expected in Area A, but was not recognized. The compiler skips all source text until one of expected language elements is in Area A. 650 GROUP LEVEL .VALUE. the three recognized DISALLOWED. The not VALUE clause permitted elementary specified specified. ignored. on this because group item is a subordinate item has a non-DISPLAY usage or has a SYNCHRONIZED clause The group VALUE <clause is DIAGNOSTIC ERROR MESSAGES D-53 651 REFERENCED LINKAGE SECTION ITEM NOT 1D .PD. USING.. This LINKAGE SECTION item has been referenced in the PROCEDURE DIVISION. However, neither this item nor the level 01 to which it is subordinate appeared in the PROCEDURE DIVISION USING phrase. Only those LINKAGE SECTION items appearing 1in the PROCEDURE DIVISION USING phrase, or items subordinate to them, may be referenced in the PROCEDURE DIVISION of a COBOL program. Fatal. 652 NON-SEQ FILE IN .MULTIPLE. FILE TAPE. CLAUSE. In the 1I-O0O CONTROL paragraph, the MULTIPLE FILE TAPE clause is specified for a file whose organization 1is not SEQUENTIAL. The MULTIPLE FILE TAPE clause is ignored for this file. 653 .VALUE. CLAUSE ILLEGAL IN FILE SECTION. A VALUE clause is specified for a data description entry given in the FILE SECTION. The VALUE clause is ignored. 654 SYNTAX ERROR IN CURRENCY CLAUSE. The alphanumeric literal expected in the CURRENCY SIGN clause of the SPECIAL-NAMES paragraph is omitted. The clause 1is ignored and the currency sign defaults to the dollar sign. 655 ILLEGAL CURRENCY SIGN. The alphanumeric literal in the CURRENCY SIGN clause 1s not allowed as the currency sign either because the literal is 1longer than one character or because it is an invalid COBOL currency sign. The CURRENCY SIGN clause 1s ignored, and the currency sign defaults to the dollar sign. 656 SPECIALNAMES CLAUSE INVALID. An unrecognizable word appears 1in a position where a SPECIAL-NAMES paragraph clause keyword is expected. All source text 1is skipped until the next keyword is recognized. D-54 DIAGNOSTIC ERROR MESSAGES 657 SYNTAX ERROR IN DECIMALPOINT CLAUSE. The keyword COMMA is omitted 1in the DECIMAL-POINT IS COMMA clause of the SPECIAL-NAMES paragraph. The clause 1is ignored. 660 .AFTER. MISSING IN .USE. STATEMENT. ASSUMED. The keyword AFTER is omitted in the USE 1is assumed present and statement. AFTER processing continues. 661 NO .ERROR. OR .EXCEPTION. IN .USE. ASSUMED. EXCEPTION or One of the keywords ERROR The the USE statement. 1in omitted is present missing keyword is assumed processing 662 NO KNOWN CLAUSES and continues. IN SPECIALNAMES. no The SPECIAL-NAMES paragraph contains This is an observation clauses. valid only. 663 REDUNDANT .USE. COVERAGE. PREV. .USE. IGNORED. Multiple USE statements have same the specified referenced 664 UNKNOWN OPEN MODE IN .USE. The last USE file. 1is then applied file. Fatal. referenced statement to the STATEMENT. An unrecognizable OPEN mode option was specified in the USE statement. Fatal. 665 GROUP ITEM HAS BEEN CALLED FILLER. A FILLER item cannot have any elementary items subordinate to it. The compiler replaces the FILLER declaration with a system-defined name and proceeds with the processing item. The transparent of the newly-named system-defined name and 1inaccessible to group is the user. 666 MISSING ENVIRONMENT DIVISION. The program does not contain an ENVIRONMENT DIVISION. The compiler skips to the DATA DIVISION and continues processing. DIAGNOSTIC ERROR MESSAGES D-55 667 DIVISION BY ZERO. The divisor literal of ignored. 670 VALUE NOT PERMITTED WITH THIS of a DIVIDE statement 1is zero value. The error ITEM. A VALUE clause is recognized description entry that REDEFINES VALUE 671 INVALID CONSTANT OR LITERAL a is or clause an is FOLLOWING OCCURS in a data contains a clause. The ignored. .ALL.. The reserved word ALL is not followed by a non-numeric literal or a figurative constant. ALL is ignored and processing continues. 672 BAD FILENAME IN .USE. STATEMENT. An unrecognizable word appears file-name is expected in statement. 673 FILE NOT where the a USE opened, but Fatal. CLOSED. The referenced file was there was no CLOSE statement for this file in the program. 674 SUBJECT OF .ALTER. IS SECTION The detected NAME. ALTER name. statement references FILE COVERED BY CONFLICTING USE paragraph a names section be altered. 1If this statement 1s reached during execution, the program will be aborted. 675 Only may PROCEDURE. There was more than one conflicting USE procedure specified for the referenced file. Fatal. 676 DATA DIVISION EXCEEDS ADDRESS RANGE. The maximum DATA DIVISION bytes. 677 SUPPLIED VALUE INVALID FOR NUM size is ITEM. IGNORED. The VALUE clause specifies invalid initialization for a numeric data The D-56 DIAGNOSTIC ERROR MESSAGES 65,535 Fatal. compiler ignores the VALUE value item. clause. 700 FILE ACCESSED BY VERB REQUIRING REL. A OR IDX ORG. SEQUENTIAL whose organization is START or DELETE the by referenced file is the has that verb verbs or by an I/0 1In all specified. KEY clause INVALID must file referenced these cases, the have RELATIVE or INDEXED organization. Fatal. 701 FILE ACCESSED BY VERB REQ. SEQUENTIAL ORG. A file whose organization is RELATIVE or an I/0 verb by referenced INDEXED 1is that has the AT EOP or ADVANCING clauses must file referenced The specified. Fatal. have SEQUENTIAL organization. 702 VERB NOT IMPLEMENTED. is that An ANS 1974 COBOL verb appears the of release this in implemented not The compiler compiler. period, verb, 704 OCCURS ILLEGAL FOR 01 OR 77 or scans to another in Area A. word IGNORE. ITEM. 0l An OCCURS clause is specified for an The compiler data-name. 1level 77 or ignores 705 .ACCEPT FROM. the OCCURS clause. OBJECT NOT IN SPECIALNAMES. ACCEPT the in the 1in used The mnemonic- name defined not was statement Fatal. SPECIAL-NAMES paragraph. 706 ACCEPT IDENTIFIER INVALID. not data- name a or verb ACCEPT The word following the is has non-DISPLAY usage or a data-name is that class. invalid Fatal. 707 VERB OR COND. CLAUSE CONFLICTS WITH FILE ACCESS. There is a conflict between MODE of the referenced the ACCESS file and the condition <clauses verbs and/or Fatal. reference this file. 710 DATANAME AFTER .GO DEPENDING. The INVALID. word phrase of data-name INDEX I/0 that following the GO TO or usage. is a the DEPENDING ON statement 1s not a data-name that has Fatal. DIAGNOSTIC ERROR MESSAGES D-57 711 INVALID CLASS OF DATANAME AFTER .GO DEPENDING. The data-name following the DEPENDING ON phrase of the GO TO statement is not a numeric data-name or non-integer data-name. 712 .DISPLAY UPON. OBJECT NOT IN .DISPLAY. OPERAND IS The mnemonic-name used 1in statement not defined was paragraph. MISSING OR INVALID the DISPLAY 1in the Fatal. INVALID. A data item in the DISPLAY invalid class or USAGE. 714 numeric, SPECIALNAMES. SPECIAL-NAMES 713 1is a Fatal. OPERAND FOR ARITHMETIC One of the statement statement has VERB. operands of an 1is either missing arithmetic or invalid. Fatal. 715 MISSING OR INVALID SOURCE OPERAND. The an source operand is missing arithmetic verb. Fatal. 716 MISSING 717 .GIVING. REQUIRED AFTER .DIV...BY. OR INVALID DESTINATION The OPERAND. GIVING phrase DIVIDE...BY 720 .GIVING. REQUIRED AFTER LITERAL .BY. MISSING IN . INTO. MULTIPLY, or literal. Fatal. DIAGNOSTIC missing in a Fatal. 1is of SUBTRACT required ADD, if an the DIVIDE, statement 1is a .MULTIPLY. MISSING FROM ERROR MESSAGES BY is missing Fatal. in a MULTIPLY .DIVIDE. One of missing Fatal. D-58 is OPERAND. The keyword statement. 722 INTO statement. The GIVING phrase second operand 721 following the from keywords the BY or INTO 1is DIVIDE statement. 723 .FROM. MISSING IN .SUBTRACT. The keyword FROM SUBTRACT 724 FILE NEEDS DYNAMIC ACCESS FOR 1is statement. missing from the Fatal. .READ NEXT.. In a READ NEXT statement, the referenced file must have ACCESS MODE IS DYNAMIC ‘specified in the FILE-CONTROL paragraph. Fatal. 725 BAD PROCEDURE NAME IN .PERFORM.. A missing or recognized invalid procedure in the PERFORM name 1is statement. Fatal. 726 ILLEGAL OPERAND OF .TIMES. OPTION OF .PERFORM.. The TIMES operand of the statement is not a numeric data-name or numeric integer The compiler assumes a value the TIMES operand. 727 .TIMES. MISSING FROM .PERFORM.. PERFORM integer 1literal. of 1 for ASSUMED. The PERFORM statement does not contain the keyword TIMES but does contain the iteration value required to execute the PERFORM correctly. The keyword TIMES is assumed present. 730 PROCEDURE NAME OMITTED IN .ALTER.. A valid recognized Fatal. 731 ILLEGAL .ALTER. DUE TO MISSING procedure-name in the ALTER was not statement. .TO.. The keyword TO was not recognized ALTER statement. Fatal. 732 FILE HAS VAR. SIZE RECS. .READ INTO. in the ILLEGAL. It is 1illegal for the READ INTO statement to reference a file that has multiple record descriptions of different lengths. Fatal. 733 FILE ACCESSED BY VERB REQUIRING .LINAGE. A file that did not have a LINAGE clause in 1its specification I/0 verb. Fatal. is accessed by an DIAGNOSTIC ERROR MESSAGES D-59 7134 .DELETE. OR .REWRITE. WITHOUT INV. KEY OR USE. A DELETE or REWRITE statement without the INVALID KEY phrase references a file for which there 1is no USE procedure. Fatal. 735 OPEN MODE OR NO READ PROHIBITS REWRITE A or DELETE OR DELETE. REWRITE statement references a file that was not OPENed in the proper mode or that has no READ statement referencing it in the program. Fatal. 736 .START. CONFLICTS WITH OPEN MODE. A START statement was not opened Fatal. 737 .WRITE. CONFLICTS WITH OPEN MODE. A WRITE statement was not opened Fatal. 740 . READ. CONFLICTS WITH OPEN references a file that in the proper mode. references a file that 1in the proper mode. MODE. A READ statement references is only opened in OUTPUT or Fatal. 741 USE NOT IN DECLAR. OR NOT FOLLOWING SECTION a file that EXTEND mode. NAME. The USE statement is not in the DECLARATIVES section of the PROCEDURE DIVISION or is not immediately following a section name inside the DECLARATIVES. Fatal. 742 MORE THAN 255 ALTERNATE KEYS. IGNORED. The maximum of been 743 INTEGER IN SWITCH CLAUSE exceeded. INVALID A OR 255 The ALTERNATE clause 1is KEYS has ignored. OMITTED. SWITCH <clause of the SPECIAL-NAMES paragraph either contains an invalid numeric 1integer or has omitted the integer 1in its specification. A SWITCH clause integer must be 1in the decimal range 1<=n<=16. The SWITCH clause is ignored. D-60 DIAGNOSTIC ERROR MESSAGES 744 .IS. OMITTED IN SPECIALNAMES. ASSUMED PRESENT. a The required keyword IS is omitted in the SPECIAL-NAMES paragraph. of clause processing and present assumed IS is continues. 745 DEVICE MNEMONIC OMITTED IN SPECIALNAMES. device valid A in recognized not 1is mnemonic-name CONSOLE, the of one CARD-READER, PAPER-TAPE-PUNCH or paragraph. clauses of the SPECIAL-NAMES LINE-PRINTER, PAPER-TAPE-READER, All text source next recognizable 746 TERMINATOR OMITTED IN 1is skipped until the keyword. SPECIALNAMES. The SPECIAL-NAMES paragraph terminated by a period. and present assumed not is The period is processing continues. 747 SUBJECT OF .ALTER. NOT .GO TO.. ALTER IGNORED. by referenced The paragraph contain not does statement statement as its first is ALTER statement 750 KEYWORD OMITTED IN .SWITCH. ALTER an TO GO a The statement. ignored. CLAUSE. One of the keywords OFF or ON is omitted the of clause SWITCH the in SPECIAL-NAMES clause 751 CONDITION NAME MISSING IN is .SWITCH. paragraph. The SWITCH ignored. CLAUSE. A valid condition-name is not recognized the of clause SWITCH the in SPECIAL-NAMES clause 752 .CR. OR .DB. 1is NOT AT RIGHT END OF paragraph. The SWITCH ignored. PICTURE. not does DB or The PICTURE symbol CR the right end of the PICTURE at appear the ignores compiler The string. the treats and PICTURE user-supplied a with alphanumeric as 1item data "PICTURE X" DECLARATION. DIAGNOSTIC ERROR MESSAGES D-61 753 .CR. OR .DB. USED WITH SIGNED ITEM. Both a the PICTURE sign, + PICTURE. symbols, or -, The CR or appear compiler 1in DB, and the same ignores the user-supplied PICTURE and treats data item as alphanumeric with "PICTURE X" declaration. 754 MULTIPLE DEFINITION OF SWITCH. FIRST USED. Multiple definitions are detected in of a the paragraph. All but the of SWITCH are ignored. 755 . SENTENCE. ASSUMED AFTER keyword keyword present SUBSCRIPT NOT NUMERIC COBOL switch SPECIAL-NAMES first definition .NEXT. The 756 NEXT is not followed by INTEGER. used as a subscript 1is numeric 1in class. A default value is assumed as the subscript. 761 ILLEGAL INDEXED SYNTAX FILE IN .DIVIDE. REQUIRES RECORD KEY INVALID FOR The compiler the DIVIDE .RECORD THIS KEY. detects illegal statement. Fatal. RECORD KEY. INVALID FOR valid only for clause is FILE. FILE. clause is IGNORED. The ALTERNATE RECORD KEY only for indexed files. 764 in explanatory. RECORD KEY indexed files. .ALT syntax PHRASE. The 763 not of 1 STATEMENT. Self 762 the SENTENCE. SENTENCE is assumed and processing continues. A data-name 760 the a valid READ—AHEAD. OR. WRITE-BEHIND. NOT SUPPORTED. The APPLY READ-AHEAD and APPLY clauses are not supported in this version of the compiler. The APPLY clause is ignored. WRITE-BEHIND D-62 DIAGNOSTIC ERROR MESSAGES 765 INTEGER INVALID IN. RESERVE AREA. CLAUSE. by reserved The number of buffer areas The 1invalid. 1is clause RESERVE the RMS default clause is ignored, and the is 766 BAD VALUE used. IN BLOCK CONTAINS CLAUSE. clause The numeric literal in the BLOCK is less than the sum of the record size, the record header header is 767 VALUE IN. BLOCK CONTAINS. size. The size, and the BLOCK CONTAINS bucket clause ignored. CLAUSE IS ROUNDED UP. clause is value The 512. of multiple a not is rounded up to the next even multiple of The numeric literal in the BLOCK 512. 770 EXPECTED .RECORD KEY. DATANAME NOT DEFINED. The data-name in a RECORD KEY clause has not been defined in the DATA DIVISION. 771 .RECORD KEY. DATANAME HAS INVALID CLASS. KEY RECORD A data-name referenced in a of a RECORD KEY phrase ALTERNATE or FILE-CONTROL the in clause SELECT paragraph is defined with FILE 1in the in a RECORD KEY in a RECORD KEY DIAGNOSTIC ERROR MESSAGES D-63 non-alphanumeric class SECTION. 772 .RECORD KEY. DATA ITEM CANNOT BE VARIABLE LENGTH. A data-name referenced of a phrase KEY RECORD ALTERNATE or FILE-CONTROL the in clause SELECT paragraph is defined in the FILE SECTION as an item whose size 1is variable. 773 .RECORD KEY. ITEM NOT DEFINED IN RECORD OF FILE. A data-name referenced an ALTERNATE RECORD KEY phrase of a or the 1in not defined 1is SELECT clause associated the record description of file. 774 FILE ACCESSED BY VERB REQUIRING A INDEXED ORG. file or whose organization RELATIVE 1is verb that has the phrase specified. must 775 .KEY IS. PHRASE INVALID have INDEXED FOR SEQUENTIAL Either the the READ INVALID DATANAME IN .KEY IS. SEQUENTIAL by organization. IS. PHRASE NOT file not has ACCESS is FOLLOWED BY followed RECORD SEQUENTIAL or the word illegal. KEY RECORD KEY or by a OCCURRENCES TABLE MUST A END COBOL following the READ statement ALTERNATE the KEY IS is not a RECORD KEY for The RECORD KEY table ON with the declared phrase can be followed the record only by data entries whose level-numbers than the 1level-number of The remainder Fatal. RECORD. DEPENDING entry. statement data-name. the referenced file. data-name is assumed. VARIABLE IS Fatal. KEY. The data-name phrase of the 1000 Fatal. statement contains either case the The KEY IS phrase of the READ .KEY READ PHRASE. was 777 the KEY IS data-name The referenced file .READ. NEXT. In data-name phrase 776 is referenced compiler ignores the record the descriptor from where the is of point in description are greater this table error detected. Fatal. 1001 .ASCENDING. OR .DESCENDING. A DATANAME user-defined but or 1002 RENAMED DATAITEMS NOT EXPECTED. not DESCENDING IN CURRENT The in KEY the IS was expected, ASCENDING KEY IS phrase. RECORD. data RENAMES data-name found, items keyword specified (that is, the after the data items being renamed) are defined outside of the current record description. The compiler ignores the entire RENAMES data description D-64 DIAGNOSTIC ERROR MESSAGES entry. 1003 MAXIMUM OCCURRENCES NOT GREATER THAN MINIMUM. In a variable occurrence table declaration, the integer following the keyword TO (that is, the maximum) must be greater than the integer following the keyword OCCURS (that is, the minimum). The compiler assumes the max imum value to be one greater than the minimum value. 1004 .DEPENDING. IS OMITTED IN THE .OCCURS. CLAUSE. In a variable occurrence table declaration, the keyword DEPENDING has been omitted. The compiler ignores the remainder of the OCCURS clause and treats the table declaration as an ordinary COBOL table. 1005 A DATANAME MUST FOLLOW THE .DEPENDING. KEYWORD. In a variable occurrence table declaration, a valid data-name is not found following the keyword DEPENDING. The compiler ignores the remainder of the OCCURS <clause and treats the table declaration as an ordinary COBOL 1006 .OCCURS DEPENDING. SUBORDINATE TO AN table. .OCCURS. The compiler detects a table declaration with a DEPENDING ON phrase subordinate to a group item that has an OCCURS clause. The compiler ignores the DEPENDING ON phrase and treats the declaration as an ordinary COBOL table. 1007 MAXIMUM NO. TABLE OCCURRENCES MUST BE POSITIVE. table occurrence variable a In integer following the the declaration, must maximum) keyword TO (that is, the compiler The zero. than greater be assumes the maximum wvalue to be one greater than the integer value following the is, (that OCCURS keyword the minimum). 1010 EXPECTED .DEPENDING ON. DATANAME NOT DEFINED. The data-name referenced in a DEPENDING ON phrase was not defined in the DATA DIVISION. Fatal. DIAGNOSTIC ERROR MESSAGES D-65 1011 EXPECTED .ASCENDING KEY. DATANAME NOT The data-name KEY phrase DIVISION. 1012 EXPECTED .DESCENDING KEY. NOT not the DATA Fatal. . RENAMES. APPLIED TO AN INVALID in the LEVEL DATA OF The RENAMES renaming of . DEPENDING ON. DATANAME CLAUSE ON A The data The compiler detects a data-name, follows a DEPENDING ON phrase and defines the current number that that of DETECTED TABLE WITHIN KEY TABLE. NOT a variable occurrence its storage allocated of the table. Fatal. DATANAME. compiler DESCENDING DOES the level 77, or 88. entire RENAMES ' The TABLE Fatal. clause specifies data items whose detects OCCURS clause been declared .SEARCH ALL. DEPENDING a numeric DATA. occurrences 1in table, to have within the range .OCCURS. a as DIVISION. number 1is 01, 66, compiler ignores the description entry. 1017 in DEFINED. data-name referenced in phrase was not declared integer 1016 an ASCENDING .DEPENDING ON. DATANAME NOT A NUMERIC INTEGER. The ON 1015 in defined data-name referenced in a DESCENDING phrase was not defined in the DATA DIVISION. 1014 referenced was Fatal. DATANAME The KEY 1013 DEFINED. HAVE on as KEY. the a of an data item that an ASCENDING presence has or Fatal. KEYS. The table being searched by a SEARCH ALL statement must have the ASCENDING KEY or DESCENDING KEY phrase declaration. Fatal. 1020 IMPERATIVE STATEMENT EXPECTED DURING A period was or found environment statement. D-66 DIAGNOSTIC ERROR MESSAGES specified in its .SEARCH. a non-imperative where is the expecting Fatal. statement SEARCH statement an imperative 1021 KEYS SPECIFIED FOR .SEARCH ALL. NOT DENSE. When a key is referenced for the SEARCH ALL statement, all preceding keys in the KEY clause of the table declaration must also be 1022 .WHEN. EXPECTED BUT NOT FOUND IN referenced. Fatal. .SEARCH. to failed but expected compiler The recognize the WHEN keyword while Fatal. compiling the SEARCH statement. 1023 THE KEYWORD .WHEN. ILLEGAL IN THIS CONTEXT. The compiler detects the presence of the WHEN outside the environment of keyword the 1024 THE KEYWORD .SEARCH. SEARCH statement. Fatal. ILLEGAL IN THIS CONTEXT. the While compiling a SEARCH statement, compiler detects the presence of another SEARCH second The statement. SEARCH statement 1is detected at a point where an imperative statement 1is expected. Fatal. 1025 KEY MUST BE SUBSCRIPTED BY FIRST INDEX OF TABLE. The SEARCH ALL statement requires that the key referenced on the left side of the simple condition must be subscripted by the first index name of the table being 1026 THE KEYWORD .SENTENCE. searched. EXPECTED AFTER Fatal. .NEXT.. The keyword SENTENCE was not detected after the NEXT keyword during the compilation of a SEARCH statement. Fatal. 1027 TABLE NAME NOT FOUND AFTER .SEARCH. VERB. The compiler failed to recognize a valid table data item after the keyword SEARCH or 1030 INVALID TABLE REFERENCE IN SEARCH ALL. .SEARCH. Fatal. STATEMENT. following The table data item reference the SEARCH or SEARCH ALL verbs must have both the clauses INDEXED BY specified declaration. and the in OCCURS its Fatal. DIAGNOSTIC ERROR MESSAGES D-67 1031 DATANAME EXPECTED AFTER .VARYING. IN .SEARCH. No data-name reference was found the VARYING keyword in the statement being compiled. Fatal. 1032 . VARY ING. ITEM MUST BE INDEX OR after SEARCH INTEGER. The data-name reference following the VARYING keyword must be an index data item, an index-name, or an elementary, numeric, 1integer data-name reference. Fatal. 1033 .SEARCH ALL. DATA ITEM IS NOT A KEY. The data item referenced on the left side of the SEARCH ALL simple condition must be declared as an ASCENDING or DESCENDING 1034 DATA ITEM NOT A KEY FOR THIS KEY. .SEARCH. Fatal. TABLE. The data item referenced on the left side of the SEARCH ALL simple condition is not a key for the table being searched. Fatal. 1035 . RENAMES. SPECIFIES RENAMING OF A COBOL TABLE. The RENAMES clause specifies the renaming of an item that has an OCCURS clause 1in its declaration or is subordinate to another item having an OCCURS clause. The compiler ignores the entire RENAMES data description entry. 1036 . RENAMES. APPLIED TO VARIABLE LENGTH DATAITEM. The compiler detects an application of the RENAMES <clause to a range of data items that contains a data item whose length is wvariable at run-time because is has a subordinate data item whose data description entry contains an OCCURS DEPENDING ON clause. The compiler ignores the entire RENAMES data description entry. 1037 DATANAME OMITTED AFTER 66 LEVEL NUMBER. The data-name declaration is omitted after a 66 level number. The compiler ignores the entire RENAMES data description entry. D-68 DIAGNOSTIC ERROR MESSAGES 1040 .RENAMES. OMITTED IN LEVEL 66 DESCRIPTION ENTRY. The RENAMES keyword is omitted 1in a level 66 data description entry. The compiler ignores the entire 1level 66 data description entry. 1041 SEARCH KEY NOT SUBORDINATE TO TABLE. The compiler detects an ASCENDING or DESCENDING data-name key that 1is not defined as a data item subordinate to the associated SEARCH table. 1042 INVALID OR MISSING DATANAME AFTER .RENAMES.. The data-name 1is missing after the RENAMES keyword or, if present, is not recognized as a valid data item that was previously defined. ignores the entire description entry. The compiler RENAMES data ITEM NOT ALLOWED BETWEEN TABLE AND KEY. 1043 item data a detects compiler The clause OCCURS an with declared of "sandwiched" between the declaration table and its associated COBOL another SEARCH 1044 . RENAMES. SPECIFIES key. INVALID NOMENCLATURE RANGE. In processing the RENAMES clause, the compiler detects an invalid nomenclature range specified by identical data-names following the RENAMES and THRU keywords, respectively. The compiler ignores the entire RENAMES data description entry. 1045 . RENAMES. SPECIFIES STORAGE OVERLAP ON LEFT END. In processing the RENAMES clause, the compiler detects the condition in which the beginning of the storage allocated to the data-name after the THRU keyword is to the left of the beginning of the storage allocated to the data-name after the RENAMES keyword. The compiler ignores the entire RENAMES data description entry. DIAGNOSTIC ERROR MESSAGES D-69 1046 INVALID OR MISSING DATANAME AFTER .THRU.. In specifying the RENAMES <clause, a data-name 1is missing after the THRU keyword or, if present, is not recognized as a valid data item that was previously defined. The compiler ignores the entire RENAMES data description entry. 1047 DATANAME MISSING AFTER .CORRESPONDING. In the or processing MOVE of an CORRESPONDING ADD, SUBTRACT, statement, the compiler detects the omission of a valid data-name reference after the CORRESPONDING keyword. Fatal. 1050 .TO. OR .FROM. OMITTED IN .CORRESPONDING.. In the or processing MOVE compiler detects or FROM keyword. 1051 INVALID OR MISSING DATANAME In AFTER the or of .TO. OR ADD, 1052 NO OBJECT CODE PRODUCED FOR In FROM. of an CORRESPONDING the processing MOVE of an CORRESPONDING ADD, NOT REFERENCED IN In SUBTRACT, statement, ADD, SUBTRACT, statement, containing the This diagnostic is the processing MOVE of an CORRESPONDING ADD, SUBTRACT, statement, compiler discovered that one references is a reference elementary item. Fatal. LEVEL 66 REFERENCE DISALLOWED In or IN the DIAGNOSTIC ERROR MESSAGES the of to the an .CORRESPONDING. processing MOVE compiler D-70 the because between 1in the .CORRESPONDING. or 1054 the of a valid keyword TO object code was found referenced COBOL statement CORRESPONDING option. informational only. ITEM TO Fatal. compiler produced no no "correspondence" the two group items GROUP the the .CORRESPONDING. or 1053 of .FROM. compiler detects the omission data-name reference after the or SUBTRACT, statement, the omission Fatal. processing MOVE an CORRESPONDING of an CORRESPONDING detects a ADD, SUBTRACT, statement, reference the to a data-name declared an 1055 .FILE STATUS. ITEM DEFINED invalid IN at level reference. .FILE 66. This 1is Fatal. SECTION. A data-name referenced in a FILE STATUS phrase of a SELECT clause is defined in the FILE SECTION of the COBOL program. The compiler ignores this error and continues to process the FILE STATUS data-name. 1056 INCOMPATIBLE OPERANDS FOUND IN .CORRESPONDING. In the processing of an ADD, SUBTRACT, or MOVE CORRESPONDING statement, the compiler detects a pair of CORRESPONDING data items that are incompatible. This diagnostic is informational only. 1057 EMPTY .GO TO. WAS NOT THE SUBJECT OF AN .ALTER.. A GO TO statement without a procedure reference was detected. The empty GO TO is not the subject of an ALTER statement. Fatal. 1060 QUALIFIER OMITTED IN PROCEDURE REFERENCE. A section name 1is omitted after the keyword OF or IN in a qualified procedure reference of the COBOL statement being compiled. Fatal. 1061 INCONSISTENT NUMBER OF ARGUMENTS IN .CALL.. The subprogram referenced in this CALL statement has been referenced before. The number of arguments in the earlier CALL differs from the number 1in the current 1062 PARAGRAPH WITHOUT SECTION CALL. PRECEDES THIS SECTION. In a COBOL program, if one paragraph is in a section, then all paragraphs must be in sections. 1In this source program, a paragraph not within a section has been detected preceding this section 1in the 1063 DUPLICATE PARAGRAPH NAME source program. DETECTED. In a section of the Procedure Division, a paragraph name is defined more than once and is not uniquely referenceable even with qualification. DIAGNOSTIC ERROR MESSAGES D-71 1064 REFERENCE TO UNDEFINED PROCEDURE NAME. The compiler undefined PROCEDURE 1065 UNDEFINED PROCEDURE detects a procedure reference to name in an the DIVISION. QUALIFIER REFERENCE. The compiler detects a qualified reference that contains an undefined qualifier in the PROCEDURE procedure DIVISION. 1066 ILLEGAL PROCEDURE NAME REFERENCE. The compiler detects an name reference procedure PROCEDURE 1067 AMBIGUOUS PROCEDURE NAME DIVISION. REFERENCE. The compiler in the procedure name not uniquely referenceable, qualification. even PROCEDURE that is through 1070 PARAGRAPH NAME invalid the in DISALLOWED AS detects DIVISION a reference to a QUALIFIER. The compiler detects a qualified reference in which the is a paragraph name. procedure qualifier 1071 SECTION NAME REFERENCE MAY NOT BE The QUALIFIED. compiler detects a qualified section section procedure reference 1in which a name is qualified by another name. 1072 AMBIGUOUS PARAGRAPH NAME REFERENCE. The compiler in the paragraph name that is not uniquely referenceable, through qualification. even PROCEDURE 1073 POSSIBLE .PERFORM. RANGE detects DIVISION a to reference a VIOLATION. The compiler detects a PERFORM THRU statement 1in which the procedure name following THRU 1is defined before the procedure name following the PERFORM. This condition could a logic problem in the COBOL program being compiled. D-72 DIAGNOSTIC ERROR MESSAGES 1074 NUMERIC PROCEDURE NAME EXCEEDS 30 CHARACTERS. a be to A numeric string that appears 30 exceeds name procedure numeric is string length. The in characters on the right to 30 characters truncated procedure and processing of the numeric name continues. 1075 NUMERIC PROCEDURE NAME CONTAINS DECIMAL POINT. a be to A numeric string that appears a contains name procedure numeric The compiler ignores the decimal point. numeric procedure 1076 .RELATIVE KEY. point decimal of processing the the of with presence proceeds and the name. ITEM DEFINED IN RECORD OF FILE. A data-name referenced in a RELATIVE KEY of a SELECT clause is defined in phrase the record description of the associated KEY 1077 NO. ignores compiler The file. and continues to process the this error RELATIVE data-name. FOR FILE TYPE. OF AREAS DEFAULTS TO MAX. by reserved The number of buffer areas clause is greater than the RESERVE the file the for allowed max imum allocates compiler The organization. one two areas for a sequential file and for relative a file. 1105 UNRECOGNIZED LITERAL TYPE...SYSTEM ERROR The compiler identify a has to failed literal. System properly error. Fatal. 1107 .TO. OR .GIVING. MISSING IN ADD The keyword TO or GIVING was operand second the ‘after statement. 1110 MORE THAN 18. DIGITS IN COMPOSITE. found not ADD an 1in Fatal. TRUNCATING. The length of an arithmetic composite is The composite 18 digits. than greater digits. 18 is truncated on the left to Warning. DIAGNOSTIC ERROR MESSAGES D-73 1111 ONLY ONE DEST ALLOWED AFTER .CORRESPONDING. USE FIRST. More than one destination data-name follows the keyword CORRESPONDING. The compiler warning. 1113 UNSIGNED COMP 3 ITEMS ignores all but the first. ILLEGAL The PICTURE for a COMP-3 contain an S character. item does Fatal. not identifier with 1114 ARGUMENT CANNOT BE PASSED .BY DESCRIPTOR. The compiler detected COMPUTATIONAL JUSTIFIED RIGHT DESCRIPTOR in statement. only 1115 .BY VALUE. ARG. MUST BE by .COMP. An the REFERENCE LONGWORD argument SEPARATE that Such statement an wusage, is being passed USING phrase items can or VALUE. SIGN, of a be or by CALL passed Fatal. INTEGER. passed must by be VALUE in data item a a CALL that is declared with COMPUTATIONAL usage with no V character 1in its PICTURE string. The item must have from five to nine decimal positions; that is, its PICTURE must be in the range 9(5) to 9(9). Fatal. 1116 ARGUMENT OMITTED AFTER .BY. CLAUSE IN .CALL. The compiler following the VALUE, or BY statement. 1117 .GIVING. ITEM MUST BE .COMP. detected keywords no identifier BY REFERENCE, BY DESCRIPTOR 1in a CALL Fatal. LONGWORD INTEGER. The 1identifier following the keyword GIVING in a CALL statement must be declared with COMPUTATIONAL usage with no V character 1in its PICTURE string. The item must have from five to nine decimal must be Fatal. 1121 .SEARCH. VERB NOT Because of an (warning or fatal), Fatal. DIAGNOSTIC is, its PICTURE 9(5) ¢to 9(9). PROCESSED process D-74 positions; that in the range ERROR MESSAGES the SEARCH earlier the diagnostic compiler statement cannot completely. APPENDIX E RUN-TIME ERROR MESSAGES This appendix describes error messages that are produced by the COBOL-74 run-time system (RTS). Run-time messages look like this: $C74-F-CODE, TEXT [string-1] [(string-2)] [string-3] where: $C74 F CODE is the facility code for VAX-11 COBOL-74 All (fatal). is the severity level are RTS errors fatal. is the mnenomic composed of the first three characters of the first three words of the RTS error message. TEXT is the body of the error message string-1 is the character string specified in VALUE OF (string-2) string-3 1ID clause is the literal used in SELECT...ASSIGN entry is the printed itself. RMS on error the message, 1line after this the messages 1is error message Associated with each error is an eight digit hexadecimal status code (enclosed 1in parenthesis). The status code is not printed with the run-time message, however. You can use this <code to check the completion status of DCL commands within an indirect command procedure or batch file. For example, consider the following program: 00001 00002 IDENTIFICATION PROGRAM-ID. DIVISION. 00003 SUBERR. 00004 00005 ENVIRONMENT DIVISION. SOURCE-COMPUTER. VAX-11. 00006 OBJECT-COMPUTER. 00007 SPECIAL-NAMES. 00008 CONSOLE 00009 DATA 00010 00011 WORKING-STORAGE 01 T-NUMBER 00012 00013 00014 01 | 01 IS CONSOL. DIVISION. SECTION. TABLE-VALUES. 03 FILLER 03 FILLER 00015 00016 00017 00018 00019 00020 VAX-11. 03 03 03 FILLER FILLER FILLER PIC 9. PIC PIC X(5) X(5) VALUE VALUE "ONE "TwO PIC PIC PIC X(5) X(5) X(5) VALUE VALUE VALUE "THREE". "FOUR ". "FIVE ". T-VALUES 03 REDEFINES TABLE-VALUES. TAB-VAL OCCURS 5 TIMES INDEXED BY 05 FILLER PIC XXXXX. DIVISION. 00021 PROCEDURE 00022 00023 MAIN SECTION. PARA. 00024 00025 00026 DISPLAY "ENTER NUMBER : " UPON NO ADVANCING. ACCEPT T-NUMBER FROM CONSOL. 00027 00028 00029 IF T-NUMBER = 0 GO TO FINISH. SET T-INDEX TO T-NUMBER. 00030 00031 00032 DISPLAY TAB-VAL (T-INDEX) GO TO PARA. UPON ", "“. T-INDEX. CONSOL CONSOL. FINISH. 00033 DISPLAY 00034 STOP "*** END OF SESSION ***" QUPON CONSOL. RUN. The program will prompt you for input - numbers from 1 to 5 (0 will cause the program to terminate). If you enter any other number, the program will abort, and the RTS will print "Subscript or index out of range". If you run SUBERR from your terminal, you could restart the program and continue. If you run SUBERR as part of a command procedure or batch Jjob you could not restart the program from your terminal. You can, however, include commands in the file to test the completion status of the program and take action: E~-2 RUN-TIME ERROR MESSAGES »nLaunannnnnnWn ASSIGN SET 'Pl COBSCONSOLE NOON AGAIN: RUN SUBERR IF SSTATUS .EQ. $X101D800C THEN GOTO WRITER EXIT WRITER: | WRITE SYSSOUTPUT "Index must be less than 6 - type 0 to quit"” GOTO AGAIN NOTE The parameter line 'Pl "ASSIGN..." 1in command allows you specify a device at run-time. to If you include the preceding commands in a file named link SUBERR with the /NOTRACEBACK qualifier, and procedure, the following will appear at your terminal: CHECKER.COM, execute the @CHECKER OPAQ: ENTER NUMBER You could now : input ENTER NUMBER : a number from the system console: 3 THREE ENTER NUMBER : If you enter a number other than appear on the 0 through 5, the following will terminal: ENTER NUMBER : 3 : 6 THREE ENTER NUMBER $C74-F-SUBOUTRAN, subscript out of Index must be less than 6 - type 0 ENTER NUMBER range to quit : See the VAX/VMS Command Language User's Guide for a full discussion of command The procedures remainder BADFILNAM, bad of and batch jobs. this appendix file name describes string-1 the run-time error messages. (string-2) (001D8OE4) The file specification and/or associated switches for a file description are syntactically incorrect. RUN-TIME ERROR MESSAGES E-3 CLOERRFIL, (001D8094) CLOSE error on file string-1 (string-2) string-3 The execution of a CLOSE failed. The accompanying RMS further COMGENABO, compiler generated specifies the statement error code error. abort (001D8034) The run-time part of the errors. system tried program that See DELETE error on file (001D80CC) string-l execute your source (string-2) string-3 listing. DELERRFIL, to contains The execution of a DELETE failed. The accompanying RMS further ERRACC, error in ACCEPT logical-name specifies the a fatal program statement error code error. string-3 (001D810C) An error occurred a record from while the logical-name. The further specifies the "SHOW TRANSLATION use to trying file to ACCEPT associated RMS error error. logical-name" determine the code can value logical-name. ERRCLOUNI, error in CLOSE UNIT (001D8084) or REEL on string-1 The error in DISPLAY (001D8104) logical-name An exponent too a statement CLOSE that RMS error error. UNIT failed. code or The further string-3 error DISPLAY EXPTOOLAR, of string-3 executed REEL accompanying specifies the ERRDIS, be file (string-2) program CLOSE with occurred a associated with error further code while record from trying the logical-name. specifies The the to file RMS error. large (001D8054) The exponent used in out of range. -32768 to 32767. is E-4 RUN-TIME ERROR MESSAGES a COMPUTE statement The legal range is FILALROPN, file string-1 already open (001D805C) The program tried to open a file that 1is currently open. FILPRELOC, file string-1 previously locked (string-2) (001D807C) for file The program tried to access a a executed previously had it which CLOSE...WITH LOCK statement. FINNOTOPN, file string-1 not open (001D8064) The program access a tried file otherwise to CLOSE or not currently is that open. INVDECDAT, invalid data in decimal data-item <address-of-error> (001D8114) 1invalid contains item Numeric DISPLAY non-numeric as such value, data signs. separate invalid or character DISPLAY items must be initialized before use. The INSPECT statement can to wused be clean-up invalid data in existing files. INVLINVAL, invalid LINAGE value on file string-1 (string-2) (001D80A4) body The LINAGE clause specifies a page results in an invalid value; that size the value is not greater it is out of range. INVOPEFIL, invalid operation on file string-1 than oOr zero, (string-2) (001D806C) the The program tried to execute one of following I/O statements for a file that is open in an incompatible mode: a file open for OUTPUT (a) a READ for (b) a WRITE (c) an I/O operation not consistent (for organization file the with sequential a on START example, for a file open for INPUT file). RUN-TIME ERROR MESSAGES E-5 NOEOFPRO, no EOF processing on file string-1 (001D8OAC) (string-2) An end-of-file detected, but the condition has been I/0 statement does not have an AT END clause, and the program has no USE procedure for end-of-file processing. NOTPONOPR, (001D809C) file string-1 (string-2) The not open program statement NULGOTO, GO TO executed has not been (001D802C) The of arguments in a to file execute that is an not I/0 open. ALTERed program reached CALL an before procedure number operation tried for statement NUMARGCAL, for alterable assigning GO TO it a name. incorrect (001D8044) The number of arguments received by a subprogram does not agree with the expected number of arguments; that 1is, COBOL the in as number of CALL statement the calling program is not the number PROCEDURE called OCCDEPVAL, OCCURS DEPENDING value of DIVISION arguments the arguments USING phrase same in the of the program. out of range (001Dp8014) The value of the size table size clause. OPNCOBIN, error opening logical-name (001D8OFC) An for the data item of the table range specified error opening error occurred ACCEPT the logical-name (001D80F4) An as while file RUN-TIME ERROR MESSAGES the OCCURS error trying to associated RMS error error. open with code string-3 occurred DISPLAY the while trying to open file associated with logical-name. The further specifies the E-6 in string-3 logical-name. The further specifies the OPNCOBOUT, that defines 1is not in the RMS error. error code OPNERRFIL, (001D80O8C) OPEN error (string-2) on file string-1 string-3 statement OPEN an of execution The The accompanying RMS error code failed. further PERCOUTOO, PERFORM counter specifies the error. too large (001D804C) used The value of the iteration counter in a PERFORM statement exceeded 32767. REAERRFIL, (string-2) string-3 READ error on file string-1 (001D80B4) statement READ a of execution The The accompanying RMS error code failed. further REANOTPRE, (001D8074) read specifies the error. not preceeded by rewrite or string-1 The delete on file (string-2) program attempted to execute a a for statement DELETE or REWRITE sequentially accessed file, but the last file was not a the operation on 1/0 READ. RECCALDET, recursive CALL detected (001D803C) «call to attempted subprogram A COBOL y. indirectl or directly either itself, be EXIT PROGRAM statement must The the subprogram before in a executed subprogram can be called again. RECPERDET, recursive PERFORM detected (001D8024) The program attempted to execute a PERFORM statement whose exit is also the exit of a previously executed PERFORM that is still active. RETEXTOUT, PERFORM exited out of order (001D801C) The program reached the end of an active PERFORM while processing a more recently program that is, the executed PERFORM; executed a PERFORM statement whose range PERFORM the of end the overlaps statement that is currently being executed. RUN-TIME ERROR MESSAGES E-7 REWERRFIL, REWRITE error on file string-1 (001D80C4) (string-2) string-3 The execution of a REWRITE failed. The accompanying RMS further SAMAREUSE, SAME AREA already in (001D8OEC) STAERRFIL, use specifies when string-1 START error on opening program uses the open file. file error. file (string-2) The string-l (001D80D4) the tried same to OPEN buffer (string-2) a file area subscript (001D80O0C) or index out of The the subscript value value of an greater UNLOCK error (001D8ODC) on file than string-1 An that another statement error code range zero, the maximum number table data item. UNLERRFIL, as string-3 The execution of a START failed. The accompanying RMS further specifies the error. SUBOUTRAN, statement error code for a data item, index-name, 1is or it of occurrences (string-2) unsuccessful is greater or not than of the made to string-3 attempt has been unlock a record in the file. The accompanying RMS error code further specifies the error. WRIERRFIL, (001D8OBC) WRITE error on file string-1 The (string-2) string-3 execution of a WRITE failed. The accompanying RMS further specifies the error. E-8 RUN-TIME ERROR MESSAGES statement error code APPENDIX INTERNAL COMPILER ERRORS F -- SYSTEM ERRORS This appendix lists errors that the VAX-11] COBOL-74 compiler if it System errors have the following C74 -- displays aborts. form: SYSTEM ERRORXXXXXX where: XXXXXX is a six digit error code. ERROR MESSAGE 000000 NO MORE AVAILABLE DISK SPACE The Work File system has available disk space. The ad. compiler UNRECOGNIZABLE SOURCE longest are available, submit FILE compiler could source file because: The a. the all contiguous disk area available up to 1024 64-word blocks. If 1less than 1000 blocks remain, clear the disk and start again. If 1000 blocks a smaller job. 000604 uses exhausted not process the /ANSI FORMAT qualifier was not used, and source program is not 1in terminal reference format. IDENTIFICATION missing The following compiler: errors represent internal 000017 TOO MANY PROCEDURE NAMES 000020 TOO MANY PROCEDURE NAMES 000065 TOO MANY LITERALS 000077 COMMAND 000115 BLOCK DATA NAME TOO table overflow in the LARGE a. A Procedure too large handle. b. Reduce used in TABLE OVERFLOW the the Division for the number of statement. statement compiler |is to identifiers The following errors occur if compiler malfunctions. You the operating system or the COBOL-74 should submit a Software Performance Report errors. (SPR) for any of these NOTE You should include the source program in machine readable form for any SPR you submit. 000001 000002 000003 INTERNAL WORK FILE ERROR INTERNAL WORK FILE ERROR INTERNAL WORK FILE ERROR 000004 000005 000011 000012 000013 BAD USAGE ELT ALREADY INTERNAL ALLOCATION 000014 000015 000016 000021 INTERNAL WORK 000023 000035 000036 000037 000055 000063 000070 DEALLOCATED INSUFFICIENT CORE INSUFFICIENT CORE ATTEMPT TO INVALID FILE FILE PROCESS ERROR ERROR MORE ELSE'S THAN IF'S CLASS ERROR IN PROCESSING PROCEDURE TAG TABLE ERROR IN PROCESSING PROCEDURE TAG TABLE WORK FILE SEARCH ERROR INDEX NAME UNDEFINED BY INTERNAL WORK DATA IN 000072 000075 DATA ITEM ERROR IN 000076 EXCEEDED COMPILER ERROR FILE SEARCH ERROR DIVISION SEQUENCE ERROR F-2 CODE SUBSCRIPT STARTING DISPLAY STACK INTERNAL COMPILER ERRORS -- ERROR PROCESSING ON DATA ODD ADDRESS ITEM CAPACITY SYSTEM ERRORS 000100 COMPILER LOOP: 000101 RECORD 000102 ERROR 000104 INVALID USAGE CODE ILLEGAL LEVEL NUMBER 000105 000106 000111 000112 000116 000120 000121 000122 000123 000124 000125 000126 000127 000130 000131 000132 000133 000134 000135 000140 000140 000141 000150 000151 000201 000201 000202 000204 000220 000221 000230 000231 000232 000233 000234 000997 000999 005000 005001 005002 005003 005004 005005 005006 005007 005010 005011 005012 005013 005014 005015 TOO PROCESSING IN ITEM MANY LOGIC SUBORDINATE ITEMS ERROR PROCESSING LOGIC LEVEL 01 READ BUT DOES NOT VALIDATE ERROR IN EDITED ITEM ILLEGAL TYPE DATA ITEM RESERVED WORD TABLE ERROR DELIMITED SENDING ITEM .NOT FOUND FOR STRING CMD ERROR IN DELIMITED SENDING ITEM FOR STRING CMD SENDING ITEM NOT FOUND FOR STRING CMD ERROR IN TALLYING DATA ITEM FOR UNSTRING ERROR IN DELIMITED RECEIVING ITEM FOR UNSTRING ERROR IN RECEIVING ITEM FOR UNSTRING ERROR IN DELIMINTED SENDING ITEM FOR UNSTRING DELIMITED SENDING ITEM FOR UNSTRING DELIMITED SENDING ITEM FOR UNSTRING INSPECT TALLYING ERROR INSPECT TALLYING BEFORE/AFTER ERROR INSPECT INSPECT REPLACING REPLACING ERROR ERROR INSPECT REPLACING BEFORE/AFTER INITIAL ERROR EXTENDED NAME TABLE ERROR SAME AREA RECORD CLAUSE ERROR SAME AREA RECORD CLAUSE ERROR INTERNAL STACK ERROR CORRESPONDING ERROR STACK ERROR MESSAGE PROCESSING ERROR OCCURS FRT KEY DEPENDING ON CLAUSE ERROR INDEX DATA ITEM NOT FOUND ERROR IN DESTINATION FOR SEARCH WORK FILE READ ERROR INVALID IBF FLAG READ WORK FILE READ SEQ. ERROR ERROR IN ALTER PROCESSING INVALID LINKAGE SECTION ITEM WORK FILE SEARCH ERROR INTERNAL INTERNAL ILLEGAL ILLEGAL ILLEGAL ILLEGAL ILLEGAL ILLEGAL DIVIDE ERROR ERROR OPERATOR FOR BOOLEAN OPERATION USAGE FOR OPERANDS IN RELATIONAL CODE USAGE FOR OPERANDS IN RELATIONAL CODE NUMERIC COMPARISON LITERAL IN ARITHMETIC OPERATION USAGE FOR DIVIDE OPERAND ERROR ILLEGAL USAGE MULTIPLY FOR MULTIPLY OPERAND ERROR ILLEGAL USAGE FOR ARITHMETIC ADD/SUBTRACT ERROR ILLEGAL ARITHMETIC ILLEGAL COMPARE INDEX PROBLEM IN OPERAND OPERATOR FOR SEARCH ALL TABLE INTERNAL COMPILER ERRORS -- SYSTEM ERRORS F-3 APPENDIX G PROGRAMMING EXAMPLES The This appendix contains examples of VAX-1l1] COBOL-74 programs. to intended are they ; applications real programs do not represent suggest useful techniques and their implementation with COBOL-74. CALLING A FORTRAN SUBROUTINE G.l COBOL-74 modules can be linked with other VAX-1l1l native-mode modules, even if they were written in other languages. This capability 1is often useful, especially when a feature is not available in COBOL-74, One example is the square root is available in another language. but COBOL-74 function, which is not available in (non-integer exponents are not allowed). G.1l.1 The COBOL Program, GETROOT - This program accepts a value from the terminal, calls the FORTRAN and passes the value as a character string (BY SQROOT, subroutine, It then displays DESCRIPTOR, because that is how FORTRAN expects it). the result. therefore, COBOL-74 does not support the floating point data type; Note the FORTRAN subroutine returns the result as a character string. that because the result is a character string with a decimal point, the program uses a MOVE CORRESPONDING to place it in a numeric data the returned The second DISPLAY shows the result of editing item. value. An INSPECT statement replaces all space characters in the result by space characters would cause a reserved operand fault when the zeros; MOVE statement was executed. IDENTIFICATION DIVISION. PROGRAM-ID. GETROOQT. INSTALLATION. DIGITAL EQUIPMENT CORPORATION. khkkkkhkhkkkhkkkkkhkkhkkkkhkkkkkhkkhkhkkkkkkhkkkkkhkkkkkkkk * * * This program demonstrates the use of the * * * * statement in calling FORTRAN-IV-PLUS It calls a FORTRAN subprogram which returns the square root of the argument. CALL programs. * * * * * * * * khkkhkhkkhkhkhkhkhkkhkhkhkhkhkhkhkkkhkhkhkhkhkhkhkhkhkhkhkhkhkdhhkkhkihkkihkkk * ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. OBJECT-COMPUTER. DATA DIVISION. WORKING-STORAGE 01 SECTION. INPUT-NUMBER. 03 03 03 01 VAX-11. VAX-11. INTEGER DEC-POINT DECIMAL PIC PIC PIC 9(5). X(1). 9(8). WORK-NUMBER. 03 INTEGER 01 PIC 9(5). 03 DECIMAL PIC 9(8). WORK:NUMBER—A REDEFINES WORK-NUMBER 01 DISPLAY-NUMBER PROCEDURE STARTER PIC PIC 9(5)Vv9(8). 2Z2,2Z29.9999. DIVISION. SECTION. SBEGIN. MOVE SPACES TO DISPLAY "Enter INPUT-NUMBER. number (with decimal point): " NO ADVANCING. ACCEPT INPUT-NUMBER. IF INPUT-NUMBER GO TO = SPACES ENDJOB. CALL "SQROOT" USING BY DESCRIPTOR INPUT-NUMBER. IF INPUT-NUMBER = ALL "#*" DISPLAY "** INVALID ARGUMENT FOR SQUARE ROOT" ELSE DISPLAY "The INSPECT INPUT-NUMBER square REPLACING ALL MOVE " CORRESPONDING " root BY is: " INPUT-NUMBER "O" INPUT-NUMBER TO WORK-NUMBER MOVE WORK-NUMBER-A TO DISPLAY-NUMBER DISPLAY DISPLAY-NUMBER. GO TO SBEGIN. ENDJOB. STOP G-2 RUN. PROGRAMMING EXAMPLES The FORTRAN Program, SQROOT G.1.2 This subroutine accepts a l4-character string, decodes it into a real variable (DECODE is analogous to an internal READ). It then calls the SQRT function in the statement that encodes the result into the l4-character argqument. SUBROUTINE SQROOT (ARG) CHARACTER*14 ARG VAL DECODE (14,10 ,ARG,ERR=20) FORMAT (F12.6) IF(VAL.LE.0.)GO TO 20 10 (VAL) SQRTRG) ENCODE (14,10,A 999 20 RETURN kk ARG='**kkkkhkhkkhhk! GO TO 999 2 END Sample Run of GETROOT G.1.3 S RUN GETROOT <CR> Enter number (with decimal point): 5.000000 The square root is: 5.0000 <CR> 25. Enter number (with decimal point): HELLO <CR> Enter number (with decimal point): 1000000. <CR> ** TNVALID ARGUMENT FOR SQUARE ROOT The square root is: 1000.000000 1,000.0000 Enter number (with decimal point): 1.414214 The square root 1is: 1.4142 Enter number (with decimal point): 2. <CR> <CR> $ PROGRAMMING EXAMPLES G-3 G.2 The CALLING VAX-11l VAX-11 purpose Common and RUN-TIME PROCEDURES Run-time Procedure language- spe01f1c using the VAX-11 procedure callable by COBOL-74. The procedures are Library Reference G.2.1 The character example). calling described in the contains The standard; VAX-1l COBOL Program, two sets procedures therefore, Common Manual. This program calls and FORSDATE. LIBSMOVTC Library procedures. Run-Time of general are written they Procedure RUNTIME procedures in the Run-Time Library: LIBSMOVTC uses a translation table to translate each character in a string from one code form to another (EBCDIC to ASCII, for This program uses LIBSMOVIC to translate all 1lower-case characters to upper case that LIBSMOVTC expects Note and all all IDENTIFICATION PROGRAM-ID. non-graphic to be parameters FORSDATE returns the system date as a it expects the string to be passed by 9-character reference. characters to spaces. by descriptor. passed string. Note DIVISION. RUNTIME. kkkkkkhhkhkkhhkhkhkhkhkhkkhkhkhkhkhhkhkhhhhkhkhkhkhkkkkkkkhhhkhhhkkk * * * * * This program demonstrates the method calling VAX-11l Run-time Procedures. for * * * khkkkkkhkhkkhhkhkkhkhkhkkhkhkhkhkhhkhkhkhhkhkhkhhkhkhkhkkkhhkkhhkkhhkhkkk DATE-COMPILED. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. VAX-11. OBJECT-COMPUTER. DATA 01 01 01 01 G-4 VAX-11. DIVISION. WORKING-STORAGE 01 are INPUT-AREA SECTION. PIC X (50). OUTPUT-AREA PIC X(50). FILL-CHAR PIC X VALUE SPACE. TRANSLATION-TABLE. 03 FILLER PIC X(32) VALUE SPACES. 03 FILLER PIC X(24) VALUE " I""#$%&'()*+,-./01234567". 03 FILLER PIC X(24) VALUE "89:;<=>?@ABCDEFGHIJKLMNO". 03 FILLER PIC X(24) VALUE "PQRSTUVWXYZ[\]"~ ‘ABCDEFG". 03 FILLER PIC X(24) VALUE "HIJKLMNOPQRSTUVWXYZ{|}~ ". DATE-AREA PIC X(9). PROGRAMMING EXAMPLES that PROCEDURE DIVISION. STARTIT SECTION. SBEGIN. DISPLAY "Enter string:". MOVE SPACES TO INPUT-AREA. ACCEPT INPUT-AREA. CALL "LIBSMOVTC" USING BY DESCRIPTOR INPUT-AREA FILL-CHAR TRANSLATION-TABLE OUTPUT-AREA. DISPLAY OUTPUT-AREA. CALL "FORSDATE" USING DATE-AREA. DISPLAY DATE-AREA. STOP RUN. Sample Run of RUNTIME G.2.2 S RUN RUNTIME Enter string: How do I love thee? Let me count... 8, 9, A HOW DO I LOVE THEE? LET ME COUNT... 8, 9, A 18-DEC-78 $ G.3 USING TERMINAL ESCAPE SEQUENCES data input It is often useful to design terminal screen forms for ls by using termina You can implement forms on most applications. escape segquences. PROGRAMMING EXAMPLES G-5 G.3.1 The COBOL Program, ESCAPE This program accepts data from a DIGITAL VT52 terminal; it form and guides the operator by using escape-character Other terminals have similar capabilities. builds a sequences. The program defines the ESC character (decimal 27, hex 1B) as a one-word COMPUTATIONAL item, and redefines it as a one-byte data item. The same technique is used for the one-character row and column values required for direct cursor addressing. (Chapter 4 describes the internal format of COMP data items.) The program contains a table that describes the format of the terminal screen. First, the program clears the screen. It then cycles through the table to display the prompts. During a second pass through the table, the program "paints" the input area for each field with underscore characters, and accepts data from the operator. Note the use of the OCCURS ... DEPENDING ON clause in of INPUT-AREA, allowing the variable-length display. IDENTIFICATION the DIVISION. PROGRAM-ID. ESCAPE. khkkkkhkkhkhkhkhhkhkhhhkhkhhkhkhkkhkhhkhkhhkhkhkhkhkhkhhkhkhhhkhkhkkhk kkkkkk * * * This * * through program demonstrates the use of terminal escape gequences, including cursor control, COBOL. * * * * * * khkkhkkkhkhkhkhkhkhkhkkhhkkkkhhkhkhkhhhkhkhkhkhkhkhkhkkkhhkhkhkhkhkkhhkkkkk * DATE-COMPILED. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. VAX-11. OBJECT-COMPUTER. DATA VAX-11. DIVISION. WORKING-STORAGE 01 SECTION. INPUT-AREA. 03 IACHAR PIC X(1) OCCURS DEPENDING 01 IASUB 01 PIC ON 9(2) 1 TO FIELD-TABLE. FILLER PIC X(24) VALUE "050830NAME:". FILLER PIC X(24) VALUE "012024ADDRESS:". FILLER PIC X(24) VALUE "180106CODE NUMBER:". 03 FILLER PIC X(24) VALUE "166010PHONE:". FIELD-TAB-A REDEFINES FIELD-TABLE. 03 FIELD-TAB-ENTRY OCCURS 4 TIMES. 05 ROW PIC 9(2). 05 COLUM PIC 9(2). 05 FIELD-LENGTH PIC 9(2). 05 G-6 TIMES COMP. 03 03 03 01 30 IASUB. PROMPT PROGRAMMING EXAMPLES PIC X(18). description 9(3) COMP. 01 ROW-VALUE PIC 01 COLUM-VALUE PIC 9(3) 01 01 ESCAPER PIC 9(3) COMP VALUE 27. ESCAPE-C REDEFINES ESCAPER PIC X(1l). 01l CTR PIC ROW-VALUE-C REDEFINES ROW-VALUE PIC X(1). 01l COMP. COLUM-VALUE-C REDEFINES COLUM-VALUE PIC X(1). 01 PROCEDURE 9(2). DIVISION. LOOP. * ESC H moves the cursor to the home position. * ESC J clears from the cursor position to the of end * the screen. DISPLAY ESCAPE-C "H" ESCAPE-C "J". PERFORM PROC-FIELD VARYING CTR FROM 1 BY 1 UNTIL CTR > 4. UNTIL CTR > IF CTR < 90 GO TO LOOP. 4. PERFORM ACCEPT-FIELD VARYING CTR FROM 1 BY 1 STOP RUN. * * *» PROC-FIELD. Compute the row and column values from the table. Also, set the OCCURS DEPENDING item to the length of the prompt. PERFORM COMP-LEN. * Display the prompt. DISPLAY ESCAPE-C "Y" ROW-VALUE-C COLUM-VALUE-C INPUT-AREA NO ADVANCING. ACCEPT-FIELD. * Recompute the prompt location. PERFORM COMP-LEN. * Position the cursor at the end of the prompt. ADD IASUB TO COLUM-VALUE. * Set the OCCURS DEPENDING item to the length of * the expected input entry. MOVE FIELD-LENGTH(CTR) TO IASUB. PROGRAMMING EXAMPLES G-7 Display a string of underscores as the expected input entry. MOVE ALL DISPLAY " " TO " " DISPLAY "Y" COLUM-VALUE-C cursor ESCAPE-C ROW-VALUE-C " to 30 MOVE SPACES the of the "Y" TO item to make INPUT-AREA make INPUT-AREA IASUB. TO INPUT-AREA. input. ACCEPT IF beginning NO ADVANCING. MOVE Input the COLUM-VALUE-C Set the OCCURS DEPENDING its maximum size. Get length INPUT-AREA. Reposition the input area. " same INPUT-AREA. ESCAPE-C ROW-VALUE-C the INPUT-AREA. processing INPUT-AREA MOVE 91 TO code = goes here. "QUIT" CTR. DONOTHING. EXIT. COMP-LEN. * * Set the MOVE 30 % % Escape * OCCURS its maximum so add 31 row to ADD 31 ROW(CTR) 31 COLUM(CTR) the its prompt length by UNTIL to column row GIVING to DONOTHING the TO values column begin with 32, numbers. ROW-VALUE. COLUM-VALUE. display the area, last then determine character (:). FROM 1 INPUT-AREA. VARYING IACHAR(IASUB) PROGRAMMING EXAMPLES and GIVING locating PROMPT (CTR) PERFORM and the ADD Move item IASUB. sequence we MOVE G-8 TO DEPENDING size. = IASUB ":". 1 BY G.3.2 Sample Run of ESCAPE In this example of a screen during the execution of ESCAPE, the has just accepted the name and is waiting for the operator to program enter the address. ADDRESS: NAME: Robert Fried PHONE: CODE NUMBER: PROGRAMMING EXAMPLES G-9 G.4 CALLING VAX/VMS SYSTEM SERVICES System services are procedures that the VAX/VMS to control resources available to processes, operating system uses to allow communication among system processes, Although most system, to system perform services can use many System services Manual. are described G.4.1 you and The of COBOL Program, This program calls two basic are them operating used primarily yourself in by functions. the operating in VAX-11l COBOL-74 programs. the VAX/VMS System Services Reference SYSTSVC system services: S$GETMSG and S$TRNLOG. SGETMSG returns the text of a system message to the caller, using the unique identification number that is assigned to each system message. This program uses $GETMSG to translate the return status from the other system service, STRNLOG. STRNLOG translates string. It also a logical returns one name of and five returns return the status equivalence name codes. The program accepts a logical name from the terminal. It then calls STRNLOG (note that the prefix, §SYS, 1is required) to get the equivalence name. Because the equivalence name could itself be a logical name, the program checks the return status; it repeatedly calls $TRNLOG until the return status indicates that no translation occurred. IDENTIFICATION DIVISION. PROGRAM-ID. SYSTSVC. INSTALLATION. DIGITAL EQUIPMENT CORPORATION. khkkkkkkhkkhkhkhkhkkhkhkhkkkkhkhkhkhkhkhkhkhkkkkhkhkkkhkhhkhkkkkkkkk * : * This program * * CALL statement Services. * demonstrates in the use calling VAX/VMS of the System * * * * * khkkkkhkhkhkhkhkkkhkhkhkhkhkkhkhkhhkhkhkhkkhkkhkhkhkhkkhkkkhkkkhkkkkkkk ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. VAX-11. OBJECT-COMPUTER. G-10 VAX-11. PROGRAMMING EXAMPLES DATA DIVISION. WORKING-STORAGE 01 SECTION. LOG-STRING. 03 LOG-CHAR PIC DEPENDING X OCCURS ON 1 TO 30 TIMES LOG-LENGTH. 01 01 01 LOG-LENGTH PIC 9(2). LOG-NAME PIC X(30). IN-PTR PIC 9(2). 01 01 01 NAME-LENGTH PIC S9(4) COMP. EQUIV-NAME PIC X(30) VALUE SPACES. PHYSICAL-TEST REDEFINES EQUIV-NAME. 03 PT-1-4. 05 05 PT-CHAR PIC X. FILLER PIC X(3). 01 03 PHYSICAL-NAME PIC X(26). ESCAPE-CHAR PIC 9(3) COMP VALUE 01 ESCAPE 01 RES REDEFINES 0l PIC S9(8) COMP. 88 SUCCESSFUL VALUE 1. RESULT-NAME PIC X(30). 01 OUT-LENGTH 01 01 01 PIC Z(4). RESULT-DISP PIC 9(8). DUMMY-ARG PIC S9(9) COMP VALUE MESSAGE-AREA. 03 MESSAGE-CHAR OCCURS DEPENDING ON 01 01 MESS-LEN PIC 9(8) MESSAGE-LENGTH PIC 01 01 MASK PIC 9(8) MSG-VALUE PIC PROCEDURE STARTER 176. ESCAPE-CHAR PIC 1 TO X. 0. 256 TIMES MESSAGE-LENGTH PIC X. COMP. 9(8) COMP. COMP VALUE X(4). IS 15. DIVISION. SECTION. SBEGIN. DISPLAY ACCEPT "ENTER LOGICAL NAME: " NO ADVANCING. LOG-NAME. SLOOP. PERFORM TRANSLATE-LOGICAL-NAME. PERFORM GET-RESULT. IF PT-CHAR MOVE = ESCAPE PHYSICAL-NAME TO RESULT-NAME ELSE MOVE MOVE EQUIV-NAME NAME-LENGTH DISPLAY * * * TO TO LOG-NAME RESULT-NAME. OUT-LENGTH. "= " RESULT-NAME. If the translation was performed, use the result to attempt further translation. IF SUCCESSFUL MOVE GO STOP TO RESULT-NAME TO LOG-NAME SLOOP. RUN. PROGRAMMING EXAMPLES G-11 khkhkhkkhkkkhkhkhkAkkrkhkhhkhkkkhkhkhkhhkhkhhkhkhkhkhkkkkhkhkhkhkhkhkhkkkkkk * * * The following paragraph uses the contents of * * LOG-STRING as an argument to the SYSS$STRNLOG * * System Service. The translated name is placed * * in EQUIV-NAME and the length of -the result * * is in RES-LEN. RES contains the status code %* * from SYSSTRNLOG. * * * * khkhkhkhkhkhkhkkhkkhkkhhkhkhkhkhkhkhhkhkkhkhkhkhkhkkhkkhkkkkhkkkkkhkkkkkk * TRANSLATE-LOGICAL-NAME. MOVE SPACES * TO EQUIV-NAME. Initialize UNSTRING pointer MOVE 1 TO * IN-PTR. Initialize DEPENDING ON subscript MOVE 30 * TO LOG-LENGTH. Create string of exact length UNSTRING LOG-NAME DELIMITED BY INTO * LOG-STRING WITH Fix SUBTRACT * 2 up string FROM POINTER length " " IN-PTR. from pointer. IN-PTR GIVING LOG-LENGTH. Delete colon from logical-name string. IF LOG-CHAR (LOG-LENGTH) = ":" SUBTRACT 1 FROM LOG-LENGTH. CALL "SYSS$TRNLOG" USING BY DESCRIPTOR LOG-STRING, BY REFERENCE NAME-LENGTH BY DESCRIPTOR EQUIV-NAME BY VALUE DUMMY-ARG, DUMMY-ARG, GIVING RES. GET-RESULT SECTION. SBEGIN. MOVE MOVE CALL 256 TO MESSAGE-LENGTH. TO MESSAGE-AREA. "SYS$GETMSG" SPACES USING BY VALUE BY REFERENCE RES BY DESCRIPTOR MESSAGE-AREA BY VALUE MESS-LEN MASK BY DESCRIPTOR MSG-VALUE. MOVE MESS-LEN TO MESSAGE-LENGTH. DISPLAY G-12 MESSAGE-AREA. PROGRAMMING EXAMPLES DUMMY-ARG G.4.2 Sample Run, SYSTSVC $ RUN SYSTSVC ENTER LOGICAL NAME: COBSINPUT $SYSTEM-S-NORMAL, normal successful completion COBSINPUT = SYSSINPUT $SYSTEM-S-NORMAL, normal successful completion SYSSINPUT = TTEl: $SYSTEM-S-NOTRAN, TTEl: no string translation performed = TTE] v \\'\& . $ PROGRAMMING EXAMPLES G-13 INDEX - ACCEPT, 6-26, 6-27, 6-28 Access mode, 6-14 ADD, 4-17 multiple operands, 4-16 /AL:n, file specification switch, 6-22 Alphabetic class, 3-1 Alphanumeric class, 3-1 ALTER, 7-5 Ambiguities, DEBUG, 9-5 /ANSI FORMAT, 2-3 APPLY, 6-17 Arithmetic expression processing, 4-21 temporary work area, 4-21 Arithmetic statements, 4-13 ASSIGN, 6-20 ASSIGN command, 2-12, 6-19, AT END, 6-16, 6-26, 10-7 COBSOUTPUT, 6-28, 6-29 COBSPAPERTAPEPUNCH, 6-27 COBSPAPERTAPEREADER, 6-27 COBSSWITCHES, 2-12, 2-13 Command qualifiers, COMP, CALL, G-1, G-4, G-10 signs, COMPUTATIONAL. See 6-27 VAX/VMS system services, G-10 CANCEL BREAK, DEBUG command, 9-6 CANCEL MODULE, DEBUG command, 9-3 CANCEL SCOPE, DEBUG command, 9-3 CANCEL TRACE, DEBUG command, 9-7 CANCEL WATCH, DEBUG command, 9-8 6-27 COMPUTE, COMP See COMP-3 COMPUTATIONAL-3. VAX-11] tun-time procedures, G-4 4-20 Condition-names, 7-7, 7-8 CONSOLE, 6-27 Constant, figurative, 4-9 CONTINUE command, 2-13 Conventional format, 2-1, 2-3, 7-1, 8-1 corpy, 2-3, 12-1, 12-2 COPY REPLACING, 12-4 /COPY LIST, 2-3 CORRESPONDING, 3-13 COUNT, in STRING, 3-30 CREATE command, 2-2 /CROSS REFERENCE, 2-3 /CROSS_REFERENCE, LINK qualifier, 2-9 CTRL/Y, 2-13 in DEBUG, 9-9 Current record area, Cursor addressing, 6-10 G-6 Data category, 3-1 class, 3-1 movement, 3-7 Data Division size limitation, B-1 3-3 /CL:n, file specification switch, 6-22 Class Data item elementary, group, 3-2 3-2 Data-name limitation, B-1 DEASSIGN command, 2-13 3-1 4-7 /CO:n, file specification switch, 6-22 COBSCARDREADER, 6-27 COBSCONSOLE, 6-27 COBSINPUT, 6-28 COBSLINEPRINTER, 5-4 in a table, Compiler error, 10-3, F-1 Computation, optimizing, 13-9 FORTRAN programs, G-1 data, test, 6-27 2-3 6-24 4-4, 4-3 COMP items 13-8 Category, data, 3-1 Characters, special, compiler, Comparison, 3-6 Compiler command line, 2-2 qualifiers, 2-3 Calling CARD-READER, 4-2, COMP-3, Binary, 4-1 Block, 6-5 physical, 6-5 Blocking, 6-5, 13-9 Breakpoint, DEBUG, 9-5, 9-6 /BRIEF, LINK qualifier, 2-9 Bucket, 6-5, 13-6 Buffer defaults, RMS, 6-13 Buffers, 6-13 multiple, 6-13 sharing, 6-14 Caching index roots, 4-1 /DEBUG, 2-4 DEBUG, 9-1 /DEBUG, /DEBUG, LINK qualifier, 2-10 RUN qualifier, 2-13 Debugging, 9-1 Decimal scaling, DEFINE command, INDEX-1 4-3 2-12, 2-13 INDEX DELIMITED File, BY in STRING, 3-16 in UNSTRING, 3-25 DELIMITER, in UNSTRING, 3-31 DEPOSIT, 9-10 DEBUG command, Device, 6-18 Diagnostic error Directory, 6-18 DISPLAY, 4-1, messages, 6-26, DISPLAY statement DIVIDE, 4-19 6-27, 10-1 6-29 limitation, B-1 /DQ:n, file specification switch, 6-22 /DW, file specification switch, 6-22 Dynamic group item, 5-17 Edited move, 3-10, 4-10 Editing, 4-10, 4-11 Elementary item, 3-2 move, 3-9, 4-9 Entering a source program, I1/0, 2-7 messages, compile-time, diagnostic, 10-1 link-time, 10-5 character, DEBUG Examples, programming, F-1 DEBUG command, 9-10 G-1 9-9 Figurative constant, 4-9 File attribute, 6-1 compatibility, 6-24 design, 13-2 disk, indexed, 6-9 disk, relative, 6-8 disk, sequential, 6-7 handling, 6-1 I/0 interface, in sorting, indexed, 13-3 library, 12-2 magnetic tape, 6-6 name, 6-18 2-3, formats, DEBUG 7-1, 8-1 2-10 A-1l limitation, 9-8 B-1 command, I/0 buffer, error /EXECUTABLE, LINK qualifier, 2-10 Executing a COBOL image, 2-12 EXIT, 2-1, 3-9, 4-8 Group item, 3-2 dynamic, 5-17 G-6 command, 7-1, Group move, G-6 sequences, EXAMINE, GO, 10-1 messages, run-time, 10-5 procedures, 1/0, 10-7 system, compile-time, 10-3, 2-3, programs GIVING, 4-16 GO TO DEPENDING messages, messages, 2-1, 8-1 record, 6-2 reference, 2-1 General 6-25 Escape conventional, calling, G-1 files for, 6-24 /FULL, LINK qualifier, 2-2 6-20 Format terminal, 2-7 message summary, messages, 10-1 ESC (continued) record I/0 interface, in sorting, 11-2 relative, 13-2 sequential, 13-2 sharing, 6-23 specification, 6-17, 6-18, switches, 6~-19, 6-22 type, 6-18 version, 6-18 Files naming, 6-17 opening, 6-14 Fixed-length record, 6-2 FORTRAN Error fatal, (Continued) 6-13 procedures, 10-7 error processing, 6-25 Image execution, 2-12 /INCLUDE, LINK qualifier, 2-11 Index data item, Index-name, 2-10, 5-15 5-16 initialization, 5-14 Index roots, caching, 13-8 Indexed file, 6-9, 13-3 Indexes, 5-13 Indexing, 5-9 relative, 5-14 INSPECT, 11-2 — 5-13, 3-39 Intermediate 4-23 Interrupting results, image, in INVALID 6-16, 6-26, IS, KEY, 7-3 Justified move, INDEX-2 3-11 4-13, 4-22, DEBUG, 10-7 9-9 INDEX Key buffer, Key, sort, in sort, 11-4 11-3 Library facility, 12-1 file, 12-2 /LIBRARY, LINK qualifier, 2-11 Limitations, compiler, B-1l LINAGE, 6-17 LINE-PRINTER, 6-27 LINK command, 2-7, 2-9 LINK qualifiers, 2-9 Link-time error messages, 10-5 Linking, 2-7 /LIST, 2-4 Listing, program, C-1 Literal subscripting, 5-10 /LO, file specification switch, 6-22 Locations DEBUG, resolving ambiguities, 9-5 specifying in DEBUG, 9-4 Logical name, 6-19, 6-20, 6-27 Magnetic tape file, 6-6 /MAP, 2-5, C-2 /MAP, LINK qualifier, 2-10 /MI, file specification 6-23 Mnemonic-name, 6-27 MOVE, 3-8, 4-8 switch, 3-29 Multiple Multiple operands, receiving MULTIPLY, Node, 6-18 /OBJECT, 2-6 Open mode, OPEN 4-1 6-14 statement execution, 6-16 Opening files, 6-14 Optimization, 13-1 Optimizing computation, 13-9 OPTIONAL, 6-16 /OPTIONS, LINK qualifier, 2-12 OVERFLOW in in STRING, 3-18 UNSTRING, 3-36 Packed-decimal, 4-2 PAPER-TAPE-PUNCH, 6-27 PAPER-TAPE-READER, PERFORM, 7-6 Physical block, PIC, 6-27 6-5, 13-9 7-3 7-3 PICTURE, POINTER in STRING, 3-15 in UNSTRING, 3-32 PRINT-CONTROL, 6-17 Procedure-name limitation, B-1 listing, C-1 organization, 13-8 Programming examples, use of, G-1 7-5 Qualification, 7-9 limitation, B-1 Receiving fields, multiple, 3-12 Record 3-13 area, in areas, UNSTRING, 4-16 fields, 3-12 4-18 /NOANSI FORMAT, 2-3 /NOCOPY LIST, 2-3 /NOCROSS REFERENCE, data, Punctuation, edited, 3-10, 4-10 elementary, 3-9, 4-9 group, 3-9, 4-8 justified, 3-11 subscripted, 3-12 CORRESPONDING, Multiple delimiters Numeric Program Move MOVE (Continued) 2-3 /NODEBUG, 2-4 /NODEBUG, RUN qualifier, /NOLIST, 2-4 /NOMAP, 2-5 /NOOBJECT, 2-6 /NOVERB_LOCATION, 2-6 /NOWARNINGS, 2-6 Numeric class, 3-1 2-13 current, 6-10 sharing, 6-11 blocking, 6-5 size, 6-4 Record format, 6-2 fixed-length, 6-2 variable-length, 6-3 VFC, 6-3 Record Management Services, 6-1 Record Unit Size, Reference format, 8-1 6-5 2-1, 7-1, REFORMAT, 8-1 Relation Relative test, 3-4, 4-6 file, 6-8, 13-2 Relative indexing, 5-14 RESERVE, 6-13 Restarting program, in DEBUG, RMS, 6-1 buffer INDEX-3 defaults, 6-13 9-8 INDEX ROUNDED, 4-14 RTS, 2-8 RUN command, 2-13 Run-time error messages, 10-5 procedures, calling, System, 2-8 SAME AREA, SAME RECORD AREA, 6-14, Subscripted fields in INSPECT, 3-47 in STRING, 3-20 in UNSTRING, 3-37 Subscripted move, 3-12 Subscripting, 5-9 G-4 data-name, 5-12 indexes, 5-13 literal, 5-10 SUBTRACT, 4-18 6-16 6-11 Scaling, decimal, 4-3 Scope, DEBUG, 9-3 SEARCH, 5-17, 5-18, 5-19 SELECT, 6-20 Sequential disk file, 6-7 file, 13-2 SET, 5-16 SET BREAK, DEBUG SET LANGUAGE, SET MODULE, SET multiple operands, 4-16 Switches file specification, 6-19, program, DEBUG SYNCHRONIZED, command, 9-2 9- 2 SCOPE, DEBUG command, 9-3 SET TRACE, DEBUG command, 9-6 SET WATCH, DEBUG command, 9-7 record SHOW areas, BREAK, SHOW CALLS, SHOW System 9- 6 switch, command, 9-6 DEBUG command, 9-9 LOGICAL command, 2-13 SHOW MODULE, DEBUG command, 9-3 SHOW SCOPE, DEBUG command, 9-3 SHOW TRACE, DEBUG command, 9-7 SHOW WATCH, DEBUG command, 9-8 Sign test, Signs, 4-4 COMP-3, SIZE 4-7 4-15 keys, Sort subroutines, Report, 11-6 11-1 file I/0 interface, 11-2 record I/0 interface, 11-2 Source listing, C-1 Special characters, 3-3 SPR, F-2 Statements arithmetic, STEP, DEBUG 10-3, System messages, VAX/VMS, 10-4 System services, calling, G-10 Table handling, Tables 5-1 COMP items in, 5-4 defining, 5-1 initializing, 5-7 variable-length, 5-17 TALLYING in in Tape INSPECT, 3-48 UNSTRING, file, 6-6 Temporary 3-34 work area arithmetic expression, 4-21 Terminal escape sequences, G-6 Terminal format, 2-1, 2-3, 7-1, class, 4-7 relation, 3-4, F-2 11-3 SPECIAL-NAMES, compile-time, Test Performance Sort Sorting, error, 2-8 2-8 8-1 4-3 ERROR, Software 5-4 F-1 6-11 DEBUG 6-22 2-13 SYSSLIBRARY:C74LIB/OPT, command, /SH, file specification 6-23 Shar ing buffers, 6-14 2-12, SYSSLIBRARY:C74LIB/LIB, command, DEBUG (Continued) 6-27 9-9 2-10, 9-9, /TRACEBACK, LINK qualifier, Tracepoint, DEBUG, UNSTRING, 3-22 USE procedure, 9-6, 9-7 6-26 5-7 OF ID, 6-20 Variable-length record, 11-6 2-4, 10-6, 10-8 VALUE command, 4-6 4-7 Traceback, VALUE, 4-13 STOP literal, 2-13 in DEBUG, 9-9 STRING, 3-14 Subroutines, sort, sign, table, Variable 6-3 5-17 with control INDEX-4 fixed-length record. See VFC 2-10 INDEX VAX-11l run-time procedures, calling, G-4 VAX-11 Sort, 11-1 VAX/VMS system messages, 10-4 VAX/VMS system services, calling, G-10 /VERB_LOCATION, 2-6, C-2 (Continued) Version, file, VFC, 6-29 VFC record, /WARNINGS, 6-18 6-3 2-6 Watchpoint, DEBUG, /Wléné3file specification INDEX-5 9-7, 9-8 switch, VAX-11 COBOL-74 User’s Guide READER’S COMMENTS NOTE: | AA-C986A-TE This form is for document comments only. DIGITAL will use comments submitted on this form at the company’s discretion. If you require a written reply and are eligible to receive one under Software Performance Report (SPR) service, submit your comments on an SPR form. Did you find this manual understandable, usable, and well-organized? Please make suggestions for improvement. Did you find errors in this manual? If so, specify the error and the page number. Please indicate the type of user/reader that you most nearly represent. [0 Assembly language programmer O Higher-level language programmer 0 Occasional programmer (experienced) O User with little programming experience 0 Student programmer O Other (please specify) Name Date Organization Street City State Zip Code or Country ~ — =—=Do Not Tear - Fold Here and Tape — — — — — — — — — — _ _ . _ L — — — —_ __ No Postage t | Necessary l if Mailed in the | | United States | I R I ] l BUSINESS REPLY MAIL — FIRST CLASS PERMIT NO.33 MAYNARD MASS. P POSTAGE WILL BE PAID BY ADDRESSEE ] | | ] | ATTN: Commercial Engineering Publications MK1-2/H3 — | DIGITAL EQUIPMENT CORPORATION S CONTINENTAL BOULEVARD | | MERRIMACK N.H. 03054 N | ] | I I l Do Not Tear - Fold Here and Tape — — — — — — — @ e — — — _— — —_— —_— I Cut Along Dotted Line — e e ] — dlilgliltlall PRINTED IN USA
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies