Digital PDFs
Documents
Guest
Register
Log In
AA-C986A-TE
January 1979
394 pages
Original
87MB
view
download
OCR Version
27MB
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 IS7, L / / ( 7 Q / L O B O C 5 MiC ot SySs Py {[ S LiprBRY CI79CI fe 13 B 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 A'NDVERSION: VAX/VMS V01.5 SOFTWARE VERSION: / i & /s" \\v A I fi ’ VAX-11 COBOL-74 V04 To order additional copies of this docunient, contact the Software Distributiofl Center, Digital Equipment Corporation, Maynard, Massachusetts 01754 digital equipment corporation - maynard, massachusetts N } The and information in this document should Corporation. for not any errors be is construed as subject to change without Digital Equipment Corporation assumes no that may appear responsibility in this document. _ The'software described in this document is furnished under and may be used or copied only notice a commitment by Digital Equipment in accordance with the a 1license terms of such license. Digital Equipmént Corporation assumes no responsibility for the use or reliability Digital. of its software on equipment | that is not supplied by | | Copizright@ 1979 by Digital Equipment Corporation { The postage-prepaid READER'S COMMENTS form on the last document requests preparing future documentation. The following are the wuser's «critical | | Equipment Corporation: DECsystem-10 DECtape DIBOL ~ MASSBUS 'OMNIBUS 0S/8 | DECUS EDUSYSTEM PHA UNIBUS FLIP RSTS COMPUTER LABS COMTEX FOCAL INDAC DDT DECCOMM ASSIST-11 VAX LAB-8 DECSYSTEM-20 RTS~-8 | VMS - DECnet IAS CHIP RSX TYPESET-S8 TYPESET-11 TTMTMS-11 ITPS-10 | 5/79-14 page ~ SBI of this to assist us in ;s trademarks of Digital DIGITAL DEC PDP evaluation ) CONTENTS Page PREFACE X111 - ACKNOWLEDGMENTS - Xiv INTRODUCTION 2 USING 2.1 CREATING SOURCE SYSTEM FILE 2.2.1 The THE COMPILER Command 2.2.2 Command 2.2.3 Error 2.2.4 Common Summary COBOL-74 LINKING 2.4 EXECUTING Format Qualifiers Message 2.3 | Line Command COBOL-74 A Setting The RUN | USING 2.4.2 Line Errors PROGRAMS COBOL IMAGE and Resetting Command Program Switches | ! I TT I R HHEOWOUOIIOUITERWNDNON - w NON-NUMERIC DATA HANDLING 3 N ® NON-NUMERIC Tests Classes of Data The WM OO STATEMENT - Multiple Receiving Subscripted Fields Moves Common Errors, MOVE Format 2, CORRESPONDING STRING MOVE Statement STATEMENT Multiple Sending Fields The POINTER Phrase - The DELIMITED The OVERFLOW Subscripted Common THE — MOVEMENT MOVE Elementary Moves Edited Moves Justified Moves N O UTdWNDDNDDND . ) ) o ) ® o o o o o o e e ) ° o e o [ e ) [ ) o s Operation Tests Group Moves THE ) Comparison " Class DATA ) FIELDS Relation [N ) CHARACTERS TESTING N [) [} - SPECIAL ° ° Items Elementary Items THE o ORGANIZATION Group ) ® [} [] _ - WWWWWWWwWwwWwwWwwWwwwwwww INTRODUCTION DATA s CHAPTER A COBOL-74 Choosing a Reference Format Entering a Source Program- 2.1.2 2.2 - VAX-11 | 2.1.1 THE BY UNSTRING Multiple Phrase Phrase Fields Errors, in STRING STRING iii Statements Statement STATEMENT Receiving HHKMHFODOOWMNMDDNDNDEH CHAPTER Fields WHN DN 1 MNDNDMNDDNDNDDNDNDMDDNDNDN CHAPTER CONTENTS (Continued) INSPECT Statement [ [] MOVE w N B I Y Elementary Numeric Moves Elementary Numeric Edited Moves Common Errors, Numeric MOVE Statements Intermediate Results The ROUNDED Phrase The SIZE ERROR Phrase iv | 4-15 \\ - / D Y S | I STATEMENT Group Moves THE ARITHMETIC STATEMENTS |] NG SO N Tests U NG NG G [] [] > w N+ THE FIELDS U |] Sign Tests Class SO S CONVENTIONS ILLEGAL VALUES IN NUMERIC TESTING NUMERIC FIELDS Relation Tests [] ® wMn - SIGN I COMPUTATIONAL-3 DECIMAL SCALING POSITION QT S LN+ w N . [] [J [] DISPLAY COMPUTATIONAL B Errors, G S N Common List | in Replacement Argument Lists (N B> WN [ [ [} [] [} [] The Interference | o ® L [ ® e [ o Value Argument Replacement Argument The - = HEeOOOoOOONJNoOOoONUTEWNDHEHEFEH [t N W W N o w N - [ [] ® [} o [] [ [ Replacement Replacement [ o [4 The [} [} REPLACING Phrase Search Argument [] 3-46 The Tally Argument List Interference in Tally Argument Lists The NNV WN 3-45 TALLYING Phrase Tally Counter Tally Argument The The ‘The S [] [] [] ' 3-43 Subscripted Fields in INSPECT Statements SO S SO S [] [] [] ® [] SO SO SO SO O LJ o O O @ Y [ U [] S ) 3-39 3-40 3-42 STATEMENT USAGES NG NG G G Statements Statement The BEFORE/AFTER Phrase Implicit Redefinition The INSPECT Operation Setting the Scanner Active/Inactive Arguments Finding an Argument Match The [J L4 INSPECT UNSTRING 3-25 3-29 3-30 3-31 - 3-32 3-34 3-36 3-37 3-39 S - L ] WNDN WOJoOuUTded [] SooooooutuumuuesewwwwpnH [] [} '@ ® e [] ® [] e © [} THE Errors, NUMERIC CHARACTER HANDLING TG CHAPTER 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 Common [ [] W WOWWOWWOWWOWWWWWWILWIWOLWYWIWLILWYILWLWLLILWWLOLW O O 00 o o WWWWwWWWwWwWwwWwWwwwWwwWwwWwWwwWwWwwwwwwwwwwwww Page CONTENTS (Continued) Phrase Operands 4-16 in ADD and SUBTRACT [] B The DIVIDE The COMPUTE Statement Statement Statement Errors, Arithmetic EXPRESSION Statements PROCESSING HANDLING 4-19 4-20 4-20 4-21 on ° TABLE 4-17 4-18 4-18 Statement [] [] - | J [J [} MAPPING TABLE HWOW-JOU & WN - - ® |] ] ] | [] R INDEXING with Literals Operations Performed by the RTS Subscripting with Indexes Operations Performed by the RTS Relative Indexing Index Data Items The SET Statement Referencing a Variable-Length Table Element at RTS Time Referencing a Dynamic Group at RTS T1me< The SEARCH Verb The SEARCH Verb - Format 1 The SEARCH Verb - Format 2 N ENE S o [] |] ® [ [] [] 1 2 Performed by the Software Subscripting with Data-Names [] LJ L L} ] Format Format Tables AND Operations [J - ELEMENTS Initializing [] DR DR BB E N O 'S Phrase Phrase Subscripting g, oron TABLES OCCURS OCCURS SUBSCRIPTING SIZE RECORD BLOCKING Control Sequential Files on Magnetlc Sequential Files Relative Files Indexed Files on Disk > - RECORD N = CURRENT RECORD AREA Effects on Output Operations Effects Sharing of Input Operations Record Areas Tape =0 O Variable-length Variable with Fixedlength HHEFRMEOOJOUTED WWNDN FORMAT Fixed-length SO ANASNOOIONOYOY OV O | - W N wnN -~ RECORD w [} [] [) [] LJ [] L] | [] [ [] [ o) INPUT-OUTPUT PROCESSING BB RWWWWWNDHHH NN OO OYOYOY OYOY CHAPTER The The OO oTCT T T U i i N I I A HHHEFOJWWN - DEFINING [] ® N ] INTRODUCTION [] W WD NN GNONGEGESGNG RN NG RGESG RSN ES RS NSRS, ' CHAPTER SUBTRACT MULTIPLY Common 4-16 Statement ARITHMETIC (O Co S ] ] 2 e @ AN ADD (o oL BE N Statements The The The | GIVING Multiple = The L 4 | ] ® [ = N Page CONTENTS (Continued) w - o o000t onoron — s HM~ OO\~ e o L] ] [] ® [] ) . [ [ [} . O oo OO I1/0 BUFFERS RMS Buffer Defaults Multiple Buffers (RESERVE Sharing (NI OPENING =W o+ | COMPATIBILITY Data Type Differences Data Record Formatting Differences Special Control Characters I/0 ERROR PROCESSING LOW-VOLUME I/O (ACCEPT AND DISPLAY) Mnemonic-Names (SPECIAL-NAMES Paragraph) LLogical Name "Devices" ACCEPT Statement DISPLAY 6-14 6-14 6-14 6-16 Execution FILES File Spec1flcat10ns Logical Names ASSIGN and VALUE OF ID Clauses File Switches (PDP-11 COBOL Compatibility) FILE w N Clause) (SAME AREA Clause) FILES I/0 Operations OPEN Statement NAMING > W= Buffers 6-13 6-13 6-13 6-17 6-17 6-19 6-20 6-22 6-24 6-24 6-25 6-25 6-25 6-26 6-27 6-27 6-28 6-29 Statement DEBUG A SCOPE Commands: SHOW, = HEHEWOVWOJONUTL T www N N | P CANCEL and CANCEL I Location Types Resolving Location Ambiguities vi | ~J P P SET, LOCATIONS ~ and | - - i | IR | PR RN | PP [ PROGRAM e WD | ] wN -~ [ ] ) TO SET LANGUAGE COBOL Command MODULE Commands: SET, SHOW, SPECIFYING NN PROGRAM CONCEPTS PREPARING ° WwwhdDDDDD - |] WO YOO DEBUG UTILITY oo Qualification and Compiler Performance | REFERENCES Data References 1 (Data Item Definition) 2 (Reference Format) 3 (Unique Referability) Procedure References Qualified Guideline Guideline Guideline Qualified O CONDITION NAMES . I LEVEL-88 OF. QUALIFIED ! OF USE | USE STATEMENT YW WYOWWYWWOLOL ALTER W WO < [ SoaohnoO oo OO WD THE oo ® NN NNNN N NN OF USE OF THE PERFORM STATEMENT O N USE PROGRAM DEBUGGING COBOL PROGRAMS WO CHAPTER FORMATTING THE SOURCE USE OF PUNCTUATION REFORMAT WO CHAPTER GOOD PROGRAMMING PRACTICES [ CHAPTER ot - @)} [o)We)We)WerWerWe )l e We )W W e)WerWerWe ) We) i e) W o) e o) Be) Weo) o) s @ ° L[] e o [] ® L4 [4 [] [} [ [} ¢ L] [] ] Page (Continued) EXAMINE Command 10.1 COMPILE-TIME Error Message Printing Internal Compiler Errors SYSTEM MESSAGES VAX-11 IN A COBOL SORT SUBROUTINE I/0 INTERFACE METHODS File I/0 Interface Record I/0 Interface 11.3 KEY DATA 11.4 11.5 11.5.1 11.5.2 11.5.3 KEY BUFFER 12.1 12,2 12.3 12.4 12.5 i Errors 10-5 Procedures PROGRAM 11.2 11.2.1 11.2.2 12 System | Faulty Program Logic Error File I/0 Error Procedures 11.1 11.5.6 -= Link-Time Error Messages Run-Time Error Messages SORTING 11.5.4 O 00 ~J 6L U ERROR MESSAGES Severity Levels 11 11.5.5 DATA DEPOSIT Command SAMPLE DEBUG SESSION ERROR MESSAGES 10.2.2.1 10.2.2.2 - CHANGING OO O Command AND WO e L] N EXAMINING O [J [ CALLS AT OT O Command SHOW WO CANCEL = CANCEL and O O WO WWL WYL and SHOW, ~ [ [] ] [] [] SHOW, SET, o |] SET, Commands: EXIT 10.2 10.2.1 10.2.2 CHAPTER Commands: TRACE WATCH Commands: SET, SHOW, and CANCEL GO and STEP Commands CTRL/Y Command (Interruptlng the Image) 10.1.1 10.1.2 10.1.3 CHAPTER BREAK j—t o CHAPTER CONTROLLING PROGRAM EXECUTION B BB D WO WO WIWWWWVWOLOIWOWYL ) v 8} Q CONTENTS 10-5 10-7 11-1 PACKAGE PROGRAMMING EXAMPLE 11-1 11-2 11-2 11-2 11-3 11-4 11-6 11-6 11-7 11-8 11-9 11-10 11-11 11-12 USING 12-1 SORT AND RECORD AREAS SUBROUTINES SORSPASS FILES SORSINIT SORT SORSRELEASE REC SOR$SORT_MERGE SORSRETURN_ REC SORSEND SORT THE Creating The COPY LIBRARY FACILITY a COBOL Library Statement Flle COPY REPLACING Statement The Source Llstlng Common Errors in Using the L1brary 12-2 12-2 The vii Facility 12-4 12-6 12-7 CONTENTS (Continued) Page 13 OPTIMIZATION 13.1 OPTIMIZING 13-1 FILE 13.1.3 Indexed Files Index Depth Overhead Accumulation OPTIMIZING PROGRAM ORGANIZATION Sequential Reading of Indexed Files 13-8 13-9 Caching Index Roots Multi-block Reading and Writing APPENDIX SOURCE 'APPENDIX DIAGNOSTIC APPENDIX RUN-TIME ERROR APPENDIX INTERNAL COMPILER ERRORS APPENDIX PROGRAMMING CALLING A FORTRAN SUBROUTINE [ [ The The FORMATS LISTINGS ERROR MESSAGES MESSAGES - SYSTEM EXAMPLES COBOL Program, GETROOT FORTRAN Program, SQROOT Sample Run of GETROOT N USING -] COBOL Program, RUNTIME ‘Sample Run of RUNTIME N [J [ The " TERMINAL ESCAPE The COBOL Program, Sample Run of SEQUENCES ESCAPE ESCAPE ® N CALLING VAX/VMS SYSTEM SERVICES The COBOL Sample Run Program, of ERRORS i -- pJ PROGRAM CALLING VAX-11 RUN-TIME PROCEDURES ® [] [ [] [] o [ L4 |] ® [} OO [] COMPILER IMPLEMENTATION LIMITATIONS wn -~ APPENDIX [ THE b bdbWWwWDDDONOH APPENDIX COBOL 13-9 | @ COMPUTATION NANONGN OPTIMIZING 13-2 13-2 13-3 13-5 13-6 13-7 13-7 13-8 13-8 SYSTSVC SYSTSVC | —t HEHEWOWOAUTOU B WWH W oo 13.1.2 13.1.3 13-2 DESIGN Sequential Files Relative Files Indexed Files ‘General Rules for Bucket Size 13.1.1 mmmmmmcfimmmmmm N | CHAPTER Index-1 INDEX viii i Wk W N B> o Building a COBOL Task Image Field Sizes | Redefining Special Characters w W w FIGURE | ST ol FIGURES CONTENTS FIGURE (Continued) Relation Condition | The Meanings of Relational Operators Class Condition, General Format Data Movement with Editing Symbols Data Movement with No Editing Subscripted MOVE Statements Sample STRING Statement Concatenation with the STRING Literals as Sending Fields Indexed Sample Sending POINTER Delimiting Statement Fields Phrase with the Word SPACE as a Delimiter SIZE Repeating the DELIMITED BY Phrase Delimiting with More Than One Space Character The ON OVERFLOW Phrase Various STRING Statements Illustratlng the Overflow Condition | STRING Statement with Subscripting with the Subscripting with the Pointer Pointer Delimiter 3-21 Sample UNSTRING Statement Multiple Receiving Fields 3-22 3-23 3-25 Delimiting with a Space Character 3-28 3-29 3-30 Delimiting with Multiple Rece1v1ng 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 Field The TALLYING Phrase The POINTER and TALLYING Phrases Used 3-26 1 3-29 3-29 3-30 1 3-31 3-33 3-33 3-34 3-34 Together Subscripting TALLYING 3-37 Using with the - 3-36 3-36 of Subscript Evaluation Erroneously Repeating 3-38 3-39 the Word INTO Sample INSPECT...TALLYING Statement Sample Sample INSPECT...REPLACING Statement INSPECT...BEFORE Statement 3-44 Matching the Delimiter Characters Characters in a Field Sample INSPECT Statement 3-45 Sample REPLACING 3-46 Sample AFTER Delimiter Phrase 3-47 Where Active Arguments to the Become ix 3-40 3-40 3-40 3-41 3-44 Argument K\ - COUNT Phrase Item the OVERFLOW Phrase Sequence 3-43 the Data 3-44 in a Field 3-45 3-46 CONTENTS 3-48 Sample Subscripted Argument Format of the Tally Argument ' CHARACTERS Form of the Tally Argument Results of Counting Condition Argument List with Adding into the LEADING One Tally Counter Argument List Adding into Separate Tally Counters Argument List (with Dellmlters) Addlng 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 An Attempt to Tally the Character B with Two Arguments Tallying Asterisk'Groupings Placing the LEADING Condition in the List Reversing the Argument List in Flgure An Argument List that Counts Words in Argument Statement Counting Counting | Leading Tab or Space Characters the Remaining Characters with the CHARACTERS Argument Format of the Search Format of the Replacement The 3-62 a Argument Value Replacement Argument Replacement Argument List that Over the Entire Field Replacement Argument List that Ones for Zeroes and Zeroes for is Active "Swaps" Ones Replacement Argument List that Becomes Inactive with the Occurrence of a Space Character Argument List with Three Memory Storage of COMP Memory Storage of COMP-3 Arguments that Become Inactive with the Occurrence of a Space Data Items Data Items Truncation Caused by Decimal Point Alignment Zero Filling Caused by De01mal Point Alignment Numeric Editing Rounding Truncated Decimal Point Positions ‘Rounding Truncated Decimal Scaling Positions TN FIGURE (Continued) CONTENTS FIGURE Explicit (Continued) Programmer-Defined Temporary Work Area Arithmetic Statement Intermediate Result Field Attributes Determlned from Composite of Operands Arithmetic Expression Intermedlate Result Field Attributes Determined by Implementor- Defined Rules \m Defining a Table | Mapping a Table into Memory Synchronized COMP Item 1n 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 a FILLER Item as Shown in Figure 5-6 Initializing Tables Initializing Mixed Usage Fields Initializing Alphanumeric Fields Literal Subscripting Subscripting a Multi-Dimensional Table Subscripting Rules for a Multi- D1men51ona1 Table Subscripting Index-Name with Data-Names Item Subscripting with Relative Indexing Index Data Index-Name Items 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 Y 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 TABLE Results Results Fields of of (Continued) Delimiting Delimiting SN CONTENTS with an Asterisk Multiple Receiving | Results of Delimiting with Two Asterisks Results of Delimiting with ALL Asterisks Results of Delimiting Asterisks Results of the in Figure 3-29 with | Multiple ALL Double | 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 Mode Switches for PDP-11 REPLACING Matches Commercial Engineering Publications typeset this manual using DIGITAL’s TMS-11 System. 956ALL Xx1ii PREFACE MANUAL OBJECTIVES , This manual describes the VAX-11 COBOL-74 compiler. It discusses the relationships between the COBOL-74 language, the compiler, object modules and executable images, and VAX/VMS and 1its wutilities. The User's Guide supplements the description of the COBOL-74 programmlng language in the INTENDED AUDIENCE This manual of of the VAX-1l1l COBOL-74 Language Reference Manual. is designed for programmers who have a COBOL~-74 language and who are familiar working w1th the basic knowledge concepts VAX/VMS STRUCTURE - OF_THIS_DOCUMENT The User's Guide describe language is organized functions, system. ASSOCIATED concepts, ‘into and chapters .and features of appendixes the VAX-11 DOCUMENTS This manual supplemental refers to the following documents, information that is relevant to which VAX-1l1l programmlng . contain COBOL-74 | e VAX-1ll COBOL-74 Language e VAX/VMS Language User's Guide @ VAX-1ll1l e Introduction To VAX-11 Record Management Services '@ VAX-11 Symbolic Debugger Reference Manual e VAX-1ll ® VAX/VMS CONVENTIONS that COBOL-74 Command Linker Sort Manual Manual Reference Manual Operator's Guide USED The syntactic discussed 1in Manual. Reference Reference IN THIS DOCUMENT conventions used Chapter 1 of the | | 1in general format examples are VAX-1ll COBOL-74 Language Reference | | ~ X1i1i ACKNOWLEDGMENT COBOL is an industry language and is not the property of or group of organizations. companies, or of any . organization any or company group of 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 language. Moreover, no responsibility 1is 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 in part, in the COBOL specifications. Such authorization extends to the reproduction and use of COBOL specifications in programming manuals or similar Procedures have publications. 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 Washington, DC 20013. \ T 1808, Xiv CHAPTER 1 INTRODUCTION The VAX-11l COBOL-74 compiler translates ANS-74 COBOL into relocatable VAX/VMS. object modules; it runs source under the pfograms supervision of o To run a COBOL program,‘you follow a fOur—step'prccess: @ Prepare a source program ® Compile e Link object modules intd an executable image file ® Execute the image a source program The VAX-11l COBOL-74 compiler accepts COBOL source statements from source 1input files. This means that you must manually enter your source statements onto an acceptable medium prior to the compilation process. o o Once you have input files decided and The VAX-11l COBOL-74 upon an input medium and format for your source have <created them, you compile the source program. compiler reads source statements from the source input file and translates them into an object module consisting of program sections (PSECTs). It can also produce a source program listing with optional special-purpose 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. 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. Each 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 in image is an executable form of the declarations your COBOL source programs. It includes and instructions 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 your | program. Figure 1-1 | shows the | process of preparing a COBOL execution. functions for program for | - COBOL COBOL SOURCE SOURCE PROGRAM LIBRARY | VAX-11 COBOL-74 COMPILER OTHER OBJECT MODULES' | ~ VAX-11 OBJECT -\ , MODULE B ffififfl%fifl? E | RuNTIM VAX-11 LINKER VAX-11 IMAGE FILE H-MK-00043-00 Figure Building 1-2 INTRODUCTION an 1-1 Executable Image CHAPTER 2 USING THE VAX-11 COBOL-74 SYSTEM o~ This chapter discusses the procedures linking, and executing COBOL programs. 2.1 CREATING A Before you reference can SOURCE compile format and for creating, PROGRAM a COBOL program, prepare your you must source decide program on for compiler. 2.1.1 The or COBOL-74 formats in library). a Reference COBOL-74 conventional VAX-11l source to the compiler terminal Reference same qualifier to reduce amount source can accept reference specify of programs (both are Manual). However, you cannot program (including space text in either described mix copied in your may want COBOL to select program the was format. needed conventional originally the reference from a COBOL easily used by programmers at the <compiler accepts terminal allows you to wuse a command conventional file source format to store The terminal source format programs. addition, it is usually easier to edit source programs written terminal format, because spacing requirements are more flexible. ~You the Format Terminal format was designed to be interactive terminals; therefore, reference format as a default and the the input | Choosing VAX-11 compiling, | reference written format, that way however, for can In in 1if 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 command line, which file is type assumes COB as a default; naming source files with for the source program described in the next section, therefore, the default you can file simplify file 1in the the compiler compiling by 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 2.2 SLP text editors. USING 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 1The Command Line Format | The'VAxéll COBOL-74 command line has the following format: - COBOL/C74 [/command-qualifiers] file-spec where:fl - | . | COBOL/C74 | specifies the VAX-11] COBOL-74 compiler. /édmménd—qualifiers specify compiler options. 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 as use the default. specification. 2-2 USING THE VAX-11l COBOL-74 SYSTEM wild cards in the | file VN and 2.2.2 Command Qualifiers VAX-11 COBOL-74 provides a series of command qualifiers that you use to select or qualifiers, which suppress compiler options. Table are then described in detail. 2-1 can summarizes the Table 2-1 Command Qualifiers Qualifier Default / [NO]ANSI FORMAT / [NO]COPY LIST /[NO]CROSS_REFERENCE / [NO]DEBUG | .~ /NOANSI_ FORMAT /COPY LIST /NOCROSS;REFERENCE /NODEBUG /[NO]JLIST[=file-spec] / [NO]MAP /NOMAP / [NO]JOBJECT [=file-spec] /[NO]VERB_LOCATION | / [NO]JWARNINGS /ANSI FORMAT /NOANSI FORMAT | Indicates whether format or For with \‘ / source program in DIGITAL's terminal conventional optional indicators the /NOVERB_LOCATION /WARNINGS , format, in position beginning in positions 73-80. the sequence in format. compiler numbers 7, is in expects 12, and the LIST in the listing /COPY_LIST is the default: the compiler the source /NOCOPY_LIST suppresses the source file is record position 1. of statements file. text copied it in S includes ‘ listing B 1in 1in the all - source from library only the COPY statement appears in the listing file. /CROSS REFERENCE /NOCROSS REFERENCE Controls listing. 1-6, Area | | source program are printed files; 8, identification area Controls whether statements included by COPY in positions | /COPY LIST statements R in position By default, the compiler assumes that the terminal format; that is, Area A begins in /NOCOPY , | (conventional) 80-character images character Area A beginning position ANSI whether cross-reference the listing. source program listing USING THE VAX-11l COBOL-74 includes SYSTEM a | 2-3. /CROSS REFERENCE produces a cross-reference listing as part of the listing file. The compiler sorts data-names 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 1arge programs. By default, the compiler does not create a cross-reference listing. /DEBUG allows you to refer to data items Procedure Division traceback and 1locations symbol table by line Chapter 9 data-name, discusses COBOL program and to /DEBUG=TRACEBACK /NODEBUG generates | debugglng and it generates both information. produces traceback information only; The default is /NODEBUG. ‘Symbolic by number; 1nformat10n using neither. the /k\\ /DEBUG [=TRACEBACK] /NODEBUG Controls whether the compller produces traceback local symbol table information for the debugger. VAX/VMS Debugger.- _/LIST[=fi1e—spec] /NOLIST use the If the COBOL/C74 by default, the COBOL/C74 default. does command is command not create executed in interactive a listing from file. a batch job, When you specify /LIST, you can control the defaults mode, the /LIST is applied to the output file specification by where you place the qualifier in the command, as described in the VAX/VMS Command Language User's Guide. The output file type always defaults to LIS. /MAP /NOMAP /MAP causes the listing file: e ® @ Data Division Map Procedure Map External Subprograms @ Data and Control ® RTS ® Segmentation /NOMAP 2-4 compiler | Routines to produce Referenced PSECTs Referenced Map is the default. USING THE VAX-11 the , COBOL-74 SYSTEM following reports in the | // If you compiler, 3 Controls whether the compiler produces an output listing. /OBJECT [=file-spec] /NOOBJECT Controls whether the compller produces an object file. By default, the compiler produces an object file with the same file name as the input file and a file type 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 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 in which used. The default 1is /NOVERB_LOCATION. /WARNINGS /NOWARNINGS | | | | Controls whether the compiler prints informational diagnostic messages as well as warning and fatal diagnostic messages. By default, the compiler prints /NOWARNINGS Consider the to suppress following them. command informational diagnostics; specify | line examples: COBOL/C74/DEBUG PROGA Produces an object module file file PROGA.COB. PROGA.OBJ from the 'Source | COBOL/C74/LIST/DEBUG/OBJECT=TESTB Al2 Uses the source TESTB.OBJ and file Al2.COB to produce object 'module a source listing in file Al2.LIS. T COBOL/C74/LIST/CROSS_REFERENCE PAYROLL Uses the source file PAYROLL.COB to produce object module PAYROLL.OBJ and a source listing 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), displays The error nnnnn FATAL NOTE If any fatal errors occur, the does 2.2.4 not generate an object compiler file. Common COBOL-74 Command Line Errors Somévddmmon errors to avoid when entering COBOL-74 command lines are: ® Omitting the /ANSI FORMAT qualifier are in conventional format. ® Including /LIST. o ° to compile qualifiers, | other Forgetting to use a file you intend to wuse or default file type. —~ than the type in <create source | programs that | Omitting version numbers from file want file. 2.3 contradictory for such as /MAP specifications latest version the a without when of a you source file specification when file with other than the LINKING COBOL-74 PROGRAMS After you have compiled one or more source programs to produce object modules, you 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-1l1l Linker Reference Manual. | | To link object modules, LINK 2-6 enter a [/command-qualifiers] USING THE VAX-1l1l COBOL-74 LINK command file-spec(s) SYSTEM in the following format: [/file-qualifiers] where: /command-qualifiers specify output flle optlons. file-spec specifies the input flle(s) - /file-qualifiers to be linked. specify input file options. You can enter multiple file specifications separated from each other by commas or plus signs (which are equivalent). Regardless of how many file spec1f1cat10ns you spe01fy, the LINK command produces only one executable image. If you do not specify a file type in an input file specification, the depending on the nature of the types, file default assumes Linker of type file For example, object files are assumed to have a file. OBJ. The VAX/VMS Command Language User's Guide dlscusses VAX-11 Linker default file types in detail. Default file types for output Command Language User's Guide. ~ files are | discussed 1in +the VAX/VMS Consider the following command line: LINK TESTA,TESTB,SYSSLIBRARY:C74LIB/LIB This line causes the compiler to use two object modules (TESTA.OBJ and TESTB.OBJ) to produce a single executable image (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 at the same time. Link sharable RTS by specifying: images with run the SYSSLIBRARY:C74LIB/OPT use Before you can system manager must image, The your this option, install the sharable SYSSSYSTEM:C74LIB.EXE, procedure is as described VAX/VMS Operator's Guide. SHARED. in the - | USING THE VAX-11 COBOL-74 SYSTEM 2-7 The following qualifiers However, you qualifiers qualifiers discussion describes that you will are find most complete in the references are discussed: Command the likely to command use for discussions already qualifiers qualifiers linking of all mentioned. and file COBOL modules. LINK The command following Default /BRIEF / [NO]CROSS REFERENCE /NOCROSS REFERENCE /[INO]DEBUG[=file-spec] / [NO]EXECUTABLE [=file~-spec] /NODEBUG /EXECUTABLE /FULL « /[NO]JMAP[=file-spec] /NOMAP / [NO] TRACEBACK | /TRACEBACK File qualifiers /INCLUDE=module-name|,...] /LIBRARY /OPTIONS Command Qualifiers: /BRIEF Produces you a brief memory also specify line. The allocation map /MAP; file. Use /BRIEF only 1if /BRIEF must follow /MAP on the command | brief form of the map contains: l. A summary ofAthe image characteristics. 2. A list of all ébject modules included in’the image; 3. A summary of link-time performance statistics; Example | | | LINK/MAP/BRIEF PROGA,SYSSLIBRARY:C74LIB/LIB M/CROSS_REFERENCE. /NOCROSS_REFERENCE Controls whether the Linker the memory allocation map. Use /CROSS_REFERENCE /CROSS_REFERENCE must 2-8 USING THE VAX-1ll produces only if follow /MAP on COBOL-74 SYSTEM a symbol vyou the cross-reference also command specify line. on /MAP; Example LINK/MAP/CROSS REFERENCE PROGA,SYSSLIBRARY:C74LIB/LIB ‘The stbol cross-reference lists each global symbol referenced in the image, its value, and all modules in the image that refer to it. The default is /NOCROSS REFERENCE. /DEBUG[=file-spec] /NODEBUG o 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. If you specify /DEBUG without a file specification, the default VAX/VMS Debugger is linked with the image. 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 image with the file name as the first input file and a file type of EXE. same Use /NOEXECUTABLE to see the results of linking in less time than the Linker would need to create an image file. 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 if 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 descrlptlons of each program sectlon and 1mage 3. Lists of global symbols by name and value. section in the 1mage in the brief listing. file. 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 - the first input file, with a file to name the file is the same type of MAP. as 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: A list of user-defined global in the brief listing. symbols sorted by name. A list of userdeflned program sections. The default is /NOMAP /TRACEBACK/NOTRACEBACK Controls whether image information contained the Linker includes traceback 1nformat10n in the file. By default, the Linker includes traceback information system can trace the call stack when an error specify /NOTRACEBACK, you will get no traceback errors N 2. 3. the TN All so the occurs. If you reporting when occur. If you spec1fy /DEBUG, | the Linker 7 also | assumes /TRACEBACK. , ! File Qualifiers /INCLUDE-module namef[, ...] Indicates that the associated file specification refers to an object module library (the default file type is OLB) ; furthermore, it causes the Linker to unconditionally include only the specified module(s). 2-10 USING THE VAX-11 COBOL-74 SYSTEM / 1. 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 the Linker to search the library for unresolved references it unconditionally includes the specified module(s). Examples: LINK | | PROGA,LIBA/INCLUDE=MODA,SYSSLIBRARY:C74LIB/LIB The Linker links PROGA.OBJ and from the 1library file produce PROGA.EXE. the MODA LINK cause after module to LIBA.OLB PROGA,LIBA/INC=(MODA,MODB)/LIB,SYSSLIBRARY:C74LIB/LIB The Linker MODA and links PROGA.OBJ and MODB from the LIBA.OLB. Because qualifier, the LIBA.OLB any in for PROGA.OBJ, of the Linker other MODA, the /LIBRARY will also unresolved and modules file 1library file 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 specification does not include a file type, the Linker assumes the default file type OLB. Do not specify a library as the first input file wunless vyou also specify the /INCLUDE qualifier to indicate which modules in the library are to be unconditionally included in the image. You can wuse 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 séarches LIBA.OLB for references LINK in PROGA.OBJ to create unresolved PROGA.EXE. LIBA/LIB/INCLUDE=MOD]1/EXEC=PROG,SYSSLIBRARY:C74LIB/LIB ~ The Linker LIBA.OLB, includes then the module searches MOD1 LIBA.OLB The for result | — unresolved references in MODl. is an executable image PROG.EXE. from USING THE VAX-11l COBOL-74 SYSTEM 2-11 /OPTIONS to options of 1list a contains Indicates that the input file /OPTIONS file specification does not the If 1linking. control include a file type, the Linker uses the default file type OPT. The contents of the option Linker 2.4 are file Reference Manual. EXECUTING A COBOL described in VAX-1ll the | | IMAGE an executable «create to When the object modules have been 1linked image in the the execute to command RUN the use can you image, SPECIAL-NAMES in the OFF If you specified SWITCH ON or process. of paragraph 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 can be command defined for COBSSWITCHES, (you can also use the ASSIGN command) which Use the DEFINE process, group, or system. the to change the status of program switches: "switch-list" DEFINE COBSSWITCHES where switch-list is a list of one or more program switch numbers The entire 1list must be enclosed in separated by commas. (1-16) quotes. A switch is set ON if its number appears in the switch-list; otherwise, i1t is set OFF. Examples "1,5" Séts switches 1 and 5 ON; 7N DEFINE COBSSWITCHES sets all others OFF. DEFINE COBS$SWITCHES "4,5,6,7,8,9,10,11,12,13,14,15,16" 2, Sets all switches ON except 1, " DEFINE COBSSWITCHES Turns OFF all and 3. " switches. The order of evaluation of 1logical 1is: assignments name 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 aware of system and group assignments of be should you Therefore, COBSSWITCHES before executing an image if you do not define it yourself 2-12 in your process. USING THE VAX-1l COBOL-74 SYSTEM | , You can guarantee the intended status of COBOL setting switches just before executing can confirm the switch settings by using - SHOW LOGICAL can use the DEASSIGN name from your process; then active: You can also 1. switches by uses them. command: You COBSSWITCHES You command the to remove group or the system | DEASSIGN program an image that the following switch-setting logical name logical (if any) is | COBSSWITCHES change the status of switches Interrupt the image with CTRL/Y during execution: or STOP a literal COBOL statement. 2. Use a DEFINE command to change switch settings. 3. Continue do not command N 2.4.2 the image force that with the a CONTINUE interrupted executes another command. image to Be exit sure by that you entering a image. The RUN Command Use the RUN command to execute an image: "RUN If you [/command-qualifier] do command not uses specify the a default file file file-spec type in type EXE. file specification, the | RUN | The RUN command has two optional command qualifiers: /DEBUG Specify /DEBUG to request the debugger at execution time if the image was not linked with the debugger. However, you cannot use /DEBUG if /NOTRACEBACK was specified when the image was linked. /NODEBUG Specify /NODEBUG if you do time for an image that was | | not want the debugger at execution linked with the /DEBUG qualifier. Examples 'RUN PROGA Executes PROGA.EXE. RUN Executes PROGB.ABC 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 the VAX/VMS command to Command execute Language the debugger it. image User's as a Guide.) N USING THE VAX-1l COBOL-74 SYSTEM 2-13 - CHAPTER NON-NUMERIC 3.1 3 CHARACTER HANDLING INTRODUCTION COBOL programs hold their data in fields whose sizes are described their source programs. Thesé fields are thus "fixed" compilation to remain the same size throughout the 1lifespan resulting object program. The data descriptions of the as belonging to any of three or numeric class. Numeric values, alphabetic <class data a items may mixture character Further, fields in a COBOL program describe them data classes -- alphanumeric, alphabetic, <class data only A-Z and contain values of alphabetic from the these ASCII three 1in during of the | 7 that bytes, character classes are are items space, all contain only numeric but alphanumeric class alphabetic, numeric bytes, set. all or, ‘ subdivided numeric, in fact, or any | 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 For alphabetic classes and of subordinate numeric (data elementary items) class synonymous. and category are U alphabetic (A-Z and | | An items. field space) is a field declared to contain only characters. alphabetic . 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 field. reading the between the class the item contains following or sections of this category should of always a data be kept item chapter, and in mind. the this actual distinction value that the Sometimes ~alphanumeric text refers to alphabetic, alphahumeric, edited data items as non-numeric data items. and This is to distinguish them from items that are spec1f1cally described as numeric items. Regardless of the class of an item, it is usually possible to store a value in 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 occa51onally omit however, the reader should an item; 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 item. This chapter discusses non-numeric class data and the Anon—arithmetic, 3.2 ,/ non-input-output operations that manipulate this type of data. DATA ORGANIZATION into group organlzed 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 wvalued 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 tlme. The following sub-sections (3.2.1 and 3.2.2) diScuss, on a general level, how the compiler handles group and elementary data 1items. 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. subordinate elementary its by software the Thus, items. DISPLAY alphanumeric be to items 1if they had been described as PIC X() as items manipulates group items, and 1gnores the structure of the data contained within them. 3.2.2 Elementary Items The size of an elementary item 1is determined by the number allowable symbols it contains that represent character positions. example, 3-2 consider NON-NUMERIC figure 3-1. CHARACTER HANDLING b in the TM~ the value of For 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 operational sign. data differently, VAX-1ll memory. mapping of the two 8-bit byte of may refer however, contains with the Records items .”/\\\ the This OCCURS (a 01 that a field may begin in the left effect on the function of any becomes clause level have Procedure digits a particularly (see Chapter entry and level number all important 5, of of Table its 77 Division automatically when begin array of declaring all on entries) literal even byte words. reads and writes and data addresses. integral system table values given in boundaries file bytes, « I/0 verbs require that records be aligned on word COBOL-74 a Handling). subordinate and or right-hand operations that the VAX-11 an of of COBOL operations on such fields are independent of the field into VAX-1l1l memory words (l6-bit words that hold In effect, the compiler sees memory as a continuous words. contains and Although certain verbs handle these two classes the data, in either case, occupies seven bytes bytes). Thus, a word with no to that field. not FIELD-1 decimal because numbers of - Non-input-output verbs do not require alignment of the data. when two fields sometimes increase rather that a byte However, are aligned 1identically, the processing verb can its efficiency by processing them a word at a time at a time. In all cases, automatic word alignment of literals, records, and/or 77 items 3.3 increase the opportunity for more efficient processing. SPECIAL CHARACTERS COBOL allows the ASCII character user set to manipulate as any of the alphanumeric data 128 characters of even though many of the the characters are control characters, which usually control input/output devices. Generally, alphanumeric data manipulations are performed in a manner that attaches no "meaning" to an 8-bit byte. Thus, the user can move alphabetic and and compare these control numeric characters. characters in the same manner as | Although the object program c¢an 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 characters may be placed into data fields of the object program by numeric COMP Consider the even word.) placing field the the and binary redefining following byte of a word example the field special as alphanumeric of redefinition. to the character low-order into a | (fi | DISPLAY. (Keep in mind bits of that a binary in Figure 3-2 introduces each character as a 1l-word : 01 LF-COMP 01 LF PIC 999 01 01 01 01 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 The sample coding item (The of that corresponds COMP VALUE LF-COMP Redefining - COMP value with a decimal second byte of level, since \sized>fields.) the value, then redefines it as a single redefinition need not be described at redefinition Reference 10. X. Figure 3-2 Special Characters at ' Use the Character Set table in Language PIC Manual to this level Appendix determine the does B not of require the decimal the 01 ( - identically VAX-11 value byte. for COBOL-74 any ASCII character. 3.4 TESTING NON-NUMERIC FIELDS 3.4.1 An Relation Tests 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 control in the program. An IF statement with a and use the | relation result | condition to alter compares the two flow of operands, either of which may be an identifier or a literal, except that both cannot be literals. If the relation exists between the two operands, the relation condition has a truth value of true. : Figure (The not 3-3 illustrates relational underlined the general greater-than-or-equal-to.) 3-4 NON-NUMERIC format characters ">," "<," to avoid confusion CHARACTER HANDLING of a relation condition. and "=," although required, with other symbols such are as . ( - { identifier-1 IS IS [NOT] [NOT] GREATER THAN LESS THAN IS [NOT] > IS [NOT] EQUAL TO literal-1 arithmetic-expression-1 IS [NOT] < IS [NOT] = identifier-2 literal-2 arithmetic-expression-2 f Figure 3-3 Condition Relation When coding reserved a relational word. When considers it and the operator, the next leave reserved key word a word space NOT before is or relational | GREATER THAN The first [NOT] > (or not IS [NOT] LESS The first IS [NOT] < (or not IS [NOT] EQUAL TO Is [NOT] = TN [NOT] IS - TN, class The (or The '3.4.1.1 - Meanings of operand greater each class comparison of of and 3-4 is than) first operand not is greater than than) operand less equal to) the the non-numeric be one shows the operand. than second is equal the to second operand. | operand. | Relational class second less the Figure 3-4 Classes of Data - COBOL allows operands to Figure | each software MEANING IS THAN after the character relational operator that defines the comparison. meanings of the relational operators. OPERATOR and present, 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 values and non-numeric (or a numeric and a non-numeric) class operands with respect to a specified collating sequence. - If only one of the operands is numeric, it must be an integer data item or an integer literal and it must be DISPLAY usage; further, the manner in which the software handles numeric operands depends on the non-numeric operand. Consider the following two types of non-numeric operands: 1. If the non-numeric operand is 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. In 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 is described with a picture-string of 9999999. 1If its value is 432J (-4321), the value in the temporary 1location 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, sign, whether carried as therefore, includes any operational a separate character or as an ASCII characters overpunch, 1in numeric its length. digits, but (Overpunched characters in the range are never 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. | these two comparison between a non-integer operand, and any attempt to compare items will cause a diagnostic message at compile time. N The compiler will not accept a ‘numeric operand and a non-numeric 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 is the greater operand. | ) If the operands have different lengths, though the ASCII spaces shorter (hex 20) operand to make were them the comparison extended on the right both the same length. If all of the pairs of characters compare equally, equal. 3-6 NON-NUMERIC CHARACTER HANDLING the proéeeds as operands are by sufficient 3.4.2 Class Tests An IF statement 'ALPHABETIC) can DISPLAY and only) use the to that test contains the wvalue determine result to alter if it the a <class condition (NUMERIC or 1in a non-numeric data item (USAGE contains numeric flow of 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 is 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 key word as one class condition that defines the class test to be executed; for example, NOT NUMERIC is a truth test determining if an operand contains at least one non-numeric byte. for 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 perform most of the business-oriented programs. data (MOVE, STRING, movement The MOVE and UNSTRING) operations statement required simply moves data that by 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 its 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 the third then the with fields 1in field and receiving however, bring the contents of two fields (receiving) field if the receiving field has subordinate size. If elementary other fields they differ in size field will require items are from to the additional that match be the concatenated first two into two fields, subdivisions (through redefinition). "table" are the of a of concatenation receiving single characters field character in 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 to can also several left-most end then the second MOVE sending field to another be used receiving of the to disperse fields. sending statement receiving the The field times a loop which moves each sending field, a character at a subscript that moves continuously across the receiving to data movement using contents a to a there as time, field. first is creating of a one MOVE statement receiving field; can move the right-most end of the 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 The a character-by-character concatenation handled quite dispersion easily following sections in detail. 3.6 and movement by (3.6, (as limitations the 3.7, loop STRING and 3.8) with of concatenation). the MOVE and UNSTRING discuss these statement statements. three are The statements THE MOVE STATEMENT The MOVE statement moves the contents of one field following illustration Format shows the two formats of into another. the MOVE The statement. 1 MOVE FIELD1l TO FIELD2 Format 2 MOVE CORRESPONDING FIELDl1 TO FIELD2 NOTE Format-2 is discussed in Section 3.6.6. 'FIELDl is receiving contents size, the name field. of FIELDL class, or of the sending field and The statement causes into FIELD2. wusage; and the The two fields they may be items. 3-8 FIELD2 NON-NUMERIC CHARACTER HANDLING is the software need either , name not be group or of to move the the same the elementary \ method subdivide v" Another 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 Group of every the software will align pad (with spaces) non-numeric elementary truncate items and or | remember when using contents will the MOVE character statement position in is the a that it will receiving field. Moves If either considers ///*\\ the sending or receiving field is a group item, the software 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 (except for the size description, in bytes, and any JUSTIFIED editing 3.6.2 the therefore, the receiving field. software conducts no | 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 . K clause); on numeric o the moves -- see Chapter 4, Numeric Character Handling -- control data movement.) \ The - following table elementary moves. shows - SENDING 1legal Table Legal > the Non-Numeric FIELD CATEGORY . (and “ ‘illegal) non-numeric 3-1 Elementary Moves RECEIVING ALPHABETIC FIELD CATEGORY ALPHANUMERIC ALPHANUMERIC ALPHABETIC | Legal ALPHANUMERIC ALPHANUMERIC EDITED ONLY) NUMERIC EDITED Legal Legal Legal Illegal | Legal Legal NUMERIC INTEGER (DISPLAY " Illegal NON-NUMERIC EDITED / Legal | Légal 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(). 1If 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 wuses them only to determine the field's size. | Numeric class data must be in DISPLAY | (byte) format and must be integer. an - 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 item, 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 2zero digits. It then wuses 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 If the sending item is an unsigned characters in its picture-string, to a temporary location. numeric shorter than the receiving field, field with spaces. that <class is, field as if the 1its | with the software does not move the A numeric integer data item sending justification of the receiving field. In legal, X(), alphanumeric. no P item field has no effect on the 1If the numeric sending field is software non-numeric elementary moves, | fills the receiving 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 its 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 is wused as the receiving field of a non-numeric elementary MOVE statement, the statement moves the characters by starting at the left-hand end of the fields and scanning across, character-by-character to the right. If the sending item 1is shorter than the receiving item, the software fills the remaining character positions with spaces. ) 3.6.2.1 . editing 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 / —-—- 0 3-10 -- zero slash NON-NUMERIC insertion position insertion position insertion position. CHARACTER HANDLING contain editing only the B character; three characters. f When a field that contains an insertion editing character in its .picture-string is wused 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 FIELDl TO FIELDZ2. (Assume that FIELDl was described as PIC X(7).) FIELD2 FIELD1 PICTURE-STRING 070476 - 04JUL76 2351212 | CONTENTS AFTER MOVE XX/99/%XX 07/04/76 99BAAAB99 04 XXXBXXXX/XX/ JUL 76 235 1212/ / 0XBOXBOXBOX 01 123456 Figure 3-6 Data Movement with Editing 02 03 04 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 ‘/—..TM~N - field characters. | 3.6.2.2 Justified Moves - A JUSTIFIED RIGHT <clause in 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. FIELDl PICTURE-STRING ' | XXX the statement, FIELD2 | CONTENTS ABC for PICTURE-STRING (AND JUST CLAUSE) | MOVE XX AB XXXXX XX JUsT ABC BC XXXXX JUST Figure CONTENTS AFTER ~ ABC 3-7 Data Movement with No Editing NON-NUMERIC CHARACTER HANDLING 3-11 3.6.3 If Multiple Receiving Fields a MOVE statement is written with more than one receiving field, it the same sending field value to each of the receiving fields. It has essentially the same effect as a series of separate MOVE statements that all have the same sending field. (For information on moves - subscripted fields, see section 3.6.4.) The receiving fields need have no 'software checks the legality of an independent move relationship to each each one independently, other. The and performs operation on each one. Multiple receiving fields on MOVE statements provide a convenient way to set many fields equal to the same wvalue, such as during initialization code at the beginning of a section of processing. For example: | * | MOVE SPACES TO LIST-LINE, EXCEPTION-LINE, NAME-FLD. { MOVE ZEROES TO EOL-FLAG, EXCEPT-FLAG, NAME-FLAG. MOVE 3.6.4 1 TO COUNT-1, CHAR-PTR, CURSOR. Subscripted Moves Any field of a MOVE statement may be subscripted field may statement. also When more than statement, the affects the situations: be wused one to subscript receiving order results in of which the | field the move. is named software : and the 1in the another name evaluates ~Consider | the in the referenced the same same MOVE subscripts following Situation 1 MOVE FIELDI (FIELD2) TO FIELD2 FIELD3. Situation 2 MOVE FIELDl TO FIELD2 FIELD3(FIELD2). two | Figure 3-8 Subscripted MOVE Statements In situation 1, the software evaluates FIELD1(FIELD2) only before it moves any data to the receiving fields. 1In effect it if the statement were replaced with the following statements: MOVE FIELD1 (FIELD2) MOVE TEMP TO FIELD2. MOVE TEMP TO FIELD3. | TO TEMP. 3-12 NON-NUMERIC CHARACTER HANDLING once, is as In situation 2, the software before moving the data into it to FIELD2). Thus, subscript value. with the following MOVE it uses the In effect, statements: FIELDl1 TO evaluates FIELD3(FIELD2) (but after moving the data newly stored it as is if value the of immediately from FIELD1 FIELD2 statement were as ‘the replaced FIELD2. MOVE FIELDl1 TO FIELD3 (FIELD2). 3.6.5 Common Errors, MOVE 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 item 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 effect on the action of 3.6.6 Format 2 - MOVE CORRESPONDING Format 2 of elementary MOVE the MOVE items statement. statement from When the elementary items in items in the receiving example: | 01 A-GROUP. allows group group move. the programmer item to <corresponding another, phrase 1is the sending field are moved to field whose data-names are | | 02 FIELDI. MOVE one a to move multiple by using a used, single selected those elementary identical. For 01 B-GROUP. | 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 FIELDl1 TO FIELD2 NON-NUMERIC CHARACTER HANDLING 3-13 The preceding examples are statements: MOVE equivalent to the | A OF FIELDl following | TO A OF series of MOVE ' FIELD2 MOVE C OF FIELDl TO C OF FIELD?2 MOVE E OF FIELDl1 TO E OF FIELD2 3.7 THE STRING STATEMENT The STRING statement concatenates the contents of two or more fields The into a single statement has sending field. many forms; the simplest 1is equivalent, in function, to a non-numeric MOVE statement. Consider the following illustration; 1if the two fields are the same size, or if the sending field (FIELDl) 1is 1larger, the statement 1is equivalent to the statement, MOVE FIELDl1 TO FIELD2. | — STRING FIELD1 DELIMITED BY SIZE INTO FIELD2. Sample Figure 3-9 STRING Statement | If the sending field is shorter than the receiving field, an important difference between the STRING and MOVE statements emerges: the software does not fill the receiving field with spaces. Thus, the statement may leave some portion unchanged. Additionally, the receiving field with description. fills the insertions. no JUSTIFIED clause Thus, the data movement receiving field from 3.7.1 of | Multiple Sending field must be an the receiving field | | elementary alphanumeric or editing characters in its of the STRING statement always left-to-right with no editing Fields An important,characteristic of the STRING statement is its ability concatenate a Consider following the series TN STRING of sending example of fields the STRING into one receiving to field. statement: STRING FIELD1A FIELD1B FIELDIC DELIMITED BY SIZE INTO FIELD2. Figure with 3-10 the STRING Statement 2 Concatenation 3-14 NON-NUMERIC CHARACTER HANDLING In this sample STRING statement, FIELDIA, FIELD1B, and FIELD1C are all sending fields. (FIELD2) in the The order software in which moves they them appear in to the the receiving statement, to right, resulting in the concatenation of their values. field from left If FIELD2 is not large enough to hold all three items, the operation stops when it is full. If this occurs while moving one of the sending fields, the software ignores the remaining characters of that field and any FIELD2 the other became rest of sending fields full while FIELDIB and not receiving all of yet processed. FIELD1B, the For software example, would if ignore FIELDIC. 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 (FIELD1C in Figure 3-10). nor space-fill field. the The software does not remaining character alter positions of the contents the receiving \ | 7 The sending ~constants statement . between fields (except sets the up STATE may for an and STRING CITY be 1literal). address ZIP label SPACE STATE BY fields may also statement wuses (A-TABLE) into subscript or be an single the and example, literal figurative the period following and space " ZIP INTO Figure 3-11 as Sending subscripted. subscripts a ". SIZE Literals Sending with literals For fields: DELIMITED ’//\\ non-numeric ALL field to ADDRESS-LINE. Fields For concatenate (A-FOUR). (I, example, the of the elements course, following of a must table be a index-name.) STRING A-TABLE (I) A-TABLE (I+l) A-TABLE(I+2) A-TABLE (I+3) DELIMITED BY SIZE INTO A-FOUR. Figure 3-12 Sending Fields Indexed 3.7.2 The POINTER Phrase Although the it the STRING statement normally starts at the receiving field, with the POINTER phrase it is scanning however, at remains another point within the field. left-hand end of possible to start (The scanning, left-to-right.) NON-NUMERIC CHARACTER HANDLING 3-15 o~ MOVE 5 TO P. | STRING FIELD1A FIELD1B DELIMITED BY SIZE INTO FIELD2 WITH POINTER P. Figure 3-13 Sample POINTER Phrase When the POINTER phrase 1is used, 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 FIELDI1A into character position 5 of FIELD2 (the left-most character position of the receiving field is character position 1) through 4 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 at - compile time, fields of the STRING statement are fixed in size 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 left-hand end of the sending field. The DELIMITED BY phrase, written with a data-name or literal, instead of the word SIZE, performs this operation. (The delimiter 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 total, until it either exhausts the sending receiving field.) sending field, in field, or fills the | | Consider the following example: STRING CITY SPACE STATE ". DELIMITED BY SIZE Figure Delimiting " ZIP INTO ADDRESS-LINE. 3-14 with the Word SIZE If CITY is a 20-character field, the result of shown in Figure AYER__ 3-16 3-14 might look \ like MA. the 01432 16 spaces NON-NUMERIC CHARACTER HANDLING the following: STRING operation A far more attractive operation produce the AYER, To on MA. printout can be produced follow1ng by hav1ng ~the STRING 01432 accomplish this, use the figurative the sending field; thus, constant SPACE as a of pointing delimiter / MOVE 1 TO P. STRING CITY DELIMITED INTO STRING ", " BY SPACE ADDRESS-LINE STATE ". DELIMITED INTO " BY Figure \ N POINTER P. WITH POINTER P. SIZE ADDRESS- LINE SPACE WITH ZIP 3-15 as a Delimiter i / ,"'A/ { This sample coding ~one character ~receiving field uses the position to pointer's beyond enable the characteristic the second 1last STRING position one character past where the (The first STRING statement moves data a space character STRING statement another literal, The delimiter statement names the to by separate and can it effect source a be match the the the the lines, the 1literal, for Thus, as shown in operation of the statement, simplifies debugging.) to in begin the at a SPACE. The second /STATE. field, Single 'STRING field.) within phrase after following example. this but to 2-character field BY the preceding delimiter the each DELIMITED applies. as of statement replaced first STRING statement stopped. characters until it encounters 5—character‘ZIP varied repeating which same -- adds character the shorter (Placing example, improves a has field statement has the no program sending operands effect on on the readability and STRING CITY DELIMITED BY SPACE n" , Zz1P n STATE n . DELIMITED INTO LI BY SIZE ADDRESS-LINE. Figure Repeating The the 3-16 DELIMITED BY Phrase sample names, between STRING statement in Figure 3-16 cannot handle 2-word city as New York, since the software would consider the space the two words as a match for the delimiter SPACE. A longer such delimiter, such as two or three spaces (non-numeric solve this problem. Only when a sequence of characters delimiter will the movement stop for that data item. NON-NUMERIC literal), matches CHARACTER HANDLING can the 3-17 With a 2-byte delimiter, the same statement simpler form: can be rewritten 1in a { STRING CITY ", " STATE ". " ZIP DELIMITED BY " " INTO ADDRESS-LINE. Figure 3-17 Delimiting with More Than One Space Character Since only the CITY field may contain two consecutive same as moving (delimiting by SIZE). 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 the full field - Data movement under control of a data-name slower in execution speed or literal than movement delimited is by SIZE. generally The example in Figure 3-17 illustrates a frequent source of error 1in the use 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, if the However, fleld 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 1is not predlctable, it may be difficult to tell overflow an " whether the size of the receiving field is adequate, and 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 FIELD2 WITH POINTER PNTR ON OVERFLOW GO TO PN57. Figure 3-18 ON OVERFLOW Phrase - /""\\\ The '3-18 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 termlnates the operatlon immediately. The ON OVERFLOW phrase cannot dlstlngulsh 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 FIELDIA PIC 01 FIELD2 PIC XXX VALUE "ABC". XXXX. . DELIMITED BY "B" INTO FIELD2. STRING FIELD1A FIELDl1A "C" DELIMITED BY STRING FIELD1A QUOTE DELIMITED BY SIZE INTO FIELD2.. FIELD1A DELIMITED BY SIZE INTO FIELD2. STRING FIELD1A FIELD1A 19 [] [] STRING FIELD1A FIELD1A FIELD1A FIELDIA STRING [] > W N PROCEDURE DIVISION. 6. MOVE FIELD1A INTO FIELD2. 2 P. TO "C" INTO FIELD2. "C" ) STRING FIELD1A INTO DELIMITED BY "AC" DELIMITED BY FIELD2 WITH POINTER ~Various Illustratlng "C" P. Figure 3-19 STRING Statements the Overflow Condltlon The results of’executing the numbered statements follow: | Table Results Preceding Value of FIELD2 after the STRING operation l. ABC" 2. ABCA 3. ABAB 4, AAAA 2. ABAB 6. AABA | Sample the Statements Overflow? | | | | 3-2 of | i E | | ~ ~ No Yes No No Yes No NON-NUMERIC CHARACTER HANDLING 3-19 3.7.5 Subscripted Fields All data-names the pointer used in STRING Statements in the STRING statement may value may be used as a be subscripted, and subscript. Slnce the p01nter value might be used as a subscript on one or more of the fields in 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 p01nter of each sending field. Consider 1 STRING TO out P. "ABC" g MOVE after it moves the last character the following sample coding: SPACE DELIMITED BY R WITH POINTER STRING SIZE r/ "DEF" INTO 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 value 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. | - updating characteristics of the pointer when applied 1 TO P. / MOVE —— \ Now, con51der the to subscripting: STRING CHAR(P) CHAR(P) CHAR(P) CHAR(P) DELIMITED BY SIZE INTO R WITH POINTER P. Figure 3-21 Subscripting with the If one CHAR is after into R as a l-character field in a table, field has been moved and each if and CHAR(4). two if after they they had each had 1If CHAR field been NON-NUMERIC the ©pointer the software been subscripted as is 2-character field, a CHAR(1l), the increases by move them will CHAR(2), pointer CHAR(3), increases by has been moved and the fields will move into R as subscripted as CHAR(l), CHAR(3), CHAR(5), and CHAR(7) . 3—-20 Pointer CHARACTER HANDLING AN Thus, the software evaluates the subscript of sending a immediately before it considers the item as a sending item. item once, The software evaluates the subscript of a receiving 1tem only once, at Therefore, if the p01nter is used the start of the STRING operatlon. changes occurring to the as a subscript on the receiving field, statement will not alter STRING the of execution p01nter during the the choice of which receiving string is altered be can Even the dellmlter fleld subscripted, and it too can be subscripted with the pointer. The software re-evaluates the delimiter subscript once for each sending field, immediately before it compares Thus, by subscrlptlng 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 choos1ng 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 TIMES X OCCURS D PIC TO | P. "ABC" n ABC " "ABC" INTO DELIMITED BY D(P) R WITH POINTER P. Figure 3422 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 3-3 Results of the Preceding Sample Statements DTABLE Value | R Value ABCDEFG (Unchanged) BCDEFGH AABABC CDEFGHI ccccccce ABABCABC -~ | ABABAB NON-NUMERIC CHARACTER HANDLING 3-21 | NOTE (f 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 1involving the use of the pointer field as a subscript, may programs that will not perform way on other COBOL compilers. produce the same If the pointer field is not wused as a subscript on any of the fields in the statement, the point at which the software evaluates the subscripts 1is immaterial to the execution of the statement. Thus, by avoiding the use of the pointer results can compilers 3.7.6 Common Errors, as a be that subscript, expected adhere to from 1974 | uniform all ANS | COBOL ( B . COBOL. STRING Statement Themdst common errors made when writing STRING statements are: using the word “TO" instead of "INTO" (fi ° forgetting to write "DELIMITED BY SIZE?;’ \ e forgetting ® initializing ° forgetting when it is to initialize the the pointer to provide desirable. to for pointer; 0 instead space fill of of 1; the receiving field 2N | ® | 3.8 THE UNSTRING STATEMENT The UNSTRING field statement into multiple The statement has to a non-numeric the sample many MOVE statement regardless of the UNSTRING disperses receiving forms; the statement. 1is relative FIELDl1 the contents simplest Consider equivalent sizes of INTO a single the is equivalent the following to MOVE two fields. FIELD2. Figure 3-23 Sample UNSTRING Statement 3-22 of sending fields. NON-NUMERIC CHARACTER HANDLING FIELD1 in function illustration; TO FIELD2, s an item or a group may be either (FIELDl) field sending The The receiving alphanumeric, or alphanumeric edited elementary item. field (FIELD2) may be alphabetic, alphanumeric, cannot specify any type of editing. or numeric, | but it 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 integer; it further, automatically truncates or zero 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 1s 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 FIELD1 INTO - FIELD2A FIELD2B FIELD2C. Figure 3-24 Multiple Receiving Fields The software In this sample statement, FIELDl is the sending field. per forms 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 grou | 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) (FIELD2A, FIELD2B, of FIELD2A determines the size The long. FIELD1l is 15 characters number of characters for the first move. The software scans across FIELD]l until the number of characters scanned equals the size of It then moves those first five characters to FIELDZ2A, (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 software begins this move by scanning across FIELDl 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 the the FIELDl. sixth scanner FIELD2C through the to next the determines the tenth size characters (eleventh) of the to character last move this example) and causes characters 11 through 15 of FIELD1l moved into FIELD2C, thus terminating this UNSTRING operation. (for to be 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. If the receiving field is numeric, the move operation will convert the would happen and data to the numeric form. if the fields under discussion were manipulating the values shown in For had the example, the following Table 3-4 | Values Moved Into the Receiving Flelds Based on the Value in the Sending Field 'FIELD1 PIC | X(15). VALUE FIELD2A PIC FIELD2B X(5) 1IS: PIC S9(5) LEADING ABCDE1234512345 XXXXX0000100123 ABCDE XXXXX | consider what descriptions data table: | ~ FIELD2C ~ PIC S5999V99 SEPARATE +12345 +00001 13450 1230 FIELD2A is an alphanumeric field and, therefore, the software conducts an characters. the elementary non-numeric move with simply first FIELDZB; however, has a leading separate sign'that is not included itssize. Thus, the software moves only five numeric characters generates a positive sign in the separate 31gn p031t10n. | 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 low-order digit a +0 (or the ASCII character, sign { ) . character with sign (There is no simple way to have UNSTRING recognize a or a decimal point in the sending field.) If the sending field is shorter than the sum of the sizes of the receiving fields, the software ignores the remaining receiving fields. If it reaches the end of the sending field before it reaches the end of ‘one 0of characters remaining the receiving decimal p01nt aligns for numerlc data. 3-24 fields, the into that receiving field. character positions with and zero fills NON-NUMERIC CHARACTER HANDLING software moves the scanned It left-justifies and fills the spaces for alphanumeric data, or the remalnlng ‘ character « positions o "Consider the following examples of a sending field that is too short. (The statement is UNSTRING FIELD1 INTO FIELD2A FIELDZ2B. FIELDZA'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 shown.) Table 3-5 Handling FIELD]l PIC X(6) VALUE a Sending Field that FIELD2B is Too Short FIELD2B PICTURE 1IS: Value after UNSTRING Operation 1IS: | N ‘ e —————————ee———— e ———) , - ABCDEF ABC246 0024F S9V999 S9999 LEADING 3.8.2 DEF | XXXXX 599999 600 +0246 SEPARATE The DELIMITED BY Phrase The size of the data to be moved can be controlled rather than by the size of the receiving phrase supplies the delimiter characters. field. by a delimiter, The DELIMITED BY o UNSTRING delimiters are quite flexible; they can be 1literals, figurative constants (including ALL literal), or 1identifiers (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 the Subscripted Fields following figurative constant, sample SPACE, in UNSTRING Statements. UNSTRING as a delimiter: UNSTRING FIELD1 DELIMITED BY SPACE Figure 3-25 Delimiting with a Space statement; it uses the EREEE 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 all of the scanned (non-space) characters that precede that space it finds no space character, it If (FIELD2). field receiving the moves the entire sending field. 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 "*" FIELD2). | Results FIELD1 FIELD2 X(6) VALUE Table 3-6 Delimiting with ~ FIELD2 PICTURE IS: ABCDEF | AFTER ABC X(7) XXX ¥***** ABCDEF JUSTIFIED DEF X XX _*ABCDE | XXX CAFx kxR XXX JUSTIFIED 246 A 59999 12345% 024F S9999 SEPARATE | 2345+ TRAILING 2468%* S999V9 : SEPARATE | *246%* the VALUE UNSTRING XXX If | IS: | an Asterisk \'\ PIC of ‘/ INTO 9999 delimiter | +4680 LEADING f matches the 0000 first character in the sending field, the software considers the size o0f the sending field to be zero. The movement operation still takes place, however, and fills the rece1v1ng field with spaces or zeroes depending on its class. A delimiter may also be applied to an multiple receiving fields: UNSTRING statement that has UNSTRING FIELDl’DELIMITED BY SPACE INTO FIELD2A FIELDZB;- | Figure 3 26 with Multiple Rece1v1ng De11m1t1ng The sample instruction in Figure 3- 26 causes FIELD1 flnds searching a match, scanner to for it moves the next that matched. It then matches the delimiter. 3-26 a character the Fields the that matches scanned characters to character resumes p051t10n to the scanning FIELDl NON-NUMERIC CHARACTER HANDLING software to the delimiter. FIELD2A and sets right for scan 1If a of the it the character character ‘that Pl~, If the software between the finds a match, character that it moves all of the characters that lie first matched the delimiter and 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 receLV1ng 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). operation that (UNSTRING FIELD1 Table 3-7 Results of Delimiting Multiple Receiving Fields FIELD1 VALUES AFTER UNSTRING PIC X (8) FIELD2A FIELD2B VALUE PIC PIC IS: ABC*DEF* || ABCDE*FG x<3) aBC FG A *AB*CD** **ABCDEF A*BCDEFG ABC**DEF | L A ABC Akkkkk kR X (3) DEF ABC INIXEEEEE OPERATION B AB ‘ BCD B | A The last two examples illustrate the limitations of delimiter. = Accordingly, the delimiter may be character and it may be preceded by the word ALL. a single character longer than one | | The follow1ng table shows the results of an UNSTRING operation uses a 2-character dellmlter (UNSTRING FIELD1 DELIMITED BY "**" FIELD2A FIELDZB) | that TNTO ) Table 3-8 Results of Delimiting - with Two Asterisks FIELD1 PIC W?- X(8) VALUES AFTER UNSTRING OPERATION FIELD2A VALUE 1IS: PIC | ABC**DEF A*B*C*D* AB***C*pD AB**C*p* B | ABC ] A*B AB AB || =~ ¢‘ AB AB AB . | 1 | XXX JUSTIFIED DEF : ~ ~_ C*D *D* CD CD* : - /—-\\ |{ PIC | )| ' FIELD2B . | AB**Cp** || AB***Ccp* )] AB*****CD T XXX NON-NUMERIC CHARACTER HANDLING 3-27 N 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 wuntil the scanning operation finds a match. At this point, the software scans farther, looking for additional consecutive strings of characters that considers the "ALL delimiter" repetitions of 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 FIELDl1 DELIMITED BY ALL "*" INTO FIELD2A FIELD2B). Table 3-9 Results of Delimiting with ALL Asterisks FIELD1 PIC X(8) VALUE 1IS: VALUES AFTER UNSTRING OPERATION FIELD2A | FIELD2B PIC XXX -~ PIC XXX JUSTIFIED ABC*DEF* ~ ABC**DEF ABC | A AXPkk*kk A The next combines BY ALL - ABC Akkkkkkp A*CDEFG | | DEF DEF F | F A | EFG table illustrates the results of an UNSTRING operation that ALL with a 2-character delimiter (UNSTRING FIELDl1 DELIMITED "**" INTO FIELD2A FIELD2B). Table 3-10 Results of Delimiting with ALL Double Asterisks FIELD1 PIC X(8) VALUE IS: ' | ABC**DEF " AB* *DE* * I A***D*** Akkkkkkk 3-28 VALUES AFTER UNSTRING OPERATION PIC XXX PIC XXX ~ ABC DEF AB : | A | JUSTIFIED A DE *D - NON-NUMERIC CHARACTER HANDLING * In addition to unchangeable delimiters, such as 1literals and figurative constants, delimiters may be designated by identifiers. Identifiers (which may even be subscripted data-names) permlt variable delimiting. Con51der the following sample statement: - UNSTRING FIELDl1 DELIMITED BY DELI1 INTO FIELD2A FIELDZ2B. | The data-name, Figure Delimiting with DELl1l, 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 contains a subscript, the subscript may be varied as a side effect of the UNSTRING operation. The evaluation of subscripts is discussed 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 only requirement of the list connected by the word and delimiters of is that dellmlters 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 FIELD1 ALL n , n ; n n TAB DELIMITED BY SPACE OR OR OR OR CR INTO FIELD2A FIELD2B FIELD2C Figure 3-28 Multiple Delimiters Table 3-11 illustrates ASCII horizontal the potential of this statement. The tab (represented by the letter t) and carriage return (represented by the letter r) characters represent single character fields contalnlng the tab and carrlage return characters. NON-NUMERIC CHARACTER HANDLING 3-29 Results Table 3-11 of the Multiple Delimiters Shown in Figure 3-28 EIELDl- FIELD2A FIELD2B FIELD2C PIC PIC PIC PIC X(12) A,0,Cr XXX 9999 A 0000 A 0456 A 0003 AttBr A 0000 B A,,C A 0000 C ABCD, 4321,% ABC - 4321 Z At456, A E 3 9 t--tab character, 3.8.3 The r--carriage return | XXX C | E . 9 character COUNT Phrase The COUNT phrase keeps stores the length in a track of the size of the user-supplied data area. sending string | and The length of 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 in size) some data may be truncated and, the program's To use words logic may require the phrase, simply COUNT IN and an statement: follow the receiving field name with the identifier. Consider the following sample | | UNSTRING FIELDl INTO this information. DELIMITED BY ALL FIELD2A FIELD2B COUNT COUNT IN FIELD2C. this sample statement, "*" COUNT2A COUNT2B | Figure In IN 3-29 The COUNT Phrase the software will count characters between the left-hand end of FIELD]l and in FIELD1l and place that value into COUNT2A: thus, the the 3-30 size of delimiter 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). TN The software then counts sending field the and places number that value of characters The phrase should be used only Where, needed; moved to in into COUNT2B. is in this not needed, second example the length phrase of the string 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 ‘ FIELD2C the so no COUNT | 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 into 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 useful when: (1) the statement contains a delimiter 1list, (2) any one of the items in the list might have delimited the field, and (3) 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 sending string and the delimiter character that terminated it. To use the DELIMITER phrase, simply follow the with the words DELIMITER IN and an identifier. the delimiter character in the area named by the the following sample receiving field the name (The software places identifier.) Consider 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 the character in DELIMA. 3-30 DELIMITER Phrase first sending string (or characters) DELIMA, then, to FIELD2A, the software takes that delimited that string and places it 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 \ software then moves the places its delimiting second character sending string into DELIMB. to FIELD2B and 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 1s 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 in 3.8.5 The the phrase). Both - subscripted or correct order are used together, they must (DELIMITER phrase preceding the COUNT of the data items named in these phrases may be 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.) POINTER Phrase Although the UNSTRING statement normally starts at the 1left-hand end of the sending field, the POINTER phrase permits the user to select a character position in the sending field for the software scanning. (The scanning, however, 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 its 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 1nterruption) to begin the next scannlng operation. The program may then examine the new position, the receiving field, the delimiter value, 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 preceding string of data. The POINTER statement. ~ accompanylng 3-32 phrase must Consider the follow dependent the on 1last ' the context receiving item of the 1in the following two UNSTRING statements with their POINTER phrases and tests- NON-NUMERIC CHARACTER HANDLING | TN The MOVE 1 TO UNSTRING P. FIELDl 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 FIELD1 DELIMiTED BY ... The Figure 3-31 POINTER Phrase PNTR contains the current position field. WITH POINTER PNTR. of the scanner in ~additional sending strings ' ~ \\ : § Sending one, the the in FIELDIl. Since the software considers the left-most character to position the The second UNSTRING statement uses PNTR to begln scanning 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 | | FIELD1-CHAR OCCURS 40 coding: 01 FIELDI. 02 UNSTRING FIELDl WITH IF TIMES. POINTER PNTR. FIELD1-CHAR(PNTR) = "X" ... Figure 3-32 Examining the Next Character By Using the Pointer Data Item as a Subscript Another way to examine the next character of the sending field use the Consider the statement sample to coding move in is to it to a l-character receiving figure 3-33. I : \: field. UNSTRING NON-NUMERIC CHARACTER HANDLING 3-33 UNSTRING FIELDI1 WITH POINTER PNTR. UNSTRING FIELD1 INTO CHAR1 WITH SUBTRACT 1 FROM PNTR. IF CHARLI = "X" ... POINTER PNTR. Figure 3-33 Examining the Next Character By Placing It Into a l1-Character Field ‘The program must decrement PNTR in order for this case to work 1like before the the same receiving fields that several :.receiving fields, the the one illustrated in Figure 3-32, since the second statement will increment the pointer value by 1. . .- The program must initialize the POINTER phrase data item UNSTRING UNSTRING statement uses it. The software will terminate the UNSTRING operation if the initial value of the pointer is: 1less 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.) o ~TheflPOINTER and TALLYING phrases may be UNSTRING the but, when both are wused :‘together- in used, the POINTER phrase must TALLYING phrase. o | /TN precede statement; 3.8.6 The TALLYING Phrase The TALLYING phrase received data from the counts sending When an UNSTRING statement the number field. contains of o - | | - 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 "," OR ALL SPACE INTO FIELD2A FIELD2B FIELD2C FIELD2D FIELD2E 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 plus the number of sending strings acted upon by the UNSTRING command 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 items The data of the field names, the DELIMITER and COUNT phrases. 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 un31gned and, if they are DISPLAY usage, they may contain any desired | e- sign option. The data items for both phrases may be subscrlpted or indexed, or they may be used as subscrlpts 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 unt11 it exhausts the sending kY5 ! ~ I/“‘ PARl1. field. MOVE 1 TO PNTR, TLY. UNSTRING FIELD1 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 codlng causes program control to loop through the UNSTRING scan across FIELDl with to PNTR, the pointer, using statement, until string sending a Each comma isolates successive executions. return character or the end of <carriage a either reaches control FIELDl. If it reaches the end of the field without encountering a space into the a software places the return character, 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 it serves as a subscript on the receiving field. 1In effect 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 supplied and loaded by the UNSTRING/TALLYING statement by adding’ the to the coding in Figure 3-35, as is shown in Figure - COUNT 1IN phrase 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 the above example, is one greater than the number of receiving fields acted upon by the UNSTRING operation. This is because the data item must be initialized to a value of one 1in order to be used as a subscript for the first receiving item. | 3.8.7 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 pointer greater statement is about this situation, the software before it moves any data. Thus, receiving 2. to be executed data item contains a value of than the size of the sending field. fields remain 1less When and its than one or it detects executes the OVERFLOW phrase the values of all of the 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 it 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 1t), the the to move off the software will not end of execute OVERFLOW phrase. ~ -\ Consider the following set of instructions, which cause program ‘control to execute the UNSTRING statement repeatedly until it exhausts the sending field. receiving field. which accomplishes MOVE PAR1. 1 The TALLYING data item is a subscript indexing the (Compare this the same thing.) TO UNSTRING TLY 1loop the PNTR. TALLYING IN Using "," OR CR TLY PARI. Figure 3-37 the OVERFLOW Phrase NON-NUMERIC CHARACTER HANDLING one in v FIELDl1 DELIMITED BY INTO FIELD2(TLY) WITH POINTER PNTR ON OVERFLOW GO TO 3-36 with Figure 3-35, \ N P ,—\‘ NOTE The overflow condition also occurs 1if a pointer data item lies value of 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 fields within the statement (such as subscripting the receiving field the TALLYING data item as discussed above), it is important to with these software evaluates the understand how often and exactly when subscripts and indexes. This sub-section discusses the frequency and times of subscript evaluation. The software evaluates subscripts and indexes on the following items only once, at the initiation of the UNSTRING statement; thus, change in subscript values during the execution of the statement no effect on these any has fields: 1. 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 in the statement (which is the same order as below): o field, 1. Receiving 2. DELIMITER data item, 3. COUNT data item. The software evaluates any subscripts and indexes on the data-names in the DELIMITED BY phrase (delimiters) immediately before it scans each re-evaluates it Thus, sending string looking for a delimiter match. 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 fields, are the programmer must be aware of the point at which receiving these items updated: ® POINTER data-item, ® TALLYING data-item, ® COUNT data-item, ® Another receiving field. Figure 3-38 illustrates, with a flow chart, the sequence of evaluation operations: '— EVALUATE ALL SCANNING FOR SUBSCRIPTS MATCHES DELIMITER &w (([TEvALUATE | s CONTINUE & REPETITIVE STORE SCANNER IN FIELD PRESENT DATA ITEM SUBSCRIPT m= fl F POINTER RECEIVING 7 < | DELIMITER PHRASE POINTER XL [ N FIELD FOR DELIMITER RECEIVING g SUBSCRIPT ? ALL DELIMITER IF TALLYING =) RECEIVING PRESENT IF COUNT PHRASE PRESENT MATCH STORE DELIMITER w EVALUATE DELIMITER = STRING IN -— S S%T'\fNTER MOVE SENDING STRING TO RE'(:E:EéL\-/I;NG ? L FIELD PHRASE EVALUATE ([ COUNT ADD 1 TO TALLY1I_r\éfn DATA I ' SENDING FIELD FIELD EXHAUSTED SUBSCRIPT ? STORE COUNT VALUE IN COUNT FIELD RECEIVING | VES PN SENDING E _ SCAN S MORE FIELDS ? H-MK-00046-00 Figure Sequence of 3-38 3-38 Subscript Evaluation NON-NUMERIC 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 1t 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: e Leaving the OR connector out of a delimiter list; @ Misspelling or interchanging the 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 is not needed; it as TO; UNSTRING FIELD1 DELIMITED BY SPACE INTO FIELD2A DELIMITER IN INTO FIELD2B DELIMITER IN INTO FIELD2C DELIMITER IN Figure 3-39 Erroneously Repeating the Word ) Writing the POINTER and TALLYING phrases (POINTER must 3.9 THE precede order thus: OR TAB DELIMA DELIMB DELIMC. INTO in the wrong order TALLYING). INSPECT STATEMENT The INSPECT statement examines the character positions in a field counts that or field. replaces certain characters (or groups of characters) and in 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 TALLYING operation (which counts certain characters in the field) and the REPLACING operation (which replaces certain characters in the 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 under which only to stated both those characters conditions. cause a scan of INSPECT FIELDl that match a given Consider the the complete TALLYING TLY - Figure Sample FOR ALL 3-40 for sample string statements, field: | "B". | INSPECT...TALLYING This statement scans FIELD1l looking finds a B, it increments TLY by 1. character following Statement the character , B. Each time it Wherever it INSPECT FIELDl REPLACING ALL SPACE BY ZERO. Figure 3-41 INSPECT...REPLACING Sample Statement This statement scans FIELD1 finds a space character, it looking for space characters. replaces it with zero. One contain INSPECT REPLACING statement phrase. can However, when both used 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, BEFORE/AFTER Phrase 7 The : fj 3.9.1 A— X, ! \‘ | 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.) " The BEFORE/AFTER phrase acts as a delimiter and the area The following precede of the the field sample percent being statement sign (%) (possibly) 1in would count FIELDI. only | INSPECT FIELD1 TALLYING TLY FOR ALL Sample 3-40 restricts inspected. ZEROES BEFORE "g". Figure 3-42 INSPECT...BEFORE NON-NUMERIC CHARACTER HANDLING Statement the =zeroes that | The delimiter (the percent sign in the preceding sample statement) can be single a constant. ® - character, a string of characters, or any figurative Further, it can be either an identifier or a literal. If the delimiter is an identifier, it must be an elementary It may be alphabetic, DISPLAY usage. of item data editing may contailn it and, alphanumeric, or numeric, it had if as item the treats always compiler The . characters (It does this by been described as an alphanumeric string. d Section implicit redefinition of the item, as describein 3.9.2.) ¢ ' If the delimiter is a literal, it must be non-numeric. The software repeatedly compares the delimiter characters against an equal number of characters in the field being inspected. If none of if insufficient characters the characters matches the delimiter, or (at the right-hand endy), the comparison full a for field remain in the software considers the comparison to be unequal. 1illustrate the The examples of the INSPECT statement in Figure 3-43, field being the in match a finds character delimiter the way (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.) "FIELDl1 VALUE INSTRUCTION ABCDERPZHZY , 4" _/”“'\\ N \ INSPECT FIELDl...BEFORE "E". INSPECT FIELDl...AFTER "E". XBZPPFGHI INSPECT FIELDl...BEFORE "K". INSPECT FIELDl...AFTER "K". ABCDEFGHI ABZDEFPRBHA INSPECT FIELDl...BEFORE "AB". INSPECT FIELDl...AFTER "AB". ABCPEFGHZ XBCDEFGHI INSPECT FIELDl...BEFORE "HI". INSPECT FIELDl...AFTER "HI". ABCDEFGRZ XBCDEFGUY ". INSPECT FIELDl...BEFORE "I ". ~ INSPECT FIELDl...AFTER "I ABCDEFGHI KBZPREFPGHZ 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 the operation before beglnnlng the further discusses the importance of it scans for establishing actual 1inspection. the separate scan. N 3.9.2 The Implicit Redefinition software statement be described as the INSPECT This requires redefinition fields fields. is If the edited, field was or unsigned movement occurs at as alphanumeric. @ certaln referred If conducted as one to o0f by these the INSPECT was another data class, the compiler redefines that field so statement can handle it as a simple alphanumeric string. implicit ® that alphanumeric follows: described as alphabetic, numeric, the compiler simply This run fields alphanumeric redefines is a compile-time operatlon- time. no it data - 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 1its 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 compller never moves an 1mp11c1tly redefined 1tem from its storage gp051t10n. All redefinition occurs The position of an implied decimal not affect implicit redefinition. - 3-42 NON-NUMERIC in place. point CHARACTER HANDLING on numeric quantities does 7N Table | 3-12 Original, Altered, and Restored Values Resulting from Implicit Redefinition ORIGINAL VALUE ALTERED 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) A B C D H I 8 9 (48) (49) H I (38) (39) (48) (49) } (7D) } (7D) 0 (30) N (4E) 5 (35) N (4E) R (52) 9 (39) R (52) 0 (30) 0 (30) 5 (35) 7 J K L M J K L M 1 (31) 2 (32) 3 (33) 4 (34) (4A) (4B) (4C) (4D) 1 (31) 2 (32) 3 (33) 4 (34) { (7B) 1 (31) 2 (32) 3 (33) 4 (34) A (41) B (42) C (43) D (44) 5 (35) E (45) 7 (37) G F (46) 6 (36) 6 (36) (37) All other values (47) H (48) I (49) 8 (38) 9 (39) 8 (38) 9 (39) (42) (4B) (4C) (4D) O (4F) P (50) Q (51) 6 (36) 7 (37) 8 (38) O (4F) P (50) Q (51) 3.9.3 { (7B) 0 (30) { (78) RESTORED VALUE { (7B) 0 (30) The INSPECT Operation of the type of Regardless 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 operation let's analyze the INSPECT statement itself: INSPECT FIELDl1 TALLYING TLY The field being——d// . inspected FOR ALL followed phrase by an must - phrase Figure 3-44 ‘ INSPECT Statement the INSPECT statement requires that a field be named inspected (FIELDl1 above); the field name must be be operation be phrase followed by (TALLYING one or more TLY TALLYING above); identifiers above). These identifiers or literals comprise to be compared to the field being inspected). makes up the "argument list". ® "A". The delimiter phrase The format of which is to BEFORE conducted, The afgfiment The operation Sample "B" is . or and, literals that ("B" the "arguments" (items More than one argument. Arguments Each argument in an argument 1list can have other fields associated with it. 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 field argument with a character or being inspected. REPLACING Arguments INSPECT FIELD1 REPLACING ALL replacing Sample "O0" BY "$". argument Figure 3-45 REPLACING Argument Each argument in an argument list that is used in a REPLACING operation must have a replacement item (S 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. If (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. 1If 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 Setting the Scanner - The INSPECT operation begins by setting 3.9.3.1 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 an argument has a BEFORE/AFTER phrase assoc1ated with it, that argument has a delimiter ~and may not be eligible to in participate a every at comparison position of the scanner. Thus, each argument 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 assoc1ated 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 in the comparison. When the delimiter finds a match, the software matched retains the character position beyond the , becomes active. INSPECT FIELD1 FOR ALL string; - TALLYING "B" TLY AFTER "X". Figure 3-46 Sample AFTER Delimiter If FIELD]l character the scanner reaches or passes this position, the argument then, when in Figure 3-46 has a value of Phrase "ABABXZBA", the argument B inactive until the scanner finds a match for the delimiter X. remains scans character 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 situations 1longer than one INSPECT...TALLYING - where the character. statement that is 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 FIELD1 DELIMITER VALUE . | ARGUMENTV- CONTENTS OF ACTIVE TLY AT AFTER /"‘l\.\ ARGUMENT AND SCAN - POSITION BXBXXXXBB 6 2 "B" AFTER "XX" XXXXXXXX BXBXBBBBXX 3 never 0 0 "X" AFTER ~ "XX" BXBXXBXXB XXXXXXXX BBBBBBXX 6 3 never 2 6 0 "B" AFTER "XB" BXYBXBXX XBXBXBXB 0 3 BBBBBBXB 7 3 never XXXXBXXXX 6 XXXXBBXXX XXBXXXXBX 6 4 0 1 1 "BX" | AFTER "XB" Where When an argument state when inactive/active the has states scanning an Figure 3-47 | Arguments Become Active reverse begins, 0 associlated roles: and BEFORE the argument becomes inactive in a Field delimiter, at is the in an active the character position that matches the delimiter. Additionally, regardless of the presence of the BEFORE delimiter, an argument becomes inactive when the scanner approaches remaining characters are and in argument. (In a match in so the Since field the right-hand end of the field fewer in number than the characters such a case, the argument cannot possibly find it becomes inactive.) the BEFORE/AFTER delimiters field, the before can be software are recognizes and found on a separate scan of the the the sets up the delimiter boundaries it scans for an argument match; used as arguments and delimiters therefore, the same in the same phrase. characters 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 in 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 f1nd a match, remaining arguments operation on the in the list character. and The the conducts scanner software the moves TALLYING to a new ignores any or REPLACING 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 to updates it. 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 executes 3.9.4 those character positions the entire statement again. Subscripted Fields in again unless program control INSPECT Statements Any identifier named in an INSPECT statement indexed. may be subscripted or ¥ /”—\\\V . 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 TALLYING TLY X(TLY). /A\‘ Sample In this sample statement, operatlon. Figure 3-48 Subscripted Argument the software evaluates the address of X(TLY) only once, before it begins inspecting the field; hence, it will ~evaluate X(TLY) as X(l). 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 be 1in INSPECT...TALLYING statement 1its altered state if used subscript by the will as a 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 counts the strings under certain stated wuser-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 inspected, tally the or overpunched). argument software adds 1 matches to the the tally delimited counter. The programmer can initialize the tally counter (The INSPECT statement does not initialize 1it.) 3.9.5.2 The Tally Argument - The character-string and a condition compared figure to the shows the delimited format of ALL } LEADING to any numeric . being value. tally argument specifies a under which that string should be string the string being inspected. tally argument: The following identifier} literal CHARACTERS ‘the delimited string. For example, - illustration causes TLY to be that precede the first comma, might be. the statement in | INSPECT FIELD1 TALLYING TLY FOR CHARACTERS BEFORE ",". - Figure 3-50 CHARACTERS 3-48 the following incremented by the number of characters regardless of what those characters Form of the NON-NUMERIC CHARACTER'HANDLING Tally Argument 4 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 "\\ Figure 3-49 of the Tally Argument ; Format 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 updates to the scanner by adding the size of the matching This moves the scanner to the next character beyond it. 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 statement Fields in again. - INSPECT Statements Any identifier named in an INSPECT statement indexed. 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 operation. For example, consider the following illustration: | MOVE 1 INSPECT TO TLY. FIELD1 TALLYING FOR ALL TLY X(TLY). Figure 3-48 Subscripted Argument / rr— ~ . 1 Sample In this sample statement, only once, before it evaluate X(TLY) as X(1). the software evaluates the address of X(TLY) hence, it will the action of begins inspecting the field; The alteration of TLY by inspecting and tallying has no effect on the (X(1) will be used throughout the operation.) choice » of the X operand. NOTE When that subscripting an contains both REPLACING phrase, statement will separate INSPECT INSPECT statement a TALLYING and a keep be in mind compiled statements. that the into two Therefore, any field that is altered by the action of the INSPECT...TALLYING statement will be in 1its altered state if used as a subscript by the INSPE . .REPLACING CT. statement. NON*NUMERIC CHARACTER HANDLING 3-47 3.9.5 An The INSPECT TALLYING Phrase occurrence - conditions. here, a statement 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 usagde, and it may be signed (separate or Each time the‘ tally overpunched). string being ‘The programmer can initialize the tally counter to any numeric value. inspected, argument software adds 1 matches to the INSPECT statement does not initialize 3.9.5.2 The Tally Argument - The character-string and a condition compared to the figure shows the delimited delimited the tally counter. string it.) , tally argument specifies a under which that string should be being inspected. The format of the tally argument: ALL } LEADING following /‘"‘\\ (The the identifier} literal CHARACTERS the tally argument to match an imaginary character that serves This increments as the tally counter by a value ‘the delimited string. ~illustration For example, the causes TLY to be that precede the first comma, might be. specifies every the tally argument. the following that equals the size of statement in incremented by the number of characters regardless . of what INSPECT FIELD]1 TALLYING TLY FOR CHARACTERS BEFORE ",". f 3-50 Figure CHARACTERS Form of the Tally Argument 3-48 that inspected should be considered NON-NUMERIC CHARACTER HANDLING those characters Y of TN form in the delimited string being / character ! The CHARACTERS \ Figure 3-49 Format of the Tally Argument 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 B only begins has the been entire scan FIELDI. Figure 3-55 shows various values of FIELD1l and the contents of the three tally counters after the scan. Assume that the counters are initialized to 0 before the INSPECT statement. , CONTENTS FIELD1 OF TALLY COUNTERS AFTER ' VALUE SCAN . ‘Tl 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 - Figure 3-55 the Scan in Figure of 3-54 The BEFORE/AFTER phrase applies only to the argument that precedes it, ~and delimits phrase the causes field for the a field separate for scan that argument only. of its corresponding the field to Each BEFORE/AFTER determine the limits argument. of | 3.9.5.4 Interference in Tally Argument Lists - When several tally arguments contain one or more identical characters that are 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 FIELDl causes the first argument to become inactive and the second argument to become active.) MOVE 0 INSPECT TO T1 Tl two identical order match, in BEFORE "A"TM T2 FOR ALL "," AFTER "A". Figure 3-56 Tallying Arguments Two Not tally Interfere arguments in with | that Each Figure Other 3-57 will interfere since both ‘are active at the same time. the scanner, the arguments are applied to which the . "," Do each other position of TALLYING FOR ALL — The T2. FIELD1 they appear scanner moves in to the statement. the next When position NON-NUMERIC one with (For any given FIELDl in the of and them finds ignores CHARACTER HANDLING a 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 FIELDl, and T2 will always be unchanged. INSPECT FIELD1 TALLYING T1 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 1in Figure 3-56. The first argument does not become active until the 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 1ignored. Thus, Tl 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 Other The preceding 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 Consider the following problem: INSPECT statements. INSPECT FIELD1 TALLYING Tl FOR ALL T2 FOR ALL "AB" "BC". Figure 3-59 An Attempt to Tally the Character with B Two Arguments If FIELDl contains "ABCABC", after the scan Tl will be incremented by The successful matching of the argument a 2 and T2 will be unaltered. the to scanner Each match resets the includes each B in the field. character position to the right of the B, and causes the second 3-52 NON-NUMERIC CHARACTER HANDLING TN . 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 FIELD1 TALLYING T4 FOR ALL "***x&%H T3 FOR ALL "***x%U T2 Tl FOR ALL FOR ALL "**" "*", - 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 Tl counts singles. ~ If FIELD1l contains a string of more than four consecutive asterisks, the argument 1list breaks the string into groups of four, and counts them in T4. It then counts the less-than-four remainder in T3, T2, or Reversing the order of the arguments in this list causes Tl all of the asterisks and T2, T3, and T4 to remain unchanged. to When the LEADING condition is used with an argument in the condition following count 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 should appear first. statement: Consider | MOVE the | sample | 0 TO T1 T2. INSPECT FIELD]1 TALLYING Tl FOR LEADING "*" T2 FOR ALL "*", Figure Placing in the the 3-61 LEADING Condition Argument List The placement of the LEADING condition in this sample statement causes Tl to count only leading asterisks in FIELDl; the occurrence of any other character stops this counting and causes the first tally argument to become inactive. T2 keeps a count of any remaining asterisks in FIELD1. NON-NUMERIC CHARACTER HANDLING 3-53 Reversing the order of the arguments in this argument list that can never increment Tl. INSPECT statement results | in an FIELD1l 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 FIELDl 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 MOVE0 TO T1 T2. INSPECT T1 a BEFORE inspected: phrase can | FIELD1 TALLYIN FOR LEADING SPACES T2 FOR ALL " " BEFORE "." T2 FOR ALL "TM " BEFORE "." T2 FOR ALL " " BEFORE ".". IF T2 > 0 ADD 1 TO T2. The statements in Figure 3-63 count the number of "words" in 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 FIELD1l has been scanned, T2 contains the number of gaps between the words. Since a count of the gaps renders a number that is 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 FIELD1 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 FIELD]l 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 N Figure 3-63 An Argument List that Counts Words in a Statement INSPECT FIELD]1 TALLYING Tl FOR LEADING Tl T2 FOR LEADING TAB FOR ALL " " etc. SPACES Figure Counting Leading Tab 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 1in the field being inspected. Consider the ‘MOVE following illustration. - 0 TO T1 T2 T3 T4 T5. INSPECT FIELD1 TALLYING Tl FOR LEADING SPACES T2 T3 FOR ALL FOR ALL "." "+" BEFORE BEFORE "," "," T4 FOR ALL "-" BEFORE "," T5 FOR CHARACTERS BEFORE ",". Figure 3-65 Counting the Remaining Characters With the CHARACTERS Argument If FIELD1l is known to contain a number in the form frequently used to input data, it may contain a plus or minus sign, and a decimal point; further, the number may possibly be preceded by spaces and terminated by a comma. If this statement were compiled and executed, it would deliver the following results: Tl would contain the number of leading T2 would contain the number of periods, T3 would contain the number of plus signs, T4 would contain the number TS5 would contain the number of remaining characters be the 3.9.6 numeric), sum of Tl occupied The signs, (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 of minus spaces, a REPLACING phrase, that statement or groups of characters 1in the field. 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 being of inspected. the area A search argument applies only to of the the delimited field area 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 o 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 Thus, string. the imaginary character that serves as the replacement value replaces each character (The replacement value, in this case, must search be argument. in the delimited one character long.) The ALL, LEADING, particular and FIRST forms of the search argument specify a character string, 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 item. BEFORE/AFTER the software performs an implicit redefinition of (This redefinition 1is identical delimiter redefinition .discussed in 3.9.1.) 3-56 NON-NUMERIC CHARACTER HANDLING | to the Section The words ALL, LEADING, and FIRST delimit the inspection operation: ® supply 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 "," 1is a string of consecutive commas, as many as statement requires.) ALL "," as REPLACING phrase means, "replace adjacent ¢ conditions The characters." word search the context of the a search argument of the each comma without regard to LEADING specifies argument at the that only adjacent matches 1left-hand end of the 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. ® 3.9.6.2 The word FIRST specifies that only the leftmost string that matches the search argument is to be After the replacement operation, the search containing this condition becomes inactive. The Replacement Value - Whenever character replaced. argument the search 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 must search argument. If replacement the Figure 3-67 the Replacement Value of always be the same size as 1its associated | value is a literal character string, it must be either a non-numeric literal or a figurative constant (other than ALL literal). A figurative constant represents as many characters as the length that the search argument requires. If the replacement value is an identifier, it must be an elementary item of DISPLAY usage. It may be any class. However, if it is other than alphanumeric, the software conducts an implicit redefinition of the item. (This redefinition 1is the same as the BEFORE/AFTER redefinition discussed in Section 3.9.1.) NON-NUMERIC CHARACTER HANDLING 3-57 3.9.6.3 of the The Replacement Argument - The search argument replacement value, and (with an ALL its optional ";" BY search replacement argument condition and consists string), the BEFORE/AFTER phrase. SPACE BEFORE "." ‘ argument character . BEFORE/AFTER 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 1lists. The text following each one tells be processed. / INSPECT FIELD1 REPLACING ALL "," BY SPACE ALL ' "." ALL BY ";" SPACE BY SPACE. Figure 3-69 Replacement Argument List Active Over the Entire These three SPACE, and replacement are arguments active over Thus, this space characters; statement INSPECT with replacement how that list will replaces and leaves FIELD1 all the entire have commas, all other " 0 n BY n l " ALL |llll‘ BY llOIl replacement value, inspected. periods, characters and semicolons with unchanged. . Figure 3-70 Replacement Argument Ones same being REPLACING ALL "Swaps" the field all 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 leaves all other characters unchanged. 3-58 NON-NUMERIC CHARACTER HANDLING NOTE When a search argument finds a match 1in 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, 1t 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 interference. with no = chance of \ INSPECT FIELD1 REPLACING ALL "0" BY "1" BEFORE SPACE ALL BY "O" BEFORE SPACE. - "1" 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 FIELD1 ALL ALL REPLACING "O0" "1" BY BY "1" "0" CHARACTERS BY BEFORE BEFORE "*" SPACE SPACE BEFORE SPACE. Figure 3-72 Argument List with Three Arguments That Become Inactive with the Occurrence of a Space Just as in ~causes all the of argument list in Figure 3-71, the first space character these replacement arguments to become inactive. argument 1list exchanges zeroes for ones, ones for zeroes, asterisks for all other characters that are in the delimited area. If the BEFORE phrase is removed from the third argument, This and 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 that identical have interference of is active they an one Replacement are characters, consequently arguments in 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 matches before The any action of a search replacement value, characters again Interference of the argument is never since the scanner during between execution search status of the replacement 1in of arguments. Tally arguments as l. 2. Place end 3. 3.9.7 the statement. on the in the Section applies, order active-inactive 3.9.5.4 generally, to arguments interference LEADING with the or in FIRST CHARACTERS replacement conditions condition at at the list; Consider, very carefully, search arguments that characters. Common discussion minimize arguments.with the list; several of and INSPECT depends well.) lists: Place search the start of the Lists, delimiter , by the characters of inspect the replaced therefore, arguments, (The Argument The following rules will help argument the affected not does of arguments, arguments, the values Interference BEFORE/AFTER other arguments, since the software scans for it scans for replacement operations. | Errors, the order contain | of one appearance of any more 1identical or INSPECT Statement The most common errors made when writing INSPECT statements are: ® e Leaving the Using the FOR out word of an "WITH" phrase. @ ® instead | of "BY" * in statement. the Failing to initialize the tally counter. Omitting the word INSPECT 3-60 INSPECT...TALLYING NON-NUMERIC "ALL" FIELDl1 e.g.: TALLYING CHARACTER HANDLING TLY FOR SPACES. REPLACING CHAPTER 4 NUMERIC CHARACTER HANDLING This chapter discusses numeric class data and the COBOL operations It is assumed that you can be performed on numeric data items. that concept of COBOL data the understand you that and 3, have read Chapter classes. 4.1 USAGES The USAGE of a numeric class item specifies the form in which the data is stored in data storage: DISPLAY-7), memory. DISPLAY COMPUTATIONAL VAX-11 COBOL-74 has four formats for numeric (which 1is equivalent to DISPLAY-6 and (abbreviated (abbreviated COMP-3). 4.1.1 COMP), | and | COMPUTATIONAL-3 o 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 1in memory (in one, two, or four words) as follows: PICTURE RANGE S(9) to S9(4) S9(5) to S9(9) S9(10) to S9(18) STORAGE -1 word 1 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 in a COMP data item "(1)" indicates that the byte contains the lowest-valued bits. Observe that the computer address (the first-referenced byte) of each COBOL data item corresponds to the low byte of the least significant word. The number in parentheses also the data example of item is redefined as a two-word COMP item: 01 The an alphanumeric subscripts of CHARACTER-ITEM in Figure 4 correspond to the high | low high | low byte | byte byte | byte (2) (2) (1) (2) (1) (4) (3) | | (4) (3) (6) (5) Next word (8) (7) Next word (1) Two-word item COMP Addressed | COMP is Figure 4-1 of COMP contained in 03 COMP-3 word item Storage The maximum size of a COMP-3 item the decimal scaling position. represent Data Items items is 1In the They are an assumed rightmost half stored as two decimal scaling (four bits) of 18 decimal digits, regardless of the following example, both NUM-1 of maximum size: NUM-1 PIC S9(18) USAGE IS COMP-3. NUM-2 PIC S9(6)V9(12) USAGE IS COMP-3. The description of a COMP-3 data item must have a sign in its character-string. 4-2 in Next word COMP-3 specifies packed-decimal data items. decimal digits per byte (byte—-aligned) with position. The sign the rightmost byte. numbers Four-word item Memory 03 if an 4-1. byte | byte NUM-2 Consider TIMES. high | low COMP characters item. | GROUP-ITEM REDEFINES COMP-ITEM. 03 CHARACTER-ITEM PIC X OCCURS One-word and of COMP-ITEM PIC 9(9) USAGE IS COMP. 01 parentheses indicates the order NUMERIC CHARACTER HANDLING ) | 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 "+" binary 1100 " binary hexadecimal C 1101 hexadecimal F value +the The following signs are also recognized as valid, generated as a Positive signs- program operations: binary 1010, binary 1100, signs| binary binary 1110, 1111, hexadecimal hexadecimal hexadecimal hexadecimal binary binary 1011, 1101, hexadecimal hexadecimal A C E F B D is stored in receiving item | is | but they are not data items of one, i ' . P "»\‘ N Negative result of zero Figure 4-2 represents the memory two, and three digits: ’/___..\_ lst byte 5 ‘lst + PICTURE S9 value: +5 byte 0 DECIMAL part of an COMP-3 byte 2 value: lst byte - 2 -32 Figure 4-2 of COMP-3 Data 6 byte 2 + PICTURE S9(3) - Storage 2nd value: +262 Items SCALING POSITION The assumed decimal as of PICTURE S9(2) Memory 4.2 2nd 3 | storage scaling position, actual control operations field description: on numeric numeric value. data or scaling factor, is not stored is by However, it used items. ~ Consider | the the RTS to following 01 ORDER-PRICE PIC 99V99 COMP VALUE 12.34. VAX-11 COBOL- 74 stores this item as a l-word binary number. The word contains the integer value 1234 and another location contains the scaling factor. 1In this example, the scaling factor records the fact that this integer has two decimal fractional positions. Thus, the COBOL RTS knows that the stored binary integer is 100 times larger than the programmer intends it to 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 in a program. To illustrate, if a DISPLAY usage number and a mixed number are both involved in the same arithmetic statement, 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 it reduces the space required for most numbers and can speed up the execution of 4.3 arithmetic | | statements. SIGN CONVENTIONS COMP-3 data items must be signed; however, DISPLAY AND COMP numeric items can be signed or unsigned. Unsigned numbers can contain values that range from zero to the largest positive value allowed by their Negative values are not allowed. All VAX-11 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. This guide does not recommend unsigned numbers for general use. are usually a source of They errors, and are handled less programming ly signed quantities by the RTS. than efficient 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 read into a field described using the picture character 5, an include must data that then operational format 4-4 to pass sign of the appropriate the NUMERIC test. NUMERIC CHARACTER HANDLING VAX-11 COBOL-74 always stores signed COMP items binary form. Thus, Sign representation 4.1.40 VAX-11] COBOL-74 byte positions the sign extra, in the byte on the for always stores signed containing numeric high-order either the When the RTS stores the numeric digit, the sign in two's complement high-order bit indicates the sign of the item. COMP-3 data items 1is described 1in Section ) byte, the high-order DISPLAY items as ASCII characters. low-order or byte, low-order a sequence of It may include or end as of a the sign as part of a byte that also causes a value change in that byte separate, item. contains and, a hence, changes the value of the numeric digit. Table 4-1 shows the actual ASCII character that results when a numeric value and a sign share the byte. PN same The Resulting Table 4-1 ASCII Character Sign and Digit’ Sharing DIGIT From a the Same Byte VALUE SIGN A byte containing a +0 stores as hexadecimal 7B, which prints as A byte containing a -0 stores as 'hexadecimal 7D, which prints as either a.{ or a [ depending on the printing device. either a | When RTS the actual 2B) or 4.4 All or a ] depending on the printing device. stores the sign ASCII character the graphic minus ILLEGAL VALUES VAX-1l1 COBOL-74 as a separate that it stores sign (hex 2D). is IN NUMERIC FIELDS arithmetic operations distinct the character, graphic store legal | plus values sign in | the (hex their result fields. However, it is possible, by readlng 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 is possible non-numeric to or place signed improperly values into signed unsigned data into fields, signed and to numeric place DISPLAY fields.) " The results of arithmetic flelds are unpredictable. operatlons that use NUMERIC invalid data CHARACTER in numeric HANDLING 4-5 o, 4.5 TESTING NUMERIC FIELDS COBOL provides the following numeric 1. 2. p 3. three kinds | fields: Relation tests, numeric value:; Sign tests, tests for that examine the field's sign to Class tests, evaluating | that compare the field's contents to positive or negative; legal of and, that inspect the numeric values. field's digit see if another it positions | 1is for The following sub-sections explain these tests in detail. 4.5.1 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 FIELD]l 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 statement. IF FIELDl > FIELDZ2 ... N the 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 Dbe “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 item.) 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 A~ of Q— - 4.5.2 8Sign Tests The Sign test compares a numeric quantity to zero and determines if it ~1s greater (positive), 1less (negative), or equal (zero). Both relation test and the sign test can perform this function. example, consider the following relation test: Now consider the IF Both of at the FIELD]1l these same ~and shows, following the For sign test: POSITIVE ... tests accompllsh the same thing and would always arrive result. The sign test, however, shortens the statement at a glance, that it is testing the sign. Table 4-2 shows the sign tests and their equivalent relatlon tests - as applied to FIELDI. | Table 4-2 The Sign Tests SIGN TEST | IF FIELD1l POSITIVE ... IF FIELD1 NEGATIVE ... IF IF IF FIELD1 FIELDl FIELD1 | IF FIELD1 NOT POSITIVE ... NOT NEGATIVE ZERO ... NOT ZERO ... ... EQUIVALENT RELATION TEST - IF FIELDl> 0 ... o IF FIELDl1 < 0 ... IF IF IF FIELDl FIELDl1 FIELD1 NOT = 0 NOT < 0 ... =0 IF FIELD1l NOT > | -l 0 ... o ... ... 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 4.5.3 sign values Class and the treatment of illegal Tests The class test interrogates contains numeric or flow of control in a a numeric field true and IF program FIELDl1 to control takes IS NUMERIC the true If so, path of ‘only determine these zeroes. tests. tests Thus, for if the both some if it the test condltlon. the statement: ... When reading in newly prepared data, it is often certain - fields determine alphabetic data, and uses the result to alter theprogram. For example, the following statement~” determines if FIELD1 contains numeric data. 1s sign values.) wvalid values. desirable Relation tests and sign to check tests can field's contents are within a certain range, and treat illegal characters data preparation 5 errors in DISPLAY could pass usage items both of as -these 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 checks <carried it sign value. 1If the character position carrying the sign illegal sign wvalue, 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 of information concerning Section 3.3.2.) 4.6 the the item passes the to take the true path THE MOVE the field contain a an and If the digit positions in class test passes the IF statement. alphanumeric) character. If ASCII an valid contains the item characters ALPHABETIC class test and of the IF statement. causes (For ALPHABETIC see 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), control usage digits. test, fields all of (A-Z or program further 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 fields, and 3. Elementary moves following each 4.6.1 of these Group moves, three with numeric sub-sections categories edited (4.4.1, receiving 4.4.2, 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 field in a treats the storage if either the sending It treats both fields performs the move as group move is a numeric elementary item, the RTS 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 If both fields of a MOVE statement are elementary is numeric, the RTS considers the move to be an 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, The end truncated 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 ends both 999Vv999 is moved to a field described as PIC 99V99, it loses one digit the left end and one from the right end. Figure 4-3 illustrates from (° ) indicates the stored decimal this alignment operation (the carat scaling position): 01 AMOUNT1 MOVE » | | 99V99. PIC 123.321 TO AMOUNTI. Before execution 00 00 After 23 execution | o = 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 TOTAL-AMT PIC 999V99. MOVE TO TOTAL-AMT. Before‘execution 000 00 After 001 execution Zero The 1 following Consider truncating 00 Figure 4-4 Caused By Decimal Filling statement produces MOVE 001.00 the following and the same Point Alignment results: TO TOTAL-AMT. two 'MOVE, zero-filling statements effects: STATEMENT and TOTAL-AMT their AFTER MOVE 00100 TO TOTAL-AMT 100 00 MOVE 100 "00100" TO TOTAL-AMT resultant EXECUTION 00 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 statement's receiving field dictates how the sign will be moved. A signed DISPLAY usage receiving field causes the sign to be moved as a separate quantity. An unsigned DISPLAY usage receiving field causes no sign movement. A COMP usage receiving field, whether signed or unsigned, causes the sign to be moved; however, if the receiving field is 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 run-time receiving field system of considers the numeric an elementary edited category numeric to 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 in numeric edited moves as unsigned DISPLAY usage integers. //‘—-s\‘ a Edited Moves CHARACTER HANDLING \‘.4 s The RTS considers the receiving field to be numeric edited category if it is described with a BLANK WHEN ZERO clause, following symbols: | or a combination of the | , B Space P Decimal Vv Location of assumed decimal point; Z Leading numeric character position to be replaced by a space if the insertion position; scaling position; position contains a zero; 0 Zero insertion position; 9 Position contains a numeric character; / Slash insertion position; ; Comma insertion position; . Decimal point * Leéding numeric character position asterisk if + Positive editing insertion position; the position contains - - Negative editing CR Credit editing DB Debit editing cs Currency symbol sign a to control symbol; sign control symbol; sign control sign control ($) replaced by an symbol; symbol; insertion position. A numeric edited field may contain 9, V, and P, those symbols without an editing character numeric be zero; 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 field until sending the zeroes) (with padding truncating or of digit positions on both sides of the number same the contains resulting then moves the 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 perform any of the following editing @ edited functions: move operation to Suppress leading zeroes with either spaces or asterisks; NUMERIC CHARACTER HANDLING 4-11 @ Float a currency suppressed sign zeroes, and 1inserting plus or minus sign through the sign at either end of the field; /- ®@ Insert zeroes and spaces; ®@ Insert commas and a Figure 4-5 MOVE FLD-B illustrates TO decimal several TOTAL-AMT. of point. these (Assume functions that with FLD-B the statement, described as S9999v99.) TOTAL-AMT "FLD-B 0023 PICTURE STRING CONTENTS AFTER MOVE 00 22727 .99 23.00 0085 90 ++++.99 -85.96 1234 00 0012 34 0000 34 1234 00 0012 34 0012 34 Z2,2727.99 $,98$.99 $,$$9.99 S$,$85.99 $$9,999.99 $$55,555.99 - 1,234.00 S12.34 S0.34 $1,234.00 S0,012.34 $12.34 0000 00 $5%,$55.53 0012 0012 3M 34 o ++++.99 Skkxkx *kx Qg9 -12.34 Skkkk%x] 2 34 Figure 4-5 Numeric The the currency symbol only floating more occurrences 4.6.4 Common The ($) and the editing symbols. To float the Errors, most common @ Placing an numeric edited errors sign control symbols them, enter a string (+ of -) are two or symbol. Numeric made MOVE when incorrect Statements writing number of numeric MOVE replacement statements characters are: 1in a item. @ Moving @ Trying to float the $ decimal point to force spaces. (Use $$.99 or @ 4-12 of Editing non-numeric data into numeric fields with group moves. or insertion characters zero values to appear as .00 ++.99.) past instead the of Forgetting that the $ or + insertion characters require an additional position on leftmost end that cannot be replaced by a digit (unlike the * insertion <character which can be completely replaced) . NUMERIC CHARACTER HANDLING 4.7 THE ARITHMETIC STATEMENTS The COBOL arithmetic statements, ADD, SUBTRACT, MULTIPLY, DIVIDE, and COMPUTE allow COBOL programs to perform simple arlthmetlc operations on numeric data. 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 in temporary work locations, then move the results to the receiving fields, aligning the decimal points and truncatlng Or ZzZero f1111ng the resultant values. This temporary work field, called the intermediate result field, has a maximum = 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 ! B Vel N < 5, statement. | | | When the compiler determines that the size of the intermediate result field exceeds 18 digits, it truncates the excess high-order digits. Thus, a program that requests a multiplication operation between the following two fields, PIC 9(18) and PIC V99. ) (which would otherwise cause the compiler to set up a 20-digit intermediate result field -- 9(18)V99) actually causes the follow1ng intermediate result PIC 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, will nine of PIC their 9(12) high-order digit positions. or PIC 9(15) but the values probably applications. not exceed so zeroes occupy most Numeric data may be declared as that are placed in these fields digits of range (1 billion) in most | 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 1lose 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 in such an operation, move the field to a temporary location before 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 arithmetic operations. the operations. results of COBOL 4 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 1ntermed1ate result has more 1low-order digits than the result field. B VAX-11 digit stores COBOL-74 rounds-off by adding of the absolute value of that result. a 5 the to the leftmost truncated intermediate result before it Consider the following illustration and assume an intermediate of result 54321.2468: Coding: 01 FLD-A PIC S9(5)V9999, 01 FLD-B PIC S9(5)V99. ADD FLD-A TO FLD-B ROUNDED. Intermediate PIC The result field: S9(6)V9999. ROUNDED operation: | | Intermediate Truncated result field: 054321. 24 ¥ digits |50 |18 LEFT-MOST truncated digit 68‘\ | ROUNDED: FLD-B*'s ROUNDED Rounding 4-14 (ADD) result: Figure 4-6 Truncated Decimal NUMERIC CHARACTER HANDLING .00 054321.25 Point Positions The following position (P). discusses the ROUNDING example rounds-off Assume an intermediate result GIVING phrase in numeric to of the decimal scaling 24680. (Section 4.7.4 operations.) | Coding: 01 01 AMOUNTL PIC 9999. AMOUNT2 PIC 9999PP. MULTIPLY AMOUNTI1 BY GIVING AMOUNTZ2 10 ROUNDED. \ Intermediate result field: PIC 999999, The ROUNDED operation: ,Truncated Intermediate result ROUNDED }4;7.3 0246 (ADD) : AMOUNT2's Roundlng field: |80. 50. ROUNDED result: 0247 Figure 4 7 Truncated Decimal Scallng |30. Positions The SIZE ERROR Phrase ‘The SIZE ERROR phrase detects the loss of high-order in the digits results of COBOL arithmetic operations. non-zero digits ‘The phrase may be used on any COBOL arithmetic,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 1mperat1ve contains both result before it phrase. ROUNDED checks for and SIZE ERROR phrases, a size error. NUMERIC the CHARACTER HANDLING RTS 4-15 The phrase cannot be used on numeric MOVE statements. Thus, 1if a program moves a numeric quantity to a smaller numeric field, it may inadvertently lose high-order digits. For example, consider the following MOVE of a field to a smaller field: 01 AMOUNT-A PIC 9(8)V99. 01 AMOUNT-B PIC 9(4)V99. MOVE AMOUNT-A 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, and could be tailored to any size field: 1. TIF AMOUNT-A NOT > 9999.99 MOVE AMOUNT-A TO AMOUNT-B ELSE 2. ... ADD ZERO TO AMOUNT-A ON SIZE ERROR ... GIVING AMOUNT B ‘Both of these alternatives allow the MOVE operation to occur only if AMOUNT-A loses no significant digits. If the value in AMOUNT-A is too large, both alternatives alternative execution path. 4.7.4 The avoid altering AMOUNT-B and take 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 statements. If | the data item following the RTS performs 4.7.5 the the word GIVING is a numeric edited editing Multiple Operands the same way it does for MOVE in ADD and SUBTRACT Statements Both the ADD and SUBTRACT statements may contain a string one operand preceding the field, statements. word TO, 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 field. NUMERIC CHARACTER HANDLING The folloWing software three equivalent executes the multiple l. coding operand Statement: coding: ADD A B, Statement: coding: C, GIVING TEMP. TEMP, D, GIVING ADD TEMP, E, GIVING ADD TEMP, F GIVING F. ADD TEMP, G GIVING G. ADD TEMP, H GIVING H. B, N coding: all E. FROM D. C GIVING TEMP TEMP. FROM D GIVING D. ADD A B C D GIVING E. ADD A B GIVING TEMP. ADD TEMP C GIVING TEMP. ADD TEMP D GIVING E. COBOL statements, any commas in these statements are | | 7 PNy (Just as with optional.) Equivalent B, C, TEMP. GIVING TEMP. TEMP, SUBTRACT “ the GIVING TEMP. ADD ADD A, how H. TEMP, ADD Statement: G ADD SUBTRACT A, Equivalent 3. illustrate ADD ABCDTOETF Equivalent 2. groups statements: Only is statement 3 may have a numeric edited receiving the only statement containing a GIVING phrase. 4.7.6 field, \ it The ADD Statement The ADD statement adds two or more operands together and stores the exception of result. f/ - TM, since The statement Format in one 3) of may contain multiple and the the following and operands SIZE ADD FIELDl ...TO FIELD2 Format 2. ADD FIELD]l FIELD2 In Format 1, In 2, Format addends. format, must not be the receiving They It may be written FIELD3 ...GIVING ... . FIELD3 FIELD4 ... . ADD CORRESPONDING FIELDl TO FIELDZ2. the receiVing fields These the formats: 1. addends. (with ERROR phrases. Format Format 3. this ROUNDED may omit in fields either the word the be TO. (FIELD2, FIELD3) numeric edited (FIELD3, FIELD4) numeric or numeric are one of the of the category. are not edited. one When using - NUMERIC CHARACTER HANDLING 4-17 In Format 3, the receiving field (FIELD2) is one of the addends. FIELDl FIELDl and FIELD2 must are added to the 4,7.7 The be group items. The corresponding corresponding elements of FIELD2. from another operand and stores the the The statement may contain multiple operands Format in 3) one of of SUBTRACT Statement The SUBTRACT statement subtracts one, or operands Both elements and the the following - Format 1. In Format 1, SIZE . two (with the exception ERROR phrases. ... SUBTRACT FIELDl ... GIVING FIELD3 3. of or more, of It may be written formats: SUBTRACT FIELDPl Format 2. Format ROUNDED and sum result. FROM FIELD2 FIELD3 FIELD4 ... | . FIELD1 FROM are both in the In Format 2, the receiving fields (FIELD3, FIELD4) are used only to In Format 3, the reCeiving field (FIELD2) is both the subtrahend and numeric store and edited the the difference (the result). These must not be result. They may be either numeric and or numeric edited. FIELD2 must be group the items. The MULTIPLY Statement The MULTIPLY statement multiplies one operand by the another and stores ( result. 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 BY FIELD2 In Format 1, multipliers. In Format multiplier editedo 4=18 . category. the difference (results). Both FIELDl The corresponding elements of FIELD2. 4.7.8 ( FIELD2. (FIELD2, FIELD3) subtrahend fields . FROM FIELDZ2 SUBTRACT CORRESPONDING the receiving ... FIELD1 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 . TN COBOL's "near English" format could cause a problem with the MULTIPLY statement, since it 1is common to speak of multiplying a number (multiplicand) by another number (multiplier) and to think of the result as a new value for the multiplicand; thus: MULTIPLY EARNINGS BY 0.24. Multiplie 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 EARNINGS BY TAX-RATE. The compiler would not diagnose this statement's error, and would store the result of the operation in TAX-RATE. A good practice when using MULTIPLY statements is to always write them in Format 2. This ensures that the result 1is properly stored. The following two statements safely capture their results: | - MULTIPLY EARNINGS BY 0.24 GIVING EARNINGS. or 4.7.9 The MULTIPLY EARNINGS DIVIDE Statement The DIVIDE BY statement divides TAX-RATE 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'FIELDl INTO Format 3. DIVIDE BY Format 4. FIELD2 FIELD2 FIELDl GIVING GIVING . FIELD3 FIELD4 FIELD3 FIELD4 ... ... . | DIVIDE FIELD1l INTO FIELD2 GIVING FIELD3 REMAINDER FIELD4. Format 5. | DIVIDE FIELDl1 BY FIELD2 GIVING FIELD3 REMAINDER FIELD4. In Format 1, dividends. the receiving These must not be fields in the (FIELD2, FIELD3) numeric NUMERIC edited are alsd'-the category. CHARACTER HANDLING | — 4-19 These may be either numeric or numeric neither dividends nor divisor. edited. are (FIELD3, FIELD4 ... ) fields receiving In Formats 2 and 3, the | In Formats 4 and 5, the receiving field (FIELD3) is neither a dividend FIELD4 is the remainder. The receiving field and the nor a divisor. remainder may be either numeric or numeric edited. The COMPUTE Statement 4.7.10 The COMPUTE statement ¢omputes'the value of an and stores the value in the result. expression arithmetic | It The statement may contain the ROUNDED and SIZE ERROR phrases. contain following multiple format: receiving | operands. COMPUTE FIELD1 FIELD2 ... may The COMPUTE statement has the | = arithmetic-expression. The receiving fields (FIELD1, FIELD2) may be either numeric or numeric edited. ~. { Pal 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 @ Writing the ADD or SUBTRACT without the GIVING the result into a numeric Writing a Format 2 ADD statement with the word phrase, edited ¢ statements put but field. attempting to /// Y statements require that all fields be numeric. , For TO; example: ADD A TO B GIVING C. ° Subtracting a 1 froma numeric counter that was described an unsigned quantity, | Zero. . ° S | | Forgetting that the MULTIPLY statement, phrase, stores the result back without the the into ) - GIVING second operand X r'/ A \‘\ (multiplier). as and testing for a value of less than 4-20 NUMERIC CHARACTER HANDLING ° Performing a series of generate an when final the calculations intermediate result result will be that fewer in such is larger digits. a way than (The as to 18 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 e an for each arithmetic fields, receiving the field statment ROUNDED that Forgetting that, in an arithmetic multiple receiving fields, the ON specified applies to all rece1v1ng receiving are left after ARITHMETIC operands for unaltered. all the which The receiving ON a ERROR are to be must be rounded. statement containing SIZE ERROR phrase, if fields. Only those size error SIZE fields is containing phrase condition statement processed by is is the raised executed RTS. EXPRESSION PROCESSING ( e, ) 4.8 in receiving COBOL provides language arithmetically. In statements ADD, facilities particular, SUBTRACT, for the MULTIPLY, manipulating user-defined language provides and DIVIDE and the the data arithmetic facilities of arithmetic expressions using the +, -, *, /, and ** operators. In simple terms, a given arithmetic functionality may be expressed in one of several ways. For example, consider a COBOL application in which the total yearly sales of a salesman are to be computed as the sum of the four individual sales quarters. Flgure 4-8 illustrates one method of expressing a solution to this problem in COBOL: MOVE 0 TO TEMP. ADD ADD 1ST-SALES 2ND-SALES ADD 3RD-SALES TO TEMP. ADD 4TH-SALES TO TEMP Figure 4-8 In figure ADD of to important declares COBOL TEMP. TEMP. GIVING TOTAL-SALES. Explicit Programmer-Defined Temporary Work Area the statements process used 4-8, TO TO COBOL programmer to develop computing develop the TOTAL-SALES, the partial chooses final a sums to value COBOL (i.e., program. That is, the attributes to a series of TOTAL-SALES. data-name, called intermediate point here is that the programmer the temporary work area TEMP in integer and decimal places by the COBOL programmer. use for (i.e., be maintained) single 1In the TEMP, is results). The explicitly defines the data division of class, are USAGE, specified and the number of explicitly NUMERIC CHARACTER HANDLING 4-21 Figure 4-9 below illustrates another way of expressing a solution to the problem: ADD lSTéSALES, 2ND-SALES, GIVING TOTAL-SALES. 3RD-SALES, 4TH-SALES o 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. single ADD required to develop the partial sums of is field result ate intermedi the four quarterly sales quantities. In Figure 4-8, the programmer 1is cognizant of this requirement, but chose to define: the intermediate the compiler 4-9, Figure defines the to the COBOL source intermediate result field in a manner transparent program. That is, the compiler allocates storage for and assigns various attributes to this "transparent’ intermediate result field by the COBOL language a well-defined set of rules defined ~according to of attributes the r, particula In gpecification. number-of-integer-places, number-of-decimal-places, and USAGE assigned to the intermediate result field are a function of the by the software composite of source operands in the ADD statement. (The reader should read the VAX-11l COBOL-74 Reference Manual for details concerning the 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 TN n his COBOL program. result area TEMP explicitly in the data divisioof waevér; for the example in | compiler, must implement those rules. a final example, consider the following solution to our problem: As + 3RD-SALES + 2ND-SALES COMPUTE TOTAL-SALES = 1ST-SALES Figure | 4-10 ‘Arithmetic Expression Intermediate Result Field Attributes Determined by Implementor-Defined Rules by using In Figure 4-10, the programmer solves the problem . expression arithmetic COMPUTE statement with an embedded ~intermediate result field is defined by the software. intermediate result fields required and, as ‘in Figure TN | + 4TH-SALES. | a single Again, an 4-9, is However, in defining the attributes of for COBOL arithmetic expressions, the ANS-74 COBOL language standard is not as helpful to the user as it could be. In 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 implementor will on the composite of operands and/or arithmetic receiving indicate technlques fields. used in handling expre531ons. 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 compller computes the sizes of intermediate result fields. | The, compller computes the size of an each intermediate result component operation of an arithmetic expression. can be stated OP1 as: field for Each operation ‘ OPR OP2 where: OP1 is the first opérand "OPR is an arithmetic operator "OP2 is the-secohd 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 in the entire arithmetic expression. OPR + and - | | * / %% IP = max (IP(OP1l), IP(OP2)) DP = max (DP(OP1), DP(OP2)) IP = IP(OPl) DP ” = DP(OPl) + 1 + IP(OP2) + DP(OP2) IP = IP(OP1l) + DP(OP2) DP = max (DPEXP, max (DP(OPl), DP(OP2) + 1)) For exponents that convert to one-word values, a = OP2 b = OP2 + DP(OP1) Otherwise, a: 9, if IP(OP2) = 1, otherwise, a = 19 = IP(OP1l) * a = max (DPEXP, DP(OPl) * b = DPEXP and IP DP 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. to which the This unique identification of data items is usually accomplished by assigning a unique name to each item. However, in many applications this is tedious and inconvenient; often programs require too many names for of type same the contain that have different names but 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 two formats: Format 1 OCCURS integer-2 TIMES ASCENDING | KEY IS data-name-2 DESCENDING data-name-3] ~ ... cos ' [ INDEXED BY index—name—l' Format [, [, index-name-2] ...] 2 OCCURS integer-1 TO integer-2 TIMES DEPENDING ON data-name-1 ASCENDING DESCENDING [ INDEXED BY index-name-1 [, index-name-2] ...] either format, accommodate the amount of storage system generates occurrences of the a will automatlcally map table into memory, the the mapping which depend on whether the items or not. If they do not contain maps them a buffer data large enough descrlptlon. into adjacent memory elements software into element contains synchronized items, locations and the size amount memory. follows of to Therefore, of storage allocated in either case is equal to the required to repeat the data entry integer-2 times. The software mapping the integer-2 the When rules for synchronized the software the table can be easily calculated by multiplying the size of the element times the number of occurrences (5X10 for the table 111ustrated in Figure 5-1, or 50 bytes of memory). . 01l A-TABLE 03 A-GROUP PIC X(5) OCCURS 10 TIMES. Figure 5-1 Defining a Table 5.2.1 When The OCCURS Phrase - Format 1 Format 1 (number of is used, a occurrences) fixed is length equal to table the is value generated, whose specified by length 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 might be TABLE HANDLING used. //-"\\N s In / . 5.2.2 The OCCURS Phrase - Format 2 Format 2 is used to génerate variable length tables. table whose 1length (number of occurrences) specified by data-name-l1l is generated. 1is When used, a data in equal | to the value | NOTE Data-name-1 must always integer whose value greater than integer-l than integer-2. be a positive is equal to or but not greater Unlike format 1 tables, the number of occurrences format 2 tables can be dynamically expanded or of reduced to items satisfy 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-l always reflects the number of user access. To expand the size (number use) of a table, accordingly. the user need only occurrences available occurrences available of increase Likewise, reducing the value in data -name-1 occurrences available for user access. the value of w111 reduce for for data-name-1 the number of 5.3 MAPPING TABLE ELEMENTS As mentioned in Section 5.2, when the software detects an OCCURS clause in an unsynchronized item, it maps the table elements into adjacent locations in memory. Consider the following data description of a simple table and the way it is mapped into memory: Table Description: Memory “words bytes 01 A-TABLE. 03 A-GROUP PIC X(5) OCCURS 10 TIMES. Map: [T J1J J1z]ziz] 11 F A-GROUP av]v Jvi LD JTRT A-GROUP Mapping |viz]viiI | ix x| 1] | | 11 A-GROUP A-GROUP Figure 5-2 a Table into e e ~ Memory TABLE HANDLING 5-3 AN Figure 5-2 causes each (elements) the and software to set place them in up ten adjacent ascending memory locations for a total of 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 items of that bytes in that occurrence of addresses, of that causes contain an odd item the even. element but will map element. SYNCHRONIZED clause, the the software number This will same If the software data add that alternate or even) map fill each between as the description would a byte thereby making the ensures not (odd the to of bytes, it of subsequent odd first A-GROUP quite to number and even repetition contained differently. a If A-GROUP were synchronized, it would expand its length to three 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 referrlng - to ATABLE will not detect the presence or absence of the character. The paddlng character does, however, affect the overall length of the group item and, hence, the table. Without the SYNCHRONIZED clause, A-TABLE required only 50 character positions; now, with the <clause, it requires 60 character positions. (This length includes the last padding character -- following the tenth element in the table.) Although the SYNCHRONIZED clause has 1little value 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 111ustrat10n of a synchronlzed data 1tem be1ng mapped by the software° - Table Description: 01 A- TABLE | 03 05 , 05 E | ' OCCURS A-GROUP ITEM1 ITEM2 20 PIC X. PIC S999 | TIMES. | COMP. - | BYTE - Memory Map: words ‘bytes 1 1 11| 11 | 11| 1v] 212 |l| | . v 2|2| l| ) o A-GROUP A-GROUP - TABLE HANDLING |vi | - P | f'“A—GROUP Flgure Jviz|vriiz] 2|2| 1| ) Synchronlzed COMP 5-4 . 1--ITEM1 2--ITEM2 - S=--SLACK 2|2 |»:;. R A-GROUP 53 Item in a | Table | ... ’ ‘The data description in items of five bytes 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 ITEMl. 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 Now, consider the place the field formerly occupied data byte following each). effect of adding a l-byte field to A-TABLE. If we between ITEM1 and ITEM2, it will take the space by the slack byte. This has the effect of adding a but leaving the illustration: Table ' size of the table unchanged. Consider | the | 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: words | ' II bytes II I III | IV {13 |9 V , 2--ITEM2 3--ITEM3 |VI|.. - 2]2711]3]2]2]1]|3]2[F... ‘ e A-GROUP A-GROUP | Adding a Field |N A-GROUP | J Figure 5-4 without Altering the Table Size e > I1f, however, we place the l-byte field after ITEM2, it has the effect of adding its 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 ITEM1 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: | 01 | A-TABLE. 03 A-GROUP OCCURS 20 05 ITEM1 PIC X. 05 ITEM2 PIC S999 05 Memory ITEM3 PIC TIMES. COMP. X. | Map: 0dd or Even E O E words bYteS | I, ,2/22 2 1 A-GROUP One Byte ... IX . oo " 3 L Adding OEOEOEO I ’ o 0 @ ‘ A-GROUP Figure which Adds Two A-GROUP 5-5 Bytes to the | Element Length TABLE 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. Figure 5-6 occupies the The software illustrates this. even number of bytes in 1length in order to synchronized item(s) will map onto word boundaries. are needed A-TABLE and requires Table Since the FILLER even byte of the first word, ITEMl1l falls on an odd requires that each repetition of ITEM1 must be an guarantee that the No slack bytes A-GROUP elements are again only four only 81 bytes. Description: | | bytes long, and | 01 A-TABLE. | 03 FILLER PIC X. 03 A-GROUP OCCURS 20 TIMES. 05 ITEM1 PIC X. 05 ITEM2 PIC S999 COMP. 05 ITEM3 PIC X. Memofy Map: odd or even' E O EO bytes 2121 words I FI1] FILLER Forc1ng II A-GROUP EO EO III | IV 3§1 1212 A-GROUP EO vV 3§1] EO VI EO VII 21213 co o .o o .o A-GROUP Figure 5-6 an 0dd Address By Adding a l-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 ITEM1l 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 01 A-TABLE. Description: 03 A-GROUP OCCURS 20 TIMES. 05 ITEM1 PIC X SYNCHRONIZED RIGHT. 05 ITEM2 PIC S999 COMP. 05 ITEM3 PIC X. Memory Map: 0dd or Even E O E O words O IT . bytes 2]2 | .~ A-GROUP EO EO | VI _JVII]VIII 2121 381 | 2]2 EO ... .. A-GROUP ... Figure 5-7 Effect of a of a SYNCHRONIZED RIGHT Clause Instead FILLER Item as shown in Figure 5-6 To determine how the software following two rules| ~will map o a given table, | software maps all items in the first table element into memory words as with defined with a data description, obeying synchronlzatlon apply the | The explicit 2. EO V_ A-GROUP ‘ The l. EO repetition of a any item properly any implicit or o requirements. If the flrst repetltlon contains any elementary items with implicit or explicit synchronlzatlon, the software maps each successive same way slack as repetition of the element into memory words the first byte, repetition. if necessary, It does this to make the size by in the adding one of the element to any desired even. 5.3.1 Initializinngablesn If a table contains only DISPLAY initial VALUE OCCURS value (initialized). phrase on the clause. initialized . record The tables: items, it can To initialize a be set table, simply specify a level preceding the item containing the sample data definitions, below, will set up o R | TABLE HANDLIN 5-7G ‘Table Description: - 01 A-TABLE VALUE IS "JANFEBMARAPRMAY JUNJULAUGSEPOCTNOVDEC". 03 MONTH-GROUP PIC XXX USAGE DISPLAY OCCURS 12 TIMES. Memory Map: [z [T words [rzifzv [ v {vi Jvizfvizzfix | x MONTH-GROUP ! MONTH-GROUP MONTH-GROUP MONTH-GROUP "Figure y X — |x1 [ X171} |U[N}JJ|UJL|A|U|G] byte contents [J[A[N[F[E[B|M|A[R[A|P|R]M[A]Y|J _”MONTH-GROUP MONTH-GROUP - MONTH-GROUP MONTH-GROUP 5-8 Initializing Tables Often a table is too long to initialize with a single literal, or it 01 A-RECORD-ALT. 05 FILLER PIC 05 FILLER PIC 05 FILLER PIC 05 FILLER PIC Table Description: N items that cannot be initialized (numeric, alphanumerlc, or contains These items can be individually initialized by redefining the COMP). contains the OCCURS clause. that 1level the preceding level group descriptions: table sample following the Consider XX VALUE "AX". 99 COMP VALUE 1. XX VALUE "BX", 99 COMP VALUE 2. 01 A-RECORD REDEFINES A-RECORD-ALT. 03 A-GROUP OCCURS 26 TIMES. 05 ITEM1 PIC X. 05 ITEM2Z PIC S99 COMP. Binary 1 Memory Map: words byte contents at | T AlX initialiZzation time Binary 2 [z fziz]iv [ ... A-GROUP B X - ... A-GROUP Figure 5-9 — Initializing Mixed Usage Fields In the preceding example, the slack bytes in the (ITEM1) are being initialized to X. 5-8 TABLE HANDLING alphanumeric fields Table Description: 01 A-RECORD-ALT. | 03 FILLER PIC X(30) VALUE IS "AAAAAAAAAABBBBBBBBBBCCCCCCCCCC". 03 FILLER PIC X(30) VALUE 1S "DDDDDDDDDDEEEEEEEEEEFFFFFFFFFF". (etc.) 01 A-RECORD REDEFINES A-RECORD-ALT. 03 ITEM1 PIX X(10) OCCURS 26 TIMES. 'Memory Map: word | 1 byte [z1 |1xzf|zv | v |vr Jviz|vizzfix | x [ATA|ATA[ATA[ATA[ATA[B[B|B[B[B[B -contents at ] initialization[_* time | * Vv ITEM1 | ‘ | l Figure 5-10 Initializing Alphanumeric ... | J — ITEM1 c o| Fields In the preceding example,-each FILLER item initializes table Ixz ] ... |B[B[B[B[C[C| elements. 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 initialized; 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 Dbe able have established to access the the necessary elements ‘individually. Subscripting and indexing are the by COBOL for accessing individual elements. 5.4 of tables, those two methods the tables provided i SUBSCRIPTING AND INDEXING To refer name of to a the particular element within a table, simply follow the desired element with a parenthesized subscript 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 1index 1is a data-name that has been named in an INDEXED BY phrase in the OCCURS clause. - 'TABLE HANDLING 5-9 TN 5.4.1 Subscripting with Literals integer whose value A literal subscript is simply a parenthesized In figure represents the occurrence number of the desired element. causes ~the (2) instruction 5-11, the literal subscript in the MOVE the contents of the second element of the table, software to move A-TABLE, to I-RECORD. | Table Description Procedural ~ | _ 01 A-TABLE. ‘03 A-GROUP PIC X (5) OCCURS 10 TIMES. : MOVE A-GROUP(2) Instruction Figure TO I-RECORD. 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 of the desired The first subscript in the clause to which the item is subordinate. first OCCURS clause to which the item is list applies to the in the is the most encompassing level -- A-GROUP subordinate. (This 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 OCCURS clause being 1level lowest number of the item named in the procedural instruction -- ITEM5 in the | example). following the subscripts (2,11,3) in the MOVE instruction Consider Figure 5-12; the third repetition of ITEM5 in the cause the software to move to A-GROUP of eleventh repetition of ITEM3 in the second repetition I-FIELD5 is not defined.) simplicity, illustration (For I-FIELDS. the 1in ITEM5 of to the first occurrence (ITEM5(1,1,1) would refer of ITEMS.) table and ITEM5(5,20,4) would refer to the last occurrence 01 A-TABLE. 03 | | Table Description ‘ | | | . A-GROUP OCCURS 5 05 ITEM1 PIC X. 05 ITEM2 PIC 99 COMP OCCURS 20 05 TIMES. ITEM3 OCCURS 20 07 X. 07 ProCedural Instruction 5-10 TABLE HANDLING ITEM4 PIC TIMES. ITEMS5 PIC XX OCCURS - 4 TIMES. MOVE ITEM5(2, 11, 3) TO I-FIELD5. Figure Subscripting TIMES. 5-12 a Multi-Dimensional 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 | OF | - | FIELD . /r\‘.\ ITEM]1 FIELD NAMED | | - | a slack 1% 2 TWO 9 TWO 1 THREE 2 byte Figure 5-13 Subscripting Rules Multi—Dimensional for a Table Operations Performed by the Software When a literal subscript is used to refer to an item in a software of , 222 TWO ITEM4 above 1110 ONE | ITEM3 5.4.2 OF FIELD ONE ITEMS the THE » ITEM2 * Plus of SIZE NONE | each NUMBER OF SUBSCRIPTS REQUIRED TO REFER TO A-TABLE A-GROUP not list. performs the the item: 1. The compiler 2. The not be compiler less following converts range than specified by the message 1f the 1 steps the to literal determine to a the l-word table, exact the address binary value. checks the subscript value (the value must nor greater than the number of repetitions OCCURS value is clause) out of and prints range. a diagnostic The compiler decrements the value of the subscript by 1 and multiplies it by the 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 value time, for a fixed length table, the RTS adds the index (from 3 above) to a base address, thus determining the address of the desired item. For a variable length table reference, the procedure for fixed length tables is preceded by the procedure described in Section 5.4.6. TABLE HANDLING 5-11 Subscripting with Data-Names 5.4.3 As discussed earlier in this sectlon, subscrlpts may also be spec1f1ed' data-names using To ‘use a refer to the literals. of instead data-name as a subscript, simply define it as a numeric integer (COMP or DISPLAY) . It may be signed, but the sign must be positive at the time it is used as a subscript. The sample subscripts figure in (2, accessed in Figure 5-12, Data Descriptions of Subscript data-names | Procedural Instructions 11, 5-14 - 3). | element same - 01 KEY1l PIC 99 USAGE DISPLAY. 01 KEY2 PIC 99 USAGE COMP. 01 KEY3 PIC S99. MOVE MOVE 2 TO KEY1. 11 TO KEY2. MOVE 3 TO KEY3. GO TO TABLERTN. TABLERTN. | MOVE ITEMS(KEYl KEY2 KEY3) | TO I- FIELD5 Figure 5-14 Subscripting with Data-Names 0perat10ns 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 follow1ng steps at run time: 1. software I 2. the software range checks the For fixed 1length tables, 1less than 1 nor (the value must not be subscript value by the —spe01f1ed repetltlons of number greater than the and terminates the image (with a diagnostic OCCURS clause) For varlable length tables, message) if it is out of range. 54, 6 1s followed Sect1on in the procedure descrlbed 3. The software decrements the value of the subscr1pt by 1 and multiplies it by the size of the item that contains the thus forming OCCURS clause correspondlng to th1s subscrlpt, an index value. 4. 5-12 the If the data-name's data type ~is DISPLAY, | converts it to a l-word binary 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 Indexes The same rules apply for subscripts except that phrase of the OCCURS the specification the index must of be clause. indexes named in as the apply to INDEXED BY - 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 TN value is the product formed the software for 1literal location, within the table, in step 3 of the operations performed by or data-name subscripts -- the relative of the desired item.) The compiler allocates a 2-part data item for each name that follows an INDEXED BY phrase. These index-name items cannot be accessed as normal data items; they cannot be moved about, redefined, written to a file, etc. However, the SET verb can change their values and relation tests can examine their values. 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 — —» » ' Figure 5-15 Index—-Name Item Whenever a SET statement places software performs an the index part. Only or receiving field. a new value in the subscript part, index value computation and stores the the subscript part of the item acts as The index part is never altered by the result in a sending any other operation and is never moved to another item. It is used only when the index-name is wused as an index referring to a table item. The sample MOVE statement in Figure 5-16 would move the contents of the third once repetltlon again, of I-FIELD A-GROUP is Table Description . ' not ‘ to I-FIELD. (For illustration defined.) | | " 01l A- TABLE . 03 A-GROUP OCCURS | Procedural Instructions simplicity, | 5 TIMES INDEXED BY IND-NAME SET IND-NAME TO 3. MOVE A-GROUP Figure 5-16 Subscripting With Index-name (IND-NAME) TO I-FIELD. Items TABLE HANDLING 5-13 5.4.6 The Operations Performed by the RTS RTS performs the following steps - statement: when ..it § 1. The RTS converts the contents of the statement to a l-word binary value. 2. The RTS range checks the value (the executes the SET of the SET - sendlng field value must not be .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 item that contains the OCCURS forming an index value. | fixed length tables, once the SET it by clause, the thus statement has been executed and the software has encountered the index-name item as an. 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. : L For a variable length table, when the index-name is encountered as an index, the procedure described in Section 5.4.6 1is invoked before following the fixed length table logic. However, the SET statement itself is not impacted by the fixed/variable characteristic of the associated table. | o | | VAX-11 COBOL-74 initializes the value of all index-name items ¢to subscript wvalue 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 not rely on this feature. Relative 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 wuse, 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 corresponding :to the specified literal; and transfer this to the object.file. At run time, the index value for the index value index value 1literal is ‘added to index-name. 5-14 TABLE (+) or subtracted HANDLING from (-) the index value of the 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 length tables, this index manipulation is relatively more involved. straightforward. The size of the table is known at compilation time, and this size is passed along to the RTS in the object file. A simple compare against this fixed value is all that is required to determine if a given index value is within the permissable range for the table. For a variable length table, however, The current index of occurrences the process (data-name-1) is 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 number for the value. | The run-time overhead required for the relative indexing length tables length tables. not altered. range) value, -~ table must of variable 1is significantly greater than that required for fixed 1In either case, the index portion of the index-name is If any of the range checks reveals an illegal (out of execution 1is terminated with an apropriate error message. The sample MOVE of A-GROUP to verb, instruction in Figure 5-17 I-FIELD if IND-NAME has moves the fourth repetition not been altered with a SET - MOVE TO A-GROUP (IND-NAME + 3) 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 1Index 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-11l COBOL~-74 provides the index data item. . - Index data items are 1l-word binary integers with implicit synchronization. (The 1l1-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 ‘ S | Figure 5-18 Index Data Item 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 1index data item, only the subscript part 1is moved. Likewise, when a -SET statement "moves" an index 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 numeric, COMP items 1is that the data description is shorter, easier to write, more self-documenting. Further, the restrictions placed on access index items may be usefulTMin debugging the program. 5.4.9 The and to SET Statement The SET statement alters the value o0f index-name items and copies their wvalue into 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 statement can perform. INDEX-NAME ITEM - NUMERIC LITERAL NUMERIC DATA NAME (COMP OR DISPLAY) L __ (INDEX PART) _ _ INDEX F__;,F(SUBSCRIPT PART) m— ~_ - ] Figure 5-19 ITEM ] INDEX~-NAME ITEM | _ (INDEX PART) (SUBSCRIPT PART) | ‘ DATA | Legal Data 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 is 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 1is used: 1. element Determine the number of occurrences in the table (the contained in data-name-1), and verify its legality. in a value o '_(integer—l <= data-name-1 <= integer-2) 2. Verify that the subscript is within the legal range. (subscript <= data-name-1) If any of the above checks fails, appropriate error message. 5.4.11 | execution is - terminated | | with | an Referencing a Dynamic Group at Run Time A dynamic group is defined as a group item that contains a subordinate item that 1is a variable length table. At run time, when a dynamlc group is referenced 1. the are followed The number of occurrences of the subordlnate variable 1length table is determined, and checked for 1legality; i.e., integer—l<=data—name-1<=integer—2. If this check fails, execution terminates and the appropriate error message is 1ssued 2. follow1ng procedures | | . ; a ,The size of the dynamlc group is calculated. The number of occurrences of the variable 1length table (data-name-1l) is multiplied by the size of one table entry. The resulting number is then added to the fixed size of the dynamic group. NOTE The fixed size of a dynamic group is the size of including 5.4.12 the group the variable up to but length table. not The SEARCH*Verb The SEARCH verb has two formats: Format 1, which performs a sequential search of the specified table beginning with the current index setting; and Format 2 which performs a selective (binary) search of the specified table, 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 in failure path is defined either explicitly by the AT END statement, which case the imperative statement which follows it is executed; by default, in which case control is passed to the next procedural or sentence. statement In is either case executed, (success or control is failure), passed to sentence. 5.4.13 after the an imperative next procedural - The SEARCH Verb - Format 1 Format 1 directs the RTS to search the indicated table search. index setting, and index by one as each The OCCURS clause for the INDEXED by phrase. Unless statement, the first 1index The progresses search begins through the sequentially. table being searched must contain the otherwise specified 1in the SEARCH 1s the controlling index for the table with table, the current augmenting the occurrence is interrogated. If any of the specified conditions true (success), the associated imperative statement is executed; search exits; and the index remains at the current setting. If the possible number of occurrences for the before any of the specified conditions are met, exit path is taken. specified) 1is That taken, or sentence. 1is, either control 1is the table 1is exhausted the specified failure AT passed END to exit the | path in a | | search serially. ‘Associated with Format 1 is the optional VARYING phrase. be specified by using any of 1. default - phrase omitted 2. VARYING 3. VARYING identifier-2 4. VARYING the following methods: This a phrase N, \ index-name-n v index-name-2 B can (if next procedural Figure 5-20 contains an example of using the SEARCH verb to table is the NOTE a. The following above methods is is An associated index name true used. regardless with the of which table 1s of the methodically augmented by one, by the RTS, for each cycle of the serial search. This controlling index, when compared to the allowable number of occurrences for the table, dictates the permissible range of search <cycles at run time. When an exit occurs (success or failure), this index remains at the current setting. 5-18 TABLE HANDLING b. The RTS will not initialize the index when the search begins. It is 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 (index-name-~l) associated with the table is used as the controlling 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. When method 2 is used, index-name-n is any index with the the table. - processor. that is See associated table being searched. It becomes the controlling index for It alone is set to consecutive values by the RTS search 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 Figure 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 (lst index for the table) of the searched table 1is augmented, index-name-2 1is also augmented. See Figure 5-20, Example / —_— A 5.4.14 The SEARCH Verb - Format 2 Format 2 is used to direct the RTS to search the indicated table selectively. The selective (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 the sequence of simple tests for equality, beginning the median value. 3. with the first, with the index set | to If all of the tests for equality are true (success), the search is terminated; the associated imperative statement 1is executed; the search exits; and the 1index retains 1its current value. TABLE HANDLING 5-19 1If any of the tests for results a. b. occur. equality 1is false, the following | 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. 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 1less 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. : C. Once the direction of search isidetermined, half d. Processing begins all over-again,from Step 1. See Figure 5-20, Example 6, for Format 2 of the SEARCH verb. 5-20 of the table is eliminated from further consideration. A new range of permissible index values is computed from the remaining half of the table. | TABLE HANDLING an example of searching a table - using e 4. FED=TAX=TABLES, A2 ALLOWANCE=DATA, @3 FILLER PIC X(78) VALUE "Qa@lLLD 13202880 "@304320 "@4A5760 "AEAT200 "A6QB6UD "@718080 "0811520 3912960 - ALLOWANCE=TABLE @3 ASCENDING INDEXED 04 @2 REDEFINES FED=ALLOWANCES BY KEY ALLowANcanoATA. OCCURS 18 1@ TIMES ALLOWANCE=NUMBER IND=1, ALLOWANCE=NUMBER 04 ALLOWANCE SINGLES=DEDUCTION=DATA, PIC ~ a3 FILLER "(250006700200216 "B6T0011508067227 "1150018380163223 XX, PIC 999V99, A PIC X(112) VALUE "1830024000319621 2 "2UB0P27900439326 "279P334600540730 "3U46PP99999TU1TI6", SINGLES=DEDUCTION=TABLE ' #3 INDEXED BY IND=2, 04 SeMINwRANGE @2 92 REDEFINES TEMP=INDEX, PIC 999V99, A4 S=MAX=RANGE B4 SeTAX @4 S=PERCENT MARRIED=DEDUCTION=DATA, #3 FILLER "BUB00096000020017 "09602173200081620 "17300260000235617 "26402346002390325 "346P0433000595328 "4330050P08MR3B9T2 "EARRN999991A53336", MARRIED=DEDUCTION=TABLE @3 SINGLES=DEDUCTION=DATA, SINGLES=TABLE OCCURS 7 TIMES ASCENDING KEY 18 S=MIN=RANGE S=MAX=RANGE MARRIED=TABLE PIC PIC PIC 996V99, 99V99, V99, PIC X(119) REDEFINES OCCURS 7 M=MIN=RANGE M=MAX=RANGE M=TAX MePERCENT M=MAX=RANGE PIC 999V99, PIC 999vag, PIC 999v99, PIC V99, USAGE INDEX, | Figure Example To MARRIED=DEDUCTION=DATA, TIMES ASCENDING KEY 18 M=MIN=RANGE INDEXED RY IND=@, IND=3, 04 P4 B4 24 TEMP= INDEX VALUE of 5-20 Using Search a SEARCH Table TABLE HANDLING 5-21 { | T Example SINGLE, IF TAXABLE=INCOME < 2499 GO 7O END=FED=COMP, IND=2 TO {, SET SEARCH WHEN SINGLES=TABLE VARYING IND=2 AT END GO 7O TABLE=2=ERROR | TAXABLE=INCOME m SsMIN=RANGE(IND=2) , MOVE Se«TAX(IND»2) TO FEG-TAX-DEDUC?IQN OF QUTPUT=MASTER WHEN GO TO STNREwFED=TAY TAXABLE=INCOME « SwMAX-RANGECIND-E) SUBTRACT S=MINwRANGE(IND=2) FROM TAXABLE=INCOME MULTIPLY TAXABLE=INCOME BY S=PERCENT(IND=2) ROUNDEQ ADD TAXARLE=INCOME TO FEfinTAXwflEDUCTION OF OUTPUT=MASTER, ~Example SINGLE, 2 IF TAXABLE=INCOME < 22499 GO TO END=FED=COMP, SET IND=2 TQ 1, SEARCH SINGLES=TABLE VARYING GO WHEN TO IND=2 AT END TABLE=2«ERROR TAXABLE=INCOME 2- S=MIN=RANGE(IND=2) B MOVE S=TAX(IND=2) TO FED=TAX=DEDUCTION OF OUTPUT=MASTER WHMEN GO TO STORE=FED=TAX TAXABLE=INCOME < S-MAX-RANGE(INE*EJ | SUBTRACT S=MINeRANGE(IND=2) FROM TAXABLE=INCOME MULTIPLY TAXABLE=INCOME BY S=PERCENT(INDw»2) ROUNDED ADD TAXABLE=INCOME TO FED-TAXflDfiDUCTIDN OF | 3 'MARRIED, IF QUTPUT-MASTER. TAXABLE=INCOME < | 04799 MOVE ZEROS TO FEDwTAXwDEQUCTION OF GO 70O END#PEDGCDMP. SET IND=3 TO i, SEARCH MARRIED=TABLE VARYING IND=3 AT END GO TO TABLE=3=ERROR WHEN TAXABLEwINCOME = MnMIN-RANGE(INBmsg MOVE M=TAX(IND=3) GO TO0 QUTPUT=MASTER, TO FED=TAX=DEDUCTION OF GUTPUTwMASTEfig STORE=FED=TAX, WHEN TAXABLE=INCOME ¢ MuMAX=RANGE(IND=3) MOVE MeTAX(IND=3) TO FED=TAX«=DEDUCTION SUBTRACT MeMIN=RANGE(IND=3) FROM OF OQUTPUT=MASTER, TAXABLE=INCOME ROUNDED, MULTIPLY TAXABLE=INCOME BY MesPERCENT(IND=3) ADD TAXABLE=INCOME T0O FED«TAX=DEDUCTION GO NF QUTPUT=MASTER ROUNDED, TO STORE~FED=TAX, ‘Figure 5-20 (Cont.) Example of Using SEARCH To Search a Table 5-22 TABLE HANDLING ROUNDED, Example SINGLE, 4 1F TAXABLE=INCOME < p2499 GO TO END=FED=COMP, SET IND=TO 2 {, SEARCH SINGLES=TABLE VARYING GO TO TABLE=2«ERROR WHEN TAXABLE=INCOME MOVE GO WHEN TO TO OUTPUT=MASTER STNRE=FED=TAX SUBTRACT MULTIPLY « FED=TAX=DEDUCTION ~ OF %wHAXnRANfifi(INDwQJ TO FED=TAXwDEDUGCTION OUTPUT=MASTER, ~, END S=MIN=RANGE(IND=2) FROM TAXABLEeINCOME TAXABLE=INCOME BY S=PERCENT(IND=2) ROLNDED TAXABLE=INCOME OF 4 ;7 - \\\ AT $=MINeRANGE(IND=2) S=TAX(IND=2) TAXABLE=INCOME ADD 3 | TEMPeINDEX Example 5 ‘SINGLEQ IF TAXARLE=INCOME < 32499 GO TO ENN=FED«COMP, SET IND=2 TO i, | | SEARCH SINGLES=TABLE VARYING IND=2d AT END GO TO TABLE=2=ERROR WHEN TAXABLE=INCOME = S=MINeRANGE(IND=2) MOVE S=TAX(IND=2) TO FED=TAX=DEDUCTION GO TO OF QUTPUT=MASTER STORE=FED=TAX WHEN TAXABLE=INCOME ¢ SwMAX=RANGE(IND=2) SUBTRACT S«MIN=RANGE(IND»2) MULTIPLY TAXABLE=INCOME ADD TAXABRLE=INCOME TO FROM BY TAXABLE=INCOME 8=PERCENT(IND=2) FED«TAX=DEDUCTION ROUNDED OF OUTPUT=MASTER, Example 6 FED'DEDUCTDCOMPUTATIQN, SET IND=t{ SEARCH WHEN TO 1, ALL FEDwALLOWANCES AT END GO T0O TABLE={=»ERROR ALLOWANCE«=NUMBER(IND=1) = NR=DEPENDENTS OF QUTPUT=MASTER, | SUBTRACT ALLOWANCE(IND=1) GIVING IF | | FROM GROSS=WAGE TAXARLE=INCOME MARRITAL=STATUS OF QUTPUT=MASTER 60 TQ MARRIED Figure 5-20 Example To QUTPUT=MASTER = MWM¥ | (Cont.) of Using Search OF ROUNDED, a SEARCH Table TABLE HANDLING 5-23 CHAPTER g \ INPUT-OUTPUT 6 PROCESSING This chapter relates COBOL-74 I/O 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/0, this chapter provides a bridge between the concepts and facilities of both. For more detailed information: 1. 2. The VAX-11l COBOL-74 Language Reference Manual describes the I/0 concepts and statements that are part of the COBOL language. » The basic concepts of RMS, such as file organization, access the physical attributes of file devices, are the Introduction to VAX-11l Record Management modes, and discussed in Services. Most of the following discussion relates to input-outpgt is largely device-independent file handling. However, in the VAX-1l1l 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 and the systems file-associated low-volume apply only 1I/0 statements I/0 statements (ACCEPT to terminal devices. (like OPEN, and READ, DISPLAY), and WRITE) which in many 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 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 they are 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; cannot correctly access a file if it specifies a different blocking for factor or record format (fixed-length instead of variable-length, instance) than was originally defined. specify COBOL programs attributes file combination a through statements in the Environment and Data Divisions: 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 sizes record 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.1l.1 Fixed-length Files with the fixed-length record format contain records that are all the the fixed-length record format The compiler generates same size. file_attribute when: The file has only one record description, or has multiple "RECORD CONTAINS it 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 a The program does of the follow1ng e The '@ An @ 6.1.2 not to specify a print- controlled refer to the file: ADVANCING phrase APPLY in PRINT-CONTROL a WRITE clause file by using any statement in the Environment Division A LINAGE clause in the file description Variable-length Files with the variable-length record format can contain vary 1in size. RMS stores a record length field before of each data record. @ ® records that the beginning For disk files, the reeord length field is a 2-byte binary value that specifies the length of (excluding the record length field). For tape value files, that (including the record specifies the length the field 1length record length the record a 4-byte the record is of for The file has more than one record description, and described fqr the file decimal in bytes field). The compiler generates the variable-length attribute records (l—word) in bytes are the same a file when: not all size; OR the file description contains a "RECORD TO 6.1.3 integer-2" phrase. CONTAINS integer-1 t Variable With Fixed-Length Control Variable with fixed-length variable-length records; field between the record control records however, they contain length field and the a are similar to fixed-length control variable-length data record. ‘The and compiler for generates this attribute only for prlnt controlled files that are opened by a DISPLAY statement; the RTS files stores print-control values in the fixed-length control field, which is two bytes 1long. Section 6.1.1 describes the COBOL 1anguage 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 s1ze of the COBOL record descrlptlon that is used to write the record. The maximum @ size For of a record depends on record fixed-length records, the format: maximum size. @ - size 1is - the record | 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 needed for the storage medium. number - of overhead bytes | | 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 length field. B - - In sequential and indexed files, however, variable-length records can save Sspace. RMS stores records contiguously whenever 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 1is determined only by the effective size of the record description named in the WRITE statement. 1In the following example, the first WRITE statement causes 56 bytes to be written to the file spec1f1ed by ACCOUNT-FILE; the second WRITE statement transfers 42 bytes. FD ACCOUNT-FILE 01 ACCT-FLAG-REC. 03 FILLER 04 ACCT-FLAG 01 ACCT-REC. ‘03 ACCT-NUM 03 ACCT-NAME 03 ACCT-LIMIT 03 ACCT-DISCOUNT 03 ACCT-DATE WRITE | PIC X(40). PIC 9(2). PIC PIC PIC PIC PIC ACCT-REC. WRITE ACCT-FLAG-REC. 6-4 INPUT-OUTPUT PROCESSING 9(10). X(30). 9(6). 99V99. 9(6). 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 block. The COBOL language expresses block characters. The actual size of the by the the ‘uses storage medium, term "block" terminology - Physical size unit record format and can have several that is more in of terms data file of records transfer affected chapter organization. meanings, the or is Because rest of this treated as a unit by physical block can specific: Block A group the - of consecutive storage medium. vary in size; it interrecord gaps. ~unit. bytes of data On magnetic tape, a is the number of On disk, a physical » bytes block between two is a 512-byte | A physical block can contain one or more records, or it contain part boundaries. of ‘Physical block. is block a record; records can synonymous with the span physical VAX-11l RMS can block 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 buckets. Récord Unit 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 size store is is field. INPUT-OUTPUT the a record record the maximum PROCESSING 6-5 For variable with fixed-length control records, record unit sum of the maximum record length, the count the is size (two field field size, and the size of the print-control | bytes). , s characters orord In COBOL, you can specify blocking in terms of rec or you can use the compiler's default. The following sections discuss the three methods separately for each file organization. The examples to the following samples of COBOL file and:record descriptions: refer A Sample TEST-FILE FD LABEL RECORDS ARE STANDARD. PIC X(100). REC-1 PIC X(511). REC-2 01 01 | Sample B BLOCK CONTAINS 50 RECORDS LABEL RECORDS ARE STANDARD. PIC X(20). REC-1 01 Sample | TEST-FILE FD C " FD TEST-FILE BLOCK CONTAINS 512 CHARACTERS - LABEL RECORDS ARE STANDARD. PIC X(494). 01 REC-1 Sequential Files on Magnetic Tape 6.3.1 Default ST | The physical block size is determined when the volume is mounted; if the command, qualifier /BLOCK=n not used with the VAX/VMS MOUNT is the RMS default is 2048 characters. . - . . n RECORDS BLOCK CONTAINS The compiler computes the physical block size as n multiplied the record unit size. Example: Sample B 6-6 Physical block size 1000 bytes (50%20) INPUT-OUTPUT PROCESSING | ot by BLOCK CONTAINS n CHARACTERS ignores n compiler physical block size. Ifn is less than the record unit size, the and uses the record unit size as the Otherwise, the physical block size equals n. Records cannot span therefore, a physical block can contain only physical blocks; A physical block complete records (regardless of record format). device when the tape magnetic the to (written) is transferred program tries to add a record that cannot fit into the 1I/0 buffer; the unwritten record begins the next physical block. Example: Physical block size Sample 512 bytes - C (18 unused) Sequential Files on Disk 6.3.2 Records are: packed together in each there .are no block; physical unused bytes in any block, and the records can span block boundaries. Default T sequential for The RMS default determines record blocking files. | disk BLOCK CONTAINS n RECORDS data The compiler computes the unit of 512-byte physical blocks, as follows: Unit of data transfer = (n*record unit size/512), transfer, | . in terms of 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 follows: transfer, in terms of Unit of data transfer = n/512, rounded up Example: 'Sample C Unit of data transfer 1 = 512/512, rounded up INPUT-OUTPUT PROCESSING 6-7 - 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 is empty. Bucket size is expressed in terms of 512-byte physical blocks. The bucket size is a file attribute; the file, you must specify created. it | The following 6030 examples therefore, each time you the same way as when the access file was “ refer to the COBOL samples presented ' in Section Default - The compiler tries to make the bucket size as small by computing Bucket it as size follows: ((l+record unit size)/512), as rounded possible up . Example: Sample Bucket A size 2 = ((1+(2+511))/512), rounded up BLOCK CONTAINS n RECORDS The compiler Bucket computes size = the bucket (n*(l+record size as unit follows: size)/512), rounded up Example: Sample Bucket B 3 = size (50%(1+20)/512), rounded up BLOCK CONTAINS n CHARACTERS ' ‘The compiler computes the bucket size as follows: Bucket size = n/512 Where: @ n must equal or exceed (l+record unit size). If it 1is less than that gquantity, the compiler issues a warning diagnostic and uses the default method to compute the bucket size. @ n must be a multiple warning diagnostic 512. 6-8 INPUT-OUTPUT | PROCESSING | of 512. If and rounds not, the n up to compiler issues a the next multiple of Example: Sample Bucket C 6.3.4 size 1 Indexed Files Each of the methods for considers overhead bytes Record Bucket computing bucket for each record and The bucket size is a file attribute; the file, you must created. In each specify | of the it therefore, each time you the | following indexed files bytes bytes 7 15 overhead overhead size for bucket: same way as when | methods, 512-byte physical blocks. samples presented in Section access file was terms of | bucket Again, 6.3. the size the is expressed examples - refer ~ in to the COBOL Default The compiler by computing tries it as Bucket size to make the follows: bucket size as small as - possible A ((15+(7+record unit size))/512), rounded up Example: Sample A BLOCK CONTAINS The Bucket 2 = n compiler size | ((15+(7+(2+511)))/512), rounded up RECORDS computes the bucket size as follows: Bucket size = ((15+(7+record unit size)*n)/512), rounded up Example: Sample B Bucket 4 size = ((15+(7+20)*50)/512), rounded up - INPUT-OUTPUT PROCESSING 6-9 5 BLOCK CONTAINS n - CHARACTERS The compiler computes the bucket size Bucket size = n/512 as follows: | Where: @ @ n must equal or exceed'(15+(7+record unit size)). If less than diagnostic size. a the that quantity, the compiler issues and uses the default method to compute n must be a multiple of 512. warning 512. diagnostic and If not, rounds n up the to compiler the it 1is warning bucket issues a next multiple of \\. Example: Cc Bucket size. B Samplé_ | 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 record area is the location in which records are available to a COBOL program; it is defined by the record descriptions that follow the file description. COBOL I/O statements appear to transfer data directly between a file and 1its current record area. Actually, I/O statements transfer data between the current record area and the file's I/0 buffer. RMS manages the I/O buffers and transfers data between them and files. 6.4.1 Effects on Output Operations The current record area includes the total area described by all of file's record descriptions: described for the file. The size of a determined by 1is as large record written by a COBOL the record description named statement. 6-10 it INPUT-OUTPUT PROCESSING | | as the largest 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, the operation does not change the area beyond the end of the - incoming record. Consider an example in which the current record area contains 20 the first record read from a file. If the next READ from characters returns a l2-character record, the remaining 8 character positions are not | changed: Current record area after first READ: | 0239394CABINET, 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 FILE to vdepend on Sharing Record Areas The compiler normally allocates storage space separately for each file's current record area. This method of current record area "allocation has two potentially undesirable effects: 1. Each file's current record area requires storage in the program's Data Division. If the number of files and the size could Division sizes of their records are large, Data which is limitation, size Division Data COBOL-74's approach 65,535 2. bytes. another to them writing Reading records from one file and file's from one transfer intermediate data an requires a If the program processes current record area to the other. movement data the way, this records of number large 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 named in a SAME RECORD AREA clause, the compiler assigns the beginning of the current record areas to a common location; the leftmost bytes of each current record area coincide in the same way that the leftmost bytes of each record for a file share one location. Records need not be the same size; "the maximum sizes of each current record area be the same. nor must Figure 6-1 shows the effect of current record area sharing in a program that reads records from one file and writes them to another. However, it also shows a drawback: current record area sharing 1is INPUT-OUTPUT PROCESSING 6-11 equivalent to separately -- implicit therefore, redefinition; if the program the output file, the original available. Remember that you directly. input cannot the records changes the do record not exist defined file record is access a file's ‘ | for no 1longer I/0 buffer Figure 6-1 Sharing Record Areas Program Without Sharing B Program With Sharing I-O-CONTROL. . SAME RECORD AREA INP-FILE FOR OUT—FILE. PROCEDURE DIVISION. PROCEDURE DIVISION. READ INP-FILE ... READ INP-FILE ... MOVE INP-REC TO OUT-REC. WRITE OUT-REC ... WRITE Process Without Sharing OUT-REC Process With Sharing INP-FILE buffer READ READ (move) (move) INP-REC . MOVE o - OUT-REC | Y TM Sl | S i | INP-REC |} OUT-REC S | | WRITE \ | WRITE (move) [ | OUT-FILE (move) buffer ~ L - 6-12 INPUT-OUTPUT PROCESSING 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 descrlptlon of records and files: it can read or write more data (or less) 1n each operatlon than the program Buffer use is necessary for record blocklng, requests. for example, when your| program reads a record that is 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/0 operations. Using multi-buffering, RMS RESERVE clause. e P Ny , can reduce your program's record access time by storing large amounts of data in the program's address space between I/0O requests. 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 P. 6.5.1 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 RMSDEFAULTS 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/0 speed is important. | You can specify up to 127 areas in the RESERVE clause; however, 1f 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 are in a not to ensure not this (when save SAME COBOL program must operation OUTPUT, I-O, on and statements you that used can be 6.6.1 explicitly it. program clause shared. specific cannot be However, files opens therefore, are you a since open at can use closed before 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 used by the RTS and RMS when you open files. I1/0 Operations Three conditions determine perform on a file: l. File 2. Access 3. Open mode the 1I/0 | operations that a | program can | organization mode relationships among file organization, access mode, open mode, and statements are hierarchical: file organization determines which access modes are valid; the combination of mode determines valid open modes; and enables or disables I/0 statements. relationships combination. 6-14 your resources; AREA actually that condition. OPENING FILES I/0 The I/0 detects would specified buffers it dynamically sharing the SAME AREA clause others are opened. 6.6 when use the valid to the RTS by INPUT-OUTPUT indicating PROCESSING I/0 statement organization and the combination of all Table 6-1 shows availability for access three these each valid 6-1 Table I/0 Statements Grouped by File Organization, Access File Organization SEQUENTIAL Access Mode Mode, and Open Mode Open Mode Statement SEQUENTIAL | READ . | REWRITE | WRITE RELATIVE ~ Yes No Yes No No Yes Yes Yes (No No Yes Yes No No Yes No No NO No No Yes Yes Yes Yes Yes No No Yes Yes No Yes Yes No Yes REWRITE START No Yes No No Yes WRITE NoO Yes No No No Yes Yes Yes START WRITE No Yes No Yes ‘No No Yes Yes No DELETE READ = | No Yes No No- WRITE No Yes No Yes No No No No No Yes START WRITE { DELETE READ REWRITE WRITE DYNAMIC DELETE READ . NEXT SEQUENTIAL | DELETE READ REWRITE DYNAMIC Yes Yes NoO RANDOM RANDOM : No No NoO READ INDEXED Yes No Yes No READ REWRITE / I-0 'No SEQUENTIAL | DELETE i INPUT | OUTPUT REWRITE DELETE READ READ NEXT REWRITE START WRITE No | No Yes No Yes No - EXTEND NoO No Yes , N/A Yes 1 1 Yes Yes Yes Yes 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: @ File open procedure and how 1t 1s affected organization ® 'Access mode An @ Open mode ® RTS error detection ® RMS error detection ® Existence OPEN attempt statement to of USE procedures causes the the file make RTS to begin available detected, the OPEN fails: the RTS procedure (if the program has terminates the image. to a series the of The RTS checks the current status of the OPEN an that error reaches statement: already open, If either performs the applicable one) or issues an error message | | The following proCedure starts when a COBOL program 1. procedures program. the file. an If is USE and OPEN it is fails. 2. The RTS builds a file specification by using the contents of the VALUE OF ID identifier, if any, to replace or add to the components of the ASSIGN clause file specification 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 1its 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 sequential marks the successful, 1f RMS find the in file, specified files only) file for and returns reports that 6-16 INPUT-OUTPUT PROCESSING it the it the and an AT file control logical name specification invalid device, or if it reports - notifies as the is condition, to the find the RTS; OPTIONAL open mode END cannot a the file spe01f1cat10n, file the to checks If any RMS then, (valid 1f for INPUT, the RTS considers the OPEN program. file, the Otherwise, OPEN fails. 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. 1If the program the program PRINT-CONTROL is opening a sequential file for output, and contained either the LINAGE or APPLY clauses, the RTS initializes the LINAGE counters. 10. Before returning control to the program after a successful OPEN, the RTS marks as enabled or disabled all the 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 NAMING FILES In a COBOL you program, specify CLOSE in statements. exists outside clause of the specification; you the However, to a file use in the you refer by its file-name: SELECT, OPEN, the physical to READ, the name START, file, as and it the program, with a file specification. The ASSIGN SELECT statement contains the default file the VALUE OF 1ID <clause in the file description particularizes the file specification. This section discusses are described It relates techniques refer FD and file in detail specifications in the VAX/VMS the ASSIGN and VALUE and recommends a your COBOL programs and 1logical names, which Command Language User's Guide. OF ID clauses to the two file naming convention that you can follow to make device-independent. “ - NOTE The term "system" is used when it is not important VAX/VMS and example). 6}7.1 to differentiate between 'its subsystems (RMS, for » File Specifications File spécifications provide the system with needs The to uniquely general form identify a of the file file or device. specification all the information it is: node: :device: [directory] filename. type;ver INPUT-OUTPUT PROCESSING 6-17 N - The punctuation marks and brackets specification. The fields are: A network node separate node name network, names are 1if vyour from one the fields identifies a the location file on system 'is connected to one. to six characters long. Each hardware device in the system has name specification in the format: device of a unique the Node device devcu: where dev is a mnemonic controller designation; directory for the device type; c and u is a unit number. 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 field, in combination with the file type and version number, uniquely identifies files within directories. The file name can be from one to nine characters long. type The of file its type is often used to contents. It can characters executable 1long. images is identify be from For example, usually EXE. the a file in one to file terms three type of 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 1in the same directory, the system assigns a version number that is one greater than the highest existing version. You must put a semicolon or a period before the version ver number. ‘All fields are optional in a file specification. The system supplies default values for all omitted fields, except file name and type. For example, default device and directory names are established when you log in; you can change them with the SET DEFAULT command. File Specification Examples: DBAl: [SMITH]ACCOUNT.DAT Refers ACCOUNT.DAT local 6-18 system the in latest version directory (node name INPUT-OUTPUT PROCESSING name default). (default) [SMITH] on of the file device DBAl: | named on the PAYROL.NEW; 23 Refers to version number 23 of the file named default directory on the default device. File PAYROL.NEW in the | Switches File specifications in the ASSIGN or VALUE OF ID <clause <can be followed by "file switches". These specifications are not defined by VAX-1ll RMS; however, the RTS accepts them and translates switches discussed 6.7.2 them to VAX-11l RMS parameters. for <compatibility with PDP-11 in Section 6.8.5). COBOL-74 COBOL. accepts file (They are Logical 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 the ASSIGN command, which is described in the VAX/VMS Command 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 level, or on a system-wide basis. | To translate a logical name, the system searches the three system); therefore, by defining it for process. you your tables in can override a group or your | / , \ . order (process, dgroup, system-wide logical name 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 and example, assume that the equivalence use the ASSIGN command: name of FILEA you ASSIGN If another logical name translation. It continues it cannot translate the equivalence name. your FILEA program 1is in the the this ALPHA,.DAT, | MYFILE tries to open a file whose file specification 1is "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 would named use it as a file specification and look for a file INPUT-OUTPUT PROCESSING 6-19 "MYFILE.". ASSIGN and VALUE OF ID Clauses 6.7.3 You can use the SELECT statement ASSIGN clause alone or in combination the VALUE OF ID clause to supply file spec1f1cat10ns 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]WORKl.TMP". OF ID clause if You need not use the VALUE you choose this technique. Partial file spec1f1cat10n If part of the file specification can change from one run another, you can use a partial file spec1flcat10nSELECT INPUT-FILE to .DAT". ASSIGN TO "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: file specificétion identifier contents [JONES]A PERSONNEL [WILLIAMS] spaces DBAOQ: [SMITH]WEEK LIS . TMP Logical DBAl: [JONES]A.DAT DBAl: PERSONNEL.DAT DBAl: [WILLIAMS] .DAT | ~ . DBAl: .DAT DBAQ: [SMITH]WEEK.LIS DBAl: .TMP name A 1ogical name can look like a partial file specification 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 system recognizes it as a file specification, the the that system tries to translate 6-20 INPUT-OUTPUT PROCESSING it. For example, to the assume that equivalence statement the name is: logical name "MYFILE" "PERSONNEL.DAT". If translates the SELECT | SELECT INP-FILE ASSIGN TO - | "MYFILE". and the program accepts input at run time to fill the VALUE OF ID identifier, 1logical name translation may or may not take place, dependlng on the input: | identifier contents file « DAT MYFILE.DAT spaces PERSONNEL. DAT [SMITH] You can often specification [SMITH]MYFILE. increase program versatility and avoid "one-time" recompilations by wusing 1logical names in the ASSIGN clause literal. Consider an accounting system with 20 programs that access the same ten master files. access another example, when set two It of could be necessary to use the same programs to files at the start of a new year, for accounting vyears are active, or when another master organlzatlon S accounts must also be maintained. involved in convertlng the programs would depend naming conventions: @ If complete file specifications are clause, and the programs do not accept run time, all 20 programs need to The amount of work on the programs' file used in the ASSIGN file specifications at 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 If the programs would not need the would be tested. accept file specifications at run time, they changed. However, assuming they run as command procedure needs to be ~changed, and to be batch jobs, each probably renamed. operators programs If need to be the 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 spec1f1cat10n errors, ~and perhaps damage to data files. e If logical would jobs, case, not the names are need to used be in command procedures since logical the changed. name are ASSIGN clause, If programs the simpler assignments than need the in be programs run as the previous made only batch once at the beginning of the procedure instead of for each program; 1f multiple command procedures were used, they could all execute a single command procedure that does nothing but assign 1logical names. If the programs run interactively, the operator needs only to execute one command procedure to assign all logical names for the correct set of files. N | | INPUT-OUTPUT PROCESSING 6-21 6.7.4 File Switches (PDP-11 COBOL Compatibility) PDP-11 COBOL allows the wuse of switches (gqualifiers) 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 COBO compatible with VAX-11] RMS; | programs with VAX-11 COBOL-74 and execute them without change. Table 6-2 describes the Note that :some those in the PDP-11 switches. specification file COBOL the terminology and concepts are not the same as of also Note system. VAX-1ll wvalues that numeric specified as either decimal or octal, not hexadecimal. are | Table 6-2 File Specification Switches for Compatibility with PDP-11 COBOL SWITCH MEANING 1is created. Allocate n disk blocks to the file when it that n blocks are available before ensures This switch to the also use You can processing begins. If file. entire the hold can volume the the that ensure of n is a decimal point, the RTS the rightmost character otherwise, interprets the value as a decimal number; /AL:n the RTS treats n as an octal value. | The blocks allocated need not be contiguous. 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 /CL:n operating , system. This switch complements /CO:n /AL:n; it further specifies rightmost the If contiguous. be blocks all that interprets RTS the character of n is a decimal point, otherwise, the RTS number; as a decimal the value treats n as an octal value. Specifies an extension quantity of n blocks when the file 1is created. A large extension quantity minimizes 1If the rightmost character of n is a extend operations. decimal point, the RTS interprets the value as a decimal /DQ:n » number; the RTS treats n as an octal value. as Causes I/0 buffers to be written only when full, the default case, in which every write to contrasted This option operation causes a physical I/0 operation. is available only for files that are not write-shared. /DW /LO otherwise, “ Causes RMS to use the fill numbers file was created. specified when contain free space to allow later record insertion. 6-22 INPUT-OUTPUT PROCESSING the Fill numbers can cause the file to Table 6-2 /MI indexed an (into insertion This switch optimizes the wof records sorted in order of ascending prime key file) for values. Mass insertion eliminates the index search 1in implemented is feature subsequent writes. This RMS-11. /SH (Continued) » for the for the 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 file, the it processes sharing 2. must the be file. If a file is being opened specified for output specified, /SH switch the with file processes currently using the have the /SH switch specified. 3. all or 1I/O other all also must the /SH If a file is opened for input without no other process can use the file set, switch for output or 4, for I/O. 1If é file is opened for input without set, switch no the /SH other process currently using the file can have the /SH switch set. If access is denied because one of these rules has been violated, the RTS stores a value of 91 1in the FILE-STATUS data-item associated with the file, assuming contains a file the for statement SELECT that ‘the FILE-STATUS clause. /WIzn | 4 o Sets the number of retrieval pointers in the window used virtual block numbers to logical block numbers. map to Kknow if ‘you The acceptable values range from 1 to 102 how many pointers are present on disk for the exactly as pointers or 255, which requests assignment of file, needed. CAUTION The /WIin switch can cause loss of data and file integrity is being if the system crashes while a buffer 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-1l1l 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 Ccreates. - The ability to read records, however, does not imply a universal ability to transfer data between programs written in different languages -- at least not without some special processing. 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 Data‘Type Differences Not all data types are supported utilities. For example- e * e COBOL-74 does not by all support Therefore, COBOL point data (FORTRAN the programs real VAX-11 SORT does not Therefore, problems COMPUTATIONAL key whose programming languages floating cannot variables) support arise in picture is point easily in and data process all type. floating files. quadword binary items. sorting a file on a in the range S9(10) to S9(18). e FORTRAN | Therefore, be used does by support the COMPUTATIONAL-3 not data packed-decimal in COBOL files data type. cannot ea51ly FORTRAN programs. " The fact that'datatypes differ should not keep you from data between programs written in different languages. techniques to overcome data type incompatibilities: l. ©Use in transferring can use two ASCII character representation, if possible, for all data files intended for use across languages: ASCII representation (USAGE IS DISPLAY, universally recognized. All VAX-1ll support this data type. 2. You Convert the data in your program to in COBOL) 1is ‘almost languages and utilities | a data format you can use. Even if .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 double-precision for representation fraction and in any exponent COMPUTATIONAL data items. 6-24 INPUT-OUTPUT PROCESSING value may have COBOL can be too large data-. type; represented a magnitude however, in COBOL by the two 6.8.2 Data Record Formatting Differences Programming languages may use different conventions to format their data records, causing incompatibilities in 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, 1in some cases, by print-controlled files. 1In FORTRAN, for example, with the “CARRIAGE CONTROL-'NONE'" specification. a file 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, 6.8.3 which your program can either interpret or ignore. SpeCial Contrel 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 item 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/0 ERROR PROCESSING When your program reaches a file I/O 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/O 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 accessed file, an INVALID KEY condition 1is reported whenever RMS determines that the file does not contain 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 1I/O statements. An I/O error is any other condition that causes an I/O statement to If your program contains a USE procedure that applies to the file for which the I/O 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. if the file status data item contains the value "91", that the file is locked by another process, you might opening the In other file cases, procedure processing for again performing other when program continuation can in after perform is not "housekeeping" an orderly way, by saving procedures. desirable, operations data or the that informing USE conclude the user, example. 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 the 6.10 handled by a USE procedure, you must USE procedure and run it again. LOW-VOLUME I/O 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 association of your own VAX/VMS logical names; and DISPLAY statements. 6-26 INPUT-OUTPUT it PROCESSING mnemonic-names continues with discussions of to the ACCEPT /“"""‘\\ - For example, which indicates decide to try 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 logical names. are COBSINPUT and names 1logical default the , clauses FROM/UPON COBSOUTPUT. | | 1in The FROM/UPON clauses refer to mnemonic-names that you can define a define You 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 //‘v ~ 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 ation with a VMS for example, assign a logical name to a file specific ASSIGN command: ASSIGN[ALLSTATUS]STATUS.LIS COB$LINEPRINTER no Because a logical name does not imply a device, it <carries a upon display can program a re, implication of "open mode"; therefo a from accept or ADER CARD-RE 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 , therefore es; file-nam However, the RTS uses RMS for all I/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 - 7,\\ in any COBOL module in the image. INPUT-OUTPUT PROCESSING 6-27 '/“""\\t NOTE -When the RTS DISPLAY opens a logical name statement, it variable with fixed-length format to allow carriage RTS does opens a not wuse 1logical statement. The for specifies a the control (VFC) control: - the VFC. format when it name for an ACCEPT record format attribute is used for all operations until the image terminates; therefore, .if vyour program contains both ACCEPT and DISPLAY statements that logical name, DISPLAY before refer it to the should the same execute first a ACCEPT. Otherwise, DISPLAY statement carriage control will be 1lost; all DISPLAY statements will execute as if they contained the WITH NO ADVANCING phrase. "This condition does use ACCEPT without the statements names 6.10.3 Format the use not occur and DISPLAY FROM/UPON refer (COBSINPUT to and when you statements clause: different the logical COBSOUTPUT). ACCEPT Statement 1 of the ACCEPT statement transfers object of a VAX/VMS logical name the FROM clause, the RTS uses otherwise, it wuses the logical name SPECIAL-NAMES paragraph the ACCEPT COBSCONSOLE: that statement. In is referred the small amounts implied by the to following by the PROCEDURE ACCEPT IS WHATS-HIS-NAME DIVISION. PARAMETER-AREA 6-28 INPUT-OUTPUT PROCESSING FROM WHATS-HIS-NAME. data from you do not COBSINPUT; key word in the mnemonic-name example, SPECIAL-NAMES. CONSOLE of to a data item. If the 1logical name the RTS 1in uses 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 COB$OUTPUT; 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 T that are 1. The Conventional 2. The Terminal the Conventional Although also available with VAX-11 produces (ANS) COBOL-74: the reference formats format. format. format produces ANS compatible programs, source printouts that are somewhat more cluttered it 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: 1. It requires less 2. It no 3. Its statements may be aligned with tab characters. requires storage line area. numbers. Further, whenever required, the REFORMAT utility program will Terminal format programs to the Conventional format. utility program is discussed in Chapter 8). (The convert REFORMAT The following suggestions should help to further simplify even the most complicated l. source programs. Begin division, section, and paragraph names in column 1. Although these names may start anywhere in Area A, aligning them in column 1 produces required, place the * becomes column 0.) 2. Insert the a blank purpose statement 5 (use following or the file) separate tab AREA or more before lines to of A a comment each Place character illustration a much more readable and - in column 1. one paragraph. on the line, of FILE-CONTROL the and begin over typical each Area of in the them the SELECT in column Consider the statement: 5 [4 ® ® | L J ® ® SELECT ( MASTER-FILE "DBl:" ORGANIZATION ACCESS IS IS RELATIVE SEQUENTIAL. Place the phrases of the file description statement on separate 1lines and begin each of them in column 5. (Use the tab to skip over Area A.) Consider the follow1ng illustration of a typical file description entry | , AREA l ® A ® AREA ® 5 FD ® B |] ® LABEL DATA the Indent, by [J ® |] RECORDS VALUE OF 1In both |J File and RECORD Working-Storage level 1tems in column 1. four columns, all ARE STANDARD ID IS MASTER-FILE-NAME IS MASTER-RECORD. sectlons, beg1n subordinate all items 01 with higher -valued level numbers. (For example, if the item that is subordinate to a 0l-level record descrlptlon 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 insert by GOOD PROGRAMMING PRACTICES 5; then additional inserted without having to items that are subordinate 7-2 <“ MASTER-FILE , - of A). SELECT (describing statement phrases ASSIGN TO 4. lines SELECT skip listing. When (Column 1 then AREA B l ® .“'. 3. ( change to later, group the level that group. if items, it becomes they may be numbers of all - ( If desired, 1l instead of write the level numbers as single digits 01l). (such as Working-Storage the 1in 77 of Use 1eve1 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, for except 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 the noiseword IS.' c. Align the PIC clauses on successive 11nes. character to 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 be on the further, affecting the other portions of the sentence; diagnostic messages will refer to the correct line and their meanings will be clearer. / TN the enhance any program 1in allgned statements Since leftstarting 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 contalns statement or more than one imperative statement, conditional immediately 1lines place all statements in the true path on «conditional statement and indent them to show the following their dependence upon that statement. 'illustration of an IF statement and IF COMPUTED-TAX > Consider the following 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 has an ELSE (or false) path, align the If the statement ©preceding IF and indent all statements that the under ELSE are dependent on the ELSE statement. GOOD PROGRAMMING PRACTICES 7-3 N Thus: IF condition true path true path statement statement ELSE Be false path statement false path sure to statement. place the period after the last statement only! Another good method for simplifying conditionals is to only a single imperative statement in the true or false If the path requires more statements, place them separate paragraph and either PERFORM the paragraph write path. in from a the path or GO to it. This technique avoids the possibility of inadvertently placing a period at the end of a statement within the path, thereby terminating it prematurely. When writing procedure Consider GO a GO TO name the TO ... on a DEPENDING separate readability of the statement, 1line and following place indent sample them each all. statement: P35 P40 P45 P60 P65 DEPENDING When grouping the P-SWITCH. statements into paragraphs organizational ideas: following Group ON together logical units of and processing sections, into a use section. Select a section name that reflects the type of processing being conducted within that section (such as TAX-COMPUTATION SECTION, etc.). = Follow 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 TC10, 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 the 1in an that paragraph, usually When simple arises reflect the type of processing lines instead. (Comment lines use convey more using temptation attempt to comment information, numbered more paragraph to give a paragraph a clearly.) names, assign increasing numeric characters to sequential paragraphs. If the numeric portion of the names increases by 5 or 10, new ones may be inserted later without disturbing the sequence of the names. 7-4 GOOD PROGRAMMING PRACTICES Vi PRINT-LINE-FORMATTER section name with sufficient comment 1lines to explain processing that is carried out by the statements within section. ' K SECTION, Do not use the PERFORM verb in the form, PERFORM a If the paragraphs a thru b must be performed, place section by themselves and PERFORM the section, thus the use of the THRU option. THRU b. them in a avoiding 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 modular blocks following a. additional entry to section "fall i ' ,fl_\‘\\ ) the through" these all from the use are of through a preceding the GO TO, a paragraph the names GO TO that are the first PERFORM, or section. Ensure that all GO TO statements refer to or into used, applied. sections/ by Division guidelines techniques may be of containing USE OF 1If statement names 7.2 coding. Restrict a b. of only internal to the section section statement. PUNCTUATION Avoid using the COBOL punctuation characters, comma and semicolon. They 1lend 1little to the readability of programs that have their statements néatly aligned, as discussed earlier in this chapter. Further, it is quite easy to misuse'these characters, which can cause serious errors for many compilers. (Other compilers either ignore incorrect punctuation characters or flag them with warning messages.) At best, even when used correctly and in the proper places, they have no effect on the meaning of the program. 7.3 USE OF THE ALTER STATEMENT Avoid using the ALTER statement to program. It is 1impossible to statement accompany except an by executing alterable GO it. change the flow test the setting Also, statement, it unless is of of control 1in a alterable GO an explicit difficult to tell comments whether or not it is referenced by ALTER statements or what the possible destinations might be. All of this makes debugging programs that contain these statements quite difficult. There are two other techniques that may be used in their place: 1. If control branches one of two ways write the switch as a following sample coding: (i.e., a binary conditional GOOD variable. PROGRAMMING switch), Consider PRACTICES the 7-5 o\\\ P-SWITCH PIC S9 COMP VALUE 0. 01 88 NO-PRINT VALUE 1. MOVE 1 TO P-SWITCH GO TO P40. IF NO-PRINT P40. MOVE 0 TO P-SWITCH. statements GO TO ... If control branches more than two ways, use MOVE to place integers into a data 1item, and a DEPENDING ... statement to test the data item and accordingly. Consider the following sample coding: branch P-SWITCH PIC S9999 COMP VALUE O. 01 MOVE 1 TO P-SWITCH MOVE 3 TO P-SWITCH. GO 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 l. are | rules: The endp01nt of a section and the with the of the 1last augmented endpoint paragraph in the same section are two distinct points. This means that it 1is possible to execute a PERFORM of the section, then while that PERFORM is still active, to execute a PERFORM of the last paragraph. On the start of a PERFORM, PERFORM 1is the RTS aborts the task and 7-6 if the end p01nt of the new end p01nt of an already active PERFORM, the GOOD PROGRAMMING PRACTICES issues an error message. 3. At the end procedure range. of any procedure, a being ended is the If so, check is made to see end of the most recent the most recent PERFORM range is 1if the PERFORM exited. 1f 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 not being exited in the reverse of the were entered. the perform ranges are order in which they | NOTE The RTS Chapter 7.5 error messages 10. are discussed 1in USE OF LEVEL-88 CONDITION-NAMES Condition-names provide a convenient method for testing a wvalue 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. B The following example illustrates the use of condition-names and shows the advantages inherent in their use. Suppose the records of a file each describe a student in 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 interrogation at wvarious 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, 1lst year, 2nd vyear, 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 processing for for all students special students, and still except enrolled undergraduates. different GOOD PROGRAMMING PRACTICES 7-7 Without the aid of condition-names, statements follows to resolve this problem: IF STUDENT-CATEGORY = "S" might be written as ... IF STUDENT-CATEGORY NOT LESS THAN "1" | IF STUDENT-CATEGORY NOT GREATER THAN "4" ... IF STUDENT-CATEGORY EQUAL TO "G" NEXT SENTENCE ELSE IF STUDENT-CATEGORY EQUAL TO “p" NEXT However, if various SENTENCE 1level 88 ELSE entries GO TO ... follow. the STUDENT-CATEGORY description, as shown below, condition-names can simplify this coding. 05 STUDENT-CATEGORY PIC X. 88 UNDERGRADUATE VALUE "1" THRU "4". 88 SPECIAL-STUDENT VALUE "S". 88 GRAD-STUDENT VALUE "G" "p". 88 "4". SENIOR VALUE VALUE "sS" 88 NON-DEGREE-STUDENT "p". - Now, the following procedural statements can solve the problem: IF SPECIAL-STUDENT ... IF 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. In addition, the statement, IF NOT UNDERGRADUATE’_...‘ can test the category of not being an undergraduate, which is equlvalent to any one 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 usage, 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. their to equal entries 88 level make - the It does not conditional-variables nor pads (with spaces) in This means that it neither truncates size. non-numeric literals. Further, it neither truncates ..nor pads (with zeros) numeric literals, but stores them as or, if converted to binary, in the minimum size COMP item that written 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 wvariables 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 Procedural operations on as the WRITE, MOVE, and ADD statements. 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 YTD-GROSS-PAY WEEKLY-GROSS SECTION. PIC 9(5)V99. PIC 999V99. 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 in the Working Storage Section of the Data Division as COBOL variables with a level number of 01. 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 FILE SECTION. FD MASTER-IN ~ 01 VALUE OF ID IS "MASTER.PAY". PAY-RECORD. 03 NAME PIC X(30). 03 EMPLOYEE-NO PIC 9(9). 03 YTD-GROSS-PAY PIC 9(5)V99. LABEL 7-10 RECORD GOOD PROGRAMMING PRACTICES IS STANDARD / The example 1in Figure 7-1 1is artificial because the data item representing the "year-to-date gross pay" 1is defined as a level 1 variable in 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 approprlately in Flgure 7-2. | . 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. 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 of - name 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 qualified 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 is 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 1items whose names follow. In the latter case, each item in the group must have the same level number, which must be greater than the level number of the group item. | 7.6.3 Guideline 2 (Reference Format) Data-name qualification is performed by following a data-name or condition-name by one or more phrases of a qualifier preceded by IN or OF. 1IN and OF are logically equivalent. The general format - of a qualified refierence to an elementary item or group of items named "name-0" is given in Figure 7-3. | name-0 OF name-l...0F Figure General Format of a 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-1l,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-1l. 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 unigque 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 wused as a qualifier for any of its condition-names. | 7-12 GOOD PROGRAMMING PRACTICES Enough qualification must be mentioned to make the however, it hierarchy as 7.6.4 may not the example be necessary in Figure to mention reference 7-2 demonstrates. unique; all 1levels of the | 3 (Unique Referability) Guideline 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 qualifiers for the (including complete) 7.6.5 item is uniquely referable if the complete set of data item are not identical to any set of qualifiers for another data item. partial 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 wunique 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 section-name Figure 7-4 - General 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 1is implicitly qualified by the appropriate section name. | - | If a paragraph name is unique within a COBOL program it is 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 utilization 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. by the However, due to If qualification is not employed in a program compiled VAX-11 COBOL-74 compiler, compilation speed is not affected. when qualification is used, the compilation rate slows down the additional system overhead. 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-11l COBOL-74 accepts source programs that were coded the conventional 80-column card reference terminal-oriented VAX-11l cobol terminal format. program reads source programs that were coded format or using either the shorter, The REFORMAT utility 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 @ e 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-1ll system. It eliminates the line-number and identification fields and allows horizontal tab characters and short lines. - The conventional format compatible throughout produces with the reference the industry. source format of REFORMAT lets you write source programs in if compatibility 1is ever required for provides a simple method for conversion to programs other o @ @ @ coding the conventional format: of terminal It generates a 6-character line number of 000010, places that It places any continuation or comment symbols (-,*, or /) into number in the increases it by character first six character positions of the 000010 for each subsequent line. line, position 7. It places the coding from the terminal format character positions 8-72, thereby c¢reating conventional format coding. It replaces any horizontal space 5, 13, ® to are the terminal format; then, any of those programs, it the conventional format. - REFORMAT follows the following steps to expand each line format that COBOL compilers a and 1line into 1line of tabs with the appropriate 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 character positions left between last character of coding and character position 73. the @ It places either identification characters (if they were supplied at program initialization) or spaces into character positions 73-80. e It right justifies (at continued ~literal position non-numeric will remain 72) 1literal, the same thefirst thus length as it was format. @ word that (at position 72) is split over two the first (/) in lines. ® It creates a line containing a slash ~space in the of a that the of any 7 and default | It right justifies COBOL 1line guaranteelng characters character that in it positions 8 through 72 part position for every form-feed encounters. REFORMAT Command String To run REFORMAT, enter the following command: MCR RFM This causes requests to be file the REFORMAT file begin processed. 1In response to specifications for your two RFM-INPUT FILE RFM-OUTPUT When to specifications the system following the REFORMAT two files its prompting immediately (input messages, files. o opened both flles, and output) type 1in the | SPEC: FILE SPEC: has successfully request execution. for for REFORMAT types the an identification entry in columns 73 through 80. If you desire an identification entry, type in from one to. eight characters. REFORMAT places these characters, left justified, in columns type a 73 through carriage 80 of each output line. If no entry 1is required, return. RFM-COLS 73 TO 80: Following this response, REFORMAT reads the input file and writes asf80-character records, in conventlonal reference format.- 'When 1t has processed the last record in the flle, the follow1ng output records messages; produced and the first the second indicating REFORMAT dlsplays the number requesting it another (nnnnn) input of file. ‘RFM-nnnnn LINES PROCESSED. RFM-INPUT FILE SPEC: If there is another file to be reformatted,»follow the with the terminate 8-2 specifications execution. REFORMAT UTILITY for | PROGRAM the next file. | If not, same type sequence CTRL/Z to REFORMAT Error Messages If any of the responses to the prompting messages errors, REFORMAT problem. | the displays | detectable contain messages following indicating the . RFM-ERROR IN OPENING INPUT FILE RFM-TRY AGAIN RFM-INPUT FILE SPEC: The system could not open the input file. Either the file 1is not present on the device specified (the default device is SYSSDISK) or 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 f» N, 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.) The usual I/0 error messages precede this message. To a 1in and type specification file examine the output continue, corrected version. To terminate execution, type CTRL/Z. RFM-INPUT FILE RFM-INPUT FILE IS EMPTY SPEC: The system successfully opened the input file, statement encountered the AT END condition. but the first )T~ To continue, type in a new input file specification for another To terminate execution, RFM—ERROR RFM-INPUT type CTRL/Z. IN READING SPEC: READ file. INPUT 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 rlght—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. than to the read To process another file, type in a new input first record), REFORMAT a record. It terminates sPeéification and REFORMAT was unsuccessful in an attempt to write an output record. It continue with the prompting message sequence. type CTRL/Z. RFM-ERROR IN WRITING OUTPUT RFM-REFORMATTING ABORTED RFM-nnnnn LINES RFM-INPUT FILE terminates execution and file To terminate execution, FILE | PROCESSED SPEC: closes both files. To process another file, type in a new input file specification and continue with the prompting message sequence. To terminate execution, type CTRL/Z. = /_/' /..\\\ l 8=4 REFORMAT UTILITY PROGRAM CHAPTER N 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 TN program. 9.1 DEBUG CONCEPTS DEBUG 1s LINK command. a module that (See you can Chapter include 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-11l Symbolic Debugger is called symbolic because it allows you to refer to data items by the symbols vyou 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 references, the compiler must object module. Although this adds no address store space the symbols requirement 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, To summarize, use and and 1link time. prompts you not but you specify /DEBUG cannot refer at to compile data for a command with the prompt: that cause the the is them when you compile a time, you can still items the /DEBUG command qualifier at Then, when you execute the image, file; you must in to symbolically. both compile DEBUG takes DBG>. time control 9.2 PREPARING TO DEBUG A PROGRAM The following sections describe the commands that establish environment for debugging COBOL programs. The commands are: SET LANGUAGE the COBOL SET MODULE SHOW MODULE CANCEL SET SCOPE SHOW -~ SCOPE CANCEL 9.2.1 MODULE SCOPE SET LANGUAGE COBOL Command This command tells DEBUG that the debugging dialog applies to a program. It allows format of the command SET LANGUAGE symbols that contain hyphens, for example. COBOL The is: COBOL You may want to debug an image that contains modules written in more than one 1language; the SET LANGUAGE command allows you to change language conventions during the debugging session. DEBUG's default 9.2.2 is the language of the main program. MODULE Commands: SET, SHOW, 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 is hold in all of them at once. the active symbol You cannot refer to a symbol unless it table. | Use the MODULE commands to control symbol table modules. SET MODULE | | The when the commands image you the contents want (program) into format of the the active DEBUGGING COBOL PROGRAMS the specified symbol table. SET MODULE SET MODULE module-name 9-2 DEBUG's active are: Places the symbols defined in The of to debug contains multiple command is: [,module-name] ... modul | SHOW MODULE Displays the currently in names the of the modules whose active symbol table. symbols are The format of the SHOW MODULE command is: SHOW DEBUG CANCEL MODULE MODULE responds by displaying the names of the modules linked with it; symbols are in the space they occupy. it also indicates which modules' active symbol table and how much Removes symbols a module's from table. The format of CANCEL MODULE MODULE module-name active command is: [,module-name] symbol ... 1 7 s o i TM CANCEL the the 9.2.3 SCOPE Commands: SET, SHOW, and 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 deflned, or you can omit the module name. If you omit the name, DEBUG uses a default; if it can't find the symbol in the default scope, it attempts to find an unambiguous symbol in the remaining modules. If DEBUG cannot resolve the reference, it displays a message. Until you use name of The SCOPE SET SCOPE the a SET SCOPE first module commands command, with it was as the default scope the linked. are: Specifies The the format default of the SET SCOPE SHOW SCOPE DEBUG uses wh1ch Displays the module. SET SCOPE command is: module-name current default module name. The format of the SHOW SCOPE command is: SHOW CANCEL SCOPE - Cancels use SCOPE - the another current SET default module name. SCOPE command, DEBUG uses the first modul with which e default. it was Until vyou the name of 1linked as the DEBUGGING COBOL PROGRAMS 9-3 The formatAof the CANCEL SCOPE command is: CANCEL SCOPE 9.3 SPECIFYING LOCATIONS locations allow Several DEBUG commands use locations as parameters; you to tell DEBUG what data you want to look at or where you want , control transferred, for example. 9.3.1 For Location Types COBOL programs, specifications: Data-name | can Yyou use three refers to a data item in the - types | Data 1location of Division. type of location is often called a symbol. This For example: EXAMINE INPCHAR tells DEBUG that you want to see the contents of the You cannot quallfy data—names in DEBUG commands ‘the data item whose data-name is INPCHAR. . If you refer to a data-name in COBOL. way you can once in the module, DEBUG than more defined is that applles 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 1in the calling program. specifies the beginning of Line a source The format of a line 1ocatlon is: N $LINE program line. B n The value of n corresponds to a compiler- a551gned line number on the program's source listing. Absolute specifies a numeric memory address. absolute location as an integer. Specify an - For example: EXAMINE 1200 tells DEBUG to display the contents of located at address 1200 9-4 DEBUGGING COBOL PROGRAMS the longword 9.3.2 Resolving Location Ambiguities Your program can consist of more main program called a than one module, 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 defaults to resolve you may want than the example, to the your SLINE Because scope TESTB, duplicates exist, Furthermore, if more 1line numbers could references. scope in an 1In program might not resolve depending a then than also some a one be cases, location to consist of to a main transfer program, TESTA, control to refer to line and 36 in | specify the on a module ambiguity whether -- name, the vyou DEBUG default had could previously uses the be either used a command. default TESTA SET or SCOPE | You can override the default and resolve specifying GQ if than one 36 you did to if would from more default module. a subprogram, TESTB. If you wanted TESTB, you might use the command: GO it symbols ambiguous specify as the the $LINE Similarly, scope as part of the the location: ambiguity vyourself by TESTB\36 you can specify the scope in symbolic data-name locations: EXAMINE TESTB\ACCNT~-NUM 9.4 CONTROLLING PROGRAM EXECUTION This section describes DEBUG monitor, and program commands are: SET SHOW resume commands BREAK BREAK | at EXIT GO | The CALLS CTRL/Y SET, SHOW, and CANCEL The BREAK commands control the location of A breakpoint 1is a location where you execution and return control to you; at a data suspend, STEP BREAK Commands: change to points. SHOW SET CANCEL TRACE or you specific SET WATCH CANCEL WATCH TRACE allow SHOW WATCH CANCEL4BREAK, SHOW TRACE 9.4.1 that execution values, or you can change breakpoints in the program. want a program to suspend breakpoint, you can examine the program's execution DEBUGGING COBOL PROGRAMS path. 9-5 The BREAK commands SET BREAK are: Spec1f1es a locatlon at which to suspend execution. The format of the SET BREAK command SET BREAK location [DO is: (DEBUG commands)] it 1is If the program reaches the specified location, the instruction located executing before suspended commands perform You can request that DEBUG there. using . .the DO by reached is breakpoint when the option. For example: SET BREAK SLINE 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 program. The breakpoints set currently A : , format of the SHOW BREAK command in .the | is: SHOW BREAK CANCEL BREAK ‘Removes specified breakpoints.: The format of the CANCEL BREAK command is: CANCEL BREAK/ALL or ... TRACE Commands: SET, SHOW, and CANCEL \\ '9.4.2 CANCEL BREAK location [,location] allow you to monitor the sequentlal R The TRACE commands control the location of tracepoints in the program. a breakpoint, except that program execution resembles A tracepoint current. 1ocat10n.=A Tracep01nts the displays DEBUG continues after flow of a program._ ., that, is, if you set Tracep01nts and breakpoints supersede each other; at the same location as a breakp01nt, the breakpoint is tracepoint T cancelled. The TRACE SET TRACE commands | ‘ are: Specifies a location at which to suspend display location information, and continue. The format of the SET TRACE command SET TRACE location 9-6 DEBUGGING COBOL PROGRAMS execution, is: ~ a SHOW TRACE Displays the program locations at | currently The format of the SHOW TRACE command SHOW set. which are | tracepoints ‘ is: TRACE order DEBUG displays traéepoints in newest-to-oldest -- newest CANCEL TRACE is the last traCepoint set. | Removes specified tracep01nts. The format of the CANCEL TRACE command is: CANCEL TRACE/ALL or [,location] CANCEL TRACE location ... ) 9.4.3 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 Watchpoints are useful when you need to know if a data inadvertently changed. item The WATCH commands are: SET WATCH Specifies locations to be monitored. The format of the SET WATCH command is: | The SET WATCH identifier identifier specifies the location to Dbe monitored. NOTE the When a watchpoint is set, DEBUG protects When access. write from page memory entire (your 1level mode wuser at instruction an to change the contents of attempts program) any location on the protected page, DEBUG evaluates the access for watchpoint action; however, if a system service tries to write it returns an error. page, protected a to Therefore, if watchpoints are set on the same File Section record description, a as page input 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 the newest-to-oldest watchpoint set. current order - watchpoints newest 1s CANCEL WATCH command is: the in 1ast Removes specified‘watchpoints{ CANCEL WATCH The format of the CANCEL WATCH/ALL or CANCEL WATCH 9.4.4 GO The and GO GO and identifier STEP Commands STEP commands initiate Resumes program location or and continue execution, another location. program either execution. at the current The format of the GO command is: GO If [location] you omit the location, location. execution starts at the current If you specify an location, DEBUG to the new location. transfers control | 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 1if the current 1location 1is other than the beginning of a line. 1If the current location is not a line boundary -a common occurrence when watchpoints are reached -— use the STEP command to reach the next 1line boundary before attempting a GO %$line 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 The of current format of the STEP command STEP for a steps to is: [n] The value of n execute. location steps. 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, your program runs slower because of DEBUG overhead. reduce this overhead by using the SET BREAK can You and GO commands (instead of STEP) execute more than a few steps. 9.4.5 CTRL/Y Command (Interrupting the when you - want to 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 vyour 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 when the CTRL/Y command interrupted execution. EXIT Command 9.4.6 The EXIT command terminates the debugging session. The format of the EXIT command EXIT is: | DEBUG terminates the program and returns control to the VAX/VMS system \command 9.4.7 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 information are similar to the traceback display, which is described in Chapter 10. DEBUGGING COBOL PROGRAMS \ 9-9 The format of the SHOW CALLS SHOW CALLS command is: [n] If you do not spécify'n, DEBUG displays all call levels; determines 9.5 the number of levels that DEBUG otherwise, n reports. 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 during a change values to correct errors or to test a hypothesis debugging session. The commands are: EXAMINE DEPOSIT 9.5.1 EXAMINE Command The EXAMINE command displays The format of EXAMINE You will the contents command of a specified location. is: [location] usually specify the for example). address (such as location as a However, you can display EXAMINE 1000). data-name the contents a specified (EXAMINE of an SUBI, absolute DEPOSIT Command The DEPOSIT The format command of DEPOSIT the changes DEPOSIT the contents command of //2:\\\ 9.5.2 EXAMINE the location. is: location=value Examples: DEPOSIT ITEMA=12 Places the numeric data—-name ITEMA. DEPOSIT WORDX="NOW IS value THE 12 into the data item 9-10 item named by the data-name WORDX. DEBUGGING COBOL PROGRAMS by into the TIME" Places the characters in the alphanumeric literal data named DEPOSIT TOP="662K" Places the value -6622 into the DISPLAY data item, TOP. four-digit signed numeric NOTE The DEPOSIT command functions 1in the same way as the COBOL ACCEPT statement for DISPLAY data items. Therefore, vyou 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 string’from the terminal and it its to TESTB. TESTB reverses length) to TESTA. the character string and returns passes it (and The following'debugging session does not demonstrate the location actual program errors; it 1s designed to show the use of of DEBUG features. Responses from DEBUG and VMS appear in red. l) 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 us that the default language is COBOL and that the default scope and module are TESTA. DEBUG returns control by dlsplaylng its prompt, ¢ RUN DBG>. TESTA VAX/VMS DEBUG V1.5 04 January 1979 '$DEBUG-I-INITIAL, language is COBOL, 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 DBG>SHOW MODULE see table only one module, The last module is was 1linked from C74LIB.OLB. module we symbol | | | 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 breakpoint at line 26 of cannot find 1line 26, symbols are not 1in the table. $LINE TESTB\26 $DEBUG-W-NOLINE, routine 'TESTB' has no %line 4) We add, TESTB's MODULE DBG>SET MODULE 26 symbols with the SET command. TESTB 5) Then, we confirm that the been added. size DBG>SHOW MODULE module name symbols language TESTA TESTB yes yes COBOL COBOL 164 316 'CBFLSW no BLISS 128 ' symbols have | total modules: 3. remaining 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. BACKWARD break at TESTB\TESTB %line 26 9) We set two breakpoints. TESTB is reached, commands in display two execution. DBG>SET BREAK %LINE When line DEBUG will parentheses; data items, | 40 of execute the it will then resume , 40 DO(EX HOLD-WORD;EX SUB-1;GO) DBG>SET BREAK %LINE 34 10) DBG> SHOW We display the .active breakpoints. BREAK breakpoint at TESTB\TESTB %line 34 breakpoint at TESTB\TESTB %line 26 breakpoint at TESTB\TESTB %line 40 DO SN 11) We set a TESTA is (EX HOLD-WORD;EX SUB-1;GO) tracepoint at line the default scope. | 22 of TESTA. | E DBG>SET TRACE $LIN22 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) DBG> GO start at TESTB\TESTB %line We resume execution. Whenever line 40 in TESTB is 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. 26 break at TESTB\TESTB %line 40 TESTB\TESTB\HOLD-WORD(1:20): D 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 40 break at TESTB\TESTB %$line 40 TESTB\TESTB\HOLD-WORD (1:20) : TESTB\TESTB\SUB-1(1:2): 5 DRA DRAW start at TESTB\TESTB %line 40 break at TESTB\TESTB %1line 40 DRAWK‘ TESTB\TESTB\HOLD-WORD (1:20) : TESTB\TESTB\SUB-1(1:2): 4 start at TESTB\TESTB %line 40 break at TESTB\TESTB %line 40 DRAWKC TESTB\TESTB\HOLD—WORD(I:20): TESTB\TESTB\SUB-1(1:2): 3 start at TESTB\TESTB %$line 40 break at TESTB\TESTB %1line 40 DRAWKCA 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 DRAWKCAB 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) 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 value (1:2) | DBG>EXAMINE SUB-1 TESTB\TESTB\SUB-1(1:2): 1is DEBUG displaying contained in bytes of the data item. Here, SUB-1, 1 the through we deposit another wvalue using a quoted string. deposits 2 a COBOL of bytes. the value ACCEPT in the same manner statement: - 1into DEBUG as a as stream ’ " 17) 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>EXAMINE SUB-1 TESTB\TESTB\SUB-1(1:2): 9-14 it 10 16) DBGY>DEPOSIT SUB-1=" that DEBUGGING COBOL 32 PROGRAMS 18) We depoSit a value into data item SUB-2, whose usage 1is COMP-3. The string is needed because usage is than COMP. DBG>DEPOSIT SUB-2="-42" 19) DBG>EXAMINE We then examine SUB-2, value is now -42. SUB-2 TESTB\TESTB\SUB-2(1:2): | - and see that 1its | -0000000000000000000000000000042 20) We look at 99V99. DEBUG CHARCT, whose displays picture 1is the contents 0800; it is not aware of the decimal point. DEBUG treats all data items as alphanumeric. DBG>EXAMINE quoted other as implied DISPLAY CHARCT TESTB\TESTB\CHARCT (1:4): 0800 21) We deposit four characters into CHARCT. 22) CHARCT now has DBG>DEPOSIT CHARCT="1500" DBG>EXAMINE "1500" (15.00). another value, omitting 1500 23) Here, the we deposit quotes. CHARCT=42 24) DBG>EXAMINE wvalue CHARCT TESTB\TESTB\CHARCT(1:4): DBG>DEPOSIT the We examine CHARCT and see contains an asterisk (decimal followed by three spaces. that it value 42) CHARCT TESTB\TESTB\CHARCT (1:4): * 25) We deposit the quoted wvalue "15" into DEBUGGING COBOL PROGRAMS 9-15 CHARCT. CHARCT="15" / . DBG>DEPOSIT 26) DBG> EXAMINE CHARCT TESTB\TESTB\CHARCT(1§4): Since a quoted string is deposited without conversion, we see that CHARCT now contains "15 ". If we left this value in CHARCT (invalid for a numeric data item), an error would occur later in the run. - 15 27) So, we deposit 28) We resume displays a valid value. DBG> DEPOSIT CHARCT="0800" image execution. The program TESTA the reversed word. When the reaches line detects that an the contents of set 'a 22 in TESTA, instruction DISP-COUNT. watchpoint DEBUG has changed Since we on DISP-COUNT, DEBUG displays the old and new values, then returns control to wus. Note that we don't know the current location in terms of 1line number; the displayed location is in the RTS. | | | DBG> GO start trace at at TESTB\TESTB TESTA\TESTA DRAWKCAB write to %line %line : 34 22 | - TESTA\TESTA\DISP-COUNT(1:2) old value = new value = at | PC CVT_P ANY+67 | 08 29) To see the image's current location, try the SHOW displays the still don't CALLS command. we DEBUG active call frames, but know the line number in we our program. DBG> SHOW CALLS module name routine name line relative 0000004F 00001414 22 0000007C 00004748 CVT P_ANY TESTA 30) C We o DISP-COUNT. DBG>STEP %line 28 r 9-16 absolute PC 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 o start at CVT_P ANY+79 stepped to TESTA\TESTA PC DEBUGGING COBOL PROGRAMS Y 31) We resume execution. TESTA executes its final DISPLAY. DEBUG regains control when 08 STOP RUN is executed. | DBG>GO start the at TESTATESTA CHARACTERS %line 28 | $DEBUG-I-EXITSTATUS, 1is '%SYSTEM-S—NORMAL, normal successful completion' 32) the At this point, we can continue session, by examining the contents of data items, for example; or, we can terminate the image with the EXIT command. DBG>EXIT ) $ | Program Listings: 00001 00002 PROGRAM-ID. IDENTIFICATION DIVISION. TESTA. 00003 00004 00005 DATE-WRITTEN. JANUARY DATE-COMPILED. | 15-Jan-1979 . 1979. | 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. vax-11. OBJECT-COMPUTER. VAX-11. DATA DIVISION. WORKING-STORAGE SECTION. 01 LET-CNT PIC 9(2)V9(2). 01 IN-WORD PIC X(20). 01 DISP-COUNT PIC 9(2). PROCEDURE DIVISION. GETIT SECTION. BEGINIT. DISPLAY "ENTER WORD". MOVE SPACES TO IN-WORD. ACCEPT IN-WORD. 00021 00022 00023 CALL "TESTB" USING PERFORM DISPLAYIT. STOP RUN. 00024 00025 00026 00028 LET-CNT. DISPLAYIT SECTION. SHOW-IT. DISPLAY IN-WORD. 00027 00027 IN-WORD MOVE 0372 POSSIBLE LET-CNT TO DISP-COUNT. LOW ORDER RECEIVING DISPLAY DISP-COUNT " FIELD TRUNCATION. CHARACTERS". DEBUGGING COBOL PROGRAMS 9-17 00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 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 IDENTIFICATION DIVISION. DATE-WRITTEN. JANUARY PROGRAM-ID. TESTB. 1979. DATE-COMPILED. 15-Jan-1979 ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. OBJECT-COMPUTER. DATA DIVISION. WORKING-STORAGE 01 01 01 SUB-1 PIC SUB-2 PIC HOLD-WORD. SECTION. 9(2) COMP. S9(2) COMP-3. | HOLD-CHAR PIC 03 LINKAGE 01 VAX-11. VAX-11. X OCCURS 20 TIMES. SECTION. TEMP-WORD. TEMP-CHAR PIC X OCCURS 20 TIMES. 03 01 CHARCT PIC 99V99. PROCEDURE DIVISION USING TEMP-WORD, CHARCT. CONVERT-IT SECTION. STARTUP. I1F TEMP—WORD = SPACES (0 TO CHARCT MOVE GO TO PERFORM 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. EXIT PROGRAM. MOVE-I T. MOVE TEMP-CHAR (SUB-1) TO HOLD-CHAR (SUB-2). SUBTRACT 1 FROM SUBl 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-1ll errors and Appendix run-time messages. D error . . 10.1 If COMPILE-TIME ERROR MESSAGES the VAX-11 COBOL-74 compiler detects an error, diagnostic message either before or after the line. Diagnostic messages look like this: X LINE ERR X-——====-— TEXT ——error message error message it erroneous will prlnt source a program : =—===—————————m X number source program line number severity level - 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 ‘OBJECT-COMPUTER. 00006 DATA DIVISION. .00007 - WORKING-STORAGE VAX-11. SECTION. 00008 00009 00010 00011 00012 01 TABLE-VALUES. 05 TAB-VAL OCCURS 9 TIMES PIC 01 SAVE-VAL PIC X. PROCEDURE DIVISION. . MAIN SECTION. 00013 PARA 00014 0622 | TERMINATOR MISSING AFTER PROCEDURE NAME. 00014 000%5 IF 00015 0714 OOOlG 0616 -~ SAVE-VAL = SPACE ADD 1 TO SAVE-VAL. MISSING OR INVALID OPERAND FOR ARITHMETIC VERB PROCESSING RESTARTS AFTER TERMINATOR. 00016 00017 MOVE TAB-VAL (9) TO SAVE-VAL. STOP RUN. 00018 EXIT. w 00018 0103 10.1.1 X. .EXIT. WAS NOT THE ONLY VERB IN PARAGRAPH. Severity Levels 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 program in Section 10.1: the following messages, | taken from the SAMPLE I 00014 0622 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 1in a manner consistent with your intentions, it issues an informational message only. - NOTE You can use the /NOWARNINGS suppress 10-2 informational ERROR MESSAGES command error messages. line 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. 1In 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. The compiler cannot recover reflects your intentions. IGNORED. from fatal errors On line 15 in of program a manner SAMPLE, that SAVE-VAL is defined as alphanumeric; therefore, it cannot be used 1in an arithmetic statement. The compiler cannot take corrective action, so it issues a fatal error and does not create an object file. However, it analyzes all remaining source program lines and reports errors. | | R NOTE You cannot warning or 10.1.2 use a command 1line qualifier to suppress fatal messages -- they are always printed. Error Message Printing The compiler displays the diagnostic error message after the erroneous this rule: 1. line. There are either processed the entire DATA DIVISION text. Diagnostic messages can appear after the PROCEDURE DIVISION. cannot issue until it 1last 1line of the flow and the These are messages that the compiler has processed the entire PROCEDURE DIVISION. 10.1.3 before or two exceptions to Diagnostic messages can appear after the last entry 1in the DATA DIVISION before the PROCEDURE DIVISION header. These messages reflect errors the compiler cannot report until it has 2. source program | Internal Compiler Errors -- System Errors The compiler performs consistency contents of data fields. | checks on program 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 compller then terminates. The format of the I/0 system error message is: C74--<error message> C74--I0 The number (VAX/AME) 10.2 ERROR -NN (-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 L | is a VAX/VMS | For | example, facility, or %C74 represents component COBOL-74. is a severity level indicator; | the | - following values: Level Meaning S sSuccess I W Information Warning E Error F Fatal, or an abbreviation of severe CODE is TEXT is a descriptive message. name. | it has one of error the message text. 'If VAX/VMS displays more than one message for an error, the addltlonal message 10-4 takes the form ERROR MESSAGES "-FACILITY-L-CODE, TEXT". 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 Messages 10.2.1 first be 1linked. they nonexecutable; The object modules produced by the compiler are must Two kinds of link-time error messages occur: (1) warning error messages, imbedded in the object module by the (2) errors detected by system and (see Section 10.1.1), compiler | 4 invoked by the linker. facilities the /,,.,-\ . If the compiler flags an object file as having ~warnings, SLINK-I-WRNERS, MODULE <{name> has compllatlon $LINK-W-DIAGSISUED, Completed but with dianostics - | detects the flag and issues the following diagnostics: 1linker warnings | I1f a system facility error occurs (for example, if an error occurs when the linker invokes the RMS facility), it is put on a message- stack and the linker displays it. you typed the command line: LINK Consider the following example. ST - If XXXX and no object file existed with the name XXXX, the following messages would appear at your terminal: $ LINK 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 sLINK-E-FATALERROR, Fatal error message issued "$RMS-F-FNF, file not found" is generated by the VAX-11l RMS result of system 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 | faulty occur - at Faulty Program Loglc 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 00005 00006 DATA DIVISION. PROCEDURE DIVISION. ROUTINE-A. | 00007 00008 00009 PERFORM ROUTINE-B. PERFORM ROUTINE-C. 00010 00011 ROUTINE-C. PERFORM ROUTINE-A. ROUTINE-B. it will compile without any detectable errors. it, the following will appear on your terminal: However, if YOU run S RUN PERF 3C74-F-RECPERDET, | | recursive PERFORM detected 3TRACE-F-TRACEBACK, symbolic dump follows module name PERF routine | PREF = PERF PERF The | line relative PC absolute PC PERF 7 PERF 0000002C 11 0000005C PERF 0000C6AS8 9 00000044 0000C62F PERF 7 0000002C 0000C678 0000C678 RTS displays "C74-F-RECPERDET, recursive PERFORM detected" to show program PERF contains a statement (PERFORM ROUTINE-B) that, if executed, will cause a PERFORM statement to try and perform itself. - that If a fatal /TRACEBACK ~symbolic dump a occurs, and (linker the program default), of all call frames that A call frame represents one occurred. or error qualifier PERFORM statement. For - the each call was linked with will produce when the TRACEBACK were active execution frame, of a the subroutine CALL displays: (1) TRACEBACK module name (program-id), (2) the routine name (program-id), ‘the source program line number where the error occurred, and program-counter information. S - The initial line of the preceding TRACEBACK dump shows ~detected a fatal error . created that will cause>the - executed the twice symbolic - executed, dump starting If program PERF subprogram-, 00005 10-6 without show with on line 7 of program PERFORM on source an intervening the the sequence most were modified | | as program EXIT. The in which A that line has 7 statement. follows, it become a RTS been to be lines of PERFORMS executed would , the loop remaining the (3) (4) | recently PROCEDURE DIVISION USING. ERROR MESSAGES PERF. a error were callable n call PERF: A program could then be writteto IDENTIFICAION DIVISION. 00001 00002 00003 00004 00005 00006 00007 DRIVER. PROGRAM-ID. ENVIRONMENT DIVISION. DATA DIVISION. PROCEDURE DIVISION. PARA. CALL | "PERF". If you rfinADRIVER, the following would appear at your terminal: S RUN DRIVER i "\;\ $C74-F-RECPERDET, recursive PERFORM detected $TRACE-F-TRACEBACK, symbolic dump follows module name routine line relative PC PERF PREF PERF PERF PERF PERF PERF PERF 7 11 9 7 0000002C 0000005C 00000044 0000002C DRIVER DRIVER PC absolute =~ 0000C678 0000C6A8 0000C62F 0000C678 0000C62F 0000002F 7 shows the calling The symbolic dump now contains a fifth line, which PERFORM stack. program DRIVER as the initial entry on the nested 10.2.2.2 occurs: during File I/O Error Procedures- If an error 1. . | , following procedure is used: the operations 1I/0 If the file status key for the file is present, the RTS sets the it to VAX-11 values. the «code for the error condition. COBOL-74 Reference Manual 1lists Appendix Cof file status Kkey | If an INVALID KEY imperative condition is specified for the I/0 operation, the RTS performs the associated imperative statement. The RTS performs no other processing in the file The USE procedure 1is not the current statement. for performed. | ‘ , If no INVALID KEY imperative condition is specified for the is declared for the file, I/0 operation and a USE procedure the RTS performs the USE procedure and returns control tc 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 returns 5. 1is present, control If no AT END, to the the RTS performs the USE procedure and program. | and no INVALID KEY, no | | USE procedure is declared for the file, an error condition exists; the program terminates with a C74 error status. Both C74 and RMS messages will be displayed as a result. | The following example shows a program that procedure and ( for a file that is opened 00001 IDENTIFICATION 00002 00003 00004 PROGRAM-ID. TESTIO. ENVIRONMENT DIVISION. CONFIGURATION SECTION. 00006 OBJECT-COMPUTER. VAX-11. 00008 FILE-CONTROL. 00010 00011 00012 DATA DIVISION. FILE SECTION. FD NOFILE 00005 does not contain for INPUT: a USE DIVISION. SOURCE-COMPUTER. VAX-11. 00007 INPUT-OUTPUT SECTION. 00009 (/ h ” | - SELECT NOFILE ASSIGN TO "NOFILE.DAT". - 00013 00014 00015 LABEL RECORDS ARE STANDARD. 01l FILE-REC PIC X. PROCEDURE DIVISION. PARA. OPEN INPUT NOFILE. 00016 00017 - If you execute the prbgram and RMS does not find the file (NOFILE.DAT) in the default directory on the default device, will appear at your the following messages terminal: $C74-F-OPNERRFIL, OPEN error on file: (NOFILE.DAT) o - $RMS-E-FNF, file not found $TRACE-F-TRACEBACK, symbolic stack dump follows module name TESTIO routine name TESTIO line relative PC absolute PC 17 00000030 0000C630 < . R 10-8 ERROR MESSAGES The following procedure for 00001 00002 00003 00004 - a example shows a program that file that is opened for INPUT: IDENTIFICATION TEST2IO. ENVIRONMENT DIVISION. a SOURCE-COMPUTER. OBJECT-COMPUTER. DATA DIVISION. 00011 00012 00013 FILE SECTION. FD NOFILE 00014 00015 00016 01 LABEL RECORDS FILE-REC VAX-11. VAX-11. SECTION. FILE-CONTROL. SELECT NOFILE ASSIGN TO PROCEDURE "NOFILE.DAT". | ARE STANDARD. PIC X. DIVISION. DECLARATIVES. 00017 00018 00019 00020 00021 00022 00023 00024 USE-SECTION -~ USE SECTION. AFTER | STANDARD USE-IT. » PROCEDURE ON INPUT. , DISPLAY STOP END ERROR "INVALID FILE OPEN". RUN. DECLARATIVES. PARA. OPEN INPUT NOFILE. If you execute this program and the file "NOFILE.DAT" does not the USE USE SECTION. 00005 00006 00007 00008 00009 00010 INPUT-OUTPUT contain DIVISION. PROGRAM-ID. CONFIGURATION does procedure will display the following message: exist, | "INVALID FILE OPEN". Thus, if you use a USE procedure, the VAX/VMS error facility will display error See Appendix messages. E for a full | not list of RTS error messages. ERROR MESSAGES 10-9 CHAPTER 11 SORTING IN A COBOL PROGRAM VAX-1ll 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-1]1] SORT 1is described in detail in the VAX-1l1l SORT : ' User's Guide. This chapter introduces the describes how to use 1l1.1 VAX-11l SORT them to SUBROUTINE VAX-11 callable subroutines in COBOL programs. and PACKAGE The SORT subroutines are part of the they conform to native-mode VAX-1l1l SORT sort records standard the VAX/VMS calling program can call them. VAX/VMS standards. 1In COBOL, 1library, and Therefore, any you communicate with the subroutines through the CALL statement. The subroutines, because they are in the VMS library, are linked automatically with modules that call them. VAX-11 SORT provides six subroutines to perform sorting SORSPASS FILES ~opens _ file. are SORS$INIT SORT | ~ an input file and functions: <creates an output This routine is used only when files sorted. initializes the SORT files, wusing work areas and the arguments you pass CALL statement. SORSINIT SORT once A program at the beginning work in the = calls of each ; i 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—metge operation. SORSRETURN_REC returns a sorting. once for record to A program each record vyour - calls to be program this after subroutine returned from sort. SORSEND SORT | 11.2 the | performs housekeeping functions at the end of a sort, such as <closing files and releasing memory. A program calls SORSEND SORT once at the end of each sort. I/0 INTERFACE METHODS The VAX-11l SORT subroutine package allows you to specify sorts in terms of an entire file or one record at a time; these techniques are called I/0 interface methods. This section briefly describes the two I/0 interface methods. o li;é.lj‘Fiié I/O Interface. Using this method, you request VAX-1l1l SORT to sort all records file to create a re-ordered output file. This technique to the SORT...USING...GIVING syntax of the ANSI-74 COBOL > The 6 [] [ W N Call~each of'the following subroutines»oncé in the order shown: . for 11.2.2 a / SOR$PASS FILES SOR$INIT SORT SOR$SORT_MERGE SORSEND SORT programming method 1in is comparable SORT Module. the example second Record I/0 in Section sort 11.6 operation. uses , the file | 1I/0 interface | 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 program. This technique is functionally identical to the ANSI-74 COBOL SORT with input and output procedures. Call each of the following routines in the order shown: 1. SORSINIT SORT 2. 3. SOR$SRELEASE REC SOR$SORT MERGE 5. SORSEND SORT 4. 11-2 SORSRETURN REC SORTING IN A COBOL PROGRAM Call SORS$RELEASE REC and SORSRETURN_REC once for the other subroutines only once in each sort. each The programming example in Section 11.6 uses the record I/0 method for the first sort operation. 11.3 call record; interface KEY DATA AND RECORD AREAS the to that you pass record the interface, I/0 For the record (key data). keys sort subroutine consists of the SOR$RELEASE_REC The key data must followed by the record to be sorted (record area). contain all the key fields specified in the key buffer, which is furthermore, you should specify the described in the next section; ~key fields in the same sequence and in the same way (for example, the TN same size and data type) leave space between the that they appear in the key buffer. Do not key fields. The record area immediately follows the key data. It defines the that VAX-1l1l Sort returns -- the subroutine SOR$RETURN REC does record not return the key data. ' You can specify from one to ten keys for each sort. If you need more 1in a single sort, you may be able to combine some key keys ten than the 1if example, For fields to reduce the number of specifications. 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 SORT-KEYS. 05 05 05 SORT-KEY-1 SORT-KEY-2 SORT-KEY-3 PIC X(10). PIC X (5). PIC X(20). 05 LAST-KEY PIC 05 03 Comblned 01 SORT-KEY-4. PIC S9(5) COMP-3. S9(6). SORT-DATA. keysSORT-RECORD. 03 SORT-KEYS. 05 03 COMBINED-KEY-1. | | 05 PIC X(10). SORT-KEY-1 07 07 SORT-KEY-2 PIC X(5). SORT-KEY-3 PIC X(20). 07 SORT-KEY-4 PIC S9(5) COMP-3. 05 LAST-KEY SORT-DATA. PIC S9(6). | SORTING IN A COBOL PROGRAM 11-3 The total size of the key area cannot exceed 255 character positions. However, it 1is 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 ACCOUNT-NUM PIC 9(11). ACCOUNT-KEY PIC S9(11) 03 03 COSsT COST-KEY PIC PIC 9(7)V99. 9(7)V99 COMP. 03 COMP-3. - Requires 11 characters. Requires 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 use the record I/0 interface, can define such keys in the key area with one of the allowable types. In the following examples, the data descriptions on the are not defined by a valid key type for subroutines. The data descriptions on key area for those data items: Description in'record area S9(5) SIGN PIC S9(17) PIC l1.4 ‘The TRAILING COMP key left the record I/O interface the right can be used in the | Description in key data PIC S9(5) SIGN LEADING SEPARATE PIC you PIC S9(5) COMP SEPARATE | S9(5) PIC PIC S9(5) PIC S9(5) COMP-3 S9(17) COMP-3 COMP-3 KEY BUFFER key Define buffer it as a describes record each key (0l-level) to in the SORSINIT SORT the Working- Storage subroutine. Section. The first data item in the key buffer specifies the number of individual Kkeys; 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 » 01 Follow KEY-BUFFER. 03 NUMBER-OF KEYS the number-of-keys definitions. Each ‘key data preceding one-word COMP data key type 9(4) COMP specification with block specifies one Specifies the data VALUE IS up ten to key field the record area. The items -- PICTURE 9(1l) to type consists the key of key valid of as four field. follow1ng data interface: 1 2 character (alphanumeric) binary (COMPUTATIONAL) packed-decimal (COMPUTATIONAL-3) SORTING IN A COBOL PROGRAM types are "blocks" that you defined block 9(4): of 3. The I/0 4 11-4 | PIC for the. record key - specifies the order order start position 0 = 1 = for sorting ascending descending Kkey The the the (not record character position in the buffer) at which this key £field begins. to value of this data item can range from 1 maximum record size. specifies the size of the key length this key field: field in digits, for packed-decimal (COMPUTATIONAL-3) items, or character positions for all other data items. For COMPUTATIONAL items, the"lengths with PICTURE ranges asSociated,g‘ are: PICTURE in key-length 9(1) to 9(4) 2 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 SOR$SORT INIT. WORKING-STORAGE SECTION. KEY-BUFFER. 03 NUMBER-OF-KEYS 01 - 01 03 03 03 03 03 03 03 03 03 03 KEY-1-TYPE KEY-1-ORDER KEY-1-START KEY-1-LENGTH KEY-2-TYPE KEY-2-ORDER KEY-2-START KEY-2-LENGTH KEY-3-TYPE KEY-3-ORDER 03 KEY-3-START 03 | KEY-3-LENGTH 03 9(4) 9(4) 9(4) 9(4) 9(4) 9(4) 9(4) 9(4) 9(4) 9(4) 9(4) COMP COMP COMP COMP COMP COMP COMP COMP COMP COMP COMP PIC 9(4) COMP VALUE | 05 NUMBER-OF-EMPLOYEES FILLER 05 DOLLAR-VOLUME INDUSTRY | e PIC S9(5) COMP-3. PIC 9(4) COMP. SORT-DATA. 05 35. 2. PIC X(25). KEY-NUMBER-OF-EMPLOYEES KEY-DOLLAR-VOLUME 05 VALUE 3. VALUE 1. VALUE O. VALUE 10. VALUE 25. VALUE 4. VALUE 1. VALUE 1. VALUE 5. VALUE 2. VALUE O. PIC 9(4) COMP VALUE SORT-RECORD. 03 SORT-KEYS. KEY- INDUSTRY 05 05 05 PIC PIC PIC - PIC 'PIC PIC - PIC PIC PIC PIC PIC | - | e "PIC S9(5) COMP-3.'Ci) PIC X(6). PIC 9(4) 10 PIC X(25). COMP. 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 "SOR$END SORT" GIVING SORT-RESULT. causes the result status for the clean-up routine to be available the COMPUTATIONAL data item, SORT-RESULT, which you have defined the Working-Storage Section with a PICTURE 9(9). in in 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. that they SOR$PASS_FILES For the file I/0 interface, input and output The general CALL " this subroutine passes the files to VAX-1l1l Sort. names o0f the | form of the CALL is: "SORSPASS 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 spec1f1cat10n (or loglcal name) of the input . file. output file is the data-name of a data item that contains the file specification output»file. 11-6 g SORTING IN ACOBOL PROGRAM (or 1logical name) | of | the N 11.5.1 order Result Status Values Hex Symbolic Decimal Value NORMAL SORT_ON VAR FIX Value 1 1 1C802C 1867820 1C8064 1867876 Meaning Success.v A sort is this call You 1C805C 1867868 OPENIN 1C109C 1839260 OPENOUT 1C10A4 1839268 All 11.5.2 RMS error .'\ /,.—( —\'n I variable-length fixed-length open data for input records. file. file. Cannot open output file. SORSINIT SORT areas, passed change to 1Inconsistent < Cannot in progress or the wrong sequence. in codes. This subroutine begins a sort. and is cannot records INCONSIS already by and the it It initializes the Sort's interprets program. the | parameters | work files (arguments) - that | are | The general form of the CALL is: CALL "SOR$INIT_SORT" USING <key buffer> <LRL> [ , <file size> ] [ <work files> ] [GIVING <result status>] Arguments key buffer is the data-name of - have defined key buffer LRL | the key buffer, the Working-Storage discussed in Section - 1is the longest record length - ’ File is in - item, is data-name of the which you a have a you The 11.3.2. one-word 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 data which Section. COMP in 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 is the data-name of a | wo:k files one-word - COMP data item. "that specifies the number of work files the Sort should use. Valid values are 0 and 2 through 10; The Sort expects this argument the default is 2. as a one-byte binary item; COBOL 9(1) to however, define it in as a one-word COMPUTATIONAL item - PICTURE 9(4). Result Status Values Symbolic 1 Meaning Success. 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 invalid sort process was specified. BAD LRL 1C8084 1867908 An invalid LRL 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 VM _FAIL 1C801C 1867804 WS FAIL 1C8024 1867812 NUM KEY 1C803C 1867836 KEY LEN 1C80AC 1867948 - ‘ call is in the wrong sequence. - | All 11.5.3 - , s e S Value 1 'NORMAL ~ Decimal Hex Value access or not local node. SORT failed to get needed virtual memory. 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 1I/0 interface. the REC, your program Before calling SORSRELEASE Usually, must construct the sort keys 1in 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. the record area, or if you compute key values in some other way. 11-8 IN A COBOL PROGRAM SORTING - exception An might be when you construct keys by combining data items in Call this subroutine once for each record you want to be the sort. This call is in an Input Procedure. The general CALL form of comparable the call to the ANSI included COBOL RELEASE ) in statement is: "SORSRELEASE REC" USING | BY DESCRIPTOR [GIVING <result <key data> status>] Argument key data | is the record-name data record-name the record the access Result Status Values Symbolic Hex Value NORMAL area; subroutine both Decimal Value the of the key data area. The includes both the key data therefore, all the sort keys this argument information and the key and gives it needs to data. Meaning 1 1l Success. SORT ON 1C802C 1867820 A sort is already in prOgess or this BAD LRL 1C8084 1867908 Record call that in the length was wrong is longer specified key area sequence. to than the LRL SORSINIT SORT. ADR 1C8094 1867924 1Invalid address. KEY LEN 1C80AC 1867948 Invalid key length specified. EXTEND 1C80A4 1867940 Failed to extend work file. MAP 1C809C 1867932 1Internal NO_ WRK 1C8014 1867796 Sort map error. - ,.-.' \ BAD is | ~ 11.5.4 - Cannot sort data Need work in memory. files. SOR$SORT_MERGE This subroutine performs the final phases of the sort-merge process. For the record I/0O interface, call it once, after the last record has been released to the Sort, and before attempting to return ~the first of the sorted records. For the file 1I/O interface, call SORSSORT MERGE once after calling SOR$INIT SORT. - The general form of the callAis: CALL "SORS$SORT [GIVING MERGE" <result status>] SORTING IN A COBOL PROGRAM 11-9 SN Arguments None. ~ Result Status Values Decimal Hex Value Symbolic Meaning 1 Success. | 1 NORMAL Value SORT_ ON 1C802C 1867820 A sort is already in progress, Or - EXTEND 1C80A4 1867940 Failed to extend work file. - NO_WRK 1C8014 1867796 Cahnot sort data in memory. “"MAP 1C809C 1867932 - READERR 1C10B4 1839284 Cannot read an input file record. "WRITEERR 1C10D4 1839316 an output file record. Cannot write BADFIELD 1C1l01C 1839132 Bad data in key field. 11.5.5 this call | Need work is in the wrong sequence. files. 1Internal Sort map error. SOR$RETURN_REC It "This subroutine returns one record to your program from the Sort. places the record in the record area data item; it also returns the . record length. You cannot " subroutine. call from the Sort. Call this | | subroutine before calling the sort-merge REC once for each record to be returned SORSRETURN a The general form of the call is: "CALL A N_ "SORSRETUREC" USING BY DESCRIPTOR <record area> BY REFERENCE <record length> [GIVING <result status>] Arguments -“reCOrd‘area | is the data-name of the area into which the Usually, it is returned record should be placed. released; 1t was from which area same the however, 'you can specify another data-name. item into which the subroutine will place the ,‘ 7 actual size of the returned record. b is the data-name of a one-word COMPUTATIONAL data AT record length 11-10 SORTING IN A COBOL PROGRAM Result Status Values Symbolic Success. A record has been returned. 1 870 12160 MAP 1C809C 1867932 Internal Sort map error. EXTEND 1C8084 1867940 Failed to extend work file. ENDOFFILE 11.5.6 N Meaning Value 1 NORMAL o Decimal Hex Value No more records to return. SORSEND SORT This subroutine deletes the Sort's work files and ' releases its::work sort; ning another SORSEND SORT before begin You must call areas. however, it is good programming practice to call' this subroutine at the end of any sort to-relhgse work file space and memory. The general form of the call is: CALL "SORSEND SORT" [GIVING <result status>] Arguments None. Result Status Values - Symbolic ‘Decimal Hex - Value Value UP 1C80B4 CLEAN ' 11.6 1 1 NORMAL . Meaning Success. 1867956 Failed to delete work files and reinitialize work areas. PROGRAMMING EXAMPLE ~ The program in this section reads a sequential mailing 1list :file, It uses theand writes a new filei “attempts to detect duplicates, ‘an artificial 'record I/O interface Sort technique, after constructing to return identically-keyed records:together, so ion identificatkey, le, the program:juses’ they can be compared. After it writes the newifi ‘the file I/O interface to sort the file into its original order. fOne of the sort “keys (subscription .descending record order, because is probably the most the start designer accurate. date) assumes is specified as that the earliest IN A COBOL PROGRAM 'SORTING 11-11 4 The comparable ANSI-74 COBOL SORT module statements comments for are included as comparison. IDENTIFICATION: DIVISION. PROGRAM-ID. | 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 ASSIGN TO "NEWLIST". SELECT SORT-FILE ASSIGN FILE TO "SORTF". DIVISION. SECTION. *SD * *01 SORT-FILE LABEL RECORDS SORT-REC. * * * 03 03 *. 05 03 * * 05 S-CITY-KEY 05 FILLER * 03 S-START MAILING-FILE | LABEL ARE 01 » FILLER RECORDS -~ | X. PIC PIC X. X. PIC PIC X(12). X(12). PIC PIC X(4). X(16). PIC X(4). PIC X(16). PIC XX. ~ . PIC 9(6). “ STANDARD. | 05 ZIP-CODE 05 LAST-NAME. 07 LAST-NAME-CHAR PIC 9(5). » OCCURS 05 05 05 03 03 '11-12 | , MAILING-REC. 03 MAILING-KEY. \ - PIC PIC X. ~ 03 9(5).. | S-NAME-4 * FD PIC u 05 FILLER S-FIRST-NAME S-STREET. 05 S-STREET-KEY 05 FILLER S-CITv,. 03 03 * * * OMITTED. S-ZIP S-LAST-NAME. 05 S-NAME-1 05 S-NAME-2 05 FILLER * * * * * ARE FIRST-NAME STREET | CITY | STATE SUBSCRIP-START - 16 S PIC PIC PIC PIC X(16). X(20). X(20). PIC PIC X(2). 9(6). ' SORTING IN A COBOL PROGRAM \‘\ DATA "MAILLIST". ‘ | * * TO NEW-FILE | X(1l). FD NEW-FILE ‘ LABEL RECORDS ARE STANDARD. PIC X(85). NEW-REC 01 WORKING-STORAGE SECTION. 01 01 01 01 PIC X(8) X(8) MAILING-FILE-ID NEW-FILE-ID FIRST-IN FIRST-KEY. 03 FIRST-COMPARE 03 PIC PIC PIC FILLER VALUE X(85) VALUE X(6) VALUE SPACES. 4 SORT-RECORD. 03 SORT-KEYS. 05 SPACES. X(14) VALUE SPACES. - 01 - "MAILLIST". "NEWLIST". VALUE PIC PIC s9(5) KEY-ZIP COMP 3 NAME-ADDRESS-GROUP. KEY-LAST. 07 -LAST-CHAR KEY 09 OCCURS 3 PIC X(1). PIC X(4). KEY-STREET 07 07 KEY-CITY PIC X(4). 05 KEY-START PIC 9(6). SORT-DATA. SR 05 LAST-IN PIC X(85). 05 LAST-KEY. 07 LAST-COMPARE PIC X(14). 07 FILLER PIC X(6). ,} p Py N 05 03 KEY-BUFFER. » NUMBER-OF-KEYS PIC 9(4) COMP VALUE 03 03 FILLER FILLER PIC PIC 9(4) 9(4) COMP VALUE COMP VALUE 03 FILLER PIC 9(4) COMP VALUE 03 03 03 03 03 03 03 03 03 01 | 03 FILLER , FILLER FILLER ~ PIC 9(4) . | AN COMP VALUE \Pig 9(4) COMP VALUE PIC\Q(4) COMP VALUE FILLER FILLER | PIC-9¢4) COMP VALUE PIC 9(4)~COMP VALUE FILLER PIC 9(4) COMP‘VALEE S FILLER FILLER FILLER PIC PIC PIC ORIGINAL KEYBUFFER 9(4) 9(4) 9(4) 1. COMP V COMP VALUE 80, COMP VALUE 6. »\\ FILLER PIC'9(4)\COMP VALUE l‘ 03 FILLER PIC 9(4) FILLER FILLER FILLER . I 03 03 03 03 e PIC 9(4) PIC 9(4) PIC 9(4) COMP VALUE 1 COMP VALUE COMP VALUE COMP VALUE 0 1 7 -] ¢ 01 SORTING IN A COBOL PROGRAM 11-13 01 RESULT-STAT 88 88 01 LRL 01 FILE-STAT 01 PIC SUCCESSFUL END-SORT REC-LENGTH 88 VALUE VALUE | 9(8) COMP. 1. 2160. PIC 9(4) COMP VALUE 105. PIC 9(4) COMP. PIC 9(1) VALUE O. ENDFILE VALUE 1. 01 DUPLICATES-DELETED PIC 9(6) 01 01 DISPLAY-DUPLICATES DISPLAY-RESULT PIC PIC 722Z,229. 9(8). COMP VALUE O. PROCEDURE DIVISION. ' MAINLINE SECTION. SBEGIN. INPUT MAILING-FILE. SORT SORT-FILE 'ASCENDING ¥ ¥ F F OPEN S-Z1IP S-NAME-1 S—-NAME-2 F ¥ - S-NAME-4 % DESCENDING INPUT ¥ ¥ ¥ S-STREET-KEY OUTPUT S-CITY-KEY S-START PROCEDURE PROCEDURE - GET-AND-RELEASE RETURN-AND-WRITE. CALL "SORSINIT SORT" USING KEY-BUFFER LRL GIVING IF NOT RESULT-STAT. SUCCESSFUL DISPLAY "INIT-SORT GO TO ABORT-RUN. ERROR" PERFORM GET-AND-RELEASE UNTIL ENDFILE., CLOSE MAILING-FILE. CALL "SOR$SORT MERGE" GIVING RESULT-STAT. IF NOT SUCCESSFUL DISPLAY "SORT-MERGE GO TO ABORT-RUN. OPEN ERROR" OUTPUT NEW-FILE. PERFORM RETURN-AND-WRITE UNTIL END-SORT. CALL "SORSEND SORT" GIVING 11-14 RESULT-STAT. SORTING IN A COBOL PROGRAM IF NOT SUCCESSFUL DISPLAY "END-SORT ERROR" GO TO ABORT-RUN. MOVE DUPLICATES-DELETED TO DISPLAY-DUPLICATES. " Dupllcates deleted". SORT SORT-FILE ASCENDING S-ZIP S-LAST-NAME S—FIRST-NAME S-STREET S-CITY % % o % % % % % DISPLAY DISPLAY-DUPLICATES CLOSE NEWFILE USING NEW-FILE GIVING MAILING-FILE. CALL "SOR$PASS FILES" USING BY | DESCRIPTOR NEW-FILE-ID MAILING-FILE-ID GIVING IF NOT SUCCESSFUL DISPLAY "/A\\‘ 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 ERROR" GO TO ABORT-RUN. | CALL "SORS$SSORT MERGE" - GIVING IF NOT SUCCESSFUL DISPLAY GO CALL RESULT-STAT. "SORT-MERGE ERROR" TO ABORT-RUN. "SORSEND SORT" GIVING RESULT-STAT. IF NOT SUCCESSFUL DISPLAY STOP "END-SORT ERROR". RUN. SORTING IN A COBOL PROGRAM 11-15 GET-AND-RELEASE SECTION. SBEGIN, MOVE SPACES READ MAILING-FILE AT TO MAILING-REC. END MOVE 1 TO FILE-STAT GO TO SEXIT. * MOVE MAILING-REC MOVE LAST-NAME-CHAR (1) TO KEY-LAST-CHAR (1l). MOVE LAST-NAME-CHAR (2) TO KEY-LAST-CHAR (2). MOVE MOVE LAST-NAME-CHAR (4) TO STREET TO KEY-STREET. KEY-LAST-CHAR (3). MOVE CITY MOVE ZIP-CODE MOVE SUBSCRIP-START TO MOVE NAME-ADDRESS-GROUP RELEASE CALL TO TO SORT-DATA. KEY-CITY. TO KEY-ZIP. KEYSTART. SORT-REC FROM 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. * RETURN * SBEGIN. AT SORT-FILE * MOVE % GO * INTO SORT-DATA END SPACES TO LAST-KEY MOVE TO COMPARE-KEYS. (data to keys for comparison). CALL "SOR$RETURN REC" USING BY DESCRIPTOR SORT-DATA BY REFERENCE REC-LENGTH GIVING IF END-SORT MOVE GO IF RESULT-STAT. TO SPACES TO LAST-KEY COMPARE-KEYS. NOT SUCCESSFUL DISPLAY "RETURN-REC .GO TO ABORT-RUN. 11-16 ERROR" SORTING INA 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. P SBEGIN. MOVE RESULT-STAT TO DISPLAY STOP DISPLAY- RESULT DISPLAY-RESULT. RUN. SORTING IN A COBOL PROGRAM 11-17 TN 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 library source text 1in a program, eliminating a great deal of repetitious coding and the errors that often go along with 1it. The compiler treats the copied text as if it were a part of the source program; powever, the copied material does not change the source program file in any way. . The COBOL library facility provides two important benefits: 1. Standardization of File and Coding A data file Conventions 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 is 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. pe— 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 into 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 wuse 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 a COBOL library file must form syntactically correct COBOL text 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 library 1into a COBOL source program. The simplest form of the statement COPY text-name. Text—hame must be either an . Remember that the regardless of where COPY it alphanumeric statement must appears in the 1literal end with a or a file terminator name. period source program. If you specify a literal, the compiler uses 1its value as a file specification; therefore, vyou 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 file name type, and itself. version number. | For example: COPY " [ACCTLIB]ACCFIL.XYZ:3". causes the compiler to in directory [ACCTLIB] access version number 3 on the default device. of the file If you use a file name in the COPY statement, the compiler as the default 12-2 file type. USING THE LIBRARY FACILITY ACCFIL.XYZ uses - .LIB For example: COPY causes the ACCOUNT. latest compiler to access the default device ACCOUNT.LIB on and version of the Only four conditions require the use of the indicate the full file specification for the alphanumeric 1literal copy statement: to 1} When the file type is other than .LIB. 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 contains more than one version of Figure the the 12-1 Procedure maintained COBOL 1library latest. file and you want to default device. copy a version other than demonstrates the use of the COPY statement to include code. Note that the format of the library text is when 1t is included in the ‘source program. Division Source Resulting Program Source Program PROCEDURE DIVISION. PROCEDURE DIVISION. START-PROC SECTION. START-PROC SECTION. BEGIN-PROC. ACCEPT | BEGIN-PROC. TO-DATE FROM DATE. OPEN-FILES. COPY ACCEPT OPENF. 'READ CUST-FILE | TO-DATE FROM DATE. OPEN-FILES. COPY ... OPEN INPUT OPEN I-O CUST-FILE. ORDERS. GET-VERSION. DISPLAY ACCEPT IF Library File (OPENF.LIB) GO TO OPEN i INPUT OPEN I-O | "VERSION?". VER-NUM. VER-NUM NOT NUMERIC GET-VERSION. I-O WORK-FILE. INPUT-LOOP. OPEN OPENF. * OPEN I-O WORK-FILE. INPUT-LOOP. : file directory. . CUST-FILE. ORDERS. GET-VERSION. DISPLAY ACCEPT IF "VERSION?", VER-NUM. VER-NUM GO TO NOT NUMERIC GET-VERSION. Figure 12-1 Merging Library Text USING THE LIBRARY FACILITY 12-3 "The COPY statement can appear a source program; anywhere therefore, that a COBOL word you can use it different problems. = For example, if a 1library contains the single entry MORTGAGE-PAYMENTAMOUNT, in the Data Division: Source Statement: MTG. PIC 03 COPY 03 MORTGAGE-PAYMENT-AMOUNT Resulting Source or in the to in solve file <called MTG it could be copied 999V99. - Statement: Procedure Source is allowed in many ways 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 in 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 ACCTREC REPLACING 02 BY 05, 03 BY 09, 04 BY 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 procedure for occurrences of 12-4 USING THE LIBRARY FACILITY 03 and 04. The following contains this 01 Example examples text: A. COPY the 1library file named | NEWSBOY, | which | 02 B 02 02 02 02 C PIC D PIC E PIC F PIC PIC 99. 99 VALUE 2. X(5) VALUE "ABCDE". 99V99 VALUE 3.75. 99 VALUE 02. 1 Statement: COPY NEWSBOY REPLACING B BY X. Result: A. 02 02 02 02 02 01 PIC 99, C PIC D PIC E PIC 99 VALUE 2. X(5) VALUE "ABCDE". 99V99 VALUE 3.75. F 99 VALUE PIC 02. 2 \” Example X ” Statement: COPY NEWSBOY REPLACING 2 BY 6. Result: A. 02 02 02 02 02 01 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. Example 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 \\ merged text is incorrect and would generate syntax errors. The REPLACING character—string can be a literal or a character equally, compare character-string in the library character, for Table text. results of some character-string comparisons. REPLACING Literal "ABC" "ABCD" No HRLY-RATE HRLY-RATE Yes 2 nom ngl2" L No 012 12 No SUBTRACT Yes "pl2" Yes | "p12" ACCT ACCT1 | Table 1illustrates the No - No 'SUBTRACT must entire Yes "5 15" "o 12.4 | 1 1 it the Match? Library Text or Word 12-1 word; with No | 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. end of the line; the to scans it when text source of line a prints 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 { . ' In the last example, level-number 02 was changed to level-number 63, therefore, although both the which is not 1legal under COBOL rules; the COPY statement and the library text are syntactically correct, Thus, if text (including the source line contains spaces), the a COPY compiler statement prints the the followed library by other text before source line containing the COPY statement; this results in a somewhat confusing 1listing. You can cause the compiler to produce a more readable 1listing by making sure that you write each COPY statement 12.5 Some as the Common of the facility last Errors more entry in Using common Merging a terminal) Forgetting line. to avoid when wusing the rules for library file. are Writing the COBOL « the library reference library file 1in one format with a source program written in to Inadvertently end the defining also duplicate ° program Library Facility COPY period. they ° source | ® ) the errors Failing to follow when creating the - a are: ® ) on data-names defined in names. library incorrect when it Merging the wrong versions exist, or statement in the the format (conventional the other. with a source 1library file, or terminator program when thus causing | file text that is merged with the becomes source 1library file, either because of misspellings. syntactically program. because multiple | ® Writing source text following the COPY statement on the same line, thus causing confusion in the source program listing. e Forgetting that numeric literals (such as 02, 77, ...) used REPLACING option replace level-numbers, picture descriptions, and paragraph or section names, when they find matches in the library file. | in ® the Forgetting that a périod must appear in the library it is to appear in that ends the COPY file 1if the source program; the terminator period statement is replaced by library text. USING THE 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, accomplish this . by the way aim to minimize I/O activity. You can 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: - 1. What kinds of I/0 operations are 2. How can you best place 3. How should you structure the file? 4. necessary or I/0 operations desirable? For each file, are frequent likely, or absolutely) - You can necessary data? also will file in to process the o the program? Are multiple access record updates contents remain keys and insertions relatively (or stable? influence computational - formatting - data to avoid data ‘specialized computational routines of performance, conversions and the compiler. especially utilize | by fast, - The following sections describe each of these optimization techniques. NOTE For more information on optimization techniques you <can use through Record Management Services (RMS) facilities, refer to appropriate RMS documentation. 13.1 OPTIMIZING FILE DESIGN 'This.Séction describes the effect of file design on performance. following 1. | suggestions apply to any type of file Preallocate the entire file, contiguously if possible, the /CO:n or /AL:n file switch (see DEFINE utility. 2. Select a -~ file, wusing (Refer extend to RMS documentation for a quantities and the RMS DEFINE The organization. Table 6-2) or using the RMS create the | suitable default the /EX:n extend file quantity when switch or the you RMS DEFINE utility. description of default utility.) 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 conserve file to no MOVE RECORD AREA address space. another, and statement is clause If to records save are compute being time copied and from one both files share the same record area, 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 - different 13.1.1 SAME AREA effects.) clauses; they | appear | similar, the fewest for definition, population, and handling. You can reduce of disk accesses by keeping record length to a minimum. With a sequential disk file, you can use the write facility to create a larger buffer area. specify the BLOCK CONTAINS n CHARACTERS clause ORGANIZATION IS SEQUENTIAL. CHARACTERS clause, 13.1,2 Relative relative l. 13-2 have | Sequential Files Sequential files have the simplest structure and For but If you omit the RMS default applies. multi-block To in the the options number read and use this facility, combination with BLOCK CONTAINS n R Files files: Select a record space remalning OPTIMIZATION format and size that minimizes the empty in each record position and each bucket. 2. 1If you create select a the file realistic by using 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. '13.1.3 Be aware that, before writing ‘ a record B i into a relative file, RMS must have formatted all buckets up to and including the bucket into which the record insertion 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. 1Indexed 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 wunderstand how indexed files are organized and processed. | AT As the name suggests, an indexed file contains, besides data ‘pointer information to facilitate access to the records. records, All data records and record pointers are maintained in storage units called Dbuckets. The bucket is the basic retrievable element of an ‘indexed file. It consists of an 1integral 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 in the record description that contains a unique value for each individual record. When RMS writes records into the indexed file, it arranges them 1in 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 ~structure of key-value and location pointers. (See element of the index structure 1s a bucket, and structured into a hierarchy of levels. a trée—like Figure 13-1.) the buckets The highest level of Each are the index consists of a single bucket, called the root bucket. The root contains location pointers to buckets at the next lower level. RMS scans one bucket at each level of the index for a pointer bucket Thus, to a bucket at the next level, 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 _Avl.llll X% —N\ L13AT 13-4 OPTIMIZATION v13AIiva) (03A31 V. /’-\\ RMS also constructs an index for the contained file. in the Like file. for each alternate key actual data records at the data level; to data records that you define the primary index, alternate key indexes are However, alternate key indexes do not contain instead, they contain pointers in the data level of the primary index. Successive levels of an index are numbered. The data level 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 key. (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 lower level into memory. This process is repeated for each level of the index. RMS thus searches one bucket at each level 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, while making room to write the new record. This action is as a bucket split. 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. . ~, known 13.1.3.1 following General Rules general rules for for 1Indexed Files - You can apply the indexed files at the COBOL source code level. 1. While alternate keys are often wuseful, the more keys you define for an indexed file, the longer each WRITE , 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 file activity of index structure. (See OPTIMIZATION 13-5 3. Avoid excessive duplication of key values. COBOL does not allow duplicates on the primary key, but permits them on ‘alternate keys. : » The following subsections design and creation. deal 13.1.3.2 Bucket Size - Bucket file performance markedly. To RMS, blocks, 512-byte bucket, w1th the size selection and so 1long. bucket can of indexed influence integral Thus, size number a bucket size of of 2 specifies of 1 file indexed | bucket size is expressed as an each 512 bytes bucket, while a specifics - .phyeical specifies a a 1024-byte on. The COBOL compiler passes bucket‘sizervalues.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 wused derive 'bucket sizes, so that you can predlct how RMS will treat your file descrlptlon. | | | If you express block size in records, the bucket can in some cases contain more records than you specify, but never fewer. For example, assume that your file contains fixed-length 100-byte records, and you call for each bucket to contain five records, as follows: BLOCK CONTAINS 5 RECORDS hlS mlght seem to def1ne a bucket as a 512-byte block containing five records of 100 bytes each. However, the compiler adds RMS record and bucket overhead to each bucket for control purposes, as follows: . Bucket Overhead , 15 bytes per bucket 'vRecord Overhead “_ 7 bytes per record'(fixed—length) e Thus, A 1n the example, vBucket Overhead Record Size + 7 bytes is bucket size o 100 Total each of Record Space Total Block bytes | 5 records is (100*+ spec1f1ed Because phy51cal 13-6 bytes per is o record calculated . -~ | (variable-length) _ as follows: 15 bytes Record Overhead for some (the 9 by user | 7)*5, 2 or 535 | bytes 550 bytes 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 from which 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 specify bucket size more directly. BLOCK CONTAINS 2048 clause allows .you~ to For example: 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. If you specify a value that is not a multiple of 512, RMS rounds next higher multlple of 512, 13.1.3.3 | 1Index Depth - The size of data records, it the to L key fields, of 3 or | and buckets in the file determines the depth of the index. Index depth, in turn, determines the number of dlsk accesses requlred to retrleve a particular record. | In general, performance is best with an index depth 4;-WIA~ shallower index will require fewer accesses, but will reduce avallable 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, to contain it. | there must be sufficient room in the bucket a bucket split occurs. Otherwise, Bucket splits can cause accumulation of storage overhead, thereby reducing usable space. The new bucket contains records moved from the original bucket (see record each For new record. Section 13.1.3) to make room for the moved out of the original bucket, a seven-byte pointer to the new 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. Under most storage overhead. Record deletions also can accumulate the space that was occupied by the most of however, circumstances, orlglnal record becomes available for reuse. Because duplicate primary keys are not allowed, RMS can reclaim all but two bytes of the deleted record space. record has been This two-byte field 1is a flag indicating that a deleted. There are several ways to deal w1th 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¢ record additions and deletions. S . OPTIMIZATION 13-7 However, if you expect frequent additions and deletions, try the following: 1. Choose a bucket size that allows for if possible. multiple 2. To of optimize space Avoid your for record record optimization), (using number bucket overhead sizes that are accumulatlon, an exact or near size. insertion performance first 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 is populated. Then, populate the file, specifying the /LO switch (see Table 6-2 or RMS utilities documentation). Thereafter, the unused space 1s available for record insertions, with minimum bucket spllttlng' ~Make certain that programs /LO 13.2 performing such record insertions do not spec1fy sw1tch the o OPTIMIZING PROGRAM ORGANIZATION Program organization can sectlon suggests 13. 2 1 Sequent1a1 influence guldellnes I/0 performance toward an efflclent pregram Readlng of Indexed greatly. structure. This Flles If you access an 1ndexed file sequentlally, 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 flle--even though you have no 1ntent10n of doing so. | | L Readlng from a file that is open for 1nput output improves performancef by the 1locking the bucket, same bucket without 13.2.2 Caching Index allowing you to rereading it. obtain subsequent Roots RMS requires at ieast two buffers to proceSs:an buffer is program RMS to large does set not the records from enough contain indexed to a default. file. | | By including a RESERVE n AREAS clause in the SELECT statement file, you <can create additional - (but not fewer) buffers processing of an indexed file. At run time, RMS will 'retain the roots of one or more access of operation. 13-8 any record OPTIMIZATION Each contain a single bucket. If your COBOL RESERVE n AREAS clause, the compiler allows through | indexes of that index the file w1ll in memory. then requlre | for a for the (cache) The one random 1ess I/O The following rules apply shared at run roots: The 2. ‘Allocate 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 Kkey and two alternate keys, and vyou use all of these keys to access - not be index l. 3. file must for caching time. records, allocate a total of five buffers. one key to access this file in a program, additional buffer area, or three in all. If you use only you need only one Use the RESERVE n AREAS clause this to obtain 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 T 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/O operation, reducing the number of I/O 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 and resides on disk Then, in the FD entry for the file, specify: . 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. Ifn is not a multiple of 512, the compiler rounds the size to the next multiple 13.3 of e 512. OPTIMIZING COMPUTATION R o | | On arithmetic (ADD, SUBTRACT, MULTIPLY, DIVIDE, and COMPUTE) and movement (MOVE) spec1alized code l. 2. 3. operations,' the 1f | | = | The data items 1nvolved in the computation (including rece1v1ng f1e1ds) have the same type and scaling. You omlt the ROUNDED and data compiler generates more efficient, SIZE the ERROR phrases.v LINKAGE SECTION data is not 1nvolved in the computation. Also, in the case of COMPUTATIONAL data, the data items same size. Otherwise, the compiler uses slower, must be the generalized code. OPTIMIZATION 13-9 Certain data types allow faster computation types, in order of most efficient to least than others. efficient, The are: 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 most efficient when performed on data items of minimal Different data size does not force the use of generalized code these data types. A The following situations also force opposed to more efficient code: 1. Non-matchlng dec1mal ‘receiving fields. 2. Use 3. of the point ROUNDED or SIZE the alignment Generalized code is their addresses are necessary on not known at specialized ADD code 01 01 01 01 A B C E PIC PIC PIC PIC and among the code, as operands andv LINKAGE SECTION of R | LINKAGE compile SECTION data time. The following example illustrates the between generalized ERROR options. Data itéms defined in the program. use of are size. with S difference thé source | items, in because execution time the generalized ADD code. S9(4) USAGE COMP. S9(4) USAGE COMP. S9(4) USAGE COMP. S9(4)V9 USAGE COMP. Of the following two ADD statements, statement 30 to 40 tlmes faster than statement (2): (1) ADD A B (2) ADD A B GIVING E. (1) typlcally executes GIVING C. On MULTIPLY and DIVIDE operations, decimal point alignment has Assuming compiler a that wuses N different meaning than for ADD and SUBTRACT operations. the data types are the same for all items involved, the the more efficient code if: 13-10 OPTIMIZATION 1. On of a MULTIPLY, the product field scale factor equals the the scale factors of the multiplicand and multiplier. sum For example: 01 X PIC 01 Y PIC 01 z PIC S9(4)V9(2) S9(4)V9(3) S9(6)V9(5) USAGE USAGE USAGE COMP. COMP. COMP. MULTIPLY X Y GIVING Z%. 2. On a DIVIDE operation, the quotient dividend scale factor example, using the minus data scale the divisor descriptions factor scale from equals factor. the the For previous example: = DIVIDE When defining data i e COMPUTATIONAL 1is by indexes unless The use It also of Z BY X GIVING Y. to the most you need arithmetic generates be used as efficient. to perform expressions subscripts, increases larger operands, l-word signed' Try to avoid referencing tables relative index references. and use of can temporary cause the storage. less-efficient generalized code to be used unnecessarily. Avoid using the COMPUTE verb, and avoid using arithmetic expressions when specifying relational conditions. | | 3 OPTIMIZATION 13-11 APPENDIX A THE COBOL NOTATION USED COBOL FORMAT IN FORMATS ® Underlined upper-case words (key words) - required-words; ‘@ Upper-case words (not underlined) - optional words; ® - Lower-case words = generic térms, must be supplied by the user; ® Brackets [] - enclosed portion is optional; if several enclosed words are only one of them may be used; P N, vertically stacked, ® 7” o Braces {} - a selection must be made from the vertical stack of enclosed words; o Ellipsis «e. = the position at which repetition may occur; ® Comma and semicolon - ® Period - NOTE : optional punctuation; required where Shaded items shown in the formats. represent PDP-11 COBOL extensions to the ANS=74 list of COBROL formats. IDENTIFICATION DIVISION. PROGRAM-ID, [AUTHOR. program=-name. [comment-entry]...] [INSTALLATION. [comment=entry]...] [DATE-WRITTEN. [comment-entryle.e.] [DATE-COMPILED. [SECURITY. [comment-entryl...] [comment—entry]l...] ENVIRONMENT DIVISION, CONFIGURATION SECTION. SOURCE-COMPUTER. VAX-11l. | | OBJECT-COMPUTER. VAX-11 MEMORY SIZE integer | WORDS CHARACTERS MODULES [PROGRAM COLLATING SEQUENCE 3 IS»alphabet-name] [SEGMENT-LIMIT IS segment-number]. [SPECIAL-NAMES. | N [CARD-READER IS mnemonic-name=1] [CONSOLE IS mnemonic-name=2] [LINE-PRINTER IS mnemonic-name=-3] [PAPERPTAPE-PUNCH Is mnemon1c-name-4] [PAPERrTAPE-READER.;§_mnemon1c-name—5] SWITCH integer-1 ] Alphabet=-name IS {ONSTATUS IS condition-name-1 OFF STATUSIS condition-name=-2 NATIVE {STANDARD-l]] [ [OFF STATUS IScondition-name-2] } [QE'STATUS E§_condition—name-l] " [CURRENCY SIGN ISliteral-1] [DECIMAL-POINT IS COMMA ].] [INPUT-OUTPUT SECTION, Format 1: SELECT [OPTIONAL] (, ’ FILE-CONTROL. {file-control-entry}... file-—name ASSIGN TO literal-l | : [AREAE]] AREA \\ [} RESERVE integer-1 / [; ORGANIZATION IS SEQUENTIAL] IS SEQUENTIAL] [; ACCESS MODE' [; Format FILE STATUS IS data-name-1] . 2: SELECT file=-name ASSIGN TO literal-1l - [, RESERVE integer-1 : | [AREAE]] AREA | ; ORGANIZATION IS RELATIVE - . A-2 ; L ] =~ — SEQUENTIAL ACCESS MODE IS | 1 ( RANDOM DYNAMIC FILE STATUS IS data=-name-2] THE COBOL FORMATS [, RELATIVE KEY IS data—name-l] ELATIVE KEY IS dat ata-name . . — ( / Format 3: SELECT file-name ASSIGN TO literal-1 [, S integer=-1 . s+ RESERVE 3 ORGANIZATION [AREAS]] AREA - IS INDEXED SEQUENTIAL 1; ACCESS MODE IS RANDOM e RECORD KEY IS data-=name-=1l o BN [ [ ALTERNATE RECORD KEY IS data-name=2 [WITH DUPLICATES]]... s - DYNAMIC FILE STATUS IS data=name-3] . " [I-0-CONTROL. [SAME [RECORD] AREA FOR file-name-1l {flle—name-Z}...]...- [MULTIPLE FILE TAPE CONTAINS [file-name-4 [APPLY file-name-3 [POSITION integer-1] [POSITION integer=2].eeleee PRINT=-CONTROL ON file-name-5 [file-name-6]...] ...]J' DATA DIVISION. [FILE SECTION., [gg_file-name , [RECORD CONTAINS [integer-3 TO] meeL TRl [ _L—ALUE OF ID {llteral-l }] RECORD IS ( . A | B F " JPATA ID IS LINAGE IS LINES AT TOP’ CHARACTERS integer-4 CHARACTERS] STANDARD data-name-1 ] RECORD IS {RECORDS ARE} —— ] {RECORDS BLOCK CONTAINS [integer-1 TO] integer-2 data=-name=3 data-name-3| integer=-5 'data-name-? integer=7 . oo | [da#a—name-4] ... coe WITH FOOTING AT , |data-name=6 integer-6 | |viNES ar BoTTOM ~— ——— [data-name=8 |1nteger-8 [CODE-SET IS alphabet=-name]. [record-description-entry]leeeleee] [WORKING=STORAGE SECTION. [77-1evel-description—entry] record-description=-entry 0.0] - THE COBOL FORMATS A-3 \ “\\ . -P [LINKAGE SECTION, [77-level—description-entry] oeol record-description-entry Data description entry: Format 1: data-name-l] lével—number‘ { FILLER [REDEFINES data=name=2] L{E;;?URE} IS character-string] COMPUTATIONAL COMP l COMPUTATIONAL-3 | [USAGE IS]§J COMP-3 ] - T DISPLAY DISPLAY-6 DISPLAY=-7 - 1 [SIGN IS] INDEX G y LEADING } {TRAILING [SEPARATE CHARACTER] p{SYNCHRONIZEDl | |sYNC j JUSTIFIED} _{JUST - [ LEFT [RIGHTa] | RIGHT | [BLANK WHEN ZERO] [VALUE IS literall TOinteger-2 TIMES DEPENDING ON data—name-B} [QEEH§§_ {integer-Z TIMES integer-1 ASCENDING [{DESCENDING} _ KEY IS data=name=4 [INDEXED BY index=-name-1 Format [data=name-=5]. [index-name—2] ...]] R 2: 66 data-name-1 RENAMES data-name-2 THROUGH | THRU Format 3: 88 condition-=-name [literal— 3 PROCEDURE DIVISION A-4 data=-name=3|, THE { VALUE VALUES IS } [{THROUGH} THRU [USING COBOL FORMATS ARE . literal-1 [{ THROUGH } literal-z] THRU literal-4]] coe o [data=-name-=1][,data=name=2] ces]e Format 1l: [DECLARATIVES. {section-name SECTION [segment=-number] . declarative-sentence [paragraph-name. [sentencel.eeleeeltee. END DECLARATIVES,] {section-name SECTION [segment=-number]. [paragraph=name. [sentenceleeeleceeoe Format 2: {paragraph-name. [sentencel...}... STATEMENTS ACCEPT identifier [FROM mnemonic-=name] 27N DATE ACCEPT identifier FROM { DAY TIME ap [identifier-] ADD [identifier-n [ROUNDED]]... [ON SIZE ERROR imperative-statement] {identifier-l} {identifier-Z] [identifier—3] . e [ddentifier-2] literal=-1l literal=2 GIVING identifier=-m [ROUNDED] 0 igentifier-n (ROUNDED) literal=3 [identifier-n [ROUNDED]] coe [ON SIZE ERROR imperative-statement] oo| CORRESPONDING CORR identifier-1 Eg_identifier-Z [ON SIZE ERROR imperative=-statement] [ROUNDED] ALTER procedure-name-l1 TO [PROCEED TO] procedure-name-2 [procedure-name-3 TO[PROCEED TO] procedure-name—4]--o CALL literal - [BY REFERENCE ] BY VALUE BY identifier-1 DESCRIPTOR BY REFERENCE BY VALUE identifier-3 [identifier-2] ... | | | [identifier—4] R “ee wee BY DESCRIPTOR - b ot _J [GIVING identifier-5] - {.REEL} ! UNIT CLOSE file=name=-1 | ' - | [WITH NO REWIND:] FOR REMOVAL LOCK - REEL} . N {EQ_REWIND} - = file=-name=2 — | UNIT — . - [WITH NO REWIND] )] | FOR REMOVAL {gQ_REWIND} LOCK I THE COBOL FORMATS ceo %J A-5 COMPUTE identifier-1 [ROUNDED] [identifier-2 [ROUNDED]] ... = arithmetic-expression DELETE file-name RECORD identifier=-1 identifier-2 [UPON mnemonic-name] , <‘ [INVALID KEY 1mperat1ve-statement] DISPLAY {literal-l | } [llteral-z ] ‘ | [ON SIZE ERROR imperative-statement] [WITH NO ADVANCING] prvipe | rdentifier-l literal-1 *ec INTO identifier-2 [ROUNDED] m——— [identifier-3[ROUNDED]] eee [ON SIZE ERROR 1mperat1ve-statement] - { identifier-1} DIVIDE {literal-l : : INTO identifier=2 [11teral 5 } . GIVING identifier-3[ROUNDED] identifier-3 [1dent1f1er-4[ROUNDED]]...[ON SIZE ERROR 1mperat1ve-statement] identifier-1 DIVIDE - |‘11teral-l } identifier-2 {llteral 5 } BY v R »GIVING identifier | 3[ROUNDED] : Ces | - ( [identifier-4 [ROUNDED]]...[ON SIZE ERROR imperative-statement] identifier-1] ‘1iteral-l } DIVIDE : identifier-2) {llteral-Z } - InTo - , | GI N i, | VING identifier=-3[ROUNDED] G f - ~ REMAINDER identifier-4[ON SIZE ERROR imperative-statement] pIvIDE -_— | | 11teral-1 rdentifier-l . s BY : TP GIVING identifier-3[ROUNDED]—_— o o REMAINDER 1dent1f1er-4[ON SIZE ERROR 1mperat1ve—statement] EXIT [PROGRAM] GO TO identifier literal-2 - - . | | <\ [procedure-name-1] GO TO procedure-name-1 IF condition [procedure-name—2]...procedure-name—n DEPENDING ON identifier lstatement-l ] NEXT SENTENCE - [ELSE statement-2 _]‘ ELSE NEXT SENTENCE INSPECT identifier-1 TALLYING identifier-2 FOR INSPECT identifier-1 ,LEADING} | , {literal—4 ’ . : AFTER o [{AFTER } S INITIAL identifier-6 {iQintlflzr'4}] o itera identifier-3 CHARACTERS REPLACING CHARACTERS BY literal-1 } [:ifiggiE} INITIAL ALL BEFORE . identifier-5 LEADING INSPECT identifier-1 - identifier-6 BY identifier-7} FOR REPLACING literal-1 | } RACTERS BY {1iteral-4 J Y . [{BEFORE} INITIAL . - T identifier-7 e — 1dent1f1er-3} LEADING CHARACTERS CHA " | BEFORE o0 e oo e TALLYING ALL identifie;—2 - lliteral—S : {{FIRST } '{lliteral'3 } — lliteral‘4 , - [{éflzfifi } HHLTIAL literal-5 ’]} } ALL p—— - AFTER [{AFTER } identifier-6 ‘| BEFORE ‘ | o — INITIAL A ! <1§ent1f1er—4’]}...} o literal-2 lli;eral-S. }] identifier-7 ‘{{%éfigggfli} {‘literal-B _} B {literal-4_ ] [:{AFTER }';' INITIAL {literal-S:'}}} "'} "t ) —— identifier-5 . identifier-6| | | BEFORE . identifier-7 ; A-6 THE COBOL FORMATS movg | identifier=ll 4 literal — MOVE ——— ... [identifier-3] . .0 tifier-2 | S . — TO identifier-2 identifier-1 —— SPONDING< co CORR I MuLTIpLy 4 [ f . [] . \" - .- oy qentifier-2 [ROUNDED] —_— |identifier=ll literal-1l [identifier-3 [ROUNDED] ] ... [ON SIZE ERROR imperative-statement] [1dent1f1er—4 [ROUNDED]] . , [ROUNDED] GIVING identifier-3 identifier-2 {literal-Z BY identifier-1) {literal—l MULTIPLY ... [ON SIZE ERROR imperative-statement] INPUT flle-name-l[WITH NO REWIND] [flle-name-Z [WITH NO REWIND]]... } OUTPUT flle-name-B[WITH NO REWIND] [file-name-4 [WITH EQ_REWIND]]... .l_g_flle-name-s [flle-name-6]... u EXTEND file-name=7 [file-name-8]... THROUGH me-l PERFORM procedure-na | THRU ' cee - rocedure- me—2-1 procedure=nha - TIMES PERFORM procedure-name-1 THROUGH } procedure-name-z {THRU identifier-l ‘integer-l | PERFORM procedure-name=1 T procedure-name-2] {Tg§$UGH} . UNTIL condition-1 - PERFORM procedure-name-1 ‘ggifiUGH} procedure-name-2 VARYING BY —— | AFTER | 1dent1f1er- ! index-name-1 — l b] — ¥ FROM 1ndex-name— {1dent1f1er-7 [AFTER identifier-8 literal-4 | identifier-3 index-name=-2 . literal-1l UNTIL condition-1 literal-2 v - FROM — } identifier-6 index-name-4 \ literal-3 UNTIL condition-2 identifier-9 FROM |= { index-name-. 6 g =2 index=-name=5 literal=5 UNTIL condition-%] | 1dent1f1er-lO} literal=-6 [AT END imperative-statement] READ file-name [NEXT]RECORD[INTO identifier] READ file-name RECORD [ INTO identifier] [INVALID KEY imperative-statement] READ file-name RECORD[INTO identifier] [;KEY IS data-name] [; INVALID KEY 1mperat1ve-statement] . REWRITE record-name [FROM 1dent1f1er][INVALID KEY imperative-statement] ) | . THE COBOL FORMATS A-7 SEARCH identifier-1 identifier-2 VARYING Do . e index=-name=1 }] [AT END imperative-statement-1] : {imperative-statement-2 WHEN condition-1 NEXT [WHEN condition=2. SENTENCE {1mperat1ve-statement-3}] L NEXT SENTENCE SEARCH ALL identifier-1[AT END imperative-statement=-1] data-name-1 IS EQUAL TO Is = | WHEN L AND | arithmetic-expression~1 | | T identifier-4 data-name~2 - literal-1 . condition-name=-1 - 1§ent1f1er-3 ] {;2 EQEAE-TO] {literal-Z arithmetic-expression=-2]) condition-name-2 cee _ imperative-statement-2 NEXT » SET — SENTENCE identifier-1 . s e [identifier-2]... index-name-1 [index-name=2] ... . o S—— SET . | | [ index-name-4 , 1fiexr=3 index~-name=-3 —_— . integer-1 UP BY ] " {DOWN|§£} {1nteger-2 —_— [identifier-4 . IS EQUAL TO IS | ] TO index-name-=5]... B START file=-name identifier- ] = KEY E ig SREAT'R.THAN _ IS NOT < IS } NOT . ~ data=name LESS THAN \ | - [INVALID KEY imperative-statement] STOP ‘literal} RUN | : Cer o - sTRING | rdentifier-l ——ree literal-1l | ,. . . fidentifier-d literal-4 INTO identifier=-7 s o] ldentifier=2|_ | literal=-2 . e = > identifier-5] = | literal=5 B | identifier-3 pEIMITED BY Jliteral-3 SIZE identifier-6 poiuieep By |literal-6 .o SIZE [WITH POINTER identifier-8] [ON OVERFLOW imperative-statement] SUBTRACT {literal-l identifier=1 } [literal—z identifier=2 eee E—— . [identifier-n [ROUNDED]]...[ON SIZE ERROR imperative-statement] " A-8 THE COBOL FORMATS . o FROM identifier-m[ROUNDED] SUBTRACT literal=-l literal=2 »o. IROM { | identifier-2 identifier-1 “GIVING identifier-n[ROUNDED] | identifier-1 FROM identifier-2 [ROUNDED] | CORR literal=-m [identifier=o[ROUNDED]]... [ON SIZE ERROR imperative-statement] ' {CORRESPONDING} SUBTRACT identifier-m} : [ON SIZE ERROR imperative-statement] UNSTRING identifier-1 {literal-2 }] } [95-[§££J [DELIMITED BY [ALL] {literal-l IMITER IN identifier-5] [COUNT IN identifier-6] identifier-2 ‘ identifier-=3 INTO identifier-4[DEL [identifier-7 [DELIMITER IN identifier=8] [COUNT IN identifier-9]]... [WITH POINTER identifier-10] [TALLYING IN identifier-11] coe ] | . [ON OVERFLOW imperative=-statement] { file-name=-1[file-name=2]... ’ {EXCEPTION ERROR USE AFTER STANDARD | [AT - ° 1-0 \EXTEND - {{.identifier=-2 } [ LINE integer LINE ]’ [PAGE] - | / END-OF-=PAGE . . {EOP S } - imperative-statement] WRITE record-name [FROM identifier] LOFL OUTPUT ' WRITE record-name [FROM identifier-1] ——— e BEFORE } ADVANCING IAFTER INPUT PROCEDURE ON [INVALID KEY imperative-statement] text—namé [literal-3} REPLACING NOTE: literal-1 BY literal-=2 word=1 — word=2 . A COPY statement may appear anywhere that a word appears in the COBOL source program, THE COBOL FORMATS A-9 APPENDIX COMPILER B IMPLEMENTATION LIMITATIONS - This appendix describes the 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 g ~ the implementation. limits of a language An implementation limitation quantifies facility that is supported by the system. Practical implementation limitations exist in every compiler; They result from the finite size of compiler tables, compiler data structure representations, and so on. Since the VAX-11 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 in the development of a COBOL program. IMPLEMENTATION 1. The Data Division of a COBOL program cannot be 1larger 65K Dbytes. A file description entry cannot be larger 32K 2. LIMITATIONS bytes. A DISPLAY statement operands. 3. 5. is cannot contain more than number of approximately data-name is sending definitions approximately in a COBOL in a COBOL 2000. The maximum number of procedure-name definitions program 16 | The maximum program 4, than than 2000, Because file description level-numbers can range from 01 to 49, level 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 6. A GO TO operands. DEPENDING statement can have (01 no - 48). more than - 16 APPENDIX C SOURCE PROGRAM LISTINGS This appendix contains compiler listings for two COBOL programs. The The such first, STATB, calls the subprograms. examples three demonstrate subprograms; some of the the second, features DOCATS, is one of VAX-11 COBOL-74, of as: ® The COPY statement o The COPY REPLACING ® The CALL statement ® The results of statement using the /MAP and /VERB LOCATION compiler qualifiers The circled numbers on annotated in the text. [clcRele Source Listing - The source | listings | indicate features that | are Features version The source number. the of the file, VAX-11] including COBOL-74 file compiler. type, or extension, and version | Date -and time when the compilation 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. | © © 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 1in error messade that offe displays show nested PERFORMs. Sequence number. If the source file wused conventional format (/ANSI_FORMAT), the sequence field (positions 1-6) appears here. Source text. the compiler. appears here This area contains the text that was processed by 1If a line of text was too long, only the part that was processed. © @ Q diagnostic message when Identification field. format, this area (positions The prints source text. a 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 on the Segment number line. (/VERB LOCATION qualifier only). Identifies program segment, or PSECT. Notice that this name; it is a consecutive number assigned to PSECTS during other programs. ® ¢ ® © ® compiler also it truncates a line of Offset the is not the PSECT all procedural compilation and duplicates the segment numbers in | (/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). Offset (/VERB_LOCATION qualifier only). Specifies the hexadecimal offset in hexidecimal bytes from the beginning of the program entry-point (STATB). Compiler diagnostic severity code. Describes the seriousness of the compiler diagnostic. This diagnostic is "informational", which means that the compiler can take corrective action. Diagnostic source line number. Identifies the source line to ~which the diagnostic applies. In this case, OPTIONS-AREA is defined as larger than CUSTOMER-FILE-ID; therefore, truncation | ® © occurs. Compiler diagnostic number. Use this number to find "Appendix D. Diagnostic message. C-2 Identifies the specific diagnostic. a description of the diagnostic in A one-line description of SOURCE PROGRAM LISTINGS the condition. © Data Map. Describes the data-names and file-names program. This section © used. L S) ® O® Linkage Name. Contains if the Section The level-indicator the 1level or the Data rData Division location. level-number that the or Division. data-name is a A directory compiler not data the beginning of data PSECT. offset is from the 0l-level. used item. location did not in 'the that Class. compiler Procedure a asterisks descriptor the DISPLAY CMP3 COMPUTATIONAL-3 INDX INDEX the COBOL class The the clause or implicit following abbreviations COMPUTATIONAL data-name. item. on class from following the of the PICTURE For is a this Linkage offset of data items, descriptor USAGE The DISP determines the the the to indicates because Division. CMP Identifies the is that the data-name was usage are data or abbreviations of item. level the used: The associated are used: TN [ with contains generate USAGE. Corresponds to data item description. of data-name defined Directory location. Identifies the hexadecimal data item's descriptor. For Linkage Section offse 'is t from the 0l-level. The RTS uses the on the Identifies the hexadecimal offset of the file or data-name from Section data-names, the operate in qualifier data-name. The file-name in or indicates item. file-name line wused /MAP | the preceding 'Source line. source only , Level. An appears ALPHA Alphabetic NUM Numeric AN Alphanumeric ANEDIT Alphanumeric Edited ®® © NMEDIT Occurrence to refer to level. the 1Indicates Edited the number data-name. of subscripts necessary sfiength.vapecifies the length of the data item in decimal bytes. Procedure Name Map. the program. This used. © Numeric Procedure-name. Division. | Describes the procedure-names that appear 1in section This is the appears name as only i it if the appears | /MAP in qualifier the is Procedure SOURCE,PROGRAM LISTINGS C-3 AY procedure-name is defined. source - which in line | the PSECT. Identifies the name of the executable code PSECT (program section) in which the procedure-name appears. PSECT name OB 0 @ 6 consists of the first 11 characters of PROGRAM-ID (padded on the right by "$" if less than 11), followed by a three-digit number. Offset. Segment-number. for the hexadecimal offset (distance) Corresponds to the segment-number An "S" section-name. indicates indicates "P" A Paragraph. in the in which the procedure-name appears. the section Section. paragraph-name. of the that that the procedure-name » procedure-name the | | header is a is a , Describes the segmentation for each Procedure Segmentation Map. This map appears only when the /MAP qualifier Division section. is ®®0 Specifies location of the procedure-name from the beginning of the PSECT. used. | Section Name. The name of the Procedure Division. Segment-number. header, or the | The implied section segment-number segment-number as it specified 00. appears in 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 first. . The size of the procedural PSECT in hexadecimal bytes. The size of the procedural PSECT in decimal bytes. Compiler-Generated generated by the olelele execution PSECT PSECTs. Describes the compiler (/MAP qualifier) initialization. name. The size of the PSECT in hexadecimal bytes. ‘The size of the PSECT in decimal bytes. COBOL RTS all of names the Lists Referenced RTS Routines. the by referenced are that qualifier) (/MAP routines form: the have routines RTS All code. compiler-generated C74$<name>. C-4 procedural PSECT's to provide run-time SOURCE PROGRAM LISTINGS | /4 ® o the Identifies line. Source 0000 © Data PSECT compiler PSECT Map. Lists the ‘nonexecutable (/MAP qualifier). PSECTs | the name. The size of the PSECT in hexadecimal bytes. The size of External the PSECT in Subprogram subprograms decimal bytes. References. (/MAP quallfler) Lists referenced the by "Error Severity Chapter Error 10 Code. describes Count. The severity level. the number Describes severity of the their errors SOURCE of statements serlousness codes and compilation names CALL program. ©© generated by of in all the errors. meanings. detected PROGRAM for LISTINGS each C-5 12«Jan=1979 @814A11S VAX*11 COBOLe=74 va.;;-ux T, FORMAT /NOANS /MAP /DEBUG=TRACEBACK /COPY_LIST /VERB,LOCATION Badee 204323 a@aau pedns IDENTIFICATION DIVISION, STATB, PROGRAM=ID, AUTHOR, ' R FRIED, DATE=WRITTEN, 18 JANUARY 1979, INSTALLATION, DATE=COMPILED, eeaas enae? 20408 * 2nee9 * * x onele 209013 *® Qeovld 2ea1s enaie eea17? ® 20024 vaaes ae226 orv27 A28 22029 22030 00931 202032 20033 4ed3d 20235 program generates various outputs, % The called programs aretl * * NAME * FUNCTION Generates an exception reports Generates mailing labels, EXCEPT DOCATS * * 1imit® Generates “credit CREDLM * letters, * % * *ttt*****ttt*t*t*************t**i**t****t*******t********* , 12=Jan=1979 ENVIRONMENT DIVISION, N AR AR KA AR R AR R AR ARARE AR RN RN RN RRRARRRRRNRRRRANR CONFIGURATION SECTION, SOURCE=COMPUTER, AR AR ARE R AR R AR INPUT=0UTPUT 20a38 ABA39 FILE=CONTROL, aeade R VAX=11, AR AR R AR AR ARRRR R AN R R AR A AR AR AR AR AR AR SECTION, SELECT CUSTOMER=FILE ASSIGN TO "CUSTOM" ORGANIZATION 1S INDEXED ACCESS MODE IS DYNAMIC 20041 @¢oade 20043 20044 RECORD KEY IS CUST=CUST«NUMBER ALTERNATE RECORD KEY 1S CUST=CUSTOMER=NAME FILE STATUS IS CUSTOMEReFILE=STATUS, 202a4sS J2046 20047 APAUA SELECT 7”349 STATEMENT=REPORT ASSIGN 20450 TO A "STATEM" FILE STATUS 1S STATEMENTREPORT=STATUS, 20451 20353 this program demonstrates develonment, - Depending on ocperator=specified options and the contents of dats recordsy the 1R Y) dna37 seuse ’ the effects and sdvantages of modular progranm 200190 20419 JONES MAIL ORDER COMPANY, Using called programss eea1l eraze vadel 20vee 20023 <j> /0BJECT=STAT B /WARNINGS & @ aRd18 STATB,COBJ4Y /NOCROSS, REFERENCE /LIST=STATB <:> 2120286 t***tf***t**it******itt*************i***t*****fi********fii** anasy 20455 anase 20087 DATA RIVISION, AR AR AR AR R AR R AR R AR R RAR AR R RN AR R AR IARA AN RN AR AR R AN RN AR 20058 APASS FILE SECTION, 0Ra6? ARVe6l FD CUSTOMER=FILE LABEL RECORDS ARE STANDARD VALUE OF ID IS CUSTOMER=FILE=ID, rrrr’rrt—rrrrrrrr—rr—ra AP A6 2 229263 LYY 22465 CUSTRC., COPY LYY ACA67 20Y68 QP269 APAT0 #1 CUSTOMER=FILE=RECORD, 23 73 CUST=CUST=NUMBER CUST=CIUSTOMER=NAME PIC PIC X(6), X(30), 23 23 CUST=ADDRESS=LINE=? CUST=ADDRESS=L INE=3 PIC PIC X(30), X¢32), 23 2RaTy aea7e pUaT3 arPAT4 n3 eea7s X 20276 y PBaT7 20078 2AR3A79 AAL8Q Y AMNa 2dd82 a3 "3 ¢3 C-6 SOURCE PROGRAM LISTINGS PIC CUST=ANDRESS=LINE=] CUST=ADDRESS=ZIP=CODE PIC CUST=PHONE, aY 25 2% CUST=PHONE=AREA=CODE CUST=PHONE=EXCHANGE CUST=PHONE=LAST=4d CUST=PHONE=NUMBER REDEFINES CUST=PHONE CUST=ATTENTION=LINE CUST=CREDIT=LIMIT : X(30), X(S). PIC PIC X(3), X(3), PIC PIC PIC 9(19), X(20), . 9(18) V99, PIC 9C¢4), TN STATSB IDENTs e e e nrec 22983 23 00284 CUST=HEADER=DATA a5 FILLER eovas as eod8e 00087 23 CUSTeOWE=AMT 2pQes8 03 CUST«BQUGHT 20089 20490 22091 00092 20093 23 200896 20097 81 83 FILLER FILLER eeiae ®3 0o101 FILLER @3 FORMeNAME, 20099 @3 gatae 00103 21 oaiae PIC X(S), X(38), X(1), X(5), X(es), 2S5 FILLER @S FORM=DATE PIC e2114 00115 PIC PIC REPORTeYTD PIC 2,222,222,279,99, ¥3 @3 @3 STATEMENT=DATE FILLER STATEMENT=CAPTION PIC P1C PIC X(12), PIC 2,222,222,229,99, @3 LA EE R STATEMENT=BALANCE RS el e WORKING=STORAGE R R R Y Y @1 o1 CUSTOMER=FILE=STATUS STATEMENT=REPORT=STATUS @1 gaiee o127 21 TODAYS=DATE TOR REDEFINES TODAYS=DATE, @3 TODAY=YEAR 3 TODAY=MONTH @3 TODAYeDAY VALUE o128 geie9 1 00134 02135 eA13e 20137 00140 814y 00145 2t t TODAYeMQONTH 83 FILLER @3 TODAY=DAY 83 ®3 FILLER TODAY=YEAR PIC PIC PIC PIC 29, PIC PIC X(1) VALUE "/», VALUE "/», PIC 9(2), PIC PIC X(1) 9¢2), X(58) 3! PIC PIC 2(5), 21 YTO=CATALOG=MINIMUM PIcC 9(1@) VALUE lo@dee, el EXCEPTION=INDICATORS, 21 OPTIONS=AREA, 23 OPTIONS=AREA=CHAR el A=COUNT o1 OPTION=STORAGE, @3 OPTIONeENTRY QCCURS 8 OPTION=VALUES REDEFINES OPTION=STORAGE, 23 FILLER 88 WANT=STATEMENTS VALUE 1 83 FILLER 88 WANTeINVOICES VALUE FILLER 23 B8 WANTeALL~CATALOGS VALUE 1 23 FILLER | ee149 20150 00154 @oiss ea1se AR DISPeMESSAGE, 23 FILLER @3 DISP=NUM eeL46 02151 va1se 20153 S R PIC ee147 02148 R STANDARD=MESSAGE ve141 pR142 20143 Y 21 00138 00139 Y PIC "CUSTOM,DAT", TODAYS=REPORT=DATE, @3 e PIC PIC 0125 eeied X(32), SECTION, CUSTOMER=FILE=]ID gaile xX(19), @3 21 0131 09132 2@133 X(1%8), 20222,y222,229,99, PIC FILLER 20118 0e123 X(6), Xce)., PIC 91 vetle 00119 00120 ee121 o122 9(18)V99, 9(4), 9(4). PIC PIC REPORT=CREDIT @3 ee113 S enlte eoi17 9¢12) V99, RPIC PIC S.R-R-EO ?3 FILLER 03 pa1e8 eeio9 eaile eeitt PIC PIC PIC ADDRESS=ZIP 00124 oa1e7 : ADDRESSeWINDOW @3 0010S X(6), 9(6), PIC CUST=NEXT=PAYMENT«SEQUENCE @3 20098 PIC PIC STATEMENT=REPORT LABEL RECORDS ARE STANDARD, STATEMENT=REPORT=RECORD, 0e094 20Q9s CUST=CREDIT=LIMIT, CUSTeNEXTeORDER=SEQUENCE 23 FD REDEFINES NEXT=ACCT=NUMBER a1 peis? 29158 2e159 20160 gelel 2plée gaie63 23 EXCEPT!ION=INDICATOR NCCURS @ NCCURS 30 oRied vR16S 23 20166 oeler veies 23 X(38) SPACES., VALUE PIC 9(1), PIC X(1), PIC 9(1)., PIC THRU PIC THRU PIC THRU 9(1), 9, 9, 9, PIC 9¢1). 9¢1), | 9¢1), WANT=SOME«CATALOGS VALUE 1 THRI} 9, FILLER 1 PIC 9¢1), 88 WANTeCREDIT=LIMIT=LETTERS VALUE 1 THRU 9, FILLER PIC X(3), 01 RECORD=COUNT PIC 9(5) STATEMENT=COUNT VALUE 71 @, PIC 9(5) VALUE @, vA169 en170 21 eei17y @1 SPACES, 9¢2). PIC 88 VALUE INVOICE=CQUNT CREDIT=L IMITeCOUNT PIC PIC SOURCE 9(S) 9(5) VALUE VALUE PROGRAM @, @, LISTINGS C-7 @1 20172 an173 ttt***tifi******t****t*tti*tt*tfi*flt**t*fl*******t**t****ti**i erL74 021798 PROCEDURE an176 w177 DECLAKATIVES, N CUSTOM=ERROR SECTION, 2 182\1° USE ) ale 2002¢Y (r22¥2p24) DISPFLAY : paglan (22000024) USE AFTER STANDARD ERROR PROCEDURE ON CUSTOMEReFILE, 27183 SHREGIN, AN1RY DISPLAY "I=0 ERROR ON CUSTOMEReFILE, CODE (" vn185 CUSTOMER=FILE=STATUS we18se STQP H pepA2y (r2A00QdW) USE : AAdden (AQ2008064) DISPLAY : STOP dvles B2189 dvi9e H 4 aveeq SBEGIN, (7A002060) DISPLAY "I=0 ERROR ON STATEMENT=REPORT, CODE (" 201935 STATEMENT=REPORT=STATUS bL (N0PR2082) STOP WA19é6 Ae197 END Ar198 24199 preie aeeet Ap202 Bp203 * ® * START=UP«HOUSEKEEPING SBEGIN. @3 evR0ey (2008009C) MOVE H 23 #ORd18 (PORJLARY) 3 03 evucuy (AV2BAVEND) @209 ACCEPT H 03 @d8v68 MOVE eea07s (A0P00114) ve2ie MOVE : n3 eeRosa (needeied) @Ep; 1 86217 0371 MOVE, H if DISPLAY A02994 HIGH ORDER " none RECEIVING FIELD ENTER CUSTOMER SPACES 2n219 @ a3 @2AVAY DISPLAY 3 23 LY DISPLAY 3 23 pegona DISPLAY & 03 BRROES . DISPLAY 3 a3 peaien DISPLAY 3 03 o118 (42909184) ACCEPT : 23 en@ailn (220001CC) MOVE : 23 e0G140 : 23 22pi4c a3 eua1sc CIF DISPLAY C-8 20224 - (V0ABa154) eP225 (P0ARR16C) 20226 (0ARAA184) an227 (30@@219C) 89228 28229 @n23p (20202010C) ae231 (020PR1ES) ev232 (00PYP1FS) 88233 entered, FILE NAME (OR CR)", | TRUNCATION, MOVE ve218 DISPLAY {8 MOVE OPTIONS=AREA TO CUSTOMER=FILE=ID (r200v132) * TO OPTIONS=AREA, options Get » 20220 on221 80222 po223 (PBLYR13C) OPTIONS=AREA, IF OPTIONS=AREA NOT = SPACES PR217 POSSIBLE a3 TO ACCEPT OPTIONS=AREA, an2is 23 FROM DATE, Get CUSTOMER=FILE name, Use default * 20214 (RoPRG124) ? SPACES " (PPCABVVEC) if 49, SECTION TODAYS=DATE housekeeping MOVE CORRESPONDING TDR TO TODAYS=REPORT=DATE, 22228 aee1e 20213 eepesa ACCEPT Baee7 vee1o apett 23 This section perterms functions only, pa2us 2 H DECLARATIVES, 20206 ACCEPT DISPLAY RUN, t*tt********i**t****t*****t**tiit**i****t*****t**ti****i**i ve2ad MOVE SECTION, USE AFTER STANDARD ERROR PROCEDURE ON STATEMENT=REPORT, 20194 20195 STOP RUN, STATEM=ERROK peiay ae192 e0ALen ~ H)". pal187 @2 DIVISION, *t*t**t**tt***tt*t**t*fif************fi*l*****tt*i**t****fi*** Jei78 an179 prl18¢ ACLRLZ 9(5) VALUE @. PIC CATALUG=COUNT from store results, * option DISPLAY " imput, ENTER the operator and Ignore mon=standard ' QPTIONS:", DISPLAY " § =2 Print statements‘p CISPLAY " I = Print 1nvoice'”;‘ bISPLAY " CA 3 Ma{l al) cate!oééfio DISPLAY " CO = Mai{l selective éataiéds”DISPLAY " CL = Credit Vimit lettért'. ACCEPT OPTIONS=AREA, MOVE ALL ZERO TO OPTION=STORAGE, Ik OPTIONS=AREA s SPACES SOURCE PROGRAM LISTINGS DISPLAY "D{screpancy Report Onply" GO 3 nea174 MOVE 23 @oa17cC (24000219) 20234 (220QR218) GO TO CONFIRM=DPTIONS, 22238 INSPECT 23 pea188 (20000224) 28236 PR237 20238 P39 @240 20241 TALLYING FOR ALL "S" FOR ALL "1 FOAR ALL "CA" FOR ALL "cCO" FOR all "CL", INSPECT OPTTIONS=AREA OPTION=ENTRY (1) OPTIONSENTRY (2) OPTION=ENTRY (3) OPTIONSENTRY (4) OPTION=ENTARY (5) 20242 iF 23 P0B248 (QVPRR2EY) DISPLAY 23 000258 (Q20002F4) STOP 93 paga7e (r2ABR3AC) DISPLAY a3 00deT4 IF 23 pogesc ¥a243 DISPLAY 20244 (p00eRR312) 2m247 (20200328) DISPLAY o3 BBO2AC IF 23 e¥0R2C4d (22000360) DISPLAY 23 eeg2E4 IF 03 @eeeFC- DISPLAY a3 p0831C IF 23 08334 (22003388) ¥p253 (2000a3DQ) 20@354 (PBRBR3FQ) 0250 (po0RO380) 20251 (20022398) 20252 83 OPTIOMN=STORAGE STOP 20245 20246 20248 (000@B348) 2n249 DISPLAY IF 20254 DISPLAY 23 DISPLAY e3 00036C (20AQA428) pealscC (00P20428) 28256 DISPLAY 23 #0a3AC (P20004483) ACCEPY 03 PBA3CY 20260 (0000Q46R) IF a3 P2p3p4 (0000Q472) DISPLAY DISPLAY IF AANT=ALL=CATALOGS DISPLAY (e@0004B8B) IF WANT=SOME=CATALOGS DISPLAY IF " PA@A43C STOP e3 200454 (0o0Ra4Fa) IF 03 00R458 (300024F4) DISPLAY e3 poQ478 (A0220514) OISPLAY " Credit GO (a@@easac) 0e0490 IF 23 @PQUAC (30@00548) av272 "AQBQRTED MOVE IF @ " TO DISPLAY (002A0580) OPEN 03 . 00Q4F 4 (2290805902) ee27e OPEN INPUT MOVE 03 ednsSea MOVE "00020@" 20274 p0275 OPEN e3 9022528 (00@205C4) (1) BY INVOICES = mot implemenmted" (2), ACCEPT statement message TO CUST=CUST=NUMSBER, OPEN AR AR R R OUTPUT AR AR AR MAINLINE CR" CUSTOMER=FILE, er280 00281 or STANDARD=MESSAGE, START CUSTOMER=FILE KEY IS » CUST=CUST=NUMBER, 20285 (P0@0ASES) 20286 @0287 MN® ®nN" eg278 28279 20282 29283 20284 AND OPERATOR" OPTION=ENTRY "Enter QOB4EY - 0eoS5ac "Y® WANT=STATEMENTS 23 a3 = RUN, ACCEPT START NOT CONFIRM=OPTIONS, CISPLAY 29273 (2200259C) 20277 (20PP0S5A8) (1) IF WANT=INVOICES 80279 ee271 (200030S68) TO STOP 20269 03 letters", OPTIONS=AREA, DISPLAY 00266 2267 MOVE 1imit DISPLAY "CONFIRM OPTIONS: (Y)es of (M)o¥, 28265 00268 catelogs", CONFIRM=QPTIONS, (0020040D8) 03 2Pe00e Selected WANTeCREDIT=LIMIT=LETTERS 00263 @64 24 catalogs", OPTIONS=AREA=CHAR 20041C READ A)) IF 23 gea4cc " OPTIONS=AREA=CHAR IF . 03 " Inmvoices", IF (920004RQA) DISPLAY " Statements", ACCEPT 002414 recoanizea" "Selected options:", 9262 03 DISPLAY options RUN, 08261 60 ZERO WANT=INVOICES IF 28257 00258 20259 ALL IF WANT=STATEMENTS 20255 44 "No =3 . \ STATEMENT=REPORT, R AR R AR AN R AR R AR AR A AR RR R AR A AR R AR AR R kAR Rk SECTION, SBEGIN. READ CUSTOMEReFILE AT END NEXT SOURCE PROGRAM LISTINGS C-9 a4 PegR14 24 22aeiC IF 4 Q0028 (2@@2aSFC) 20288 (00Q0a624) an289 00290 er291 pE292 (PVo0R612) PERFORM 24 poER3s8 (00@00629) o4 200048 (p00B0630) 9000ABC 203148 MOVE 24 @000Cs IF 4 020004 MOVE 24 @P0BEY IF 24 200100 MOVE 04 poai0 IF o4 20013C MOVE o4 00214C 1F Q“ P00168 24 e0e178 IF o4 000194 MOVE 24 000144 ELSE o4 8901Ca (e@e0e74A8) IF 24 0001C8 (e2200780) MOVE a4 0MR1ES 1F a4 200204 CALL 24 pURely (pveev700) 2a32s (P@@RQ@7EC) 20326 (2@0027FC) - 00333 GO 24 e0Q274 GO 04 20ae7C » » % ADD "DOCATSTM § TO USING CUSTOMER=FILE=RECORD CATALOG=COUNT, Check for customer’s discrepancies {n record. the MOVE ALL ZERO TO EXCEPTION=INDICATORS. IF CUSTeCUSTOMEReNAME = SPACES MOVE | TO EXCEPTION=INDICATOR IF CUST=ADDRESS=_LINE=1 IF CUSTePHONE OR = SPACES CUST=ADDRESS=ZIP«CODE MOVE MOVE | 1 TO TO 3 MOVE | TO NOT (1), > "Qodea" EXCEPTION=INDICATOR (2), SPACES EXCEPTION=INDICATOR IF CUSTeCREDITe_LIMIT NOT (3), > @ EXCEPTION=INDICATOR (4), IF CUST=0ONE~AMT > CUSTCREDIT=LIMIT MOVE 1| TO EXCEPTION=INDICATOR (5S) ELSE IF CUST=OWE=AMT MOVE | TO > CUSTeCREDIT=LIMIT EXCEPTION=INDICATOR F EXCEPTION=INDICATORS CALL NOT = « 2,8 (6), ALL ZERO % "EXCEPT" USING CUSTOMER=FILE=RECORD EXCEPTION~INDICATORS, % Gemerate a “credit 1imit letter’ the customer has exceeded or ahout to exceed hig limit, {if {s IF WANT=CREDIT«LIMIT=LETTERS AND CUST=OWE=AMT NOT € CUST=CREDIT=LIMIT * @,8 (2020285C) GO 20337 02341 for ¥ CALL 08334 20335 02336 (o0P22864) label {t, AN (0200081C) ¥e3ss 2e339 N340 print WANT=ALL=CATALOGS OR 20327 802234 need a3 mailing WANTeSOME=CATALOGS ea324 22339 we catalog, CUST=BOUGHT NOT € YTD=CATALOGeMINIMUM 00323 ‘03314 00332 ad - 00322 00328 20329 IF IF 20312 MOVE STATEMENT=COUNT, It (P2000680) 83311 (Ar0R2026BC) (200206CC) 20313 (0022U6ES) 00314 22315 (po200708) 20316 (20002724) 00317 (00002734) 00318 (e2R02750) ‘00319 (e020802769) 02320 (2000277C) 20321 (2200278C) required, PRINT=STATEMENT TO a |] 04 {f % 0000A4 { ¥ a4 ADD ADD % CALL PERFORM (228009063C) en320 20301 20322 09303 208304 (00@0068C) ge3as (020V06A4) 2@326 evl3a?7 go308 02329 statement % 000054 END=PROCESS, IF CUST=0OWE=AMT > @ 00294 % 24 TO RECORD=COUNT, Print 20293 0a295 0a29e 00297 pe298 08299 TO ¥ IF { » ADD GO ADD TO DO=CR, GO get » 60 GO TO the mext record, MAINLINE, en3d4e AP 343 CALL a4 00@28C (a0002874) ADD 24 e0R2A4 (a0a20288C) vn3dy 20345 C-10 SOURCE CALL "CREDLM" USING CUSTOMER=FILE=RECORD, ADD PROGRAM LISTINGS | TO CREDIT=LIMIT=COUNT, GO 24 e04280 (Gved0898) 20346 00347 00348 we3d49 22350 e@a3sy 28352 22353 GO TO RN . ) RN N @5 022008 (avo00888) S eR008C (2002308C4Y) MOVE es 000018 DISPLAY 2S ere03s MOVE 25 ©02050 MOVE es PueRsc (2000@280C) 2n3S59 (200008F2) vpl360 (a2020908) 29361 (02000914) DISPLAY 05 220270 (pe@on928) MOVE 2s gooess (P22200940) MOVE 25 @Vpa94 DISPLAY 2s Q000A8 MOVE 25 P0eRCA MOVE 2s PPeRCC (02008960) 20366 (00202978) en3e67 - (@0eee9ay) es P220EP (2002@72998) DISPLAY 05 @RBOFA 25 PAR1Y DISPLAY es - pYa11s STOP 5 aco13am A6 (P020BARY) 20384 MOVE a6 eaemac (PVV0RA1D) WRITE 26 gepea18 (PRRIRALC) MOVE aé 0oeanln (P2P2RA34) 06 peewB3c (P2QVAALDR) (02228A4C) Q389 (PPAANRASS) 22392 (PPR2RALY) MOVE 20385 22386 21387 an3a8 MOVE aé ARPB4UA MOVE A6 breasy NRITE a6 pRoven MOVE a6 eBaLTC MOVE a6 pAaA88 (2000P0A82) 0392 (PECHOAARC) 6 P20V29y (A0PVUAG8) a0391 2p393 MOVE Ba394 NRITE ] 22Q00AnN (PorovAAL) 2e395% MOVE 26 avgenc (200VRACYH) 20396 MOVE Aé geyucs WRITE 26 anpoQDu (200802ACC) 2a397 (PrUPRQADS) MOVE 26 A QUPBF (AIVMDBBAFY) ep398 22399 DISP=MESSAGE, DISP=MESSAGE., MOVE "INVOICES" TO DISP=MESSAGE, MOVE INVOICE=COUNT TO DISP=NUM, DISPLAY DISP=MESSAGE, " MOVE "CATALOGS® TO DISP=MESSAGE., MOVE CATALOG=COUNT 28368 gnQdon TO TO DISP=NUM, MOVE STATEMENT=COUNT TO DISP=NUM, DISPLAY oB364 (A200094C) 20365 2p383 COUNT" MOVE "STATEMENTS" TO DISP=MESSAGE, 20363 - (p2000989) 2R379 (P2000R98C) 20371 (20000909) @2372 (P200P09ES) Pe373 02374 2937S 228376 ea37?? 2e378 ©0379 0n380 "RECORD DISPLAY DISP=MESSAGE. Q@362 AR381 ¥P382 MOVE MOVE MOVE RECORD=COUNT TO DISP=NUM, DISPLAY DISPeMESSAGE. 20369 MOVE MOVE 47, CLOSE STATEMENT=REPORT, 20358 aneP24 SECTION CLOSE CUSTOMER=FILE. 00357 (2¢ooeaDp) 2s AR NRARRRRARNRAN A, has been completely significant counts, _ ENDSPROCESS SBEGIN. pA3Se MOVE The CUSTOMER=FILE processed, Report . 20354 CLOSE R RN AR AR R RN AR R R AR RAR RN v * * 30355 CLOSE MAINLINE, R AR Rk MOVE "CREDIT LIMIT LETTERS" TO DISP=MESSAGE, MOVE CREDIT=LIMIT=COUNT TO DISP=NUM, DISPLAY STOP DISP=MESSAGE, RUN, **it**fifi*****t*****iit************'fi'fi*t**fi***i*tfi***tfif***i . This section generates a statement . * ® for the current CUSTOMEReFILE ® record, * PRINT*STATEMENT SECTION 48, SBEGIN MOVE SPACES TO STATEMENT=REPORT=RECORD, MOVE "STATEMENT® TO FORM=NAME, WRITE STATEMENT=REPORT=RECORD AFTER ADVANCING PAGE, MOVE SPACES TO STATEMENT=REPORTSRECORD, MOVE CUST=CUSTOMER=NAME TO ADDRESS=WINDOW, MOVE "DATE:" MOVE TODAYS=REPORT=DATE WRITE TO FORMeNAME, TO FORM=DATE, STATEMENT=REPORT=RECORD AFTER ADVANCING | LINE, MOVE CUST=ADDRESS=LINE=1 TO ADDRESS=WINDOW, MoVE "ACCT:" TO FORM=NAME, MOVE CUST=CUSTNUMBER TO FORMSDATE, wRITE STATEMENT=REPORT=RECORD AFTER ADVANCING 1 LINE, MOVE SPACES TO STATEMENT=REPORT=RECORD, MOVE CUST=ADDRESSeLINE=2 TO ADDRESS=WINDOW, WRITE STATEMENT=REPORT=RECORD AFTER ADVANCING 1 LINE, MOVE CUSTeADDRESS=LINE=3 TO ADDRESS=WINDONW, SOURCE PROGRAM LISTINGS C-11 né 29Q0FC (PoPROBRY) he ava1eH. (AeAYeBAC) enapp A04ny MOVE 26 0BA124 (220n0B28) Anda2 MOVE 76 MOVE 26 aealdy WRITE weé QLv158 (P00 ARBUR) 2040y (nve@nBsC) Aé 620174 (rAr2ABT8) MOVE MOVE . (p2rduB14) 2A4RT 2042S VAUne 26 MOVE MOVE P13 @ee6 TTILE (A2@YvBadg) p218C (APRVABYY) gantana (edepeBAd) a6 IF né MOVE asé MOVE MOVE e0@1AC (P¢RYRERY) ero1cs (va@avvBCC) vad1l 500104 (PeeY@RLA) QUALEY (20@2MBES) LYY 2241F8 MOVE Ae vo@e18 ELSE né anp224 (20d0p2C28) MOVE 26 m@eecC (Pve20C39) 26 pvp238 MRITE MOVE 0419 (2020eC3C) 0C225C (wo00vaCe0) end24q C-12 "BALANCE DUE"TM TO STATEMENT=CAPTIUN, MOVE SPACES TO STATEMENT=REPORT=RECORD. IF CUST=OWE=AMT > CUST=CREDIT=LIMIT MOVE "#% CREDIT LIMIT EXCEEDED #x" TO ELSE STATEMENT=REPORT=RECORD | IF CUST=QWE=AMT > cusr-cngoquLlnxr.r 2,8 MOVE "CONSIDER AN INCREASED CREDIT TO STATEYENT=REPORT=RECORD LIMIT, * ELSE MOVE STANDARD=MESSAGE TO STATEMENT=REPORT=RECORD, vwRu20 agdes 26 ADVANCING 8 LINES, WRITE STATEMENTREPORT=RECORD AFTER ADVANCING 6 LINES, AR4U17Y 20418 an421 B4 EXIT | WRITE STATEMENTeREPORTRECORD AFTER ADVANCING 4 LINES, N " REPORT=YTD, MOVE SPACES TO STATEMENT=REPORT=RECORD, -aed14 RAAIFA TN MOVE CUST=OWE=AMT TQ STATEMENT=BALANCE, n6 ”_I# CUST=BOUGHT wAdEs (PAPY2BF4Y) Qa41s (A2QuPBFC) ¢a416é (dveeesciC) a6 TO STATEMENT=REPORT=RECORD, WRITE STATEMENTeREPORT=RECORD AFTER wrgy3 ELSE SPACES MOVE CUST=CREDIT=LIMIT TO REPORT=CREDIT, MOVE TODAYS=REPORT=DATE TO STATEMENT=DATE, 041D mMOVE WRITE STATEMENT=REPORT=RECORD AFTER ADVANCING 1 LINE, A0da7 PRU4PY. nRITE. MOVE CUST=ADDRESS=ZIP=CODE TO ADDRESSeZIP, SEXIT, EXIT, SOURCE PROGRAM LISTINGS 4 MOVE WRITE STATB I0ENT; DATA NAME CUSTOMEReFILE - STATEMENT=REPORT CUSTOMER=FILE=RECORD CUSTCUST=NUMBER CUST=CUSTOMER=NAME CUST=ADDRESSeL INE={ INE=2 CUST=ADDRESS=L CUST=ADDRESS=LINE=3 CUST«ADDRESS=21P=CODE CUST=PHONE CUSTePHONE=AREA=CODE CUSTePHONE=EXCHANGE CUSTePHONE=LAST=4 CUST«PHONE=NUMBER INE CUSTATTENTION( CUSTeCREDIT=LIMIT P CUSTeHEADER=DATA NEXT=ACCT=NUMBER CUSTeOWE=AMT CUSTeBOUGHT CUST=NEXTeORDER=SEWUENCE CUSToNEXT=PAYMENT=SEQUENCE STATEMENT=REPORT=RECORD ADDRESS=WINDOW ADDRESS=Z1P FORMeNAME FORMeDATE SeReoRe? . y S=ReR=3 STATEMENT=DATE STATEMENT-CAPTION STATEMENT=BALANCE CUSTOMER=FILE=STATUS " STATEMENTeREPORT=STATUS CUSTOMER=FILE=ID TODAYS=DATE TOR TODAYeYEAR TODAYeMONTH - TODAY=DAY ' TODAYS=REPORT=DATE TODAY=MONTH TODAY=DAY TODAY=YEAR _ STANDARDeMESSAGE DISP=MESSAGE DISP=NUM YTD=CATALOG=MINIMUM EXCEPTION=INDICATORS EXCEPTION=INDICATOR OPTIONS=AREA OPTIONS=AREA=CHAR A=COUNT OPT.IONeSTORAGE OPTION=ENTRY OPTIONeVALUES . RECORD=COUNT STATEMENTeCOUNT INVOICE=COUNT CREDIT«LIMITeCOUNT CATALOG=COUNT nB8344:1S VAX=11 COROL=T74 V4, =] AP SCURCE LINE DOIV DIR LOCN Loc Aenel 002024 0dea2? A BUO1F Adracy 2893 20068 20069 eRa7® P2B71 pear? PPa73 @eev4 20075 @eaTe eee7r7 aea7s 2Ra79 AeA8] 0ne82 Pees3 27285 aee8e TLLY 20090 00091 29895 USAGE A 20Q1F 000200 GPR21E a0@23c 000254 A0n278 @20270 208270 YELFLY PAu283 2v2270 020287 pLB298 pBV298 paa9eC vaeQy1sd nega24 W LIRY 800 3C @agal AAKANR DISP DISP DISP DISP CLASS 0CC LENGTH ® @ waz2a5 AN e Lg% na pa ge AN 1% AN ea AN AL 3eal AN pa Bara3 NUM ') waaad NUM 1] aeat) AN ne naagy AN AN AN Haane wREAla QY3 Rk khhk DISP DISP DISP DISP DISP DISP DISP DISP DISP ARPR6nR NISP NUM n@ Aguie 'TT2E 2 AN PA02AT popReC DISP DISP DISP NIJM @ Y aeenes PeAnT78 DISP NUM Ak kddh X DISP NUM A2 Z'% 8 1 NISP NUM W6v283 PVA25F p¥02C3 Padays geausd wkkhwk 23383 Rikdkd KAk RN @202CA 20p@84 DISP 0vp97 0B2CF pQ@90 DISP 20099 @0V2EE oeap9C DISP A3234C ee103 0eR312 ee1es 0202C4 ee107 822209 Pr129 BU02F3 @811 8YB2CA Pe112 PUB2CA T IRY AYR2ED ee11s 220302 00121, 00031C eey22 a9e31E pe123 eve320 @125 20u32E an126 A@e32€E edy27 Yea32E @128 eee33o @129 P@0332 nv130 PBV334 28131 P22334 o133 200337 20135 000334 eA137 P2a33C 22139 20036E @a141 #2038C @@143 020392 20145 20039C 0A146 e2e39C 2P148 0303Ae PA149 @203A6 2151 @263C4 #2153 @e03C6 20154 PAv3C6 08155 @v03C6 20168 @B23CE 22169 @2e3D4 00170 PA23DA 22171 p023E0 70172 ARO3ES ee1ay REPORT=CREDIT REPORTYTOD e 12=Jamn=1979 ® a12086 d02GAB8 2004084 R E XX & A000CA e2@pCC AR RR neaaDs edueEY poQaFd A0Q0FC o0@1@8 veayty vweal12a4 DISP DISP DISP DISP DISP DISP DISP DISP DISP DISP DISP DISP DISP paeyecC DISP @aun138 DISP 200144 DISP Ad3150 OISP weayscC DISP 202168 DISP penL174 DISP LT BE-T) DISP 20018C DISP ¥ea198 DISP weat1ad DISP @@2i802 200218C gowvics ACALES ¢dv1Fd e0e214 @0p22¢ ggaec ek kkh DI§P DISP DISP 0ISP DISP DISP DISP DISP DISP DISP vop2Ba 2902C4 DISP 220200 DISP vap20C MQQES DISP DISP AN NUM w9 09 weuln PpulQ MAA0S neotya vooye woete npmi2 ey pgand AN gpesa AN QR34 AN AN, WaRAasS "eeid AN arQ08 AN uaes? NMEDIT NMECIT voaaie AN ARATY e AADL AN @éuele AN NMEDIT ?@al3e 20016 AN “nn2 AN Abwde AN pani1d NUM agungde AN U/ JelnY. . NUM dorn gana venae NUM NUM AN wanes NMEDIT 20002 NUM Q202 NUM agaae AN Jeasae AN A0335% wanas NMEDITY NUM . AN NUM AN ageta 2ea10 ne401 20039 AN woaal NUM “denee AN 2008 NLIM NUM "44021 deaos pRaas oaras d000as NUM aenes NUM neaRs AN NUM NUM SOURCE PROGRAM LISTINGS C-13 {2nJan=1979 081408115 J12086 @, 22190 pa192 0a2es Ra206 20259 SBEGIN . : START«UP=HOUSEKEEPING SBEGIN CONFIRM=«OPTIONS OFFSET INE ea182 02184 CUSTOM=ERROR SBEGIN STATEMeERROR MAINLINE ra284 SBEGIN DO=CR END=PROCESS SBEGIN PRINTSTATEMENT SBEGIN SEXIT 20285 Pa34y 28354 935S 20382 023873 2423 STATBSSS8355001 STATES$3$555001 STATBS$S5555002 STATBSSS$$58002 STATBSSS5885003 STATBSSSS555003 STATBSSS5588003 STATBSSSSSSSauY STATBSSSS5$5004 STATBSSSSSSS204 STATBSS$5535005 STATBS$553$5205 STATBSS$88$8S006 STATBSS$%$8355006 STATBISSS8S8%0Q¢e ag00qe A2000a @ SECTION 229000 NAME SEGMENT 2828929Q apa000 d02002a n02000 0a2eae 700000 aan2sC MAP NAME NO, : 49 MAINL INE g STATBS$$5855294 END=PRQCESS PRINTeSTATEMENT 47 48 STATBSSSS5550a5 STATBSSS5838a%6 STATBSS$$355022 2AP@3C 2erRe60 STATBSS$5$5500a3 20254C aaa2Do 1356 oe720 C-14 a8my4acC 200270 12=Jan=1979 GENERATED PSECTS ‘E’ SI1ZE ‘!} eea024 SOURCE a0a3e6 PROGRAM ‘I’; Aeae6n olamea<::> - ‘I’ SIZE 2d203C STATBSSSSSSSAa1 STATSB STATB3ISS$38%5%5000 V4,008e01 5 nea28C START=UP«HQUSEKEEP ING NAME VAX=13 COBOL=T74 ) ] eanoee 2033AC ea e V4,00-=01 @09 A00000 CUSTOMeERROR STATEM«ERROR COMPILER SECT 12=Jan=1979 08340115 012086 SEGMENTATION IDENT SEG @o%000 STATS IDENT: VAX=11 COBOL=74 STATB,CO0Bs4 MAP PSECT SOURCE NAME V4,00=01 O » P » NAME COBOL=74 VAX=11 STATB,COBj4 w PROCEDURE [ = STATB IDENT: LISTINGS ?e332 AR624 28140115 STATB.COB’“ 81ATB IDENT; | fif STATB IDENT: CT4SXOPEN C74SXEDIS C74SXINTD C743CZ0OLE C748CSTGT CTUSMGNG 200406 e203aC CT4S$XSTAR CT4$XSTPR C748CZ0LT - CTUSCFSEQ CT48MCAD C748AMG3P VAX=1{{ COBOL=74 Vi, 00=04] VAX=11 COBOL=T74 STATB,CO0B34 Vid,fa=0a1 VAX={] VQ.@U*O! C748XCLOS CT4SXINSH C748CGZLY C748CSTNE C74SMJUSL CT48SBIXY 12=Jan=1979 A814011S 12=Jan=1979 N8142215 U STATB.COBy 2gnaee 01030 08780 TTLY) STATBSSSSSSSLIT 2000 1A eeoeCe 08e26 8e704 STATBSSSSSSSADT 0@02De 200009 ee720 STATBSSSSSSSLTD STATBSSSSSSSUSE 2eo020 ooe0e0 eaoeaed $CBXAY $CBFO1 0eepa eeas2 20002 20004 Ve . C7T4SXWRIT C74SXENDP CT4SXINIT C748CSTEQ C748CGPGT C748AAF2D 15!» SIZE (::) NAME , Vi, pa=01 MAP STATBI$SSSSSDAT STATBS338S380DD STATBS3SSSSSARG STATBS§8SSSSWRK ’ C74SXREDN C748XG0O C748XACCS C748CGPLE C748C2D6GT CT4SMGLA @12086 DATA PSECT B VAX=i1 COBOL=74 STATB,C0814 REFERENCED 0TS ROUTINES CT4SMGNE C74SXEACC CT48XINTG C74SCGPLY CTU4SCFSNE CTUSMCFST CT4SXPRF{ ( {2=Jan=1979 08140115 2120286 <~ S1ATB " IDENTs EXTERNAL DOCATS @12086 SUBPROGRAM REFERENCES CREDLM EXCEPY 12=Jan=1979 2814815 STATB IDENT: SEVERITY I 0f120@86 ERROR COBOL=74 SYATB.COB:& COUNT 1 SOURCE PROGRAM LISTINGS C-15 DOCATS IDENT: ' {2=Jam=1979 212086 @834d1122 VAX=3y ' /NOANS T, FORMAT JCOPY, LIST /MAP /NOCKOSS REFERENCE /VERBR, LOCAT JON COBOL=7d4 DOCATS,.COByb /LIST=DOCATS /WARNINGS /ORJECT=DOCATS /0EBUG2TRACERACK aAIA] IDENYIFICATION 0RBuR PROGRAM=TD, 20373 . DIVISION,- POCATS, Aeany : DATE=wRITTEN, ARAANS 14 JANUARY 1979, DATE=COMPILED, AAd26 ' andpy * This sub=proaram A0dne * for each CUSTOMER=FILE APAA9 APdL R * * the callina prints a record mafiling passed - label from program. 20911 paale {2=Jan={979 AR ENVIRONMENT , DIVISION, vAa14 . d@d1s CONFIGURATION 2a816 ~ 0ed17 SECTION, SOURCE=CCOMPUTER, VAX=ii, UBJECT=COMPUTER, VAXw1{1, 42218 22019 ' INPUT=QUTPUT FILE=CONTROL, el SELECT 20v2°2 A0223 : LABEL=REPORT ASSIGN TO "LABEL" ' FILE dvded STATUS 1S LABELnREPORT-STAIpS. _ 2225 w26 voae7 Lo DATA DIVISION, 4 FILE SECTION, 22028 —_ ' 2Qd29 FD LABELeREPURT IAR3Q LABEL RECURDS ARE STANDARD, ABAY1 M)y LABEL=REPORT=RECORD 20232 W1 LeReDETAIL, @1 LeR=DETAILe2, 40233 PRA3y 20335 - SECTINON, 2AR22 23836 40437 PIC A% FILLER PIC X(34), ©3 LR=ACCOUNT PIC X(6), 33 FJILLER PIC ¢3 LR=21P PIC 20438 20439 WORKING=STORAGE 62340 : aeJ41q proyue X(32), X(s8), ’ SECTION, \ , 2y X(40), | LABEL=REPORT=STATUS VALUE "xx", ) plc x(2) 20943 20044 L 20246 L 28047 L L L o0@u4s 20049 22359 L 22851 L 0035} 26854 BBUSS L L L L LINKAGE | 20va4s - COPY 5 22056 2ees? 26258 082589 de0ee 00061 L 0080262 L L L 22063 09064 28es6s CUSTRC, . Pl - 200852 L L L L L CUSTOMER=FILE=RECORD, 23 CUST=CUST=NUMBER a3 CUST=CUSTOMER=NAME A3 CUSTcADDREss-LINE-I 23 83 CUST=ADDRESS=LINE=?2 CUST=ADDRESS=LINE=3 23 CUST=ADDRESS=Z21P=CODE 23 CUST=PHONE, A3 2neTy 02a7e 22377 § 01 . 00pvga oae7sS A3 A3 ' CUST-NEXT-ORDER-SEOUENCE_ CUST=NEXTePAYMENT=SEQUENCE DIVISION REPORT=ERROR veose C-16 CUSTeOWE=AMT CUST=BOUGHT X(30), PIC PIC X(30), X(32), PIC X(S), PIC X(3), X(3), 9(4). ' PIC PlIC PIC 9¢18), PIC X¢ee), PIC 9(10)V99, CUST=CREDIT=LIMIT, PIC PIC . - X(6), 9¢(s), PIC 9(108)V99, PIC PIC PIC 9(18)Vv9e9, 9(4), 9(¢d), USING DECLARATIVES, (0P00QdRR28) P08} : NEXT=ACCT=aNUMBER a3 - -~ X(6), X(39), PIC CUSTOMER=FI_LE=RECORD, . 40478 USE as 23 PROCEDURE #ears J CUST=CREDIT=LIMIT CUST<HEANER=DATA REDEFINES 25 FILLER ' 26367 00068 P0ede69 20879 ép07} aeag7e 20073 - ' CUST=ATTENTIONeLINE 73 @3 ' RPIC PlC as CUST=PHONE=AREA=CODE es CUST=PHONE=EXCHANGE @S CUST=PHONE=| AST=4 CUST=PHONE=NUMBER REDEFINES CUST=PHONE 23 L 020266 L L L L L L L SECTION, . - USE AFTER SBEGIN, SOURCE PROGRAM LISTINGS SECTION, ‘ STANDARD ERROR PROCEDURE ON LABEL=REPORT, Vd,00=01 DISPLAY : @1 wageaa (p202v428) ago8e peas7 anaag. 02 gaoeven @2 evad10 (p3220072) MOVE i 82 P2pe1C (A0@2287C) 808392 END MOVE § @2 amémas (A3382088) 1 92 @200834 (0000¢094) IF WRITE § @2@dsC (N2PABBBRC) ! 02 a0pe78 (A0c02008) ! @e po0o8d (00P0V0V0REY) ’ PN WRITE ! @2 MOVE CUST=CUST=NUMHBER MOVE P0B0AC (eovdaiag) MOVE a01e3 82 P200Cs8 (20000128) MOVE § A2 @2eaDy (20002134) 1) (n0@001402) ! 22 @ABPEH edie7 02 0000FC (0093045C) WRITE $ 22 p0o1las (PO?20168) EXIT t 22 030124 IDENTs ADVAWCING o1 rrrrrrecrrrrre L CUST~ADDRESS=LINE=3 WRITE LABELeREPORT=RECNRD ADVANCING SPACES AFTER (p0000184) TO LAREL=REPORT=RECORD, TO LR=ZIP, LINE, ADVANCING 2 LINES, PROGRAM, 1{2=Jan=1979 PR34d1122 NAME LABEL=REPORT LABEL=REPORT=RECORD L=ReDETA]IL LR«ACCOUNT 3 ©3 83 @S @3 @3 @3 CUST=HEADER=DATA NEXT=ACCT=NUMBER CUST=OWE=AMT CUST=BOUGHT CUST=NEXT=ORDER=SEQUENCE @3 TO LABFL=REPORT=RECORD, 012086 LABEL=REPORT=8STATUS 83 1 MOVE CUSTOMER=F ILE=RECORD CUST=CUST«NUMBER CUST=CUSTOMER=NAME CUST=ADDRESS=LINE={] CUST=ADDRESSeLINE=2 CUST=ADDRESSeLINE=3 CUST«ADDRESS=Z]P«CODE CUST=PHONE" CUST=PHONE=AREA=CODE CUST=PHONE=EXCHANGE CUST=PHONE=LAST=4 CUST=PHONE=NUMBER CUSTeATTENTION=| INE 83 83 ®3 83 @3 03 @3 05 PS5 LABEL=REPORT=RECORD, LINE, WRITE LABEL=REPORT=RECNRD L=R=DETAJILe2 83 LReZIP -] n #1 @3 1 0109 CUST=CREDIT=LIMIT CUSTeNEXT=PAYMENT«SEQUENCE VAX=1{ COBROL=74 DNCATS.CORs6 MAP SOURCE DDIV LINE FD @1 21 TO CUST=ADDRESS=ZIP<CODE EXIT LAREL=REPORT=RECORD, LINE, 22110 oAl DATA LEVEL 1 MOVE AFTER oai12 TO LABEL=REPQRT=RECORD DOCATS T TN 1 LINE, MOVE vole8 MOVE ADVANCING AFTER a018s WRITE 1 CUSTeADDRESSeLINE=2 WRITE gajed i LR=ACCOUNT, LABEL=REPORTeRECORD AFTER gaiae MOVE ADVANCING CUST=ADDRESS=_INE=1 WRITE galoel (20@003100) TO LABEL=REPQORT=RECORD AFTER ADVANCING 2 LINES, aga99 P0B0AY LABEL=RFPORT=RECQRD, ARITE 9a19a 82 SPACES AFTER vea97 0Ea98 MOVE TO LABEL=REPORT, MOVE MOVE CUST=CUSTOMER=NAME T0O LABEL=REPORT=RECORD, Woad9e WRITE OUTPUT "xx WRITE LABEL=REPORT=RECORD 20d9s (20000082) = LABEL=REPORT=STATUS OPEN 28494 92 . 029059 (" SBEGIN, PaA93 MOVE CODE DECLARATIVES, 20491 WRITE 1 | ABFL=REPQKRT, MAINLINE SECTION, 0BE99. 1 MOVE ON (202000V60) OPEN 22 ERROR ll)ll. 20088 ! "l=0 LABEL-REPOKT=STATUS A2a84 DB3Y8S 200286 ;F NISPLAY 1oL TR LOCN DIR USAGE CLASS OCC LENGTH LoOC A0E29 AIRE20 20031 @2014C 202@AD DISP e e eepdn veeas MYPA24 wxxna% NAPPAC xxxaxx @2MA18 ARQR24 *xxxvxk VYOVRAY VUAAAC DISP DISP 02052 @AQ1UC AUQ16E PUQ14C 22016C ABALT6 QAP 007 @007AG6 AN AN AN g¢ @¥A32 00034 2035 0P@37 0G4l P0A49 Q0059 @PA51 @gnl7 22005 nee@2 VP20S “oves ¢@a3n waR3Y PAPR42 poe@24 20aS4 PSS Q20060 QAUUATE “OABIA Werp3C AN AN AN AN AN AN AN AN AN AN e 00 en n0 ¥d A% °8 @0AS3 DISP DISP DISP DISP DISP DISP DISP DISP DISP DISP pgd ©®0 o0 Peale V@a3n 20005 “AUPL8 Vonup 00056 Q0VPHI *wxxxx DISP AN @0 20010 00057 00058 Q0ABB3 P20p86 #wwwax r*wxwxax DISP DISP AN AN 02 "¢ 0CeE3 Q0QPR3 PAP59 J2PP89 NUM (20083 kkaxwwx wkawak DISP PUR6D DISP NUM 0 e Aeney epetu Q0062 2063 PR064 AVADPBD POPRAL P2APAL xxmwwakx xaawix wxwrwxw DISP DISP DISP AN NUM AN 0o PO 0gni2 Qp@12 00066 3067 20069 @UOBT1 BUARAT QPANAD PIBABY QVQBACS wdaxxkx xkakwx wrrwrx #srarx DISP DISP DISP DISP NUM NUM NUM NUM g0 a0 00 0 0gede vaet? eeei2 vedpd 20072 APPACY xrxkxxnx DISP NUM @ 0Oeaad A3 @pn2v SOURCE PROGRAM LISTINGS V4,2h=@} {2eJan=1979 @8141122 DOCATS IDENT; 012086 PROCEDURE NAME NAME SOURCE VAX={1 COBOL=74 DOCATS,.COB)y6 V4,00=9} VAX=1] COBOL=74 V4,00=01 VAx-li COBOL=74 V4,00-01 VAXei{1 COBOL=74 DOCATS,C0B)y6 V4,00=01 VAX={1 COBOLeT4 V4,00+0}% MAP PSECT OFFSET SEG mo0OQ00 Q0 SECT PARA LINE REPORT=ERROR SBEGIN 28079 MAINLINE SBEGIN DOCATS IDENT; DOCATS$3$5%%001 03281 0@A88 DOCATSS$S$83558221% DOCATSS$S$S$SSSS002 000022 00000Q0 @00889 DOCATSS$3$$S0A2 02000C0 SEGMENTATION SEGMENT SECTION NAME P DOCATS,C0B36 DOCATSSSSS8Ss5071 DOCATSSSSS83002 SIZE A2e038 02213C ppessé 00316 12=Jan=1979 08341122 DOCATS,.COBj6 GENERATED PSECTS SIZE DOCATS$$3$33000 DOCATSSS$833303 200028 200040 20049 20264 DOCATS {2=Jan=1979 IDENT; 912086 REFERENCED CTUSXOPEN 88341122 | OTS ROUTINES CTUSXWRIT C748X8UBK IDENT; 0O NAME B12086 NAME DOCATS P MAP NO, 29 e REPORT<ERROR MAINLINE COMPILER S S {2=Jane1979 08141122 012086 DOCATS IDENT; 00 0O CT4SXEDIS CT4SXINIT C74$XGO C748CSTNE CT4SMJUSL C74SXENDP CTUSMCFST CTUSXEXIT CTUSMGLA 12=Jan=1979 B8141122 012886 DOCATS,C0Bj6 i DATA PSECT MAP NAME A S1ZE DOCATSSSSSSSDAT 200178 00376 DOCATSSSSSSSWRK DOCATSSSSSSSLIT DOCATSSSSSSSLTD DOCATSSSSSSSADT DOCATSSSSSSSUSE SCBXAY 2a0@1A 0pa@2E 20003C 200000 ~ Oe0e29 202000 20026 20246 00060 200020 00032 20000 DOCATSSSSSSSDDD DOCATSSSSSSSARG $CBFD1 DOCATS IDENT; 2000804y 20048 eea72 20004 12=Jan=1979 08141122 @at2086 EXTERNAL SUBPROGRAM REFERENCES NO EXTERNAL NO ERRORS C-18 2000830 2000248 SUBPROGRAM SOURCE REFERENCES PROGRAM LISTINGS / VAX=1{{ COBOL=74 DOCATS,C0B36 Vd4,00-0} 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 IGNORED. line has continue PUNCH MISSING. a continue indicator QUOTE is indicator. ignored. ASSUMED. A non-numeric literal has no quote and ‘the following 1line has no continuation indicator. A terminal quote is assumed at the end of the line. 003 VIOLATION OF AREA A. ASSUMED CORRECT. The first non-blank character continued 1line occurs error is ignored. 004 LINE LENGTH EXCEEDS 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 type of CONTROL. word being processed. IGNORED. 'An I-O-CONTROL paragraph appears when no FILE-CONTROL paragraph was present. I-O-CONTROL paragraph is ignored. The 006 .STRING. DATA ITEM MUST HAVE DISPLAY USAGE. A data item in a STRING statement is defined with DISPLAY usage. Fatal. 007 NAME EXCEEDS 30 CHARACTERS. TRUNCATED TO not 30. A character-string that appears to be name exceeds The string is 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 a 30 characters in length. truncated on the right to 1in the to NUMERIC LITERAL HAS MULTIPLE DECIMAL POINTS. A numeric literal has more than one decimal point. 012 PICTURE CLAUSE ILLEGAL ON GROUP LEVEL. IGNORED. A group level The clause is 013 .SELECT. NOT FOUND. SENTENCE item has ignored. 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 1level JUSTIFIED, ZERO 015 FILENAME MISSING OR INVALID. A SELECT The clause not or 1is contain BLANK WHEN ignored. statement either the the SELECT | contains no user name statement 1is is USAGE CONFLICTS WITH GROUP USAGE. USES GROUP. The D-2 may IGNORED. user name or invalid. The ignored. 016 item SYNCHRONIZED, clauses. SELECT IGNORED. DIAGNOSTIC for this item differs from the usage higher group 1level. The usage is used. stated group at a level ERROR MESSAGES usage specified - 017 ILLEGAL NUMERIC DATANAME IN .STRING. A numeric statement data item in has an illegal a STRING description. Fatal. 020 .ALL. ILLEGAL IN CONTEXT OF .STRING. STATEMENT. An ALL literal has been used in a STRING statement. 021 Fatal. VSYNTAX ERROR OR NO TERMINATOR. CLAUSES 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 THIS were found. is ignored. contains SENDING LIST OMITTED IN « STRING. UNSTRING, a numeric MORE THAN ONE FILENAME IN or INSPECT statement literal. contains no DELIMITED BY .ASSIGN. specification. specification is ILLEGAL DATANAME FOLLOWS .INTO. IN Only used. SUBSCRIPTING DEPTH EXCEEDS 3. OVER of than an ASSIGN one file the first | .STRING. The receiving field statement is invalid. 026 sending phrase. | The non-numeric 1literal clause contains more 025 Fatal. STATEMENT. A STRING statement fields before a Fatal. 024 SELECT STATEMENT. A STRING, 023 The 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 item with DIAGNOSTIC ERROR MESSAGES D-3 an OCCURS clause or subordinate to an OCCURS VALUE clause is ignored. in an clause. item The 030 VALUE ILLEGAL IN REDEFINES ITEM. IGNORED. 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-O0-CONTROL paragraph is not terminated by a period. The terminator is 032 .MAP. NO LONGER APPLICABLE. assumed present. IGNORED. An APPLY clause with the MAP. option version +this for applicable not the compiler. future versions of | APPLY clause is ignored. 033 AN IO CONTROL CLAUSE WITHOUT FILES. of <clause The clause 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 is and The INVALID ACCESS MODE. TREAT AS is illegal syntax. The ignored. SEQUENTIAL. The SELECT statement contains an invalid SEQUENTIAL ACCESS mode is ACCESS mode. assumed. 036 INVALID FILE ORGANIZATION. TREAT AS SEQUENTIAL. The SELECT statement contains an invalid SEQUENTIAL specification. ORGANIZATION organization is assumed. 037 NO SELECT 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 The FILE-CONTROL IGNORED A SELECT statement contains no ASSIGN is statement SELECT The clause. ignored. D-4 DIAGNOSTIC ERROR MESSAGES | 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 expected, fractional positions were found. literal is ignored and a value of is assumed. 043 INTEGER VALUE TOO BIG. LARGEST A VALUE P ERROR IN DATA RECORDS numeric CLAUSE. The or The 045 ERROR IN LABEL RECORDS literal 046 CLAUSE 1is too NO INTEGER IN BLOCK CLAUSE. -BAD VALUE IN BLOCK CLAUSE. big for the given used. SKIPPED. 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 in is word DATA is not followed by RECORD RECORDS in the DATA RECORDS clause. DATA RECORDS clause is ignored. CLAUSE. The or The CLAUSE The does The not contain BLOCK clause NO INTEGER IN RECORD CLAUSE. numeric literal CLAUSE in the BLOCK clause block 0 and SKIPPED. | l The RECORD contain a CONTAINS 051 a is SKIPPED. causes an illegal block size. The size in bytes must be greater than less than 32768. Clause ignored. 050 | USED. conversion as an 1integer context. A value of 32,767 044 but The =zero CONTAINS clause numeric literal. clause is does not The RECORD ignored. INVALID VALUE IN RECORD CLAUSE. CLAQSE SKIPPED. The numeric CONTAINS zero. The ignored. 1literal <clause RECORD 1is 1in not the RECORD greater CONTAINS clause DIAGNOSTIC ERROR MESSAGES than is 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 entry period terminator. The ignored. | 054 KEY WORD EXPECTED. REMAINING CLAUSES 055 NO LABEL CLAUSE IN FD. contains error no is SKIPPED. A keyword that BLOCK, LABEL, The remainder ignored. - a begins a clause, such as DATA, etc., 1s missing. of the FD entry is | .STANDARD. ASSUMED. The FD entry contains no LABEL RECORD clause. LABEL RECORD IS STANDARD 1is assumed. | o 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 01 entry under the same file. The value CONTAINS clause 060 RECORD AREA EXTENDED TO CONTAIN LARGEST specified by the RECORD is used. 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 1is used. 061 NO RECORD AREA. FILE DELETED. No record area 1is allocated for a file description. The file description is ignored. All references to the file will be diagnosed as undefined. . D-6 DIAGNOSTIC ERROR MESSAGES 062 ILLEGAL DATANAME FOLLOWS .WITH POINTER. PHRASE. a in pointer a The data item used as STRING or UNSTRING statement is illegal. Fatal. 063 IN ILLEGAL SYNTAX STATEMENT. .STRING. STRING ‘A syntax. 064 illegal contains statement | Fatal. 77 ILLEGAL IN FILESECTION. CHANGED TO 0l. been has description A 77 level item The 77 level found in the FILE SECTION. is 065 ILLEGAL WORD FOLLOWS treated as an 01 level. ' - PHRASE. .DELIMITED BY. expected 1is literal or A data-name phrase in a a DELIMITED BY following Fatal. STRING or UNSTRING statement. 066 ILLEGAL USE OF .ALL.. IGNORED. numeric an ALL <clause, VALUE "In the ALL is ignored by is detected. literal the 067 compiler. IGNORED. 88 CONDITION NAME MISSING OR INVALID. The condition-name in an 88 level is either entire entry is 070 or missing ignored. invalid. entry The TWO INDEXED KEYS START AT SAME OFFSET IN RECORD. the of The leftmost character position KEY RECORD ALTERNATE or KEY RECORD leftmost the to ‘data-name corresponds position of some other RECORD character KEY or ALTERNATE RECORD The 071 clause is KEY data-name. ignored. . REDEFINES. ON Ql LEVEL IN FILE SECTION INVALID. the on The REDEFINES clause is present FILE SECTION, where the in 01 level REDEFINES implicit. 1is redefinition clause 072 PICTURE IGNORED FOR INDEX is | ignored. ITEM. as An item defined PICTURE clause. USAGE INDEX has a The PICTURE clause is ignored. | DIAGNOSTIC ERROR MESSAGES D-7 073 NONNUMERIC PIC ON COMP ITEM. TREATED AS DISPLAY. ~An item defined with has a non-DISPLAY picture-string with usage non-numeric characters. The stated usage is ignored. The item is treated as USAGE DISPLAY. 074 -SUBSCRIPT OUT OF RANGE. ASSUME 1. A literal subscript is either less 1l or greater than the maximum value. A value of I is used. than allowable 075, .STATUS. OMITTED FROM .FILE STATUS.. ASSUMED. The FILE STATUS syntax. 076 SOME FILES WITHOUT POSIT. o IN MUL. A MULTIPLE , y NO. all the The searching file. .MULTIPLE FILE TAPE. CLASSES IN 101 - POSSIBLE contains contain error 1is OPEN ignored. will Not POSITION File find the FILE error. TAPE The clause clause is contains a ignored. CONFLICT. One | clause POSITION clauses. during MULTIPLE syntax OPERAND 1incorrect SYNTAX ERROR. A 100 TAPE with has ignored. TAPE. file—-names clauses. 077 is FILE FILE file—names « clause The error an RECEIVING FIELD or more invalid operands class. in a statement have Fatal. TRUNCATION. A MOVE statement results in right-hand truncation of the receiving field value. This is not an error and is ignored. 102 TOO FEW SOURCE FIELDS FOR ADD .GIVING.. At least two valid source operands appear Fatal. 103 1in ADD...GIVING must statement. A.EXIT. WAS NOT THE ONLY VERB IN PARAGRAPH. An EXIT statement ] D-8 an | DIAGNOSTIC ERROR MESSAGES statement 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 Fatal. missing sending operand. 105 - SENDING ITEM NOT FOLLOWED BY .TO..V A MOVE keyword RECEIVING ITEM INVALID the following TO have OR OMITTED. receiving A MOVE statement has no valid operand. 107 | Fatal. 1 INVALID CLASS FOR DESTINATION FIELD. receiving operand numeric edited. Fatal. The SUBTRACT 110 the sending Fatal. operand. 106 does»not statement RELATIVE OR RECORD KEY OR STATUS statement is of not an ADD or numeric or NAME INVALID. The name referenced in a RELATIVE KEY, RECORD KEY, ALTERNATE RECORD KEY or FILE The clause 1is STATUS clause is invalid. ignored. 111 .STOP. SYNTAX ERROR. The STOP statement is not followed by literal or the word RUN. 112 .SIZE ERROR. Fatal. STATEMENT INCORRECT. the ON contain a calls for excess of an 18 " The word ERROR is not found SIZE clause. 113 .PROCEDURE DIVISION. in Fatal. OMITTED. The source program does PROCEDURE DIVISION. 114 a not Fatal. INTERMEDIATE RESULT TOO LARGE. HIGH ORDER TRUNC. An arithmetic statement intermediate result in 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 INTERMEDIATE RESULT TOO LARGE.‘LOW ORDER TRUNC. An arithmetic intermediate digits. 116 .DIVISION. OMITTED The expression result in truncated on with a non-zero digits AFTER TERMINATOR MISSING AFTER right possible an 18 result to 1loss of execution at 18 is digits, low-order, time. .PROCEDURE.. The word DIVISION PROCEDURE DIVISION is DIVISION The missing header. The in the error is from a | HEADER. period terminator division header. 120 calls for excess of intermediate the ignored. 117 TN 115 is missing The error is ignored. LITERAL INCOMPATIBLE WITH ATTEMPTED USAGE. Conversion ofa literal from one form to another 121 has Fatal. DATANAME MUST FOLLOW .INTO. IN THIS STATEMENT. A valid data-name following statement. 122 failed. NUMERIC SUBJECT OR OBJECT MUST BE INTO in is a 'not Fatal. 123 OPERANDS CONFLICT IN .SET...TO. A » INTEGER. object of this STATEMENT. SET...TO SET...BY operands. statement references Fatal. invalid | | statement references invalid Fatal. ILLEGAL FILENAME LITERAL OR FILENAME DATANAME. An ASSIGN statement statement or contains specification or statement is ignored. 'D-10 or OPERANDS CONFLICT IN .SET ...BY. STATEMENT. A 125 subject context Fatal. condition. ~operands. 124 UNSTRING » A numeric, non-integer is invalid in the relation presént STRING or DIAGNOSTIC ERROR MESSAGES a an VALUE OF 1ID 1invalid file data-name. The “ PR 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. A data item used as itself a table element. 130 .POINTER. MUST FOLLOW .WITH. IN THIS STATEMENT. A STRING or UNSTRING a | an statement has invalid WITH POINTER phrase. 131 is subscript Fatal. Fatal. 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 numeric neither a 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 table item contains no A reference to 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 is ignored, and only the index-name is used. DIAGNOSTIC ERROR MESSAGES D-11 137 SUBSCRIPTS GIVEN WHERE NOT REQUIRED. IGNORED. A reference is made and a subscript ‘reference. ignored. 140 TOO FEW SUBSCRIPTS GIVEN. ASSUME 1 The FOR to a non-table list item, follows the list is subscript 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 TOO MANY SUBSCRIPTS GIVEN. SUBJECT AND OBJECT USAGE 142 IGNORE EXCESS. A reference to a many subscripts table Extra are MUST subscripts in item contains too the subscript list. ignored. MATCH. A relation condition between non-numeric operands both requires the operands. Fatal. same usage for ARITHMETIC EXPRESSION REQUIRED IN THIS CONTEXT. 143 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 A IN THIS condition CONTEXT. expression the 145 " ILLEGAL OPERAND FOUND IN is context of compiled. The the COBOL compiler recognize the this context. Fatal. COBOL required condition expression data-name the or COBOL literal has been statement being compiled. The class or USAGE of data item may be invalid here reference in an expression. Fatal. OPERATOR IS MISSING IN COBOL EXPRESSION. An operator specification The is of omitted this COBOL in DIAGNOSTIC ERROR MESSAGES the as a the expression. compiler cannot recognize expression as a syntactically COBOL expression. Fatal. D-12 in EXPRESSION. An invalid found in 146 in statement being has failed to this valid 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 IN AREA A. Fatal. ALLOWED. in Area A. A statement begins ,_., 2N is 152 EXPECTED .RELATIVE KEY. 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 ALLOWED. procedure data-name. can there references. 155 name 1is identical The error is ignored, in. ambiguity no be | to a since legal . 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 statement = may SELECT The on files with sequential only OPTIONAL is OPTIONAL word The organization. ignored. - 157 FILE HAS IO CONTROL CLAUSE A CONFLICTS. file 1is given specifications paragraph of the in conflicting the INPUT-OUTPUT clause I-0O-CONTROL SECTION. DIAGNOSTIC ERROR MESSAGES D-13 160 FILE REQUIRES REL. KEY. TREATED AS SEQ. ACCESS. A file with relative organization random or dynamic access has KEY clause. The access mode to 161 INVALID INDEX DATAITEM USE IN RELATIONAL. compiler detects an 1index data item subject or object condition. Fatal. UNKNOWN WORD. SCAN TO and RELATIVE changed SEQUENTIAL. The 162 no is NEXT the invalid use of reference as the of a relation CLAUSE. 'An unknown word is encountered when a clause keyword is 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 occurrence -~is used. two clause. The SELECT. The file-name statement is supplied not further 1in a SELECT described in an FD in the Data Division. The SELECT statement is ignored, causing the file-name to become undefined. AREAS FOR SAME AREA. between SAME the / The compiler detects a conflict the SAME RECORD AREA clause and AREA clause. ~ DIFFERENT SAME REC. /_/ 165 166 . READ. WITHOUT,.INVALID KEY. .AT END. OR .USE. A READ statement clauses, and USE procedure 167 I0 CONTROL CLAUSE HAS FILE WITH An NO contains no the file being applied to it. D-14 DIAGNOSTIC ERROR MESSAGES read has Fatal. no .SELECT. I-O-CONTROL <clause references file-name that was not named statement. The file-name is the conditional I-O-CONTROL statement. a in a SELECT ignored 1in 170 INTEGER OMITTED IN .RESERVE.. DEFAULT ASSUMED. A RESERVE clause fails to number of buffer areas to clause is ignored, and the is used. 171 specify the reserve. The RMS default INVALID SUBJECT OF CLASS CONDITION. The subject of a class condition is a data Fatal. 172 VALUE EXCEEDS FIELD CAPACITY. item NO DATA DIVISION INVALID not class. a VALUE field. stored STATEMENTS GRP LEV NUM. acceptable clause exceeds the length of the The value is right truncated and in the field. REST OF literal supplied by PROCESSED. The Data entries. 174 an TRUNCATED. A numeric 173 with Division contains no valid This is an observation only. RECORD IGNORED. A 1level-number is encountered that terminates a previous group item, but does not match level-number. any previous All data skipped until the next indicator or header. 175 INVALID PROCEDURE NAME DEFINITION IN The A AREA compiler of the 01 group item's entries are 1level, level | | A. detects source Procedure not conform to definition of a text Division in Area that does the rules for the 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 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. L A relation condition has both subject and object. 200 COPY IGNORED WITHIN LIBRARY INVALID FILENAME ON library text ignored. | COPY. COPY The encountered COPY within statement is - IGNORED. A COPY statement supplies specification that is invalid. statement is ignored. 202 as TEXT. A COPY statement is 201 a 1literal Fatal. a file The COPY COPY FILENAME NOT FOUND. A COPY statement supplies a wvalid 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 The .END. STATEMENT. word END is DECLARATIVES. END not followed DECLARATIVES by 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. PHRASE. A STRING or an 210 .OVERFLOW. MUST FOLLOW .ON. UNSTRING invalid WITH IN THIS statement contains POINTER phrase. STATEMENT. A STRING or UNSTRING statement an invalid ON OVERFLOW phrase. 211 sending statement ILLEGAL SYNTAX IN .UNSTRING. SIGN CLAUSES ON THIS More data 214 an class. UNSTRING Fatal. statement has invalid Fatal. » ITEM. than one SIGN description. LEADING is field of invalid an UNSTRING syntax. MULTIPLE has STATEMENT. An 213 or clause appears (SEPARATE must TRAILING.) used. The 1in a follow second clause J | ILLEGAL SYNTAX IN COBOL EXPRESSION. The compiler detects a syntax nature 1in the COBOL general being 215 contains Fatal. ILLEGAL SENDING FIELD DATANAME IN . UNSTRING. The 212 Fatal. compiled. error of a expression Fatal. SIGN CLAUSE ON NONNUMERIC 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 numeric data other than is ignored. DATAITEM. A SIGN clause appears in a description that has no PICTURE string. The numeric SIGN "S" in clause data its is ignored. 220 ILLEGAL DELIMITING DATA ITEM IN .UNSTRING. TN An UNSTRING invalid 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. UNSTRING statement item data Fatal. .DELIMITED. ALL an .UNSTRING. receiving 223 contains Fatal. references that | .UNSTRING. CLAUSE REQUIRED IN THIS no contains statement UNSTRING An ’ Fatal. DELIMITED BY clause. 224 DATANAME MUST FOLLOW .DELIMITER IN. PHRASE. 'An UNSTRING ILLEGAL DATANAME FOLLOWS statement DELIMITER IN phrase .DELIMITER IN. PHRASE. with contains a illegal an Fatal. reference. 225 a is invalid. 226 DATANAME MUST FOLLOW VR a contains statement UNSTRING An DELIMITER IN phrase referencing a data Fatal. item that is invalid. PHRASE. .COUNT IN. COUNT a An UNSTRING statement contains 1illegal reference. an with IN phrase Fatal. 227 ILLEGAL DATANAME FOLLOWS .COUNT IN. PHRASE. An UNSTRING statement contains IN data 230 DATANAME MUST FOLLOW that phrase .TALLYING COUNT PHRASE. An UNSTRING statement with phrase TALLYING reference. 231 'ILLEGAL DATANAME FOLLOWS 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 is invalid. Fatal. 234 ILLEGAL DATANAME PRECEDES .FOR. IN An INSPECT...TALLYING invalid. a tally ~ data statement item that Fatal. is | .FOR; OMITTED IN .INSPECT. STATEMENT. An INSPECT...TALLYING invalid DATANAME MUST FOLLOW .TALLYING. A 236 data .INSPECT. references 235 a syntax. statement Fatal. has | PHRASE. t o An INSPECT...TALLYING statement does not reference 237 ILLEGAL WORD FOLLOWS .FOR. IN a tally data-name. Fatal. .INSPECT. An INSPECT...TALLYING statement does not state 240 DATAITEM OMITTED AFTER .ALL. a valid .LEADING. search condition. OR Fatal. .FIRST. An INSPECT statement does not reference a valid search argument. Fatal. 241 .ALL. FIGURATIVE CONSTANT ILLEGAL IN .INSPECT. "An ALL literal statement. 242 ILLEGAL DATANAME FOLLOWS .ALL. OR o appears in Fatal. ILLEGAL DATANAME FOLLOWS .LEADING. .BEFORE.'OR An INSPECT a valid phrase. 244 not reference Fatal. .AFTER. statement delimiter does not reference in the BEFORE/AFTER Fatal. | ILLEGAL DATANAME FOLLOWS .BY. An INSPECT statement does not a valid replacement argument. 245 INSPECT | An INSPECT statement does a valid search argument. 243 an ILLEGAL DATANAME PRECEDES reference Fatal. .BY. An INSPECT statement does not a the legal data-name or BY phrase. reference literal preceding Fatal. DIAGNOSTIC ERROR MESSAGES D-19 246 DATAITEM OMITTED IN .BEFORE. An OR .AFTER. PHRASE. INSPECT statement does not reference a legal data-name or BEFORE or AFTER phrase. 2477 ILLEGAL SYNTAX IN .INSPECT. literal Fatal. after the STATEMENT. Both the TALLYING and REPLACING keywords are missing in the INSPECT statement. Fatal. 250 .BY. MUST FOLLOW .CHARACTERS. The IN REPLACING LIST. 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) specified, the or 2) preceding the statement, CHARACTERS BY phrase 1is a figurative constant BY keyword of the ALL, LEADING, or FIRST phrase 1is specified, the data-name or literal after the BY keyword must be defined in length. Fatal. 253 DATAITEMS BEFORE AND AFTER .BY. In an data UNEQUAL IN .BEFORE. OR .AFTER. character SIZE. INSPECT...REPLACING statement, items before keyword of the ALL, phrase must be equal 254 as one and after an INSPECT...REPLACING CHARACTERS must be one character .REPLACING. A IN legal following statement. - D=-20 BY OPERAND EXCEEDS 1 CHARACTER. In ILLEGAL WORD FOLLOWS the LEADING, or FIRST in length. Fatal. or data-name the statement, following the BEFORE or AFTER 255 the DIAGNOSTIC ERROR MESSAGES in length. BY literal keyword Fatal. .INSPECT. keyword was REPLACING Fatal. not in recognized the INSPECT 256 .BY. OMITTED AFTER REPLACING COMPARISON OPERAND. \ The keyword BY 'LEADING, separates 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 o0f left parentheses in the COBOL expression being compiled. Parentheses must be specified in balanced pairs; that is, a right parenthesis must exist for each left parenthesis specified. Fatal. 261 MISSING OPERAND IN ARITHMETIC EXPRESSION. An operand 1is omitted in arithmetic expression. Fatal. 262 a COBOL ILLEGAL OPERAND IN ARITHMETIC EXPRESSION. The 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 The Fatal. EXPRESSION. compiler detects considered invalid. a non-integer, numeric exponent in a COBOL arithmetic expression. The arithmetic expression is 264 SUBJECT OMITTED IN CLASS Fatal. CONDITION. The compiler detects the omission of the subject in a NUMERIC or ALPHABETIC class condition. 265 Fatal. SUBJECT OMITTED IN SIGN CONDITION. The compiler detects the omission of the subject in a sign condition. Fatal. DIAGNOSTIC ERROR MESSAGES 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 ‘omitted. 273 .AT END. ILLEGAL FOR RANDOM may have been .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 itself Fatal. 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 item 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. \ 277 - RELATIVE An index-name used in a subscript 1list 1is not defined for this table or either | INDEX IS appears in the wrong logical position of the subscript list for this table. The index-name 1is 1ignored and a default value of 1 is assumed as the subscript. INVALID. The literal component of a relative index is zero or less in value, or is 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 gJreater 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 present. 305 data-name | is assumed SECTION OR PARAGRAPH NAME MISSING. The Procedure Division does not start with a section or paragraph name, or a is not followed by a section header paragraph name. Fatal. DIAGNOSTIC ERROR MESSAGES D-23 306 . PROCEDURE. MISSING IN .USE. The STATEMENT. keyword USE PROCEDURE statement. processing 307 ASSUMED. is is It missing 1is in the assumed and continued. | .START. WITHOUT .INVALID KEY. OR .USE. The the INVALID KEY option is START statement, or no is declared Fatal. for the missing from USE procedure referenced file. | S 310 .WRITE. WITHOUT .INVALID KEY. The OR .USE. INVALID KEY option is missing from the WRITE statement, or no USE procedure is declared for the referenced file. Fatal. | | 311 - DATA DIVISION MyCH TOO LARGE. Too much buffer the files 1in files are space this is being program. declared to simultaneously. 312 '« REDEFINES. SPECIFIES INVALID used for Too many be 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 description REDEFINES clause redefined. The REDEFINES processing 313 ILLEGAL TO between entry the the containing and the compiler item ignores data the being the clause and continues data description entry. REDEFINE ANOTHER 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 the REDEFINES clause" to whose length is variable at run ‘time it has a subordinate data item because whose data description entry contains an The. clause. ON DEPENDING OCCURS clause to application of the REDEFINES syntactically 1is item data a such the ignores compiler invalid. The continues and clause REDEFINES processing the data description entry. 316 ON. ILLEGAL IN REDEFINITION. .OCCURS DEPENDING The compiler detects a redefinition that description entry data a contains ON DEPENDING OCCURS declared with an DEPENDING ON clause OCCURS clause. The causes the ‘redefinition to contain a 1length is variable at item whose data is The DEPENDING ON phrase run time. . continues g processin ignored and 317 PICTURE EXCEEDS 30 CHARACTERS. PIC X ASSUMED. The unexpanded PICTURE string exceeds 30 compiler The 1length. in characters PICTURE and user-supplied ignores the as alphanumeric item the data 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 IT IS ASSUMED. .NO. The WITH NO REWIND phrase of statement It 323 is must assumed the CLOSE completely specified. present. '.REMOVAL. MUST FOLLOW .FOR. IT IS ASSUMED. The FOR REMOVAL statement 324 be .LOCK. OMITTED AFTER must It is assumed .WITH. IT IS phrase be of the completely CLOSE specified. present. ASSUMED. The keyword WITH in a recognized but is not CLOSE statement is followed of the keywords NO or LOCK. The phrase is assumed present. by one WITH hY LOCK The name reference was 326 FILENAME MUST FOLLOW some a / 325 DATANAME SPECIFIED WHERE FILENAME EXPECTED. wused in an I/0 file was not a other data-name. verb file name to but Fatal. MODE SPEC. IN .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. VERB. One of the OUTPUT, OPEN I-O, immediately 330 331 .END. MUST FOLLOW .AT.. FILENAME MUST FOLLOW mode or after keywords EXTEND the 1is INPUT, required OPEN verb. Fatal. IT IS ASSUMED. The keyword END phrase AT END phrase .READ. END was of is the omitted READ assumed in the statement. AT The present. 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. IN .READ. The data-name reference following INTO keyword of the READ statement omitted. Fatal. D-26 DIAGNOSTIC ERROR MESSAGES the was 333 RECORDNAME MUST FOLLOW .WRITE. OR .REWRITE. The 01 record-name reference immediately following the WRITE or REWRITE verb was omitted. 334 Fatal. STATEMENT IGNORED DUE TO ILLEGAL RECORDNAME. The data-name immediately following WRITE or REWRITE verb record-name reference. 335 .ADVANCING. OPTION OMITTED IN .WRITE. is not a valid Fatal. the 01 1 ASSUMED. integer A data-name reference, numeric or the keyword PAGE reference, literal BEFORE/AFTER the was not recognized in ADVANCING phrase of the WRITE statement. is A numeric integer literal value of 1 assumed. 336 .EOP. MUST FOLLOW .AT.. IT IS ASSUMED. The keyword EOP was omitted EOP AT EOP phrase 337 DATANAME OMITTED AFTER is assumed present. reference the of keyword FROM statement was omitted. .ADVANCING. INTEGER TOO BIG. TRUNCATED TO The numeric integer .NO REWIND. ILLEGAL WITH following WRITE or the REWRITE Fatal. 63. phrase of ADVANCING is greater than 63. 341 AT The .FROM. The data-name 340 the in phrase of the WRITE statement. in the BEFORE/AFTER the WRITE statement 63 1is assumed. .I0. OR .EXTEND. MODE. An OPEN statement with the I-O or EXTEND "mode specified cannot have the NO REWIND Fatal phrase also specified. 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 integer integer assumed. 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 .KEY - None of the GREATER, the 350 TERMINATOR IGNORED IN IS. or KEY PHRASE. relational NOT 1IS was phrase statement. Fatal. CONTROL. PARAGRAPH. .IO A clause 1is 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-0-CONTROL paragraph. 351 TERMINATOR IGNORED IN .SPECIAL A NAMES. clause is not is PARAGRAPH terminated by a period, followed by a header The period is ignored, continues processing but 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 s DIAGNOSTIC ERROR MESSAGES clause does STANDARD-1. or clause is ignored. not The T 353 'SYNTAX ERROR IN .OBJECT COMPUTER. PARAGRAPH. contains The OBJECT-COMPUTER paragraph The compiler word. unrecognizable an 1is word scans over all words until ‘a found 354 in Area A. TERMINATOR OMITTED IN..OBJECT COMPUTER. PARA. The OBJECT-COMPUTER paragraph 1is not terminated by a period. The compiler scans over all words found 355 word a until in Area A. is . DATANAME FOLLOWING .KEY IS. 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 be defined 357 ILLEGAL SEPARATOR IN COBOL 88 condition wvariable as USAGE INDEX. STATEMENT. An 1illegal between two statement. IGNORED. character was consecutive words The. detected a COBOL character is illegal of ignored. S 360 ILLEGAL cannot | 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 AT error 1is not usually will messages. internally corrected and cause further error | 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 TO MAX. An alphanumeric characters literal 1is literal in 1length truncated retaining the the literal. 364 or has or COBOL SOURCE LINE TOO LONG. TRUNCATED first TO greater than 132 is detected. The on the right, 132 characters as MAX. " The indicated COBOL source line contains more than format. 65 ignored, and the printed retained. 365 .BY. OMITTED IN REPLACING characters The OPTION. COPY excess only COBOL 366 TERMINATOR OMITTED IN .COPY. is terminal are those characters in source line are IGNORED. The keyword BY COPY...REPLACING statement in characters was not found statement. in a The ignored. IT IS ASSUMED. The réquired periodfterminating the COPY statement is omitted. It 1is assumed referenced 1in the of the FILE SECTION is decimal places in LINAGE defined - the present. 367 . LINAGE. CLAUSE DATANAME MUST BE AN INTEGER. A data—-name clause with WORKING4STORAGE 370 SECTION. .LINAGE.CLAUSE DATANAME MUST BE UNSIGNED. A numeric data-name referenced 1in the LINAGE clause of the FILE SECTION is defined as a signed data item in the WORKING-STORAGE SECTION. D=30 DIAGNOSTIC ERROR MESSAGES 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 results, and the message should not be 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 in OPENed 1is the OPTIONAL file mode. 375 EXPECTED .FILE STATUS. DATANAME NOT DEFINED. A data-name phrase of STATUS 1in the FILE-CONTROL paragraph is not defined in the WORKING-STORAGE SECTION of the DATA DIVISION. ' | 376 EXPECTED .VALUE OF ID. referenced in a FILE a SELECT clause 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 referenced in a RELATIVE KEY phrase of a SELECT clause must not be defined with INDEX usage in the WORKING-STORAGE 402 .RELATIVE KEY. DATAITEM IS TOO SECTION. LONG. A numeric integer in a RELATIVE KEY data-name referenced phrase is defined with more than eight digits of ©precision 1in the WORKING-STORAGE SECTION. .RELATIVE KEY. DATANAME MUST BE AN A INTEGER. numeric data-name RELATIVE KEY decimal places referenced phrase in 1is the in defined a with WORKING-STORAGE N 403 SECTION. 404 .FILE STATUS. DATANAME HAS INVALID CLASS. A data-name referenced in a the FILE STATUS phrase of a SELECT clause must be defined in with DISPLAY usage in the WORKING-STORAGE 405 L.FILE STATUS. DATA NAME HAS INVALID SECTION. USAGE. A data-name referenced phrase of a SELECT with DISPLAY USAGE WORKING-STORAGE 406 in a FILE clause is STATUS defined in the SECTION. ‘LENGTH OF .FILE STATUS. DATAITEM IS ILLEGAL. An alphanumeric data-name a FILE STATUS phrase of referenced a SELECT in clause must be defined in the WORKING-STORAGE SECTION as an alphanumeric wvariable consisting of two characters. 407 .VALUE OF ID. DATANAME HAS A INVALID CLASS. data-name clause of referenced an non-alphanumeric WORKING-STORAGE D-32 DIAGNOSTIC ERROR MESSAGES FD in a 1is class SECTION. - 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 in the WORKING-STORAGE SECTION. 411 LENGTH OF .VALUE OF ID. DATAITEM IS ILLEGAL. An 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 falls in Fatal. the range 9<=L<=150 .LINAGE. CLAUSE DATANAME HAS INVALID CLASS; A data-name referenced 1in the LINAGE of the FILE SECTION is defined non-numeric class in the clause with WORKING-STORAGE 413 SECTION. .LINAGE. CLAUSE DATANAME HAS INVALID 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 operand Fatal. SET OMITTED OR ILLEGAL receiving operands statement. a SET OPERAND AFTER .TO. operand. ILLEGAL SYNTAX IN .SET. are specified IN no valid has FOLLOW .UP. OR sénding Fatal. receiving statement. MUST a STATEMENT. the .BY. in .SET.. The words TO, UP or DOWN do 420 statement Fatal. A SET statement 417 of NO RECEIVING OPERAND SPECIFIED IN .SET.. No 416 SECTION. .DOWN.. The not of follow a SET Fatal. ASSUMED. keyword UP or assumed operands BY does DOWN 1in present. a DIAGNOSTIC not SET follow the statement. ERROR MESSAGES word BY 1is D-33 r 421 OMITTED OR ILLEGAL OPERAND AFTER .BY. The BY 422 NO OPERANDS operand following the UP BY or DOWN phrase in a SET statement is invalid or omitted. No operands the keyword Fatal. SPECIFIED 5 423 IN .SET.. were recognized DISPLAY. following Fatal. SETTING INDEX NAME OUT OF RANGE. .SET."IGNORED. A SET statement is attempting to set index large. 424 name wusing Fatal. a literal an is too t .IF. TRUE PATH OMITTED. ASSUME -NEXT SENTENCE.. The true path code is omitted IF as 425 that | CONFLICTING SIGN SYMBOLS statement. the true path NEXT of SENTENCE the IF from is ‘the assumed statement. 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 item as alphanumeric with a "PICTURE X" declaration. » 426 ZERO SUPPRESSION CONFLICTS IN.PICTURE STRING. The compiler recognizes both the Z and * zero suppression symbols in this PICTURE string. The compiler ignores the user-supplied PICTURE and treats the data item as alphanumeric with a "PICTURE X" declaration. 427 ILLEGAL CHARACTER IN THE PICTURE STRING. A character that is not string character set the PICTURE recognized in this PICTURE by the compiler. The compiler ignores the user-supplied PICTURE and treats the data item as alphanumeric with a "PICTURE X" declaration. D-34 DIAGNOSTIC ERROR MESSAGES in is 430 .BLANK WHEN CONFLICTS WITH ZERO. ZERO SUPPRESS. recognized 1is A BLANK WHEN ZERO clause a zero suppression field specified with in the PICTURE string. The compiler BLANK WHEN ZERO clause and the ignores continues with its processing. 431 PARENTHESIZED SPECIFIER EXCEEDS 18 DIGITS. The specification contained inside the of a PICTURE string exceeds “parentheses compiler The length. 1in digits 18 PICTURE and user-supplied ignores the alphanumeric as item data treats the 432 INSIDE SPECIFIER MISSING "PICTURE X" declaration. | | PARENTHESES. -~ 4 N with a The specification contained inside parentheses of a PICTURE string 1is missing. The compiler ignores the user-supplied PICTURE and treats the data item as alphanumeric with a "PICTURE X" 433 ILLEGAL SYMBOL PRECEDES LEFT PAREN. The declaration. IN compiler PICTURE. recognizes an S, V, CR, DB, left a preceding character " or parenthesis in a PICTURE string. The processing and ignored is error 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 Fatal. 436 INVALID OPERAND IN .FROM. OR .BY. The FROM VARYING TOO MANY .AFTER. PHRASES IN statement. | PHRASE. or BY statement valid operand 437 VARY ING .PERFORM. phrase does reference. of a PERFORM not 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 VARYING 441 ILLEGAL CONDITION EXPRESSION IN THE the or omission of UNTIL in 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. Fatal. | 443 INVALID RELATION CONDITION IN .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 in 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 in the Data Division. Fatal. 447 TOO MANY NAMES IN COBOL PROGRAM. RECOMPILE. The COBOL program being compiled has too many data-names or procedure-names. This condition has caused a compiler - table to overflow, aborting the compilation. D-36 DIAGNOSTIC ERROR MESSAGES 450 REFERENCE TO UNDEFINED DATANAME OR ILLEGAL SYNTAX The COBOL a contains data-name.. reference. in issued statement being compiled reference to an undefined the ignores compiler The may Dbe diagnostic This other with conjunction diagnostics for the erroneous statement. Fatal. o 451 QUALIFIED REFERENCE ILLEGAL IN THIS CONTEXT. detects compiler ‘The context a in reference 1is unqualified reference qualified a which an 1in required. The compiler permits the qualified reference the with in this context and continues /'/“\\\ compilation the 452 of the statement containing 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 gqualifiers in a qualified reference. ignored in are excess qualifiers 48 The the reference. 454 UNDEFINED QUALIFIER IN QUALIFIED REFERENCE. qualified a detects compiler The 1is a qualifier a in. which 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 COBOL the the reference in the text of This diagnostic may be issued program. diagnostics other with in conjunction for the statement in error. 7 .. compiler uses a reference that satisfies DIAGNOSTIC ERROR MESSAGES D-37 456 DATANAME REFERENCE EXPECTED IN THIS CONTEXT. The compiler detects a reference to a data item that is not alphabetic, numeric, alphanumeric-edited, alphanumeric, or numeric-edited. The context of this reference regquires 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 reference to item that its usage. issued in diagnostics invalid in the context 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 an 1is 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 gquote and continues processing 462 PROGRAM NAME MUST BE A NONNUMERIC the non-numeric literal. LITERALS ARE ILLEGAL IN | LITERAL. The program—-name key word CALL 464 literal. literal is not following the a nonnumeric Fatal. ARGUMENT‘LIST OF .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 1is in missing the CALL TN 470 ILLEGAL SYNTAX IN .CODE SET. CLAUSE. IGNORED. A valid omitted alphabet-name reference is in the CODE-SET clause. The compiler ignores the CODE-SET clause and continues to process the remainder of the 471 FD. DATANAME IN .KEY IS. PHRASE NOT ALPHANUMERIC. The 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 less than 473 DATANAME IN .KEY IS PHRASE IS The or equal 255. SUBSCRIPTED data-name phrase in a referencing an subscripted or 474 to OR INDEX. following the KEY IS READ or START statement indexed file must not Dbe indexed. Fatal. . RECORD KEY. DATAITEM MUST NOT BE A COBOL 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 from the ALTERNATE RECORD error is ignored. 476 UNDEFINED .ALTERNATE RECORD KEY. KEY clause. The DATANAME. The data-name given 1in an ALTERNATE RECORD KEY clause has not been define in the Data Division. | DIAGNOSTIC ERROR MESSAGES D-39 +ALTERNATE RECORD KEY. CLAUSES In ARE SEPARATED. the SELECT RECORD the KEY KEY statement clauses are LINKAGE SECTION ITEM APPEARS A TWICE LINKAGE appear IN clauses. ILLEGAL .SEGMENT-LIMIT. among This error .USING.. SECTION more data than item once in phrase of a PROCEDURE header. Fatal. 501 ALTERNATE other clauses. The ALTERNATE RECORD clauses should follow one another with no intervening is ignored. 500 the interleaved must not the USING DIVISION USING VALUE IGNORED. The segment-limit is not a numeric literal or 1is a numeric literal whose value is outside = of allowed segment-1limit range. 502 INTEGER 1 BEYOND AREA A TREATED AS An 01 Area 503 LEVEL NUMBER. level item was and accepted as A CLOSING PARENTHESIS | clause. The PICTURE clause MISSING IN Dbeyond Area A. used PICTURE the A SUBPROGRAM .PROGRAM. An last specified. The right parenthesis is missing in string. last four string. NOT than' one compiler PICTURE. PICTURE 505 in ,-MULTiPLE PICTURES FOR SAME ITEM. LAST USED. A data item has more 504 detected if The characters compiler of the the uses the PICTURE | IGNORED. EXIT PROGRAM has been detected, the COBOL program being compiled is a subprogram. Because EXIT PROGRAM but not 1is meaningful only in a subprogram, the word PROGRAM is ignored, and the statement 1is treated as 1if it were a simple D-40 DIAGNOSTIC ERROR MESSAGES EXIT statement. ° TN 477 ( 506 EXPANDED PICTURE STRING TOO LONG. PIC X ASSUMED. string PICTURE a of The expansion that string a produces specification The exceeds implementation limitations. user-supplied the ignores compiler as if PICTURE and treats the data item it had a "PICTURE X" declaration. 507 SPECIFIER OMITTED BEFORE IN LEFT PAREN. PIC. The first character of a PICTURE string The compiler parenthesis. 1left a is and PICTURE user-supplied the ignores as alphanumeric item data the treats X" declaration. with a "PICTURE — 510 SECTION NO. 49 TREATED AS 49. GREATER THAN A segment number greater the word treated 511 as SECTION. if it were than 49 follows The 49. 1is segment 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 a with alphanumeric -~ "PICTURE X" declaration. 512 VALUE CLAUSE NOT ALLOWED IN LINKAGE SECTION. data 1in The VALUE clause cannot appear The only 1in the LINKAGE SECTION. items place the VALUE clause can appear in the is in a condition name SECTION LINKAGE 513 : | definition. OPERAND IN .USING. MUST BE LINKAGE SECTION ITEM. only level 01 or 77 LINKAGE SECTION in the USING phrase of items may appear 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 Multiple detected compiler STRING. 2zero suppression fields are in a PICTURE string. The ignores the user-supplied PICTURE and alphanumeric treats the with a data 1item "PICTURE declaration. 516 as X" ZERO SUPPRESSION ILLEGAL WITH FLOATING FIELD. The PICTURE floating and The compiler string contains both 2zero suppression fields. ignores the user-supplied PICTURE and alphanumeric treats the with a data item "PICTURE as X" declaration. 517 ILLEGAL SYNTAX IN PICTURE STRING. The PICTURE correctly PICTURE string ignores 520 MULTIPLE DECIMAL POINTS string according the the with "PICTURE IN not specified the rules syntax. wuser-supplied treats a is to data item X" The as of compiler PICTURE and alphanumeric 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 OR 77. - - Only items a 522 INVALID USAGE. level MULTIPLE USAGE or may appear PROCEDURE 77 in DIVISION CLAUSES. clause word. The USAGE clause. LAST The the DIAGNOSTIC SECTION USING phrase header. contains compiler of Fatal. ERROR MESSAGES ignores an ~invaiid the entire USED. defined data-name clauses specified. clause specified is compiler. D-42 LINKAGE IGNORED. The USAGE 523 01 has multiple USAGE The last USAGE used by the 524 MULTIPLE OCCURS CLAUSES. LAST USED. The multiple has data-name defined The compiler clauses specified. OCCURS uses the last OCCURS clause specified. 525 OCCURS SPECIFICATION ERROR. 1 ASSUMED. is clause OCCURS The integer entry of the either non-numeric or non-integer or The 4095. to 1 range is not in the compiler assumes an integer value of 1. 526 DATANAME OMITTED IN DATA DESCRIPTION ENTRY. The declaration data-name omitted is data the in level-number a after description entry. The compiler supplies system-defined name and proceeds with a description data of the the processing is name system-defined entry. The to inaccessible 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 OPTICN NOT YET IMPLEMENTED. IGNORED. The compiler detected COMP-1 1in the not option 1is 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 in entry A data description period. a by terminated not 1is DIVISION is period the assumes compiler The present and continues processing. 532 INVALID SIGN IN NUMERIC PICTURE. The sign character S is position ' other than detected the 1in a leading PICTURE character position of a numeric the ignores compiler The string. the treats PICTURE and 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 is recognized with its PICTURE clause omitted in the description. The compiler treats the data item as alphanumerlc 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 n 536 INDEX data item exceeds digits in its specification. compiler truncates it and allocates words for its run-time storage. 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 1INDEX 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 1in the VALUE clause 1is 1longer than the associated data-item. The literal is truncated on the right to fit 1in the storage ‘allocated to the data-item. 541 CLAUSE DUPLICATION. IGNORED. This clause has recognized for this clause 1is ignored. 542 INVALID WORD IN .BLANK WHEN ZERO.. been item. The IGNORED. The kéywdrd ZERO was not recognized the BLANK WHEN ZERO clause. clause is ignored. D-44 DIAGNOSTIC ERROR MESSAGES previously duplicate The 1in entire ( 543 LEVEL NUMS UNEQUAL IN .REDEFINES. CLAUSE IGNORED. i : A REDEFINES clause attempts to redefine two items of different level numbers. The REDEFINES clause is ignored. 544 POSSIBLE OVERLAP OF DEPENDING ON ITEM AND TABLE. The DEPENDING ON length table are LINKAGE SECTION. SECTION items items appearing item and variable both defined in the Because LINKAGE are associated with data 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 your execution. responsibility overlap does 545 LEVEL ILLEGAL AFTER 77. It not occur. 1s, to therefore, ensure TREATED AS 0l. An invalid level number (02-49) follows a 77 1level item. The 77 level item is treated as an 01 level item. This : action 546 can cause further diagnostics if it is nota valid group item. y Q‘ PERIOD OMITTED AFTER .EXIT PROGRAM. The words EXIT PROGRAM are not by a period. 547 < that ) The error is followed ignored. .EXIT PROGRAM. NOT LASTSTMT OF SENTENCE. An EXIT PROGRAM statement appears | sequence sentence. of But, statements it 1is not 1in within the a a last statement. All of the statements following it -are compiled, but can never be executed. 550 REDEFINING LENGTH SHOULD MATCH ORIGINAL LENGTH. | The length of a non-01 is item the item is 551 REDEFINITION OF .OCCURS. level REDEFINES the same as the length of not 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 that. time identifying SECTION. The compiler at issued an error message 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 DIVISION, but was not recognized by the compiler. The compiler skips to the next level number data 554 INVALID WORD FOLLOWING item descrlptlon. VALUE.. - IGNORED. The VALUE. clause word for this entire VALUE 555 contains data clause an invalid description. is The ignored. VALUE CONFLICT. GROUP VALUE USED. ‘The VALUE clause assigns a value to an item subordinate to a group item that also has a VALUE clause. subordinate VALUE clause 556 The is ignored. LEVEL NUMBER OMITTED. ITEM IGNORED. The level number has been omitted in ~data-item description. All source is ignored up to and including the /perlod 557 NO VALUE AFTER CONDITION NAME. 88 IGNORED. An 88 level condition-name has no clause specified. The entire data-item is ignored. 560 SYNTAX ERROR IN SWITCH CLAUSE. CLAUSE VALUE 88 level IGNORED. The SWITCH clause has a syntax error its the D-46 a text next DIAGNOSTIC ERROR MESSAGES specification. entire clause. The compiler in ignores 561 IN ADVANCING PHRASE. ASSUMED. .NO. MISSING NO is assumed present. statement. 262 the in DISPLAY missing the of is keyword NO The phrase ADVANCING ASSUMED. _ADVANCING. MISSING AFTER .NO.. The keyword ADVANCING is missing in '563 assumed is ADVANCING statement. | present. the DISPLAY the of - phrase ADVANCING DUPLICATE DATANAME DECLARATION DETECTED. VR DATA In the ENVIRONMENT DIVISION and/or e defined that is DIVISION, a data-namis not uniquely referenceable even with | ,.. complete qualification. 564 ILLEGAL PARAGRAPH HEADER ID DIV. PAR IGNORED. | An illegal paragraph'header the paragraph is appears DIVISION. IDENTIFICATION 1in The ignored. 565 ILLEGAL PARAGRAPH HEADER ENV DIV. PAR IGNORED. in appears An illegal paragraph header the ENVIRONMENT DIVISION. The paragraph is 566 ignored. | NUMERIC LITERAL ILLEGAL ON GROUP ITEM. IGNORED. A numeric literal is ignored. illegal is a group item. VALUE clause of clause 567 in .ENVIRONMENT. NOT FOLLOWED BY .DIVISION.. The word ENVIRONMENT is not followed by DIVISION is assumed word DIVISION. the | present. 570 the The VALUE TERMINATOR,MISSING AFTER ,DATA DIVISION. HEADER. The DATA DIVISION header is not followed by a period. The period is assumed 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 entire RENAMES the compiler ignores data description entry. 573 .SECTION. OMITTED FROM SECTION HEADER. An ENVIRONMENT DIVISION section name not followed error 574 TERMINATOR MISSING AFTER is SECTION by the word SECTION. ignored. HEADER. An ENVIRONMENT DIVISIONA section is not error is 600 ILLEGAL LEVEL NUMBER. TREAT AS terminated ignored. by a or number 601 header period. The 01. This level number is hot an 77, is The 88 is 1level assumed number. to be 01-49, The 66, level 01l. TERMINATOR MISSING AFTER ENV DIV HEADER. The ENVIRONMENT DIVISION header is not terminated by a period. The period is assumed present and processing continues. 602 .DATA. NOT FOLLOWED BY : - DIVISION. The word DATA is word not DIVISION. present. 603 ENVIRONMENT DIVISION by the assumed | program DIVISION COBOL PROGRAM contains header. proce551ng UNRECOGNIZABLE 1is HEADER OMITTED. The 604 followed DIVISION FORMAT. at the next no ENVIRONMENT compiler resumes paragraph header. ABORT. “ 'The compiler is reserved word first word The unable to recognlze “the IDENTIFICATION as 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 fact, (1) IDENTIFICATION is, in omitted word of the source file, first the as a (2) the user is attempting to compile conventional program in source COBOL the specifying without format switch, or (3). the format conventional file a compile to user is attempting The program. source that is not a COBOL 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. The IDENTIFICATION DIVISION terminated by a period. not and present assumed is is header The period processing continues. 607 .PROGRAMID. EXPECTED AFTER DIVISION HEADER. The IDENTIFICATION not followed DIVISION by error The paragraph. processing continues. 610 TERMINATOR OMITTED AFTER .PROGID. PARA the 1is is header PROGRAM-ID and ignored HEADER. not is paragraph-name PROGRAM-ID The is period The period. a by terminated processing and present assumed 611 / 7 e Pe N ~ N continues. INVALID PROGRAM NAME IN . PROGRAM ID. The 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 more than program or that more than 30 SAME RECORD the 1in specified are clauses AREA 1limit a The compiler imposes program. the cases, because 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 word is found where verb is expected. a verb, period, or 614 The compiler scans word in Area A. 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. is an observation only. 615 PROCESSING RESTARTS This message ~ 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‘V.IDENTIFICATION.‘KEYWORD NOT IN AREA A. The compiler detects IDENTIFICATION Kkeyword A. The compiler ignores continues processing. 620 not the period. processing .LINAGE. INVALID FOR THIS FILE. was terminated The period continues. CLAUSE is Area error and without assumed for a file that organization. ignored. DIAGNOSTIC ERROR MESSAGES a and IGNORED. - The LINAGE clause must not be 'D=-50 the in PARAGRAPH TERMINATOR ASSUMED OMITTED. A paragraph 621 that is has The RELATIVE LINAGE specified or INDEXED clause is 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 624 VERB EXPECTED TO FOLLOW ELSE.. IGNORED. ELSE statement. has The ELSE no is associated IF ignored. .ELSE. IGNORED. A sentence ends with ELSE is ignored. 625 name 1is not The period is processing .JUSTIFY. WITH NUMERIC OR EDITED ITEM. 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 is 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 in 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 has depth of 30 ignores nesting exceeded levels. beyond the The this DIAGNOSTIC ERROR MESSAGES D-51 " | 632 DUPLICATE PROCEDURE NAME DETECTED. In the or Procedure Division, section-name a 1is defined uniquely referenceable qualification. 633 REFERENCE TO UNDEFINED PARAGRAPH paragraph that is not even with NAME. In the 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 clause exceeds 150 It is truncated to 635 the ASSIGN ILLEGAL SYNTAX IN .GO TO. STATEMENT. The the 636 in characters in length. 150 characters. INVALID INTEGER OR compiler detects GO TO statement. illegal Fatal. syntax 1in DATANAME. In the LINAGE failed to clause, recognize the a compiler non-negative integer literal or a numeric integer data-name. This phrase of the LINAGE clause 637 .GO TO. HAS MULTIPLE is ignored. PROCEDURE NAMES. A GO ON TO statement without the phrase has more procedure-name. 640 INVALID WORD FOLLOWS Fatal. .DATA DIVISION. The word following the header either does not or is not one of the FILE, DATA DIVISION start in Area A reserved words WORKING-STORAGE, LINKAGE, PROCEDURE. The compiler source text until one of FILE, WORKING-STORAGE, PROCEDURE is D-52 DIAGNOSTIC DEPENDING than one ERROR MESSAGES recognized. or skips all the keywords LINKAGE, or - N 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, LINKAGE, is 642 .OMITTED LABELS IGNORED WITH .VALUE OF a file. Warning. «.SECTION. PROCEDURE ID. The LABEL RECORDS ignored if VALUE 643 or recognized. ARE OMITTED clause 1is OF ID is specified for STANDARD labels are assumed.- | EXPECTED AFTER HEADER WORD. The keyword SECTION is omitted after the word FILE, WORKING~-STORAGE, OR LINKAGE SECTION. It 1is assumed present and processing continues. 644 TERMINATOR EXPECTED AFTER SECTION HEADER. ‘The FILE SECTION, not terminated is assumed 646 .OF. OR .ID. MISSING IN SECTION, or and LINKAGE by a WORKING-STORAGE SECTION period. processing header The is period continues. . One or both of the keywords OF or ID is omitted in the VALUE OF ID clause. Their presence is assumed and processing continues. 647 ILLEGAL WORD IN AREA A. SCAN 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 the three recognized GROUP LEVEL .VALUE. DISALLOWED. The VALUE clause not 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 ID .PD. USING.. This LINKAGE SECTION item has been referenced 1in 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 in 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 I-0O CONTROL paragraph, the MULTIPLE FILE TAPE clause is specified for a file whose organization 1is not SEQUENTIAL. The MULTIPLE FILE TAPE clause 653 is ignored for this file. .VALUE. CLAUSE ILLEGAL IN FILE SECTION. A VALUE clause is specified for description entry given SECTION. The VALUE clause 654 SYNTAX ERROR IN CURRENCY in is a data the FILE ignored. 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 1is not allowed as the currency sign either because the literal is longer than one character or because it is an invalid COBOL currency sign. The CURRENCY SIGN clause is ignored, and the currency sign defaults to the dollar sign. 656 SPECIALNAMES CLAUSE INVALID. An unrecognizable word appears in 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 ) 3 s \ '//',—-\ SYNTAX ERROR IN DECIMALPOINT CLAUSE. ! . 657 The keyword COMMA is omitted 1in the DECIMAL-POINT IS COMMA clause of the SPECIAL-NAMES paragraph. The clause is ignored. 660 .AFTER. MISSING IN .USE. STATEMENT. ASSUMED. The keyword AFTER is omitted in the USE statement. AFTER is assumed present and processing continues. 661 NO .ERROR. OR .EXCEPTION. IN .USE. ASSUMED. EXCEPTION or keywords ERROR One of the the USE statement. in omitted is present missing keyword is assumed processing continues. | 662 The and NO KNOWN CLAUSES IN SPECIALNAMES. ' The SPECIAL-NAMES paragraph contains valid clauses. no This is an observation only. REDUNDANT .USE. COVERAGE. v//_,,A.;\\ 663 PREV. .USE. IGNORED. Multiple USE statements have The last USE file. 1is then applied file. Fatal. same the specified referenced 664 UNKNOWN OPEN MODE IN .USE. specified GROUP ITEM HAS statement to the STATEMENT. An unrecognizable OPEN mode 665 referenced in the USE option statement. was Fatal. BEEN CALLED FILLER. A FILLER item cannot have any elementary items subordinate to it. The compiler replaces the FILLER declaration with a proceeds with and name system-defined the processing of the newly-named group is name system-defined item. The transparent and inaccessible to 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. ~ 670 VALUE NOT PERMITTED WITH The divisor literal of ignored. 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 FOLLOWING an is 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 a the USE Fatal. CLOSED. The referenced file was opened, but there was no CLOSE statement detected for this file in the program. 674 SUBJECT OF .ALTER. IS SECTION NAME. The ALTER statement references a section name. Only paragraph names may be altered. 1If this statement 1is reached during execution, the program will be aborted. 675 ~FILE~COVERED BY CONFLICTING USE PROCEDURE. There was more than one conflicting procedure specified file. Fatal. 676 DATA DIVISION EXCEEDS for the USE referenced . ADDRESS RANGE. The maximum DATA DIVISION size is 65,535 bytes. 677 SUPPLIED VALUE | b INVALID FOR NUM Fatal. ITEM. IGNORED. ‘The VALUE clause specifies invalid value initialization for a numeric data item. The compiler ignores the VALUE clause. D-56 DIAGNOSTIC ERROR MESSAGES TN 700 FILE ACCESSED BY VERB REQUIRING REL. OR IDX ORG. A file whose organization is referenced is by the SEQUENTIAL START or DELETE the has that verb verbs or by an I/0 1In all specified. clause KEY 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 INDEXED is referenced by an I/0 verb 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 in this release of the implemented not compiler. The compiler scans to another verb, period, or word in Area A. 704 OCCURS ILLEGAL FOR 01 OR 77 ITEM. IGNORE. 01 An OCCURS clause is specified for an The compiler data-name. 1level or 77 ignores 705 .ACCEPT FROM. OBJECT NOT IN the OCCURS clause. 5 SPECIALNAMES. The mnemonic-name used 'in the defined not was statement Fatal. SPECIAL-NAMES paragraph. 706 ACCEPT IDENTIFIER ACCEPT in the INVALID. is verb ACCEPT The word following the data-name or is a data-name that a not class. has non-DISPLAY usage or invalid Fatal. 707 VERB OR COND. CLAUSE CONFLICTS WITH FILE ACCESS. There MODE is a conflict between the ACCESS of the referenced file and the I/0 verbs and/or condition clauses reference this file. - Fatal. 710 DATANAME AFTER .GO DEPENDING. that INVALID. The word following the DEPENDING ON phrase of the GO TO statement is not a has that data-name a data-name or is Fatal. INDEX usage. 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 1is a numeric, non-integer data-name. Fatal. 712 . DISPLAY UPON. OBJECT/NOT IN SPECIALNAMES. The mnemonic-name used in statement defined was SPECIAL-NAMES 713 paragraph. the DISPLAY 1in the Fatal. .DISPLAY. OPERAND IS INVALID. A data item invalid 714 not in the DISPLAY class or USAGE. statement has MISSING OR INVALID OPERAND FOR ARITHMETIC VERB. One of the statement | operands of an 1is either missing arithmetic or invalid. Fatal. 715 MISSING OR INVALID SOURCE OPERAND. The source operand an 716 MISSING OR 717 .GIVING. REQUIRED AFTER .DIV...BY. The .GIVING. GIVING phrase MULTIPLY, or literal. Fatal. missing in a Fatal. is of SUBTRACT required ADD, if an the DIVIDE, statement is a .BY. MISSING IN .MULTIPLY. .BY. OR .INTO. MISSING FROM One of DIAGNOSTIC ERROR MESSAGES BY is missing Fatal. in a MULTIPLY .DIVIDE. missing Fatal. D-58 is REQUIRED AFTER LITERAL OPERAND. The keyword statement. 722 INTO statement. The GIVING phrase second operand 721 following Fatal. INVALID DESTINATION OPERAND. DIVIDE...BY 720 is missing arithmetic verb. the from keywords the BY DIVIDE or INTO is statement. 723 .FROM. MISSING IN .SUBTRACT. The keyword FROM is missing SUBTRACT statement. Fatal. 724 FILE NEEDS DYNAMIC ACCESS FOR - from the .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 Fatal. 726 invalid procedure 1in the ‘ PERFORM name 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 is statement. | .TIMES. PERFORM 1integer 1literal. of 1 for MISSING FROM .PERFORM.. 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 1is assumed present. 730 PROCEDURE NAME OMITTED IN .ALTER. . A valid = procedure-name recognized in the ALTER Fatal. 731 ILLEGAL .ALTER. DUE TO MISSING was not statement. .TO.. The keyword TO was not recognlzed ALTER statement. Fatal. 732 in the FILE HAS VAR. SIZE RECS. .READ INTO. ILLEGAL. It is 1illegal for the READ INTO statement to reference a file that has multiple record descriptions of different 1engths. Fatal. 733 - FILE ACCESSED BY VERB REQUIRING LINAGE A f11e that did not have a LINAGE clause in 1its specification is accessed by an I/0 verb. Fatal. DIAGNOSTIC ERROR MESSAGES D-59 7134 .DELETE. OR .REWRITE. WITHOUT INV. KEY A DELETE or OR USE. REWRITE the INVALID KEY for which there Fatal. 735 OPEN MODE OR NO READ PROHIBITS REWRITE A or DELETE statement without phrase references a file 1is no USE procedure. 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 references a file that was not opened in the proper Fatal. 737 +WRITE. CONFLICTS WITH OPEN mode. | MODE. A'WRITE statement references a file that was not opened in the proper mode. Fatal. 740 . READ. CONFLICTS WITH OPEN MODE. A READ statement references a file is only opened Fatal. 741 USE NOT IN DECLAR. OR NOT FOLLOWING in OUTPUT or | SECTION that EXTEND mode. NAME. The USE statement 1is 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 255 ALTERNATE been exceeded. 743 The clause 1is KEYS has ignored. INTEGER IN SWITCH CLAUSE INVALID OR OMITTED;' A SWITCH clause of the SPECIAL-NAMES paragraph either contains an invalid numeric integer 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. The required keyword IS is omitted in a the SPECIAL-NAMES paragraph. clause of processing assumed present and IS is continues. 745 DEVICE MNEMONIC OMITTED IN SPECIALNAMES. mnemonic-name device valid A 1is not CONSOLE, the of one in recognized -~ CARD-READER, | LINE-PRINTER, PAPER-TAPE-PUNCH or PAPER-TAPE-READER, paragraph. clauses of the SPECIAL-NAMES All text source 1is skipped until the next recognizable keyword. 746 TERMINATOR OMITTED IN SPECIALNAMES. The SPECIAL-NAMES paragraph terminated by a period. and present assumed continues. 747 , SUBJECT OF .ALTER. NOT .GO TO.. ALTER IGNORED. "'/-R\\ by referenced The paragraph not contain does statement is KEYWORD OMITTED IN .SWITCH. ALTER an TO GO a The statement. statement as its first ALTER statement 750 not is The period is processing | 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 paragraph. | ignored. is .SWITCH. The SWITCH CLAUSE. A valid condition-name is not recognized the of clause SWITCH the in SPECIAL-NAMES clause 752 .CR. OR .DB. NOT AT RIGHT END OF paragraph. PICTURE., The PICTURE symbol CR appear string. SWITCH The ignored. is at or DB does not the right end of the PICTURE the ignores compiler The the treats and PICTURE user-supplied a with alphanumeric as item data "PICTURE X" DECLARATION. DIAGNOSTIC ERROR MESSAGES D-61 753 .CR. OR .DB. USED WITH SIGNED ITEM. Both the PICTURE symbols, CR or DB, and a sign, + or -, appear 1in the same PICTURE. The compiler ignores the user-supplied PICTURE and treats the data item as alphanumeric with a "PICTURE X" declaration. , 754 MULTIPLE DEFINITION OF SWITCH. FIRST USED. Multiple are definitions detected in of paragraph. All but the of SWITCH are ignored. 755 . SENTENCE. ASSUMED AFTER .NEXT. The COBOL switch SPECIAL-NAMES first definition | | keyword NEXT keyword present 756 a the is not followed by the SENTENCE. SENTENCE is assumed and processing continues. SUBSCRIPT NOT NUMERIC INTEGER. A data-name used as a subscript 1is not numeric in class. A default value of 1 is assumed as the subscript. 760 761 ILLEGAL INDEXED SYNTAX FILE IN .DIVIDE. REQUIRES RECORD The compiler detects illegal the DIVIDE Fatal. .RECORD | 762 STATEMENT. KEY. statement. FOR THIS RECORD KEY indexed files. .ALT RECORD KEY. INVALID o : FILE. The 763 FOR FILE. clause is valid for only for IGNORED. The ALTERNATE RECORD KEY clause only 764 in PHRASE. Self explanatory. KEY INVALID syntax indexed files. is valid ”READ-AHEAD. OR. WRITE-BEHIND. NOT SUPPORTED. The APPLY READ-AHEAD and APPLY WRITE-BEHIND clauses are not supported in this version of the compiler. The APPLY clause is ignored. D-62 DIAGNOSTIC ERROR MESSAGES 765 INTEGER INVALID IN. RESERVE»AREA. CLAUSE. by reserved The number of buffer areas The 1invalid. 1is RESERVE <clause the RMS default clause 1is 1gnored and the is 766 used. BAD VALUE IN BLOCK CONTAINS CLAUSE. in the BLOCK The numeric literal clause is less than the sum of the record size, the record header size, and the bucket header size. The BLOCK CONTAINS clause is ignored. 767 VALUE IN. BLOCK CONTAINS. CLAUSE IS ROUNDED UP. clause 1is value The 512. of multiple a not is rounded up to the next even multiple of | 512. The numeric literal in the BLOCK 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 SELECT clause paragraph is non-alphanumeric defined class 1in the with FILE SECTION. 772 .RECORD KEY. DATA ITEM CANNOE BE VARIABLE LENGTH. ! | i 773 .RECORD KEY. KEY RECORD A data-name referenced in a of a phrase KEY RECORD ALTERNATE or FILE-CONTROL the in clause SELECT FILE SECTION the in defined is paragraph as an item whose size is variable. ITEM NOT DEFINED IN RECORD OF FILE. RECORD KEY A data-name referenced in a an ALTERNATE RECORD KEY phrase of a or the 1in not defined 1is SELECT clause associated the record description of file. DIAGNOSTIC ERROR MESSAGES D-63 774 FILE ACCESSED BY VERB REQUIRING INDEXED ORG. e A file whose or RELATIVE organization is 1is referenced verb that has the phrase specified. must 775 .KEY IS. have INDEXED PHRASE INVALID FOR SEQUENTIAL Either the the READ NEXT. INVALID DATANAME IN .KEY IS. KEY IS data-name The referenced file organization. file has ACCESS SEQUENTIAL or statement contains the word either case the KEY IS is illegal. Fatal. PHRASE. The KEY IS phrase of the READ ‘was 777 .KEY IS. PHRASE NOT Fatal. .READ. In data-name phrase 776 SEQUENTIAL by the READ not FOLLOWED BY followed RECORD the KEY or a statement data-name. Fatal. KEY. The data-name phrase of the RECORD by following the READ statement ALTERNATE referenced RECORD file. The data-name is assumed. KEY IS is not a KEY for RECORD KEY | 1000 VARIABLE OCCURRENCES TABLE MUST END RECORD. A COBOL table DEPENDING ON declared phrase can be the record only by data entries whose level-numbers than the 1level-number of entry. The remainder the compiler of point record where the 1001 .ASCENDING. OR .DESCENDING. A or RENAMED DATAITEMS NOT the | EXPECTED. user-defined but 1002 in descriptor from error is detected.. | DATANAME the description are greater this table ignores the Fatal. with followed DESCENDING KEY IN CURRENT The data-name was expected, found, in the ASCENDING KEY IS not B RECORD. data RENAMES IS phrase. 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 entry. D-64 DIAGNOSTIC ERROR MESSAGES 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. ' s IS OMITTED IN THE | | | .OCCURS. | CLAUSE. In a variable occurrence table declaration, the keyword DEPENDING has been omitted. The compiler 1ignores the remainder of the OCCURS <clause and | treats the table declaration ordinary COBOL table. as an 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 treats | of the the table ordinary COBOL OCCURS clause declaration table. as and . an * 1006 .OCCURS DEPENDING. SUBORDINATE TO AN .OCCURS. / (~ i} . The compiler detects a table declaration with : a DEPENDING ON phrase subordinate to a group 1item that has an OCCURS clause. The compiler ignores the | . DEPENDING | ON declaration as phrase and treats the 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 value to be one greater than the integer value following the 1is, (that OCCURS keyword the minimum) . 1010 EXPECTED .DEPENDING ON. DATANAME NOT DEFINED. The data-name referenced in a DEPENDING not defined in the DATA was phrase ON DIVISION. Fatal. DIAGNOSTIC ERROR MESSAGES D-65 1011 EXPECTED .ASCENDING KEY. DATANAME NOT DEFINED. The data-name referenced in an ASCENfiiNG KEY phrase DIVISION. 1012 EXPECTED .DESCENDING KEY. DATANAME The KEY was not defined in the DATA Fatal. NOT | DEFINED. data-name referenced in a DESCENDING phrase was not defined in the DATA DIVISION. Fatal. 1013 .. DEPENDiNG-ON. DATANAME NOT A NUMERIC INTEGER. The ON data-name referenced in phrase was not declared integer 1014 - RENAMES. APPLIED TO AN in the DATA INVALID LEVEL OF "The = RENAMES renaming of DIVISION. . DEPENDING ON. DEPENDING a numeric Fatal. DATA. clause specifies data items whose number is 01, 66, compiler ignores the description entry. - 1015 a as the 1level 77, or 88. entire RENAMES . The data DATANAME DETECTED WITHIN TABLE. The compiler detects a data-name, that follows a DEPENDING ON phrase and that defines the current number of occurrences 1in table, to have within the range 1016 - OCCURS. CLAUSE ON A TABLE KEY DATANAME. The compiler detects the presence of an been or OCCURS clause on declared as DESCENDING 1017 a variable occurrence 1its storage allocated of the table. Fatal. KEY. a data an item that has ASCENDING Fatal. . SEARCH ALL. TABLE DOES NOT.HAVE KEYS. The table being searched by a SEARCH ALL statement must have the ASCENDING KEY or DESCENDING KEY phrase spec1f1ed in 1its declaration. Fatal. 1020 IMPERATIVE STATEMENT EXPECTED DURING - SEARCH. A period was or found environment statement. D-66 DIAGNOSTIC ERROR MESSAGES 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 referenced. Fatal. 1022 .WHEN. EXPECTED BUT NOT FOUND The IN .SEARCH. compiler expected but failed to 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 SEARCH statement. 1024 THE KEYWORD .SEARCH. ILLEGAL IN THIS Fatal. 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 being searched. 11026 index name of the table Fatal. THE KEYWORD .SENTENCE. EXPECTED AFTER .NEXT.. The keyword SENTENCE was not detected after the NEXT keyword during the compilation Fatal. 1027 of a SEARCH | - statement. 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 SEARCH or SEARCH ALL verbs must have both the INDEXED BY and the OCCURS its in specified clauses declaration. Fatal. o ’ Ve TM. The table data item reference DIAGNOSTIC ERROR MESSAGES D-67 1031 DATANAME EXPECTED AFTER .VARYING. IN .SEARCH. { No data-name reference was the VARYING ~statement being 1032 . VARY ING. found keyword in the compiled. Fatal. after SEARCH ITEM MUST BE INDEX OR 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 side of item referenced on the left the SEARCH ALL simple condition must declared be DESCENDING KEY. 1034 DATA ITEM NOT A KEY FOR THIS .SEARCH. as an ASCENDING or Fatal. TABLE. The data item referenced on the 1left 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 1is 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 is not defined as a data item’ subordinate to the associated 1042 SEARCH table. INVALID OR MISSING DATANAME AFTER .RENAMES.. The data-name is missing after the RENAMES 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. 1043 .OCCURS. ITEM NOT ALLOWEDVBETWEEN TABLE AND KEY. item data a detects compiler The clause OCCURS an with declared of "sandwiched" between the declaration another COBOL SEARCH key. 1044 | table and its associated .RENAMES.,SPECIFIES 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 ADD, CORRESPONDING 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 or the processing MOVE of an CORRESPONDING ADD, SUBTRACT, statement, compiler detects the omission of the or FROM keyword. the TO Fatal. 1051 INVALID OR MISSING DATANAME AFTER .TO. OR . FROM. In or the processing MOVE of an CORRESPONDING ADD, SUBTRACT, statement, the compiler detects the omission of a valid data-name reference after the keyword TO 1052 NO OBJECT CODE PRODUCED FOR In or FROM. Fatal. .CORRESPONDING. the processing MOVE compiler of an CORRESPONDING produced no ADD, SUBTRACT, statement, object code the because no "correspondence" was found between the two group items referenced 1in the COBOL statement containing the CORRESPONDING option. This diagnostic is informational 1053 GROUP ITEM NOT REFERENCED IN only. .CORRESPONDING. In the processing of an ADD, SUBTRACT, MOVE CORRESPONDING statement, the compiler discovered that one of the references is a reference to an elementary item. Fatal. or 1054 LEVEL 66 REFERENCE DISALLOWED IN - CORRESPONDING. In the processing of an MOVE CORRESPONDING compiler detects a or D-70 DIAGNOSTIC ERROR MESSAGES ADD, SUBTRACT, statement, the reference to a TN or data-name declared an 1055 invalid at level reference. 66. This 1is Fatal. .FILE STATUS. ITEM DEFINED IN .FILE SECTION. A data—-name referenced in a FILE phrase of a SELECT clause STATUS 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. ; 2 B a’wh‘uA TM . 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 EMPTYr.GO TO. WAS NOT THE SUBJECT OF AN .ALTER.. A GO TO statement without reference was detected. is not the subject ~statement. Fatal. a procedure The empty GO TO of an ALTER 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 in the current 1062- PARAGRAPH WITHOUT SECTION CALL. PRECEDES THIS SECTION. In a COBOL program, if one paragraph 1is in a section, then all paragraphs must be in sections. In this source program, a paragraph not within a section has been detected preceding the source program. 1063 DUPLICATE PARAGRAPH NAME this | section o 1in 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 detects a undefined procedure PROCEDURE 1065 UNDEFINED PROCEDURE reference to name in QUALIFIER REFERENCE. The compiler detects reference that undefined - ILLEGAL PROCEDURE a in the detects an PROCEDURE NAME REFERENCE. The AMBIGUOUS qualifier qualified an contains DIVISION. compiler procedure PROCEDURE 1067 an the DIVISION. procedure 1066 ( PROCEDURE NAME name DIVISION. invalid reference in the (/ REFERENCE. The compiler in the procedure name that is not uniquely referenceable, through qualification. even . PROCEDURE detects DIVISION a reference to a 1070 PARAGRAPH NAME DISALLOWED AS QUALIFIER. The compiler procedure qualifier detects a qualified reference in which is a paragraph name. (\ the - :1071 SECTION NAME REFERENCE MAY NOT BE QUALIFIED. The compiler detects a qualified reference 1in which a section is qualified by another section procedure name name. 1072 AMBIGUOUS PARAGRAPH NAME REFERENCE. The * compiler PROCEDURE detects DIVISION a reference in the to a paragraph. name that is not uniquely referenceable, through qualification. even 1073 POSSIBLE .PERFORM. RANGE VIOLATION. | The compiler statement following - DIAGNOSTIC a PERFORM THRU name the procedure name following the PERFORM. This condition could a logic problem in the D-72 detects 1in which the procedure THRU 1is defined before ERROR MESSAGES COBOL program being compiled. </ , 1074 NUMERIC PROCEDURE NAME EXCEEDS \ 30 CHARACTERS. a be to A numeric string that appears 30 exceeds name procedure numeric characters in length. The string is on the right to 30 characters truncated ‘and processing of the numeric procedure name continues. 1075 NUMERIC PROCEDURE NAME CONTAINS DECIMAL POINT. be 'a to A numeric string that appears a contains name procedure numeric the ignores compiler The point. decimal of with presence proceeds point decimal of processing the the - name. , i e ~.. Y . 3 numeric procedure and the 1076 .RELATIVE KEY. ITEM DEFINED IN RECORD OF FILE. A data-name referenced in a RELATIVE KEY of a SELECT clause is defined in phrase of the associated the record description this error ignores compiler file. The and continues to KEY 1077 NO. OF AREAS DEFAULTS TO MAX. process the RELATIVE data-name. FOR FILE TYPE. by The number of buffer areas reserved the than greater is clause RESERVE the file the for allowed max imum compiler allocates The organization. one two areas for a sequential file and for a relative file. 1105 UNRECOGNIZED LITERAL TYPE...SYSTEM ERROR The compiler ‘identify a has failed literal. to System ©properly error. Fatal. 1107 .TO. OR .GIVING. MISSING < IN ADD found not The keyword TO or GIVING was ADD an operand in second the ‘after statement. 1110 MORE THAN 18. DIGITS IN COMPOSITE. 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. More than one USE FIRST. destination data-name follows the keyword CORRESPONDING. The compiler ignores all but the first.. Warning. 1113 UNSIGNED COMP 3 ITEMS ILLEGAL The PICTURE for a COMP-3 contain an S character. item does Fatal. not | 1114 ARGUMENT CANNOT BE PASSED .BY DESCRIPTOR. The compiler detected COMPUTATIONAL usage, JUSTIFIED RIGHT DESCRIPTOR in statement. only by that the Such REFERENCE an identifier with SEPARATE SIGN, or is being passed USING phrase items can or VALUE. of a be by CALL passed Fatal. 1115 .BY VALUE. ARG. MUST BE .COMP. LONGWORD INTEGER. An argument statement passed must by be VALUE 1in 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. The detected keywords no identifier BY REFERENCE, BY DESCRIPTOR 1n a CALL Fatal. LONGWORD INTEGER. identifier 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 positions; that is, its PICTURE must be in the range 9(5) to 9(9). Fatal. 1121 .SEARCH. VERB NOT PROCESSED | - Because (warning process Fatal. D-74 DIAGNOSTIC ERROR MESSAGES of or the an earlier diagnostic statement completely. fatal), SEARCH the compiler cannot 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 (/ he CODE is the facility code for VAX-11 COBOL-74 is the severity level are fatal. All (fatal). RTS errors first three the is the mnenomic composed of first three words of the RTS characters of the error message. TEXT is the body of the error message string-1 is the character string specified in VALUE OF 'ID ( (string-2) b string-3 - clause is the literal used in SELECT...ASSIGN entry ages | is is the RMS error message, thismess printed itself. on the 1line after the error message Associated with each error is an eight digit hexadecimal status code 00001 IDENTIFICATION DIVISION. - 00002 PROGRAM-ID. 00003 00004 ENVIRONMENT (/ in parenthesis). (enclosed 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: SUBERR. DIVISION. 00005 SOURCE-COMPUTER. VAX-11. OBJECT-COMPUTER. VAX-11. 00008 CONSOLE SPECIAL-NAMES. 00009 DATA 00010 00011 WORKING-STORAGE 01 T-NUMBER 00012 00013 00014 01 IS | CONSOL. DIVISION. SECTION. PIC TABLE-VALUES. 03 FILLER 03 FILLER 00015 00016 00017 00018 00019 00020 03 03 03 - X(5) X(5) VALUE VALUE "ONE "TWO PIC PIC PIC X(5) X(5) X(5) VALUE VALUE VALUE "THREE". "FOUR ". "FIVE ". FILLER FILLER FILLER 00022 MAIN 00033 00034 T-VALUES 03 PARA. SECTION. , | : ". . PIC 'PIC 00021 00024 00025 00026 00027 00028 00029 00030 00031 00032 01 9. | REDEFINES TABLE-VALUES. TAB-VAL OCCURS 5 TIMES INDEXED BY 05 FILLER PIC XXXXX. PROCEDURE DIVISION. 00023 , - 00006 00007 | T-INDEX. - | | DISPLAY "ENTER NUMBER : " UPON CONSOL NO ADVANCING. ACCEPT T-NUMBER FROM CONSOL. T-NUMBER = 0 GO TO FINISH. SET T-INDEX TO T-NUMBER. DISPLAY TAB-VAL(T-INDEX) GO TO PARA. ( : ( ‘ IF FINISH. | UPON CONSOL. DISPLAY "*** END OF SESSION ***" UPON CONSOL. STOP RUN. | : The program will prompt you for input - numbers from lvtb 5 (0 will 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: cause E-2 RUN-TIME ERROR MESSAGES ’ | — / (\ v nnn-nn-nnn ASSIGN SET 'Pl COBSCONSOLE NOON AGAIN: RUN SUBERR IF SSTATUS EXIT | .EQ. - %X101D800C THEN GOTO WRITER ' WRITER: | WRITE SYSSOUTPUT "Index must be less than 6 - type 0 to quit" GOTO AGAIN NOTE The line parameter 'Pl1 "ASSIGN..." in allows command you specify a device at run-time. If you include the preceding commands in link SUBERR procedure, with the /NOTRACEBACK a file to qualifier, named and the following will appear at your terminal: CHECKER.COM, execute the @CHECKER OPAOQ: ENTER NUMBER You could now : input a number from the system console: 'ENTER NUMBER : 3 THREE ENTER NUMBER : If you enter a number other than YN appear on the 0 through 5, the following will terminal: ENTER NUMBER : 3 'THREE ENTER NUMBER : 6 $C74-F-SUBOUTRAN, subscript out of range Index must be less than 6 - type 0 to quit ENTER NUMBER : | ’ » o See the VAX/VMS Command Language User's Guide for a full dlscu551on of command procedures and batch jobs. The remainder of this appendix describes the run—tlme error messages. BADFILNAM, bad f11e name strlng-1 (strlng 2) (001D8OE4) ! The file specification and/or associated switches for a file description are | syntactically incorrect. P RUN-TIME ERROR MESSAGES E-3 CLOERRFIL, (001D8094) CLOSE error - on file strlng -1 (strlng 2) string-3 The execution of a CLOSE failed. The accompanying RMS further COMGENABO, compller (001D8034) generated specifies the error. The run—-time of the errors. system tried program that See your error on file (001D80OCC) (strlng 2) execution failed. further execute a fatal program | strlng -1 The to contains source listing. DELETE - abort part DELERRFIL, statement error code The of string-3 a DELETE statement accompanying RMS specifies the error. error code ERRACC, error in ACCEPT loglcal—name string- 3 (001D810C) An error a record occurred while from logical=-name. further the The specifies trying file with error code RMS the to ACCEPT associated error. "SHOW TRANSLATION logical-name" use to determine the logical-name. ERRCLOUNI, error (001D8084) string-1 REEL in DISPLAY logical- name CLOSE UNIT or RMS error error. code The further . string-3 error DISPLAY (001D8054) a statement that failed. , An EXPTOOLAR, - string-3 executed accompanying specifies the error f (string-2) program CLOSE (001D8104) be of in CLOSE UNIT or REEL on file The ERRDIS, can value occurred a assocliated with error further code while record trying from the logical-name. specifies to file The the RMS error. exponent too large The exponent used'ih a COMPUTE statement is out -32768 to E-4 RUN-TIME ERROR MESSAGES of range. 32767. The legal range is FILALROPN, file string-1 already open (001D805C) The program tried to open a file that 1is currently open. FILPRELOC, (001D807C) file string-1 (string-2) previously locked \ for file The program tried to access a a had previously executed it which CLOSE...WITH FINNOTOPN, LOCK statement. | file String—l not open- (001D8064) The program tried to CLOSE or ’ '/’—\‘\ (001D8114) otherwise not currently 1is | | open. INVDECDAT, that file a access invalid data in decimal data-item <address-of-error> invalid 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 used be clean-up invalid data in existing files. INVLINVAL, invalid LINAGE value on file string-l1 (string-2) (001D80A4) body ‘The LINAGE clause specifies a page results in an invalid value; that size INVOPEFIL, the value is not greater it of is out than Or zero, range. invalid operation on file string-1 (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 for (c) an I/O operation not consistent (for organization file the with sequential a START on example, a file open for INPUT file). RUN-TIME ERROR MESSAGES E-5 NOEOFPRO, no EOF processing on flle string-1l (001D8OAC) (string-2) An end-of-file condition has been detected, but the 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-l1l (string- 2) not open for operation The program tried statement NULGOTO, GO TO executed has (001D802C) not been for number of arguments execute that is an not I/0 open. The program reached an alterable GO TO it a before procedure (001D8044) to file ALTERed statement - NUMARGCAL, a assigning name. in CALL incorrect 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 arguments the calling program is not the same . the number PROCEDURE called OCCDEPVAL, OCCURS (001D8014) DEPENDING value y DIVISION out of The value the. size clause. (O01D8OFC) error openlng loglcal name An for (001D80F4) of the data item of the table range spec1f1ed | that defines 1is not in in the OCCURS the string-3 error occurred ACCEPT the while file trying to associated RMS error error. open with code error opening loglcal name string-3 \ An as error occurred DISPLAY the while trying to open file associated with logical-name. The further specifie the s E-6 the the range logical-name. The further specifies the OPNCOBOUT, in of program. table size OPNCOBIN, of arguments USING phrase RUN-TIME ERROR MESSAGES RMS error error. code \. rdA\\ , OPNERRFIL, (001D808C) OPEN error The execution failed. further PERCOUTOO, (string-2) on file string-1 PERFORM counter string-3 an of OPEN statement The accompanying RMS error code specifies the error. too large (001D804C) The value of ‘the iteration counter used in a PERFORM statement exceeded 32767. REAERRFIL, (string-2) string-3 READ error on file string-1 (001D80B4) The execution failed. further REANOTPRE, (001D8074) read a READ statement specifies the error. not preceeded by rewrite or string-1 The of The accompanying RMS error code delete on file (string-2) program attempted execute to a N\ a for statement DELETE or REWRITE sequentially accessed file, but the last file was not a the operation on 1/0 i /:’ READ. RECCALDET, recursive CALL detected (001D803C) «call to A COBOL subprogram attempted y. indirectl or directly either itself, be EXIT PROGRAM statement must The the subprogram before in a executed subprogram can be called again. RECPERDET, (001D8024) recursive PERFORM detected The program attempted execute to a PERFORM statement whose exit is also the exit of a previously that is still active. RETEXTOUT, executed , PERFORM 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 currently being is that - statement executed. " RUN-TIME ERROR MESSAGES E-7 REWERRFIL, REWRITE error on file»string—l (string-2) (001D80C4) string-3 The execution of a REWRITE failed. The accompanying RMS further specifies the error. statement error code SAMAREUSE, SAME AREA already in use when opening file (001DBOEC) string-1 (string-2) The program uses the open file. tried same STAERRFIL, START error on file string-1 to OPEN buffer (string-2) (001D80D4) a file area as string-3 The execution of START a failed. The accompanying RMS further specifies the error. SUBOUTRAN, subscript (001D800C) or index out of The the subscript value value of an than zero, the maximum number table data item. (001D80ODC) UNLOCK error on file unsuccessful unlock code for a data item, or index-name, is not or of string-l1l (string-2) An statement error range greater UNLERRFIL, that another a string-3 attempt record accompanying specifies the it is greater than occurrences of the has in been the RMS error error. made file. code | to The further WRIERRFIL, WRITE error on file string-1 (string-2) string-3 (001D8OBC) The execution failed. further E-8 RUN-TIME ERROR MESSAGES of a WRITE The accompanying RMS specifies the error. statement error code N APPENDIX F 'INTERNAL COMPILER ERRORS -- SYSTEM ERRORS This appendix lists errors that the VAX-11l COBOL-74 compiler if it aborts. displays System errors have the following form: C74 -- 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. a. The exhausted all compiler uses the longest blocks remain, clear the disk contiguous disk area available up to 1024 64-word blocks. If 1less than 1000 and start again. If 1000 blocks are available, a 000604 smaller submit job. UNRECOGNIZABLE SOURCE FILE compiler could source file because. The Ao not process /ANSI FORMAT qualifier was not and source program is terminal reference format. IDENTIFICATION missing the used,-‘ not 1in The following errors represent internal table overflow in the compiler: 000017 TOO MANY PROCEDURE NAMES 000020 TOO MANY PROCEDURE 000065 TOO MANY LITERALS 000077 COMMAND BLOCK NAMES TOO LARGE a. A Procedure too large Division for the statement compiler handle. b. 000115 Reduce used in | the compiler malfunctions. (SPR) for any of You should these errors. | program for any 000004 000005 000011 | submit system a or the Software | include the ‘ source in machine readable SPR you submit. INTERNAL WORK INTERNAL WORK INTERNAL WORK FILE FILE FILE form ERROR ERROR ERROR BAD USAGE CODE ELT ALREADY DEALLOCATED INSUFFICIENT CORE - 000012 000013 INSUFFICIENT CORE 000014 INTERNAL ALLOCATION ERROR INTERNAL WORK FILE ERROR 000015 000016 000021 000023 000035 000036 000037 000055 000063 000070 000072 000075 ATTEMPT TO PROCESS MORE ELSE'S THAN IF'S INVALID FILE CLASS ' ERROR IN PROCESSING PROCEDURE TAG TABLE ERROR IN PROCESSING PROCEDURE TAG TABLE WORK FILE SEARCH ERROR INDEX NAME UNDEFINED BY COMPILER INTERNAL ERROR WORK FILE SEARCH ERROR DATA DIVISION SEQUENCE ERROR ERROR IN SUBSCRIPT PROCESSING DATA ITEM STARTING ON ODD ADDRESS ERROR IN DISPLAY DATA ITEM 000076 F-2 identifiers statement. NOTE You should 000001 000002 000003 of . DATA NAME TABLE OVERFLOW The following errors occur if the operating Report number the is to | EXCEEDED STACK INTERNAL COMPILER ERRORS -- CAPACITY SYSTEM ERRORS COBOL—74 Performance N 000100 000101 000102 COMPILER LOOP: 000104 000105 000106 INVALID USAGE ILLEGAL LEVEL NUMBER 000111 000112 000116 000120 000121 000122 000123 000124 000125 000126 000127 000130 000131 000132 000133 000134 000135 000140 000140 1 VRN 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 RECORD ERROR TOO MANY PROCESSING LOGIC IN SUBORDINATE ITEMS ERROR ITEM PROCESSING LOGIC CODE 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 REPLACING ERROR INSPECT REPLACING 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 ERROR INTERNAL ERROR ILLEGAL OPERATOR FOR BOOLEAN OPERATION ILLEGAL USAGE FOR OPERANDS IN RELATIONAL CODE ILLEGAL USAGE FOR OPERANDS IN RELATIONAL CODE ILLEGAL NUMERIC COMPARISON ILLEGAL LITERAL IN ARITHMETIC OPERATION ILLEGAL USAGE FOR DIVIDE OPERAND DIVIDE ERROR ILLEGAL USAGE MULTIPLY FOR MULTIPLY OPERAND ERROR. ILLEGAL USAGE FOR ARITHMETIC OPERAND ADD/SUBTRACT ERROR ILLEGAL ARITHMETIC ILLEGAL COMPARE INDEX PROBLEM IN OPERATOR FOR SEARCH ALL TABLE INTERNAL COMPiLER ERRORS -- SYSTEM ERRORS F-3 7N APPENDIX G PROGRAMMING EXAMPLES This appendix contains examples of VAX-11 COBOL-74 programs. The they are intended to programs do not represent real applications; suggest useful techniques and their implementation with COBOL-74. G.1 CALLING A FORTRAN SUBROUTINE 'COBOL-74 modules can be linked with other VAX-11 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, is available in another language. One example is the square root but exponents (non-integer function, which is not available in COBOL-74 | are not allowed). G.1.1 . The COBOL Program, GETROOT - calls the FORTRAN This program accepts a value from the terminal, and passes the value as a character string (BY SQROOT, - subroutine, It then displays DESCRIPTOR, because that is how FORTRAN expects it). the result. COBOL~-74 does not support the floating point data type: therefore, 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 second DISPLAY shows the result of editing the returned item. value. | 'An INSPECT statement replaces all space characters in zeros; the by result space characters would cause a reserved operand fault when the MOVE statement was executed. ~ IDENTIFICATION DIVISION. PROGRAM-ID. -~ GETROOT. u INSTALLATION. DIGITAL EQUIPMENT CORPORATION. khkkkkhkkhkkkkhkkkhkkhkkhhkhkkhhkkhkhkkkkhkhkkkkkhkkkkkkkhkhkkk * * * This program demonstrates * * * CALL statement in calling FORTRAN-IV-PLUS programs. It calls a FORTRAN subprogram which returns the square root of the * * * '* argument. * * the use of the ' * * *kkkkkkkhhhkhkhhkhhhhkhhhhhhhhhhhhkhkhkhkkhkhkkkkkk * ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. VAX-11. - OBJECT-COMPUTER. = VAX-1ll. DATA DIVISION. WORKING-STORAGE 01 03 03 03 01 01 0l SECTION. INPUT-NUMBER. INTEGER DEC-POINT DECIMAL PIC PIC PIC 9(5). X(1). 9(8). WORK-NUMBER. 03 INTEGER 03 DECIMAL | PIC 9(5). PIC 9(8). DISPLAY-NUMBER PIC 7272,2729.9999. WORK:NUMBER—A REDEFINES WORK-NUMBER PIC 9(5)V9(8). PROCEDURE DIVISION. STARTER SECTION. SBEGIN. MOVE SPACES DISPLAY TO INPUT-NUMBER "Enter number (w1th 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 square root is: INSPECT INPUT-NUMBER REPLACING ALL " " BY "Q" MOVE CORRESPONDING MOVE WORK-NUMBER-A DISPLAY GO TO SBEGIN. STOP RUN. - G-2 INPUT-NUMBER TO WORK-NUMBER TO DISPLAY- NUMBER DISPLAY-NUMBER. ENDJOB.. 'PROGRAMMING EXAMPLES " INPUT-NUMBER | 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 SORT function in the statement that encodes the result into the l4-character . argument. SUBROUTINE SQROOT (ARG) CHARACTER*14 ARG VAL RG, ERR=20) DECODE (14,10,A FORMAT (F12.6) IF(VAL.LE.0.)GO TO 20 10 ) SQRT (VAL) ENCODE (14,10,ARG 999 20 RETURN ARG="**kkkkkkkkkkkk! GO TO 999 END ’ Sample Run of GETROOT G.1.3 S RUN GETROOT <CR> Enter number (with decimal point): 5.000000 The square root is: 25. <CR> 5.0000 Enter number (with decimal point): HELLO <CR> | ** INVALID ARGUMENT FOR SQUARE ROOT <CR> 1000000. point): decimal (with Enter number * 1000.000000 The square root is: 1,000.0000 Enter number (with decimal point): 1.414214 The square root is: 1.4142 Enter number (with decimal point): 2. <CR> <CR> $ PROGRAMMING EXAMPLES G-3 G.2 The CALLING VAX-1l1l RUN-TIME PROCEDURES VAX-11l 'purpose Common and using the ~callable Run-time Procedure language- spec1f1c VAX-11l procedure Library procedures. calling contains The standard; The procedures are described in the VAX- 11 Common G.2.1 The Manual. COBOL Program, This program calls rtwo and FORSDATE. LIBSMOVTC character example). uses a written they Run-Time 'Procedure- in the Run-Time Library: LIBSMOVTC table to translate each character and all non-graphic all parameters to be FORSDATE returns the system date as a it expects the string to be passed by 9-character reference. string. - Note | DIVISION. RUNTIME. * , This program demonstrates the method calling VAX-11l Run-time Procedures. %* for A * * % khkkkkhkhkkhkkhhkkhhkhkhkhhkhhkhkhhkkkhhkhkhkkkkkkkhkhkhkkhkkkk DATE-COMPILED. ENVIRONMENT DIVISION., CONFIGURATION DATA 01 01 01 -~ G-4 01 VAX-11. VAX-11. DIVISION. WORKING-STORAGE 01 | SECTION. SOURCE-COMPUTER. OBJECT-COMPUTER. SECTION. INPUT-AREA 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 " 1""§$3&' () *+,-./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 a characters to spaces. passed by descriptor. khkkkkkhkhkhhhhkhkkhkhkhhkhkhhkhkhhhkhkhkkhhkkhhkkhkhkkkhhkkhhkkhkk * in one code form to another (EBCDIC to ASCII, for uses LIBSMOVTC to translate all lower-case characters to upper case Note that LIBSMOVTC expects * * are / translation PROGRAM-ID. general are RUNTIME procedures string from This program IDENTIFICATION of therefore, by COBOL-74. L1brary Reference sets procedures X(9). PROGRAMMING EXAMPLES that PROCEDURE DIVISION. STARTIT SECTION. SBEGIN. DISPLAY "Enter string:". MOVE SPACES TO INPUT-AREA. ACCEPT INPUT-AREA. CALL "LIBS$SMOVTC" USING BY DESCRIPTOR | INPUT-AREA FILL-CHAR TRANSLATION-TABLE OUTPUT-AREA. DISPLAY OUTPUT-AREA. CALL "FORSDATE" USING DATE-AREA. 'DISPLAY DATE-AREA. ' STOP RUN. G.2.2 Sample Run of RUNTIME 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 screen forms for data input It is often useful to design terminal forms on most terminals by using applications. You escape sequences. can | implement | | PROGRAMMING EXAMPLES G-5 G.3.1 The COBOL Program, ESCAPE / ) This program accepts data from a DIGITAL VT52 terminal; form Other and guides the operator by using terminals have similar capabilities. it escape-character E 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 techniqu is e 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 Note the use of the OCCURS ... of INPUT-AREA, allowing IDENTIFICATION data from the operator. DEPENDING ON clause in the description the variable-length display. DIVISION. PROGRAM-ID. - ESCAPE. **************************************************. % * * % * This program demonstrates the use of terminal escape gequences, including cursor control, * through COBOL. | . * * % * * khkkhhkkhkkhkhkhkhkhkhhkkhhhkhkkhkhkhkhhkkhhkhkhkhkhkhkkhkhkhhhkhkkkkhkkk DATE-COMPILED. | CONFIGURATION SECTION. ENVIRONMENT DIVISION. SOURCE-COMPUTER. OBJECT-COMPUTER. DATA VAX-11. VAX-11. DIVISION. \ WORKING-STORAGE 01 03 | SECTION. INPUT-AREA. TIACHAR PIC DEPENDING 01 01 IASUB PIC X(1) ON 9(2) OCCURS 1 TO 30 TIMES IASUB. | COMP. 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 03 03 01 - 03 - G-6 FIELD-TAB-ENTRY 05 ROW OCCURS PIC 05 COLUM 05 FIELD-LENGTH 05 PROMPT PROGRAMMING EXAMPLES - 4 TIMES. 9(2). PIC 9(2). PIC PIC 9(2). X(18). COMP. 9(3) 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(l) 01 CTR PIC ROW-VALUE-C REDEFINES ROW-VALUE PIC X(1l). 01 COMP. COLUM-VALUE-C REDEFINES COLUM-VALUE PIC X(l) 01 PROCEDURE 9(2). DIVISION. LOOP. * ESC H moves the cursor to the home position. * ESC J clears from the cursor position to the end * of the screen. DISPLAY ESCAPE-C "H" ESCAPE-C "J". N PERFORM PROC-FIELD VARYING CTR FROM 1 BY 1 | UNTIL CTR > 4. PERFORM ACCEPT-FIELD VARYING CTR FROM 1 BY 1 4. UNTIL CTR > IF CTR < 90 GO TO LOOP. 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. TO IASUB. / PN \ MOVE EIELD-LENGTH(CTR) PROGRAMMING EXAMPLES G-7 * Display a string of underscores the same length\ * as the expected MOVE ALL DISPLAY " " input entry. TO u - INPUT-AREA. ESCAPE-C "Y" ROW-VALUE-C COLUM-VALUE-C now INPUT—AREA. * * Reposition the input area. DISPLAY cursor ESCAPE-C ROW-VALUE-C " * * " to the beginning of the "Y" COLUM-VALUE-C NO ADVANCING. Set the OCCURS DEPENDING its maximum size. item to make INPUT—AREA MOVE 30 TO IASUB. MOVE SPACES TO INPUT-AREA. * Get the input. ACCEPT * INPUT-AREA. Input processing IF INPUT-AREA MOVE 91 TO code = goes here. "QUIT" CTR. DONOTHING. EXIT. COMP-LEN. * Set the OCCURS DEPENDING item to make INPUT-AREA * its maximum Escape so * % * % MOVE 30 TO size. IASUB. sequence we add 31 row and column values begin with to the ADD 31 ROW(CTR) ADD 31 COLUM (CTR) Move the its prompt length by GIVING to PERFORM -DONOTHING G-8 the column 32, numbers. ROW-VALUE. COLUM-VALUE. display the area, last TO INPUT-AREA. VARYING IACHAR(IASUB) PROGRAMMING EXAMPLES and GIVING locating MOVE PROMPT (CTR) UNTIL row = IASUB ":". then determine character (:). | FROM | 1 BY 1 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: NUMBER: / TNY CODE 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, operatlng system uses to allow communication among system processes, and to perform basic Although most system services are - system, you can use many of them operatlng used pr1mar11y by yourself in VAX-11l functions. the COBOL-74 operating programs. System services are described in the VAX/VMS System Services Reference Manual. G.4.1 The COBOL Program, SYSTSVC This program calls two system services: $GETMSG end STRNLOG. 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, S$TRNLOG. STRNLOG translates a logical name and returns the equivalence - string. It also returns one of five return status codes. name 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. i INSTALLATION. DIGITAL | EQUIPMENT CORPORATION. ******************************************** % * ' . This program * . demonstrates * CALL statement * Services. in the * calling VAX/VMS System * . - the use B of * ok ******************************************** ENVIRONMENT DIVISION. CONFIGURATION G-10 SECTION. SOURCE-COMPUTER. VAX-11. OBJECT-COMPUTER. VAX-11. PROGRAMMING EXAMPLES | - DATA DIVISION. WORKING-STORAGE 01 SECTION. LOG-STRING. 03 LOG-CHAR PIC DEPENDING 01 01 01 01 01 01 LOG-LENGTH PIC 9(2). IN-PTR PIC 9(2). NAME-LENGTH PIC EQUIV-NAME PIC PHYSICAL-TEST TO 30 TIMES S9(4) X(30) COMP. VALUE SPACES. REDEFINES EQUIV-NAME. PT-1-4. - 05 05 03 PT-CHAR PIC X. FILLER PIC X(3). PHYSICAL-NAME ESCAPE-CHAR ESCAPE \‘\ 1 LOG-LENGTH. - LOG-NAME PIC X(30). 03 I X OCCURS ON PIC REDEFINES RES PIC 88 SUCCESSFUL S9(8) RESULT-NAME OUT-LENGTH DUMMY-ARG X(26). COMP VALUE ESCAPE-CHAR 176. PIC X. COMP. VALUE PIC PIC RESULT-DISP PIC 9(3) Z(4). PIC PIC 1. X(30). 9(8). S9(9) COMP VALUE 0. MESSAGE-AREA. 03 MESSAGE-CHAR OCCURS DEPENDING 01 01 MESS-LEN 01 01 MASK PIC 9(8) COMP. PIC 9(8) MESSAGE-LENGTH PIC 9(8) MSG-VALUE PROCEDURE STARTER SBEGIN. COMP VALUE PIC 1 TO 256 TIMES ON MESSAGE-LENGTH PIC X. COMP. IS 15. X (4). DIVISION. SECTION. DISPLAY ACCEPT "ENTER LOGICAL NAME: " LOG-NAME. NO ADVANCING. | ' SLOOP. PERFORM TRANSLATE- LOGICAL—NAME PERFORM GET-RESULT. IF PT-CHAR MOVE = ESCAPE PHYSICAL-NAME TO RESULT—NAME EQUIV-NAME RESULT-NAME. ELSE MOVE MOVE NAME-LENGTH TO TO OUT-LENGTH. * DISPLAY LOG-NAME "= " RESULT-NAME. If the translation was performed, use the result to attempt further translation. IF SUCCESSFUL MOVE GO TO RESULT-NAME TO LOG—NAME SLOOP. STOP RUN. - PROGRAMMING EXAMPLES G-11 * dhkhkhkhkhkhkhkhkhkkkhkhhhkhkhhkhhhkhhhkhhhhhhkhkhkhkhhkkhkhkhkkhkkkkhk * * * * * * * * The following paragraph uses the contents of LOG-STRING as an argument to the SYSSTRNLOG 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. B * * * * * * * * * khkkhkhkhkhkhkhkhhkhkkhkhkkhkhkkhkkkkhkkhkhkkhkhkkkhkkkkhkkkdkk * TRANSLATE-LOGICAL-NAME. MOVE SPACES 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 POINTER IN-PTR. Fix SUBTRACT 2 up string FROM length from pointer. IN-PTR GIVING LOG-LENGTH. Delete colon from logical-name string. IF LOG-CHAR (LOG-LENGTH) = ":" SUBTRACT 1 FROM LOG-LENGTH. CALL "SYS$TRNLOG" USING BY DESCRIPTOR LOG-STRING, BY REFERENCE NAME-LENGTH BY DESCRIPTOR EQUIV-NAME BY VALUE GIVING GET-RESULT S BEGIN. MOVE MOVE CALL DUMMY-ARG, DUMMY-ARG,’ DUMMY-ARG RES. SECTION. | 256 TO MESSAGE-LENGTH. SPACES TO MESSAGE-AREA. "SYSS$GETMSG" USING BY VALUE RES BY REFERENCE BY DESCRIPTOR MESSAGE-AREA MESS-LEN BY VALUE MASK BY DESCRIPTOR MSG-VALUE. MOVE MESS-LEN TO MESSAGE-LENGTH. DISPLAY MESSAGE-AREA. | G=-12 PROGRAMMING EXAMPLES TN | TO G.4.2 Sample Run, SYSTSVC S RUN SYSTSVC ENTER LOGICAL NAME: COBSINPUT $SYSTEMS-NORMAL, normal successful completion COBSINPUT = SYSSINPUT $SYSTEM-S-NORMAL, normal successful completion SYSSINPUT tSYSTEM-S-NOTRAN, TTE]l: = TTEl: no , strlng translation performed = TTEl 5 £%% TN ‘\]/ $ PROGRAMMING EXAMPLES G-13 - COBSOUTPUT, 6-28, 6-29 COBSPAPERTAPEPUNCH, 6-27 COBSPAPERTAPEREADER, 6-27 COBSSWITCHES, 2-12, 2-13 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, SN COMP, COMP-3, signs, 6-27 FORTRAN programs, G-1 VAX-11 tun-time procedures, G-4 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 Category, data, 3-1 Characters, special, 3-3 /CL:n, file specification switch, 3-1 /CO:n, file specification switch, COBSCARDREADER, 6-27 COBSCONSOLE, 6-27 | COBSINPUT, 6-28 COBSLINEPRINTER, 6-27 | 5-4 in a table, F-1 optimizing, 13-9 See COMP COMPUTATIONAL-3. See COMP-3 COMPUTE, 4-20 Condition-names, 7-7, 7-8 CONSOLE, 6-27 Constant, figurative, 4-9 CONTINUE command, 2-13 format, Conventional 7-1, 2-3, 2-1, 8-1 copy, 2-3, 12-1, 12-2 COPY REPLACING, 12-4 /COPY LIST, 2-3 i 3-13 CORRESPONDING, COUNT, in STRING, 3-30 , 2-2 CREATE command /CROSS REFERENCE, 2-3 /CROSS REFERENCE, LINK qualifier, 2-9 CTRL/Y, 2-13 in DEBUG, 9-9 Current record area, 6-10 Cursor addressing, G-6 Data category, 3-1 class, 3-1 movement, 3-7 Data Division size limitation, ~ B-1 Data item elementary, group, 3-2 3-2 Data-name limitation, B-1 DEASSIGN command, 2-13 - 2-3 6-24 4-4, COMPUTATIONAL. Calling 6-22 | 4-3 Computation, 4-21 4-13 Caching index roots, 13-8 CALL, G-1, G-4, G-10 4-7 4-2, COMP items Binary, 4-1 Bloeck, 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-1 3 Buffers, 6-13 multiple, 6-13 sharing, 6-14 6-22 Class data, test, 4-1 Comparison, 3-6 Compiler command line, 2-2 qualifiers, 2-3 Compiler error, 10-3, ASSIGN, 6-20 ASSIGN command, 2-12, 6-19, AT END, 6-16, 6-26, 10-7 CARD-READER, compiler, Command qualifiers, 9-5 /ANSI FORMAT, 2-3 APPLY, 6-17 "Arithmetic expression processing, 4-21 temporary work area, Arithmetic statements, INDEX /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 in in File, BY STRING, 3-16 UNSTRING, 3-25 DELIMITER, DEPOSIT, | in UNSTRING, 3-31 DEBUG command, 9-10 Device, 6-18 | Diagnostic error messages, Directory, 6-18 DISPLAY, 4-1, 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-2 messages, compile-time, messages, messages, diagnostic, 10-1 link-time, 10-5 : 10-1 DEBUG Examples, G-6 F-1 | programming, G-1 DEBUG command, 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 formats, 7-1, 8-1 2-10 A-1l I/0 buffer, error 9-10 /EXECUTABLE, LINK qualifier, 2-10 Executing a COBOL image, 2-12 EXIT, - 2-3, Group move, G-6 command, 7-1, 3-9, 4-8 Group item, 3-2 dynamic, 5-17 messages, run-time, 10-5 procedures, 1/0, 10-7 system, compile-time, 10-3, sequences, 2-3, GIVING, 4-16 GO TO DEPENDING limitation, B-1 GO, DEBUG command, 9-8 2-7 10-1 Escape 2-1, calling, G-1 files for, 6-24 /FULL, LINK qualifier, General character, 2-1, FORTRAN programs 6-25 message summary, A conventional, 8-1 terminal, 2-7 EXAMINE, Format 6-2 reference, 2-1 messages, ESC (continued) record I/O interface, in sorting, 11-2 relative, 13-2 sequential, 13-2 sharing, 6-23 specification, 6-17, 6-18, 6-20 switches, 6-19, 6-22 | type, 6-18 version, 6-18 Files naming, 6-17 opening, 6-14 Fixed-length record, 6-2 record, Error fatal, (Continued) 11-2 - » 6-13 procedures, 10-7 error processing, 6-25 Image execution, 2-12 | /INCLUDE, LINK qualifier, 2-11 ’ Index data item, 5-15 Index-name, 5-13, 5-16 initialization, 5-14 2-10, Index roots, caching, 13-8 Indexed file, 6-9, 13-3 Indexes, 5-13 Indexing, 5-9 relative, 5-14 INSPECT, 3-39 Intermediate results, 4-13, 4-23 \ Interrupting image, Justified move, 3-11 INDEX-2 4—22, in DEBUG, 9-9 INDEX Key buffer, in sort, 11-4 Key, sort, 11-3 | Library Numeric data, 4-1 » | facility, file, 12-1 | ~~ 12-2 /LIBRARY, LINK qualifier, 2-11 Limitations, compiler, B-1 LINAGE, 6-17 LINE-PRINTER, 6-27 LINK command, 2-7, 2-9 LINK qualifiers, 2-9 | /LIST, 2-4 Listing, program, N /LO, C-1 subscripting, | 3-8, edited, 3-10, group, 3-9, 4-8 elementary, 5-10 CORRESPONDING, Multiple delimiters 3-29 | Multiple operands, Multiple receiving MULTIPLY, 4-18 | /NOOBJECT, 6-27 of, 2-6 /NOVERB_LOCATION, 7-9 /NOWARNINGS, 2-6 Numeric class, 3-1 size, 6-4 Record format, 6-2 fixed-length, 6-2 | 6-3 6-3 Record Management Services, Record Unit Size, ‘Reference format, 6-5 2-1, REFORMAT, 8-1 Relation test, 3-4, Relative file, Relative indexing, RESERVE, RMS, 6-1 buffer INDEX-3 6-8, 6-13 Restarting | 3-12 blocklng, 6-5 | ~ 2-6 G-1 7-5 Receiving flelds, multiple, Record area, current, 6-10 areas, sharing, 6-11 2-3 2-13 B- 1 limitation, B-1 | 3-12 use Qualification, ~ 2-3 2-4 2-5 6-27 Programming examples, VFC, /NODEBUG, 2-4 /NODEBUG, RUN quallfler, /NOMAP, | 2-3 /NOCROSS REFERENCE, Node, 6-18 /NOLIST, 4-2 variable-length, /NOANSI FORMAT, /NOCOPY~LIST, in STRING, 3-18 in UNSTRING, 3-36 Punctuation, 4-16 fields, 6-16 PERFORM, 7-6 Physical block, 6-5, 13-9 PIC, 7-3 PICTURE, 7-3 POINTER in STRING, 3-15 in UNSTRING, 3-32 PRINT-CONTROL, 6-17 Procedure-name limitation, Program listing, C-1 organization, 13-8 ~ | o 3-13 in UNSTRING, 5-13 Opening files, 6-14 Optimization, 13-1 Optimizing computation, 13-9 OPTIONAL, 6-16 /OPTIONS, LINK qualifier, 2-12 OVERFLOW PAPER-TAPE-READER, 4-9 justified, 3-11 subscripted, 3-12 5-9, PAPER-TAPE~-PUNCH, 4-10 3-9, 5-3, 6-14 | Packed-decimal, 6-27 4-8 - Move MOVE | | file specification switch, Mnemonic-name, 2-6 5-2, OPEN statement execution, - 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 switch, 6-23 MOVE, /OBJECT, OCCURS, Open mode, | Link-time error messages, 10-5 Linking, 2-7 _ Literal (Continued) program, 7-1, 8-1 | 4-6 13-2 5-14 | in DEBUG, | defaultS, 6-1 6-13 9-8 INDEX ROUNDED, 4-14 RTS, 2-8 | RUN command, 2-13 Run-time exrror messages, procedures, System, - | | (Continued) - ; Subscripted fields in INSPECT, 3-47 in | 10-5 calling, - Scaling, decimal, Scope, DEBUG, SEARCH, 5-17, | 5-19 6-7 file, 13-2 SET, 5-16 SET BREAK, SET LANGUAGE, | file specification, command, DEBUG program, 2-12, 2-13 ‘SYNCHRONIZED, 5-4 | | DEBUG F-1 9-2 DEBUG command, 9-3 DEBUG command, 9-6 DEBUG command, 9-7 specification 6-23 Sharing SHOW areas, BREAK, DEBUG SHOW CALLS, DEBUG command, handling, SHOW WATCH, DEBUG command, Sign test, 4-7 COMP items in, defining, 5-1 ERROR, 9-6 TALLYING 9-9 in INSPECT, in Tape 9-7 4-15 keys, Sort subroutines, Sorting, 11-1 file I/0 interface, characters, SPECIAL-NAMES, SPR, area Terminal class, | 11-2 | 3-3 | 6-27 arithmetic, DEBUG STRING, 3-14 Subroutines, sort, UNSTRING, 9-9 | ) 11-6 2-3, 2-10, | 9-9, | LINK qualifier, DEBUG, 9-6, 9-7 3-22 5-7 ID, 6-26 | 6-20 Variable-length record, 6-3 table, 5-17 Variable with fixed-length control record. See VFC INDEX-4 G-6 7-1, 4-6 2-4, procedure, VALUE OF command, 2-1, - Tracepoint, VALUE, 4-13 STOP literal, 2-13 in DEBUG, 9-9 10-8 /TRACEBACK, 4-21 sequences, 3-4, 4-7 Traceback, USE F-2 4-7 relation, ' ~ 11-2 escape Terminal format, F-2 Statements STEP, Temporary work sign, record I/0 interface, Source listing, C-1 Special 3-34 11-3 11-6 3-48 UNSTRING, file, 6-6 _ 8-1 Test | 5-17 arithmetic expression, 9-8 Software Performance Report, sSort 5-4 variable-length, Signs, 4-4 COMP-3, 4-3 SIZE 5-1 Tables LOGICAL command, 2-13 SHOW MODULE, DEBUG command, 9-3 SHOW SCOPE, DEBUG command, 9-3 DEBUG command, 10-4 Table initializing, 5-7 SHOW SHOW TRACE, VAX/VMS, | | switch, command, 2-8 System services, calling, G-10 | 6-11 6-22 | System messages, | buffers, 6-14 6-19, SYS$LIBRARY:C74LIB/OPT, 2-8 System error, compile-time, 10-3, 9-6 command, SCOPE, file 4-16 SYSSLIBRARY:C74LIB/LIB, SET TRACE, SET WATCH, 5-13 1itera1’ 5-10 SUBTRACT, 4-18 ) SET MODULE, DEBUG command, 9-2 record 5-12 indexes, multiple operands, " disk file, /SH, data-name, 3-12 Switches 5-18, SELECT, 6-20 Sequential SET 5-9 4-3 9-3 3-37 Subscripting, 2-8 'SAME AREA, 6-14, 6-16 | SAME RECORD AREA, 6-11 3-20 Subscripted move, G-4 | STRING, in UNSTRING, 10-6, 2-10 \ INDEX (Continued) ) VAX-11 run-time procedures, calling, G-4 VAX-11 Sort, 11-1 - VAX/VMS system messages, VAX/VMS G-10 system services, 10-4 calling, Version, ‘VVFC file, record, /WARNINGS, /WI:n, PN 6-23 INDEX-5 file 6-18 6-3 2-6 specification switch, VAX-11 COBOL-74 - User’s Guide READER’S COMMENTS | AA-C986A-TE NOTE: 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 improvément. 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 [0 Higher-level language programmer [0 Occasional programmer (experienced) 0 User with little programming experience [0 Student programmer 00 Other (please specify) Name | ‘ Date Organization Street City — ‘ ! - State Zip Code or Country | | — — ==D)o Not Tear - Fold Here and Tape — — —— . e | t e | | e 1' » No Postage , | | | | Necessary | if Mailed in the | | United States | | ( I R || | - BT BUSINESS REPLY MAIL — FIRST CLASS PERMIT NO.33 MAYNARD MASS." — POSTAGE WILL BE PAID BY ADDRESSEE DU ~ ATTN: Commercial Engineering Publications MK1-2/H3 l | — ' DIGITAL EQUIPMENT CORPORATION . CONTINENTAL BOULEVARD < | | -MERRIMACK N.H. 03054 — I B | o] I i I l — — Do Not Tear - Fold Here and Tape — ) — — — — e — — — — - — - - — — 77 | I I o I ) . l £ |l ) T | Q2 l ) & @ | < -] | © | | I l l t dlilgliltlall PRINTED IN USA
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies