HP COBOL Manual for TNS/E Programs Abstract This publication describes the HP implementation of the 1985 version of the COBOL language. It includes information on the ECOBOL compiler (T0356) and program execution, task-oriented information to help an experienced COBOL programmer use HP COBOL for NonStop™ systems, and summaries of compiler and run-time error messages.
Document History Part Number Product Version 520347-003 ECOBOL H01 HP Enterprise Toolkit—NonStop Edition (ETK) PC COBOL H01 Published July 2005
HP COBOL Manual for TNS/E Programs Glossary Index What’s New in This Manual xlvii Manual Information xlvii New and Changed Information Examples Figures xlvii About This Manual xlix Manuals to Which This Manual Refers Acknowledgment liii Notation Conventions liv xlix Part I. Features of HP COBOL 1.
2. Source Program Organization and Format (continued) Contents 2. Source Program Organization and Format (continued) Nested Source Programs 2-8 Directly Contained Programs and Indirectly Contained Programs Scope of User-Defined Names 2-9 Common Programs 2-12 Programs in the Same Run Unit 2-12 Initial Programs 2-12 How Programs Share Resources 2-13 Global and Local Names 2-13 External and Internal Objects 2-14 Shared Data 2-16 Shared Files 2-22 3.
4. Data Fundamentals (continued) Contents 4. Data Fundamentals (continued) Implicit FILLER Bytes 4-16 Records 4-17 Tables 4-17 REDEFINES Clause 4-17 References to Data Items 4-18 Qualifiers 4-19 Subscripts 4-19 Reference Modifiers 4-21 Identifiers 4-24 Condition-Names 4-25 5. Identification Division Identification Division Syntax 5-1 PROGRAM-ID Paragraph 5-4 DATE-COMPILED Paragraph 5-5 6.
7. Data Division (continued) Contents 7.
8. Procedure Division Contents 8.
9. Procedure Division Verbs Contents 9.
. Procedure Division Verbs (continued) Contents 9.
9. Procedure Division Verbs (continued) Contents 9. Procedure Division Verbs (continued) STOP 9-242 STRING 9-243 SUBTRACT 9-248 SUBTRACT FROM 9-249 SUBTRACT GIVING 9-251 SUBTRACT CORRESPONDING 9-253 UNLOCKFILE 9-255 UNLOCKRECORD 9-256 UNSTRING 9-257 USE 9-269 USE DEBUGGING 9-270 USE AFTER EXCEPTION 9-270 WRITE 9-273 WRITE for Sequential Files 9-274 WRITE for Line Sequential Files 9-282 WRITE for Relative, Indexed, and Queue Files 9-283 10.
. Program Compilation (continued) Contents 11.
11. Program Compilation (continued) Contents 11.
12. Program Execution (continued) Contents 12. Program Execution (continued) DEFINEs 12-17 DEFINE and ASSIGN 12-17 Controlling the Propagation of DEFINEs 12-18 DEFINE Names 12-19 DEFINE Attributes 12-19 ADD DEFINE Command 12-21 Initial State 12-22 Status of Internal Entities During Program Execution 12-23 Status of External Entities During Program Execution 12-23 Called Program Termination 12-23 13.
13. Libraries and Utility Routines (continued) Contents 13. Libraries and Utility Routines (continued) ZCOBDLL Routines (continued) Non-SMU Routines 13-64 COBOL_ASSIGN_ 13-65 COBOLFILEINFO 13-69 COBOL_FILE_INFO_ 13-71 14.
14. Intrinsic Functions (continued) Contents 14. Intrinsic Functions (continued) NUMVAL-C Function 14-40 ORD Function 14-43 ORD-MAX Function 14-43 ORD-MIN Function 14-45 PRESENT-VALUE Function 14-46 RANDOM Function 14-49 RANGE Function 14-50 REM Function 14-52 REVERSE Function 14-53 SIN Function 14-54 SQRT Function 14-55 STANDARD-DEVIATION Function 14-56 SUM Function 14-58 TAN Function 14-60 UPPER-CASE Function 14-61 VARIANCE Function 14-62 WHEN-COMPILED Function 14-64 15.
17. HP Extensions to ISO COBOL (continued) Contents 17. HP Extensions to ISO COBOL (continued) Environment Division 17-3 Data Division 17-3 Procedure Division Verbs 17-4 18. HP COBOL CRE Support Introducing the CRE 18-1 Shared File Operations 18-2 Arithmetic Overflow Processing 18-2 19.
20. HP COBOL Limits Contents 20. HP COBOL Limits Size 20-1 Number 20-3 Callability 20-5 External Names 20-5 Ranges of Values 20-5 Ignored Elements 20-6 21. Reserved Words All Reserved Words 21-1 HP Reserved Words 21-11 Part II. Programming in HP COBOL 22.
Contents 22. Creating and Compiling HP COBOL Source Programs (continued) 22.
23. Calling Other Programs and Routines (continued) Contents 23. Calling Other Programs and Routines (continued) Passing Parameters 23-16 Addressing Modes 23-16 What HP COBOL Can Pass by Content 23-17 What HP COBOL Can Pass by Reference 23-19 What HP COBOL Can Pass by Value 23-19 Passing Parameters to COBOL Programs 23-20 Passing Parameters to Non-COBOL Routines 23-21 24.
25. Executing and Debugging HP COBOL Programs (continued) Contents 25.
28. Disk Input and Output Contents 28.
28. Disk Input and Output (continued) Contents 28.
Contents 30. Printer and Spooler Output (continued) 30.
32. Fault-Tolerant Processes Contents 32.
34. Native COBOL Cross Compiler on PC (continued) Contents 34. Native COBOL Cross Compiler on PC (continued) Tools and Utilities 34-9 NonStop ar Utility 34-9 TACL DEFINE Tool (ETK) 34-10 PC-to-NonStop-Host Transfer Tools Documentation 34-10 34-10 Part III. Syntax Summary 35.
36. Compiler Directives (continued) Contents 36.
37. Source Program Organization and Format Contents 37. Source Program Organization and Format Separately Compiled Source Program Reference Format 37-2 TANDEM 37-2 ANSI 37-3 37-1 38.
41. Environment Division Contents 41. Environment Division Configuration Section 41-1 SOURCE-COMPUTER Paragraph 41-2 OBJECT-COMPUTER Paragraph 41-2 SPECIAL-NAMES Paragraph 41-4 Input-Output Section 41-7 FILE-CONTROL Paragraph 41-8 I-O-CONTROL Paragraph 41-17 RECEIVE-CONTROL Paragraph 41-19 42.
43. Procedure Division (continued) Contents 43.
43. Procedure Division (continued) Contents 43.
44. Intrinsic Function Calls (continued) Contents 44. Intrinsic Function Calls (continued) LOG10 44-5 LOWER-CASE 44-5 MAX 44-5 MEAN 44-5 MEDIAN 44-5 MIDRANGE 44-6 MIN 44-6 MOD 44-6 NUMVAL 44-7 NUMVAL-C 44-8 ORD 44-9 ORD-MAX 44-9 ORD-MIN 44-9 PRESENT-VALUE 44-9 RANDOM 44-9 RANGE 44-10 REM 44-10 REVERSE 44-10 SIN 44-10 SQRT 44-10 STANDARD-DEVIATION 44-11 SUM 44-11 TAN 44-11 UPPER-CASE 44-11 VARIANCE 44-11 WHEN-COMPILED 44-11 45.
45. ZCOBDLL Routine Calls (continued) Contents 45. ZCOBDLL Routine Calls (continued) COBOL_SPECIAL_OPEN_ 45-6 For Spoolers and Printers 45-6 For System Log Files 45-7 For Partitioned Disk Files 45-7 For Tape Files 45-8 46. ZCREDLL Routine Calls Part IV. Error Message Summary 47.
B. Data Type Correspondence Contents B. Data Type Correspondence Glossary Index Examples Example i. Example ii. Example 2-1. Example 2-2. Example 2-3. Example 3-1. Example 3-2. Example 3-3. Example 3-4. Example 3-5. Example 3-6. Example 4-1. Example 4-2. Example 4-3. Example 4-4. Example 4-5. Example 4-6. Example 4-7. Example 4-8. Example 4-9. Example 4-10. Example 5-1. Example 5-2. Example 5-3. Example 6-1. Example 6-2. Example 6-3. Example 6-4. Example 6-5. Example 6-6. Example 6-7. Example 6-8.
Examples (continued) Contents Examples (continued) Example 7-1. Example 7-2. Example 7-3. Example 7-4. Example 7-5. Example 7-6. Example 7-7. Example 7-8. Example 7-9. Example 7-10. Example 7-11. Example 7-12. Example 7-13. Example 7-14. Example 7-15. Example 7-16. Example 7-17. Example 7-18. Example 7-19. Example 7-20. Example 7-21. Example 7-22. Example 7-23. Example 8-1. Example 8-2. Example 8-3. Example 8-4. Example 8-5. Example 8-6. Example 8-7. Example 8-8. Example 8-9. Example 8-10. Example 8-11.
Examples (continued) Contents Examples (continued) Example 9-1. Example 9-2. Example 9-3. Example 9-4. Example 9-5. Example 9-6. Example 9-7. Example 9-8. Example 9-9. Example 9-10. Example 9-11. Example 9-12. Example 9-13. Example 9-14. Example 9-15. Example 9-16. Example 9-17. Example 9-18. Example 9-19. Example 9-20. Example 9-21. Example 9-22. Example 9-23. Example 9-24. Example 9-25. Example 9-26. Example 9-27. Example 9-28. Example 9-29. Example 9-30. Example 9-31. Example 9-32. Example 9-33.
Examples (continued) Contents Examples (continued) Example 9-36. Example 9-37. Example 9-38. Example 9-39. Example 9-40. Example 9-41. Example 9-42. Example 9-43. Example 9-44. Example 9-45. Example 9-46. Example 9-47. Example 9-48. Example 9-49. Example 9-50. Example 9-51. Example 9-52. Example 9-53. Example 9-54. Example 9-55. Example 9-56. Example 9-57. Example 9-58. Example 9-59. Example 9-60. Example 9-61. Example 9-62. Example 9-63. Example 9-64. Example 9-65. Example 9-66. Example 9-67.
Examples (continued) Contents Examples (continued) Example 9-72. Example 10-1. Example 10-2. Example 10-3. Example 11-1. Example 11-2. Example 11-3. Example 11-4. Example 11-5. Example 11-6. Example 11-7. Example 11-8. Example 11-9. Example 11-10. Example 12-1. Example 12-2. Example 12-3. Example 12-4. Example 12-5. Example 12-6. Example 13-1. Example 13-2. Example 13-3. Example 13-4. Example 13-5. Example 13-6. Example 13-7. Example 13-8. Example 13-9. Example 13-10. Example 13-11. Example 13-12.
Examples (continued) Contents Examples (continued) Example 13-15. Example 13-16. Example 14-1. Example 14-2. Example 14-3. Example 14-4. Example 14-5. Example 14-6. Example 14-7. Example 14-8. Example 14-9. Example 14-10. Example 14-11. Example 14-12. Example 14-13. Example 14-14. Example 14-15. Example 14-16. Example 14-17. Example 14-18. Example 14-19. Example 14-20. Example 14-21. Example 14-22. Example 14-23. Example 14-24. Example 14-25. Example 14-26. Example 14-27. Example 14-28. Example 14-29.
Examples (continued) Contents Examples (continued) Example 14-37. Example 14-38. Example 14-39. Example 14-40. Example 14-41. Example 14-42. Example 14-43. Example 14-44. Example 16-1. Example 19-1. Example 19-2. Example 19-3. Example 22-1. Example 22-2. Example 22-3. Example 22-4. Example 22-5. Example 22-6. Example 22-7. Example 22-8. Example 22-9. Example 22-10. Example 22-11. Example 22-12. Example 22-13. Example 22-14. Example 22-15. Example 22-16. Example 22-17. Example 22-18. Example 22-19.
Examples (continued) Contents Examples (continued) Example 23-5. Example 23-6. Example 23-7. Example 23-8. Example 25-1. Example 25-2. Example 26-1. Example 27-1. Example 27-2. Example 27-3. Example 27-4. Example 27-5. Example 27-6. Example 27-7. Example 27-8. Example 27-9. Example 27-10. Example 27-11. Example 27-12. Example 27-13. Example 28-1. Example 28-2. Example 28-3. Example 28-4. Example 28-5. Example 28-6. Example 28-7. Example 28-8. Example 28-9. Example 28-10. Example 28-11. Example 28-12.
Examples (continued) Contents Examples (continued) Example 29-1. Example 29-2. Example 29-3. Example 29-4. Example 29-5. Example 29-6. Example 30-1. Example 30-2. Example 30-3. Example 30-4. Example 31-1. Example 31-2. Example 31-3. Example 31-4. Example 31-5. Example 31-6. Example 31-7. Example 31-8. Example 31-9. Example 31-10. Example 31-11. Example 31-12. Example 31-13. Example 31-14. Example 31-15. Example 31-16. Example 32-1. Example 47-1. Example 47-2. Example 47-3. Example 48-1. Example 48-2.
Figures (continued) Contents Figures (continued) Figure 3-2. Figure 3-3. Figure 6-1. Figure 7-1. Figure 7-2. Figure 7-3. Figure 8-1. Figure 8-2. Figure 9-1. Figure 9-2. Figure 9-3. Figure 9-4. Figure 9-5. Figure 9-6. Figure 9-7. Figure 9-8. Figure 9-9. Figure 9-10. Figure 9-11. Figure 11-1. Figure 11-2. Figure 13-1. Figure 16-1. Figure 21-1. Figure 22-1. Figure 22-2. Figure 22-3. Figure 22-4. Figure 23-1. Figure 24-1. Figure 24-2. Figure 24-3.
Figures (continued) Contents Figures (continued) Figure 26-1. Figure 27-1. Figure 27-2. Figure 30-1. Figure 31-1. Figure 31-2. Figure 31-3. Figure 31-4. Figure 32-1. Figure 32-2. Figure 32-3. Figure 32-4. Figure 37-1. Figure 37-2. Figure 38-1. Figure 38-2.
Tables (continued) Contents Tables (continued) Table 6-2. Table 6-3. Table 6-4. Table 6-5. Table 6-6. Table 6-7. Table 6-8. Table 6-9. Table 6-10. Table 7-1. Table 7-2. Table 7-3. Table 7-4. Table 7-5. Table 7-6. Table 7-7. Table 8-1. Table 8-2. Table 8-3. Table 8-4. Table 8-5. Table 8-6. Table 8-7. Table 8-8. Table 8-9. Table 8-10. Table 8-11. Table 8-12. Table 8-13. Table 8-14. Table 8-15.
Tables (continued) Contents Tables (continued) Table 8-16. Table 8-17. Table 8-18. Table 8-19. Table 8-20. Table 8-21. Table 9-1. Table 9-2. Table 9-3. Table 9-4. Table 9-5. Table 9-6. Table 9-7. Table 9-8. Table 9-9. Table 9-10. Table 9-11. Table 11-1. Table 11-2. Table 11-3. Table 11-4. Table 11-5. Table 11-6. Table 11-7. Table 11-8. Table 11-9. Table 11-10. Table 11-12. Table 11-11. Table 11-13. Table 11-14. Table 12-1. Table 12-2. Table 13-1. Table 13-2. Table 13-3. Table 13-4.
Tables (continued) Contents Tables (continued) Table 13-5. Table 13-6. Table 13-7. Table 13-8. Table 13-9. Table 13-10. Table 13-11. Table 13-12. Table 14-1. Table 14-2. Table 14-3. Table 14-4. Table 14-5. Table 14-6. Table 16-1. Table 19-1. Table 19-2. Table 22-1. Table 22-2. Table 22-3. Table 23-1. Table 25-1. Table 26-1. Table 27-1. Table 27-2. Table 27-3. Table 27-4. Table 27-5. Table 27-6. Table 27-7. Table 27-8.
Tables (continued) Contents Tables (continued) Table 28-1. Table 28-2. Table 28-3. Table 28-4. Table 28-5. Table 30-1. Table 30-2. Table 30-3. Table 32-1. Table 32-2. Table 34-1. Table 35-1. Table 37-1. Table 37-2. Table 38-1. Table 38-2. Table 38-3. Table 38-4. Table 38-5. Table 38-6. Table 38-7. Table 38-8. Table 38-9. Table 38-10. Table 38-11. Table 47-1. Table 47-2. Table A-1. Table A-2. Table B-1. Table B-2. Table B-3. Table B-4. Table B-5.
Tables (continued) Contents Tables (continued) Table B-6. Table B-7.
What’s New in This Manual Manual Information HP COBOL Manual for TNS/E Programs Abstract This publication describes the HP implementation of the 1985 version of the COBOL language. It includes information on the ECOBOL compiler (T0356) and program execution, task-oriented information to help an experienced COBOL programmer use HP COBOL for NonStop™ systems, and summaries of compiler and run-time error messages.
What’s New in This Manual New and Changed Information HP COBOL Manual for TNS/E Programs —520347-003 xlviii
About This Manual This manual is a complete reference book for experienced COBOL programmers who want to use HP COBOL for NonStop systems (HP COBOL). It explains every feature of the HP COBOL programming language. To understand its explanations, you must have some experience with structured (1974 or 1985) COBOL. If you do not, read an introductory text first. Topics: • • • Manuals to Which This Manual Refers Acknowledgment Notation Conventions Manuals to Which This Manual Refers Table i.
Manuals to Which This Manual Refers About This Manual Table i.
Manuals to Which This Manual Refers About This Manual Table i.
Manuals to Which This Manual Refers About This Manual Table i. HP Manuals to Which This Manual Refers (page 4 of 4) Manual Description Spooler Programmer’s Guide Explains how to use the spooler utility that collects and routes printer output Spooler Utilities Reference Manual Explains spoolers, which can be given Guardian file names and used with HP COBOL programs SQL/MP Programming Manual for COBOL Describes the programmatic interface to HP NonStop SQL/MP for COBOL.
Acknowledgment About This Manual Acknowledgment COBOL is an industry language and is not the property of any company or group of companies, or of any organization or group of organizations. No warranty, expressed or implied, is made by any contributor or by the CODASYL COBOL Committee as to the accuracy and functioning of the programming system and language. Moreover, no responsibility is assumed by any contributor, or by the committee, in connection herewith.
Notation Conventions About This Manual Notation Conventions This manual uses these conventions throughout: • • • • • • • • “Compiler” means the ECOBOL compiler unless otherwise stated “Linker” means the eld utility unless otherwise stated COBOL Name Conventions Hypertext Links Syntax Diagram Conventions Range Convention Example Conventions Change Bar Notation COBOL Name Conventions This manual uses these COBOL names, and this is what they mean: Name Meaning COBOL The implementation of the 1985 ISO/A
Syntax Diagram Conventions About This Manual To use a railroad diagram, follow the direction of the arrows and specify syntactic items as indicated by the diagram pieces: Diagram Piece Meaning Type KEYWORD as shown. You can type letters in uppercase or lowercase. KEYWORD VST412.vsd Replace item with a value that fits its description, which follows the syntax diagram. item VST413.vsd Type content (punctuation mark, symbol, or letter) as shown. You can type a letter in uppercase or lowercase.
Syntax Diagram Conventions About This Manual Spacing rules are: • If the arrow between two diagram pieces is labelled “ns,” put no spaces between the syntactic items that they represent. For example: ns volume $ VST420.vsd means that you type: $NEWVOL not $ NEWVOL • An “ns” on the top line of a choice structure applies to the lower lines in the choice structure as well. For example: ns " ns COBOL85^RETURN^SORT^ERRORS " COBOL_RETURN_SORT_ERRORS_ VST635.
Range Convention About This Manual • If two diagram pieces are separated by a separator character, separating the syntactic items that they represent by spaces is optional. For example: integer1 MULTIPLY , integer2 VST411.vsd means that you type: MULTIPLY 3,4 or MULTIPLY 3, 4 • If a diagram piece is immediately followed by a period, putting spaces between the syntactic item and the period is optional. For example: END PROGRAM program-name . VST374.vsd means that you can type: END PROGRAM SORT.
Example Conventions About This Manual Example Conventions In examples, a modified ellipsis (...) indicates an omission. The code in Example i can be abbreviated as shown in Example ii. Example i. Code Example Without Ellipsis (...) WORKING-STORAGE SECTION. 01 MONTH-NAME-TABLE. 05 FILLER PICTURE X(9) VALUE "January". 05 FILLER PICTURE X(9) VALUE "February". 05 FILLER PICTURE X(9) VALUE "March". 05 FILLER PICTURE X(9) VALUE "April". 05 FILLER PICTURE X(9) VALUE "May". 05 FILLER PICTURE X(9) VALUE "June".
Part I.
Part I.
1 Introduction This manual describes the HP COBOL for NonStop systems (HP COBOL) language and explains how to use it to create TNS/E native processes. (The COBOL Manual for TNS and TNS/R Programs explains how to use the HP COBOL language to create TNS processes and TNS/R native processes.
Embedded SQL/MP Introduction Table 1-1. Required HP COBOL Modules and Their Levels Module Level Nucleus 2 Sequential I-O 2 Relative I-O 2 Indexed I-O 2 Inter-Program Communication 2 Sort-Merge 1 Source Text Manipulation 2 Table 1-2. Optional HP COBOL Modules and Their Levels Module Level Segmentation* 2 (partial) Debug* 1 Intrinsic Function 1 Report Writer Null Communication Null * The 1985 COBOL standard classifies this module as obsolete, so you are advised not to use it.
Summary of Execution Modes Introduction Summary of Execution Modes TNS/E systems support three execution modes: TNS Mode Accelerated Mode TNS/E Native Mode Programs are generated by TNS compilers. Programs are generated by TNS compilers and then processed by the TNS Object Code Accelerator (OCA). Programs are generated by TNS/E native compilers. Programs use TNS process and memory architecture. Programs use TNS process and memory architecture.
Guardian and OSS Environments Introduction Guardian and OSS Environments The NonStop operating system offers two operating environments, the Guardian environment and the OSS environment. The OSS utility ecobol calls the ECOBOL compiler. The OSS environment provides industry-standard application program interfaces (APIs) and utilities to enable you to port existing applications quickly and easily to NonStop systems. The NonStop operating system continues to support Guardian services.
Compiler Output Introduction Compiler Output The output of the compiler is: • • A listing, including any compiler diagnostic messages (if the file for the listing is a disk file, the compiler creates an EDIT file unless the file already exists) An object file, if no compilation errors occurred The ECOBOL compiler produces either: • • • A loadfile A linkfile A dynamic-link library (DLL) For information about the COBOL85 and NMCOBOL compilers, see the COBOL Manual for TNS and TNS/R Programs.
Executing Loadfiles Introduction Executing Loadfiles Guardian Environment From ... Use ... For more information, see ... A terminal TACL command RUN or RUND RUN or RUND Command An executing program TS/MP transactionprocessing software TS/MP System Management Manual CLU_PROCESS_CREATE_ routine CRE Programmer’s Guide OSS Environment From ... Use ... For more information, see ... A terminal Name of the executable file (type it and press the return key).
2 Source Program Organization and Format The lines of a COBOL source program are organized into divisions. The program ends with an END PROGRAM statement. Individual lines must follow a reference format that the compiler accepts. Any line in a source program can contain a COPY statement, which tells the compiler to insert source text from a specified disk file, called a COPY library. A run unit can contain more than one source program. Programs in the same run unit can share resources with each other.
Source Program Components Source Program Organization and Format Source Program Components The components of a COBOL source program must appear in the order shown in Table 2-1. Table 2-1.
Reference Format for Source Program Lines Source Program Organization and Format program-name is a COBOL word. It names the same program unit that the PROGRAM-ID does (see PROGRAM-ID Paragraph), for example: IDENTIFICATION DIVISION. PROGRAM-ID. MYPROG. ... END PROGRAM MYPROG. Reference Format for Source Program Lines Individual source program lines must follow a reference format that the compiler accepts. There are two choices of reference format: Tandem and ANSI.
Indicator Area Source Program Organization and Format Topics: • • • Indicator Area Area A and Area B Restrictions Indicator Area The indicator area begins at margin C and ends at margin A, using only column 1. It can be empty, or it can contain a single character that describes the type of information on the line. Table 2-2.
Source Program Organization and Format Indicator Area Debugging Line (D or d) A debugging line has the letter D or d in the indicator area. If the program includes a DEBUGGING MODE clause, the debugging line is part of the program; otherwise, it is a comment. A debugging line cannot contain embedded SQL/MP or SQL/MX statements. For information on DEBUGGING MODE, see SOURCE-COMPUTER Paragraph. Continuation Line (-) A continuation line has a hyphen (-) in the indicator area.
Source Program Organization and Format Area A and Area B If all characters between margin A and margin R are spaces, then the line is a blank line. Blank lines can occur anywhere in the source text and have no effect on either the syntax or semantics of source programs. If at least one character other than spaces occurs after margin A, that character begins a new lexical element.
Source Program Organization and Format Restrictions Period Separators Do not put anything other than spaces after the period separator that follows one of these reserved word sequences: • • • DIVISION DECLARATIVES END DECLARATIVES Do not put anything other than spaces or a USE statement after the period separator that follow the reserved word SECTION.
Source Program Organization and Format • • • COPY Libraries Start the level-numbers 01 and 77 and all level indicators (FD and SD) in area A of a program text line with a space character in the indicator area and precede them only by space characters. Other level-numbers can start in either area A or area B.
Directly Contained Programs and Indirectly Contained Programs Source Program Organization and Format Directly Contained Programs and Indirectly Contained Programs One program can contain another program directly or indirectly. Suppose a program, L, contains another program, R. Program L directly contains program R when program L does not contain any other program that also contains program R. Program L indirectly contains program R if program L does contain any other program that contains program R.
Scope of User-Defined Names Source Program Organization and Format Table 2-3.
Source Program Organization and Format Scope of User-Defined Names Condition-Name, Data-Name, File-Name, and Record-Name When condition-names, data-names, file-names, and record-names are declared in a source program, only that program can refer to them except when one or more of the names is global and the program contains other programs.
Source Program Organization and Format Common Programs Index-Name If a data item is external and/or global and includes a table accessed with an index, that index is also external and/or global (respectively); therefore, the scope of an indexname is identical to that of the data-name that names the table whose index is named by that index-name, and the scope rules for data-names apply. Index-names cannot be qualified.
Source Program Organization and Format How Programs Share Resources How Programs Share Resources A program can share resources with programs that it contains (directly or indirectly) and programs that are in the same run unit as it is. The resources that a program can share with programs that it contains are: • • • • record-names data-names condition-names file-names The program makes them accessible to the inner programs by declaring them to be global.
Source Program Organization and Format External and Internal Objects Some names are always global; other names are always local; and some names are either global or local, depending on specifications in the program that declares the names: Name It is global if a GLOBAL clause is in … Record-name its record description entry or the file description entry for the file-name associated with its record description entry (if the record-name is in the File Section) Data-name its record description entry Co
Source Program Organization and Format External and Internal Objects Topics: • • • Data Records in Working and Extended-Storage File Connectors and Their Records Linkage Section Records Data Records in Working and Extended-Storage To give a data record described in the Working-Storage or Extended-Storage Section the external attribute, include the keyword EXTERNAL in its data description entry. Only record data description entries can include the EXTERNAL clause.
Source Program Organization and Format Shared Data Shared Data Two programs in a run unit can refer to common data in these circumstances: • • • Any program that has described an external data record can refer to the data content of that record.
Source Program Organization and Format Shared Data Example 2-2.
Shared Data Source Program Organization and Format Example 2-2. Programs With Shared Data (page 2 of 4) * Accessibility: Which Routines Can Access Which Data Names? * ----* Mane Aaa Bbb Ccc Ddd Sub Item * ---- --- --- --- ----------------* L . . . . . w of Mane * / . L . . . w of Bbb * / . . L . . w of Ccc * / . . . . L w of Sub * . . L G G . x of Bbb * . . . . . L x of Sub * L G G / G . y of Mane * . . . L . . y of Ccc * . . . . . L y of Sub * L G G G G . z of Mane * . . . . .
Source Program Organization and Format Example 2-2. Programs With Shared Data (page 3 of 4) IDENTIFICATION DIVISION. PROGRAM-ID. Aaa. PROCEDURE DIVISION. a. DISPLAY " Aaa begin" PERFORM show-me DISPLAY " Aaa adding 2 to y" ADD 2 TO y PERFORM show-me CALL Bbb PERFORM show-me DISPLAY " Aaa end" EXIT PROGRAM . show-me. DISPLAY " y (global from Mane)=/" y "/" " z (global from Mane)=/" z "/" . END PROGRAM Aaa. IDENTIFICATION DIVISION. PROGRAM-ID. Bbb COMMON. DATA DIVISION. WORKING-STORAGE SECTION.
Shared Data Source Program Organization and Format Example 2-2. Programs With Shared Data (page 4 of 4) PROCEDURE DIVISION. c. DISPLAY " Ccc begin" PERFORM show-me DISPLAY " Ccc adding 4 to w, x, and y" ADD 4 to w x y PERFORM show-me CALL Ddd DISPLAY " Ccc end" EXIT PROGRAM . show-me. DISPLAY " in Ccc, w (ext)=/" w "/" " x (global from Bbb)=/" x "/" " y (local in Ccc)=/" y "/" . IDENTIFICATION DIVISION. PROGRAM-ID. Ddd. DATA DIVISION. PROCEDURE DIVISION. d.
Shared Data Source Program Organization and Format Example 2-3.
Source Program Organization and Format Shared Files Shared Files Two programs in a run unit can refer to common file connectors in these circumstances: • • Any program that has described an external file connector can refer to that file connector. If program G is contained within program H, both programs can refer to a common file connector.
3 Language Elements The smallest unit of the COBOL language is a character. You use most characters to form character-strings, and you use a few punctuation characters to form separators. The text of a source program consists of character-strings delimited by separators. Most character-strings and all separators consist of one or more characters from the COBOL character set, which is a subset of the ASCII character set.
COBOL Character Set Language Elements COBOL Character Set The COBOL character set is a subset of the ASCII character set (which is listed in Appendix A, ASCII Character Set). The COBOL character set has 78 characters; the ASCII character set has 128. Figure 3-2. COBOL Character Set COBOL Character Set Alphanumeric Characters (for COBOL words) Letters (A – Z a–z) Digits (0 – 9) Hyphen (–) Punctuation Characters Special Characters VST503.vsd Table 3-1.
Punctuation Characters Language Elements Table 3-2. Punctuation Characters (page 2 of 2) Character Name of Character ) Right parenthesis = Equal sign Table 3-3. Special Characters Character Name of Character + Plus sign - Hyphen or minus sign * Asterisk / Stroke or slash $ Currency sign > Greater than sign < Less than sign Except in nonnumeric literals, the compiler handles lowercase letters as equivalent to the corresponding uppercase letters.
Separators Language Elements Separators A separator is one or more consecutive punctuation characters used to separate character-strings, sentences, or special clauses or to delimit other characters in expressions. The punctuation characters that can be used as separators are: • • • • • • • Space Comma or Semicolon Colon Period Quotation Marks Parentheses Equal Sign Every character-string must be followed by a sequence of one or more separators.
Comments Language Elements Period A period (.) that immediately precedes one or more spaces acts as a period separator. Period separators are required in certain places by the syntactic definition of COBOL. They cannot appear anywhere else. Each sentence within the Identification and Procedure divisions and each entry within the Environment and Data divisions must end with a period separator. Quotation Marks Quotation marks in balanced pairs enclose nonnumeric literals.
Numeric Literals and PICTURE Character-Strings Language Elements Numeric Literals and PICTURE Character-Strings Several punctuation characters (comma, period, left parenthesis, right parenthesis) are also defined as characters available for the formation of numeric literals and PICTURE character-strings.
COBOL Words Language Elements If the COBOL word is not a level-number, segment-number, section-name, or paragraph-name, these rules apply: • • • • • • char-1 is a letter (uppercase or lowercase) or a digit. If char-1 is the only character in the word, then it must be a letter. char-n is a letter (uppercase or lowercase), a digit, or a hyphen (-). At least one character must be either a letter or a hyphen. The last character cannot be a hyphen. The maximum length of the word is 30 characters.
COBOL Words Language Elements Reserved Words A reserved word is a COBOL word that has a special meaning for the compiler. All reserved words appear in uppercase letters throughout this manual. (Some other words, such as product names, also appear in uppercase letters,) A reserved word can appear in the source program only where the language syntax requires or permits it. Every reserved word is unique and cannot be used or redefined for any purpose other than those described in this manual. Table 3-4.
COBOL Words Language Elements User-Defined Names A user-defined name is a COBOL word that you compose for your own use. You cannot use a reserved word for a user-defined name.
COBOL Words Language Elements The types of system-names are: • Resource names A resource name is a mnemonic-name that identifies part of the environment: Resource Name (mnemonic-name) Environment Part Identified CONSOLE Operator console MYTERM Home terminal CHANNEL-1 through CHANNEL-15 Carriage-control tape channels SWITCH-1 through SWITCH-15 External switches DANSK-NORSK DEUTSCH ESPANOL FRANCAIS-QW FRANCAIS-AZ SVENSK-SUOMI UK USASCII Native character sets For more information on resource na
COBOL Words Language Elements • Special names for operating system files A special name is a substitute (in the source program) for a certain operating system file: Operating System File Special Name Guardian OSS #IN The file named in the IN parameter of startup message of current process. The default input device (FD 0)— do not use it in SELECT clauses or the SPECIAL-NAMES paragraph as you can in the Guardian environment.
COBOL Words Language Elements Qualified Condition-Name: condition-name OF conditional-variable-name IN mnemonic-name VST001.vsd Qualified Data-Name: OF data-name data-name IN file-name OF IN VST002.vsd Qualified Paragraph-Name: OF paragraph-name section-name IN VST003.vsd Qualified Text-Name: text-name OF library-name IN VST004.vsd Qualified LINAGE COUNTER: LINAGE-COUNTER OF file-name IN VST005.
COBOL Words Language Elements These rules apply to qualification of names: • • • • • • • Each qualifier must be at a higher level than the previous one and stay within the same structure of the name it qualifies. The same name cannot occur at different levels in a structure; otherwise, the name could qualify itself. A data-name used as a qualifier cannot be subscripted; all subscripts that apply to a qualified data-name appear after all qualifiers.
COBOL Words Language Elements In Example 3-1, all data-names except PREFIX are unique. Example 3-1. Qualified Names FD TRANSACTION-FILE ... 01 TRANSACTION-REC. 03 ITEM-NO. 05 PREFIX X(2). 05 CODE X(3). 03 QUANTITY S9(8). ... 01 MASTER-REC. 03 CODE-NO. 05 PREFIX X(2). 05 SUFFIX X(3). 03 DESCRIPTION X(70). Qualification is necessary to refer to either PREFIX item.
Literals Language Elements Literals A literal is a character-string that has a value implied by either of these: • • An ordered set of characters that compose the literal A figurative constant (a special type of reserved word) Topics: • • • • Numeric literals ° ° Decimal Numeric Literals Hexadecimal Numeric Literals Nonnumeric literals ° ° Simple Nonnumeric Literals Hexadecimal Nonnumeric Literals National Literals Figurative Constants Decimal Numeric Literals A decimal numeric literal is a ch
Literals Language Elements Decimal numeric literals follow these rules: • • • • • When a decimal numeric literal appears in a context where its value is assumed to be a sequence of characters, its size is equal to the number of digits in its representation. A sign character (+ or -) has no effect on the size of a literal. Absence of a sign signifies a positive number.
Literals Language Elements hex-digit is one of the characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, a, b, c, d, e, f. The maximum number of hex-digits in a hexadecimal numeric literal is 16 (eight pairs). A hexadecimal numeric literal is considered an unsigned integer. It can appear anywhere that a decimal numeric literal can appear. Example 3-4.
Literals Language Elements • The value of a literal is the ordered sequence of characters in its representation (excluding the delimiting quotation marks and interpreting a pair of contained quotation marks as a single quotation mark character). The literal represents a data item of the alphanumeric category whose value is the value of the literal. Example 3-5. Nonnumeric Literals "THIS IS A NONNUMERIC LITERAL" "This is ANOTHER one.
Literals Language Elements " char " N n VST745.vsd char is any character in the national character set, including a punctuation character. A national literal can have at most 160 characters, excluding the delimiting quotation marks. National literals follow these rules: • • • • • The letter N or n and the quotation marks are part of the character-string that represents the literal; they are not part of the value of the literal.
Literals Language Elements ° ° • INSPECT statement As literal-1 or literal-2 of the REPLACING phrase of a COPY statement If national literals and national data items are used for items in a STRING statement (delim-1, delim-2, result, or delim-store ), all the items must be national literals or national data items. Figurative Constants A figurative constant is a character-string that has a value the compiler generates from one of the reserved words in the first column of Table 3-5.
Literals Language Elements • • • When you use a figurative constant whose source form does not include the word ALL with a DISPLAY, STRING, STOP, or UNSTRING statement, the compiler generates exactly one character. When you use a figurative constant whose source form does include the word ALL, there are two possibilities: ° If a nonnumeric or national literal follows the word ALL, the compiler generates a string having the length and value of the literal.
PICTURE Character-Strings Language Elements Table 3-5.
Comments Language Elements Comments A comment-entry or a comment line can contain any combination of characters in the computer’s character set. Both types of comments are character-strings that serve only to document a program. A comment-entry follows a paragraph header in the Identification Division and can continue on additional lines. A comment line is any line anywhere in the source text that has a comment character in the indicator field.
Comments Language Elements HP COBOL Manual for TNS/E Programs —520347-003 3- 24
4 Data Fundamentals Every data item in a COBOL program has a level, class and category. Data items are organized into data structures. How data is represented depends on the machine on which it executes. Not all data storage locations in a COBOL program are the same size. When you direct a COBOL program to store a value of a given size at a location of a different size, the process extends or truncates the value according to a set of alignment rules.
Data Structures Data Fundamentals Data Structures Data structures—records, files, and tables—are built from elementary items. Levelnumbers show the relationship of elementary data items to data structures. Although the structural forms are defined within a hierarchy, independent structures of any level are permitted. There is no requirement that all data be fully organized to the highest level. Furthermore, multiple structures can refer to the same or overlapping physical data.
Records Data Fundamentals Example 4-1. Level Numbers FD BRANCH-OFFICE-FILE LABEL RECORDS ARE OMITTED RECORD CONTAINS 100 CHARACTERS DATA RECORDS ARE ADDRESS-RECORD, PERSONNEL-RECORD, MISC-RECORD. * A record follows. 01 ADDRESS-RECORD. * A data structure follows. 05 OFFICE-NUMBER. * 10 DISTRICT * 05 88 NEW-YORK 88 TAMPA 88 OMAHA ... 10 REGION OFFICE-ADDRESS. 10 STREET 10 CITY 10 STATE 10 ZIP-CODE ... * An elementary item follows. PICTURE 99. Condition-names follow. VALUE 21. VALUE 43.
Records Data Fundamentals Topics: • • • Physical Records and Logical Records Record Elements Record Length Note. In this manual, “record” means logical record unless “physical record” is specified. Physical Records and Logical Records COBOL programs manipulate physical records and logical records.
Records Data Fundamentals Record Elements In COBOL, the lowest subdivisions of a record (that is, those not further subdivided) are called elementary items. Consequently, a record is a series of elementary items, or the record itself can be an elementary item. In Example 4-2, the elementary items are: • • • • • • LAST-NAME FIRST-NAME TITLE PUB-NAME PUB-LOCATION PUBLICATION-YEAR A data structure is a sequence of one or more elementary items that you can refer to by a group name.
Files Data Fundamentals When a file has the variable-length record type attribute, different records can have different numbers of character positions. In this case the input and output operations on the file process whatever size is associated with a particular logical record. After a record retrieval operation, the source program has sole responsibility for determining which of the possible record formats or lengths apply.
Files Data Fundamentals Organization Organization, which specifies a file’s logical structure, is a fixed attribute that is established when you create the file and cannot be changed. Table 4-2. File Organization (page 1 of 2) Organization Description Sequential A sequential file is organized so that each record except the first has a unique predecessor record and each record except the last has a unique successor record.
Files Data Fundamentals Table 4-2. File Organization (page 2 of 2) Organization Description Queue A queue file is an indexed file (and therefore, a key-sequenced file) that can function as a queue. Processes can queue and dequeue records in a queue file. Queue files contain variable-length records that are accessed by values in designated key fields. Unlike other key-sequenced files, queue files have prime keys but cannot have alternate keys.
Files Data Fundamentals Table 4-3. Relationship Between File Organization and Access Mode (page 2 of 2) Access Mode File Organization Sequential Random Dynamic Relative Program can select records in increasing order of relative record number (ignoring empty record areas).* Relative record numbers begin at 1. Program can select records from anywhere in the file by specifying relative record numbers. Records need not exist or have contiguous record numbers.
Files Data Fundamentals Open Mode The open mode is a dynamic attribute of a file connector; it controls which file operations are permitted. In HP COBOL the status of a file connector always includes an open mode. Table 4-4.
Files Data Fundamentals File Connector A COBOL program makes reference to files indirectly. It does not refer to a file by the file’s Guardian file name. Instead, it uses an ASSIGN clause in a file-control entry in the Input-Output Section of the Environment Division (possibly overridden at execution time by command interpreter commands) to associate the Guardian file name with a file connector, which is referred to throughout the remainder of the COBOL program through a COBOL file name.
Tables Data Fundamentals The setting of the file position indicator is irrelevant when the open mode is Output or Extend or the access mode is Random, because no sequential record retrieval operations are permitted in these cases. Tables Note. This topic applies to tables in the Data Division, not to SQL/MP or SQL/MX tables. You can define a table by including an OCCURS clause in a data description entry. This clause specifies that the data item be repeated a stated number of times.
Tables Data Fundamentals Example 4-3. One-Dimensional Table With Fixed Number of Elements WORKING-STORAGE SECTION. 01 MONTH-NAME-TABLE. 05 FILLER PICTURE X(9) VALUE "January". 05 FILLER PICTURE X(9) VALUE "February". 05 FILLER PICTURE X(9) VALUE "March". 05 FILLER PICTURE X(9) VALUE "April". 05 FILLER PICTURE X(9) VALUE "May". 05 FILLER PICTURE X(9) VALUE "June". 05 FILLER PICTURE X(9) VALUE "July". 05 FILLER PICTURE X(9) VALUE "August". 05 FILLER PICTURE X(9) VALUE "September".
Data Representation Data Fundamentals Example 4-5. Multidimensional Table 02 TOTAL OCCURS 20 TIMES. 03 TOTAL-A ... 03 TOTAL-B OCCURS 3 TIMES ... A COBOL table can have a maximum of 7 dimensions. If the description of a data item T-B-S subordinate to TOTAL-B also has an OCCURS clause, T-B-S is a 3-dimensional table. The outermost table of a multidimensional table can be of variable size, but each subordinate table must be of fixed size.
Data Alignment in Receiving Items Data Fundamentals Data Alignment in Receiving Items Not all data storage locations in a COBOL program are the same size.
Implicit FILLER Bytes Data Fundamentals To improve the alignment of its subordinate items, a level-01 (record) or level-77 data item is aligned on a 8-byte boundary. For TNS processes, a word is 2 bytes (16 bits), so a data item that is aligned on a word boundary is aligned on a byte position that is divisible by 2. For TNS/E processes, a word is 4 bytes (32 bits), so a data item that is aligned on a word boundary is aligned on a byte position that is divisible by 4.
Records Data Fundamentals These extra bytes are not part of the data item. If a data structure contains two items separated by implicit FILLER bytes, then these bytes are a part of that data structure; however, a data structure always begins with the first character position of its first elementary item, ignoring any FILLER bytes that were generated to align that item properly. The initial character positions of a data structure are never implicit FILLER bytes.
References to Data Items Data Fundamentals Automatic or requested alignment of data items described by redefinition of a record’s character positions (through use of the REDEFINES clause) follows the rules described previously. When the first data item allocated by a redefinition requires 2byte or 4-byte alignment, the data item being redefined must begin on the appropriate boundary within its record.
Qualifiers Data Fundamentals • • Identifiers Condition-Names Qualifiers When the name of a data element exists within a hierarchy of names, you must be able to make references to the name unique by mentioning one or more names defined at higher levels of the hierarchy. The higher-level names are called qualifiers. Although you must provide enough qualifiers to make the name unique, you need not include all levels. For more information on qualifiers, see Qualified Names.
Subscripts Data Fundamentals condition-name is a level-88 item associated with either a data item described with an OCCURS clause or a data item subordinate to a data item described with an OCCURS clause. If condition-name is qualified, the subscripts follow the qualifiers. subscript integer qualified-name index-name + - offset VST007.vsd integer is a nonzero numeric literal. If it is signed, the sign must be positive. qualified-name is the identifier of an integer numeric data item.
Reference Modifiers Data Fundamentals Number and Range of Subscripts HP COBOL supports subscripting of up to 7 dimensions. The lowest legitimate subscript value is 1, which selects the first element of a table. The next sequential elements of the table are selected by subscripts whose values are 2, 3, and so on. The highest subscript value, in any particular case, is the maximum number of elements in the table. Any higher subscript is erroneous, and can cause an error.
Reference Modifiers Data Fundamentals leftmost-character-position is an arithmetic expression. Its value must be a positive nonzero integer less than or equal to the number of characters in identifier; it represents the leftmost character of the portion of identifier you are selecting. length is an arithmetic expression. Its value must be a positive, nonzero integer; it represents the size of the portion of identifier you are selecting.
Reference Modifiers Data Fundamentals • Reference modifiers create a unique data item, which is a substring of the data item referenced by identifier. The program handles this unique data item as an elementary data item without the JUSTIFIED clause. When identifier references an alphabetic data item, the unique data item has the class and category alphabetic. When identifier references a data item of any other category, the unique data item has the class and category alphanumeric.
Identifiers Data Fundamentals Identifiers An identifier is a data-name made unique by a combination of qualifiers, subscripts, and reference modifiers. data-name OF qualified-name IN ( ( subscript ) leftmost-character-position : ) length VST009.vsd data-name is the name of a data item. If it has reference modifiers, it must be USAGE DISPLAY. If it is used as a subscript or qualifier itself, it can be qualified but not subscripted. qualified-name is defined in Qualified Names.
Data Fundamentals Condition-Names length is an arithmetic expression. Its value must be a positive, nonzero integer; it represents the size of the portion of data-name you are selecting. The value of the expression (leftmost-character-position + length ) - 1 must be less than or equal to the number of characters in data-name.
Data Fundamentals Condition-Names This IF statement uses the condition-name RESTRICTED-USE to test the value of USE-CODE: IF RESTRICTED-USE IN PART-NUMBER (30) PERFORM REPORT-VIOLATION ELSE ... Using condition-names also makes it easier to modify the program. Suppose the table definition in Example 4-10 changes so that both 1 and 2 mean RESTRICTED-USE. Without the use of a condition-name, the program must examine and possibly change each instance of the testing of the value of USE-CODE.
5 Identification Division The Identification Division is required in a COBOL program. It has one required paragraph (PROGRAM-ID, which specifies the program name), and five optional paragraphs (which specify your name, the date, and the program purpose). The compiler handles the optional paragraphs as comments, except for the DATECOMPILED paragraph, whose presence causes the compiler to report the compilation time and date in the listing.
Identification Division Identification Division Syntax PROGRAM-ID paragraph is defined under PROGRAM-ID Paragraph. AUTHOR paragraph Note. The 1985 COBOL standard classifies the AUTHOR paragraph as obsolete, so you are advised not to use it. Instead, use a comment, as in Example 5-2. . AUTHOR comment-entry VST400.vsd comment-entry is any combination of characters from the ASCII character set.
Identification Division Identification Division Syntax DATE-WRITTEN paragraph Note. The 1985 COBOL standard classifies the DATE-WRITTEN paragraph as obsolete, so you are advised not to use it. Instead, use a comment, as in Example 5-2. . DATE-WRITTEN comment-entry VST402.vsd DATE-COMPILED paragraph Note. The 1985 COBOL standard classifies the DATE-COMPILED paragraph as obsolete, so you are advised not to use it. Instead, use a comment, as in Example 5-2. . DATE-COMPILED comment-entry VST013.
Identification Division PROGRAM-ID Paragraph Example 5-2. Identification Division With Comments * * * * * IDENTIFICATION DIVISION. PROGRAM-ID. MYPROG AUTHOR. JANE DOE INSTALLATION. HEADQUARTERS DATE-WRITTEN. JANUARY 20, 1992 DATE-COMPILED. JANUARY 21, 1992 SECURITY. COMPANY CONFIDENTIAL PROGRAM-ID Paragraph The required PROGRAM-ID paragraph names the COBOL program and (optionally) declares it to be an initial program, a common program, or both.
Identification Division DATE-COMPILED Paragraph COMMON makes the program common, which means that the program must be contained within another program and can be called by any other program contained (directly or indirectly) in the same containing program, but not by the programs it contains. Usage Considerations: • • A Program Can Be Both Initial and Common Storage Allocation For an Initial Program For an initial program, all data items are allocated dynamically.
Identification Division DATE-COMPILED Paragraph DATE-COMPILED must begin in area A, have a space in the indicator field, be completely contained on a single program text line, and end with a period followed by a space. If you split the reserved word DATE-COMPILED across program lines, the compiler handles the paragraph as a simple comment-entry and does not replace its contents with the date and time of compilation. comment-entry is any combination of characters from the ASCII character set.
6 Environment Division The Environment Division is optional in a COBOL program. It has two optional sections, the Configuration Section and the Input-Output Section. The Configuration Section states the type of computer on which to compile the program and the type of computer on which to run the program.
Environment Division Configuration Section CONFIGURATION section is defined in Configuration Section. INPUT-OUTPUT section is defined in Input-Output Section. Configuration Section The Configuration Section is forbidden in a contained program and is optional in any other program. The compiler prints a warning if a Configuration Section paragraph is out of order; it reports an error if a paragraph is repeated. CONFIGURATION SECTION .
Environment Division SOURCE-COMPUTER Paragraph SOURCE-COMPUTER Paragraph The optional SOURCE-COMPUTER paragraph names the computer system on which the program is compiled and can specify that debugging lines be compiled. SOURCE-COMPUTER . . name DEBUGGING MODE WITH VST016.vsd name is any sequence of ASCII characters except WITH, DEBUGGING, or MODE. It names the computer system on which the program is compiled.
Environment Division OBJECT-COMPUTER Paragraph OBJECT-COMPUTER Paragraph The optional OBJECT-COMPUTER paragraph names the computer system on which the object program can run. OBJECT-COMPUTER . . name «MEMORY-SIZE clause» PROGRAM COLLATING SEQUENCE clause «SEGMENT-LIMIT clause» CHARACTER-SET clause VST017.vsd name is any combination of character-strings except reserved words and separators (except period (.)). It is handled as a comment. MEMORY-SIZE clause Note.
Environment Division OBJECT-COMPUTER Paragraph CHARACTER-SET clause defines the ALPHABETIC class. For more information, see CHARACTER-SET Clause. MEMORY-SIZE Clause Note. The 1985 COBOL standard classifies the MEMORY-SIZE clause as obsolete, so you are advised not to use it. HP COBOL ignores the MEMORY SIZE clause except to check its syntax. MEMORY integer WORDS CHARACTERS SIZE MODULES VST018.vsd integer must be in the range 1 through 32,767 but is otherwise ignored.
Environment Division OBJECT-COMPUTER Paragraph alphabet-name is defined in an ALPHABET clause in the SPECIAL-NAMES paragraph. For more information, see ALPHABET Clause. SEGMENT-LIMIT Clause Note. The 1985 COBOL standard classifies the SEGMENT-LIMIT clause as obsolete, so you are advised not to use it. HP COBOL ignores the SEGMENT LIMIT clause except to check its syntax. All segment-numbers, from 01 to 49, are permanent. segment-number SEGMENT-LIMIT IS VST020.
Environment Division OBJECT-COMPUTER Paragraph character-set-type Alphabets (page 2 of 2) SVENSK-SUOMI Swedish, Finnish UK United Kingdom USASCII United States ASCII In COBOL, this clause affects only the ALPHABETIC-UPPER, ALPHABETIC-LOWER, and ALPHABETIC tests. In SCREEN COBOL, the CHARACTER-SET IS clause has some additional semantics, including terminal configuration (see the Pathway/TS SCREEN COBOL Reference Manual).
Environment Division SPECIAL-NAMES Paragraph SPECIAL-NAMES Paragraph The optional SPECIAL-NAMES paragraph assigns names of your choice to certain system-names. In addition, you can define a currency sign other than the dollar sign ($), and you can exchange the function of commas and periods in PICTURE characterstrings and numeric literals. National literals and national data items cannot be used in the SPECIAL-NAMES paragraph. SPECIAL-NAMES . System-Name clause .
Environment Division SPECIAL-NAMES Paragraph System-Name Clause IS system-name mnemonic-name STATUS phrase VST023.vsd system-name is the name of a hardware device, carriage-control tape channel, or external switch. If the System Name clause has no STATUS phrase, system-name must be one of these values: Value Meaning CONSOLE Operator console MYTERM Process’s home terminal CHANNEL-1 through CHANNEL-12 Carriage-control tape channel Note.
Environment Division SPECIAL-NAMES Paragraph switch-on is a condition-name for testing the settings of switches. You do not have to specify a mnemonic-name for a switch; you can just define this conditionname. off-phrase switch-off OFF STATUS IS VST026.vsd switch-off is a condition-name for testing the settings of switches. You do not have to specify a mnemonic-name for a switch; you can just define this conditionname.
Environment Division ° SPECIAL-NAMES Paragraph system-name is MYTERM When system-name is MYTERM, the System-Name clause assigns a mnemonic-name to the home terminal You can then use the mnemonic-name in ACCEPT and DISPLAY statements, as in this example: SPECIAL-NAMES. MYTERM IS MY-TERMINAL . ... DISPLAY "MOUNT THE PAYROLL MASTER TAPE" UPON MY-TERMINAL. ... ACCEPT EMPLOYEE-NAME FROM MY-TERMINAL.
Environment Division SPECIAL-NAMES Paragraph Example 6-1. ON STATUS Phrase SPECIAL-NAMES. SWITCH-4 IS TRANSACTION-TRACE, ON STATUS IS TRACING-TRANSACTIONS ... ... IF TRACING-TRANSACTIONS WRITE ... File-Mnemonic Clause The File-Mnemonic clause is, technically, a variant of the “system-name IS mnemonic-name ” clause, but its purpose is significantly different.
Environment Division SPECIAL-NAMES Paragraph define-name-literal is a nonnumeric literal that specifies the name of a DEFINE of type MAP. For information about DEFINE names, see DEFINEs. system-file-name-word is a single user-defined word that specifies the name of an operating system file, not qualified by any system name, volume name, or subvolume name. It cannot be a nonnumeric literal. It cannot represent a DEFINE name.
Environment Division SPECIAL-NAMES Paragraph STANDARD-1 STANDARD-2 NATIVE specify the USASCII character set. EBCDIC specifies the Extended Binary-Coded Decimal Interchange Code. literal-phrase literal-1 THROUGH literal-2 THRU ALSO literal-3 VST029.vsd defines an alphabet explicitly. An alphabet-name defined by literal-phrase cannot be used in the CODE-SET clause in a file description entry. If you use literal-phrase, you cannot specify a given character more than once in the ALPHABET clause.
Environment Division SPECIAL-NAMES Paragraph Usage Considerations: • Alphabet-Name in PROGRAM COLLATING SEQUENCE Clause When you include an alphabet-name in the PROGRAM COLLATING SEQUENCE clause of the OBJECT-COMPUTER paragraph, you are specifying that the associated collating sequence is to be used in nonnumeric comparisons performed throughout the program.
Environment Division • SPECIAL-NAMES Paragraph Program Collating Sequence and Figurative Constants You can use the literal phrase of the ALPHABET clause to specify an arbitrary collating sequence for use in nonnumeric comparisons, sorting, and the intrinsic functions CHAR and ORD. For information on nonnumeric comparisons, see Arithmetic Operations. For information on sorting, see SORT. For information on the intrinsic functions CHAR and ORD, see CHAR Function and ORD Function.
Environment Division SPECIAL-NAMES Paragraph position is an unsigned integer. Its value is in the range 1 through 256 and is the ordinal position of a character in an alphabet (the first ASCII character has ordinal position 1, although it is represented by octal 00). alphabet-name is an alphabet that includes the character to which you want to assign symbol-char. The default is USASCII.
Environment Division SPECIAL-NAMES Paragraph If literal-1 is an unsigned integer literal, its value must be in the range 1 through 256. The value is the ordinal number of a character position in the computer’s character set (the first character has ordinal number 1, even though its representation is octal 00). If literal-1 is a nonnumeric literal, its value depends on the presence or absence of literal-2.
Environment Division SPECIAL-NAMES Paragraph The order of specification has no effect on the performance of the program using the definition. CURRENCY SIGN Clause The CURRENCY SIGN clause specifies a one-character nonnumeric literal, sign, whose value is to be used in the PICTURE clause to represent the currency sign. sign CURRENCY SIGN IS VST034.
Environment Division Input-Output Section DECIMAL-POINT Clause The DECIMAL-POINT clause exchanges the functions of commas and periods in PICTURE character-strings and numeric literals. DECIMAL-POINT COMMA IS VST380.vsd Input-Output Section COBOL programs typically handle large amounts of data, stored on such devices as disks and magnetic tapes. Before a program can use the stored data, the operating system file names must be linked to COBOL file names.
Environment Division FILE-CONTROL Paragraph file-control-entry has different syntax for sequential, line sequential, relative, indexed, queue, and sort-merge files. See the appropriate topic.
Environment Division FILE-CONTROL Paragraph Table 6-3.
Environment Division FILE-CONTROL Paragraph Table 6-4. Descriptions of File-Control Entry Clauses (page 1 of 2) Clause Description SELECT Defines the file name used to refer to the file in the remainder of the source program. The OPTIONAL phrase applies only to files opened in the INPUT, I-O, or EXTEND mode. When such a file is not required to be present every time the object program unit is executed, you can designate it as optional.
Environment Division FILE-CONTROL Paragraph Table 6-4. Descriptions of File-Control Entry Clauses (page 2 of 2) Clause Description FILE STATUS The FILE STATUS clause specifies the identifier (designated in the syntax as filestat ) that is to serve as the file-status data item for the file. When a COBOL runtime I-O routine completes an operation on the file, it stores the status code in the file-status data item before returning control to your program.
Environment Division FILE-CONTROL Paragraph Each such file has an INSERTIONORDER attribute that governs this behavior for all its alternate keys. An insertion-ordered alternate key cannot share an alternate key file with other keys of different lengths, or with other alternate keys that are not insertion ordered. The attribute can be changed only by using either a call to the operating system routine SET or by use of the File Utility Program (FUP), not by any COBOL language phrase or clause.
Environment Division FILE-CONTROL Paragraph In HP COBOL, entry-sequenced disk files can have alternate record keys, whose values can identify individual records. A file-control entry for a sequential file includes an ORGANIZATION SEQUENTIAL clause or no ORGANIZATION clause (in which case the file has sequential organization by default). SELECT clause .
Environment Division FILE-CONTROL Paragraph ASSIGN clause ASSIGN system-file-name define-name-literal TO VST039.vsd associates file-name with system-file-name or define-name-literal. Only the first system-file-name or define-name-literal has meaning. The compiler ignores subsequent names and literals and issues a warning. system-file-name is the name of a file that the file system recognizes or one of the special operating system file names described in System-Names.
Environment Division FILE-CONTROL Paragraph number must be in the range 1 through 32, and its value is interpreted: Value of number Effect 1 No buffering or HP COBOL Fast I-O 2 Sequential block buffering on input and buffered cache on output if the assigned file qualifies 3 or greater HP COBOL Fast I-O if the assigned file qualifies; if not, sequential block buffering for input and buffered cache for output if the assigned file qualifies; otherwise normal I-O number is the number of blocks to buffe
Environment Division FILE-CONTROL Paragraph RECORD DELIMITER clause RECORD DELIMITER STANDARD-1 rec-delim IS VST043.vsd specifies the method of determining the length of a variable-length record on the file’s external medium. HP COBOL handles this clause as a comment, except that these requirements are checked: ° This clause can appear only for a file whose description specifies variablelength records. ° STANDARD-1 applies only to magnetic tape files that contain standard label records.
Environment Division FILE-CONTROL Paragraph alt-key is an alphanumeric or unsigned numeric data item declared in the record description entry of the file and is used to gain access to records within the file. The size and location of alt-key must agree with the size and location of the alternate key within the file, as defined when the alternate key file was established by the Guardian environment File Utility Program (FUP). (For information about FUP, see the File Utility Program (FUP) Reference Manual.
Environment Division FILE-CONTROL Paragraph 3. If Step 2 is not true, the buffer size is 4,096. • Alternate Record Keys Records in a file can be read in the ascending order of alternate key values, even if the file’s organization is sequential or relative. The order in which records are obtained using alt-key can differ from the order in which the records are stored. You can define up to 31 alternate keys for a file.
Environment Division FILE-CONTROL Paragraph Enscribe determines the size of the sequential block buffer. Usually, the buffer size is the file’s data block size, but when a process accesses a file by alternate keys, the buffer size is the alternate key file’s data block size. You can obtain the data block size for the appropriate file with the FUP command: FUP INFO file-name,DETAIL The size is usually 1,024 characters.
Environment Division FILE-CONTROL Paragraph You must not use buffered cache in applications that require each record to be actually written to disk before execution of the next statement in the program. • HP COBOL Fast I-O (Local Buffering) HP COBOL Fast I-O is an enhancement in input-output performance beyond that of sequential block buffering or buffered cache.
Environment Division FILE-CONTROL Paragraph If the RESERVE clause specifies a number that uses HP COBOL Fast I-O and the assigned file qualifies for HP COBOL Fast I-O, but there is not enough buffer space for HP COBOL Fast I-O, then the I-O status code is “07” and sequential block buffering is used. If you run out of disk space, the corrupt bit is set, the program terminates abnormally, and you cannot open the file. If the file is entry-sequenced, use FUP to clear the corrupt bit.
Environment Division FILE-CONTROL Paragraph File-Control Entries for Line Sequential Files Line sequential files are available only in the OSS environment. SELECT clause ASSIGN clause . RESERVE clause ORGANIZATION clause ACCESS MODE clause FILE STATUS clause VST624.vsd SELECT clause SELECT file-name OPTIONAL VST038.vsd OPTIONAL makes the file optional, which means that an OPEN statement with an INPUT, I-O, or EXTEND phrase can open the file whether or not the file exists.
Environment Division FILE-CONTROL Paragraph ASSIGN clause ASSIGN system-file-name TO VST640.vsd associates file-name with system-file-name. Only the first system-filename has meaning. The compiler ignores subsequent names and issues a warning. system-file-name is the name of a code-180 file that the file system recognizes or one of the special operating system file names described in System-Names.
Environment Division FILE-CONTROL Paragraph FILE STATUS clause filestat STATUS FILE IS VST046.vsd defines filestat as the file-status data item for the file. When a COBOL runtime I-O routine completes an operation on the file, it stores the status code in filestat before returning control to your program (see I-O Status Code). filestat is a 2-character alphanumeric, nonnational data item defined in the WorkingStorage Section, Extended-Storage Section, or Linkage Section.
Environment Division FILE-CONTROL Paragraph SELECT clause SELECT file-name OPTIONAL VST038.vsd OPTIONAL makes the file optional, which means that an OPEN statement with an INPUT, I-O, or EXTEND phrase can open the file whether or not the file exists. If the file exists, its I-O status code is “00”; if not, its I-O status code is “05”. OPTIONAL does not affect the OPEN statement with an OUTPUT phrase.
Environment Division FILE-CONTROL Paragraph RESERVE clause number RESERVE AREA AREAS VST040.vsd enables or prevents sequential block buffering on input and buffered cache on output, or enables or prevents HP COBOL Fast I-O for both input and output, for a disk file, depending on the value of number. The access mode of the file must be SEQUENTIAL. number is a numeric literal, an unsigned integer.
Environment Division FILE-CONTROL Paragraph ACCESS MODE clause ACCESS MODE IS SEQUENTIAL RANDOM RELATIVE KEY clause DYNAMIC VST049.vsd SEQUENTIAL makes the access mode of the file sequential (the default). That means the records of the file are to be operated upon as if they were sequentially organized. RANDOM makes the access mode of the file random. That means the records of the file are to be operated upon in any order, as selected by the current value of the relative key or an alternate key.
Environment Division FILE-CONTROL Paragraph ALTERNATE RECORD KEY clause ALTERNATE RECORD IS KEY alt-key WITH DUPLICATES VST045.vsd alt-key is an alphanumeric or unsigned numeric data item declared in the record description entry of the file. It is used to access records within the file. Its size and location must agree with the size and location of the alternate key within the file, defined when the alternate key file was established by the Guardian environment File Utility Program (FUP).
Environment Division FILE-CONTROL Paragraph Usage Considerations: • Relative Key Every record in a relative file is uniquely identified by a positive integer called the relative record number. Each record’s number defines its logical position in the file. The first logical record has a relative number of 1, the second logical record has a relative number of 2, and so on. A file is not required to contain records in every logical position; record 3 can exist even when record 2 is missing. Note.
Environment Division • FILE-CONTROL Paragraph HP COBOL Fast I-O (Local Buffering) HP COBOL Fast I-O is an enhancement in input-output performance beyond that of sequential block buffering or buffered cache. It is available if a program and the relative file upon which it is to operate are in the CRE and meet the criteria under File-Control Entries for Sequential Files. Example 6-6. Relative File Used for Random Access INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT INPUT-FILE ASSIGN TO "$DATA.MYDISC.
Environment Division FILE-CONTROL Paragraph File-Control Entries for Indexed Files Indexed organization provides the capability to read records from and write records to a disk file either randomly or sequentially. In an indexed file, the value of the prime key of each record uniquely identifies that record. A file-control entry for an indexed file includes an ORGANIZATION INDEXED clause. SELECT clause ASSIGN clause RESERVE clause ORGANIZATION clause ACCESS MODE clause .
Environment Division FILE-CONTROL Paragraph file-name is the COBOL file-name (the file-name in a file description entry). ASSIGN clause ASSIGN system-file-name define-name-literal TO VST039.vsd associates file-name with a file designated by system-file-name, or define-name-literal. Only the first system-file-name or define-nameliteral has meaning. The compiler ignores subsequent names and literals and issues a warning.
Environment Division FILE-CONTROL Paragraph number is a numeric literal, an unsigned integer.
Environment Division FILE-CONTROL Paragraph DYNAMIC makes the access mode of the file dynamic. That means the records of the file are accessible by either sequential or random access; you can position the file with START to a certain key value and read or write sequentially from there. The default access mode is sequential. RECORD KEY clause RECORD reckey KEY IS VST054.vsd rec-key is an alphanumeric or unsigned numeric data item defined in the record description entry for the file.
Environment Division FILE-CONTROL Paragraph FILE STATUS clause filestat STATUS FILE IS VST046.vsd defines filestat as the file-status data item for the file. When a COBOL runtime I-O routine completes an operation on the file, it stores the status code in filestat before returning control to your program (see I-O Status Code). filestat is a 2-character alphanumeric, nonnational data item defined in the WorkingStorage Section, Extended-Storage Section, or Linkage Section.
Environment Division • FILE-CONTROL Paragraph Buffered Cache Buffered cache, enabled by the RESERVE clause when the file is open in OUTPUT, I-O, or EXTEND mode, is discussed under File-Control Entries for Sequential Files. • HP COBOL Fast I-O (Local Buffering) HP COBOLFast I-O is an enhancement in input-output performance beyond that of sequential block buffering or buffered cache.
Environment Division FILE-CONTROL Paragraph File-Control Entries for Queue Files A queue file is an indexed file that can function as a queue. Unlike an ordinary index file, a queue file cannot have alternate keys. SELECT clause ASSIGN clause RESERVE clause ORGANIZATION clause ACCESS MODE clause RECORD KEY clause . FILE STATUS clause VST740.vsd For descriptions of clauses and usage considerations, see File-Control Entries for Indexed Files.
Environment Division FILE-CONTROL Paragraph ASSIGN clause ASSIGN system-file-name TO define-name-literal VST039.vsd associates the COBOL file-name (sd-name ) with a file designated by systemfile-name, or define-name-literal. Only the first system-file-name or define-name-literal has meaning. The compiler ignores subsequent ones and issues a warning. system-file-name is the name of a disk file that the file system recognizes.
Environment Division I-O-CONTROL Paragraph Example 6-8. File-Control Entry for Sort-Merge File INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT SORT-FILE ASSIGN TO "#TEMP". ... DATA DIVISION. FILE SECTION. SD SORT-FILE RECORD CONTAINS 40 CHARACTERS. 01 SORT-FIELDS. ... I-O-CONTROL Paragraph The optional I-O-CONTROL paragraph specifies positioning information for a tape file or the sharing of a memory area by more than one file.
Environment Division I-O-CONTROL Paragraph RERUN clause Note. The 1985 COBOL standard classifies the RERUN clause as obsolete, so you are advised not to use it. RERUN rerun-file ON system-name EVERY rerun-file-2-phrase units CLOCK-UNITS condition VST058.vsd rerun-file system-name units condition are handled as comments. rerun-file-2-phrase recs RECORDS REEL END OF OF UNIT rerun-file-2 VST059.vsd is handled as a comment.
Environment Division I-O-CONTROL Paragraph SAME AREA clause SAME RECORD SORT AREA FOR MERGE same-file VST060.vsd specifies the files that share the same memory during program execution. These files do not share disk space or tape space. The SAME AREA clause has different meanings for I-O files (sequential, relative, indexed) than for sort-merge files. same-file is a file-name. MULTIPLE FILE clause Note.
Environment Division I-O-CONTROL Paragraph SAME AREA Clause for I-O Files The SAME AREA clause advises the compiler that two or more files that are not sortmerge files can use the same memory area during processing. Only one of these files can be open at any given time. SAME RECORD AREA FOR same-file VST062.vsd RECORD specifies that two or more files are to use the same memory area for processing the current logical record.
Environment Division I-O-CONTROL Paragraph The files mentioned in the SAME AREA or SAME RECORD AREA clause can differ in organization or access. SAME AREA Clause for Sort-Merge Files The SAME AREA clause of the I-O-CONTROL paragraph can also specify sort-merge files. HP COBOL ignores the advice provided to the compiler by the SAME AREA clause. The file system automatically allocates and manages all memory areas needed for file processing and for sort or merge operations.
Environment Division • I-O-CONTROL Paragraph SAME SORT AREA or SAME MERGE AREA Clause If the SAME SORT AREA or SAME MERGE AREA clause is used, at least one same-file must be a sort or merge file. Files that are not sort or merge files can also be named.
Environment Division RECEIVE-CONTROL Paragraph MULTIPLE FILE Clause Note. The 1985 COBOL standard classifies the MULTIPLE FILE clause as obsolete, so you are advised not to use it. MULTIPLE FILE TAPE CONTAINS tape-file POSITION position VST061.vsd tape-file is the file name of a file on the tape that the program uses.
Environment Division RECEIVE-CONTROL Paragraph The $RECEIVE mechanism of a server written in HP COBOL uses the receive-control table (sometimes called the Requester table) to record the status of the requesting processes that have opened the server. It uses the reply table to keep copies of the replies it has sent to each requesting process.
Environment Division RECEIVE-CONTROL Paragraph RECEIVE-CONTROL . . EXTERNAL TABLE OCCURS phrase SYNCDEPTH LIMIT phrase REPLY CONTAINS phrase ERROR CODE phrase MESSAGE SOURCE phrase REPORT phrase VST063.vsd EXTERNAL enables COBOL external files to share communication with $RECEIVE. EXTERNAL causes the compiler to create a special block, #RECEIVE, which contains the information used when $RECEIVE is opened by a COBOL external file.
Environment Division RECEIVE-CONTROL Paragraph table-length is an unsigned integer numeric literal in the range 1 through 255. The default value is 1. EXTENDED-STORAGE is ignored. SYNCDEPTH LIMIT phrase sync-id SYNCDEPTH LIMIT IS VST065.vsd establishes the length of the reply table, controlling how many replies are saved for each requesting process (opener). sync-id is an unsigned integer numeric literal in the range 1 through 255.
Environment Division RECEIVE-CONTROL Paragraph file-name is the name of a file whose longest record’s length is the number of characters from a reply message to be saved in the reply table. ERROR CODE phrase error ERROR CODE IS VST067.vsd error is an unsigned integer numeric item for storing an error code for a reply message, which you must set. It can be in the Working-Storage Section, the File Section, or the Linkage Section. MESSAGE SOURCE phrase message SOURCE MESSAGE IS VST068.
Environment Division RECEIVE-CONTROL Paragraph REPORT phrase message-type REPORT MESSAGES VST069.vsd specifies the type of system messages to be passed to the program.
Environment Division RECEIVE-CONTROL Paragraph Topics: • • • • • Receive-Control Table Reply Table ERROR CODE Phrase MESSAGE SOURCE Phrase REPORT Phrase Receive-Control Table The receive-control table, an internal table, is required for $RECEIVE operation. Its purpose is to identify, by the PROCESS-ID, which requesting processes have opened the server process. Table 6-7.
Environment Division RECEIVE-CONTROL Paragraph If the reply table exceeds an internal threshold value, the reply table is in the ExtendedStorage Section. Note. You do not need a reply table if the requester is not a fault-tolerant process. Figure 6-1.
Environment Division RECEIVE-CONTROL Paragraph ERROR CODE Phrase The ERROR CODE phrase of the RECEIVE-CONTROL paragraph provides a way for a server process to appear as a device to its requesters. When the server process sends an error code to a requester, the server process uses file-system error codes to set the ERROR CODE item. How the server process sets the ERROR CODE item depends on the device type of the device the server is simulating.
Environment Division RECEIVE-CONTROL Paragraph MESSAGE-TYPE is one of: Value Meaning Zero or greater Message sent by the requesting process Less than zero Message sent by the operating system ENTRY-NUMBER is the number assigned to the receive-control table entry for a requesting process. It is in the range set by table-length. When certain system messages not associated with any requester, such as CPU-UP and CPU-DOWN, are received, the number is 0.
Environment Division RECEIVE-CONTROL Paragraph Table 6-8. Message Types That the Program Generates (System) (page 2 of 2) COBOL Keyword Message-Type Code SETMODE -33 STOP Not used—see Table 6-10 TIME-SIGNAL -22 Messages generated by asynchronous hardware events must be explicitly requested. Table 6-9.
Environment Division RECEIVE-CONTROL Paragraph Table 6-10. REPORT Clause Message Types (page 1 of 2) Message Type Message Type Code Meaning BREAK -20 Break on device CLOSE -31 Close CONTROL -32 CONTROL system request CONTROLBUF -35 CONTROLBUF system request CPU-DOWN -02 Local processor failure CPU-UP -03 Local processor reload DEVICE-INFO -40 Device type inquiry DEVICEINFO2-COMPLETION -41 Nowait device type inquiry FILE-GETINFOBYNAMECOMPLETION N. A.
Environment Division RECEIVE-CONTROL Paragraph Table 6-10. REPORT Clause Message Types (page 2 of 2) Message Type Message Type Code Meaning REMOTE-CPU-DOWN -08 Remote processor down REMOTE-CPU-UP -08 Remote processor up RESETSYNC -34 RESETSYNC system request SETMODE -33 SETMODE system request SETPARAM -37 Process SETPARAM SETTIME -10 Set time STATUS-3270 -21 3270 device status received SUBORDINATE-NAME N. A. Subordinate name inquiry SYSTEM N. A.
7 Data Division The Data Division is optional in a COBOL program. It has four sections: the File Section, the Working-Storage Section, the Extended-Storage Section, and the Linkage Section. Each section contains entries describing data that the program unit being compiled from the source program manipulates. If your program does not use the type of data that the section defines, then the section is optional. DATA DIVISION .
Data Division Data Categories and Data Descriptions Data Categories and Data Descriptions Table 7-1.
Data Division Independent Data Item Description Entries More information: Record Levels Sources 01-49 Records 66 Descriptions That Rename Items (Level 66) 77 Independent Data Item Description Entries and Descriptions of Noncontiguous Elementary Items (Level 77) 88 Descriptions of Condition-Names for Values (Level 88) Independent Data Item Description Entries An independent data item description entry is a set of one or more data description entries. The first entry must have level number 77.
Data Division File Section FILE SECTION . 66-or-88 FD-entry 66-or-88 SD-entry 66-or-88 VST071.vsd 66-or-88 is a level-66 or level-88 description. For syntax, see Descriptions That Rename Items (Level 66) and Descriptions of Condition-Names for Values (Level 88). FD-entry FD file-description 01-data-description VST072.vsd file-description defines the physical aspects of a data file. See File Description Entries.
Data Division File Description Entries 01-data-description defines a logical record, specifying the layout of fields within the record and the size and usage of each field. See Data Description Entries. Topics: • • • File Description Entries Sort-Merge File Description Entries Data Description Entries File Description Entries The file description (FD) entry is the highest level of organization in the File Section of the Data Division.
Data Division File Description Entries In Example 7-2, two record description entries (level-01 items) follow a file description entry. Example 7-2. File Description (FD) Entry FD INPUT-FILE-MASTER GLOBAL RECORD IS VARYING IN SIZE FROM 10 TO 256 CHARACTERS 01 OFFICE-DETAILS. 03 NUMBER PIC 9(5). 03 ADDRESS. 05 LINE-1 PIC X(25). 05 LINE-2 PIC X(25). 05 LINE-3 PIC X(25). 03 HEAD-COUNT PIC 999. 03 MANAGER-ID-NUMBER 9(5). 01 EMPLOYEE-DETAILS. 03 ID-NUMBER PIC 9(5). 03 TITLE PIC X(25).
Data Division File Description Entries File Description Entry for Sequential File . file-name EXTERNAL clause GLOBAL clause BLOCK CONTAINS clause RECORD CONTAINS clause «LABEL RECORDS clause» «VALUE OF clause» «DATA RECORDS clause» LINAGE clause CODE-SET clause REPORT clause VST074.vsd file-name is the highest-level qualifier for both a file description entry and its data descriptions; therefore, the name must be unique within a program. EXTERNAL clause is described in EXTERNAL Clause.
Data Division File Description Entries RECORD CONTAINS clause is described in RECORD CONTAINS Clause. LABEL RECORDS clause is described in LABEL RECORDS Clause. VALUE OF clause is described in VALUE OF Clause. DATA RECORDS clause is described in DATA RECORDS Clause. LINAGE clause is described in LINAGE Clause. CODE-SET clause is described in CODE-SET Clause. REPORT clause is described in REPORT Clause.
Data Division File Description Entries File Description Entry for Line Sequential File Note. Available only in the OSS environment. . file-name EXTERNAL clause GLOBAL clause RECORD CONTAINS clause «LABEL RECORDS clause» «VALUE OF clause» «DATA RECORDS clause» REPORT clause VST633.vsd file-name is the highest-level qualifier for both a file description entry and its data descriptions; therefore, the name must be unique within a program. EXTERNAL clause is described in EXTERNAL Clause.
Data Division File Description Entries VALUE OF clause is described in VALUE OF Clause. DATA RECORDS clause is described in DATA RECORDS Clause. REPORT clause is described in REPORT Clause. File Description Entry for Relative, Indexed, or Queue File . file-name EXTERNAL clause GLOBAL clause BLOCK CONTAINS clause RECORD CONTAINS clause «LABEL RECORDS clause» «VALUE OF clause» «DATA RECORDS clause» VST637.
Data Division File Description Entries BLOCK CONTAINS clause is described in BLOCK CONTAINS Clause. RECORD CONTAINS clause is described in RECORD CONTAINS Clause. LABEL RECORDS clause is described in LABEL RECORDS Clause. VALUE OF clause is described in VALUE OF Clause. DATA RECORDS clause is described in DATA RECORDS Clause.
Data Division • File Description Entries EXTERNAL Clause Inherited by Data Items in External Files The EXTERNAL clause specifies that the file connector associated with the file name defined by the containing file description entry is an external file connector, and that the data items associated with all of the record descriptions for this file name are external data items; therefore, any other source program compiled into the same run unit can share these resources by including a file description entry
Data Division ° File Description Entries RECORD CONTAINS clause If any of the file description entries includes a RECORD CONTAINS clause, all of them must include a RECORD CONTAINS clause that specifies the same record attributes (fixed-length or variable-length, fixed record size or minimum and maximum record sizes, and the external data item that reflects the current logical record size, if any). ° LABEL RECORDS clause Note.
Data Division File Description Entries Usage Considerations: • Referencing Global Items A statement in a program contained directly or indirectly within a program that describes a global name can reference that name without describing it again. • Subordinates of Global Names Are Global Names A file name described using a GLOBAL clause is a global name. All data-names subordinate to a global name are global names. All condition-names associated with a global name are global names.
Data Division File Description Entries CHARACTERS specifies that the values of blk-1 and blk-2 represent numbers of character positions. This is the default. Usage Considerations: • Limits The minimum number of character positions you can specify is equal to the maximum record size of the file. If you specify more than 32,767 character positions, the compiler reports an error.
Data Division ° File Description Entries Tape Files If the actual file associated with the COBOL file at open time is a tape unit, then blocking/deblocking always occurs. For an unlabeled tape file, the maximum block size is the one specified in the BLOCK CONTAINS clause. For a labeled tape file, the maximum block size specified in the tape label (which must be an exact multiple of the logical record size) overrides the one specified in the BLOCK CONTAINS clause.
Data Division File Description Entries length-fixed is an unsigned integer literal that specifies the exact length, in characters, of fixed-length records. Its value is in the range 0 through 32,767. «contains-phrase-range» Note. The 1985 COBOL standard classifies contains-phrase-range as obsolete, so you are advised not to use it. Instead, use a VARYING phrase of the form: RECORD IS VARYING FROM length-min TO length-max length-min TO length-max CONTAINS CHARACTERS VST405.
Data Division File Description Entries VARYING phrase VARYING IS IN length-min SIZE CHARACTERS FROM TO length-max length-var DEPENDING ON VST092.vsd explicitly declares that the file consists of variable-length records (records of different sizes). length-min is as defined previously. The default is the size of the shortest record description entry. length-max is as defined previously. The default is the size of the longest record description entry.
Data Division File Description Entries Usage Considerations: • Describing Fixed-Length Records The RECORD CONTAINS length-fixed CHARACTERS form specifies that the file consists of fixed-length records. Both other forms specify that the file consists of variable-length records. If the record you write is smaller than the fixed length, the extra characters are undefined.
Data Division • File Description Entries Depending Item When length-var is specified, the data item it references is called the depending item. ° Governs the length of the record to be written The contents of this item, evaluated just before the execution of a REWRITE or WRITE statement for the file, determine the size of the record to be written.
Data Division File Description Entries LABEL RECORDS Clause Note. The 1985 COBOL Standard classifies the LABEL RECORDS clause as obsolete, so you are advised not to use it. On systems that support file labels, this clause specifies whether the file being described has labels or not. HP COBOL does not support labeling or label processing. If you want to use file labels, you must create your own and check them. LABEL RECORD STANDARD IS OMITTED RECORDS ARE VST083.
Data Division File Description Entries VALUE OF Clause Note. The 1985 COBOL Standard classifies the VALUE OF clause as obsolete. HP COBOL does not support the VALUE OF clause. If this clause is present, the compiler checks its syntax and issues a warning. VALUE OF label-value label-name OF VST084.vsd label-name is a COBOL word. label-value is either a literal or a COBOL word. DATA RECORDS Clause Note.
Data Division File Description Entries Usage Considerations: • Correspondence Each rec-name specified in the DATA RECORDS clause must correspond to some level-01 name in the list of record description entries. Order is not important. The converse is not true; level-01 entries can exist among the record description entries without their names appearing in the DATA RECORDS clause.
Data Division File Description Entries foot is either an unsigned integer literal or the data-name of an elementary unsigned numeric integer data item. Its value is the line number within the page body at which the footing area begins, so it must be greater than 0 and not greater than the value of body. The default is body +1. top is either an unsigned integer literal or the data-name of an elementary unsigned numeric integer data item.
Data Division File Description Entries Usage Considerations: • The Logical Page The size of a logical page is the sum of the top and bottom margins and the body. The logical page is not necessarily the same size as the physical page. Figure 7-1. LINAGE Clause Layout Top Margin Top Body (Includes Footing) Body Footing Bottom Bottom Margin VST708.
Data Division ° File Description Entries If the value of top is 2 or less If the value of top is 2 or less, the preceding strategy does not work, because the run-time routines cannot backspace the printer. The run-time routines assume that the printer is positioned at the first line, omit the page eject, and advance the printer by top lines.
Data Division • File Description Entries Effect of body, foot, top, and bottom The description of the first logical page is determined from top, body, foot, and bottom when the file is opened by an OPEN statement with the OUTPUT phrase. If literals are used to define all these page areas, all logical pages have the same layout.
Data Division File Description Entries CODE-SET Clause The CODE-SET clause specifies the character code convention used to represent data on the external media supporting the file. alphabet-name CODE-SET IS VST087.vsd alphabet-name is the character set used to represent data on external media. It determines the way external codes are converted to native character codes during input and output operations.
Data Division Sort-Merge File Description Entries REPORT Clause HP COBOL does not support the report-writing feature of ISO/ANSI COBOL. If the REPORT clause is present, the compiler checks it for syntactic validity and reports an error. report REPORT IS REPORTS ARE VST088.vsd report is irrelevant. Sort-Merge File Description Entries Each SORT or MERGE operation refers to a sort-merge file.
Data Division Sort-Merge File Description Entries RECORD CONTAINS clause CONTAINS phrase RECORD VARYING phrase VST090.vsd CONTAINS phrase length-fixed CONTAINS length-min TO length-max CHARACTERS VST091.vsd VARYING phrase VARYING IS IN length-min SIZE CHARACTERS FROM TO length-max length-var DEPENDING ON VST092.vsd length-min length-max length-var are integer values as in the file description entry.
Data Division Data Description Entries DATA RECORDS clause DATA RECORD data-name IS RECORDS ARE VST093.vsd data-name is the name of a record that is declared following the sort-merge file description entry. One or more fields of those records are used as keys in SORT and MERGE statements. Usage Consideration: Only the DATA RECORD and RECORD CONTAINS (or RECORD VARYING) clauses are valid. For descriptions of these clauses, see File Description Entries.
Data Division Working-Storage Section Working-Storage Section The Working-Storage Section defines records and miscellaneous data items for the process to use. You can set the initial values of most data items in working storage. When a process does not need local data items or explicit intermediate storage to execute the run unit, you can omit the Working-Storage Section. WORKING-STORAGE SECTION . 01-data-description 77-data-description 66-or-88 VST094.
Data Division • Data Description Entries A data-name for a language element whose syntax mandates uniqueness; for example, the level-01 names of external data items If data items have hierarchical relationships to one another, you must group them into records according to the rules for record descriptions. All clauses available for record descriptions in the File Section are available for record descriptions in the WorkingStorage Section. See Descriptions of Records (Levels 01-49).
Data Division Initializing Data Items Example 7-6. Record Description Entries (page 2 of 2) 01 REPORT-HEADING-1. 05 FILLER 05 REPORT-MM 05 FILLER 05 REPORT-DD 05 FILLER 05 REPORT-YY 05 REPORT-YY 05 FILLER ... PICTURE PICTURE PICTURE PICTURE PICTURE PICTURE PICTURE PICTURE X(7) 99. X 99. X 99. 99. X(7) VALUE SPACES. VALUE "/". VALUE "/". VALUE SPACES. 01 MONTH-ABBREVIATIONS VALUE "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC". 03 MON-ABBR PIC X(3) OCCURS 12 TIMES. 01 CONSTANTS-FOR-I-O. 05 ERROR-MSG-CONST .
Data Division • Size Limits Every time the program is called, if the program is an initial program (see Initial Programs). The NOCANCEL directive does not affect initial programs. Once initialized, an internal data item retains the last value assigned to it throughout the current execution of the run unit, unless an event that causes internal data items to be reinitialized occurs.
Data Division Data Description Entries and Initializing Data Items There are limits to the number of records and level-77 items that a program can contain. See Section 20, HP COBOL Limits. 66-or-88 is a level-66 or level-88 description. For syntax, see Descriptions That Rename Items (Level 66) and Descriptions of Condition-Names for Values (Level 88). The Extended-Storage Section, if present, must appear after any Working-Storage Section.
Data Division Linkage Section Linkage Section The Linkage Section describes data passed from a calling program to the program containing the Linkage Section. No local data space is used for these items because they refer to existing items in the calling program. LINKAGE SECTION . 01-data-description 77-data-description 66-or-88 VST096.
Data Division Data Description Entries and Initializing Data Items Data Description Entries and Initializing Data Items Data description entries and data initialization rules are the same in the Linkage Section as they are in the Working-Storage Section, except that you can use the VALUE clause only for level-88 items. For information on using the VALUE clause in the Linkage Section, see Descriptions of Condition-Names for Values (Level 88).
Data Division • CALL Statement and USING Phrase Extended Addressing and the CALL Statement If a formal parameter (in the called program) has EXTENDED-STORAGE access mode (the default), a CALL statement (in the calling program) can pass it any actual parameter defined in the calling program’s Data Division. • Access Mode Heritability Subordinate items inherit the access mode of their parent.
Data Division Index-Names Example 7-7. Correspondence Between Formal and Actual Parameters These lines are in the calling program: WORKING-STORAGE SECTION. 01 PARAMETER-TABLE. 02 ROW-PART OCCURS 20 TIMES. 03 COL-PART PIC 9999 COMPUTATIONAL OCCURS 10 TIMES. ... 77 ROW PIC 99 COMPUTATIONAL. 77 COL PIC 99 COMPUTATIONAL. ... PROCEDURE DIVISION. ... CALL "SUBPROG1" USING ROW, COL, PARAMETER-TABLE. ... These lines are in the called program: LINKAGE SECTION. 01 PARM-3-IN-OUT. 04 FORMAL-ROW OCCURS 20 TIMES.
Data Division Absent Linkage Section Absent Linkage Section If there is no Linkage Section in the called program, it looks like a main program to the compiler. If you compile a main program and a subprogram with no parameters in the same compilation session, you must include either a MAIN directive or an empty Linkage Section to tell the compiler which program is the main one (see Main Programs). If you do neither, the compiler reports that it found two main programs.
Data Division Descriptions of Records (Levels 01-49) Descriptions of Records (Levels 01-49) A data description entry that starts at level-01 is a record description entry. It defines the characteristics of a record, and is followed by subordinate data description entries for items that are part of the record. You can put record description entries in any section in the Data Division. .
Data Division General Considerations data-name-1 is an alphanumeric data item whose value is the name of the record you are describing. FILLER is a place holder for a record to which the program never refers. This is the default. General Considerations These considerations apply to all record descriptions: • Data Items Must be Defined You must define every data item the source program uses (except the special registers) with an appropriate data description entry in the Data Division.
Data Division • General Considerations Constraints on Clauses of the Data Description Entry Each data description entry must begin with the level number. If a data-name or the keyword FILLER is specified, it must immediately follow the level number. The characteristics of the data item determine which of the clauses are required or optional. Clauses that appear can do so in any order. No clause can appear more than once.
Data Division ° General Considerations USAGE Clause The USAGE clause cannot be used for national data items. ° SIGN Clause The SIGN clause cannot be used for national data items. ° SYNCHRONIZED Clause The SYNCHRONIZED clause cannot be used for national data items. ° BLANK WHEN ZERO Clause The BLANK WHEN ZERO clause cannot be used for national data items.
Data Division ° General Considerations Data Items in the File Section Technically, the data description entries in the File Section only establish descriptions of data items in record areas—they are not declarations in the purest sense. If the file description does not establish a record length, the longest data description entry associated with it does so.
Data Division FILLER Keyword Example 7-9. Record Description Entries as Data Declarations 01 77 MEDICATIONS. 03 BRAND-NAME PICTURE X(50). 03 SIZE-IN-MG PICTURE 9999V99. 03 CONTRA-COUNT PICTURE 99. 03 CONTRAINDICATIONS OCCURS 1 TO 25 TIMES DEPENDING ON CONTRA-COUNT PICTURE X(50). I-DEX PICTURE 9999 USAGE IS COMPUTATIONAL VALUE IS ZERO. FILLER Keyword The FILLER keyword, explicit or implicit, substitutes for a data-name when it is not important that an item have a name.
Data Division REDEFINES Clause REDEFINES Clause The REDEFINES clause enables you to describe the same computer storage area in more than one way. This can be quite valuable for tasks such as input data validation, when tests require different descriptions of the data. It is also convenient when some portions of a record are constant, while other parts vary. data-name-2 REDEFINES VST102.vsd data-name-2 is the name of the existing data item that is being redefined as data-name-1.
Data Division • REDEFINES Clause Series of Redefinitions You can describe a series of redefinition entries with the same level number as that of the redefined entry, provided that each of these entries also contains a REDEFINES clause specifying the data-name of the redefined item. You cannot, however, separate a redefinition entry from the redefined entry by any data description entry with a numerically lower level number.
Data Division • REDEFINES Clause The EXTERNAL Clause and the REDEFINES Clause The redefinition entry cannot contain the EXTERNAL clause. When the redefined item is an external record item or is described with a level number other than 01, the redefinition can specify the same or fewer character positions (bytes) than the redefined item, but cannot specify more. When the redefined item is a record (that is, has a level number of 01) without the EXTERNAL clause, there is no such constraint.
Data Division EXTERNAL Clause EXTERNAL Clause The EXTERNAL clause specifies that a record data item is external. This item and all of its subordinate data items are available to every program in the run unit that describes that record. EXTERNAL IS VST075.vsd Usage Considerations: • Working-Storage Section and Extended-Storage Section Records Only Only data description entries within the Working-Storage Section or ExtendedStorage Section whose level number is 01 can include an EXTERNAL clause.
Data Division GLOBAL Clause Within a run unit, if two or more programs describe the same external data record, then the associated data description entries (including all subordinate data-names and data items and their redefinitions) must be identical; however, a program that describes an external record can contain a data description entry including the REDEFINES clause that redefines the complete external record, and this complete redefinition need not occur identically in other programs in the run unit
Data Division • PICTURE Clause Not With SAME RECORD AREA Clause If the SAME RECORD AREA clause is specified for several files, the record description entries or the file description entries for these files must not include the GLOBAL clause. • Global Attribute is Inherited A data-name described using a GLOBAL clause is a global name. All data-names subordinate to a global name are global names. All condition-names associated with a global name are global names.
Data Division PICTURE Clause Usage Considerations: • Size of character-string The maximum number of characters in character-string is 30. To signify more than one consecutive instance of a picture character, you can write it once, followed by an unsigned integer in parentheses. The integer tells how many times that character is to occur. For example, PICTURE 99999 is equivalent to PICTURE 9(5).
Data Division PICTURE Clause Table 7-2. PICTURE Character-String Symbols (page 2 of 3) Symbol P Symbol Counts in Item’s Size No, but determines the maximum number of digit positions in numeric and numeric edited items. Description Indicates scaling when the decimal point is not within the number that appears in the data item. One or more P s can appear only as a string of contiguous characters to the left or right of all other digit positions in the character-string.
Data Division PICTURE Clause Table 7-2. PICTURE Character-String Symbols (page 3 of 3) Symbol Symbol Counts in Item’s Size Z Yes Represents a leading numeric character position whose contents are to be replaced by a space when it and all preceding numeric character positions are 0. All Zs must precede any 9 s within the character-string. 9 Yes Represents a character position for a digit. 0 Yes Represents a character position where the character zero (0 ) is to be inserted.
Data Division • PICTURE Clause Precedence Rules Figure 7-2 shows the order of precedence for the symbols in a PICTURE character-string. An x at an intersection indicates that the symbol at the top of the column can precede the symbol at the left of the row. Where two symbols appear in a column or row, they are mutually exclusive within the same character-string. The comma (,) and period (.) insertion symbols can be reversed by the DECIMALPOINT COMMA clause (see DECIMAL-POINT Clause).
Data Division PICTURE Clause Figure 7-2. Precedence Rules for PICTURE Symbols First Symbol Second Symbol NonFloating Insertion Symbols Nonfloating Insertion Symbols Other Symbols Floating Insertion Symbols Z Z * * + – + – cs cs 9 A S X V x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x B 0 / , .
Data Division PICTURE Clause A PICTURE character-string (or part of a PICTURE character-string) of the format symbol (integer) where symbol is any symbol allowed in a PICTURE character-string except P, is equivalent to a PICTURE character-string (or substring) of integer consecutive occurrences of symbol. For example, PICTURE X(4) is equivalent to PICTURE XXXX and PICTURE A(3)0A is equivalent to PICTURE AAA0A. The size of a DISPLAY item is determined by the PICTURE character-string symbols.
Data Division PICTURE Clause Because the COBOL language considers every data structure to be in the alphanumeric category, manipulations upon data structures ignore all PICTURE constraints of their constituent elementary items, including editing specifications. As an extreme (but quite legal) example, an assignment to a containing data structure can cause any character position of an elementary item to assume any character.
Data Division • PICTURE Clause Alphanumeric Edited Data Items An item is in the alphanumeric edited category when its PICTURE characterstring consists of at least one X or A and at least one B, zero (0 ), or slash (/). The contents of the data item can be any combination of characters. Example 7-15. Alphanumeric Edited Data Items 10 15 05 20 20 05 • PART-NAME BRANCH-CODE REPORT-VERSION SITE-ID SYSTEM-TAG SEAT-NUMBER PIC PIC PIC PIC PIC PIC X(5)BX(5). XX0X. XX/X. A(3)0A. AA/A. AB9.
Data Division ° ° ° ° ° ° PICTURE Clause In the PADDING clause of the SELECT statement In a RECEIVE-CONTROL paragraph In the SPECIAL-NAMES paragraph As the identifier in a CALL statement As the identifier in a CANCEL statement In comparison with a nonnational data item or nonnational literal If national data items and national literals are used for items in a STRING statement (part-1, delimiter, or result ) or an UNSTRING statement (delim-1, delim-2, result, or delimstore ), all the items must be nation
Data Division PICTURE Clause Note. Floating insertion editing and editing by zero suppression and replacement are mutually exclusive in a single PICTURE clause, and only one of the two replacement types can be used with zero suppression in a single PICTURE clause. ° Simple insertion The comma (,), space (B), zero (0 ), and slash (/) are used as the insertion characters. They are counted in the item’s size and represent where that character is inserted.
Data Division ° PICTURE Clause Fixed insertion The currency symbol and the editing sign control symbols (+, -, CR, DB) are the insertion characters. Only one currency symbol and one of the editing control symbols can be used in a PICTURE character-string. CR and DB represent two positions when counting an item’s size. When used, they must be in the rightmost positions. When a plus (+) or minus (-) is used, it must be in either the leftmost or rightmost character position to be counted in the item’s size.
Data Division ° PICTURE Clause Floating insertion The currency sign and editing sign control symbols plus (+) and minus (-) are floating insertion characters, mutually exclusive in a PICTURE character-string. At least two of any one symbol must be used. Simple insertion characters can be mixed with floating characters. To indicate floating insertion editing in a PICTURE character-string, you include a string of at least two of the floating insertion characters.
Data Division ° PICTURE Clause Source Item PICTURE Edited Result (page 2 of 2) 0 $$$$$ (all spaces) 0 $$$99 $00 1234 +++99 +1234 -23 +++99 -23 4 +++99 +04 123 ------9 123 -123 ------9 -123 1.23 $$$9.99 $1.23 -1.23 $$$9.99 $1.23 0.03 $$$9.99 $0.03 -0.03 $$$9.99 $0.03 1.23 $$$$.$$ $1.23 -1.23 $$$$.$$ $1.23 0.03 $$$$.$$ $.03 -0.03 $$$$.$$ $.03 1.23 ---9.99 1.23 -1.23 ---9.99 -1.23 0.03 ---9.99 0.03 -0.03 ---9.99 -0.03 1.23 ----.-- 1.23 -1.
Data Division PICTURE Clause For zero suppression in a PICTURE character-string, you can either represent any or all of the leading numeric character positions to the left of the decimal point by Z s or asterisks or you can represent all of the numeric positions, right or left of the decimal point, as Z s or asterisks. If the suppression symbols appear only to the left of the decimal point, any leading zero in the data that corresponds to the symbol is replaced by the replacement character.
Data Division USAGE Clause USAGE Clause The USAGE clause determines how a data item is stored in the system (its format), and usually, the number of character positions the data item uses. BINARY USAGE IS COMPUTATIONAL COMP COMPUTATIONAL-3 COMP-3 COMPUTATIONAL-5 COMP-5 DISPLAY INDEX NATIVE-2 NATIVE-4 NATIVE-8 PACKED-DECIMAL POINTER VST099.vsd BINARY COMPUTATIONAL COMP describe a two’s complement binary integer with an implied decimal point.
Data Division USAGE Clause COMPUTATIONAL-5 COMP-5 describes a two’s complement binary integer that occupies 2, 4, or 8 character positions (bytes), depending on its PICTURE clause. For more information on the PICTURE clause, see PICTURE clause. The COMPUTATIONAL-5 data type is not an element of COBOL. If your program is compiled with a FIPS directive with NONSTANDARDEXT in the flag-optionlist, the compiler issues a warning message when it finds a COMPUTATIONAL-5 data item.
Data Division USAGE Clause Table 7-5. COMPUTATIONAL-3/PACKED-DECIMAL Digit Representation Hexadecimal Digit Representation Digit Value Left* Nibble (Odd Digit) Right* Nibble (Even Digit) 0 X"00" X"00" 1 X"10" X"01" 2 X"20" X"02" 3 X"30" X"03" 4 X"40" X"04" 5 X"50" X"05" 6 X"60" X"06" 7 X"70" X"07" 8 X"80" X"08" 9 X"90" X"09" * Count even and odd from right to left. Table 7-6.
Data Division USAGE Clause A COMPUTATIONAL-3/PACKED-DECIMAL data item with PICTURE 9999 and value +1234 is stored as shown in Figure 7-3, where F represents the nonprinting plus sign. Figure 7-3. Example of COMPUTATIONAL-3/PACKED-DECIMAL Storage ... 1 2 3 4 F 0000 0001 0010 0011 0100 1111 1 byte VST601.vsd A COMPUTATIONAL-3/PACKED-DECIMAL data item with PICTURE S9999 and value +1234 is stored as shown in Figure 7-3 except that F is replaced by C (1100), which represents the plus sign (+).
Data Division • USAGE Clause BINARY or COMPUTATIONAL Data Items ° Purpose The purpose of BINARY or COMPUTATIONAL items is to improve performance and reduce the size of generated code (sometimes by a factor of as much as 100).
Data Division • USAGE Clause COMPUTATIONAL-3/PACKED-DECIMAL Data Items ° Purpose COMPUTATIONAL-3/PACKED-DECIMAL data items are provided for data compatibility with systems other than NonStop systems. They are not recommended for other purposes. ° Inefficiency Packed-decimal data format is inefficient because HP hardware does not support it. Avoid using it if possible, especially in benchmarks and performance-critical programs.
Data Division ° USAGE Clause PICTURE clause A COMPUTATIONAL-5 data item can have any PICTURE clause containing 9, P, S, and V. The PICTURE clause determines its size and the range of its values. Bracketed items are optional.
Data Division USAGE Clause DISPLAY format is required for these data items: • ° Data items subordinate to a data structure that is described with a VALUE clause or has condition-names associated with it ° ° Signed numeric data items that are affected by a data structure’s SIGN clause ° See Trapping Size Errors.
Data Division • USAGE Clause How NATIVE-n and BINARY/COMPUTATIONAL Formats Differ The significant difference between a NATIVE-n data item (which occupies n character positions by definition) and a COMPUTATIONAL data item that happens to occupy n character positions is that the COMPUTATIONAL item has the number of decimal digits declared by its PICTURE clause.
Data Division SIGN Clause For an HP COBOL pointer to accomplish what an HP C or Pascal pointer accomplishes, you must declare a base data item in the Linkage Section. You must not put the base data item in the USING phrase of the PROCEDURE DIVISION heading (that is, you must not pass the base data item as a parameter). SIGN Clause The SIGN clause specifies the position and mode of representation of the operational sign for a numeric data item.
Data Division • OCCURS Clause for Fixed-Size Tables Use of SIGN With Elementary or Data Structures The SIGN clause can appear in the description of an elementary item or a data structure. When it appears in the description of an elementary item, it specifies the sign attributes for that item. The SIGN clause never applies to a data structure, whose category is always alphanumeric.
Data Division OCCURS Clause for Fixed-Size Tables max is an integer literal that specifies the number of elements in the table. key-order ASCENDING DESCENDING KEY IS key VST105.vsd determines whether the table elements are arranged in ascending or descending order of key values. key is either the name of the entry containing the OCCURS clause or the name of an entry subordinate to the entry containing the OCCURS clause.
Data Division • OCCURS Clause for Fixed-Size Tables KEY Phrase Each key (key in the syntax diagram) must reference a data item that is subordinate to the table, except that the first key in a list can reference the table itself. No OCCURS clause can apply to a key unless it also applies to the table. As a consequence, a key cannot be or belong to a table that is subordinate to the table of which it is a key. An OCCURS statement can have a maximum of 31 keys.
Data Division • OCCURS Clause for Fixed-Size Tables Multidimensional Tables Data items subordinate to the subject of an entry described with an OCCURS clause can themselves contain an OCCURS clause; therefore, tables can consist of multiple occurrences of subordinate tables for a maximum of seven levels.
Data Division OCCURS Clause for Variable-Size Tables Example 7-17. Fixed-Size Table 01 MY-TABLE-RECORD. 02 MY-TABLE OCCURS 100 TIMES ASCENDING KEY IS FIRST-ITEM. INDEXED MY-INDEX 05 FIRST-ITEM. 08 FIRST-A PICTURE 99. 08 FIRST-B. 10 FIRST-B-1 PICTURE 99. 10 FIRST-B-2 PICTURE 99. 05 SECOND-ITEM PICTURE X(6). 01 VEHICLE. 03 MODEL OCCURS 9 TIMES. 05 STYLE OCCURS 12 TIMES. 07 COLOR OCCURS 15 TIMES PICTURE 9(10). 05 LOCATION PICTURE X(25).
Data Division OCCURS Clause for Variable-Size Tables max is an integer literal that specifies the maximum number of table elements. depend is an integer data item that controls the size of the table. As depend increases or decreases, the number of table elements increases or decreases. When the table size decreases, elements beyond the element whose ordinal position is specified by the new value of depend are lost—even if the next statement increases the table to include them.
Data Division OCCURS Clause for Variable-Size Tables At any point during execution of the object program-unit, the current value of the depending item represents the number of occurrences in the table; therefore, its value must never be less than min or greater than max during execution of a statement that references the table, any of its subordinate items, or any data structure that contains the table. You can use the CHECK compiler directive to verify that the depending item has an acceptable value.
Data Division SYNCHRONIZED Clause Example 7-18. Variable-Size Table 01 ACTIVITY-TABLE-RECORD. 03 ACTIVITY-COUNT PICTURE 99. 03 ACTIVITY-TABLE OCCURS 10 TO 20 TIMES DEPENDING ON ACTIVITY-COUNT INDEXED BY SAVE-INX-1 SAVE-INX-2. 05 ACTIVITY-ENTRY PICTURE 999. Example 7-19. Fixed-Size Table as an Element of a Variable-Size Table 01 DISPOSAL-COMPANIES. 03 H-COUNT PICTURE 99. 03 HAULER OCCURS 1 TO 12 TIMES DEPENDING ON H-COUNT. 05 VEHICLE OCCURS 15 TIMES. 07 V-NUMBER PICTURE 9(5).
Data Division JUSTIFIED Clause Usage Considerations: • LEFT and RIGHT The optional keywords LEFT and RIGHT have no effect in HP COBOL. • Where You Can Use the SYNCHRONIZED Clause You can use the SYNCHRONIZED clause only in the data description entry of an elementary item that does not have a USAGE POINTER clause. You cannot imply or specify the SYNCHRONIZED clause for national data items.
Data Division BLANK WHEN ZERO Clause Usage Considerations: • Effect of RIGHT on Compilation The optional keyword RIGHT has no effect on the compilation, and serves only to provide emphasis. • Trailing Spaces Are Not Ignored Trailing spaces in a data item are not ignored when the data item is moved to a right-justified field. For example, 77 F1 PIC X(3) JUSTIFIED RIGHT. 77 F2 PIC X(2) VALUE "A". MOVE F2 TO F1. gives F1 the value " A " not the value " A" Note.
Data Division VALUE Clause VALUE Clause This form of the VALUE clause assigns an initial value to an elementary data item or data structure described in the Working-Storage Section or Extended-Storage Section. For the form of the VALUE clause that assigns an initial value to a condition-name in any section of the Data Division, see Descriptions of Condition-Names for Values (Level 88). VALUE literal IS VST108.
Data Division ° VALUE Clause Nonnumeric data items If the data item is nonnumeric, literal must be nonnumeric or a figurative constant. The keyword ALL can appear in the figurative constant. The value of literal cannot exceed the size indicated by the data item’s PICTURE clause. Editing characters in the PICTURE clause are included when the size of the item is determined, but do not effect initialization; therefore, the value of literal must conform to the edited form.
Data Division Descriptions That Rename Items (Level 66) Descriptions That Rename Items (Level 66) The RENAMES clause assigns a new data-name to an item or to two or more contiguous items in a record. RENAMES does not cause allocation of storage. You can put level-66 items in any section of the Data Division. new-name 66 THROUGH RENAMES . old-name end-name THRU VST109.vsd new-name is the alias for an elementary item or a data structure.
Data Division • Descriptions That Rename Items (Level 66) Restrictions on Names old-name and end-name must be data areas within the same logical record and must be different. No part of the storage area referenced by end-name can occupy character positions preceding the beginning of the storage area referenced by old-name. The area referenced by end-name can overlap that referenced by old-name, but must extend beyond it; therefore, end-name cannot be subordinate to old-name.
Data Division Descriptions of Noncontiguous Elementary Items (Level 77) Descriptions of Noncontiguous Elementary Items (Level 77) In the Working-Storage or Extended-Storage Section, you do not need to use the record structure to define elementary items that bear no hierarchical relationship to one another. Instead, you can classify and define them as noncontiguous elementary items. Use a separate data description entry that begins with the special level number 77 for each of these items.
Data Division Descriptions of Noncontiguous Elementary Items (Level 77) PICTURE clause is as described in PICTURE Clause. INDEX describes an index data item—a data item that occupies four character positions and whose value is the occurrence number of a table element. This value cannot be used in computations. If a level-77 description contains INDEX, then it cannot include the SYNCHRONIZED, JUSTIFIED, or BLANK WHEN ZERO clause. SIGN clause is as described in SIGN Clause.
Data Division Descriptions of Condition-Names for Values (Level 88) Descriptions of Condition-Names for Values (Level 88) You can assign a name to a specific value, set of values, or range of values that a data item can have and use that name as a condition in a conditional statement. The name is called a condition-name, and the data item associated with it is called a conditional variable.
Data Division Descriptions of Condition-Names for Values (Level 88) Example 7-22. Condition-Names for Values (Level 88) (page 2 of 2) Statement using one of the condition-names: IF END-OF-FILE PERFORM END-UP-OPERATION CLOSE FILE-IN END-IF Definition of an item that has a range of values: 05 tax-code 88 tax-range PIC 99. VALUES ARE 00, 03, 07 THROUGH 11. Statement testing if tax-code is 00, 03, 07, 08, 09, 10, or 11: IF NOT TAX-RANGE PERFORM TAX-ERROR-ROUTINE. Example 7-23.
Data Division • Descriptions of Condition-Names for Values (Level 88) Setting a Condition-Name to TRUE You can set the value of a condition-name to TRUE with the SET TO statement. See Nonpointer Data Items.
8 Procedure Division The Procedure Division is optional, but a program without a Procedure Division does nothing except initialize data. The Procedure Division is composed of statements, which specify the actions to be taken by the program. The program does its work by executing the statements in their appropriate sequence. The way you organize the statements not only governs the order in which they execute but also can contribute to your program’s readability and maintainability.
Procedure Division Procedure Division Components and Syntax Topics: • • • • • • • • Procedure Division Components and Syntax Execution of the Procedure Division Common Semantic Rules Common Phrases Input-Output Arithmetic Operations Conditional Expressions Concatenation Expressions Procedure Division Components and Syntax PROCEDURE DIVISION USING parameter . declaratives-portion paragraph section VST113.vsd USING marks the beginning of a parameter list in a called program.
Procedure Division Procedure Division Components and Syntax section is described in Sections. Example 8-1. Procedure Division PROCEDURE DIVISION. DRIVER SECTION. DRIVE. PERFORM 100-INITIALIZATION PERFORM 200-PROCESS-REQUESTS UNTIL JOB-IS-DONE PERFORM 300-TERMINATION. 100-INITIALIZATION SECTION. OPEN-FILES. OPEN INPUT MESSAGE-IN OPEN OUTPUT MESSAGE-OUT OPEN INPUT BASE-FILE. FINISH-UP-INIT. MOVE "READY" TO WATCH-WORD. ... 200-PROCESS-REQUESTS SECTION. READ-DOLLAR-RECEIVE. READ MESSAGE-IN ...
Procedure Division Statements Statements A statement is a syntactically valid combination of words and symbols beginning with a COBOL verb. Where a statement ends depends on its context. Table 8-1.
Procedure Division Statements Topics: • • • • Imperative Statement Conditional Statement Delimited-Scope Statement Scope of Statements Imperative Statement An imperative statement specifies an unconditional action for the process to take. Each imperative statement begins with an imperative verb. Table 8-3.
Procedure Division Statements Example 8-2. Imperative Statement MOVE "Birnham Wood" TO DUNSINANE Conditional Statement A conditional statement specifies that the truth value of a condition is to be determined and that the subsequent action of the run unit depends on this truth value.
Procedure Division Statements Example 8-3. Conditional Statement IF NOT DONE-WITH-MASTER READ MASTER-FILE AT END MOVE DONE-VALUE TO MASTER-FLAG. Compare Example 8-3 to Example 8-4. Delimited-Scope Statement A delimited-scope statement is any statement that terminates in its explicit scope terminator. An explicit scope terminator is a reserved word used to delimit the scope of a conditional statement or in-line PERFORM statement. Table 8-4.
Procedure Division Statements Compiler-Directing Statement A compiler-directing statement is a COPY, REPLACE, or USE statement. It causes the compiler to take some specific action during compilation. A sentence that contains a compiler-directing statement cannot contain any other statements. Note. In some implementations of COBOL, the ENTER verb marks the beginning of an embedded routine in some other language. For this reason, ENTER is classified as a compilerdirecting verb in those implementations.
Procedure Division Statements The detailed rules for scope termination are: • A conditional statement is composed of other statements. When no delimitedscope statements occur in the conditional statement, the next phrase of the conditional statement terminates the contained statement. In this example, the ELSE phrase implicitly terminates the statement of the THEN phrase and the separator period implicitly terminates the ELSE phrase: IF CREDIT THEN PERFORM POST-CREDIT ELSE PERFORM POST-DEBIT.
Procedure Division • Sentences When a delimited-scope statement is contained within another delimited-scope statement with the same verb, each explicit scope terminator terminates the statement begun by the most recently preceding, and as yet unpaired, occurrence of that verb.
Procedure Division Paragraphs Paragraphs A paragraph groups related sentences and statements together and identifies them by one name. Using the name, GO TO, PERFORM, SORT and MERGE statements can transfer control to the paragraph. paragraph-name . sentence VST115.vsd paragraph-name is either a COBOL word consisting of up to 30 alphanumeric characters or an integer of up to 30 digits. sentence is described in Sentences.
Procedure Division Paragraphs Usage Considerations: • Paragraph Headers Not Restricted to Area A The HP COBOL compilers accept paragraph headers that do not begin in area A; the compiler recognizes a statement by its initial verb. When the compiler recognizes the end of a sentence (by detecting the terminating period) and is prepared to accept another sentence or a paragraph, it accepts any legal paragraph header or section header whether it begins in area A or after it.
Procedure Division Sections Sections A section groups related sentences and paragraphs together and identifies them by one name. Using the name, GO TO, PERFORM, SORT and MERGE statements can transfer control to the section. section-name . SECTION segment-number sentence paragraph VST116.vsd section-name is either a COBOL word consisting of up to 30 alphanumeric characters or an integer of up to 30 digits. segment-number is a numeric literal of 1 or 2 digits. sentence is described in Sentences.
Procedure Division • Procedures Standard COBOL Format To conform to the COBOL standard, observe these rules. (HP COBOL compilers do not require that you follow these rules.) ° If you use sections, put all paragraphs in sections If the Procedure Division contains sections, put every paragraph in a section. (This means that if the Procedure Division contains a Declaratives Portion, which always contains at least one section, then each paragraph in the Procedure Division must be in a section.
Procedure Division Declaratives Portion The term procedure can also refer to the set of paragraphs or sections executed under control of a PERFORM procedure-name or a PERFORM procedure-name THROUGH procedure-name statement. When the term is used in this dynamic sense, one procedure can contain or overlap another procedure.
Procedure Division Execution of the Procedure Division section is described in Sections. Example 8-8. Procedure Division with a Declaratives Portion PROCEDURE DIVISION. DECLARATIVES. IN-FILES-USE SECTION. USE AFTER STANDARD ERROR PROCEDURE ON IN-FILE. IN-FILES-PARA. ... END DECLARATIVES. BEGIN-MY-PROGRAM SECTION. ... Execution of the Procedure Division Execution of a run unit begins with the first procedure (that is, section or paragraph) of the Procedure Division, excluding any declarative sections.
Procedure Division Sentence Execution The compiler-directing statements COPY, REPLACE, and USE do not participate in execution; therefore, control is never transferred to or from these statements. Sentence Execution A sentence containing only imperative statements is always executed in its entirety. Normally, control then passes to the next sentence in the paragraph that contains an imperative or conditional statement.
Procedure Division Section Execution During the execution of a paragraph, control passes to successive sentences unless this order is modified by a conditional or delimited-scope statement or a GO TO, STOP RUN, CALL, ENTER, or EXIT PROGRAM statement. Execution of a paragraph that does not have any sentences involves only the passing of control described for Item 2.
Procedure Division Section Execution COBOL provides these types of implicit transfers of control that override the statementto-statement mechanism: 1. When a paragraph is being executed under control of another COBOL statement (for example, MERGE, PERFORM, SORT, and USE), and it is the last paragraph in the range of the controlling statement, an implied transfer of control occurs from the last statement in the paragraph to the control mechanism of the controlling statement.
Procedure Division Procedure Execution 4. A STOP RUN statement is executed within any program. In this case, execution of the run unit terminates. 5. The last statement in the Declaratives Portion of a program completes execution without causing an explicit transfer of control, and its paragraph is not the designated end of a PERFORM … THROUGH procedure group.
Procedure Division Common Semantic Rules Common Semantic Rules The semantic rules about operand identification and overlapping operands apply to several statements.
Procedure Division Overlapping Operands Overlapping Operands When a sending and a receiving data item in a statement overlap—that is, when they share part or all of their storage areas but are not defined by the same data description entry—the result of the statement is undefined. Results are also undefined for some statements in which sending and receiving data items are defined by the same data description entry. Such cases are noted in the descriptions of those statements.
Procedure Division ROUNDED Phrase In Example 8-9, assume that the records A and H obey all of the preceding rules. The statement MOVE CORRESPONDING A TO H is equivalent to this series of MOVE statements: MOVE MOVE B OF A G OF F OF A TO TO B OF H G OF F OF H Example 8-9.
Procedure Division SIZE ERROR Phrase The situations that cause the size error condition are: • Exponentiation If the program attempts to raise zero to the zero power, or if no real number exists as the result of the exponentiation, the arithmetic operation is terminated and the size error condition arises. • Division If the program attempts to divide any value by zero, the arithmetic operation is terminated and the size error condition arises.
Procedure Division SIZE ERROR Phrase Example 8-10. SIZE ERROR Phrase and TRAP2 Directive (page 2 of 2) * ON SIZE ERROR phrase catches this size error: COMPUTE C = A + B ON SIZE ERROR DISPLAY "Too Big" NOT ON SIZE ERROR DISPLAY "Acceptable". ...
Procedure Division • SIZE ERROR Phrase Values Undefined When SIZE ERROR Phrase is Absent When a size error condition occurs during execution of a statement for which the SIZE ERROR phrase is not specified, a trap 2 (arithmetic overflow) occurs unless a NOTRAP2 directive has suspended arithmetic overflow trapping. If a NOTRAP2 directive has suspended arithmetic overflow trapping, results are undefined. Note.
Procedure Division FROM Phrase FROM Phrase The FROM phrase is an optional component of the RELEASE, REWRITE, and WRITE statements, all of which specify a record-name as their primary operand. The identifier in the FROM phrase and the record-name must not reference the same storage area or overlapping storage areas. The result of executing a statement that specifies the FROM phrase is equivalent to the execution of these statements in this order: 1.
Procedure Division Input-Output Input-Output These topics are common to several input-output statements: • • • • I-O Status Code Diagnosing Input-Output Errors Recovering from Input-Output Errors Timed Input and Output I-O Status Code Each file-control entry can include a FILE STATUS clause that designates a 2character file-status data item declared elsewhere in the program as the receptacle for that file’s I-O status code. The leftmost character position of the file-status data item is Status Key 1.
Procedure Division I-O Status Code Status Key 1 The leftmost character position of the file-status data item is known as Status Key 1 and is set for these conditions. Table 8-5. Status Key 1 Values Value Condition Explanation 0 Successful completion The input-output operation was completed without error. 1 At-end condition A sequential READ statement was unsuccessfully executed as a result of one of: • • 2 Invalid-key condition The physical end of the file was reached.
Procedure Division I-O Status Code Status Key 2 The rightmost character position of the file-status data item is known as Status Key 2 and further describes the results of an input-output operation. Table 8-6. Status Key 2 Values: Successful Completion I-O Status Code File Exception Condition “00” The input-output statement executed successfully, and no further information concerning the input-output operation is available.
Procedure Division I-O Status Code Table 8-7. Status Key 2 Values: Unsuccessful Completion—At-End Condition I-O Status Code File Exception Condition “10” A sequential READ statement is attempted and no next logical record exists in the file because the logical end of the file has been reached. “14” A sequential READ statement is attempted for a relative file, but the relative record number cannot be assigned to the relative key data item described for the file without a loss of significance.
Procedure Division I-O Status Code Table 8-9. Status Key 2 Values: Unsuccessful Completion—Permanent Error Condition (page 2 of 2) I-O Status Code File Exception Condition “37” A permanent error exists because an OPEN statement is attempted on a file that is required to be a disk file but is supported on some other medium. “38” A permanent error exists because an OPEN statement is attempted on a file previously closed with lock.
Procedure Division Diagnosing Input-Output Errors Table 8-10. Status Key 2 Values: Unsuccessful Completion—Logic Error Condition (page 2 of 2) I-O Status Code File Exception Condition “48” The execution of a WRITE statement is attempted on a file not open in the I-O, Output, or Extend mode. “49” The execution of a DELETE or REWRITE statement is attempted on a file not open in the I-O mode. Table 8-11.
Procedure Division Diagnosing Input-Output Errors External Errors An external error is recoverable if the program includes an associated declarative section; otherwise, an external error causes the program to terminate abnormally. The types of recoverable input-output errors are: • • An external error that has an associated operating system input-output error causes I-O status code “30”. The run-time routine then calls the FILEERROR procedure to check whether an operation can be retried.
Procedure Division Diagnosing Input-Output Errors Table 8-12. I-O Status Codes Augmented by GUARDIAN-ERR (page 1 of 5) Status Code GUARDIAN-ERR Value COBOL Statement(s) Cause of Status Code “00” 0 All Operation was successful 6 READ sequential Read from $RECEIVE and system message was read.
Procedure Division Diagnosing Input-Output Errors Table 8-12.
Procedure Division Diagnosing Input-Output Errors Table 8-12.
Procedure Division Diagnosing Input-Output Errors Table 8-12.
Procedure Division Recovering from Input-Output Errors Table 8-12.
Procedure Division Recovering from Input-Output Errors At-End Condition or Invalid-Key Condition If the error condition is the at-end condition or the invalid-key condition, the file is not affected (that is, if the statement was an output statement, the contents of the file remain unchanged). The run-time routines then perform these actions in this order: 1.
Procedure Division Timed Input and Output When the run-time routines have recognized the exception condition, generated a runtime diagnostic message, and stored the I-O status code, they take these actions in this order: 1. If a declarative procedure of the form USE AFTER EXCEPTION is associated with the file, execute the declarative procedure. Then, if recovery from the exception is not possible (the I-O status code is “90” or Status Key 1 is “4”), terminate the process.
Procedure Division Timed Input and Output Expired Time Limit An expired time limit indicates a potential deadlock. The programmed recovery action (declarative procedure) must release any locks held by the program and restart the execution of the current request. If no declarative procedure applies to the file when the operation terminates, the program terminates abnormally.
Procedure Division Arithmetic Operations Arithmetic Operations Many different statements tell the compiler to perform arithmetic operations, either because they are arithmetic statements or because they include arithmetic expressions.
Procedure Division Common Features of Arithmetic Statements The composite of operands for a given operation is a fictitious data item. It has as many positions in its integer portion (to the left of the decimal point) as the operand that has the largest number of integer positions, and as many positions in its fraction portion (to the right of the decimal point) as the operand that has the largest number of fraction positions.
Procedure Division Arithmetic Expressions TEMP is the intermediate data item. Any subscripts specified in a reference to a receiving item are evaluated just prior to the assignment operation for that item.
Procedure Division Arithmetic Expressions Arithmetic expressions can appear in: • • • • • • ENTER statements EVALUATE statements Reference modifiers Sign conditions Relation conditions Function arguments The values computed when arithmetic expressions are evaluated are transitory and are not stored for later use by the program.
Procedure Division Arithmetic Expressions A plus (+) or minus (-) appearing as the first character of a numeric literal is the sign character of that literal, not an arithmetic operator. For example, +2 is not an arithmetic expression. In contrast, a plus (+) or minus (-) followed by a separator is interpreted as a binary operator when preceded by an operand or as a unary operator when not preceded by an operand. For example, X + 2 represents a simple arithmetic expression.
Procedure Division Arithmetic Expressions You can use arithmetic parentheses to: • Override the normal hierarchical sequence of execution in expressions whose evaluation must not follow the normal precedence, for example: A / ( B * C ) • Clarify the hierarchical sequence of execution for the benefit of the reader, for example: PRIN + ( INT * PERIOD ) It is recommended that division be the last operation performed in an expression, if possible; otherwise, execution can be slow and precision can be los
Procedure Division Arithmetic Precision Arithmetic Precision The precision of ADD, SUBTRACT, MULTIPLY, and DIVIDE statements can be fairly easily stated. The precision of arithmetic expressions is substantially more complex, because the compiler must create intermediate data items as it evaluates the expression. Arithmetic expressions occur only in the COMPUTE, ENTER, and EVALUATE statements, the relation and sign conditions, function arguments, and in reference modification.
Procedure Division Arithmetic Precision ADD and SUBTRACT Statements Each data item in an ADD or SUBTRACT statement, except the one after GIVING, is called an addend. In the statement ADD P Q R S T GIVING W the addends are P, Q, R, S, and T. In the statement ADD P Q R S T TO X Y the addends are P, Q, R, S, T, X, and Y. The number of accurate fraction digits maintained during evaluation is determined by the addend having the greatest number of fraction digits.
Procedure Division • Arithmetic Precision Effect of Decimal Point Placement Under the mathematical rules for division, fraction digits in the divisor cause the significant digit positions of the quotient to appear shifted to the left with respect to the significant digit positions of the dividend. This corresponds to moving the decimal point of the dividend to the right the same number of positions as would be necessary to make the divisor an integer: 1.00/0.3 = 10.0/03 = 03.
Procedure Division Arithmetic Precision The evaluation of an arithmetic expression is the result of the evaluation of a sequence of intermediate results. The maximum number of digits held for an intermediate result is 36. If this number is exceeded, the compiler might use binary floating-point arithmetic (and issue warning 85). The size error condition applies to both final results and intermediate results.
Procedure Division Conditional Expressions the division is performed before further evaluation of either of the preceding statements. If the division operation is not the last operation in the expression and the divisor is not 2, 4, 5, 8, or a power of 10, the division is carried out to 36 digits. As many fractional digits as possible are kept. This number can be truncated depending on subsequent operations.
Procedure Division Simple Conditions Simple Conditions A simple condition has a truth value of TRUE or FALSE. Enclosing a simple condition within parentheses does not affect its truth value.
Procedure Division • Simple Conditions Operators The relational operators specify the type of comparison to be made in the relation condition, as this table shows. NOT and the component following it are considered to be a single relational operator. For example, NOT EQUAL is a truth test for an unequal comparison. In this table, optional words are in brackets.
Procedure Division ° Simple Conditions ° When the nonnumeric operand is either an elementary data item or a nonnumeric literal, the numeric operand is handled as though it were moved to an elementary alphanumeric data item, and the value of this item were then compared to the nonnumeric operand. The size of this conceptual data item is the same as the number of digit positions in the numeric operand.
Procedure Division ° Simple Conditions An index-name and a numeric data item or numeric literal The occurrence number that corresponds to the value of the index-name is compared to the value of the data item or literal. ° An index data item and an index-name or another index data item The actual values are compared without conversion. Neither an index-name nor an index data item can be compared with any operand other than those mentioned in the preceding rules.
Procedure Division Simple Conditions relationship GREATER NOT LESS THAN EQUAL TO > < = GREATER LESS OR THAN EQUAL TO >= <= VST119.vsd Relation Conditions With Pointer Operands pointer-subject relationship pointer-object IS VST602.vsd pointer-subject pointer-object ADDRESS OF identifier-1 identifier-2 NULL NULLS VST603.vsd identifier-1 is a level-01 or level-77 data item defined in the Linkage Section or Data Division.
Procedure Division Simple Conditions identifier-2 is a data item with USAGE POINTER. NULL NULLS is a null address (all 1s) that causes an address fault if a pointer with that value is referenced. NULL or NULLS can be used for pointer-subject or pointer-object, but not both. relationship EQUAL IS NOT TO = VST604.
Procedure Division Simple Conditions Usage Considerations: • NOT Modifier When NOT appears, the compiler considers it and the next keyword to form a single class condition. For example, NOT NUMERIC is a truth test that determines if the operand is nonnumeric.
Procedure Division • Simple Conditions ALPHABETIC-LOWER and NOT ALPHABETIC-LOWER You cannot use the ALPHABETIC-LOWER and NOT ALPHABETIC-LOWER tests with a numeric data item. The tested item belongs to the alphabetic-lower class only if its content consists entirely of the lowercase alphabetic characters a through z and space.
Procedure Division Simple Conditions Usage Considerations: • Condition-Name Conditions The rules for comparing a conditional variable with the literal values corresponding to a condition-name are the same as those specified for relation conditions. The result of the test is TRUE if either of these relations is satisfied: ° The value of the conditional variable equals one of the single values corresponding to the condition-name.
Procedure Division Simple Conditions Example 8-13. External Switches SPECIAL-NAMES. SWITCH-1 IS IN-SWITCH ON OFF SWITCH-2 IS OUT-SWITCH ON OFF ... PROCEDURE DIVISION. ... IF TAPE-INPUT OPEN ELSE OPEN IF TAPE-OUTPUT OPEN ELSE OPEN ... STATUS STATUS STATUS STATUS IS IS IS IS TAPE-INPUT DISK-INPUT TAPE-OUTPUT DISK-OUTPUT. INPUT TAPE-SOURCE INPUT DISK-SOURCE. OUTPUT TAPE-SINK OUTPUT DISK-SINK.
Procedure Division • Complex Conditions Expression Cannot Be Composed Entirely of Literals The arithmetic expression must contain at least one variable operand (at least one operand that is not a literal). Example 8-14. Sign Conditions ( A - 10 ) IS POSITIVE B NOT ZERO Complex Conditions A complex condition is a combination of simple conditions and any of the logical operators NOT, AND and OR.
Procedure Division Complex Conditions condition is a simple or complex condition. The truth value of a negated condition is the opposite of the truth value of the operand condition. You do not need to use parentheses when you use either AND or OR exclusively in a combined condition. When you use a mixture of AND, OR, and NOT, you can use parentheses to effect a final truth value. Combined Conditions condition AND condition OR VST123.vsd condition is a simple or complex condition. Table 8-18.
Procedure Division Abbreviated Combined Relation Conditions These combined conditions are valid: LARRY AND MOE AND (CURLY OR SHEMP) All four are condition-names— level-number 88. I < E AND (E NOT > C) All three symbols are alphanumeric data items. NOT ((A IS POSITIVE) OR (B IS POSITIVE)) Both A and B are numeric data items. Abbreviated Combined Relation Conditions COBOL enables you to abbreviate a sequence of complex relation conditions.
Procedure Division Abbreviated Combined Relation Conditions rel-operator is a relational operator. object is an identifier, a literal, an arithmetic expression, or an index-name. This abbreviation technique is available when a group of the characteristics shown in Table 8-19 is present. Table 8-19.
Procedure Division • Condition Evaluation Rules NOT as Modifier or Operator The reserved word NOT in an abbreviated combined relation condition is interpreted as a part of the relational operator if the word immediately following NOT is GREATER, >, LESS, <, EQUAL, or =; otherwise, NOT is interpreted as a logical operator, and the implied insertion of a subject or relational operator results in a negated relation condition.
Procedure Division • Concatenation Expressions When the sequence of evaluation is not completely specified by parentheses, the order of evaluation of consecutive operations of the same hierarchical level is from left to right. Using this order of evaluation, once a truth value for an entire complex condition is established, evaluation of the condition ceases.
Procedure Division Concatenation Expressions Table 8-20. Maximum Length of Result of Concatenation Expression Class of Operands Length of Result Alphanumeric 160 alphanumeric character positions National 80 national character positions A figurative constant occupies one character position. Table 8-21.
9 Procedure Division Verbs This section describes the COBOL verbs that you can use in the Procedure Division, in alphabetic order. The descriptions of some verbs, such as ADD and INSPECT, show more than one syntax format. For descriptions of the COPY and REPLACE verbs, which you can use in any divisions, see COPY Statement and REPLACE Statement.
Procedure Division Verbs ACCEPT With Mnemonic-Name Usage Considerations: • Differences in the OSS and Guardian Environments In the OSS environment but not in the Guardian environment: ° ° • No prompt is given for an ACCEPT statement. If an ACCEPT statement includes mnemonic-name, it must be the OSS pathname of a Guardian process or terminal. If mnemonic-name is an OSS device, the compiler issues a warning and the default input device (#IN) is used instead.
Procedure Division Verbs • ACCEPT With Mnemonic-Name Whether Process Closes mnemonic-name or Leaves It Open If mnemonic-name specifies a terminal that was not the object of a DISPLAY NO ADVANCING statement, then the process closes the terminal after accepting data from it. If mnemonic-name specifies another process or a terminal that was the object of a DISPLAY NO ADVANCING statement, then the process leaves the other process or terminal open.
Procedure Division Verbs ACCEPT With Mnemonic-Name If the response is in numeric literal format, the ACCEPT statement converts it to a numeric literal in an intermediate data item and then moves the value of the intermediate data item to accept-name.
Procedure Division Verbs ACCEPT With Mnemonic-Name Figure 9-1. ACCEPT Statement Collecting Alphanumeric Data 1 2 3 4 1234567890123456789012345678901234567890 Enter heading (up to 60 characters). ?Certification of Karl Michael Weaver as a? COBOL analyst Certification of Karl Michael Weaver as a COBOL analyst Column Display Accept line 1 Accept line 2 Display VST526.vsd Example 9-3. ACCEPT Statement Reading Numeric Data ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP System.
Procedure Division Verbs ACCEPT With DATE, DAY, DAY-OF-WEEK, or TIME Phrase Figure 9-2. ACCEPT Statement Collecting Numeric Data ENTER RUN CODE ?123 CODE RECEIVED: 123.00 Low-order zeros assumed ENTER RUN CODE ?12345 CODE RECEIVED: 345.00 High digits lost, by MOVE rules ENTER RUN CODE ?1.2345 Low digits lost, by MOVE rules CODE RECEIVED: 001.23 ENTER RUN CODE Null value entered ? ** Improper numeric value. Resupply input ** ?1.23 CODE RECEIVED: 001.23 VST527.
Procedure Division Verbs ACCEPT With DATE, DAY, DAY-OF-WEEK, or TIME Phrase accept-name is the identifier of the data item to which the representation of the day, date, day of the week, or time is moved (following the rules for the MOVE statement).
Procedure Division Verbs ACCEPT With DATE, DAY, DAY-OF-WEEK, or TIME Phrase DAY-OF-WEEK delivers the value of the current day of the week expressed as an integer between 1 and 7, inclusive. The value 1 represents Monday, 2 represents Tuesday, and so on. TIME delivers the current time of day.
Procedure Division Verbs ADD ADD Form Description ADD TO Adds the sum of one or more numeric values to one or more result data items; for example, ADD A B C TO D E stores A+B+C+D in D and stores A+B+C+E in E Adds two or more numeric values and replaces the current value of one or more result data items with that sum; for example, ADD GIVING ADD A B C GIVING D E stores A+B+C in both D and E ADD CORRESPONDING Adds numeric elements of one data structure to corresponding numeric elements of another dat
Procedure Division Verbs ADD TO addend ADD TO result ROUNDED SIZE ERROR ON imperative-stmt-1 NOT SIZE ERROR ON imperative-stmt-2 END-ADD VST128.vsd addend is a numeric literal or the identifier of an elementary numeric data item. result is the identifier of an elementary numeric data item to which addend or the sum of the addends is added. ROUNDED specifies that result is to be rounded before being stored.
Procedure Division Verbs ADD TO END-ADD ends the scope of the ADD statement and makes it a delimited-scope statement. If you omit END-ADD but include the SIZE ERROR or NOT SIZE ERROR phrase, the ADD statement is a conditional statement and ends at the next period separator.
Procedure Division Verbs ADD GIVING ADD GIVING ADD GIVING adds two or more numeric values and replaces the current value of one or more result data items with that sum; for example, ADD A B C GIVING D E stores A+B+C in both D and E. addend ADD addend GIVING TO result ROUNDED SIZE ERROR ON imperative-stmt-1 NOT SIZE ERROR ON imperative-stmt-2 END-ADD VST129.vsd addend is a numeric literal or the identifier of an elementary numeric data item.
Procedure Division Verbs ADD GIVING imperative-stmt-1 is an imperative statement to be executed if a size error occurs during the addition of addends or the storing of a result. imperative-stmt-2 is an imperative statement to be executed if no size error occurs during the addition of addends or the storing of a result. END-ADD ends the scope of the ADD statement and makes it a delimited-scope statement.
Procedure Division Verbs ADD CORRESPONDING ADD CORRESPONDING ADD CORRESPONDING adds numeric elements of one data structure to corresponding numeric elements of another data structure. Caution. ADD CORRESPONDING is not recommended, because minor changes to one data structure can change the correspondence between its elements and those of the other data structure, and this is difficult to detect.
Procedure Division Verbs ADD CORRESPONDING group-2 is the identifier of a data structure in which some or all of the elementary items are numeric. The value of each elementary numeric item in group-2 that corresponds to an elementary numeric item in group-1 is replaced by the sum of the two corresponding items, as in the ADD TO statement. ROUNDED specifies that result is to be rounded before being stored.
Procedure Division Verbs ALTER Correspondence depends on the names of the elementary items, not on the physical order of the elementary items. In Example 9-5, all data item names correspond except STAPLES and PAPER. Add operations skip STAPLES and PAPER. Example 9-5. ADD CORRESPONDING Statement WORKING-STORAGE SECTION. 01 CABINET-SUPPLIES. 05 PAPER-CLIPS PIC 99. 05 WRITING-TOOLS. 10 PENCILS PIC 99. 10 PENS PIC 99. 10 ERASERS PIC 99. 10 PAPER PIC 99. 05 STAPLES PIC 99. 01 STOCKROOM-SUPPLIES.
Procedure Division Verbs ALTER destination is the name of a paragraph or section to which the GO TO statement in paragraph-name transfers control. Usage Considerations: • Maintenance Problems ALTER can cause maintenance problems because it enables a GO TO statement to transfer control anywhere in the program. When you read the source code, the only clue you have that the destination was altered is that the GO TO statement is alone in a paragraph.
Procedure Division Verbs • CALL paragraph-name in an Independent Segment If paragraph-name is in an independent segment (a section whose segmentnumber is greater than 49), these restrictions apply: • ° Every ALTER statement that references the paragraph-name must be in a section that has the same segment-number as the section containing paragraph-name.
Procedure Division Verbs CALL If the program is compiled with the PORT directive, CALL behaves like the X/Open CALL statement (which is not an element of COBOL). The X/Open CALL statement transfers control from an HP COBOL program to a program written in another language. Note. If you use the X/Open CALL statement in the OSS environment, see Mixed-Language Programs. If the called program is not a function, the X/Open CALL statement does not change the value of RETURN-CODE.
Procedure Division Verbs CALL program-name is the program-name in the called program’s PROGRAM-ID paragraph. It can be expressed as a nonnumeric literal (enclosed in quotation marks) or the actual name (not enclosed in quotation marks). The form enclosed in quotation marks is recommended. If the program is not compiled with the PORT directive, the called program must be a COBOL program.
Procedure Division Verbs CALL USING phrase USING parameter-1 REFERENCE BY CONTENT VALUE parameter-2 VST134.vsd USING marks the beginning of the parameter list. The Procedure Division header of the called program must contain a corresponding USING phrase. REFERENCE specifies that the called program uses the actual data item of the calling program. If the called program changes the value of the parameter, it changes the value of the data item in the calling program.
Procedure Division Verbs CALL parameter-1 is a data item defined in the Linkage, File, Working-Storage, or ExtendedStorage Section. It must be one of: • • • • An elementary data item A level-01 data item A level-77 data item A data item whose level is other than 01 or 77 is aligned on a 2-byte boundary If parameter-1 is subscripted, its first occurrence must be on a 2-byte boundary and the number of occurrences must be even.
Procedure Division Verbs CALL historical-on-phrase excp-imperative-statement EXCEPTION ON OVERFLOW VST135.vsd excp-imperative-statement is an imperative statement to be executed when an exception prevents calling the specified program. Note. Although you can specify excp-imperative-statement in any CALL statement, it only works when the called program is a COBOL program. For programs written in languages other than COBOL, it is ignored.
Procedure Division Verbs • CALL Effect of CALL Statement Without PORT Directive If the object form of the called program is included in the run unit that contains the calling program, or if the called program is in the user library, execution of the CALL statement transfers control from the calling program to the called program. When the called program executes an EXIT PROGRAM statement or allows control to pass beyond the end of its Procedure Division, control returns to the calling program.
Procedure Division Verbs CALL 7. The program name from Step 4 is converted back to uppercase and compilation continues. When compilation ends (at the end of the source file), if a COBOL program with the desired name has been compiled, then it is the called program. 8. If no program is found using the above steps, then the calling program looks for a VALUE phrase. If the VALUE phrase is absent, the calling program assumes that the CALL statement is a COBOL CALL statement.
Procedure Division Verbs • CALL ° Have each required program bound or linked into the run unit by referring to the program explicitly in the source program with a dummy CALL statement and then calling the program by an identifier. ° Use the SEARCH directive to add the program to the primary search list. Initial State of Called Programs A program that has the INITIAL attribute is in its initial state every time it is called.
Procedure Division Verbs • CALL Parameter Validation The ECOBOL compiler reports errors if the number of actual parameters (in the CALL statement) differs from the number of formal parameters (in the Procedure Division heading). The HP COBOL compilers do not report errors under these conditions: • ° The type (alphanumeric, numeric, and so on) of an actual parameter differs from that of its corresponding formal parameter.
Procedure Division Verbs CALL Example 9-8. Called Program That Calls Another Program (page 1 of 2) Main Program (source $DATA.MYSUBVOL.MAINSRC, object $DATA.MYSUBVOL.MAINOBJ) IDENTIFICATION DIVISION. PROGRAM-ID. COBOLMAIN. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP System. OBJECT-COMPUTER. HP System. SPECIAL-NAMES. FILE "$DATA.MYSUBVOL.SUB1OBJ" IS SUB1. DATA DIVISION. WORKING-STORAGE SECTION. 01 DATA-OUT PIC X(80) VALUE "I'M THE MAIN AND I'M ALIVE". 77 PARM1 PIC 99 VALUE 10.
Procedure Division Verbs CALL Example 9-8. Called Program That Calls Another Program (page 2 of 2) DATA DIVISION. WORKING-STORAGE SECTION. 01 DATA-OUT PIC X(80) VALUE "I'M COBSUB1 ALIVE AND WELL". LINKAGE SECTION. 01 PARM1 PIC 99. 01 PARM2 PIC XX. 01 SUBPROGRAM-TABLE. 05 SUB-TABLE-ENTRY, PIC X OCCURS 10 TIMES INDEXED BY SUB-INDEX. 01 SAVE-SUB-INDEX PIC 999. PROCEDURE DIVISION USING PARM1, PARM2, SUBPROGRAM-TABLE, SAVE-SUB-INDEX. START-PROGRAM.
Procedure Division Verbs CANCEL If you want to eliminate the SPECIAL-NAMES paragraphs from the programs in Example 9-8, compile them, in the same order, with these additional directives: In COBSUB1: In COBOLMAIN: ?SEARCH SUBOBJ2 ?SEARCH SUBOBJ1 Output from running the programs in Example 9-8 as a single run unit looks like this: I'M THE MAIN AND I'M ALIVE SAVE-TABLE-INDEX = 005 I'M SUBCOB1 ALIVE AND WELL SAVE-SUB-INDEX = 005 10 AB I'M COBSUB2 ALIVE AND WELL 10 AB I WILL NOW RETURN TO THE MAIN PGM VIA CO
Procedure Division Verbs CANCEL identifier is an alphanumeric, nonnational data item whose value (which is not known until run time) is the program-name in the PROGRAM-ID paragraph of the COBOL program to be cancelled. Usage Considerations: • Internal Data Items Resume Their Initial Values Each internal data item (except those in the Linkage Section) is reset to the value that it had the first time the program was called. (CANCEL does not affect external data items.
Procedure Division Verbs ° CHECKPOINT Within programs that are to run as process pairs If the primary process of a process pair executes a CANCEL statement, the backup process can become invalid. CHECKPOINT Note. Do not use this directive in the OSS environment. CHECKPOINT defines a restart point for the backup process of a process pair and transfers the information that the backup requires to restart. CHECKPOINT data-name-1 FILE data-name-2 file-name FILE QUEUE checkpoint-list-name VST137.
Procedure Division Verbs CHECKPOINT checkpoint-list-name is the name of a checkpoint list containing information that must be transferred to the backup process. The checkpoint list is a COBOL record with a specific structure in which the message changes are recorded.
Procedure Division Verbs • CLOSE CHECKPOINT for Process Pairs When a requester that is running as a process pair sends a message, and the backup process takes over before the requester receives a reply, the server can resend the reply automatically—if a CHECKPOINT statement executes after the server reads the requester’s message but before the server writes a reply (or generates one automatically with another READ). When this happens, the server does not see the duplicate message.
Procedure Division Verbs CLOSE for Sequential and Line Sequential Files file-name is the name of the sequential file to be closed. When more than one file-name appears, the files can have different organization and access modes and the optional phrases following one filename are independent of those following any other file-name. file-info UNIT REEL FOR NO WITH REMOVAL REWIND LOCK VST139.vsd UNIT REEL specify that the current reel is to be closed and rewound, and a new reel is to be mounted.
Procedure Division Verbs • CLOSE for Sequential and Line Sequential Files File-Status Data Item If the file being closed has an associated file-status data item, the CLOSE statement assigns it an appropriate I-O status code. The possible I-O status codes and their meanings are: I-O Status Code Meaning “00” The close operation completed successfully.
Procedure Division Verbs CLOSE for Sequential and Line Sequential Files Table 9-1. CLOSE Statements for Sequential Tape File CLOSE Statement Single Reel Multiple Reel CLOSE See note 5 See notes 1 & 5 CLOSE NO REWIND See note 2 See notes 1 & 2 CLOSE LOCK See note 3 See notes 1 & 3 CLOSE REEL See note * See notes 4 & 5 CLOSE REEL FOR REMOVAL See note * See notes 3, 4, & 5 CLOSE REEL NO REWIND See note * See notes 2 & 4 1.
Procedure Division Verbs • CLOSE for Relative, Indexed, and Queue Files COBOL and FUP Closing Procedures Are Incompatible (Multiple-Tape File) When the run-time routine closes a nonfinal reel of a multiple-tape file, it writes an end-of-file mark, a trash record, and an end-of-file mark. When the File Utility Program (FUP) closes a multiple-reel tape file, it writes only the two consecutive end-of-file marks.
Procedure Division Verbs • • COMPUTE Closing Blocked Files Process Pairs COMPUTE COMPUTE evaluates an arithmetic expression and stores the result in the specified data item or items. COMPUTE result ROUNDED = expression SIZE ERROR imp-stmt-1 ON NOT SIZE ERROR imp-stmt-2 ON END-COMPUTE VST141.vsd result is the identifier of a numeric elementary item or numeric edited elementary item where the result of the computation is to be stored.
Procedure Division Verbs COMPUTE imp-stmt-2 is an imperative statement to be executed when no size error is detected in the computation or in storing the result. END-COMPUTE ends the scope of the COMPUTE statement, causing the COMPUTE to be a delimited-scope statement. If the COMPUTE statement does not end with an ENDCOMPUTE phrase, the presence of the SIZE ERROR or the NOT SIZE ERROR phrase causes the COMPUTE statement to be a conditional statement, which ends at the next period separator.
Procedure Division Verbs CONTINUE Example 9-9. COMPUTE Statement (page 2 of 2) This COMPUTE statement specifies that the result be rounded and then stored in WSRESULT: MOVE 2 TO EXPONENT COMPUTE WS-RESULT ROUNDED = WS-99 / 10 * WS-99 ** EXPONENT + WS-FIVE-ONES END-COMPUTE (The result is 108,141.) Example 9-10.
Procedure Division Verbs COPY Usage Considerations: • Effect of CONTINUE A CONTINUE statement has no effect on the execution of the program. • Where CONTINUE Can Appear The CONTINUE statement can appear anywhere a conditional statement or an imperative statement can appear. The normal use is as an unused branch of an IF statement. COPY COPY summons source text from a file set up as a COPY library. You can use COPY in any division. For more information, see COPY Statement.
Procedure Division Verbs DELETE imperative-stmt-2 is an imperative statement to be executed (after a declarative procedure) when no exception or an exception other than the invalid-key condition arises during the delete operation. END-DELETE ends the scope of the DELETE statement and makes it a delimited-scope statement. If you omit END-DELETE but include the INVALID KEY or NOT INVALID KEY phrase, the DELETE statement is a conditional statement and ends at the next period separator.
Procedure Division Verbs DELETE In a Pathway environment under the NonStop Transaction Management Facility (TMF), the last operation on the file must have been a successful execution of a READ LOCK statement (rather than a READ statement). For information on coding servers, see the Pathway/TS SCREEN COBOL Reference Manual for your system. The record retrieved by the READ statement is deleted.
Procedure Division Verbs DISPLAY DISPLAY DISPLAY delivers a small amount of data (such as an error message) to a terminal, a printer, or another process. DISPLAY identifier literal UPON mnemonic-name NO ADVANCING WITH VST144.vsd identifier is the identifier of any data item except an index data item. literal is a literal or figurative constant name. mnemonic-name is the device on which the process displays the data.
Procedure Division Verbs DISPLAY If INVOICE-NUMBER is 00246, the output from the code in Example 9-3 looks like this: I-O ERROR 23 - NO RECORD FOR KEY = 00246 Usage Considerations: • Differences in the OSS and Guardian Environments In the OSS environment (but not in the Guardian environment), if a DISPLAY statement includes mnemonic-name, it must be either the OSS pathname of a Guardian file or the name of an OSS text file.
Procedure Division Verbs ° DIVIDE Figurative constant values A figurative constant is displayed as a single occurrence of the constant value (even if the figurative constant includes the prefix ALL). ° Multiple values When you specify more than one value in a DISPLAY statement, DISPLAY combines the values (in the order you specify them) into a single characterstring and displays the character-string. The size of the displayed item is the sum of the sizes of all the values.
Procedure Division Verbs DIVIDE INTO DIVIDE INTO DIVIDE INTO divides one data item into one or more other data items and stores the quotient(s) in the respective dividend data item(s). DIVIDE divisor INTO dividend ROUNDED SIZE ERROR imperative-stmt-1 ON SIZE NOT ERROR ON imperative-stmt-2 END-DIVIDE VST145.vsd divisor is the identifier of the elementary numeric data item or numeric literal that is the divisor.
Procedure Division Verbs DIVIDE INTO END-DIVIDE ends the scope of the DIVIDE statement and makes it a delimited-scope statement. If you omit END-DIVIDE but include the SIZE ERROR or NOT SIZE ERROR phrase, the DIVIDE statement is a conditional statement and ends at the next period separator. Usage Considerations: • Mathematics The statement DIVIDE A INTO B means store B /A in B. • Precision For information on the precision of HP COBOL division, see Arithmetic Precision.
Procedure Division Verbs DIVIDE GIVING DIVIDE GIVING DIVIDE GIVING divides one data item into another data item and stores the quotient in one or more data items. divisor DIVIDE INTO dividend BY dividend GIVING divisor quotient ROUNDED SIZE ERROR imperative-stmt-1 ON NOT SIZE ERROR ON imperative-stmt-2 END-DIVIDE VST146.vsd divisor is the identifier of the elementary numeric data item or numeric literal that is the divisor.
Procedure Division Verbs DIVIDE GIVING imperative-stmt-1 is an imperative statement for the process to execute if it detects a size error in the division or in storing the result. imperative-stmt-2 is an imperative statement for the process to execute if it does not detect a size error in the division or in storing the result. END-DIVIDE ends the scope of the DIVIDE statement and makes it a delimited-scope statement.
Procedure Division Verbs DIVIDE GIVING REMAINDER DIVIDE GIVING REMAINDER DIVIDE GIVING REMAINDER divides one data item into another data item and stores the quotient and remainder in specified data items. DIVIDE divisor INTO dividend BY dividend GIVING divisor quotient ROUNDED remainder REMAINDER SIZE ERROR imperative-stmt-1 ON SIZE NOT ERROR ON imperative-stmt-2 END-DIVIDE VST147.
Procedure Division Verbs DIVIDE GIVING REMAINDER remainder is the identifier of an elementary numeric or elementary numeric edited data item where the remainder is stored. imperative-stmt-1 is an imperative statement for the process to execute if it detects a size error in the division or in storing the result. imperative-stmt-2 is an imperative statement for the process to execute if it does not detect a size error in the division or in storing the result.
Procedure Division Verbs ENTER Example 9-14. DIVIDE INTO Statement With GIVING and REMAINDER Phrases WORKING-STORAGE SECTION. 01 ARITHMETIC-WORK-SPACE. 03 LEAP-YEAR PIC 9 VALUE ZERO. 03 DIVIDE-RESULT PIC 99 VALUE ZERO. ... 01 INVOICE-DATE. 05 INV-MONTH PIC 99. 05 INV-DAY PIC 99. 05 INV-YEAR PIC 9999. ... PROCEDURE DIVISION. ... DIVIDE 4 INTO INV-YEAR GIVING DIVIDE-RESULT REMAINDER LEAP-YEAR END-DIVIDE ... Example 9-15. DIVIDE BY Statement With GIVING and REMAINDER Phrases WORKING-STORAGE SECTION.
Procedure Division Verbs ENTER In HP COBOL, ENTER is analogous to CALL but is used to call a non-COBOL routine. An HP COBOL program’s mode and operating environment determine what types of non-COBOL routines it can call. A called routine can have an ordinary, VARIABLE, or EXTENSIBLE parameter list. ENTER routine-name language OF file-mnemonic IN USING parameter OMITTED GIVING return-value VST148.
Procedure Division Verbs ENTER file-mnemonic specifies the object file containing the called routine’s code and data blocks, enabling the eld utility to find the routine during preparation of the run unit. file-mnemonic must specify either: • • • • A linkfile An import library A DLL An archive file Establish the association between file-mnemonic and the operating system file name in the SPECIAL-NAMES paragraph of the Environment Division. The file-mnemonic phrase is not part of the routine-name.
Procedure Division Verbs ENTER OMITTED must be specified in place of any omitted parameter surrounded by other parameters (because parameters are recognized by their order). OMITTED is only permitted when the called routine has the VARIABLE or the EXTENSIBLE attribute. return-value is a numeric or numeric edited elementary data item where the return value is stored when the called routine is a function.
Procedure Division Verbs • ENTER Passing Parameters by Value When a formal parameter (in the called routine) is to be passed by value, the actual parameter (in the ENTER statement) must be a numeric literal, a numeric data item, a special register, an arithmetic expression, or the word OMITTED. If the parameter is not OMITTED, it is evaluated, scaled, and converted to the storage size and type of the formal parameter. The resulting value is passed to the called routine.
Procedure Division Verbs ° ENTER COBOL The function specifies a formal parameter whose type has no corresponding COBOL type (see Appendix B, Data Type Correspondence). Do not include the GIVING phrase in an ENTER statement that accesses an HP C or HP C++ function whose type is a pointer.
Procedure Division Verbs EVALUATE EVALUATE EVALUATE defines a multiple-branch structure, a decision table. EVALUATE executes a different group of statements when one or more data items or expressions have certain sets of values. EVALUATE subject-list WHEN object-list WHEN OTHER match-imp-stmt no-match-imp-stmt END-EVALUATE VST151.vsd subject-list subject ALSO subject VST616.vsd subject identifier literal expression TRUE FALSE VST152.
Procedure Division Verbs EVALUATE expression is an arithmetic or conditional expression. TRUE FALSE are logical values. object-list object ALSO object VST153.vsd object ANY condition TRUE FALSE range NOT VST154.vsd ANY matches any corresponding selection subject. condition is a relation condition, class condition, condition-name condition, switchstatus condition, sign condition, or complex condition. TRUE FALSE are truth values. NOT inverts the comparison.
Procedure Division Verbs EVALUATE range identifier-1 literal-1 THROUGH identifier-2 arith-exp-1 THRU literal-2 arith-exp-2 VST155.vsd identifier-1 identifier-2 are any identifiers (they can be qualified, subscripted, or referencemodified). They can be compared to any corresponding selection subjects being compared in a conditional expression. literal-1 literal-2 can be any literals. They can be compared to any corresponding selection subject being compared in a conditional expression.
Procedure Division Verbs EVALUATE END-EVALUATE ends the scope of the EVALUATE statement and makes it a delimited-scope statement. If you omit END-EVALUATE, the EVALUATE statement is a conditional statement and ends at the next period separator.
Procedure Division Verbs EVALUATE The WHEN OTHER phrase is commonly used as the mechanism for handling errors, enabling the program to detect invalid values for subjects and improper specification of objects. Example 9-20.
Procedure Division Verbs EVALUATE The object is determined: • object EVALUATE uses … identifier (without NOT or THRU) The value and class of the data item referenced by identifier literal (without NOT or THRU) The value and class of literal ZERO or ZEROS or ZEROES (without NOT or THRU) The value 0 and the class of the corresponding selection subject arithmetic expression (without NOT or THRU) The numeric value determined by the rules for evaluating arithmetic expressions condition The truth v
Procedure Division Verbs EVALUATE Figure 9-3. Comparison Phase of EVALUATE Statement Enter Current object-list is first object-list Current subject is first subject Compare current subject with corresponding objectin current object-list Current subject is next subject TRUE Another subject ? FALSE TRUE Comparison satisfied? FALSE Another TRUE object-list ? Current object-list is next object-list FALSE Exit VST532.
Procedure Division Verbs EVALUATE Figure 9-4. Execution Phase of the EVALUATE Statement Enter An object-list FALSE qualified? WHEN OTHER phrase? TRUE FALSE TRUE Execute match-imp-stmt associated with qualifying object-list Control returns to point immediately after imperative statement? Execute no-match-imp-stmt FALSE Control is wherever imperative statement transferred it TRUE Control passes to end of EVALUATE statement Exit VST533.
Procedure Division Verbs EXIT EXIT EXIT provides: • • • • A common end point for a series of procedures A marker for the logical end of a called program A way to return to the test in an in-line PERFORM statement A way to go to the end of the last statement in a paragraph or section EXIT PROGRAM PARAGRAPH SECTION PERFORM CYCLE VST156.vsd PROGRAM PARAGRAPH SECTION PERFORM CYCLE are explained in Table 9-2. Table 9-2.
Procedure Division Verbs EXIT Table 9-2. EXIT Statement Restrictions and Effects (page 2 of 2) Statement Restrictions Effect EXIT PARAGRAPH Must be contained in a paragraph. Transfers control to an implicit CONTINUE statement immediately preceding the next procedure declaration. If there is no next procedure declaration, it transfers control to an implicit CONTINUE statement at the end of the program. EXIT SECTION Must be contained in a section.
Procedure Division Verbs EXIT Example 9-21. EXIT PERFORM Statement (page 2 of 2) PERFORM UNTIL WS-NUMBER-PERF = 99 ADD 3 TO WS-NUMBER-PERF IF WS-NUMBER-PERF = 96 MOVE 1 TO WS-NUMBER-PERF EXIT PERFORM END-IF IF WS-NUMBER-PERF = 1 DISPLAY "DID NOT EXIT PERFORM SUCCESSFULLY" MOVE 99 TO WS-NUMBER-PERF END-IF END-PERFORM. IF WS-NUMBER-PERF = 1 DISPLAY "TEST EXITS-1 FOR EXIT PERFORM SUCCESSFUL." ELSE DISPLAY "TEST EXITS-1 FOR EXIT PERFORM FAILED .". 0001-TEST-EXIT-PERF-EXIT. EXIT. Example 9-22.
Procedure Division Verbs EXIT Example 9-22. EXIT PERFORM CYCLE Statement (page 2 of 2) * Y counts to 4, so that every 4th time, exit the perform * cycle without incrementing Z ... ADD 1 TO Y IF Y = 4 MOVE 0 TO Y EXIT PERFORM CYCLE END-IF * so Z is incremented only 75 times, not 100. ADD 1 TO Z END-PERFORM . DISPLAY "X: " X. DISPLAY "Y: " Y. DISPLAY "Z: " Z.
Procedure Division Verbs GO TO Example 9-23. EXIT Statement in Nested In-Line PERFORM Statement ... PERFORM REPORT-EXPLOSION THROUGH REPORT-EXPLOSION-END. ... REPORT-EXPLOSION. READ MASTER-EXP RECORD AT END GO TO REPORT-EXPLOSION-END END-READ GO TO SUB-ASSY-1 SUB-ASSY-2 ... SUB-ASSY-23 DEPENDING ON SUB-ASSY OF MASTER-EXP PERFORM REPORT-BAD-SUB-ASSEMBLY GO TO REPORT-EXPLOSION-END. SUB-ASSY-1. ... SUB-ASSY-2. ... REPORT-EXPLOSION-END. EXIT.
Procedure Division Verbs Conditional GO TO Usage Considerations: • Declarative and Nondeclarative Procedures A GO TO statement in a declarative procedure (a procedure in the Declaratives Portion of the Procedure Division) cannot refer to a nondeclarative procedure (a procedure in the other portion of the Procedure Division). A GO TO statement in a nondeclarative procedure cannot refer to a declarative procedure.
Procedure Division Verbs IF depend is the identifier of an elementary integer data item. Its value determines which procedure will receive control. If the value of depend is less than 1 or exceeds the number of procedures, control passes to the next statement.
Procedure Division Verbs Delimited-Scope Form Delimited-Scope Form IF condition statement-1 THEN END-IF ELSE statement-2 VST160.vsd condition is any conditional expression (see Conditional Expressions). statement-1 is an imperative or conditional statement to be executed if the value of condition is TRUE. It can contain other IF statements. ELSE ends statement-1. statement-2 is an imperative or conditional statement to be executed if the value of condition is FALSE.
Procedure Division Verbs • Delimited-Scope Form Nested Delimited-Scope IF Statements Delimited-scope IF statements can be “nested” (included) within other delimitedscope IF statements. Nested delimited-scope IF statements are interpreted by pairing each IF phrase with an ELSE phrase, ELSE … END-IF pair, or isolated END-IF phrase, proceeding from left to right within a sentence.
Procedure Division Verbs Delimited-Scope Form Figure 9-5.
Procedure Division Verbs Conditional Form Conditional Form IF condition THEN statement-1 NEXT SENTENCE ELSE statement-2 NEXT SENTENCE VST161.vsd condition is any conditional expression (see Conditional Expressions). statement-1 is an imperative or conditional statement to be executed if the value of condition is TRUE. It can contain other IF statements. NEXT SENTENCE specifies that control be passed directly to the end of the sentence containing the IF statement.
Procedure Division Verbs • Conditional Form IF Sentences A conditional IF statement followed by a period separator is called an “IF sentence.” An IF sentence can contain IF statements (of either form) only if such IF statements do not end with period separators. • Nested Conditional IF Statements Conditional IF statements can be “nested” (included) within other conditional IF statements.
Procedure Division Verbs Conditional Form Figure 9-6.
Procedure Division Verbs Conditional Form Example 9-25. Simple Conditional IF Statement IF JULIAN-DAYS IS GREATER THAN 59, ADD LEAP-YEAR TO JULIAN-DAYS. Example 9-26. Delimited-Scope IF Statement IF JULIAN-DAYS IS GREATER THAN 59 ADD LEAP-YEAR TO JULIAN-DAYS END-IF Example 9-27 and Example 9-28 are equivalent. Example 9-27. Simple Conditional IF ELSE Statement IF TALLY GREATER THAN 0 MOVE 0 TO TALLY MOVE 3 TO MSG-INDEX PERFORM PRINT-ERROR-ROUTINE ELSE MOVE 1 TO FLAG. Example 9-28.
Procedure Division Verbs Conditional Form Example 9-31.
Procedure Division Verbs INITIALIZE INITIALIZE INITIALIZE sets selected types of data items to predetermined values; for example, numeric data to zeros or alphanumeric data to spaces. INITIALIZE receiver REPLACING replacement VST162.vsd receiver is the identifier of an elementary item or data structure. These restrictions apply to the data item: ° ° ° ° It cannot be an index data item or a pointer data item. It cannot be a special register. Its description cannot include a RENAMES clause.
Procedure Division Verbs INITIALIZE specifies the category of elementary item in receiver to which the INITIALIZE operation is to assign a value. The default replacement is ZEROS for each NUMERIC or NUMERIC-EDITED receiver and SPACES for each ALPHABETIC, ALPHANUMERIC, or ALPHANUMERIC-EDITED receiver. The receiver is in one of these categories whether you specify replacement or not (see PICTURE Clause).
Procedure Division Verbs INITIALIZE Example 9-34. INITIALIZE Statement 01 STOCK. 03 STOCK-ITEM OCCURS 500 TIMES. 05 S-NAME PIC X(30). 05 S-WHOLESALE-PRICE PIC $$$,$$$.99. 05 S-MARKUP-PCT PIC P999. ... INITIALIZE STOCK REPLACING NUMERIC-EDITED DATA BY ZERO Usage Considerations: • Execution of the INITIALIZE Statement The INITIALIZE statement is equivalent to a series of MOVE statements, each of which has an elementary item as its receiving operand.
Procedure Division Verbs ° INSPECT If you omit replacement, the sending operand is the implied figurative constant SPACES or ZEROS, as this table shows: Category of Receiving Operand Sending Operand ALPHABETIC SPACES ALPHANUMERIC SPACES ALPHANUMERIC-EDITED SPACES NUMERIC ZEROS NUMERIC-EDITED ZEROS The value of sender is established before the implicit MOVE statement executes.
Procedure Division Verbs INSPECT TALLYING INSPECT TALLYING INSPECT TALLYING counts occurrences of a sequence of one or more characters in a source string. INSPECT source-string tallying-phrase VST164.vsd source-string is the identifier of an elementary item or data structure with USAGE DISPLAY. Inspection proceeds from left to right within source-string. tallying-phrase TALLYING tally FOR for-clause VST165.
Procedure Division Verbs INSPECT TALLYING position BEFORE AFTER delim-string INITIAL VST167.vsd marks a beginning or ending point for an INSPECT scan cycle. Each CHARACTERS phrase, ALL phrase, or LEADING phrase can have a single BEFORE phrase, a single AFTER phrase, or one BEFORE phrase and one AFTER phrase in either order. BEFORE specifies that scanning is up to but not including the character or characters matching delim-string.
Procedure Division Verbs INSPECT TALLYING Usage Considerations: • Definition of “Leading” Characters are “leading” when they begin in the leftmost position of sourcestring and have not satisfied another compare-string condition. For example, two leading As are found in “AARDVARK” when INSPECT ... FOR LEADING "A" is coded, but no leading As are found in “AARDVARK” when INSPECT ... FOR ALL "A" ... FOR LEADING "A". is coded.
Procedure Division Verbs INSPECT TALLYING 2. If no match occurs in the comparison of the first compare-string, the comparison is repeated with each successive compare-string until either a match is made or there is no next compare-string.
Procedure Division Verbs INSPECT TALLYING 3. If the AFTER phrase appears, the associated compare-string or the operand implied by CHARACTERS can participates only in comparison cycles that involve the portion of source-string following the first occurrence of delim-string. The position of the first occurrence of delim-string. is determined before the first cycle of the comparison operation begins.
Procedure Division Verbs INSPECT TALLYING In Example 9-36, an INSPECT TALLYING statement uses multiple compare-string s. Some characters look as if they qualify as matches, yet are not counted, because a character can be counted only once, no matter how many comparisons it can satisfy. Example 9-36. INSPECT TALLYING With Multiple Compare-Strings WORKING-STORAGE SECTION. 01 77 INSPECT-COUNTERS.
Procedure Division Verbs INSPECT REPLACING 9 Procedure Division Verbs INSPECT REPLACING INSPECT REPLACING replaces occurrences of a sequence of one or more characters in a data item with a specified value. INSPECT source-string replacing-phrase VST168.vsd source-string is the identifier of an elementary item or data structure with USAGE DISPLAY. Inspection proceeds from left to right within source-string. replacing-phrase REPLACING absolute-replacement matching-replacement VST169.
Procedure Division Verbs INSPECT REPLACING position BEFORE AFTER delim-string INITIAL VST167.vsd marks a starting and ending place for a replacement cycle. It follows the same item rules as replace-string. A CHARACTERS phrase, ALL phrase, LEADING phrase, or FIRST phrase can have a single BEFORE phrase, a single AFTER phrase, or one BEFORE phrase and one AFTER phrase in either order. BEFORE specifies that scanning is up to but not including the character or characters matching delim-string.
Procedure Division Verbs INSPECT REPLACING matching-replacement ALL LEADING FIRST compare-string BY replace-string position VST172.vsd defines the character-string being scanned for. ALL specifies that all occurrences of compare-string are replaced. LEADING specifies scanning for consecutive occurrences of compare-string beginning at the current position within source-string. For example, REPLACING LEADING “0” replaces only the first three zeros in “000120020.
Procedure Division Verbs INSPECT REPLACING Usage Considerations: • Rules for Replacement ° CHARACTERS causes each character in source-string to be replaced by replace-string. ° ALL causes each occurrence of compare-string in source-string to be replaced by replace-string.
Procedure Division Verbs INSPECT TALLYING REPLACING Example 9-38. One INSPECT Statement, Several Replacements WORKING-STORAGE SECTION. 77 ITEM-C PIC X(10) VALUE "009,999. ". PROCEDURE DIVISION. INSPECT ITEM-C REPLACING ALL " " BY "0", LEADING "0" BY "$", ALL "9" BY "X" AFTER INITIAL "," INSPECT TALLYING REPLACING INSPECT TALLYING REPLACING counts occurrences of a sequence of one or more characters in a data item and replaces each occurrence with a specified value.
Procedure Division Verbs INSPECT TALLYING REPLACING for-clause CHARACTERS position ALL compare-string LEADING position VST166.vsd CHARACTERS specifies that any character in source-string that has not satisfied a previous compare-string relation is counted, regardless of its value. position BEFORE AFTER delim-string INITIAL VST167.vsd marks a beginning or ending point for an INSPECT scan cycle.
Procedure Division Verbs INSPECT TALLYING REPLACING delim-string is the identifier of any type of elementary item with USAGE DISPLAY or a nonnumeric literal. It can be a figurative constant that does not include the keyword ALL, in which case it represents one character. ALL specifies that all occurrences of compare-string are tallied. LEADING specifies scanning for consecutive occurrences of compare-string beginning at the current position within source-string.
Procedure Division Verbs INSPECT TALLYING REPLACING position BEFORE AFTER delim-string INITIAL VST167.vsd marks a starting and ending place for a replacement cycle. It follows the same item rules as replace-string. A CHARACTERS phrase, ALL phrase, LEADING phrase, or FIRST phrase can have a single BEFORE phrase, a single AFTER phrase, or one BEFORE phrase and one AFTER phrase in either order. BEFORE specifies that scanning is up to but not including the character or characters matching delim-string.
Procedure Division Verbs INSPECT TALLYING REPLACING matching-replacement ALL LEADING FIRST compare-string BY replace-string position VST172.vsd defines the character-string being scanned for. ALL specifies that all occurrences of compare-string are replaced. LEADING specifies scanning for consecutive occurrences of compare-string beginning at the current position within source-string. For example, REPLACING LEADING “0” replaces only the first three zeros in “000120020.
Procedure Division Verbs INSPECT TALLYING REPLACING Usage Considerations: • Action of the INSPECT TALLYING REPLACING Statement The INSPECT TALLYING REPLACING statement is a combination of the INSPECT TALLYING and the INSPECT REPLACING statements. See Usage Considerations: and Usage Considerations:.
Procedure Division Verbs INSPECT CONVERTING INSPECT CONVERTING INSPECT CONVERTING performs a character-for-character replacement. It is easier to express such a replacement with the CONVERTING phrase than it is with a series of REPLACING ALL … BY … phrases. INSPECT source-string CONVERTING match VST175.vsd source-string is the identifier of an elementary item or data structure with USAGE DISPLAY. Inspection proceeds from left to right within source-string.
Procedure Division Verbs INSPECT CONVERTING position BEFORE AFTER delim-string INITIAL VST167.vsd marks a starting and ending place for a replacement cycle. It follows the same item rules as replace-string. A CONVERTING phrase can have a single BEFORE phrase, a single AFTER phrase, or one BEFORE phrase and one AFTER phrase in either order. BEFORE specifies that scanning is up to but not including the character or characters matching delim-string.
Procedure Division Verbs LOCKFILE Usage Considerations: • Action of the INSPECT CONVERTING Statement The compiler treats a statement of the form INSPECT source-string CONVERTING compare-string TO replace-string as if it were a statement of the form INSPECT source-string REPLACING ALL comp-char-1 BY repl-char-1 ALL comp-char-2 BY repl-char-2 ... In the INSPECT CONVERTING statement, the n th character of comparestring corresponds to the n th character of replace-string.
Procedure Division Verbs LOCKFILE wait-time is a numeric literal or the name of a numeric data item. Its value must have no more than seven digits preceding any decimal point. Any fractional portion is rounded to two decimal places. For example: 03 WAIT-TIME PIC 9(7)V9(2) COMPUTATIONAL. A nonnegative wait-time is the number of seconds within which the LOCKFILE operation must finish. If the LOCKFILE operation does not finish within that time, it terminates with no error message.
Procedure Division Verbs • LOCKFILE Declarative Procedures If a declarative procedure applies to the file and the time interval expires, the declarative procedure is performed, and program execution continues with the statement following the one terminated (see Expired Time Limit). If error message 42 or 90 is returned after the declarative procedure executes, the run unit terminates abnormally.
Procedure Division Verbs MERGE Example 9-40. LOCKFILE Statement With TIME LIMIT Phrase (page 2 of 2) PERFORM UP-DATE-MASTER UNTIL DONE MOVE 0 TO M-FLAG UNLOCKFILE IN-MASTER-FILE ... MERGE MERGE combines two or more files into another file, ordered by the same key. MERGE is performed by the FastSort utility, using files that are not open to the COBOL program. MERGE opens, reads, writes, and closes these files.
Procedure Division Verbs MERGE key is a data item to be used as a merge key. If merge-file has variable-length records, key must refer to data within the first x character positions of the record, where x is the minimum record size for merge-file. COLLATING SEQUENCE phrase SEQUENCE COLLATING alphabet-name IS VST179.vsd specifies a collating sequence for sorting.
Procedure Division Verbs MERGE output-specifier OUTPUT PROCEDURE outproc-1 IS THROUGH outproc-2 THRU GIVING merge-out VST181.vsd specifies the procedure to which the merge operation is to deliver the records of the merged files, in order. outproc-1 is the paragraph-name or section-name of the first (and maybe only) paragraph or section of the procedure to which the merge operation delivers the records of the merged files.
Procedure Division Verbs • MERGE Files Specified in the MERGE Statement You can merge to and from these types of files: ° ° ° ° Disk files Blocked tape files Multiple-reel tape files Tape files on a multiple-file reel The files specified in the MERGE statement are subject to these restrictions: • ° ° ° Every file record must contain all of the key fields. ° Files that appear in the same MERGE statement cannot appear in a SAME AREA or SAME SORT-MERGE AREA clause.
Procedure Division Verbs MERGE The PROGRAM COLLATING SEQUENCE clause affects merge operations. • Output Procedure The output procedure is outproc-1 or outproc-1 through outproc-2. The output procedure must have a RETURN statement. An output procedure can be any procedure needed to select, modify, or copy the records that the RETURN statement makes available to merge-file one at a time in merged order.
Procedure Division Verbs MERGE The MERGE statement determines the merging logic by retrieving the first record from each input file to form a set of candidate records. After selecting the proper candidate to transfer to merge-file, the merging logic retrieves the next record from that input file, if any, to replace it. This process continues until all input files are exhausted. The candidate records are first ranked in accordance with their values for the most significant key.
Procedure Division Verbs • MERGE ° If the =_SORT_DEFAULTS DEFINE exists but does not specify a scratch file, then a temporary file on the volume $SYSTEM is the scratch file. ° If no =_SORT_DEFAULTS DEFINE exists, then a temporary file on the volume $SYSTEM is the scratch file. ° For more information on the =_SORT_DEFAULTS DEFINE, see Establishing Parameters With =_SORT_DEFAULTS DEFINE.
Procedure Division Verbs MERGE Example 9-41. MERGE Statement INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT PARTS-ON-HAND ASSIGN TO "H215432.ONHAND" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL. SELECT PARTS-RECEIVED ASSIGN TO "H215432.RECD" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL. SELECT PARTS-TOGETHER ASSIGN TO "H215432.TGTHR" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL. SELECT MERGER ASSIGN TO "$HISPD.#TEMP". ... DATA DIVISION. FILE SECTION.
Procedure Division Verbs MOVE MOVE Form Description MOVE TO Copies data from a data item and stores it in one or more other data items MOVE CORRESPONDING Copies elements of one group to corresponding elements of another group MOVE TO MOVE TO copies data from a data item and stores it in one or more other data items. MOVE sender TO receiver VST182.vsd sender is the literal or the identifier of the data item from which data is copied.
Procedure Division Verbs • MOVE TO MOVE Conventions Table 9-3 summarizes the legal MOVE TO statements by category of sending and receiving data items. Data is converted and stored according to the category of the receiving data item. Table 9-3.
Procedure Division Verbs MOVE TO The COBOL standard requires that the numeric item have no decimal positions. HP allows this as an extension. If an elementary receiver is described as JUSTIFIED, see JUSTIFIED Clause. • Numeric or Numeric Edited Receiving Data Items Data is aligned by decimal point and filled with zeros as necessary. If receiver is signed, the sign of sender is moved to receiver. If sender has no sign, the new sign of receiver is positive.
Procedure Division Verbs MOVE CORRESPONDING Example 9-42. MOVE TO Statements (page 2 of 2) PROCEDURE DIVISION. BEGIN-PROCESSING.
Procedure Division Verbs MULTIPLY MOVE CORRESPONDING group-1 TO group-2 CORR VST183.vsd group-1 is the group-name of the data to be copied. group-2 is the group-name to which the data is to be copied.
Procedure Division Verbs MULTIPLY BY MULTIPLY BY MULTIPLY BY multiplies one data item by one or more other data items and stores the result(s) in the other data item(s); for example, the statement MULTIPLY A BY B C D means store A x B in B, A x C in C, and A x D in D. MULTIPLY BY multiplicand multiplier ROUNDED SIZE ERROR imperative-stmt-1 ON NOT SIZE ERROR ON imperative-stmt-2 END-MULTIPLY VST184.vsd multiplicand is a numeric literal or the identifier of an elementary numeric data item.
Procedure Division Verbs MULTIPLY BY imperative-stmt-2 is an imperative statement to be executed when no size error is detected in the multiplication or in storing the product in multiplier. END-MULTIPLY ends the scope of the MULTIPLY statement and makes it a delimited-scope statement. If you omit END-MULTIPLY but include the SIZE ERROR or NOT SIZE ERROR phrase, the MULTIPLY statement is a conditional statement and ends at the next period separator.
Procedure Division Verbs MULTIPLY BY Example 9-43 converts a length in feet to a length in inches. Example 9-43. MULTIPLY BY Statement 05 LENGTH PICTURE S9(6)V9(6). ... MULTIPLY 12 BY LENGTH Example 9-44 converts several dimensions from centimeters to inches, with rounding. Example 9-44. MULTIPLY BY Statement With ROUNDED Phrase 03 CM-TO-INCHES PICTURE S9V99 VALUE 0.39. ... 03 LENGTH 03 WIDTH 03 DEPTH ... MULTIPLY CM-TO-INCHES PICTURE S9(3)V9(2). PICTURE S9(3)V9(2). PICTURE S9(3)V9(2).
Procedure Division Verbs MULTIPLY GIVING MULTIPLY GIVING MULTIPLY GIVING multiplies two data items and stores the product in one or more other data item(s); for example, the statement MULTIPLY A BY B GIVING C D E means store A x B in C, D, and E. MULTIPLY BY multiplicand multiplier GIVING result ROUNDED SIZE ERROR imperative-stmt-1 ON NOT SIZE ERROR ON imperative-stmt-2 END-MULTIPLY VST185.vsd multiplicand is a numeric literal or the identifier of an elementary numeric data item.
Procedure Division Verbs MULTIPLY GIVING imperative-stmt-1 is an imperative statement to be executed when a size error is detected in the multiplication or in storing the product in result. imperative-stmt-2 is an imperative statement to be executed when no size error is detected in the multiplication or in storing the product in result. END-MULTIPLY ends the scope of the MULTIPLY statement and makes it a delimited-scope statement.
Procedure Division Verbs OPEN Example 9-45. MULTIPLY GIVING Statement 03 03 03 03 UNIT-PRICE PICTURE S9(5)V999 COMPUTATIONAL. ORDERED PICTURE S9(5) COMPUTATIONAL. NET-PRICE PICTURE S9(10)V999 COMPUTATIONAL. NET-PRICE-DSP PICTURE $$,$$$,$$$,$$$.99. ... MULTIPLY UNIT-PRICE BY ORDERED GIVING NET-PRICE-DSP ROUNDED NET-PRICE OPEN OPEN makes a file accessible for input, output, or both. OPEN associates a COBOL file name within the program with a file name known to the file system.
Procedure Division Verbs OPEN input-file-description for a sequential, relative, indexed, or queue file: infile TIME LIMITS WITH SHARED SYNCDEPTH PROTECTED «REVERSED» EXCLUSIVE sync NO REWIND WITH VST188.vsd for a line sequential file: infile SHARED PROTECTED EXCLUSIVE VST627.vsd infile is the file description file name of a file to open in INPUT mode, for read operations only. TIME LIMITS allows you to use the TIME LIMIT phrase in LOCKFILE, READ, and START statements that apply to infile.
Procedure Division Verbs OPEN EXCLUSIVE prevents other processes from reading or writing the file while this process is open. EXCLUSIVE is the default for all other files. sync is a numeric literal that: • • • Specifies the number of write requests that cannot be tried again whose I-O status code is to be recorded by the file system. Determines the number of write operations that the primary process of a process pair can perform on the file without doing a checkpoint to its backup process.
Procedure Division Verbs OPEN output-file-description for a sequential, relative, indexed, or queue file: outfile TIME LIMITS WITH SHARED SYNCDEPTH PROTECTED sync NO EXCLUSIVE REWIND WITH VST189.vsd for a line sequential file: outfile SHARED PROTECTED EXCLUSIVE VST628.vsd outfile is the file description file name of a file to open in OUTPUT mode, for write operations only. TIME LIMITS SHARED PROTECTED EXCLUSIVE sync NO REWIND are the same as described earlier for infile.
Procedure Division Verbs OPEN i-o-file-description for a sequential, relative, indexed, or queue file: iofile TIME LIMITS WITH SYNCDEPTH SHARED sync PROTECTED EXCLUSIVE VST190.vsd for a line sequential file: iofile SHARED PROTECTED EXCLUSIVE VST626.vsd iofile is the file description file name of a file to open in I-O mode, for both read and write operations. TIME LIMITS SHARED PROTECTED EXCLUSIVE sync are the same as described earlier for infile.
Procedure Division Verbs OPEN extend-file-description for a sequential, relative, indexed, or queue file: extfile TIME LIMITS WITH SHARED SYNCDEPTH sync PROTECTED EXCLUSIVE VST191.vsd for a line sequential file: extfile SHARED PROTECTED EXCLUSIVE VST629.vsd extfile is the file description file name of a sequential file to open in EXTEND mode, for write operations that append records to the file. The file is positioned after the last logical record when opened.
Procedure Division Verbs OPEN Usage Considerations: • Associating COBOL File Names With System File Names Before you can open a file, you must associate its COBOL file name with the name of a system file name, using one of: • ° The ASSIGN clause of the file-control entry for the COBOL file (see FILE-CONTROL Paragraph) ° The TACL command ASSIGN (see ASSIGN Command) ° A DEFINE of the class MAP, SPOOL, or TAPE (see DEFINEs) ° The COBOL_ASSIGN_ routine (see COBOL_ASSIGN_) Devices That You Can Open
Procedure Division Verbs OPEN Table 9-4. I-O Status Codes for Unsuccessful Open Operations I-O Status Code Unsuccessful Open Operation “30” One of: • • • • The file was to be opened for OUTPUT and an existing disk file with unsuitable attributes cannot be purged. The file was to be opened for OUTPUT and the data in an existing disk file cannot be purged. The file was to be opened for EXTEND and the file cannot be positioned at its end. The open operation failed due to some cause outside COBOL.
Procedure Division Verbs • OPEN Labeled Files When the LABEL RECORDS clause in the file description entry indicates that label records are present, the beginning file or reel labels are processed in accordance with the conventions for the specified open mode. If the file is opened for INPUT or EXTEND, the label records are verified. If the file is opened for OUTPUT, the label records are created. If the device assigned is not a tape, the LABEL RECORDS clause is ignored.
Procedure Division Verbs • OPEN Opening a File Multiple Times, Simultaneously An HP COBOL program can open one system file under more than one COBOL file name. This is particularly helpful when you are developing a server. You can open $RECEIVE twice—once for INPUT and once for OUTPUT—and use TACL ASSIGN commands to make one terminal (or obey file) your input simulator and another terminal your output monitor.
Procedure Division Verbs OPEN Table 9-5.
Procedure Division Verbs OPEN Although no Guardian file is open, if the file might be created later by the current or another program, you must close the file before opening it in COBOL. ° If the INPUT phrase applies, the file position indicator is set to indicate that an optional file is not present. In this case, the I-O status code is “05” and the other steps described later are omitted from the open operation.
Procedure Division Verbs OPEN Table 9-7. Open Modes for Files Assigned to Terminals Open Mode Action INPUT No carriage-control messages are sent to the file, and it cannot have a LINAGE clause in its file description entry. READ, with or without the PROMPT phrase, is the only I-O statement that can be executed on the file; however, prompts are ignored in this open mode.
Procedure Division Verbs • OPEN ° If the file code is 101 (EDIT format) because either the file already exists with that code or an ASSIGN command with a CODE phrase has been processed for the file, the file can be opened in INPUT, OUTPUT, or EXTEND modes. Opening the file for OUTPUT deletes any existing records in the file and starts the line numbers at 1, and increments by 1.
Procedure Division Verbs • OPEN Structured Disk Files Present at Run Time Certain requirements pertain to all files in this category: ° The organization declared for the file must be consistent with the actual organization of the file (that is, if the file is declared ORGANIZATION SEQUENTIAL, the file must be entry-sequenced; if it is declared ORGANIZATION RELATIVE, the file must be relative; and if it is declared ORGANIZATION INDEXED, the file must be key-sequenced).
Procedure Division Verbs OPEN Table 9-9. Open Modes for Structured Disk Files Present at Run Time (page 2 of 2) Open Mode Action OUTPUT If the record length of the physical file is shorter than the record length declared in the File Section, the file is not suitable for use: • • If no alternate record keys exist, the file is purged and a new one is created. The new file has file code 0 unless the COBOL_ASSIGN_ routine or the TACL command ASSIGN provides another file code value.
Procedure Division Verbs OPEN When the OPEN routine opens a printer-type file, it turns off automatic page ejection, computes any dynamic logical page attributes, and when appropriate, performs a page eject.
Procedure Division Verbs OPEN If some process already has a file open SHARED for any access mode except OUTPUT, another process can open the same file SHARED for any access mode. If some process already has a file open SHARED for OUTPUT, no other process can open the file (because the OPEN would delete all the records in the file). If some process already has a file open SHARED for INPUT access mode, another process can open the same file PROTECTED for any access mode.
Procedure Division Verbs PERFORM Example 9-46. OPEN Statements ?NONSTOP IDENTIFICATION DIVISION. ... INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT EMPLOYEE-MASTER ASSIGN TO "EMPMAST" ORGANIZATION IS INDEXED ACCESS MODE IS DYNAMIC. ... SELECT LISTING-FILE ASSIGN TO "LISTOUT" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL. ... PROCEDURE DIVISION. ...
Procedure Division Verbs Unconditional PERFORM procedure-group proc-1 THROUGH proc-2 THRU VST193.vsd proc-1 is a paragraph-name or section-name. Without THROUGH or THRU, proc-1 identifies the only procedure that is to be executed. With THROUGH or THRU, proc-1 identifies the first procedure of a group. THROUGH THRU indicate that a group of procedures is to be executed. proc-2 identifies the last procedure in the group. imperative-statement is defined under Imperative Statement.
Procedure Division Verbs Unconditional PERFORM ° When proc-2 does appear and is a paragraph-name, the return occurs after the execution of the last statement in that paragraph. ° When proc-2 does appear and is a section-name, the return occurs after the execution of the last statement of the last paragraph of that section. The preceding conditions for the return of control might be unsatisfied when the range includes a GO TO statement.
Procedure Division Verbs Unconditional PERFORM The descriptions of the action of the PERFORM statement in this section are expressed in terms of the out-of-line PERFORM statement. The execution of an inline PERFORM statement is exactly equivalent to that of an out-of-line PERFORM statement, with the exception that the statements contained in imperativestatement in the in-line PERFORM statement are executed in place of the statements within the range of procedure-group.
Procedure Division Verbs Unconditional PERFORM ° The sequence of statements executed in any cycle of one PERFORM statement must not allow control to reach the return point for any other active PERFORM statement in which it is nested. If this does happen, neither PERFORM cycle terminates, and control falls through to succeeding statements. ° The sequence of statements executed in any cycle of one PERFORM statement must not allow control to reach any active PERFORM statement, including itself.
Procedure Division Verbs Unconditional PERFORM Example 9-47. Unconditional PERFORM Statement With One Paragraph IF REPORT-A PERFORM DO-REPORT-A END-IF Example 9-48. Unconditional PERFORM Statement With Several Paragraphs IF REPORTS-TO-DO PERFORM DO-REPORTS THRU DO-REPORTS-EXIT. IF MUST-EXIT ... DO-REPORTS. ... (several paragraphs to create the reports) ... DO-REPORTS-EXIT. EXIT.
Procedure Division Verbs PERFORM TIMES PERFORM TIMES PERFORM TIMES executes a procedure, a group of procedures, or an imperative statement a specified number of times. PERFORM count procedure-group count TIMES TIMES imperative-statement END-PERFORM VST194.vsd procedure-group proc-1 THROUGH proc-2 THRU VST193.vsd proc-1 is a paragraph-name or section-name. Without THROUGH or THRU, proc-1 identifies the only procedure that is to be executed.
Procedure Division Verbs PERFORM TIMES END-PERFORM ends the scope of the PERFORM statement, causing the PERFORM to be a delimited-scope statement. If the PERFORM statement does not end with an ENDPERFORM phrase, it is an out-of-line PERFORM. If the PERFORM statement ends with an END-PERFORM phrase, it is an in-line PERFORM. Example 9-50 specifies that the value of the identifier TRAN-COUNT controls the number of PERFORM cycles: Example 9-50.
Procedure Division Verbs PERFORM UNTIL PERFORM UNTIL PERFORM UNTIL executes a procedure, group of procedures, or imperative statement repeatedly until a condition is true. The condition is checked before or after each PERFORM cycle, and when the condition is met, the PERFORM ends. PERFORM procedure-group test-site UNTIL condition UNTIL condition test-site END-PERFORM imperative-statement VST196.vsd procedure-group proc-1 THROUGH proc-2 THRU VST193.
Procedure Division Verbs PERFORM UNTIL test-site TEST WITH BEFORE AFTER VST197.vsd specifies whether the condition is to be tested before or after the PERFORM range is executed. The default is TEST BEFORE. condition is any conditional expression. imperative-statement is defined in Imperative Statement. END-PERFORM ends the scope of the PERFORM statement, causing the PERFORM to be a delimited-scope statement. If the PERFORM statement does not end with an END-PERFORM phrase, it is an out-of-line PERFORM.
Procedure Division Verbs PERFORM VARYING Example 9-52. PERFORM UNTIL Statement WORKING-STORAGE SECTION. 01 ANY-ADDS-CV PICTURE 9. 88 SOME-MORE-ADDS VALUE 0. 88 NO-MORE-ADDS VALUE 1. ... PROCEDURE DIVISION. ... MOVE 0 TO ANY-ADDS-CV PERFORM ADD-ROUTINE UNTIL NO-MORE-ADDS ... ADD-ROUTINE. ... PERFORM VARYING PERFORM VARYING executes a loop of procedures. PERFORM VARYING with TEST BEFORE is a “while loop;” with TEST AFTER, it is a “repeat loop.
Procedure Division Verbs PERFORM VARYING procedure-group proc-1 THROUGH proc-2 THRU VST193.vsd proc-1 is a paragraph-name or section-name. Without THROUGH or THRU, proc-1 is the only procedure that is to be executed. With THROUGH or THRU, proc-1 is the first procedure of a group. THROUGH THRU indicate that a group of procedures is to be executed. proc-2 is the last procedure in the group. test-site TEST BEFORE WITH AFTER VST197.
Procedure Division Verbs PERFORM VARYING vary-1 is a numeric data item or an index. It is the iteration variable—the variable whose value is changed each time the code in the outermost loop is executed. base-1 is a numeric literal, an index-name, or the identifier of a numeric data item. It is the initial value for vary-1. step-1 is a numeric literal or the identifier of a numeric data item.
Procedure Division Verbs PERFORM VARYING imperative-statement is defined in Imperative Statement. END-PERFORM ends the scope of the PERFORM statement, causing the PERFORM to be a delimited-scope statement. If the PERFORM statement does not end with an ENDPERFORM phrase, it is an out-of-line PERFORM. If the PERFORM statement ends with an END-PERFORM phrase, it is an in-line PERFORM.
Procedure Division Verbs PERFORM VARYING When one AFTER phrase appears, vary-1 and vary-2 are initialized with the values of base-1 and base-2, respectively, at the beginning of execution of the PERFORM statement. Then either: ° If condition-1 is TRUE, execution of the statement terminates without ever proceeding to the inner loop (without performing any cycles). ° If the initial value of condition-1 is FALSE, execution proceeds to the inner loop of the PERFORM statement logic. Figure 9-7.
Procedure Division Verbs PERFORM VARYING After each termination of the inner loop, the process evaluates condition-1 again: ° If the value of condition-1 is FALSE, execution proceeds to the inner loop, as described in the preceding text. ° If the value of condition-1 is TRUE, execution of the statement terminates. Figure 9-8. Execution of a PERFORM VARYING Statement With a TEST BEFORE Phrase and One AFTER Phrase Enter Set vary-1 to current base-1 value. Set vary-2 to current base-2 value.
Procedure Division Verbs PERFORM VARYING When multiple AFTER phrases appear, the mechanism is the same as for one AFTER phrase except: ° In secondary AFTER phrases, vary-2 is also initialized with the value of base-2 in its associated FROM phrase at the beginning of execution of the PERFORM statement. ° In the inner loop (as described earlier), the step “a cycle is performed” is replaced by “execution proceeds to the next inner loop.
Procedure Division Verbs PERFORM VARYING Figure 9-9. Execution of a PERFORM VARYING Statement With a TEST AFTER Phrase and Without an AFTER Phrase List Enter Set vary-1 to current base-1 value. Execute the range of the PERFORM. condition-1 ? TRUE Exit FALSE Augment vary-1 with step-1 . VST512.vsd When one AFTER phrase appears, vary-1 and vary-2 are initialized with the values of base-1 and base-2, respectively, at the beginning of execution of the PERFORM statement.
Procedure Division Verbs PERFORM VARYING Figure 9-10. Execution of a PERFORM VARYING Statement With a TEST AFTER Phrase and One AFTER Phrase Enter Set vary-1 to current base-1 value. Set vary-2 to current base-2 value. Execute the range of the PERFORM. TRUE condition-2 ? FALSE Augment vary-2 with step-2 . condition-1 ? TRUE Exit FALSE Augment vary-1 with step-1 . VST513.
Procedure Division Verbs PERFORM VARYING When two or more AFTER phrases appear, the mechanism is the same as for one AFTER phrase except: ° In the second AFTER phrase, vary-2 is also initialized with the value of base-2 in its associated FROM phrase at the beginning of execution of the PERFORM statement. ° In the inner loop (as described earlier), the step “a cycle is performed” is replaced by “execution proceeds to the second inner loop.
Procedure Division Verbs ° • PERFORM VARYING The associated step-1 or step-2 must be a numeric literal or an identifier that designates a numeric data item. Execution Cycles of PERFORM Statements (PERFORM Cycles) Execution of a PERFORM statement causes none, one, or more executions of its range. These executions are called PERFORM cycles. The number of PERFORM cycles depends upon the values of the operands of the PERFORM statement.
Procedure Division Verbs READ In Example 9-54, each of the two paragraphs builds a table of numbers (rows) raised to powers (columns). Each paragraph fills the 5 columns of row 1, then of row 2, and so on. Example 9-54. PERFORM VARYING Statement Used to Build a Table WORKING-STORAGE SECTION. 01 TWO-D-TABLE. 03 OCCURS 10 TIMES. 05 PWR PICTURE 9(6) OCCURS 5 TIMES. PROCEDURE DIVISION. TWO-NESTED-PERFORMS.
Procedure Division Verbs READ for Sequential or Dynamic Access READ for Sequential or Dynamic Access READ for sequential or dynamic access reads the next record in the file. (For sequential access of line sequential files, see READ for Line Sequential Files.) READ file-name NEXT REVERSED RECORD INTO data-name LOCK WITH PROMPT TIME LIMIT END prompt-item wait-time imperative-stmt-1 AT NOT END imperative-stmt-2 AT END-READ VST201.
Procedure Division Verbs READ for Sequential or Dynamic Access data-name is the identifier of the data area defined by your program to which the contents of the record area are transferred after the read operation is complete. data-name cannot be an index-name or the identifier of an index data item. The transfer is conducted as if it were a move from an alphanumeric item to an alphanumeric item. The INTO phrase is allowed only when one of: ° ° Only one record is associated with file-name.
Procedure Division Verbs READ for Sequential or Dynamic Access imperative-stmt-1 is an imperative statement to be performed when the end of the file is encountered at the beginning of the read operation. This phrase is required if no USE statement is applicable for the file. If both a USE statement and an AT END phrase are present, only the AT END phrase is used. imperative-stmt-2 is an imperative statement to be performed when the end of the file is not encountered at the beginning of the read operation.
Procedure Division Verbs READ for Sequential or Dynamic Access The file identified by file-name must be open in the INPUT or I-O mode; if it is not, the read operation is unsuccessful with I-O status code “47.” If the file is described with fixed-length records and a smaller record is read, the read operation is successful with I-O status code “04.” In addition to the specific I-O status codes described later, the general codes “00,” “30,” and “90” can occur. For more information, see I-O Status Code.
Procedure Division Verbs READ for Sequential or Dynamic Access The PROMPT phrase (often used for the WRITE/READ action common in requesters) is effective only when the device with which the file is associated is either a terminal or a process and the open mode of the file is I-O. When these conditions are met, the PROMPT phrase causes the value of prompt-item to be sent to the file before the actual read operation begins (as if a write operation preceded the read operation).
Procedure Division Verbs READ for Sequential or Dynamic Access I-O Status Code Successful Read Operation (page 2 of 2) “04” The file is not described as having variable-length records (by having the RECORD CONTAINS rec-1 TO rec-2 CHARACTERS clause or a RECORD VARYING clause in its file description), and a record was read that was shorter than the maximum size. The execution of the READ statement is successful. “97” A locked record was read successfully.
Procedure Division Verbs • READ for Sequential or Dynamic Access Retrieval When the file position indicator has a value that permits positioning for the read operation, the run-time routines use that value to identify the record to be retrieved.
Procedure Division Verbs READ for Sequential or Dynamic Access The execution of a START statement establishes a subset of the file’s records that can be retrieved by subsequent sequential or dynamic READ statements.
Procedure Division Verbs • READ for Sequential or Dynamic Access LOCK Phrase When the READ statement includes a LOCK phrase, the read operation also locks the retrieved record. The concept of record locking applies only to disk files and queued files.
Procedure Division Verbs • READ for Sequential or Dynamic Access GUARDIAN-ERR Special Register The GUARDIAN-ERR special register is updated each time a file-manipulating statement is executed. The value of GUARDIAN-ERR usually provides more specific information about the cause of an unsuccessful completion signaled by the file-status data item. For example, if the file status is “30” (permanent error), GUARDIAN-ERR contains the file system error number identifying the cause.
Procedure Division Verbs READ for Sequential or Dynamic Access or RECORD IS VARYING IN SIZE FROM rec-1 TO rec-2 CHARACTERS DEPENDING ON rec-size (although in COBOL you cannot explicitly state rec-1 as 0). The only way to determine the length of the record read is to use the DEPENDING phrase of the VARYING clause. The contents of the record area beyond the data fetched by any given read is undefined. Other HP products are capable of writing records of length 0 in such files.
Procedure Division Verbs READ for Sequential or Dynamic Access The effect of declaratives on time-limit termination is: ° If there is no declarative procedure applicable to the file when the operation is abandoned, the process terminates, and an ABEND message is reported to the process’s home terminal. ° If the applicable declarative procedure is present (but no AT END phrase is present) and the time interval expires, the declarative procedure is performed.
Procedure Division Verbs • READ for Sequential or Dynamic Access Sequential Block Buffering and HP COBOL Fast I-O Sequential block buffering, enabled by the RESERVE clause of the FILECONTROL Paragraph, is an Enscribe feature that speeds the reading of a sequential, relative, indexed, or queue file by reading a block of records together into a memory buffer. HP COBOL Fast I-O is a variant of sequential block buffering that is even faster, because the run-time routines handle the record deblocking.
Procedure Division Verbs READ for Sequential or Dynamic Access Example 9-56. Reading a Dynamic Indexed File IDENTIFICATION DIVISION. ... ENVIRONMENT DIVISION. ... SELECT MASTER-IN ASSIGN TO "$WOOSTR.BERTIE.MASTER" ORGANIZATION IS INDEXED ACCESS MODE IS DYNAMIC RECORD KEY IS CUSTOMER-NUMBER FILE STATUS IS MASTER-IN-FILE-STATUS. ... DATA DIVISION. FILE SECTION. FD MASTER-IN LABEL RECORDS ARE OMITTED. 01 MASTER-IN-RECORD. ... WORKING-STORAGE SECTION. ... 01 FILE-STATUSES. 03 MASTER-IN-FILE-STATUS PICTURE XX.
Procedure Division Verbs READ for Sequential or Dynamic Access Example 9-57. Reading $RECEIVE With Timed Input-Output (page 2 of 2) DATA DIVISION. FILE SECTION. FD REQUEST LABEL RECORDS ARE OMITTED. 01 REQUEST-RECORD. ... WORKING-STORAGE SECTION. ... 01 FILE-STATUSES. 03 REQUEST-FILE-STATUS PICTURE XX. ... 01 WAIT-TIME PICTURE PICTURE 9(5)V99 VALUE 30. PROCEDURE DIVISION. DECLARATIVES. DECL SECTION. USE AFTER ERROR PROCEDURE ON REQUEST. DECL-ROUTINE. IF GUARDIAN-ERR NOT = 40 STOP RUN. END DECLARATIVES.
Procedure Division Verbs READ for Line Sequential Files READ for Line Sequential Files READ for line sequential files reads the next record in the file. READ file-name INTO data-name END imperative-stmt-1 AT NOT END imperative-stmt-2 AT END-READ VST630.vsd file-name is the file description name of the file to retrieve a record from. NEXT indicates that the next record is to be read (that is, the record after the current record, according to the key of reference).
Procedure Division Verbs READ for Line Sequential Files LOCK keeps other programs from accessing the record retrieved until an UNLOCKFILE statement, UNLOCKRECORD statement, or REWRITE UNLOCK statement executes. The file that file-name specifies must be associated with a disk device. imperative-stmt-1 is an imperative statement to be performed when the end of the file is encountered at the beginning of the read operation. This phrase is required if no USE statement is applicable for the file.
Procedure Division Verbs READ for Random or Dynamic Access READ for Random or Dynamic Access READ is for random or dynamic access reads a record from a file according to the value of a key, rather than according to the present value of the file position indicator. For relative files, READ without NEXT sets the file position indicator to the item selected by RELATIVE KEY (if KEY is omitted) or to the specified alternate key.
Procedure Division Verbs READ READ for Random or Dynamic Access file-name RECORD INTO data-name LOCK WITH TIME LIMIT wait-time KEY key IS INVALID imperative-stmt-1 KEY NOT INVALID KEY imperative-stmt-2 END-READ VST202.vsd file-name is the file description name of the file to retrieve a record from. data-name is the identifier of the data area defined by your program to which the contents of the record area are transferred after the read operation is complete.
Procedure Division Verbs READ for Random or Dynamic Access LOCK keeps other programs from using the record retrieved until an UNLOCKFILE statement, UNLOCKRECORD statement, or UNLOCK phrase is executed on the record. wait-time is the time interval, in seconds, in which the operation must complete. wait-time can be a literal or the name of a data item. In either case, it must have a value described with at most seven digits preceding any decimal point position.
Procedure Division Verbs READ for Random or Dynamic Access Usage Considerations: • Action of the READ Statement (Read According to Key Value) The execution of this form of the READ statement proceeds: ° For a file with indexed organization, or a file being accessed according to an alternate key, the run-time routines set the file position indicator to the first record in the file with a key data item value that matches the value in the key of reference.
Procedure Division Verbs READ for Random or Dynamic Access For other possible I-O status codes representing successful and unsuccessful operations, see File-Status Data Item. Note.
Procedure Division Verbs • RELEASE See these usage considerations in READ for Sequential or Dynamic Access: ° ° ° ° ° ° ° File-Status Data Item LOCK Phrase Interaction of LOCKFILE and READ LOCK Statements INTO Phrase GUARDIAN-ERR Special Register Variable-Length Records Use of wait-time Example 9-58. Reading a Random Indexed File SELECT MASTER-IN ASSIGN TO "MASTER" ORGANIZATION IS INDEXED ACCESS MODE IS DYNAMIC RECORD KEY IS INVOICE-NUMBER. ... PROCEDURE DIVISION. ...
Procedure Division Verbs REPLACE REPLACE REPLACE substitutes zero or more words of pseudotext for one or more words of pseudotext. You can use REPLACE in any division. For more information, see REPLACE Statement. RETURN RETURN, which must be within a SORT or MERGE output procedure, gets the next output record from the SORT or MERGE. RETURN file-name INTO END data-name imperative-stmt-1 AT NOT END imperative-stmt-2 AT END-RETURN VST204.
Procedure Division Verbs REWRITE END-RETURN ends the scope of the RETURN statement, causing the RETURN to be a delimitedscope statement. If the RETURN statement does not end with an END-RETURN phrase, the presence of the AT END or the NOT AT END phrase causes the RETURN statement to be a conditional statement, which ends at the next period separator. For more details and an example, see: • • SORT MERGE REWRITE REWRITE replaces an existing record in a disk file that is open for I-O.
Procedure Division Verbs REWRITE for Sequential, Relative, Indexed, and Queue Files record-name is the record-name in a file description entry whose current contents replaces a record in the file. The file must be open in I-O mode. data-name is the identifier of the item that contains the new record instead of record-name. When this phrase is used, an implicit MOVE statement occurs to copy the data to record-name before the rewrite operation occurs.
Procedure Division Verbs REWRITE for Sequential, Relative, Indexed, and Queue Files ° When the file has variable-length records whose sizes are controlled by the DEPENDING item specified in the RECORD clause (RECORD VARYING SIZE DEPENDING name), the value of the DEPENDING item determines the size of the logical record.
Procedure Division Verbs REWRITE for Sequential, Relative, Indexed, and Queue Files The rewrite operation cannot succeed if the device associated with the file is not a disk device. Note.
Procedure Division Verbs REWRITE for Sequential, Relative, Indexed, and Queue Files I-O Status Code Unsuccessful Rewrite (page 2 of 2) “44” There are two possibilities: • • “49” • The file is described with the RECORD VARYING clause, and the logical record size is greater than the maximum or less than the minimum number of character positions specified in that clause. The logical record is not released.
Procedure Division Verbs • REWRITE for Sequential, Relative, Indexed, and Queue Files Invalid-Key Condition Any of these circumstances can lead to an invalid-key condition: ° The access mode is sequential, the file organization is indexed, and the prime record key value of the logical record is not equal to the value of the prime record key of the last record read. This results in a completion status of 21.
Procedure Division Verbs REWRITE for Line Sequential Files REWRITE for Line Sequential Files REWRITE FROM record-name data-name END-REWRITE VST721.vsd record-name is the record-name in a file description entry whose current contents replaces a record in the file. The file must be open in I-O mode. data-name is the identifier of the item that contains the new record instead of record-name.
Procedure Division Verbs SEARCH 9 Procedure Division Verbs SEARCH SEARCH scans a table for an element that satisfies a condition. If SEARCH finds the element, SEARCH sets an index-name to the element’s offset value. Form Description SEARCH VARYING Performs a serial search beginning with the current index. Can also set the value of a data item or another index-name. SEARCH ALL Performs a binary search until it finds the element satisfying the conditions or has searched every element of the table.
Procedure Division Verbs SEARCH VARYING table is the name of a data item described with an “OCCURS … INDEXED BY index-1 … KEY …” clause. The search is done with index-1, which the search operation initializes to the middle of the table before beginning to scan. Only the name of table can appear, qualified if necessary, but not subscripted or reference modified.
Procedure Division Verbs SEARCH VARYING Usage Considerations: • CONTINUE is Recommended Over NEXT SENTENCE NEXT SENTENCE transfers control to the next period (.), while CONTINUE transfers control to END-SEARCH. Either imperative-stmt-1, imperativestmt-2, or both can be CONTINUE statements. • Execution The SEARCH VARYING statement specifies a serial search through elements of the table referenced by table.
Procedure Division Verbs SEARCH VARYING 2. When a condition evaluates to TRUE, the search operation terminates immediately. If that condition is followed by the NEXT SENTENCE phrase, control passes to the next executable sentence; otherwise, the associated imperative-stmt-2 is executed and control passes to the end of the SEARCH statement (unless the imperative-stmt-2 explicitly transfers control elsewhere using a GO TO statement). 3.
Procedure Division Verbs SEARCH VARYING Figure 9-11. Execution of a SEARCH VARYING Statement With WHEN Phrases Enter TRUE Index is indexer FALSE TRUE AT END? indexer from INDEXED BY? FALSE Index is index-1 from INDEXED BY Index >max ? Increment index FALSE TRUE Execute imperative-stmt-1 Another WHEN? TRUE FALSE Index is indexer ? FALSE Increment indexer TRUE FALSE condition ? TRUE FALSE NEXT Execute SENTENCE imperative-stmt-2 ? TRUE Execute next sentence Exit VST514.
Procedure Division Verbs SEARCH ALL Example 9-60. SEARCH VARYING Statement WORKING-STORAGE SECTION. 01 COMMANDS. 05 FILLER PIC X(6) VALUE "ADD". 05 FILLER PIC X(6) VALUE "DELETE". ... 01 COMMANDS-IN-TABLE REDEFINES COMMANDS. 05 COMMAND-ENTRIES PIC X(6) OCCURS 6 TIMES INDEXED BY TABLE-INDEX. 77 COMMAND-IN PIC X(6). ... PROCEDURE DIVISION. ...
Procedure Division Verbs SEARCH ALL table is the name of a data item described with an “OCCURS … INDEXED BY index-1 … KEY …” clause. The search is done with index-1, which the search operation initializes to the middle of the table before beginning to scan. Only the name of table can appear, qualified if necessary, but not subscripted or reference modified.
Procedure Division Verbs SEARCH ALL arithmetic expression-2 is any arithmetic expression. condition-name-1 is a condition (a level-88 item) that terminates the search operation. condition-name-1 must be defined as having a single value. The dataname with which condition-name-1 is associated must be specified as the first in the KEY phrase of the OCCURS clause of table. imperative-stmt-2 is an imperative statement to be executed when the condition that conditionname-1 specifies is satisfied.
Procedure Division Verbs ° SEARCH ALL When a data-name in the KEY phrase of the OCCURS clause associated with table is referenced, or when a condition-name associated with such a dataname is referenced, all preceding data-names (or the associated conditionnames) in the KEY phrase of that OCCURS clause must also be referenced. When a SEARCH ALL statement does not meet these conditions, the compiler issues a warning and does a linear search.
Procedure Division Verbs SEARCH ALL The SEARCH ALL operation proceeds in a binary fashion, successively setting the index-name to correspond to different table elements and evaluating the target condition. For each operand of the target condition, the process of operand identification occurs just before its use each time the operand participates in the determination of the value of the target condition.
Procedure Division Verbs SET Example 9-61. SEARCH ALL Statement (page 2 of 2) 01 COMMANDS-IN-TABLE REDEFINES COMMANDS. 05 COMMAND-ENTRIES PIC X(6) OCCURS 6 TIMES ASCENDING KEY IS COMMAND-ENTRIES INDEXED BY TABLE-INDEX. ... 01 COMMAND-NUMBERS. 05 COMMAND-INDEX 05 COMMAND-IN ... PIC 99 COMP VALUE 1. PIC X(6). PROCEDURE DIVISION. ...
Procedure Division Verbs SET TO pointer ADDRESS OF identifier-1 identifier-2 VST606.vsd address ADDRESS OF identifier-3 identifier-4 NULL NULLS VST607.vsd identifier-1 is a level-01 or level-77 data item in the Linkage Section that does not have an ACCESS MODE STANDARD clause in its data description entry. If pointer is ADDRESS OF identifier-1, identifier-1 is relinked so that subsequent references to identifier-1 reference the item whose address is specified by address.
Procedure Division Verbs SET TO NULL NULLS is a null address guaranteed not to point to any data item. A reference to a pointer whose value is NULL causes a trap 1 instruction failure. If you redefine a VS COBOL II pointer variable as a COMPUTATIONAL field and perform an arithmetic operation on the field to change the value of the pointer, the pointer does not behave the same as it would in IBM/370 COBOL.
Procedure Division Verbs SET TO identifier-1 is the name of an integer elementary item or an index data item to be set. identifier-2 is the name of an integer data item or an index data item. index-name-1 is the name of an index to be set. index-name-2 is the name of an index. integer is a numeric literal having no fractional part. If signed, it must have a positive value. mnemonic-name is the mnemonic name associated with an external switch in the SPECIAL-NAMES paragraph of the Environment Division.
Procedure Division Verbs SET TO Table 9-10 summarizes these rules: ° The receiving item (index-name-n ) is set to a value causing it to refer to the table element corresponding in occurrence number to the table element specified by the sending item (identifier-1, index-name-1, or integer ). If the sending item is an index data item, or if it is an index-name that is related to the same table as the receiving item, no conversion occurs.
Procedure Division Verbs • SET UP or SET DOWN External Switches The SET statement modifies the status of the external switch associated with each specified mnemonic-name. When the SET statement changes the status of a switch to ON, any condition-name associated (in the SPECIAL-NAMES paragraph) with the ON setting of that switch evaluates to TRUE.
Procedure Division Verbs SET UP or SET DOWN POINTER Data Items SET UP increments a pointer by an integral number of memory locations. SET DOWN decrements a pointer by an integral number of memory locations. SET UP pointer BY number-of-locations DOWN VST608.vsd pointer is a data item with USAGE POINTER. In these parameter descriptions, assume that the value of pointer is the address p. number-of-locations identifier-1 integer VST609.
Procedure Division Verbs SET UP or SET DOWN Nonpointer Data Items SET UP increments an index value by an integer amount. SET DOWN decrements an index value by an integer amount. SET index-name UP DOWN BY identifier integer VST212.vsd index-name is the name of an index whose value is to be incremented or decremented. identifier is the identifier of an integer numeric item whose value UP adds to the index or DOWN subtracts from the index.
Procedure Division Verbs SORT SORT SORT orders a set of records according to one or more keys. The records can either be in a file or an input procedure can send them to SORT, one at a time. SORT can either write the sorted records to a file or it can send them to an output procedure, one at a time. SORT calls the FastSort utility. SORT sd-name key-specifier DUPLICATES phrase COLLATING SEQUENCE phrase input-specifier-1 output-specifier-1 input-specifier-2 output-specifier-2 VST213.
Procedure Division Verbs SORT DUPLICATES phrase DUPLICATES WITH IN ORDER VST215.vsd specifies that, if two or more records contain equal values for all sort keys, their final order within the sort file is the order in which they were released to the sort file. If this phrase is omitted, the order of such duplicate records is arbitrary. COLLATING SEQUENCE phrase SEQUENCE COLLATING alphabet-name IS VST216.vsd specifies a collating sequence for sorting.
Procedure Division Verbs SORT input-specifier-2 USING infile VST381.vsd specifies one or more files (a maximum of 31) that contain the records to be sorted. infile is a file description name. During execution of the SORT statement, infile must either be closed or be open in another process or by another file description entry, but not in conflict with a following open for protected input. output-specifier-1 OUTPUT PROCEDURE outproc-1 IS THROUGH outproc-2 THRU VST218.
Procedure Division Verbs SORT outfile is a file description name. During execution of the SORT statement, outfile must be closed and cannot be locked.
Procedure Division Verbs SORT The swap file is a temporary file with a volume but no subvolume. If you specify a swap file, the file-id you specify is not used, only the volume. If you specify only the file-id, the default volume is used. In this explanation, if a swap file is specified but its value is all spaces, assume that no swap file was specified. If COBOL_SET_SORT_PARAM_TEXT_ specifies a SWAP-FILE, then the swap file is created on that file’s volume.
Procedure Division Verbs ° • SORT No sort key data item can be described with an OCCURS clause or can be subordinate to an item described with an OCCURS clause. Sort Input and Sort Output Files Files specified by infile and outfile must be defined as data files; that is, none of them can be defined in a sort-merge file description entry.
Procedure Division Verbs • SORT Sort Output Procedures The OUTPUT PROCEDURE phrase defines a sort output procedure that extends from outproc-1 to outproc-2, each of which must identify a Procedure Division section or paragraph. If THROUGH or THRU is omitted, the compiler assumes an outproc-2 that specifies the same section or paragraph as outproc-1.
Procedure Division Verbs ° SORT INPUT PROCEDURE phrase If the INPUT PROCEDURE phrase appears, the input phase executes an implicit PERFORM procedure-group statement (where proceduregroup is procedure name, optionally followed by THROUGH or THRU and another procedure name). The sort input procedure thereby specified is responsible for releasing the records to be sorted by one or more executions of RELEASE statements. The sort input procedure must not open a file specified by outfile.
Procedure Division Verbs • SORT Output Phase of Execution ° GIVING phrase If the GIVING phrase appears, the output phrase transfers all records in the sd-name file to each output file outfile. Each output file must be in the closed state, but not in the locked state, when the output phase begins executing. First, the output phrase implicitly opens each output file in the output mode.
Procedure Division Verbs ° SORT OUTPUT PROCEDURE Phrase If the OUTPUT PROCEDURE phrase appears, the output phase executes an implicit PERFORM procedure-group statement (where proceduregroup is the procedure name, optionally followed by THROUGH or THRU and another procedure name). The sort output procedure thereby specified is responsible for retrieving the sort file records by one or more executions of RETURN statements. The sort output procedure must not open the sort input file infile.
Procedure Division Verbs START Example 9-62. Typical Use of Input and Output Procedures (page 2 of 2) SD SORT-WORK RECORD CONTAINS 52 CHARACTERS. 01 SORT-RECORD. 05 EMPLOYEE-NUMBER PIC X(05). 05 EMPLOYEE-NAME PIC X(20). 05 DEPT PIC X(03). 05 JOB-CLASS PIC X(05). 05 HOURLY-RATE PIC 9(3)V99. 05 DEDUCTIONS PIC 9(3)V99. 05 ANNUAL-SALARY PIC 9(7)V99. ... PROCEDURE DIVISION. ...
Procedure Division Verbs START HP COBOL includes two extensions that are of particular interest if you are writing a server program: Phrase Description GENERIC Lets you position a file at the first record in a subset of a file that consists of all records that satisfy a certain (EQUALS) key relation. After such a START, you can execute sequential READ statements (READ NEXT, for dynamic-access mode) to read all records of the subset.
Procedure Division Verbs START KEY phrase KEY relationship key IS position VST220.vsd must appear if the file has sequential organization or if the file has relative organization but is not described with a RELATIVE KEY clause. If KEY phrase is omitted, the file’s prime key is used. relationship GREATER THAN OR EQUAL TO > >= = LESS NOT THAN < VST221.vsd If position is present, relationship is limited to: EQUAL TO = VST223.
Procedure Division Verbs START The value of key is restricted by the presence or absence of position.
Procedure Division Verbs START position-key is either the file prime key or a unique alternate key.
Procedure Division Verbs START imperative-stmt-1 is an imperative statement to be executed when an invalid-key condition is encountered by the START operation. It is required if no USE statement is applicable for the file. If both a USE statement and an INVALID KEY phrase are present, only the INVALID KEY phrase is used. imperative-stmt-2 is an imperative statement to be executed when no invalid-key condition is detected in the START operation.
Procedure Division Verbs START The execution of the START statement does not alter the contents of the record area associated with file-name or the content of the depending item specified in the DEPENDING phrase of the RECORD clause that describes file-name. Note. Use care in specifying the starting record. When you are starting a file with APPROXIMATE positioning (which is the default), the value you use for wait-time must take into account that a START can take somewhat longer than expected.
Procedure Division Verbs • START I-O Status Code Unsuccessful Start Operation (page 2 of 2) “90” The program attempted to use the TIME LIMIT phrase when the associated OPEN statement does not specify TIME LIMITS. “91” The program attempted to use the POSITION phrase when the file has insertion-ordered alternate keys. The start operation fails.
Procedure Division Verbs • START Effect of Declaratives on Termination If there is no declarative procedure applicable to the file when the operation is terminated, the program terminates, and an error message is reported to the process’s home terminal. If the applicable declarative procedure is present (but no INVALID KEY phrase is present) and the time interval expires, the declarative procedure is performed.
Procedure Division Verbs • START START Statement Without the POSITION Phrase Execution of the START statement establishes the specified key as the key of reference for the file: ° ° ° ° For sequential files, an alternate key For relative files, the relative key item or an alternate key For indexed files, a prime key or alternate key For queue files, a prime key The start operation searches the file for the first record whose value for the key of reference satisfies the specified relation with respect
Procedure Division Verbs ° START GENERIC Positioning Mode and the POSITION Phrase The choice of APPROXIMATE or GENERIC positioning mode, coupled with the KEY clause, govern where the next READ statement starts reading and what constitutes the end of the file (or the beginning of the file, if the file is being read in reverse).
Procedure Division Verbs • START Determining Key Value of Last Record of an Indexed or Queue File To determine the key value of the last record of an indexed or queue file, which is especially important when using the READ REVERSED statement, move HIGHVALUES to the key and then use the START statement with the relationship LESS THAN. START LESS THAN positions the indexed file so that a READ NEXT or READ REVERSED statement accesses the last record in the file. Table 9-11.
Procedure Division Verbs START Example 9-64 reads all records for employees whose last names start with G. Example 9-64. START Statement With GENERIC Phrase for Sequential File SELECT INPUT-FILE ASSIGN TO "INFILE" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL ALTERNATE RECORD KEY IS EMP-NAME WITH DUPLICATES. ... FD INPUT-FILE LABEL RECORDS ARE OMITTED RECORD CONTAINS 95 CHARACTERS DATA RECORD IS PERSONNEL-DATA. 01 PERSONNEL-DATA. 05 DEPT-NO PIC 9(5). 05 EMPLOYEE-NO PIC 9(7). 05 EMP-NAME.
Procedure Division Verbs START Example 9-65. START Statement With POSITION Phrase SELECT EMP-FILE ASSIGN TO "EMPL1093" ORGANIZATION IS INDEXED ACCESS MODE IS DYNAMIC RECORD KEY IS EMP-NO ALTERNATE RECORD KEY IS DEPT-NO WITH DUPLICATES ALTERNATE RECORD KEY IS EMP-NAME WITH DUPLICATES FILE STATUS IS EMP-STATUS. ... DATA DIVISION. FILE SECTION. ... FD EMP-FILE. 01 EMP-DATA. 05 EMP-NO PIC 9(6). 05 EMP-NAME PIC X(45). 05 EMP-DEPT PIC 9(7). ... PROCEDURE DIVISION. ... OPEN INPUT EMP-FILE ...
Procedure Division Verbs STARTBACKUP In Example 9-65, suppose that department 1572 has 12 employees: 000131Smith 001552Nguyen 001744Dietrich 001745Wellhausen 001746Thomas 001991Chew 004451O'Hara 005433Logan 006112McClure 009733Kinoshita 012255Bostrup 013146Tilden Jan Tracy Pat Robin Kim Meredith Flemming Shannon Beck Lynn Stacy Tex 0001572 0001572 0001572 0001572 0001572 0001572 0001572 0001572 0001572 0001572 0001572 0001572 If the requester sends a request with an EMP-NO value of zero for department
Procedure Division Verbs STARTBACKUP options is either an integer numeric literal or an identifier that designates an integer numeric data item. The value must be 0, 1, 2, or 3. The significance of options is: 0 The fault-tolerant facility is to read and process system messages, and the primary process is to terminate abnormally if a trap condition occurs.
Procedure Division Verbs • STARTBACKUP Backup Process and Takeover Points When the process is qualified to execute as a process pair, successful execution of the STARTBACKUP statement establishes and initializes a backup process. The STARTBACKUP statement does not itself establish a valid takeover point; this is a function of the CHECKPOINT, OPEN, or CLOSE statement.
Procedure Division Verbs • STOP What Fault-Tolerant Facility Checkpoints The fault-tolerant facility checkpoints the global-data portion of the globals-heap segment, the main stack, and all open files when the STARTBACKUP statement is executed; however, your program must contain a CHECKPOINT statement to verify the creation of a backup process and to establish a valid takeover point in the program code (rather than in the run-time library).
Procedure Division Verbs STRING STRING STRING combines some or all the characters from two or more data items into one other data item. STRING DELIMITED part-1 delimiter BY INTO SIZE result POINTER pointer WITH OVERFLOW imperative-stmt-1 ON NOT OVERFLOW imperative-stmt-2 ON END-STRING VST226.vsd part-1 is an alphanumeric literal or identifier of a DISPLAY data item. The concatenation of their values is stored in the data item named by result.
Procedure Division Verbs STRING If the data item is numeric, it must be described as an integer whose PICTURE character-string does not include P. SIZE specifies that all the characters in part-1 are moved. result is an identifier for an alphanumeric data item where the characters chosen from the part-1 s are stored. If result is an elementary item, its PICTURE character-string must not contain editing symbols or a JUSTIFIED clause. Reference modification is not permitted.
Procedure Division Verbs STRING Usage Considerations: • Operand Identification For each identifier, the process of operand identification occurs only once, at the beginning of the execution of the STRING statement. • Initialization The execution of the STRING statement begins in this manner: 1. The data item specified by result is established as the receiving item. 2. When the POINTER phrase appears, the data item specified by pointer is established as the pointer variable.
Procedure Division Verbs ° STRING Overflowing the size of the receiving item Overflow occurs if not all of the characters of a transfer string can be moved to the receiving item. The overflow condition exists when the pointer value exceeds the size of the receiving item during assignment of any transfer string or after completing assignment of any transfer string except the last one.
Procedure Division Verbs STRING In Example 9-66, STRING builds a single data item from several data items. Also see the examples in UNSTRING. Example 9-66. STRING Statement Input: WORKING-STORAGE SECTION. 77 PART-1 PIC X(10). 77 PART-2 PIC X(26). 77 PART-3 PIC X(10). 77 RESULT-1 PIC X(80) VALUE SPACES. 77 COUNT-1 PIC 99. PROCEDURE DIVISION. A10-START.
Procedure Division Verbs SUBTRACT SUBTRACT SUBTRACT computes differences between numeric values.
Procedure Division Verbs SUBTRACT FROM SUBTRACT FROM SUBTRACT FROM subtracts one or more values from the values of one or more identifiers and stores the results in the identifiers. SUBTRACT subtrahend FROM minuend-result ROUNDED SIZE ERROR ON imperative-stmt-1 NOT SIZE ERROR ON imperative-stmt-2 END-SUBTRACT VST227.vsd subtrahend is the identifier of a numeric elementary data item or a numeric literal. minuend-result is the identifier of a numeric elementary data item.
Procedure Division Verbs SUBTRACT FROM imperative-stmt-2 is an imperative statement to be executed when no size error is detected in the subtraction or in storing the result. END-SUBTRACT ends the scope of the SUBTRACT statement, causing the SUBTRACT to be a delimited-scope statement.
Procedure Division Verbs • SUBTRACT GIVING Precision For any series of items involved in a subtraction, when their decimal points are aligned, the composite picture must involve not more than 18 digits of representation, or a size error condition can result (which can cause a run unit to terminate abnormally with an arithmetic overflow condition). For information on precision of subtraction, see ADD and SUBTRACT Statements.
Procedure Division Verbs SUBTRACT GIVING minuend is a numeric literal or the identifier of an elementary numeric data item. result is the identifier of a numeric or numeric edited elementary data item. ROUNDED specifies that the result is to be rounded before being stored. imperative-stmt-1 is an imperative statement to be executed when a size error is detected in the subtraction or in storing the result.
Procedure Division Verbs • SUBTRACT CORRESPONDING Precision For any series of items involved in a subtraction, when their decimal points are aligned, the composite picture must involve not more than 18 digits of representation, or a size error condition can result (which can cause a run unit to terminate abnormally with an arithmetic overflow condition). For information on precision of subtraction, see ADD and SUBTRACT Statements.
Procedure Division Verbs SUBTRACT CORRESPONDING group-1 is the identifier of a data structure in which some or all of the elementary items are numeric. group-2 is the identifier of a data structure that has one or more elementary numeric items. For each elementary numeric item in group-2 that corresponds to such an item in group-1, the difference between the values of the two items replaces the value of group-2.
Procedure Division Verbs UNLOCKFILE UNLOCKFILE UNLOCKFILE restores access to any records in a file previously locked with LOCKFILE or to those records locked with a LOCK phrase on previous READ statements. Other processes can then read or write records, depending on the file’s open mode. UNLOCKFILE file-name VST230.vsd file-name is the file description name of a file.
Procedure Division Verbs UNLOCKRECORD In Example 9-67, the UNLOCKFILE statement precedes a CLOSE statement to unlock the file before the process closes it. Example 9-67. UNLOCKFILE Statement FD IN-MASTER-FILE ... PROCEDURE DIVISION. ... IF UPDATE-FILE OPEN INPUT IN-MASTER-FILE LOCKFILE IN-MASTER-FILE PERFORM UP-DATE-MASTER UNTIL DONE UNLOCKFILE IN-MASTER-FILE CLOSE IN-MASTER-FILE ELSE ... UP-DATE-MASTER. * Perform the update, during which time no other process * can read any record in that file. ...
Procedure Division Verbs • UNSTRING File-Status Data Item If file-name has an associated file-status data item, execution of the UNLOCKRECORD statement always assigns an appropriate I-O status code as its value. The status “00” reports a successful UNLOCKRECORD operation. Whenever the statement terminates with an I-O status code greater than or equal to “30,” execution of the UNLOCKRECORD failed.
Procedure Division Verbs UNSTRING UNSTRING source DELIMITED delim-1 BY OR ALL delim-2 ALL INTO result-list POINTER pointer WITH TALLYING tally IN OVERFLOW imperative-stmt-1 ON NOT OVERFLOW imperative-stmt-2 ON END-UNSTRING VST232.vsd source is the identifier of an alphanumeric data item containing a sequence of characters that the unstring operation is to separate into one or more sequences of characters and store them in one or more result items.
Procedure Division Verbs UNSTRING delim-1 is the identifier of an alphanumeric data item or an alphanumeric literal. If it is a figurative constant, it must represent a single character. The delimiter delim-1 marks the end of a portion of the value of source. The value that the unstring operation stores into a result item does not include the value of delim-1. ALL causes the unstring operation to handle all consecutive occurrences of the value of delim-2 as if they were only one occurrence of delim-2.
Procedure Division Verbs UNSTRING delimstore is the identifier of an alphanumeric data item. You can only use the DELIMITER phrase when you also use the DELIMITED phrase. The unstring operation copies the character or characters of source that matched the delimiter specified in the DELIMITED phrase to delimstore. delimstore cannot reference a special register. count is the identifier of an integer data item. You can only use the COUNT phrase when you also use the DELIMITED phrase.
Procedure Division Verbs UNSTRING imperative-stmt-1 is an imperative statement to be executed when overflow occurs; that is, when these conditions exist: • • The initial value of pointer is less than 1 or greater than the length of source. All data-receiving areas have been acted upon, and source still contains unexamined characters. If you do not specify an OVERFLOW clause and an overflow occurs, control passes to the next statement after UNSTRING.
Procedure Division Verbs • • • • • UNSTRING This enables you to start the unstring operation at some character other than the first character in the source item, and to retain a record of where the unstring operation terminated. (A later UNSTRING statement could then begin its operation at the point where another one left off.
Procedure Division Verbs UNSTRING the first item to be copied is “The” and the second is “UNSTRING” and so on. If you specify two or more delimiters, the unstring operation compares their values with the sending area in the same order as they appear in the phrase. If a match occurs, the corresponding set of characters in the sending area forms the delimiter string; any delimiters not yet tested are ignored.
Procedure Division Verbs UNSTRING If you execute UNSTRING U DELIMITED BY SPACE INTO WORD-1 WORD-2 WORD-3 WORD-4 WORD-5 WORD-6 The fifth item to be copied is “handy.” There is no sixth item to be copied. The unstring operation handles the set of characters thus examined (excluding the delimiter string, if any) as an elementary alphanumeric data item and copies it to the current receiving area in accordance with the rules for the MOVE statement.
Procedure Division Verbs UNSTRING If the specification of the matched delimiter includes the keyword ALL and the portion of the sending area following the delimiter string contains one or more repetitions of that set of characters, then the unstring operation advances the current character position past all repetitions; therefore the unstring operation considers two or more contiguous occurrences of the matched delimiter string as equivalent to a single occurrence in determining the beginning character fo
Procedure Division Verbs UNSTRING When the execution of an UNSTRING statement with a TALLYING phrase terminates, either normally or due to an overflow condition, tally contains a value equal to its initial value plus the number of data receiving items that were assigned new values. If an overflow condition arises, execution of the UNSTRING statement terminates at that point. 3.
Procedure Division Verbs UNSTRING Example 9-68. UNSTRING Statement Input: DATA DIVISION. WORKING-STORAGE SECTION. 77 SOURCE-STRING PIC X(18) VALUE "12345 MICKEY ABCDE". 77 UNPART-1 PIC X(3). 77 UNPART-2 PIC X(3). 77 UNPART-3 PIC X(3). PROCEDURE DIVISION. A10-START. UNSTRING SOURCE-STRING DELIMITED BY " " INTO UNPART-1 UNPART-2 UNPART-3 DISPLAY "UNPART-1 = " UNPART-1 DISPLAY "UNPART-2 = " UNPART-2 DISPLAY "UNPART-3 = " UNPART-3 STOP RUN.
Procedure Division Verbs UNSTRING Example 9-69. UNSTRING Statement (page 2 of 2) PROCEDURE DIVISION. WHATS-NEXT. * PROMPT FOR A NAME AS IT WOULD BE TYPED ON AN ENVELOPE DISPLAY "Enter a name (or a space to terminate):". ACCEPT WHOLE-NAME IF WHOLE-NAME = SPACES STOP RUN END-IF * INITIALIZE MOVE SPACES TO NAMES-TABLE, REST-OF-NAME MOVE 0 TO NAME-COUNT * * GET EACH CONSECUTIVE BLOCK OF CHARACTERS ENDING IN ONE OR MORE SPACES INTO A NAME (I) AND COUNT THE BLOCKS.
Procedure Division Verbs USE This is a sample run of Example 9-69 with a typical name and a single-word name: Enter a name (or a space to terminate): ?Abraham Moyer Last name is......Moyer Rest of name is...Abraham Enter a name (or a space to terminate): ?Johann Philip Geissinger Last name is......Geissinger Rest of name is...JohannPhilip Enter a name (or a space to terminate): ?Copernicus Last name is......Copernicus Rest of name is... The portions of the rest of the name are not separated by spaces.
Procedure Division Verbs USE DEBUGGING USE DEBUGGING Note. The 1985 COBOL standard classifies USE DEBUGGING as obsolete. The compiler does not recognize it. For its description, see the COBOL Manual for TNS and TNS/R Programs. USE AFTER EXCEPTION USE AFTER EXCEPTION intercepts control when an input-output exception occurs. The input-output system executes USE AFTER EXCEPTION procedures after it completes the standard input-output error routine.
Procedure Division Verbs USE AFTER EXCEPTION EXCEPTION ERROR introduce the exception procedure and specify that the procedure is to be performed after the COBOL run-time input-output error routine, or when an invalidkey or at-end condition arises and no INVALID KEY or AT END phrase is present in the statement then executing. file-name is a file description name that is to use this USE statement when an exception occurs. A given file-name can occur in only one USE statement in a given program.
Procedure Division Verbs • USE AFTER EXCEPTION Implicit and Explicit File Reference A USE statement that mentions a file by name is said to make an explicit reference to the corresponding file. A USE statement that mentions an open mode (INPUT, I-O, OUTPUT, or EXTEND) makes reference to a file implicitly, according to the mode in which the program opened (or attempted to open) the file.
Procedure Division Verbs WRITE Example 9-70. USE AFTER EXCEPTION Statement ... PROCEDURE DIVISION. DECLARATIVES. MASTER-FILES SECTION. USE AFTER EXCEPTION PROCEDURE ON MASTER-1 MASTER-2. MASTER-ERROR-ROUTINE. IF FILE-STATUS.... ... DETAIL-FILE SECTION. USE AFTER EXCEPTION PROCEDURE ON DETAIL-IN. DETAIL-ERROR-ROUTINE. ... END DECLARATIVES. MAIN-SECTION SECTION. BEGIN-PROGRAM. ... WRITE WRITE delivers a record to its associated file.
Procedure Division Verbs WRITE for Sequential Files WRITE for Sequential Files WRITE record-name FROM ADVANCING clause NOT from-name end-of-page clause not-end-of-page clause invalid-key-phrase NOT not-invalid-key-phrase END-WRITE VST236.vsd record-name is a logical record described in the File Section of the Data Division. The recordname can be qualified by the name of the file with which the record is associated. The data written is the current contents of record-name.
Procedure Division Verbs WRITE for Sequential Files ADVANCING clause BEFORE AFTER no-of-lines ADVANCING LINE LINES mnemonic-name PAGE VST237.vsd advances the file (skips lines) before or after the record is written to it. The default ADVANCING clause is AFTER ADVANCING 1. The ADVANCING clause can be used only with files assigned to processes or printers. BEFORE specifies that the record is to be printed before any lines are skipped.
Procedure Division Verbs WRITE for Sequential Files PAGE advances the printer to the top of the page before or after the write operation. PAGE and end-of-page clause cannot appear in the same WRITE statement. end-of-page clause END-OF-PAGE AT imperative-statement EOP VST238.vsd executes imperative-statement when the write operation encounters the end-of-page condition. The file description must include a LINAGE clause. not-end-of-page clause END-OF-PAGE AT imperative-statement EOP VST238.
Procedure Division Verbs WRITE for Sequential Files imperative-statement is an imperative statement to be executed when an invalid-key condition arises because alternate keys are defined for the sequential file, and the write operation would create a duplicate key when the file definition did not specify that duplicates are allowed. If no INVALID KEY phrase is present, a USE procedure must be present for the file or files to be opened in OUTPUT mode.
Procedure Division Verbs • WRITE for Sequential Files Opening File Positions Printer at Top of First Page When you open a file, the printer is positioned at the top of the first page, as if BEFORE ADVANCING PAGE had been executed. If you use default advancing (AFTER ADVANCING 1), you get a blank line at the top of the first page. (You usually use BEFORE 1 before the first write operation.
Procedure Division Verbs WRITE for Sequential Files The I-O status codes that result from an unsuccessful write operation are: • I-O Status Code Unsuccessful Write Operation “22” An alternate record key value of the logical record equals that of a record that already exists in the file and duplicate values are not allowed for that key (all access modes). “30” The write operation failed due to non-COBOL causes. The specified record might or might not have been written.
Procedure Division Verbs • WRITE for Sequential Files Page Overflow An automatic page overflow condition exists whenever the execution of a write statement cannot be fully accommodated within the current page body of a printer file described with a LINAGE clause. This situation arises when the execution of the WRITE statement would cause the LINAGE-COUNTER to assume a value greater than the number of lines in the current page body.
Procedure Division Verbs WRITE for Sequential Files Example 9-71. ADVANCING Phrase ENVIRONMENT DIVISION. ... INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT MASTER-RANDOM-FILE ASSIGN TO "$MARKT.PLATZ.RPT" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS M-R-STATUS. ... DATA DIVISION. FILE SECTION. ... FD MKT-REPORT LABEL RECORDS ARE OMITTED RECORD CONTAINS 132 CHARACTERS LINAGE IS 60 LINES WITH FOOTING AT FOOTLINE LINES AT TOP TOPLINES LINES AT BOTTOM BOTTOMLINES.
Procedure Division Verbs WRITE for Line Sequential Files WRITE for Line Sequential Files WRITE record-name FROM from-name END-WRITE VST631.vsd record-name is a logical record described in the File Section of the Data Division. The recordname can be qualified by the name of the file with which the record is associated. The data written is the current contents of record-name.
Procedure Division Verbs WRITE for Relative, Indexed, and Queue Files WRITE for Relative, Indexed, and Queue Files WRITE record-name FROM from-name invalid-key NOT not-invalid-key END-WRITE VST240.vsd record-name is a logical record described in the File Section of the Data Division. The recordname can be qualified by the name of the file with which the record is associated.
Procedure Division Verbs WRITE for Relative, Indexed, and Queue Files END-WRITE ends the scope of the WRITE statement, causing the WRITE to be a delimitedscope statement. If the WRITE statement does not end with an END-WRITE phrase, the presence of the INVALID KEY or the NOT INVALID KEY phrase causes the WRITE statement to be a conditional statement, which ends at the next period separator.
Procedure Division Verbs • WRITE for Relative, Indexed, and Queue Files I-O Status Code Unsuccessful Write Operation (page 2 of 2) “30” The write operation failed due to non-COBOL causes. The specified record might or might not have been written. “44” When the file is described with the RECORD VARYING clause, the logical record size must be neither greater than the maximum nor less than the minimum number of character positions specified in that clause.
Procedure Division Verbs • WRITE for Relative, Indexed, and Queue Files Relative and Dynamic Access For files of relative organization, the relative key data item must be set to the desired record number before the WRITE occurs. This can be done in either of two ways: ° ° Set the key item to the relative record number. Set the key item to -1 to have the record written at the end of the file or to -2 to have the record written in any available file position.
Procedure Division Verbs WRITE for Relative, Indexed, and Queue Files Example 9-72. INVALID KEY Phrase ENVIRONMENT DIVISION. ... INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT MASTER-REL-FILE ASSIGN TO "$MARKT.PLATZ.DT" ORGANIZATION IS RELATIVE ACCESS MODE IS RANDOM RELATIVE KEY IS VKF-NR FILE STATUS IS M-R-STATUS. ... DATA DIVISION. FILE SECTION. ... FD MASTER-REL-FILE LABEL RECORDS ARE OMITTED RECORD CONTAINS 180 TO 250 CHARACTERS. 01 DOMESTIC-SALE PIC X(180). 01 FOREIGN-SALE PIC X(250). ...
Procedure Division Verbs WRITE for Relative, Indexed, and Queue Files HP COBOL Manual for TNS/E Programs —520347-003 9 -288
10 Source Text Manipulation Source manipulation comprises the COPY statement, COPY libraries, and the REPLACE statement. You can use the COPY and REPLACE statements in any division of the source program. The COPY statement summons source text from a COPY library and delivers merged text to the compiler. Its optional REPLACING phrase replaces every occurrence of a specified portion of library text with a specified portion of new text when it copies library text into a source program.
Source Text Manipulation COPY Statement COPY Statement COPY summons source text from a file set up as a COPY library. In many systems, one section of code or data is common to several programs. Such a section can be written once, kept in a COPY library, and inserted into each program at compile time by COPY statements. In HP COBOL, the COPY statement is a mechanism for summoning text that is managed by the Data Definition Language (DDL) compiler. (Another such mechanism is the SOURCE directive.) COPY .
Source Text Manipulation COPY Statement If library-name is not specified, a default library file is selected: • In the Guardian environment: 1. If a COPY library is named in the COBOL85 command (see Starting a Compilation), then that file is the default library file. 2. If the condition in Item 1 is not true and the file COPYLIB exists on the current volume and subvolume, then that COPYLIB file is the default library file. 3.
Source Text Manipulation COPY Statement Usage Considerations: • Where COPY Statements Can Be Used With these exceptions, a COPY statement can occur anywhere in the source text that a character-string or separator can occur: • ° ° A COPY statement cannot appear within the body of another COPY statement. ° If the word COPY appears either in a comment-entry or in a place where a comment-entry can appear, it is considered part of the comment-entry, not as the keyword that begins a COPY statement.
Source Text Manipulation • COPY Statement Compiler Directives and the COPY Statement A compiler directive line cannot appear between the keyword COPY and the period separator that terminates the statement, unless it is part of pseudo-text (see REPLACE Statement). • Compiler Directives in Library Text Library text can include compiler directives, which the compiler obeys when it analyzes the copied text.
Source Text Manipulation COPY Statement In Example 10-1, EMPLOYEE-DETAIL of the COPY statement is not qualified because the COPY library is named COPYLIB and resides on the current volume and subvolume for the compile process. Example 10-1. COPY Statement Contents of COPY library COPYLIB: ?SECTION EMPLOYEE-DETAIL 01 EMP-DATA-IN. 05 EMP-NO PIC 05 EMP-NAME PIC 05 DEPT PIC 05 JOB-CLASS PIC 05 HOURLY-RATE PIC 05 DEDUCTIONS PIC 05 SALARY PIC X(05). X(20). X(03). X(05). 9(3)V99. 9(3)V99. 9(7)V99.
Source Text Manipulation REPLACING Phrase REPLACING Phrase The REPLACING phrase of the COPY statement directs the compiler to replace every occurrence of a portion of library text with a replacement portion when it copies library text into a source program. You can specify more than one pair of such portions for the compiler to replace when it executes a COPY statement. The compiler searches for each original portion in the order in which you declared them in the REPLACING phrase. .
Source Text Manipulation REPLACING Phrase pseudo-text-1 == text-word == VST250.vsd contains at least one text-word other than a comma or semicolon separator. A character-string within pseudo-text-1 can continue on the next line, but both characters of the pseudo-text delimiter (==) must be on the same line. pseudo-text-2 == == text-word VST251.vsd can be null.
Source Text Manipulation REPLACING Phrase Usage Considerations: • Effect of REPLACE on Literals The REPLACE statement does not affect literals; for example, REPLACING ==Year== BY ==Month== does not change the original text-word "End of Year" to the new text-word "End of Month" • Matching Text in a COPY Library The compiler searches for portions of text in the order you specify in the REPLACING phrase.
Source Text Manipulation REPLACING Phrase 3. If no match occurs, the compiler repeats the comparison with each successive pseudo-text-1, identifier-1, word-1, or literal-1, if any, in the REPLACING phrase until a match occurs or until it has compared each operand in the phrase to the leftmost library text-word or text-words. 4. If the compiler compares all the REPLACING phrase operands without finding a match, it copies the leftmost library text-word into the source program.
Source Text Manipulation COPY Libraries Example 10-2. COPY Statement With REPLACING Phrases COPY CUSTOMER REPLACING ==FULL NAME== BY ==Able X. Baker== ADDRESS BY STREET-ADDRESS. COPY Libraries A COPY library is either a file in the EDIT format or an OSS ASCII text file. Its text can be merged into a source program during compilation using a COPY statement.
Source Text Manipulation Library Format Library Format section-text pre-text VST252.vsd pre-text is one or more text lines. These lines are never copied. When a library file begins with pre-text, this text can be comments about the library’s sections. The compiler examines pre-text only to look for a question mark (?) in column 1 followed by zero or more spaces followed by the directive COLUMNS (in any combination of cases). If it finds such a directive, it attempts to translate and use it.
Source Text Manipulation Library Format Usage Considerations: • COLUMNS Directive The library can contain at most one COLUMNS directive. The COLUMNS directive must precede all SECTION directives and must appear alone in its compiler directive line. Furthermore, the line’s question mark must always be in column 1 (even if the ANSI source text format applies).
Source Text Manipulation • REPLACE Statement Compiler Builds a Directory of the COPY Library The first time the compiler reads from a COPY library, it begins to build a directory for itself that enables it to locate the individual sections. It reads through the library, building its directory, until it finds the selected section. After copying it, it resumes normal compilation. For subsequent COPY statements, it checks its directory.
Source Text Manipulation REPLACE Statement pseudo-text-2 == == text-word VST251.vsd can be null. A character-string within pseudo-text-2 can continue on the next line, but both characters of the pseudo-text delimiter (==) must be on the same line. text-word is any character-string or separator except space. It cannot be a concatenation expression. OFF marks the end of the scope of replacement of the most recent REPLACE statement.
Source Text Manipulation • REPLACE Statement Persistence A given occurrence of the REPLACE statement is active from the point at which you specify it until the next occurrence of a REPLACE statement or the end of the separately compiled program, respectively. • REPLACE Statements and the Listing The listing the compiler produces shows the lines containing REPLACE statements like any other lines. When any replacement occurs, the image in the listing is that of the text after replacement.
Source Text Manipulation REPLACE Statement 6. The compiler continues its comparison operation until either the rightmost textword in the source program text (within the scope of the REPLACE statement) has participated in a match or has been considered as a leftmost text-word and participated in a complete comparison cycle. • Comment Lines and Blank Lines in Replacement Text The matching operation ignores any comment lines or blank lines occurring in the source program text.
Source Text Manipulation REPLACE Statement The REPLACE statement in Example 10-3 enables you to declare a name for a constant in your program, then use that name in various places in a program. While OFFICES could have been declared as a data-item for this purpose, SQ-FTSIZE could not have.
11 Program Compilation The compiler can run at a high PIN (a process identification number greater than 255) and can be requested by other processes running at high PINs. The compiler accepts one source file as input. That source file can use SOURCE directives and COPY statements to read text from other source files.
Program Compilation Compiler Input Figure 11-1. Compiler Input and Output (affected by NOLIST and SUPPRESS directives) Listing File Compiler Source File (affected by SYNTAX directives and errors) Object File VST515.
Program Compilation Main Programs Main Programs A main program is either compiled with the MAIN directive (see MAIN) or it has no Linkage Section (see Absent Linkage Section). A loadfile must contain exactly one main program. It can also contain other programs. When the loadfile is executed, the NonStop operating system calls the main program. Then the main program can call the other programs and the other programs can call each other. The NonStop operating system does not call the other programs.
Program Compilation Calling and Called Programs Calling and Called Programs Many languages have declarations that distinguish main programs from subprograms. COBOL does not use the term “subprogram.” Instead, it defines a program as a “calling program” if it contains a CALL or ENTER statement and defines a program as a “called program” if it is the object of a CALL or ENTER statement. A program can be both a calling program and a called program.
Program Compilation Compilation Units Appendix B, Data Type Correspondence, shows the correspondence between HP COBOL data items and those of the other languages with which an HP COBOL program can interact. HP COBOL index names are entirely internal to their own program; they cannot be written, read, or passed as parameters. Index data items in HP COBOL correspond to 32-bit integers. Compilation Units The source file that is input to the compiler is also called a compilation unit.
Program Compilation Compilation Units Example 11-2. Compilation Unit (page 2 of 2) IDENTIFICATION DIVISION. PROGRAM-ID. CALLER. * THE MAIN PROGRAM FOR THIS COMPILATION. ... DATA DIVISION. ... WORKING-STORAGE SECTION. 01 WS-PARTS. 03 WS-FIRST-PART PICTURE X(30). 03 WS-SECOND-PART PICTURE X(30). 01 WS-PRODUCER. 03 WS-PRODUCER-NAME PICTURE X(60). 03 WS-PRODUCER-ADDRESS PICTURE X(60). PROCEDURE DIVISION. CALL "CPGM1" USING WS-PARTS CALL "CPGM2" USING WS-PARTS WS-PRODUCER ... END PROGRAM CALLER.
Program Compilation Compilation Details Example 11-3. Calling Programs That Are in a Separate File PROGRAM-ID. CALLER. ... SPECIAL-NAMES. FILE "$MYVOL.MYSUB.COBJECT" IS C-ARCHIVE. ... CALL "CPGM1" IN C-ARCHIVE ...
Program Compilation Temporary File Placement Figure 11-2. ECOBOL Compilation of Single Program Unit eld Source Files ECOBFE Loadfile ECOBOL Copy Libraries Linkfile Listing File VST822.vsd Temporary File Placement The ECOBOL compiler and its supporting processes create and use temporary files. By default, the compiler creates its temporary files on the current default volume. If called by the compiler, the process ECOBFE and the linker create their temporary files on the current default volume.
Program Compilation CALL and ENTER Statement Processing: Overview In the CALL statement, the called program must be a COBOL program. It can be part of the same compilation unit as the calling program, or it can be an external reference to a COBOL program outside the compilation unit (but in the same object file). All ENTER statements cause external references, because they call programs compiled from source languages other than COBOL.
Program Compilation CALL and ENTER Statement Processing: Overview For more information, see: • • • • Primary Search List Tertiary Search List ECOBEXT File ECOBEX0 and ECOBEX1 Files Primary Search List SEARCH directives define the primary search list, an ordered list of object files. Each SEARCH directive adds one or more files to the primary search list. The compiler adds files to the search list in the order that they appear in the SEARCH directives.
Program Compilation CALL and ENTER Statement Processing: Detailed Explanation ECOBEX0 and ECOBEX1 Files Each RVU of the ECOBOL compiler includes three files: ECOBEX0, ECOBEX1, and ECOBEXT. These represent the most recent, next most recent, and third most recent RVUs of the Guardian environment, respectively.
Program Compilation CALL and ENTER Statement Processing: Detailed Explanation A compilation source text consists of one or more separately compiled HP COBOL programs. Each such program can include nested programs. Suppose separately compiled program S includes program P, which contains the statement CALL A. The compiler follows this procedure: 1. If program P directly contains a program named A, the compiler always chooses that program.
Program Compilation CALL and ENTER Statement Processing: Detailed Explanation Example 11-4. For Step 1 of Finding the Called Program IDENTIFICATION DIVISION. PROGRAM-ID. P. ... PROCEDURE DIVISION. ... CALL A ... ... IDENTIFICATION DIVISION. PROGRAM-ID. A. ... END PROGRAM A. IDENTIFICATION DIVISION. PROGRAM-ID. B. ... END PROGRAM B. END PROGRAM P. Example 11-5. For Step 2 of Finding the Called Program IDENTIFICATION DIVISION. PROGRAM-ID. S. ... PROCEDURE DIVISION. ... IDENTIFICATION DIVISION. PROGRAM-ID.
Program Compilation CALL and ENTER Statement Processing: Detailed Explanation b. If no file-mnemonic appears: The compiler looks for the program in these files in this order: 1. 2. 3. 4. 5. Primary search list Tertiary search list ZCOBDLL ZCREDLL ECOBEXT c. If the compiler cannot find the program in any of the places discussed earlier, it reports an error and delivers no object code for the calling program. Note.
Program Compilation CALL and ENTER Statement Processing: Detailed Explanation Table 11-2. Resolution of External References (page 2 of 2) External reference found in ... Form* Current Source File Primary Search List Tertiary Search List ECOBEXT, ZCOBDLL, or ZCREDLL Target File Created? ENTER [TAL] “R” Impossible Yes Irrelevant Irrelevant Yes Impossible No Yes Irrelevant Yes Impossible No No Yes Yes Impossible No No No No, error reported * Bracketed keywords are optional.
Program Compilation #RECEIVE Blocks Delivering the Returned Value When an ENTER statement has a GIVING phrase, the compiler generates code to deliver the value that the program returns to a data item in the calling program. The generated code performs any necessary scaling of the result value, then performs an assignment according to the rules for an elementary move operation.
Program Compilation #RECEIVE Blocks The first HP COBOL external file to open $RECEIVE determines the values of the #RECEIVE arguments. Subsequent opens of $RECEIVE fail if they specify incompatible values.
Program Compilation Compiler Output Compiler Output The output of a compilation can include a listing (to an existing file or spooler) and an object file, but it always includes compilation statistics and a completion code. You can manipulate the object file. Topics: • • • • • Listing Creation Object File Creation Manipulating Object Files Compilation Statistics Completion Codes Listing Creation The listing is added to the end of the listing (OUT) file.
Program Compilation Object File Creation Object File Creation The object file that the compiler produces is either a linkfile or a loadfile. The compiler produces a loadfile if you specify the directive RUNNABLE. If the compilation unit contains no main program, executing the object file causes it to terminate immediately with an error message. The compiler produces a linkfile by default (if you do not specify the RUNNABLE directive). Linkfiles that the compiler produces can be input to the eld utility.
Program Compilation Compilation Statistics Example 11-7. ECOBOL Compiler and Linker Statistics COBOL - T0356H01 - (20DEC2004) No failures detected. No errors detected. No warnings reported. No remarks issued. Maximum symbol table size = 10884 bytes eld - TNS/E Native Mode Linker - T0608H01 - 03DEC07 Copyright 2004 Hewlett-Packard Company eld command line: \drp12.$system.system.eld -o opt2o opt2o \DRP12.$SYSTEM.ZDLL031.ZCOBDLL \DRP12.$SYSTEM.ZDLL031.
Program Compilation Completion Codes Completion Codes The compiler reports an appropriate completion code when it terminates execution. An HP COBOL program can set its own completion code at termination by calling the COBOL_COMPLETION_ routine. Table 11-4. Completion Codes Code Termination Explanation 0 Normal No diagnostic messages were issued. The object file is complete and valid (unless a SYNTAX directive suppressed its creation). 1 Normal At least one compiler warning occurred.
Program Compilation PARAM Commands PARAM Commands If you want to use a PARAM command, you must enter it before you give the command to run the compiler. When the compiler terminates execution, it reports an appropriate completion code. Note. PARAM commands for files in a user library are ignored. Table 11-5. PARAM Commands Accepted by Compiler Command Description PARAM SWAPVOL Specifies the volume on which the ECOBOL compiler and its processes will create temporary files.
Program Compilation Predefined SEARCH DEFINEs PARAM SYMBOL-BLOCKS The PARAM SYMBOL-BLOCKS command specifies how much space the compiler allocates for its symbol dictionary and embedded SQL/MP statements. The PARAM SYMBOL-BLOCKS command specifies how much space the compiler allocates for its symbol dictionary, local label table, and embedded SQL/MP or SQL/MX statements. PARAM SYMBOL-BLOCKS count VST419.vsd count is an integer in the range 1 through 40, which affects space allocation.
Program Compilation Predefined SEARCH DEFINEs To add a predefined SEARCH DEFINE, use the ADD DEFINE command. For example: ADD DEFINE =_SOURCE_SEARCH, CLASS SEARCH, SUBVOL0 (=_DEFAULTS,$VOL1.SUB2,$VOL1.SUB3) In this example, the compiler is to search the default subvolume first, then $VOL1.SUB2, and finally $VOL1.SUB3.
Program Compilation Starting a Compilation Starting a Compilation This section applies to the Guardian environment. To compile an HP COBOL program in the OSS environment, see Section 19, Using HP COBOL in the OSS Environment. To run the ECOBOL compiler, use this compiler command: ECOBOL / IN source-file / , OUT list-file , other-option target-name , copy-library ; compiler-directive VST807.vsd source-file file-name-1 define-name VST257.
Program Compilation Starting a Compilation define-name is the name of a DEFINE established in the current run-time environment. list-file file-name-2 define-name VST259.vsd is the destination to which the compiler directs its output. It must be a disk file, terminal, magnetic tape unit, process, line printer, or spooler collector (possibly qualified with a location name). It must already exist and meet the criteria in Listing Creation.
Program Compilation Starting a Compilation The default target-name is: \default-system.$default-volume.default.subvolume.RUNUNIT file-name-3 is a disk or nondisk file name. For syntax, see the Guardian Procedure Calls Reference Manual. define-name is the name of a DEFINE established in the current run-time environment. obj-1 ... obj-n file-name-4 define-name VST261.vsd is a list of names of disk files on which the multiple target object files are to be produced. Each has the same syntax as target-name.
Program Compilation Starting a Compilation define-name is the name of a DEFINE established in the current run-time environment. copy-library file-name-4 define-name VST261.vsd is the name of a COPY library, a disk file in EDIT format, which is to be the default COPY library (for any COPY statement in the source program that does not specify a library from which to copy). file-name-4 is a disk file name. For syntax, see the Guardian Procedure Calls Reference Manual.
Program Compilation Terminating a Compilation Terminating a Compilation There are two ways to terminate a compilation before normal completion: • • Press Break and type STOP. Press Break and type: STATUS *, TERM Find the processor (cpu ) and process number (process ) for the compiler. Type: STOP cpu,process With either method, the supporting processes stop when the compiler stops. Note.
Program Compilation Where Compiler Directives Are Allowed The general form of compiler directives is: On the compiler command line: directive ; , directive VST263.vsd In the program source text: ? directive ; , directive VST264.vsd ? is a source text format indicator (like the asterisk and the slash) and is not part of the compiler directive. The question mark must be in the indicator area (column 1 for Tandem format and column 1 or 7 for ANSI format).
Program Compilation • Categories of Compiler Directives Compiler directive lines cannot occur between the elements of a multiline COPY statement. The syntax of the COPY statement, without the REPLACING phrase, is: COPY . text-name OF library-name IN VST265.vsd If, for example, the word COPY is on one source line and text-name is on a subsequent source line, no compiler directive lines can occur on any intervening source line.
Program Compilation Categories of Compiler Directives Table 11-7.
Program Compilation Categories of Compiler Directives Table 11-9.
Program Compilation Categories of Compiler Directives Table 11-10.
Program Compilation Categories of Compiler Directives Table 11-10. Code-Generation Control Directives (page 3 of 3) Directive(s) Default Action TRAP2-74 and NOTRAP2-741 TRAP2-74 Ignored (warning issued) Specifies that the resulting object code will be in a user library UL Table 11-11.
Program Compilation Categories of Compiler Directives Table 11-12. Miscellaneous Control Directives (page 2 of 2) Directive(s) Default Action HIGHREQUESTERS1 Ignored (warning issued) MAIN Specifies the main program in an input stream NONSTOP1 Specifies program is to run as a process pair PERFORM-TRACE Provides additional information if run-time error 148 occurs.
Program Compilation ANSI ANSI ANSI TANDEM VST266.vsd ANSI specifies that subsequent source text is in ANSI reference format, which is described in Section 16, ANSI Reference Format. TANDEM specifies that subsequent source text is in Tandem reference format, which is described in Reference Format for Source Program Lines.
Program Compilation BLANK and NOBLANK BLANK and NOBLANK BLANK NOBLANK VST267.vsd BLANK adds an implicit VALUE SPACES clause to the description of: • • Every data item in the Working-Storage Section and Extended-Storage Section, except those to which an explicit VALUE clause or an EXTERNAL clause applies Every data item in the File Section, except those to which an EXTERNAL clause applies BLANK increases the size of the object file and can increase execution time.
Program Compilation CALL-SHARED CALL-SHARED CALL-SHARED NON-SHARED SHARED VST802.vsd CALL-SHARED generates shared code (PIC). NON-SHARED has no effect. [For the NMCOBOL compiler, it generates nonshared code (nonPIC)]. SHARED generates shared code (PIC) for a DLL. Default: CALL-SHARED Placement: Anywhere Scope: The last CALL-SHARED or SHARED in the compilation unit applies to the entire compilation unit.
Program Compilation CANCEL and NOCANCEL CANCEL and NOCANCEL CANCEL NOCANCEL VST383.vsd CANCEL generates code that initializes the program the first time the program is called after being canceled by a CANCEL statement. NOCANCEL prevents the generation of code that initializes the program the first time the program is called after being canceled by a CANCEL statement. Default: CANCEL Placement: Anywhere Scope: Applies to the program that contains it.
Program Compilation CHECK Default: CHECK 1 Placement: Anywhere Scope: In each separately compiled program, the last CHECK in the program unit determines the check level for the code block being produced. Dependencies: None Table 11-14. CHECK Levels check-level What is Checked Comments 0 Nothing CHECK 0 results in the fastest execution time. 1 (default) Nothing CHECK 1 might have a different meaning in future versions of HP COBOL.
Program Compilation COLUMNS COLUMNS COLUMNS causes the compiler to ignore any text beyond a certain column in subsequent input records. COLUMNS applies only to text being read under Tandem reference format. Text being read under ANSI reference format ignores any text beyond column 72. COLUMNS length VST270.vsd length is an integer whose value is at least 12. Any value greater than 132 is considered to equal 132.
Program Compilation COMPILE COMPILE COMPILE SYNTAX VST272.vsd COMPILE compiles the program unit and includes its code and data blocks in the target file being created. SYNTAX checks the syntax of the source text. No target file is produced.
Program Compilation CONSULT and NOCONSULT object-name-list object-name , object-name VST274.vsd can be continued onto subsequent lines, but the left parenthesis must appear on the same directive line as the keyword CONSULT. Each continuation line for a CONSULT directive must have a question-mark (?) in the indicator area. If a CONSULT directive spans multiple lines, they must be consecutive (no blank lines, comment lines, or program text lines can intervene).
Program Compilation DIAGNOSE-74 and NODIAGNOSE-74 Default: NOCONSULT Placement: Anywhere Dependencies: None If more than one CONSULT is present, the object names are appended to the list in the order they are read; however, if any object name specified is already in the list, it retains its current position in the list. DIAGNOSE-74 and NODIAGNOSE-74 DIAGNOSE-74 NODIAGNOSE-74 VST277.
Program Compilation DIAGNOSE-74 and NODIAGNOSE-74 Usage Considerations: • Size of Index Data Item A data item within a record description has an explicit USAGE INDEX clause. Indexes occupied two bytes in COBOL 74, but occupy four bytes in HP COBOL. You must convert any files that include records in which index data items occur.
Program Compilation DIAGNOSE-74 and NODIAGNOSE-74 One instance is that of an UNSTRING statement assigning a value through an INTO phrase that does not include a DELIMITER phrase, where the DEPENDING item is within the receiving data structure. COBOL 74 uses the computed size of the receiving item, but HP COBOL uses the maximum size.
Program Compilation 4. 5. 6. 7. 8. 9. DIAGNOSE-74 and NODIAGNOSE-74 Runs y from 2 through 4 Sets x to 3, sets y to the value of x (now 3) Runs y from 3 through 4 Sets x to 4, sets y to the value of x (now 4) Runs y with the value 4 Terminates You must revise the logic of any PERFORM VARYING containing an AFTER phrase that is controlled by the index of the outer loop.
Program Compilation DIAGNOSE-85 and NODIAGNOSE-85 DIAGNOSE-85 and NODIAGNOSE-85 DIAGNOSE-85 NODIAGNOSE-85 VST719.vsd DIAGNOSE-85 causes the ECOBOL compiler to issue warnings when it encounters source constructs that could cause the program to produce different results than it would if it were compiled with the COBOL85 compiler.
Program Compilation DIAGNOSEALL and NODIAGNOSEALL DIAGNOSEALL and NODIAGNOSEALL DIAGNOSEALL NODIAGNOSEALL VST470.vsd DIAGNOSEALL causes the compiler to issue a warning each time it encounters an undefined identifier, even if it already issued a warning for a previous use of that identifier. NODIAGNOSEALL causes the compiler to issue a warning the first time it encounters an undefined identifier, but not if it already issued a warning for a previous use of that identifier.
Program Compilation ENDIF ENDIF ENDIF terminates the effect of a preceding IF or IFNOT directive. ENDIF toggle-number VST278.vsd toggle-number is the toggle-number specified in a preceding IF or IFNOT directive. Default: None Placement: Must be either on a directive line of its own or be the last of a sequence of directives. Dependencies: Requires a preceding IF or IFNOT directive with the same togglenumber References: IF and IFNOT ENDUNIT ENDUNIT signals the end of a program unit.
Program Compilation ERRORFILE ERRORFILE ERRORFILE specifies an error-logging file that is to contain information about any compilation errors or warnings. The error-logging file is not an EDIT file. You can use it only with the FIXERRS Macro. ERRORFILE file-name define-name VST281.vsd file-name is the name of the error-logging file. It must be a disk file name. define-name is the name of a MAP DEFINE that refers to a disk file. The compiler uses this file as the error-logging file.
Program Compilation ERRORS ERRORS ERRORS sets the maximum number of severe errors allowed during compilation. If this limit is exceeded, the compilation terminates. ERRORS error-limit VST282.vsd error-limit is an integer in the range 0 through 32767.
Program Compilation FMAP flag-option Value Elements Identified OBSOLETE Obsolete language elements ABOVEMIN Language elements above the minimum subset ABOVEINTER Language elements above the intermediate subset LEVEL1COM * Communication language elements ABOVELEVEL1COM * Communication language elements above level 1 of communication LEVEL1DEB Debug language elements ABOVELEVEL1DEB * Debug language elements above level 1 of Debug REPORTWRITER * Report Writer language elements LEVEL1SEG Se
Program Compilation HEADING HEADING HEADING replaces or sets to spaces the heading portion of the standard top-of-page line that appears on each page of the compilation listing. HEADING " character-string " VST283.vsd character-string is a string of one or more ASCII characters. If a quotation mark character is part of the string, it must be represented as two contiguous quotation marks. The string is used in all subsequent top-of-page lines.
Program Compilation IF and IFNOT Default: None Placement: Must be either on a directive line of its own or be the last of a sequence of directives Dependencies: Requires a preceding IF or IFNOT directive with the same togglenumber References: IF and IFNOT The toggles are turned on and off by use of the SETTOG and RESETTOG directives. If no SETTOG directive has been issued, a toggle is off. COPY and REPLACE statements are not affected by this directive; they are still processed and expanded.
Program Compilation IF and IFNOT The compiler sees this, depending on the setting of toggles 1 and 2: Toggles On Source Lines Compiled None 01 MASTER-RECORD. 03 HEADER PICTURE X(30). 01 MASTER-RECORD. 03 HEADER 03 ACCOUNT-ID 03 TRAILER PICTURE X(30). PICTURE X(50). PICTURE X(100). 01 MASTER-RECORD. 03 HEADER PICTURE X(30). 1 only 2 only 1 and 2 01 MASTER-RECORD. 03 HEADER PICTURE X(30). 03 ACCOUNT-ID PICTURE X(50). 03 ACCOUNT-ID-REDEF REDEFINES ACCOUNT-ID. 05 ACCOUNT-GROUP PICTURE X(20).
Program Compilation INNERLIST and NOINNERLIST INNERLIST and NOINNERLIST INNERLIST NOINNERLIST VST724.vsd INNERLIST lists, immediately after each source statement, the generated machine instructions in mnemonic form. NOINNERLIST suppresses the listing of generated machine instructions. Default: NOINNERLIST Placement: Anywhere Scope: Applies until its opposite overrides it Dependencies: INNERLIST works only if LIST is active and SUPPRESS is not.
Program Compilation INSPECT and NOINSPECT INSPECT and NOINSPECT INSPECT NOINSPECT VST288.vsd INSPECT turns on the Inspect attribute for the debugging tool for the compilation unit. NOINSPECT turns off the Inspect attribute for the debugging tool for the compilation unit. Default: INSPECT Placement: Anywhere Scope: The last INSPECT or NOINSPECT in the compilation unit applies to the compilation unit. Dependencies: NOINSPECT and SAVEABEND override each other (whichever is last is active).
Program Compilation LIST and NOLIST LIST and NOLIST LIST NOLIST VST291.vsd LIST lists each source image in the output file. NOLIST suppresses the listing of each source image in the output file. Default: LIST Placement: Anywhere Scope: Applies until its opposite overrides it Dependencies: SUPPRESS overrides LIST (and therefore CODE, CROSSREF, ICODE, LMAP, MAP, SHOWCOPY, and SQL). NOLIST suppresses INNERLIST.
Program Compilation MAIN MAIN MAIN identifies the main program unit. MAIN program-name VST294.vsd program-name is the program-name (specified in the PROGRAM-ID paragraph) of the program that is the main entry point of the target file being produced by the compilation. Default: Every program unit that does not have a Linkage Section is compiled as a main program.
Program Compilation MAP and NOMAP MAP and NOMAP MAP NOMAP VST295.vsd MAP lists a symbol table listing, which appears after the source program listing for the program unit (see Symbol Table Listing). NOMAP suppresses the symbol table listing. Default: NOMAP Placement: Anywhere Scope: The last MAP or NOMAP applies. Dependencies: MAP works only if LIST is active and SUPPRESS is not.
Program Compilation NONSTOP NONSTOP Note. Do not use this directive in the OSS environment. NONSTOP causes the compiler to accept the STARTBACKUP verb. The STARTBACKUP and CHECKPOINT verbs enable you to run a program as a process pair. NONSTOP VST296.vsd Default: The program cannot run as a process pair (even if it contains a PARAM NONSTOP ON command). Placement: Must appear before the Identification Division of the first program unit in the source text.
Program Compilation OPTIMIZE OPTIMIZE OPTIMIZE specifies the extent to which the compiler attempts to optimize the code it emits. OPTIMIZE level VST297.vsd level is 0, 1, or 2. Optimization level affects compilation speed. The effect of each level is: Level Effect 0 Code is not optimized. Provided in case other optimization levels cause errors. Supports symbolic debugging; data is always in memory. 1 (default) Code is optimized within statements and across statement boundaries.
Program Compilation PERFORM-TRACE PERFORM-TRACE PERFORM-TRACE gives additional information if run-time error 148, “PERFORM nesting too deep,” occurs. PERFORM-TRACE VST800.vsd If the program was compiled with the PERFORM-TRACE directive and run-time error 148 occurs, this additional information is given: Line numbers of PERFORMs from latest to earliest Line Number File Number llllll.lll nnn ... The file number nnn is the number of the source file.
Program Compilation PORT and NOPORT PORT aligns BINARY/COMPUTATIONAL data items on byte boundaries (unless they are described with the SYNCHRONIZED clause, which aligns them on 2-byte boundaries). PORT also allows the CALL statement in a program to behave as it does in X/Open and XPG4; that is, to call non-COBOL routines, pass parameters by value, and return the values of functions.
Program Compilation • RESETTOG Passing Parameters to Programs Not Compiled With PORT If a program compiled with the PORT directive calls and passes parameters to a program not compiled with the PORT directive (or compiled with the NOPORT directive), serious problems can arise from differences in the way BINARY/COMPUTATIONAL data items are aligned in the two programs. RESETTOG RESETTOG turns off all specified toggles, which are used by the IF directive. RESETTOG toggle-number-list VST298.
Program Compilation RUNNABLE RUNNABLE RUNNABLE causes the compiler to use the linker to produce a loadfile if there are no compilation errors. RUNNABLE VST729.vsd Default: The compiler does not use the linker to produce a loadfile if there are no compilation errors. Placement: Anywhere Scope: Applies to the compilation unit Dependencies: SYNTAX overrides RUNNABLE. You must specify RUNNABLE to use RUNNAMED, SAVEABEND, NOSAVEABEND, or SUBTYPE in the compiler.
Program Compilation RUNNAMED RUNNAMED RUNNAMED specifies that the run unit is to be run as a named process. RUNNAMED VST300.vsd Default: None Placement: Any of: • • Anywhere in a source program In a linker session (specify -change) Scope: Applies to the program in which or before which it appears, to all subsequent programs in the compilation unit, and to all target files Dependencies: RUNNAMED is appropriate only if the program was compiled with RUNNABLE (because a linkfile is not a run unit).
Program Compilation SAVE SAVE Note. Do not use this directive in the OSS environment. SAVE directive specifies which initialization messages are stored for possible program manipulation. SAVE save-option-list ( ) save-option-list VST301.vsd save-option-list save-option , save-option VST302.vsd save-option-list cannot be continued onto subsequent lines, even if it is enclosed in parentheses. save-option PARAM STARTUP ASSIGNS ALL count VST303.
Program Compilation SAVE count is an unsigned integer in the range 1 through 100, an estimate of the number of messages to be saved. The default is 19. The compiler uses count to estimate process data-space requirements for the saved ASSIGN messages. The saved ASSIGN messages are in the data block #CRE_HEAP. If there is not enough space for all the ASSIGN messages held by the command interpreter, the program terminates with a run-time error message. ALL specifies that all messages are to be saved.
Program Compilation SAVEABEND and NOSAVEABEND SAVEABEND and NOSAVEABEND SAVEABEND NOSAVEABEND VST304.vsd SAVEABEND generates a saveabend file if the process terminates abnormally. Sets the Inspect attribute. NOSAVEABEND does not generate a saveabend file if the process terminates abnormally. Default: NOSAVEABEND Placement: Anywhere Scope: The last SAVEABEND or NOSAVEABEND in the compilation unit applies to the entire compilation unit.
Program Compilation SEARCH and NOSEARCH SEARCH and NOSEARCH Note. The compiler ignores the NOSEARCH directive and issues a warning. SEARCH object-name-list ( object-name-list ) NOSEARCH VST305.vsd SEARCH adds the files that object-name-list specifies to the primary search list. (See Primary Search List.) NOSEARCH is ignored. object-name-list object-name , object-name VST306.
Program Compilation SEARCH and NOSEARCH object-name is a name that designates a TNS/E object file—either a file-system file name or (in the Guardian environment) a DEFINE name. In the OSS environment, object-name must be an OSS pathname. If the file-system file name is not fully qualified with system, volume, and subvolume names, the compiler uses the current default system, volume, and subvolume names or those specified by an =_OBJECT_SEARCH DEFINE (see =_OBJECT_SEARCH).
Program Compilation SECTION SECTION SECTION identifies a section of text to be copied from either a COPY library by a COPY statement or from a source library by a SOURCE directive. SECTION text-name , TANDEM ANSI VST307.vsd text-name is a COBOL word (see COBOL Words). TANDEM specifies that subsequent source text is in Tandem reference format, which is described in Reference Format for Source Program Lines.
Program Compilation SETTOG SETTOG SETTOG turns on all specified toggles, which the IF directive uses. SETTOG toggle-number-list VST308.vsd toggle-number-list toggle-number , toggle-number VST299.vsd If toggle-number-list is omitted, all toggles are turned on. toggle-number is an integer in the range 1 through 15. Default: None Placement: Must either be on a directive line of its own or be the last of a sequence of directives.
Program Compilation SHARED SHARED SHARED CALL-SHARED NON-SHARED VST804.vsd SHARED generates shared code (PIC) for a DLL. CALL-SHARED generates shared code (PIC). NON-SHARED is ignored. Default: CALL-SHARED Placement: Anywhere Scope: The last SHARED or CALL-SHARED in the compilation unit applies to the entire compilation unit. Dependencies: References: • • • • • If RUNNABLE is active, SHARED uses the linker to create a PIC library file (DLL); otherwise, SHARED creates a PIC linkfile.
Program Compilation SHOWCOPY and NOSHOWCOPY SHOWCOPY and NOSHOWCOPY SHOWCOPY NOSHOWCOPY VST310.vsd SHOWCOPY displays COPY statements as comments in the listing before the copied text. NOSHOWCOPY suppresses the display of COPY statements. Default: SHOWCOPY Placement: Anywhere Scope: Applies until its opposite overrides it Dependencies: SHOWCOPY works only if LIST is active and SUPPRESS is not.
Program Compilation SHOWFILE and NOSHOWFILE SHOWFILE and NOSHOWFILE SHOWFILE NOSHOWFILE VST311.vsd SHOWFILE displays the identity of the file from which source text is being read under the control of the SOURCE directive. NOSHOWFILE suppresses the display of the identity of the file from which source text is being read under the control of the SOURCE directive.
Program Compilation SOURCE SOURCE SOURCE causes the compiler to begin accepting source text from a different EDIT file. The compiler can read either the entire file or one or more sections of the file (demarcated by SECTION directives). You can also use the predefined SEARCH DEFINEs to specify one or more subvolumes to be searched for unqualified files (see Predefined SEARCH DEFINEs). SOURCE edit-file-name ( section-name-list ) VST312.
Program Compilation SOURCE When the compiler encounters a SOURCE directive, it suspends reading of the current source file and begins reading lines from the specified file. If no section-name list appears, the compiler incorporates the entire file into its stream of source text lines. If a section-name list does appear, the compiler incorporates text from the designated sections only, in the order in which the sections appear within the specified file (not in the order of the list).
Program Compilation SOURCE A SOURCE directive cannot appear anywhere in the text of a COPY statement (between the word COPY and its terminating period in the input stream) or a REPLACE statement (between the word REPLACE and its terminating period in the input stream); however, the compiler detects and reports its appearance within pseudo-text only if that pseudo-text is introduced into the source as the result of expanding the COPY statement or by the editing effects of the REPLACE statement.
Program Compilation SQL and NOSQL During program compilation, the compiler identifies a section by locating the SECTION directive whose text-name matches the section-name specified in the SOURCE directive. SQL and NOSQL Note. The compiler ignores the NOSQL directive and issues a warning. SQL sql-option-list ( sql-option-list ) NOSQL VST315.vsd SQL tells the compiler to expect SQL/MP statements in the compilation unit. NOSQL is ignored. sql-option-list sql-option , sql-option VST316.
Program Compilation SQL and NOSQL RELEASE1 is for the COBOL85 compiler only—see the COBOL Manual for TNS and TNS/R Programs. RELEASE2 causes the compiler to accept only SQL/MP Release 2 features; however, the resulting object file can be executed with SQL/MP Release 350 (or later). If you do not specify RELEASE2, the ECOBOL selects the latest SQL/MP product version (350 or later). PAGES allocates num-pages of memory to the SQL compiler interface for processing SQL/MP statements. Each page is 2048 bytes.
Program Compilation SUBSET SUBSET SUBSET causes the compiler to report in the output listing any source statement that contains syntax that is obsolete or does not conform to the restrictions of a specified subset. SUBSET parameter-list ( parameter-list ) VST319.vsd parameter-list parameter , parameter VST320.vsd You cannot continue parameter-list onto subsequent lines, even if you enclose it in parentheses. parameter HIGH EXTENDED DEB1 SEG1 SEG2 OBSOLETE VST321.
Program Compilation SUBSET DEB1 accepts all syntax defined in level 1 of the Debug module without comment. If DEB1 is not specified, the compiler reports syntax defined in level 1 of the Debug functional module (DEB 1). Syntax defined in level 2 of the Debug module causes the compiler to report an error, because HP COBOL does not support level 2 of this module. SEG1 accepts all syntax defined in level 1 of the Segmentation module (SEG 1) without comment, but reports syntax defined in level 2 (SEG 2).
Program Compilation SUBSET Usage Considerations: • Invalid SUBSET Directives If a SUBSET directive appears in an invalid context, the compiler issues an appropriate message and, after analyzing the directive, ignores it and cancels the effect of any previously accepted SUBSET directive (since an error has occurred). Upon the occurrence of any error, the compiler cancels any active SUBSET directive and discards any messages not yet issued.
Program Compilation SUBTYPE The messages generated in accordance with the SUBSET directive are issued as a block after each separately compiled program. To report ... Use the directive ... Obsolete syntax SUBSET EXTENDED, DEB1, SEG2 Syntax unlikely to be portable SUBSET HIGH, DEB1, SEG2, OBSOLETE SUBTYPE Note. Do not use this directive in the OSS environment. SUBTYPE causes the main program created by the current compilation to execute as a process of a specified subtype.
Program Compilation SUPPRESS and NOSUPPRESS SUPPRESS and NOSUPPRESS SUPPRESS NOSUPPRESS VST324.vsd SUPPRESS overrides the LIST directive, suppressing all compiler listing output except the compiler leader text, diagnostic messages, and the compiler trailer text. NOSUPPRESS overrides the SUPPRESS directive.
Program Compilation SYMBOLS and NOSYMBOLS SYMBOLS and NOSYMBOLS SYMBOLS NOSYMBOLS VST325.vsd SYMBOLS includes a symbol table in the object file used by a symbolic debugger. NOSYMBOLS excludes the symbol table from the object file used by a symbolic debugger.
Program Compilation SYNTAX SYNTAX SYNTAX COMPILE VST326.vsd SYNTAX checks the syntax of the source text. No target file is produced. COMPILE compiles the program unit and included its code and data blocks in the target file being created.
Program Compilation TANDEM TANDEM TANDEM ANSI VST327.vsd TANDEM specifies that subsequent source text is in Tandem reference format, which is described in Reference Format for Source Program Lines. ANSI specifies that subsequent source text is in ANSI reference format, which is described in Section 16, ANSI Reference Format.
Program Compilation WARN and NOWARN WARN and NOWARN WARN NOWARN VST330.vsd WARN reports compilation warnings in the listing. NOWARN suppresses compilation warnings in the listing. Default: WARN Placement: Anywhere Scope: Applies to the compilation unit Dependencies: If LIST is not enabled, the last line of source text processed is also listed to provide a point of reference for each warning message.
Program Compilation WARN and NOWARN HP COBOL Manual for TNS/E Programs —520347-003 11 -94
12 Program Execution This section applies to the Guardian environment. If you are executing HP COBOL programs in the OSS environment, see Running HP COBOL Programs.
Program Execution RUN or RUND Command RUND runs the program with the debugger. program-file is the name of the loadfile to run. program-file can be represented as a filesystem file name or (in the Guardian environment) a DEFINE name. run-option-list run-option , run-option VST332.vsd run-option IN OUT accept-device display-device VST333.vsd is an option of the RUN command, described in the TACL Reference Manual.
Program Execution RUN or RUND Command program-parameter-list program-parameter , program-parameter VST806.vsd program-parameter is a parameter of the program that is to be run. Example 12-1. RUN Commands RUN PROG1 RUN RUNUNIT /IN $TERM1/ RUN MYPROG /OUT =CHECKS-PRINTER/ Usage Considerations: • Effect of Commands on Run-Time Environment Certain run-time commands establish an environment in which the running process operates.
Program Execution ASSIGN Command ASSIGN Command This section applies to programs that were not compiled with the ENV LIBRARY or UL directive. Programs compiled with the ENV LIBRARY or UL directive ignore ASSIGN commands. Note. ASSIGN commands for files in a DLL are ignored. The ASSIGN command creates an ASSIGN message in your current run-time environment.
Program Execution ASSIGN Command cobol-file-name is the COBOL file name in a SELECT clause, also called the fd-name. system-file name #IN #OUT #TERM #TEMP $RECEIVE VST335.vsd name is a spooler location or the name of a disk file, disk volume, tape device, DEFINE, process, or terminal. #IN #OUT #TERM #TEMP $RECEIVE are explained in the usage considerations. They must be uppercase. When only system-file is present, and all other clauses are omitted, the current file for cobol-file-name is assigned.
Program Execution ASSIGN Command size-list pri-extent-size ( ) pri-extent-size , sec-extent-size VST337.vsd specifies the extent size for disk file creation. Extent sizes are specified as a number of file pages to be allocated for one extent of the file. A file page is 2048 bytes of storage. pri-extent-size is an unsigned integer specifying the primary extent size. If EXT is omitted, pri-extent-size defaults to 4. sec-extent-size is an unsigned integer specifying the secondary extent size.
Program Execution ASSIGN Command block-size is an integer accepted by TACL as specifying block size. block-size determines the block size. Note. To see what ASSIGN commands are currently in force, enter just ASSIGN followed by a carriage return.
Program Execution PARAM Command The temporary file in Example 12-3 is purged when it is closed. Example 12-3. ASSIGN Command With Special COBOL Names 11>ASSIGN REPORT-OUT, $TERM4 12>RUN MYPROG 13>ASSIGN IN-MASTER,$DATA.ZZ.INFILE 14>RUN MYPROG1 15> 16>ASSIGN INPUT-FILE, #IN 17> == FD INPUT-FILE is the == file named in the == IN option. 18> 19>ASSIGN WORK-FILE, #TEMP 20> == FD WORK-FILE is to be == a temporary disk file == on the default volume.
Program Execution PARAM Command PARAM name-value-pair , name-value-pair VST338.vsd name-value-pair is one of the name-value pairs recognized by the run-time routines, or a userdefined parameter name and value: SWITCH-nn ON DEBUG OFF NONSTOP INSPECT WAITED-IO EXECUTION-LOG system-file-name define-name * TAPE-DIALOGUE ON OFF PRINTER-CONTROL parameter-name cobol-file-name parameter-value VST339.vsd SWITCH-nn sets (ON) or clears (OFF) the specified switch.
Program Execution PARAM Command NONSTOP controls whether or not a process runs as a process pair, provided that the NONSTOP directive was included in the compilation of the program. For information on using process pairs, see Section 32. If the program was compiled with the NONSTOP directive, the process runs as a process pair unless you use the PARAM NONSTOP OFF command. If this switch is set OFF, no checkpointing or backup creation occurs, and PROGRAM-STATUS is always set to “0000.
Program Execution PARAM Command TAPE-DIALOGUE is ignored. PRINTER-CONTROL specifies that the operating environment must return control to the program when the printer specified by the cobol-file-name is not ready or is out of paper. cobol-file-name is the FD name of a file in a COBOL program (not the operating system file name or a DEFINE name).
Program Execution PARAM Command The EXECUTION-LOG parameter provides a means of redirecting such unintentional input-output activity from the home terminal to another device, called the execution log file. The EXECUTION-LOG parameter can also redirect unintentional input-output activity from #IN and #OUT to the execution log file. In the absence of an EXECUTION-LOG parameter, the execution log file is the home terminal. If the EXECUTION-LOG parameter specifies asterisk (*), such output is discarded.
Program Execution PARAM Command If the access mode is write, the run-time routines use a WRITE request for all messages. Those requiring a response are assumed to have a response of end of file. If the device is a process, the process is responsible for analyzing the messages to determine if an operator response is needed.
Program Execution PARAM Command To make use of the PRINTER-CONTROL parameter, the application program must use a declarative procedure, preferably one of the form USE AFTER STANDARD ERROR PROCEDURE ON CHEX that responds only to errors on the printer file. The procedure receives control when the operating environment detects the printer problem. The procedure determines that the printer’s I-O status code is “30” and handles the GUARDIAN-ERR values of 100 and 102.
Program Execution ° CLEAR Command The compiler makes use of certain parameters and their values in performing the compilation (see PARAM Commands). For more information on the PARAM command, see the TACL Reference Manual. Example 12-4. PARAM Command 85> 86> 87> 88> 89> == Set the DEBUG switch, and set SWITCH-02 PARAM DEBUG ON, SWITCH-02 ON == Set user parameter THEDATE PARAM THEDATE 1991DEC02 == Route home terminal messages to a file 90> 91> 92> 93> 94> ... 99> PARAM EXECUTION-LOG $ARK.GKH.
Program Execution CLEAR Command ALL means clear all currently active ASSIGN and PARAM references. ALL ASSIGN means clear all currently active ASSIGN references. ALL PARAM means clear all currently active PARAM references. ASSIGN means clear the reference to the specified COBOL file name. assignation COBOL-file-name program-name . * VST638.vsd specifies what is to be cleared. COBOL-file-name is the COBOL name of a file. program-name is the name of the COBOL program that contains COBOL-file-name.
Program Execution DEFINEs Example 12-5. CLEAR Command 43>CLEAR 44>CLEAR 45>CLEAR 46>CLEAR 47>CLEAR ALL ALL ASSIGN ALL PARAM ASSIGN in-file PARAM DEBUG { { { { { Clears Clears Clears Clears Clears all ASSIGN and PARAM values } all ASSIGN values } all PARAM values } assignment for in-file only } the DEBUG switch } DEFINEs A DEFINE is a named set of attribute/value pairs. DEFINEs are similar to ASSIGN messages, but more versatile. DEFINEs involve too many commands to be described completely here.
Program Execution Controlling the Propagation of DEFINEs Table 12-1. Differences Between DEFINE and ASSIGN (page 2 of 2) DEFINE ASSIGN Not accepted by FastSort SQL/MP or SQL/MX No Available from OSS environment Yes, but it can be used only to access a Guardian disk file, tape device, or spooler location The statements of a COBOL program refer to files through a COBOL file name.
Program Execution DEFINE Names DEFINE Names Every DEFINE has a name. A name you give to a DEFINE must: • • • Consist of at least 2 and no more than 24 characters Begin with an equals sign (=) followed by a letter Continue with any combination of letters, digits, hyphens (-), underscores (_), and carets (^). HP has reserved the set of DEFINE names beginning with equals sign followed by underscore (_) for future use. Example 12-6.
Program Execution DEFINE Attributes Table 12-2.
Program Execution ADD DEFINE Command To create a DEFINE, you must: 1. Set the value of its CLASS attribute (use the SET DEFINE CLASS command in your command interpreter) 2. Give values to its other attributes For details, see the TACL Reference Manual. Usage Considerations: • TAPE DEFINE Provides the Only Way to Use Labeled Tapes For details, see Section 25, Executing and Debugging HP COBOL Programs, and the Guardian User’s Guide.
Program Execution Initial State Initial State Every program in a run unit has an initial state in which a process places it at certain times while the run unit executes. When a program is in its initial state: • • • • • • Each data item in the Linkage Section has the value specified by the calling program. Each Working-Storage or Extended-Storage data item that is described with a VALUE clause (except level-88 condition-names) has the specified value.
Program Execution Status of Internal Entities During Program Execution Status of Internal Entities During Program Execution During the execution of a program, each internal entity retains the status in which it was left by the execution of the last statement that affected its status: • • • • Each internal data item retains the last value assigned to it. If no new value has been assigned since the last time the program was placed in its initial state, its “last value” is its initial value.
Program Execution Called Program Termination When a called program that has the initial attribute terminates its own execution, an implicit CANCEL statement referencing the program is executed just after control passes from the called program. This causes the value of each internal data item to become undefined and performs an implicit close operation for each internal file connector that is not closed (with or without lock).
13 Libraries and Utility Routines Utility routines are in dynamic-link libraries (DLLs) named ZCOBDLL and ZCREDLL. (You can also create a user library for a HP COBOL program.) If a program calls a utility routine, the ECOBOL compiler automatically searches the DLLs for the routine, but the routine is not bound into the program’s target file. Programs can call dynamic-link libraries (DLLs), which you can build. Note. In this section, references to $SYSTEM apply only to the NonStop system.
Libraries and Utility Routines Table 13-1.
Libraries and Utility Routines Memory Areas Memory Areas The memory a COBOL process uses is divided into distinct areas, each holding code blocks or data blocks for the COBOL run unit or for Guardian environment routines that serve the run unit. Table 13-2. Memory Area Characteristics Memory Area Purpose Size Comments User code space Holds code blocks produced by the compilation 256 megabytes Routines from loadfiles execute here. User data space Holds data blocks produced by the compilation 1.
Libraries and Utility Routines Dynamic-Link Libraries (DLLs) Dynamic-Link Libraries (DLLs) A DLL is a library of shared code [PIC] that contains functions or data for other PIC loadfiles. (For more information about PIC and DLLs, see the DLL Programmer’s Guide for TNS/E Systems.) You can put a program in a DLL if: • • • It is not a main program. It does not contain embedded SQL/MP or SQL/MX statements.
Libraries and Utility Routines • • • • Building a DLL From a Single Source File OSS Environment: One-Step Method OSS Environment: Two-Step Method PC Environment: One-Step Method PC Environment: Two-Step Method Guardian Environment: One-Step Method Compile the source file with these directives: • • • SHARED RUNNABLE ELD with either of these options: ° ° -export_all, which exports all program names in the source file -export program-name, which exports only the specified program name.
Libraries and Utility Routines Building a DLL From a Single Source File In Example 13-2, the first command compiles the source file LIB1, creating the linkable object file LIB1O. The second command links LIB1O with the DLLs named ZCOBDLL and ZCREDLL, creating a DLL named MYDLL. Example 13-2.
Libraries and Utility Routines • Building a DLL From a Single Source File -optional_lib -l ZCOBDLL -l ZCREDLL, which links your file with the DLLs named ZCOBDLL and ZCREDLL The resulting loadfile is a DLL. In Example 13-4, the first command compiles the source file lib1.cob, creating the linkable object file lib1.o. The second command links lib1.o with the DLLs named ZCOBDLL and ZCREDLL, creating a DLL named mydll. Example 13-4. Building a DLL From a Single Source File in Two Steps (OSS) ecobol lib1.
Libraries and Utility Routines Building a DLL from Multiple Source Files 2. Link the linkfile, using the eld utility with these options: • Either: ° ° • -export_all, which exports all program names in the source file -export program-name, which exports only the specified program name. You must repeat this option for every program name that you want to export. -optional_lib followed by: ° -L lib-directory -lcob, which links your file with the DLL named ZCOBDLL ° -obey lib-directory\libc.
Libraries and Utility Routines Building a DLL from Multiple Source Files Guardian Environment 1. Compile each source file with the directive SHARED. Note. Do not use the RUNNABLE directive. The result of each compilation is a linkfile. 2. Link the linkfiles into a single loadfile, using the eld utility with these options: • Either: ° ° • • -export_all, which exports all program names in the source file -export program-name, which exports only the specified program name.
Libraries and Utility Routines Building a DLL from Multiple Source Files 2. Link the linkfiles into a single loadfile, using the eld utility with these options: • Either: ° ° • • -export_all, which exports all program names in the source file -export program-name, which exports only the specified program name. You must repeat this option for every program name that you want to export.
Libraries and Utility Routines • Specifying a DLL -optional_lib followed by: ° -L lib-directory -lcob, which links your file with the DLL named ZCOBDLL ° -obey lib-directory\libc.obey, which links your file with the DLL named ZCREDLL lib-directory is the name of the directory of libraries. In Example 13-9, the first four commands compile four source files (lib1.cob, lib2.cob, lib3.cob, and lib4.cob), creating four linkable object files (lib1.o, lib2.o, lib3.o, and lib4.o).
Libraries and Utility Routines • Specifying a DLL ELD with these options: ° ° -L (which is similar to the ecobol option -L) -l or -lib (which is similar to the ecobol option -l) For more information about the eld options -l or -lib, see the eld Manual. The result is a loadfile. The command in Example 13-10 compiles the source file MAIN and links the resulting object file with the DLL named MYDLL, creating a loadfile named MAINO. Example 13-10.
Libraries and Utility Routines Specifying a DLL OSS Environment: Compile and Link in One Step Compile the program that uses the DLL with these options: • • • -Wcall_shared -L -l Note. Do not use -c. The result is a loadfile. The command in Example 13-12 compiles the source file main.cob and links the resulting object file with the DLL named mydll, creating the loadfile main.exe. Example 13-12. Specifying a DLL When the Compiler Calls the Linker (OSS) ecobol main.
Libraries and Utility Routines Specifying a DLL PC Environment: Compile and Link in One Step Compile the program that uses the DLL with these ecobol flags: • • • • -Wcall_shared -Wcobol with the argument “CONSULT MYDLL” -L, where directory is the name of the directory of libraries -l, where library is the name of the DLL Note. Do not use -c. The result is a loadfile. The command in Example 13-14 compiles the source file main.
Libraries and Utility Routines Files of Dummy Routines For more information about the eld options -l or -lib, see the eld Manual. In Example 13-15, the first command compiles the source file main.cob, specifying the DLL named MYDLL and creating the linkable object file main.o. The second command links main.o with mydll and the DLLs named ZCOBDLL and ZCREDLL, creating the loadfile main.exe. MYDLL is in dll-location. (An example of dlllocation is C:\xxx\yyy.) Example 13-15.
Libraries and Utility Routines Establishing Parameters With FastSort Interface Routines Topics: • • Establishing Parameters With FastSort Interface Routines Establishing Parameters With =_SORT_DEFAULTS DEFINE For descriptions of individual FastSort interface routines, see ZCOBDLL Routines. Establishing Parameters With FastSort Interface Routines One way to establish FastSort parameters is with the FastSort interface routines. Table 13-5.
Libraries and Utility Routines ZCOBDLL Overview You can create a =_SORT_DEFAULTS DEFINE by using the ALTER DEFINE statement in your command interpreter. You can use the command 22> INFO DEFINE =_SORT_DEFAULTS, DETAIL to determine whether the DEFINE exists and what its current settings are. You cannot use =_SORT_DEFAULTS to alter the FastSort parameters SCRATCH and MODE, because the compiler sets these itself whenever it executes a COBOL SORT statement.
Libraries and Utility Routines Saved Message Utility (SMU) Overview Table 13-6. ZCOBDLL Routines (page 2 of 2) Utility Routine COBOL_SET_SORT_PARAM_VALUE_ COBOL_SPECIAL_OPEN_1 COBOLFILEINFO2 1. Replaces COBOLSPOOLOPEN routine (for level 2 spooling) and Guardian environment routines (for level 3 spooling) 2. Guardian environment only For descriptions of individual ZCOBDLL routines, see Non-SMU Routines.
Libraries and Utility Routines Saved Message Utility (SMU) Overview Figure 13-1. Effect of Saved Message Utility (SMU) Routines Startup Message (IN, OUT, default volume and subvolume) ASSIGNs (fd-name = actual-file-name) PARAMs (name and associated value) "Parent" COBOL process Saves the messages Modifies the messages Saved Messages Uses CREATEPROCESS to launch a new process that has customtailored ASSIGN, PARAM, and startup messages Descendent Process VST521.vsd Table 13-7.
Libraries and Utility Routines Saved Message Utility (SMU) Overview The SMU consists of these routines. For complete descriptions of these routines, see the CRE Programmer’s Guide.
Libraries and Utility Routines ZCREDLL Overview Table 13-8. Portions of the ASSIGN Message (page 2 of 2) Portion What It Identifies Portion Type FILECODE File code Integer message portion EXCLUSION Exclusion mode Integer message portion ACCESS Access mode Integer message portion RECSIZE Record size Integer message portion BLKSIZE Block size Integer message portion Table 13-9.
Libraries and Utility Routines • • • • • ZCOBDLL Routines SMU_Param_GetText_ SMU_Param_PutText_ SMU_Startup_Delete_ SMU_Startup_GetText_ SMU_Startup_PutText_ CLU_PROCESS_CREATE_ is available in the Guardian and OSS environments, but the SMU routines are available only in the Guardian environment. For information about individual ZCREDLL routines, see the CRE Programmer’s Guide.
Libraries and Utility Routines COBOL_COMPLETION_ COBOL_COMPLETION_ The COBOL_COMPLETION_ routine passes completion parameters to either the STOP or ABEND routine in the operating environment (depending on the abend-orstop parameter). ns ENTER " ns COBOL_COMPLETION_ " TAL OF library-reference USING abend-or-stop completion-code termination-info subsys-id text VST343.vsd library-reference is a mnemonic-name in the SPECIAL-NAMES paragraph.
Libraries and Utility Routines COBOL_COMPLETION_ termination-info is a numeric operand, the evaluation of which includes truncation as necessary to an integer result with a value in the range of -32,768 through 32,767. If this parameter is present, the value is passed to STOP or ABEND as the termination-info parameter for that routine. subsys-id is a data item occupying at least twelve character positions.
Libraries and Utility Routines COBOL_CONTROL_ COBOL_CONTROL_ The COBOL_CONTROL_ routine controls device-dependent I-O operations through a call to the Guardian environment routine CONTROL. If a no-waited, input-output request is active when the COBOL_CONTROL_ routine is called, the request is completed before the CONTROL routine is called. If the file is closed when the call is made, the request is queued until the next OPEN request for the file is issued. Caution.
Libraries and Utility Routines COBOL_CONTROL_ cpinfo is a checkpoint list in which the routine records the changes to the message storage data space, for example: 01 CP-LIST-1. 05 MAX-COUNT 05 CURRENT-COUNT 05 ELEMENT PIC 9999 PIC 9999 PIC 9(9) COMP COMP COMP VALUE IS 100. VALUE IS 0. OCCURS 100 TIMES. The initial value of MAX-COUNT must be the same as the number of occurrences of ELEMENT. The maximum number of elements that cpinfo can contain is the initial value of MAX-COUNT divided by 2.5.
Libraries and Utility Routines COBOL_GETENV_ COBOL_GETENV_ The COBOL_GETENV_ routine returns the value of a specified environment variable. ns ENTER " ns COBOL_GETENV_ USING env-var GIVING length " return-value VST722.vsd env-var is the name of the environment variable whose value is to be returned. It cannot have trailing spaces or a zero-byte terminator. return-value is the name of the variable that will hold the returned value of env-var.
Libraries and Utility Routines COBOL_PUTENV_ COBOL_PUTENV_ The COBOL_PUTENV_ routine sets a specified environment variable to a specified value. ENTER " ns COBOL_PUTENV_ USING env-var GIVING return-value ns " VST723.vsd env-var is the name of the environment variable whose value is to be set. It cannot have trailing spaces or a zero-byte terminator. return-value is zero if the value of env-var was successfully set, nonzero if the value of envvar was not set because of insufficient heap space.
Libraries and Utility Routines COBOL_RETURN_SORT_ERRORS_ sd-name is the COBOL name of a file defined in an SD entry. The specification of the remaining parameter is applied to any subsequent SORT or MERGE statements that refer to this file name. If a subsequent call to the same routine refers to the same sd-name, that call resets the specifications for any subsequent SORT or MERGE statements that refer to the same file name.
Libraries and Utility Routines COBOL_REWIND_SEQUENTIAL_ If the sort/merge routines do detect an error, the HP COBOL run-time routines terminate execution of the sort process and return to the program with the fields of error-info set to the values returned by the sort/merge routines. The HP COBOL run-time routines do not produce error messages of their own (they typically go to the home terminal), and no recovery is possible.
Libraries and Utility Routines COBOL_REWIND_SEQUENTIAL_ return-code is an identifier of a numeric data item in which an error value will be returned. The expected values and their respective meanings are: Value Meaning 0 Successful execution 1 file-name is missing or is invalid. 5 An operation error occurred (for example, the file could not be rewound).
Libraries and Utility Routines COBOL_SET_SORT_PARAM_TEXT_ COBOL_SET_SORT_PARAM_TEXT_ The COBOL_SET_SORT_PARAM_TEXT_ routine establishes alphanumeric parameters in the option block (the local list of parameters that HP COBOL passes to FastSort for the next sort or merge operation). ENTER OF " ns COBOL_SET_SORT_PARAM_TEXT_ ns " library-reference USING sd-name param-id param-text subsort-number GIVING return-code VST811.vsd library-reference is a mnemonic-name in the SPECIAL-NAMES paragraph.
Libraries and Utility Routines COBOL_SET_SORT_PARAM_TEXT_ param-text is the identifier of an alphanumeric data item whose contents is used for the parameter specified by param-id. If this parameter is omitted, any text previously set for this value of param-id is reset to its default value. The value of param-text depends on the value of param-id and sometimes on the value of subsort-number (see Table 13-11).
Libraries and Utility Routines COBOL_SET_SORT_PARAM_TEXT_ Table 13-11. Relationship Between param-id, subsort-number, and paramtext (page 1 of 2) param-id subsort-number param-text CPU-MASK Unspecified or 0 Contains a string of zeros and ones, with a maximum of 16 characters. The value of each character indicates whether a processor is to be used for subsort processes for a parallel sort. The leftmost character corresponds to processor 0, the next to 1, and so on, up to processor 15.
Libraries and Utility Routines COBOL_SET_SORT_PARAM_TEXT_ Table 13-11. Relationship Between param-id, subsort-number, and paramtext (page 2 of 2) param-id subsort-number SWAP-FILE param-text File-system file name of the file to be used for the extended memory swap file (must be on the local system). If the name is all spaces (the default value) or is not specified, the swap file is created on the same volume as the scratch file. If the scratch file is not local, the swap file is assigned on $SYSTEM.
Libraries and Utility Routines COBOL_SET_SORT_PARAM_VALUE_ COBOL_SET_SORT_PARAM_VALUE_ The COBOL_SET_SORT_PARAM_VALUE_ routine establishes numeric parameters in the option block. These parameters affect any subsequent SORT statement execution. " ENTER OF ns ns COBOL_SET_SORT_PARAM_VALUE_ " library-reference USING sd-name param-id param-value GIVING subsort-or-file-number return-code VST811.vsd library-reference is a mnemonic-name in the SPECIAL-NAMES paragraph.
Libraries and Utility Routines COBOL_SET_SORT_PARAM_VALUE_ param-id is an alphanumeric data item whose contents identify the parameter whose value is to be set.
Libraries and Utility Routines COBOL_SET_SORT_PARAM_VALUE_ return-code is an identifier of a numeric data item in which an error value will be returned. The expected values and their respective meanings are: Value Meaning 0 The call was correct. 1 The file-name does not name a sort-merge file. 2 The param-id does not have one of the allowed values. 3 The param-value is outside the allowed range.
Libraries and Utility Routines ° COBOL_SET_SORT_PARAM_VALUE_ CPU specifies a processor in which the sort or subsort is to occur. Allowable Value for param-value -1 Meaning If the param-value associated with SUBSORT-COUNT is 0 or has not been specified, the sort process selects a processor.
Libraries and Utility Routines COBOL_SET_SORT_PARAM_VALUE_ subsort-or-file-number must not be specified or must be 0. ° DATA-SLACK specifies a percentage of slack space in each data block for an indexed output file. It is applicable only if one GIVING file is specified and that file is an indexed file. The value of param-value is in the range 0 through 99. The default is 0. subsort-or-file-number must not be specified or must be 0.
Libraries and Utility Routines COBOL_SET_SORT_PARAM_VALUE_ If subsort-or-file-number specifies a file-number, it must be in the range 1 through 32. The number is the ordinal number of a USING file (from left to right in the USING phrase of the next SORT statement that is executed). If subsort-or-file-number is omitted, the first file is assumed. ° INDEX-SLACK specifies a percentage of slack space in each index block for an indexed output file.
Libraries and Utility Routines ° COBOL_SET_SORT_PARAM_VALUE_ NOPURGE-OUTPUT specifies whether FastSort is to purge an existing output (GIVING) file if it seems too small. Allowable Value for param-value Meaning 0 (default) FastSort purges an existing GIVING file that seems too small before writing the new data to it. nonzero FastSort does not purge an existing GIVING file that seems too small unless it has the wrong file type or wrong record length.
Libraries and Utility Routines ° COBOL_SET_SORT_PARAM_VALUE_ OUT-FILE-FORMAT specifies the format of the output file. Allowable values are 0, 1, 2, and 3. The default value is 0. See the FastSort Manual for details. This parameter may cause problems if the record area is not large enough or too large. Use it with caution. subsort-or-file-number must not be specified or must be 0. ° PRIORITY specifies the desired execution priority of the sort or subsort process.
Libraries and Utility Routines COBOL_SET_SORT_PARAM_VALUE_ subsort-or-file-number must not be specified or must be 0. ° SCRATCH-BLOCK specifies the size of the input and output blocks for the scratch file. Allowable Value for param-value Meaning -1 (default) FastSort chooses a default block size depending on the type of disk on which the scratch file resides.
Libraries and Utility Routines ° COBOL_SET_SORT_PARAM_VALUE_ SECOND-BUFFER specifies whether FastSort must use a second buffer. Allowable Value for param-value Meaning 0 (default) FastSort does not use a second buffer. nonzero FastSort uses a second buffer, which is allocated in user data space. SECOND-BUFFER is ignored under any of these conditions: • • • There is not enough space for a second buffer. NOWAIT-IO is not specified.
Libraries and Utility Routines ° COBOL_SET_SORT_PARAM_VALUE_ SUBSORT-COUNT specifies the number of parallel sorts that FastSort is to use to improve performance. Allowable Value for param-value Meaning 0 (default) FastSort uses normal, non-parallel sort. 2-8 FastSort uses parallel sort, and the value of param-value is the number of processes to be used. (A parallel sort might be faster, but it uses more system resources. In a busy system, this might cause an overall loss in system throughput.
Libraries and Utility Routines COBOL_SET_MAX_RECORD_ COBOL_SET_MAX_RECORD_ The COBOL_SET_MAX_RECORD_ routine sets the maximum record size in the COBOL internal file block. This routine is typically used to allow one file description (FD) to be used to write and read files whose maximum record lengths are less than or equal to that specified in the COBOL program.
Libraries and Utility Routines COBOL_SET_MAX_RECORD_ return is a variable into which the routine places a value indicating the success of the operation: Value Meaning 0 The operation was successful. 1 The first parameter is missing. 2 One of these occurred: • • The first parameter is not a file-name of an FD. The second parameter is greater than 4095. 3 The second parameter has been omitted and no file exists from which to obtain the record length. 5 The file is not closed.
Libraries and Utility Routines COBOL_SETMODE_ COBOL_SETMODE_ The COBOL_SETMODE_ routine sets device-dependent functions using a call to the Guardian environment routine SETMODE. If a NOWAIT input-output request is active when the COBOL_SETMODE_ routine is called, the request is completed before the SETMODE routine is called. If the file is closed when the call is made, the request is queued until the next OPEN request for the file is issued. Caution.
Libraries and Utility Routines COBOL_SETMODE_ function is a numeric data item or arithmetic expression that is the function parameter of the Guardian environment routine SETMODE. For more information, see the Guardian Procedure Calls Reference Manual. param-1 param-2 are numeric data items or arithmetic expressions that are the param1 and param2 parameters of the Guardian environment routine SETMODE. For more information, see the Guardian Procedure Calls Reference Manual.
Libraries and Utility Routines COBOL_SPECIAL_OPEN_ error-return is a numeric data item that has one of these values upon completion: Value Meaning n The call to SETMODE caused Guardian file error n. 0* No error occurred. 1 A required parameter is missing. 2 file-name is not a COBOL file name. 5 One of: • • file-name specifies an open file that is either $RECEIVE or is open for HP COBOL Fast I-O.
Libraries and Utility Routines COBOL_SPECIAL_OPEN_ Any other value for open-type causes an error. Printers or Spoolers When the parameter open-type has the value 1, the COBOL_SPECIAL_OPEN_ routine opens a line printer or a print spooler collector. Unlike the COBOLSPOOLOPEN routine, COBOL_SPECIAL_OPEN_ allows parameters to be defined in the Extended-Storage Section.
Libraries and Utility Routines COBOL_SPECIAL_OPEN_ file-name is the name of a COBOL data file; that is, a file described in a File Description entry. It must be an FD name associated with a file-system file name that specifies a line printer (device type 5) or a spooler collector (device type 0, subdevice type 31). open-type is a numeric operand whose value (after truncation to an integer value, if necessary) is 1. The value 1 (the default) signifies the opening of a line printer or a spooler collector.
Libraries and Utility Routines COBOL_SPECIAL_OPEN_ location is a 16-character alphanumeric, PIC X(16), that identifies the string passed to the spooler as its location parameter. The data item must be at least 16 characters. If longer, only the first 16 characters are passed to the spooler. The spooler expects a two-part location name in the format #gggggggdddddddd where #ggggggg is the group name and dddddddd is the destination name. The pound sign (#) is required.
Libraries and Utility Routines COBOL_SPECIAL_OPEN_ flags is a numeric operand that specifies certain attributes of the job. The evaluation of this operand includes, if necessary, truncation to an integer value. The value is represented as a 16-bit integer: Bits Contents 0 Reserved 1 ASCII compression flag (0 = OFF, 1 = ON). Ignored if code-129 is omitted. See the description of code-129 for more information.
Libraries and Utility Routines COBOL_SPECIAL_OPEN_ code-129 is a numeric operand that specifies whether a code 129 file (spooler job file) is to be created or a regular spooler file is to be created. A nonzero value indicates that the run-time library is to call SPOOLSTART with file-name reflecting the name specified in the ASSIGN phrase of the SELECT clause for the file or by an ASSIGN TACL command.
Libraries and Utility Routines COBOL_SPECIAL_OPEN_ In the Guardian environment, all the functions of this form of COBOL_SPECIAL_OPEN_ except those provided by the parameters no-eject, code-129, and form-feed can also be provided by a DEFINE of class SPOOL, but COBOL_SPECIAL_OPEN_ brings the functionality into the program, while the DEFINE solution leaves it out in the run-time environment.
Libraries and Utility Routines COBOL_SPECIAL_OPEN_ library-reference is a mnemonic-name in the SPECIAL-NAMES paragraph. This mnemonic-name is associated with the DLL containing an object copy of COBOL_SPECIAL_OPEN_. file-name is the name of a COBOL data file; that is, a file described in a File Description entry. It must be an FD name associated with a file-system file name that specifies a system log (device type 1, subdevice type 0 or 1).
Libraries and Utility Routines COBOL_SPECIAL_OPEN_ return-code is an identifier of a numeric data item in which an error value will be returned. The expected values and their respective meanings are: Value Meaning 0 Successful execution 1 file-name is missing or is invalid, or an extraneous parameter is present. 2 The value of the open-type, exclusion, or sync-depth parameter is invalid. 4 The device-type of the file specified is not compatible with the value specified for open-type.
Libraries and Utility Routines COBOL_SPECIAL_OPEN_ library-reference is a mnemonic-name in the SPECIAL-NAMES paragraph. This mnemonic-name is associated with the DLL containing an object copy of COBOL_SPECIAL_OPEN_. file-name is the name of a COBOL data file; that is, a file described in a File Description entry. It must be an FD name associated with a file-system file name that specifies a disk file (device type 3).
Libraries and Utility Routines COBOL_SPECIAL_OPEN_ return-code is an identifier of a numeric data item in which an error value will be returned. The expected values and their respective meanings are: Value Meaning 0 Successful execution 1 file-name is missing or is invalid, or an extraneous parameter is present. 2 The value of the open-type, exclusion, or sync-depth parameter is invalid. 4 The device-type of the file specified is not compatible with the value specified for open-type.
Libraries and Utility Routines COBOL_SPECIAL_OPEN_ Tape Files When the parameter open-type has the value 4, the COBOL_SPECIAL_OPEN_ routine opens a tape file ns ENTER OF ns COBOL_SPECIAL_OPEN_ " " library-reference USING file-name open-type = 4 exclusion sync-depth time-limits open-mode mount-messages end-of-tape-process GIVING return-code VST614.vsd library-reference is a mnemonic-name associated in the SPECIAL-NAMES paragraph with the DLL containing an object copy of COBOL_SPECIAL_OPEN_.
Libraries and Utility Routines COBOL_SPECIAL_OPEN_ exclusion is a numeric operand that specifies the exclusion attribute for the open operation. The evaluation of this operand includes, if necessary, truncation to an integer value. If the parameter is present, its value must be 0 (shared), 1 (exclusive), or 3 (protected).
Libraries and Utility Routines Non-SMU Routines end-of-tape-process is an alphanumeric data item of at least seven characters, whose value specifies the action to be taken if the file operation causes a reel swap. If the value is “RETURN ” (in any combination of uppercase and lowercase letters and with a space after N ), a read or write operation returns an I-O status code of “97” and a GUARDIAN-ERR of 150 when a reel swap occurs.
Libraries and Utility Routines COBOL_ASSIGN_ COBOL_ASSIGN_ The COBOL_ASSIGN_ routine enables an HP COBOL program to perform an ASSIGN-like statement while the program is executing. It associates a COBOL file name (fd-name ) with a file-system file name. You must declare the COBOL file name as dynamically assignable in a file-control entry in the Input-Output Section. The syntax for this declaration is: SELECT fd-name OPTIONAL ASSIGN #DYNAMIC TO VST355.
Libraries and Utility Routines COBOL_ASSIGN_ After fd-name is declared as dynamically assignable, the HP COBOL program can use ENTER to call COBOL_ASSIGN_. The general form of the ENTER statement to use COBOL_ASSIGN_ is: ns ENTER OF ns COBOL_ASSIGN_ " " library-reference USING fd-name system-file-name file-code file-type GIVING error-number VST356.
Libraries and Utility Routines COBOL_ASSIGN_ If the program identifies system-file-name as an OSS file system name, then the program assumes that fd-name is an OSS file; otherwise, the program assumes that fd-name is a Guardian file. If system, volume, or subvolume of a Guardian file is not specified, the respective default value is used ($volume.file is no longer allowed.) If system-file-name is omitted, COBOL_ASSIGN_ does not change the original file-system file name.
Libraries and Utility Routines COBOL_ASSIGN_ COBOL_ASSIGN_ does not determine whether the assigned file actually exists or is accessible. This checking is done by the OPEN statement. COBOL_ASSIGN_ can be called repeatedly for one fd-name. An attempt to open a file using a dynamically assignable fd-name before COBOL_ASSIGN_ has been used on it is an attempt to open $volume.#DYNAMIC (where $volume is the default volume). This causes a run-time error.
Libraries and Utility Routines COBOLFILEINFO COBOLFILEINFO The COBOLFILEINFO routine is for the Guardian environment. In the OSS environment, use the COBOL_FILE_INFO_ routine. The COBOLFILEINFO routine is for these situations: • • An application needs to perform some operation not defined in HP COBOL on a file normally managed by the HP COBOL run-time routines. This application must obtain the file system file number assigned when the file was opened.
Libraries and Utility Routines COBOLFILEINFO error-code is a numeric data item described as USAGE COMPUTATIONAL PICTURE 9999 (or S9999)or USAGE NATIVE-2. The COBOLFILEINFO routine returns the last file system file-system error code to this data item. The value returned is always positive. The access mode (see Linkage Section) of error-code must be STANDARD. file-name is a DISPLAY data item of at least 24 characters where the actual 24-byte internal file name is returned.
Libraries and Utility Routines COBOL_FILE_INFO_ COBOL_FILE_INFO_ The COBOL_FILE_INFO_ routine is for both the OSS and Guardian environments. The COBOL_FILE_INFO_ routine is for these situations: • • An application needs to perform some operation not defined in HP COBOL on a file normally managed by the HP COBOL run-time routines. This application must obtain the file system file number assigned when the file was opened.
Libraries and Utility Routines COBOL_FILE_INFO_ name-buffer is the buffer in which the file name is returned. To accommodate the maximum file name size, name-buffer must hold at least 1023 characters. To accommodate the largest Guardian file name, name-buffer must be at least 35 characters. If name-buffer is too short for the file name, the file name is truncated. If the file name is an OSS file, the terminating zero byte is included in the name and in the name size.
14 Intrinsic Functions An intrinsic function is a function that your program can use, but does not need to declare. It returns a value that is computed at the time of reference during the execution of the object program. Like an identifier, an intrinsic function has a class and category, and you can use an intrinsic function wherever you can use an identifier of the same class and category as a sending data item.
Intrinsic Functions ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° LOG Function LOG10 Function LOWER-CASE Function MAX Function MEAN Function MEDIAN Function MIDRANGE Function MIN Function MOD Function NUMVAL Function NUMVAL-C Function ORD Function ORD-MAX Function ORD-MIN Function PRESENT-VALUE Function RANDOM Function RANGE Function REM Function REVERSE Function SIN Function SQRT Function STANDARD-DEVIATION Function SUM Function TAN Function UPPER-CASE Function VARIANCE Function WHEN-COMPILED Fun
Intrinsic Functions Intrinsic Function Types Intrinsic Function Types The type of an intrinsic function is the type of the value it returns.
Intrinsic Functions Numeric Intrinsic Functions Numeric Intrinsic Functions A numeric intrinsic function returns a numeric value. Table 14-2.
Intrinsic Functions Integer Intrinsic Functions Integer Intrinsic Functions An integer intrinsic function returns an integer value. Table 14-3.
Intrinsic Functions Variable-Type Intrinsic Functions Variable-Type Intrinsic Functions The type of some intrinsic functions depends on the type(s) of its arguments. Table 14-4. Variable-Type Intrinsic Functions Function Name Value Returned MAX Function Value of maximum argument MIN Function Value of minimum argument RANGE Function Value of maximum argument minus value of minimum argument SUM Function Sum of arguments Table 14-5.
Intrinsic Functions Argument Types Table 14-6.
Intrinsic Functions ACOS Function ACOS Function ACOS, a numeric function, returns a value in radians that approximates the arccosine of its argument. FUNCTION ACOS ( argument ) VST421.vsd argument is a numeric argument whose value is in the range -1 to +1. The returned value approximates the arccosine of the value of argument. It is a floating-point number in the range zero to pi. It has no implied decimal point and is precise to approximately 14 digits. Example 14-1.
Intrinsic Functions ANNUITY Function ANNUITY Function ANNUITY, a numeric function, returns a value that approximates the ratio of an annuity paid at the end of each period for a specified number of periods at a specified interest rate to an initial investment of one. Interest is applied at the end of the period, before the payment (annuity immediate). FUNCTION ( ANNUITY interest-rate number-of-periods ) VST422.vsd interest-rate is a numeric argument whose value is greater than or equal to zero.
Intrinsic Functions ANNUITY Function Example 14-2. ANNUITY Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A PICTURE 9V99. PROCEDURE DIVISION. MOVE FUNCTION ANNUITY DISPLAY A. MOVE FUNCTION ANNUITY DISPLAY A. MOVE FUNCTION ANNUITY DISPLAY A. MOVE FUNCTION ANNUITY DISPLAY A. MOVE FUNCTION ANNUITY DISPLAY A. (1 12) TO A. (1 6) TO A. (2 6) TO A. (5 2) TO A. (0 5) TO A. Output: 1.00 1.01 2.00 5.14 0.
Intrinsic Functions ASIN Function ASIN Function ASIN, a numeric function, returns a value in radians that approximates the arcsine of its argument. FUNCTION ASIN ( argument ) VST423.vsd argument is a numeric argument whose value is in the range -1 to +1. The returned value approximates the arcsine of the value of argument. It is a floatingpoint number in the range -pi/2 to +pi/2. It has no implied decimal point and is precise to approximately 14 digits. Example 14-3.
Intrinsic Functions ATAN Function ATAN Function ATAN, a numeric function, returns a value in radians that approximates the arctangent of its argument. FUNCTION ATAN ( argument ) VST424.vsd argument is a numeric argument. The returned value approximates the arctangent of the value of argument. It is a floating-point number in the range -pi/2 to +pi/2, excluding the endpoints. It has no implied decimal point and is precise to approximately 14 digits. Example 14-4. ATAN Function Code: DATA DIVISION.
Intrinsic Functions CHAR Function CHAR Function CHAR, an alphanumeric function, returns a character whose ordinal number in the program collating sequence is the value of its argument. FUNCTION CHAR ( argument ) VST425.vsd argument is an integer greater than zero and less than or equal to n, where n is the number of positions in the program collating sequence.
Intrinsic Functions CHAR Function Example 14-6. CHAR Function With ALPHABET Clause Code: ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. ALPHABET CAPITAL-LETTERS IS 66 THRU 91. SOURCE-COMPUTER. ABD. OBJECT-COMPUTER. ABD PROGRAM COLLATING SEQUENCE IS CAPITAL-LETTERS. PROCEDURE Startt. DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY DIVISION.
Intrinsic Functions COS Function COS Function COS, a numeric function, returns a value that approximates the cosine of the angle or arc (in radians) specified by its argument. FUNCTION COS ( argument ) VST426.vsd argument is a numeric argument. The returned value approximates the cosine of the value of argument. It is a floatingpoint number in the range -1 to +1. It has no implied decimal point and is precise to approximately 14 digits. Example 14-7. COS Function Code: DATA DIVISION.
Intrinsic Functions CURRENT-DATE Function CURRENT-DATE Function CURRENT-DATE, an alphanumeric function, returns a 21-character string that represents the calendar date, time of day, and local time differential factor provided by the operating environment. FUNCTION CURRENT-DATE VST427.
Intrinsic Functions DATE-OF-INTEGER Function DATE-OF-INTEGER Function DATE-OF-INTEGER, an integer function, converts a date in the Gregorian calendar from integer date form to standard date form (YYYYMMDD ). FUNCTION DATE-OF-INTEGER ( argument ) VST428.vsd argument is a positive integer that represents a number of days since December 31, 1600, in the Gregorian calendar.
Intrinsic Functions DAY-OF-INTEGER Function DAY-OF-INTEGER Function DAY-OF-INTEGER, an integer function, converts a date in the Gregorian calendar from integer date form to Julian date form (YYYYDDD ). FUNCTION DAY-OF-INTEGER ( argument ) VST429.vsd argument is a positive integer that represents a number of days since December 31, 1600, in the Gregorian calendar.
Intrinsic Functions FACTORIAL Function FACTORIAL Function FACTORIAL, an integer function, returns the factorial of its argument. FUNCTION FACTORIAL ( argument ) VST430.vsd argument is an integer greater than or equal to zero. When argument is zero, the returned value is 1; when argument is positive, the returned value is its factorial. Example 14-11.
Intrinsic Functions INTEGER Function INTEGER Function INTEGER, an integer function, returns the greatest integer that is less than or equal to its argument. FUNCTION INTEGER ( argument ) VST431.vsd argument is a numeric argument. The returned value is the greatest integer that is less than or equal to the value of argument. Example 14-12. INTEGER Function Code: DISPLAY DISPLAY DISPLAY DISPLAY FUNCTION FUNCTION FUNCTION FUNCTION INTEGER INTEGER INTEGER INTEGER (-3.5) (-3) (3) (3.
Intrinsic Functions INTEGER-OF-DATE Function INTEGER-OF-DATE Function INTEGER-OF-DATE, an integer function, converts a date in the Gregorian calendar from standard date form (YYYYMMDD ) to integer date form. FUNCTION INTEGER-OF-DATE ( argument ) VST432.
Intrinsic Functions INTEGER-OF-DATE Function Example 14-14. INTEGER-OF-DATE Function Code: ?ENV COMMON IDENTIFICATION DIVISION. PROGRAM-ID. TESTT. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. ABD. OBJECT-COMPUTER. ABD. DATA DIVISION. WORKING-STORAGE SECTION. 01 D PICTURE 9 USAGE COMPUTATIONAL. 01 STD-DATE PICTURE 9(8) USAGE COMPUTATIONAL. PROCEDURE DIVISION. STARTT.
Intrinsic Functions INTEGER-OF-DAY Function INTEGER-OF-DAY Function INTEGER-OF-DAY, an integer function, converts a date in the Gregorian calendar from Julian date form (YYYYDDD ) to integer date form. FUNCTION INTEGER-OF-DAY ( ) argument VST433.
Intrinsic Functions INTEGER-PART Function INTEGER-PART Function INTEGER-PART, an integer function, returns the integer part of its argument. FUNCTION INTEGER-PART ( ) argument VST434.vsd argument is a numeric argument. The returned value is determined as shown in this table: Value of argument Returned Value Zero Zero Positive Greatest integer less than or equal to the value of argument Negative Least integer greater than or equal to the value of argument Example 14-16.
Intrinsic Functions LENGTH Function LENGTH Function LENGTH, an integer function, returns the length of its argument (the number of character positions it has, regardless of its current value). FUNCTION LENGTH ( argument ) VST435.vsd argument is a nonnumeric literal or data item of any class or category. The returned value is determined as shown in this table. It includes any implicit FILLER characters.
Intrinsic Functions LOG Function LOG Function LOG, a numeric function, returns a value that approximates the logarithm to the base e (natural logarithm) of its argument. FUNCTION LOG ( argument ) VST436.vsd argument is a numeric argument greater than zero. The returned value is approximately the logarithm to the base e of the value of argument. Example 14-18. LOG Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A PICTURE S9V99. PROCEDURE DIVISION. MOVE FUNCTION LOG (1) DISPLAY A.
Intrinsic Functions LOG10 Function LOG10 Function LOG10, a numeric function, returns a value that approximates the logarithm to the base 10 of its argument. FUNCTION LOG10 ( argument ) VST437.vsd argument is a numeric argument greater than zero. The returned value is approximately the logarithm to the base 10 of the value of argument. Example 14-19. LOG10 Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A PICTURE S9V99. PROCEDURE DIVISION. MOVE FUNCTION LOG10 DISPLAY A.
Intrinsic Functions LOWER-CASE Function LOWER-CASE Function LOWER-CASE, an alphanumeric function, returns a character-string that is the same as its argument, except that each uppercase letter is replaced by the corresponding lowercase letter. FUNCTION LOWER-CASE ( string ) VST438.vsd string is an alphabetic or alphanumeric string at least one character in length.
Intrinsic Functions MAX Function MAX Function MAX is a function that returns the value of its maximum argument. Its type depends on the type of its arguments, as this table shows: Argument Type Function Type Alphabetic Alphanumeric Alphanumeric Alphanumeric Integer Integer Numeric (some can be integer) Numeric FUNCTION MAX ( ) argument VST439.vsd argument is an alphabetic, alphanumeric, integer, or numeric argument. If you specify more than one argument, they must all be of the same class.
Intrinsic Functions MAX Function Example 14-21. MAX Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 NUMERIC-ARRAY. 05 PICTURE 9(1) VALUE 4. 05 PICTURE 9(1) VALUE 9. 05 PICTURE 9(1) VALUE 3. 05 PICTURE 9(1) VALUE 7. 05 PICTURE 9(1) VALUE 5 01 NUM-ARRAY REDEFINES NUMERIC-ARRAY. 05 NUM OCCURS 5 TIMES PICTURE 9(1). 01 ALPHABETIC-ARRAY. 05 PICTURE X(5) VALUE "dog". 05 PICTURE X(5) VALUE "cat". 05 PICTURE X(5) VALUE "horse". 05 PICTURE X(5) VALUE "sheep". 05 PICTURE X(5) VALUE "goat".
Intrinsic Functions MEAN Function MEAN Function MEAN, a numeric function, returns the arithmetic mean (average) of its arguments. FUNCTION MEAN ( argument ) VST440.vsd argument is a numeric argument. argument can be an array; for example, FUNCTION MEAN (ARRAY1(ALL)) returns the arithmetic mean of the elements of the array ARRAY1. The returned value is the arithmetic mean (average) of the argument series; that is n ∑ argument i i ---=--1------------------ n where n is the number of arguments.
Intrinsic Functions MEDIAN Function Example 14-22. MEAN Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 NUMERIC-ARRAY. 05 PICTURE 9(1) VALUE 4. 05 PICTURE 9(1) VALUE 9. 05 PICTURE 9(1) VALUE 3. 05 PICTURE 9(1) VALUE 7. 05 PICTURE 9(1) VALUE 5 01 NUM-ARRAY REDEFINES NUMERIC-ARRAY. 05 NUM OCCURS 5 TIMES PICTURE 9(1). 01 A PICTURE S9V9. PROCEDURE DIVISION. MOVE FUNCTION MEAN (NUM(ALL)) TO A. DISPLAY A. MOVE FUNCTION MEAN (NUM(1) NUM(3) NUM(5)) TO A. DISPLAY A. MOVE FUNCTION MEAN (3.4 5 6.
Intrinsic Functions MEDIAN Function The returned value is the value that would be in the middle of the list if the arguments were sorted numerically (according to the rules for comparing simple conditions). If there are an odd number of arguments, at least half of them are less than or equal to the returned value, and at least half of them are greater than or equal to the returned value. If there are an even number of arguments, the returned value is the arithmetic mean of the two middle arguments.
Intrinsic Functions MIDRANGE Function MIDRANGE Function MIDRANGE, a numeric function, returns the arithmetic mean (average) of its minimum and maximum arguments. FUNCTION MIDRANGE ( argument ) VST442.vsd argument is a numeric argument. argument can be an array; for example, FUNCTION MIDRANGE (ARRAY1(ALL)) returns the arithmetic mean of the minimum and maximum elements of the array ARRAY1.
Intrinsic Functions MIN Function MIN Function MIN is a function that returns the value of its minimum argument. Its type depends on the type of its arguments, as this table shows: Argument Type Function Type Alphabetic Alphanumeric Alphanumeric Alphanumeric Integer Integer Numeric (some can be integer) Numeric FUNCTION MIN ( ) argument VST443.vsd argument is an alphabetic, alphanumeric, integer, or numeric argument. If you specify more than one argument, they must all be of the same class.
Intrinsic Functions MIN Function Example 14-25. MIN Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 NUMERIC-ARRAY. 05 PICTURE 9(1) VALUE 4. 05 PICTURE 9(1) VALUE 9. 05 PICTURE 9(1) VALUE 3. 05 PICTURE 9(1) VALUE 7. 05 PICTURE 9(1) VALUE 5 01 NUM-ARRAY REDEFINES NUMERIC-ARRAY. 05 NUM OCCURS 5 TIMES PICTURE 9(1). 01 ALPHABETIC-ARRAY. 05 PICTURE X(5) VALUE "dog". 05 PICTURE X(5) VALUE "cat". 05 PICTURE X(5) VALUE "horse". 05 PICTURE X(5) VALUE "sheep". 05 PICTURE X(5) VALUE "goat".
Intrinsic Functions MOD Function MOD Function MOD, an integer function, returns the value that is argument-1 modulo argument-2. FUNCTION MOD ( argument-1 ) argument-2 VST444.vsd argument-1 is an integer. argument-2 is a nonzero integer. The returned value is argument-1 modulo argument-2, which is defined: argument-1 argument-1 – argument-2 × FUNCTION INTEGER --------------------- argument-2 Example 14-26.
Intrinsic Functions NUMVAL Function NUMVAL Function NUMVAL, a numeric function, returns the numeric value represented by its argument, which is a character-string. NUMVAL ignores leading and trailing spaces. FUNCTION ( NUMVAL ) string VST445.vsd string " sp " number + - sp sp number + - sp CR DB VST446.vsd sp is a string of zero or more space characters. number digits ns . ns digits . ns digits VST447.
Intrinsic Functions NUMVAL Function The returned value is the numeric value represented by string. The format of the value depends on the size of string. If the length of string is fewer than 10 characters, the equivalent PICTURE is S9(n)V9(n-1), where n is the number of characters. Any size greater than 9 characters results in an equivalent PICTURE of S9(19)V9(18). This is a special internal item that cannot be expressed by the user.
Intrinsic Functions NUMVAL-C Function NUMVAL-C Function NUMVAL-C, a numeric function, returns the numeric value of a specified characterstring, ignoring any currency sign or commas preceding the decimal point. FUNCTION NUMVAL-C ( ) value-1 value-2 currency-sign VST448.vsd value-1 + spaces spaces number currency-sign spaces spaces VST450.vsd value-2 spaces currency-sign spaces number spaces + - spaces CR DB VST385.vsd spaces is a string of zero or more space characters.
Intrinsic Functions NUMVAL-C Function currency-sign is a nonnumeric literal or alphanumeric data item; a string of one or two characters that specifies the currency sign. The default is the currency sign specified for the program. number digits ns digits ns ns . ns digits . ns digits VST451.vsd If the program contains the DECIMAL POINT COMMA phrase in the SPECIALNAMES paragraph, use a comma instead of a decimal point in number. digits is a string of one to 18 digits.
Intrinsic Functions NUMVAL-C Function Example 14-28. NUMVAL-C Function Code: DATA DIVISION WORKING-STORAGE SECTION. 01 A PICTURE S99V99. PROCEDURE DIVISION. MOVE FUNCTION NUMVAL-C DISPLAY A. MOVE FUNCTION NUMVAL-C DISPLAY A. MOVE FUNCTION NUMVAL-C DISPLAY A. MOVE FUNCTION NUMVAL-C DISPLAY A. MOVE FUNCTION NUMVAL-C DISPLAY A. MOVE FUNCTION NUMVAL-C DISPLAY A. MOVE FUNCTION NUMVAL-C DISPLAY A. ("35") TO A. ("$35") TO A. ("35$") TO A. ("35.75") TO A. (".35") TO A. (" (" - 35.75 35.75 ") TO A. CR") TO A.
Intrinsic Functions ORD Function ORD Function ORD, an integer function, returns the ordinal number of its argument in the program collating sequence. FUNCTION ( ORD argument ) VST452.vsd argument is a one-character alphabetic or alphanumeric argument. The returned value is the ordinal number of argument in the program collating sequence. It is at least one. Example 14-29.
Intrinsic Functions ORD-MAX Function The returned value is the ordinal number of the argument with the greatest value (according to the rules for evaluating simple conditions). If more than one argument has the same greatest value, the returned value is the ordinal number of the leftmost argument with that value. The returned value is at least one. Example 14-30. ORD-MAX Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 NUMERIC-ARRAY. 05 PICTURE 9(1) VALUE 4. 05 PICTURE 9(1) VALUE 9.
Intrinsic Functions ORD-MIN Function ORD-MIN Function ORD-MIN, an integer function, returns the ordinal number of its minimum argument. FUNCTION ORD-MIN ( argument ) VST454.vsd argument is an alphabetic, alphanumeric, integer, or numeric argument. If you specify more than one argument, they must all be of the same class. Integer and numeric arguments can be mixed, because integers are of the class numeric.
Intrinsic Functions PRESENT-VALUE Function Example 14-31. ORD-MIN Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 NUMERIC-ARRAY. 05 PICTURE 9(1) VALUE 4. 05 PICTURE 9(1) VALUE 9. 05 PICTURE 9(1) VALUE 3. 05 PICTURE 9(1) VALUE 7. 05 PICTURE 9(1) VALUE 5 01 NUM-ARRAY REDEFINES NUMERIC-ARRAY. 05 NUM OCCURS 5 TIMES PICTURE 9(1). 01 ALPHABETIC-ARRAY. 05 PICTURE X(5) VALUE "dog". 05 PICTURE X(5) VALUE "cat". 05 PICTURE X(5) VALUE "horse". 05 PICTURE X(5) VALUE "sheep". 05 PICTURE X(5) VALUE "goat".
Intrinsic Functions PRESENT-VALUE Function discount-rate is a numeric argument whose value is greater than -1. period-end-amount is a numeric argument. period-end-amount can be an array; for example, FUNCTION PRESENT-VALUE (DISCOUNT-RATE ARRAY1(ALL)) uses the elements of the array ARRAY1 as a series of numeric arguments. The returned value is approximately n period-end-amount i ∑ -----------------------------------i i=1 ( 1 + discount-rate ) where n is the number of period-end-amount s. Example 14-32.
Intrinsic Functions PRESENT-VALUE Function Example 14-32. PRESENT-VALUE Function 12.00 01.00 00.20 03.00 03.
Intrinsic Functions RANDOM Function RANDOM Function RANDOM, a numeric function, returns a pseudorandom number from a rectangular distribution. FUNCTION RANDOM ( argument ) VST456.vsd argument is zero or a positive integer. The first time a run unit calls RANDOM, RANDOM generates a series of pseudorandom numbers and returns the first number in the series. If argument is specified, RANDOM uses the value of argument as the seed; if not, it uses the default seed, one.
Intrinsic Functions RANGE Function RANGE Function RANGE is a function that returns the difference between its maximum and minimum arguments. Its type depends on the type of its arguments, as this table shows: Argument Type Function Type Integer Integer Numeric (some can be integer) Numeric FUNCTION RANGE ( argument ) VST457.vsd argument is an integer or numeric argument. Integer and numeric arguments can be mixed, because integers are of the class numeric.
Intrinsic Functions RANGE Function Example 14-34. RANGE Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 NUMERIC-ARRAY. 05 PICTURE 9V99 VALUE 0.05. 05 PICTURE 9V99 VALUE 1.15. 05 PICTURE 9V99 VALUE 2.50. 05 PICTURE 9V99 VALUE 3.75. 05 PICTURE 9V99 VALUE 4.55. 01 NUM-ARRAY REDEFINES NUMERIC-ARRAY. 05 NUM OCCURS 5 TIMES PICTURE 9V99. PROCEDURE DISPLAY DISPLAY DISPLAY DIVISION. FUNCTION RANGE (NUM(ALL)) FUNCTION RANGE (9 2 5 3.5) FUNCTION RANGE (1.5 3.6 7.8 4.9) Output: 4.50 7.0 6.
Intrinsic Functions REM Function REM Function REM, a numeric function, returns the remainder that results from dividing its first argument by its second argument. FUNCTION REM ( dividend divisor ) VST458.vsd dividend is a numeric argument. divisor is a nonzero numeric argument.
Intrinsic Functions REVERSE Function REVERSE Function REVERSE, an alphanumeric function, returns a string that is the same as its argument, except that the characters are in reverse order. FUNCTION REVERSE ( argument ) VST459.vsd argument is an alphabetic or alphanumeric argument at least one character in length. The returned value is the same as argument, except that the characters are in reverse order.
Intrinsic Functions SIN Function SIN Function SIN, a numeric function, returns a value that approximates the sine of the angle or arc (in radians) specified by its argument. FUNCTION SIN ( argument ) VST460.vsd argument is a numeric argument. The returned value approximates the sine of the value of argument. It is a floatingpoint number in the range -1 to +1. It has no implied decimal point and is precise to approximately 14 digits. Example 14-37. SIN Function Code: DATA DIVISION.
Intrinsic Functions SQRT Function SQRT Function SQRT, a numeric function, returns a value that approximates the square root of its argument. FUNCTION SQRT ( argument ) VST461.vsd argument is a numeric argument whose value is zero or positive. The returned value is approximately: argument Example 14-38. SQRT Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A PICTURE S9V99. PROCEDURE DIVISION. MOVE FUNCTION SQRT DISPLAY A. MOVE FUNCTION SQRT DISPLAY A. MOVE FUNCTION SQRT DISPLAY A.
Intrinsic Functions STANDARD-DEVIATION Function STANDARD-DEVIATION Function STANDARD-DEVIATION, a numeric function, returns a value that approximates the standard deviation of its arguments. FUNCTION ( STANDARD-DEVIATION argument ) VST462.vsd argument is a numeric argument. argument can be an array; for example, FUNCTION STANDARD-DEVIATION (ARRAY1(ALL)) returns a value that approximates the standard deviation of the elements of the array ARRAY1.
Intrinsic Functions STANDARD-DEVIATION Function Example 14-39. STANDARD-DEVIATION Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 NUMERIC-ARRAY 05 PICTURE 9V99 VALUE 0.05. 05 PICTURE 9V99 VALUE 1.15. 05 PICTURE 9V99 VALUE 2.50. 05 PICTURE 9V99 VALUE 3.75. 05 PICTURE 9V99 VALUE 4.55. 01 NUM-ARRAY REDEFINES NUMERIC-ARRAY. 05 NUM OCCURS 5 TIMES PICTURE 9V99. 01 A PICTURE S9V99. PROCEDURE DIVISION. MOVE FUNCTION STANDARD-DEVIATION (NUM(ALL)) TO A. DISPLAY A.
Intrinsic Functions SUM Function SUM Function SUM is a function that returns the sum of its arguments. Its type depends on the type of its arguments, as this table shows: Argument Type Function Type Integer Integer Numeric (some can be integer) Numeric FUNCTION SUM ( argument ) VST463.vsd argument is an integer or numeric argument. argument can be an array; for example, FUNCTION SUM (ARRAY1(ALL)) returns the sum of the elements of the array ARRAY1.
Intrinsic Functions SUM Function Example 14-40. SUM Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 NUMERIC-ARRAY 05 PICTURE 9V99 VALUE 0.05. 05 PICTURE 9V99 VALUE 1.15. 05 PICTURE 9V99 VALUE 2.50. 05 PICTURE 9V99 VALUE 3.75. 05 PICTURE 9V99 VALUE 4.55. 01 NUM-ARRAY REDEFINES NUMERIC-ARRAY. 05 NUM OCCURS 5 TIMES PICTURE 9V99. PROCEDURE DISPLAY DISPLAY DISPLAY DIVISION. FUNCTION SUM (NUM(ALL)) FUNCTION SUM (9 2 5 3) FUNCTION SUM (1.5 3.6 7.8 4.9) Output: 012.00 19 17.
Intrinsic Functions TAN Function TAN Function TAN, a numeric function, returns a value that approximates the tangent of the angle or arc (in radians) specified by its argument. FUNCTION TAN ( argument ) VST464.vsd argument is a numeric argument. The returned value approximates the tangent of the value of argument. It is a floatingpoint number with no implied decimal point, precise to approximately 14 digits. Example 14-41. TAN Function Code: DATA DIVISION. WORKING-STORAGE SECTION.
Intrinsic Functions UPPER-CASE Function UPPER-CASE Function UPPER-CASE, an alphanumeric function, returns a character-string that is the same as its argument, except that each lowercase letter is replaced by the corresponding uppercase letter. FUNCTION UPPER-CASE ( string ) VST465.vsd string is an alphabetic or alphanumeric string at least one character in length.
Intrinsic Functions VARIANCE Function VARIANCE Function VARIANCE, a numeric function, returns a value that approximates the variance of its arguments. FUNCTION VARIANCE ( argument ) VST466.vsd argument is a numeric argument. argument can be an array; for example, FUNCTION VARIANCE (ARRAY1(ALL)) returns a value that approximates the variance of the elements of the array ARRAY1. The returned value is the approximation of the variance of the argument series.
Intrinsic Functions VARIANCE Function Example 14-43. VARIANCE Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 NUMERIC-ARRAY 05 PICTURE 9V99 VALUE 0.05. 05 PICTURE 9V99 VALUE 1.15. 05 PICTURE 9V99 VALUE 2.50. 05 PICTURE 9V99 VALUE 3.75. 05 PICTURE 9V99 VALUE 4.55. 01 NUM-ARRAY REDEFINES NUMERIC-ARRAY. 05 NUM OCCURS 5 TIMES PICTURE 9V99. 01 A PICTURE 9V99. PROCEDURE DIVISION. MOVE FUNCTION VARIANCE DISPLAY A.. MOVE FUNCTION VARIANCE DISPLAY A. MOVE FUNCTION VARIANCE DISPLAY A.
Intrinsic Functions WHEN-COMPILED Function WHEN-COMPILED Function WHEN-COMPILED, an alphanumeric function, returns a 21-character string that represents the date and time the program was compiled, according to the system on which the program was compiled. FUNCTION WHEN-COMPILED VST467.vsd The returned value is the date and time of compilation of the source program that calls the WHEN-COMPILED function.
Intrinsic Functions WHEN-COMPILED Function Example 14-44. WHEN-COMPILED Function Code: DISPLAY FUNCTION WHEN-COMPILED Output: 1997041516104953-0700 The date in Example 14-44 is April 15, 1997 (19970415). The time is 16:10:49.53 or 4:10:49.53 PM (16104953), which is 7 hours behind Greenwich mean time (-0700).
Intrinsic Functions WHEN-COMPILED Function HP COBOL Manual for TNS/E Programs —520347-003 14 -66
15 Debugging Tools This section briefly describes the HP debugging tools and refers you to appropriate sources for more information. Topics: • • • Debugging Lines Run-Time Debugger FIXERRS Macro Debugging Lines Debugging lines, a batch-oriented COBOL debugging tool, apply to individual source program lines. Debugging lines are compiled only if the source program includes a DEBUGGING MODE clause (see SOURCE-COMPUTER Paragraph); otherwise, they are handled as comments. Note.
Debugging Tools Run-Time Debugger Run-Time Debugger The HP run-time debugger, Visual Inspect, is PC-based, interactive, and symbolic.,If you compile your program with the SYMBOLS directive (described in SYMBOLS and NOSYMBOLS), the symbolic debuggers allow you to debug the program using the names you assigned to the procedures and data items of the source program, rather than the addresses that the compiler and linker ultimately assigned to them.
Debugging Tools FIXERRS Macro FIXERRS Macro FIXERRS is a TACL macro that helps you find and fix syntax errors in your source file. To use the FIXERRS TACL macro to fix errors in a source file, you must compile your program with the directive ERRORFILE. You can then use FIXERRS with the errorlogging file produced by that directive. The FIXERRS TACL macro starts a two-window TEDIT session and displays an error message on the top line of the screen with the corresponding source text in the remaining lines.
Debugging Tools FIXERRS Macro HP COBOL Manual for TNS/E Programs —520347-003 15- 4
16 ANSI Reference Format In ANSI reference format, each line has 80 characters (columns). Five margins divide each line into five areas. Figure 16-1. ANSI Reference Format Margin: L Column: C 1 2 3 4 5 Sequence Number Area 6 A 7 B 8 R 9 10 11 12 ... 72 73 ... 80 Area A Indicator Field Area B Identification Field Line VST524.vsd To ensure that each line has 80 characters, the COBOL compiler truncates lines that are too long and space-pads lines that are too short.
ANSI Reference Format Indicator Area Indicator Area The indicator area begins at Margin C and uses only column 7. It can be empty, or it can contain a single character that describes the type of information on the line. Table 16-1.
ANSI Reference Format Continuation Line Continuation Line A continuation line has a hyphen (-) in the indicator area. It is a continuation of the previous line. Always leave area A of a continuation line blank. You can continue any word or literal. If you continue a numeric literal, a reserved word, or a user-defined word, the compiler ignores the trailing spaces of the previous line and initial spaces of the continuation line.
ANSI Reference Format Area A Area A Area A begins at Margin A and uses columns 8 through 11. These must begin in area A: • • • • Division names Section headers Paragraph headers These level indicators and level numbers for the Data Division: ° ° ° FD (file descriptions) SD (sort-merge file descriptions) Level-numbers 01 and 77 Level-numbers 02 through 49, 66, and 88 can begin in either area A or area B. Area B Area B begins at Margin B and uses columns 12 through 72.
17 HP Extensions to ISO COBOL This section lists the HP extensions to ISO/ANSI COBOL, grouping them according to the sections of this manual that explain them; that is: • • • • • • Source Program Organization and Format Language Elements Data Fundamentals Environment Division Data Division Procedure Division Verbs These HP extensions are explained in other sections, and are not repeated in this section: • • • HP Reserved Words Section 18, HP COBOL CRE Support Section 48, Run-Time Diagnostic Messages A
HP Extensions to ISO COBOL Language Elements Language Elements The HP extensions to ISO/ANSI COBOL that are language elements are: • • • • • HP COBOL requires at least one character in a COBOL word to be either a letter or a hyphen; COBOL requires a letter. In HP COBOL, using a COBOL word as a library-name does not interfere with its concurrent use as the name of an entity in another category; however, librarynames must be unique among themselves.
HP Extensions to ISO COBOL Environment Division Environment Division These HP extensions to ISO/ANSI COBOL are elements of the Environment Division: • • CHARACTER-SET Clause Special system-names: ° ° ° CONSOLE for the operator’s console MYTERM for the home terminal of a process CHANNEL-1 through CHANNEL-12 for carriage-control tape channels See System-Name Clause.
HP Extensions to ISO COBOL Procedure Division Verbs Procedure Division Verbs These HP extensions to ISO/ANSI COBOL involve Procedure Division verbs: • • • • For developing fault-tolerant programs to run as process pairs: ° ° ° CHECKPOINT STARTBACKUP SYNCDEPTH phrase of OPEN To mark the beginning of a parameter list, the USING phrase of ENTER To specify a data item that stores the value a function returns, the GIVING phrase of ENTER To control file access and maintain the integrity of data bases in t
HP Extensions to ISO COBOL • • • • • • Procedure Division Verbs To enable different methods of positioning files, the POSITION, GENERIC, and APPROXIMATE phrases of START PARAGRAPH, SECTION, and PERFORM CYCLE options of EXIT, which transfer control to the end of the paragraph, section, and PERFORM cycle, respectively The GUARDIAN-ERR special register is updated each time a file-manipulating statement is executed.
HP Extensions to ISO COBOL HP COBOL Manual for TNS/E Programs —520347-003 17- 6 Procedure Division Verbs
18 HP COBOL CRE Support All native programs run in the CRE. Native HP COBOL programs can call and be called by programs written in native HP C, native HP C++, and pTAL, even if the main program is not written in HP COBOL. Topics: • • • Introducing the CRE Shared File Operations Arithmetic Overflow Processing For more information about writing HP COBOL programs for the CRE, see the CRE Programmer’s Guide.
HP COBOL CRE Support Shared File Operations Shared File Operations A CRE HP COBOL program shares certain file operations with other programs in its run unit. The shared file operations are associated with these files. Other file operations are not shared. • Standard Output File For DISPLAY statements, it is the default file (no UPON phrase is specified). • Standard Input File For ACCEPT statements, it is the default file (no FROM phrase is specified).
19 Using HP COBOL in the OSS Environment The NonStop operating system offers two operating environments: • • Guardian environment OSS environment Open System Services provides industry-standard application program interfaces (APIs) and utilities to enable you to port existing applications quickly and easily to NonStop systems. The NonStop operating system continues to support Guardian services. HP has enhanced many tools from the Guardian environment so that they also operate in the OSS environment.
Using HP COBOL in the OSS Environment Running the ECOBOL Compiler Running the ECOBOL Compiler In the OSS environment, the OSS utility ecobol calls the compiler (ECOBOL), optionally followed by the linker and SQLCOMP compiler (for SQL/MP) or MXCMP compiler (for SQL/MX). The flags and the types of files in the operands determine which processes operate on the files in the operands. The ecobol utility generates programs that run in the OSS environment.
Using HP COBOL in the OSS Environment Running HP COBOL Programs pathname ns file ns . cbl cob ecbl ecob a m o dll VST817.vsd Note. The file suffixes (cbl, cob, and so on) are not case-sensitive. Running HP COBOL Programs After successfully compiling your HP COBOL program in the OSS environment, you have a loadfile. Its name is either a.out (by default) or the name you gave it with the -o flag.
Using HP COBOL in the OSS Environment Mixed-Language Programs Mixed-Language Programs In the OSS environment, you can write mixed-language programs. Native HP COBOL programs can call programs written in native HP COBOL, native HP C, native HP C++, or pTAL. To produce a native HP COBOL program that contains native HP COBOL and native HP C modules, follow these steps: 1. Using the c89 utility, compile the HP C modules, but do not link them. 2.
Using HP COBOL in the OSS Environment Files in the OSS Environment Table 19-1.
Using HP COBOL in the OSS Environment OSS Pathnames OSS Pathnames for OSS Files The OSS pathname of an OSS file has this format: ns OSS /E/ ns node filename / ns ns directory / ns VST634.vsd OSS specifies that the file is an OSS file (the default). If OSS is specified, the entire pathname must be enclosed in quotation marks. node specifies the name of a remote node. The operating system on the node must be version D40.00 or later, and the node must have a compatible OSS name server.
Using HP COBOL in the OSS Environment OSS Pathnames file-name is the name of a file. A file name can contain any characters except slash (/) and the NULL character (zero). Its first character cannot be a hyphen (-). Its maximum length is NAME_MAX characters, as defined by the limitsh header file. If filename contains special characters, the entire pathname must be enclosed in quotation marks. Example 19-1.
Using HP COBOL in the OSS Environment OSS Pathnames in HP COBOL Source Programs Example 19-2. OSS Pathnames for Guardian Files "GUARDIAN \qa.tests.cobol85.release4" "GUARDIAN S.#PRNT2" "OSS /G/tests.cobol85.release4" "OSS /E/qa/G/$tests.cobol85.release4" OSS Pathnames in HP COBOL Source Programs Within an HP COBOL source program, OSS pathnames are allowed as systemfile-name parameters in these contexts: • In the File-Mnemonic clause of the SPECIAL-NAMES paragraph, for example: SPECIAL-NAMES.
Using HP COBOL in the OSS Environment Line Sequential Files Line Sequential Files Line sequential files (code 180) are available only in the OSS environment. Their organization is line sequential. They are compatible with the system text editor of the OSS environment; therefore, they can also be called OSS ASCII text files. (The X/Open CAE specification defines an OSS ASCII text file as one that is compatible with the system text editor.
Using HP COBOL in the OSS Environment File-Control Entries File-Control Entries The syntax for a file-control entry for a line sequential file is: SELECT clause ASSIGN clause . RESERVE clause ORGANIZATION clause ACCESS MODE clause FILE STATUS clause VST624.vsd SELECT clause FILE-CONTROL file-control-entry . VST036.vsd OPTIONAL makes the file optional, which means that an OPEN statement with an INPUT, I-O, or EXTEND phrase can open the file regardless of whether the file exists.
Using HP COBOL in the OSS Environment File-Control Entries ASSIGN clause ASSIGN system-file-name TO VST640.vsd associates file-name with system-file-name. Only the first system-filename has meaning. The compiler ignores subsequent names and literals and issues a warning. system-file-name is the name of a file as it is known to the file system. It must be enclosed in quotation marks unless it forms a COBOL word.
Using HP COBOL in the OSS Environment File-Control Entries FILE STATUS clause filestat STATUS FILE IS VST000.vsd defines filestat as the file-status data item for the file. When a COBOL runtime I-O routine completes an operation on the file, it stores the status code in filestat before returning control to your program (see I-O Status Code). filestat is an alphanumeric, nonnational data item defined in the Working-Storage Section, Extended-Storage Section, or Linkage Section.
Using HP COBOL in the OSS Environment File Description Entries File Description Entries The syntax for a file description entry for a line sequential file is: . file-name EXTERNAL clause GLOBAL clause RECORD CONTAINS clause «LABEL RECORDS clause» «VALUE OF clause» «DATA RECORDS clause» REPORT clause VST633.vsd file-name is the highest-level qualifier for both a file description entry and its data descriptions; therefore, the name must be unique within a program.
Using HP COBOL in the OSS Environment I-O-CONTROL Paragraph I-O-CONTROL Paragraph The syntax for an I-O-CONTROL paragraph for a line sequential file is: I-O-CONTROL . . «RERUN clause» SAME AREA clause VST632.vsd «RERUN clause» Note. The 1985 COBOL standard classifies RERUN as obsolete, so you are advised not to use it. RERUN rerun-file ON system-name EVERY rerun-file-2-phrase units CLOCK-UNITS condition VST058.vsd rerun-file system-name are handled as comments.
Using HP COBOL in the OSS Environment OPEN Statement units condition are handled as comments. SAME AREA clause SAME RECORD SORT AREA FOR MERGE same-file VST060.vsd specifies the files that share the same memory during program execution. These files do not share disk space or tape space. The SAME AREA clause has different meanings for I-O files (sequential, relative, indexed) than for sort-merge files. same-file is a file name.
Using HP COBOL in the OSS Environment OPEN Statement input-file-description infile SHARED PROTECTED EXCLUSIVE VST627.vsd infile is the file description file name of a file to open in INPUT mode, for read operations only. SHARED allows other processes to read or write the file while this process is open. SHARED is the default for terminals. PROTECTED allows other processes to read but not write the file while this process is open. PROTECTED is the default for input files that are not terminals.
Using HP COBOL in the OSS Environment OPEN Statement SHARED PROTECTED EXCLUSIVE are the same as described earlier for infile. I-O specifies that the file or files in i-o-file-description are being opened for reading and writing. i-o-file-description iofile SHARED PROTECTED EXCLUSIVE VST626.vsd iofile is the file description file name of a file to open in I-O mode, for both read and write operations. SHARED PROTECTED EXCLUSIVE are the same as described earlier for infile.
Using HP COBOL in the OSS Environment READ Statement extfile is the file description file name of a sequential file to open in EXTEND mode, for write operations that append records to the file. The file is positioned after the last logical record when opened. All operations on the file must be write operations, as if the file had been opened in OUTPUT mode. If the file is an Enscribe unstructured file, its size must be a multiple of the record size.
Using HP COBOL in the OSS Environment REWRITE Statement The INTO phrase is allowed only when either: • • All records associated with file-name are defined as data structures or as elementary alphanumeric items and data-name is either a data structure or an elementary alphanumeric item. Only one record is associated with file-name. LOCK keeps other programs from gaining access to the record retrieved until an UNLOCKFILE or UNLOCKRECORD statement is executed.
Using HP COBOL in the OSS Environment WRITE Statement data-name is the identifier of the item that contains the new record instead of record-name. When this phrase is used, an implicit MOVE statement occurs to copy the data to record-name before the rewrite operation occurs. data-name cannot specify an index-name or an index data item. data-name cannot specify a data item allocated within the record area in which record-name is located.
Using HP COBOL in the OSS Environment Features Unavailable in the OSS Environment Features Unavailable in the OSS Environment Features that are available in the Guardian environment but not in the OSS environment fall into these categories: • • • • ASSIGN Commands PARAM Commands Compiler Directives Process Pairs ASSIGN Commands ASSIGN commands are not available in the OSS environment, You can use DEFINEs for some ASSIGN functions, but because DEFINEs do not accept OSS pathnames, they cannot perform the
Using HP COBOL in the OSS Environment Compiler Directives Compiler Directives These compiler directives are not allowed in the OSS environment: Directive Reason NONSTOP The OSS environment does not support HP COBOL process pairs. SAVE The OSS environment does not have initialization messages. SUBTYPE The OSS environment does not support the concept of subtypes.
Using HP COBOL in the OSS Environment Utility Routines Utility Routines These utility routines accept only Guardian file names: • • • COBOL_RETURN_SORT_ERRORS_ COBOL_SET_SORT_PARAM_TEXT_ COBOL_SPECIAL_OPEN_ If a program passes a file name to the utility routine COBOL_ASSIGN_, then COBOL_ASSIGN_ assumes that the file name is a Guardian file name unless the calling program identified the file name as an OSS file name.
Using HP COBOL in the OSS Environment HP COBOL Manual for TNS/E Programs —520347-003 19 -24 Utility Routines
20 HP COBOL Limits The HP architecture and the method of implementation of the HP COBOL compiler, ECOBOL, imposes these kinds of limits on HP COBOL programs: • • • • • • Size Number Callability External Names Ranges of Values Ignored Elements Size • Block size of record in a data file The maximum block size of a record in a data file is 32,767 characters.
HP COBOL Limits • Size Data in a run unit The combined size of static data, heap, and flat segments is limited to approximately 1.5 GB. Data allocated dynamically (that is, on the stack) is limited to less than 32 MB (see Storage Allocation For an Initial Program).
HP COBOL Limits • Number Tables allocated by the RECEIVE-CONTROL paragraph The maximum size of the tables allocated by the RECEIVE-CONTROL paragraph is 62 KB (65,400 characters). Anything larger causes a compilation error. Number These items, whose number in a program is limited, are in alphabetic order. • AFTER phrases in a PERFORM statement The maximum number of AFTER phrases in a PERFORM statement is 6.
HP COBOL Limits • Number Nesting depth ° OCCURS clauses The maximum depth of OCCURS clauses in a table is 7. ° Programs Programs can be nested within other programs to a depth of 7. ° PERFORM stack The maximum depth is 50. • Parameters The maximum number of parameters that can be passed by a HP COBOL program or to a HP COBOL program is 126.
HP COBOL Limits Callability Callability Native HP COBOL programs can call programs written in: • • • • Native HP C Native HP C++ Native HP COBOL pTAL External Names Within a run unit, no external data item can have the same name as any external file connector or any program.
HP COBOL Limits Ignored Elements Ignored Elements HP COBOL compilers ignore these elements of COBOL because they are unnecessary in the HP implementation: • • In the entire source program: In ANSI format, columns 1 through 6 and beyond 72 In the Environment Division: ° ° In the SOURCE-COMPUTER paragraph: Source computer name In the OBJECT-COMPUTER paragraph: ° ° ° ° Object computer name MEMORY SIZE clause SEGMENT-LIMIT clause In the INPUT-OUTPUT section: ° In the FILE-CONTROL paragraph: in the fi
21 Reserved Words This section contains these alphabetized lists: • • All Reserved Words HP Reserved Words Figure 21-1. How Lists of Reserved Words Are Related All Reserved Words in HP COBOL New COBOL Reserved Words HP-Only Reserved Words VST522.vsd All Reserved Words This is an alphabetic list of all reserved words in HP COBOL. It includes new HP COBOL reserved words (additions to COBOL 74) and reserved words found only in HP COBOL (HP additions to COBOL).
Reserved Words All Reserved Words AREAS ASCENDING ASSIGN AT AUTHOR B BEFORE BINARY BLANK BLOCK BOTTOM BY C CALL CANCEL CD CF CH CHARACTER CHARACTERS CHARACTER-SET CHECKPOINT CLASS CLOCK-UNITS CLOSE COBOL CODE CODE-SET COLLATING COLUMN COMMA COMMON COMMUNICATION COMP COMP-3 COMP-5 COMPUTATIONAL COMPUTATIONAL-3 COMPUTATIONAL-5 COMPUTE CONFIGURATION CONTAINS CONTENT CONTINUE HP COBOL Manual for TNS/E Programs —520347-003 21- 2
Reserved Words All Reserved Words CONTROL CONTROLS CONVERTING COPY CORR CORRESPONDING COUNT CURRENCY D DATA DATE DATE-COMPILED DATE-WRITTEN DAY DAY-OF-WEEK DE DEBUG-CONTENTS DEBUG-ITEM DEBUG-LINE DEBUG-SUB-2 DEBUG-SUB-3 DEBUGGING DECIMAL-POINT DECLARATIVES DEBUG-NAME DEBUG-SUB-1 DELETE DELIMITED DELIMITER DEPENDING DESCENDING DESTINATION DETAIL DISABLE DISPLAY DIVIDE DIVISION DOWN DUPLICATES DYNAMIC E EGI ELSE HP COBOL Manual for TNS/E Programs —520347-003 21- 3
Reserved Words All Reserved Words EMI ENABLE END END-ADD END-COMPUTE END-DELETE END-DIVIDE END-EVALUATE END-IF END-MULTIPLY END-OF-PAGE END-PERFORM END-READ END-RECEIVE END-RETURN END-REWRITE END-SEARCH END-START END-STRING END-SUBTRACT END-UNSTRING END-WRITE ENTER EOP EQUAL ERROR ESI EVALUATE EVERY EXCEPTION EXCLUSIVE EXIT EXTEND EXTENDED-STORAGE EXTERNAL F FALSE FD FILE FILE-CONTROL FILLER FINAL FIRST FOOTING FOR HP COBOL Manual for TNS/E Programs —520347-003 21- 4
Reserved Words All Reserved Words FROM FUNCTION G GENERATE GENERIC GIVING GLOBAL GO GREATER GROUP GUARDIAN-ERR H HEADING HIGH-VALUE HIGH-VALUES I I-O I-O-CONTROL IDENTIFICATION IF IN INDEX INDEXED INDICATE INITIAL INITIALIZE INITIATE INPUT INPUT-OUTPUT INSPECT INSTALLATION INTO INVALID IS J JUST JUSTIFIED HP COBOL Manual for TNS/E Programs —520347-003 21- 5
Reserved Words All Reserved Words K KEY L LABEL LAST LEADING LEFT LENGTH LESS LIMIT LIMITS LINAGE LINAGE-COUNTER LINE LINE-COUNTER LINKAGE LOCK LOCKFILE LOW-VALUE LOW-VALUES M MEMORY MERGE MESSAGE MODE MODULES MOVE MULTIPLE MULTIPLY N NATIVE NEGATIVE NEXT NO NOT NULL NULLS NUMBER NUMERIC NUMERIC-EDITED HP COBOL Manual for TNS/E Programs —520347-003 21- 6
Reserved Words All Reserved Words O OBJECT-COMPUTER OCCURS OF OFF OMITTED ON OPEN OPTIONAL OR ORDER ORGANIZATION OTHER OUTPUT OVERFLOW P PACKED-DECIMAL PADDING PAGE PAGE-COUNTER PERFORM PF PH PIC PICTURE PLUS POINTER POSITION POSITIVE PRINTING PROCEDURE PROCEDURES PROCEED PROGRAM PROGRAM-ID PROGRAM-STATUS PROGRAM-STATUS-1 PROGRAM-STATUS-2 PROMPT PROTECTED PURGE HP COBOL Manual for TNS/E Programs —520347-003 21- 7
Reserved Words All Reserved Words Q QUEUE QUOTE QUOTES R RANDOM RD READ RECEIVE RECEIVE-CONTROL RECORD RECORDS REDEFINES REEL REFERENCE REFERENCES RELATIVE RELEASE REMAINDER REMOVAL RENAMES REPLACE REPLACING REPLY REPORT REPORTING REPORTS RERUN RESERVE RESET RETURN REVERSED REWIND REWRITE RF RH RIGHT ROUNDED RUN S SAME SD SEARCH HP COBOL Manual for TNS/E Programs —520347-003 21- 8
Reserved Words All Reserved Words SECTION SECURITY SEGMENT SEGMENT-LIMIT SELECT SEND SENTENCE SEPARATE SEQUENCE SEQUENTIAL SET SHARED SIGN SIZE SORT SORT-MERGE SOURCE SOURCE-COMPUTER SPACE SPACES SPECIAL-NAMES STANDARD STANDARD-1 STANDARD-2 START STARTBACKUP STATUS STOP STRING SUB-QUEUE-1 SUB-QUEUE-2 SUB-QUEUE-3 SUBTRACT SUM SUPPRESS SYMBOLIC SYNC SYNCDEPTH SYNCHRONIZED T TABLE TAL TALLYING TAPE TERMINAL HP COBOL Manual for TNS/E Programs —520347-003 21- 9
Reserved Words All Reserved Words TERMINATE TEST TEXT THAN THEN THROUGH THRU TIME TIMES TO TOP TRAILING TRUE TYPE U UNIT UNLOCK UNLOCKFILE UNLOCKRECORD UNSTRING UNTIL UP UPON USAGE USE USING V VALUE VALUES VARYING W WHEN WITH WORDS WORKING-STORAGE WRITE Z ZERO ZEROES HP COBOL Manual for TNS/E Programs —520347-003 21 -10
Reserved Words HP Reserved Words Special Characters + * / ** < > = HP Reserved Words This is an alphabetic list of reserved words found only in HP COBOL (HP additions to COBOL).
Reserved Words HP Reserved Words N NULL NULLS P PROGRAM-STATUS PROGRAM-STATUS-1 PROGRAM-STATUS-2 PROMPT PROTECTED R RECEIVE-CONTROL REPLY S SHARED STARTBACKUP SYNCDEPTH T TAL U UNLOCK UNLOCKFILE UNLOCKRECORD HP COBOL Manual for TNS/E Programs —520347-003 21 -12
Part II.
Part II.
22 Creating and Compiling HP COBOL Source Programs Note. This section applies primarily to the Guardian environment. If you are compiling HP COBOL programs in the OSS environment, see Section 19, Using HP COBOL in the OSS Environment.
Creating and Compiling HP COBOL Source Programs Displaying Previous Commands Displaying Previous Commands TACL maintains a chronological log of previously entered commands, which you can display with the HISTORY command.
Creating and Compiling HP COBOL Source Programs Editing and Reexecuting Previous Commands If you enter an exclamation mark followed by a number, TACL displays and executes the command with that number: 6> 6> 1> 2> 3> 4> 5> 6> 7> !4 history who fileinfo view myfile history history history If you enter an exclamation mark followed by text, TACL displays and executes the most recent command that begins with that text: 7> !v 7> view myfile 8> Editing and Reexecuting Previous Commands If you enter the comma
Creating and Compiling HP COBOL Source Programs Creating or Altering an HP COBOL Source Program If you enter the FC command followed by text, TACL displays the most recent command that begins with that text so that you can edit it: 10> fc view 10> view srcfile1 10... TACL also allows you to program the function keys on your terminal and write macros. For more information about TACL, see the TACL Reference Manual.
Creating and Compiling HP COBOL Source Programs EDIT Files EDIT Files An EDIT format file (abbreviated “EDIT file”) is a specially formatted disk file. It is the only type of file that the EDIT and TEDIT editors create or alter. The file-code value that the EDIT or TEDIT editor assigns to an EDIT file is 101. To use the EDIT or TEDIT editor on the contents of a non-EDIT file, create a new EDIT file and copy the text of the non-EDIT file into it.
Creating and Compiling HP COBOL Source Programs EDIT Editor Figure 22-2. ANSI Reference Format Margin: L Column: C 1 2 3 4 Sequence Number Area 5 6 A 7 B 8 R 9 10 11 12 ... 72 73 ... 80 Area A Indicator Field Area B Identification Field Line VST524.vsd You can write a COBOL source program entirely in either format or in a mixture of both. The default is Tandem format. Unless you direct the compiler to accept ANSI format, the compiler assumes the entire program is in Tandem format.
Creating and Compiling HP COBOL Source Programs EDIT Editor To retrieve lines from a non-EDIT file (in this example, PAYROLXX) and put them into an EDIT file (in this example, PAYROLS), use the GET and PUT commands together: *GET PAYROLXX PUT PAYROLS (With the TEDIT editor, you cannot combine the GET and PUT commands.
Creating and Compiling HP COBOL Source Programs TEDIT Editor TEDIT Editor The TEDIT editor is a full-screen editor with a command line. Overall, the TEDIT editor is more powerful than the EDIT editor. The TEDIT commands SEARCH and REPLACE have powerful pattern-matching abilities, with single-character, multicharacter, and setof-characters wild cards. Caution. The TEDIT editor works on your original file, not on a copy of it.
Creating and Compiling HP COBOL Source Programs TEDIT Editor Topics: • • • Second Window TEDIT Commands Customizing the TEDIT Editor Second Window The TEDIT editor allows you to open a second window.
Creating and Compiling HP COBOL Source Programs HP Tandem Extensions for Codewright (TEC) Customizing the TEDIT Editor Some ways in which you can customize the TEDIT editor are: • • • You can write macros that perform complex tasks with few keystrokes. With the RECONFIGURE KEYS command, you can redefine the default keys. With the RECONFIGURE OPTIONS command, you can do such things as reset your tab stops and define delimiter pairs.
Creating and Compiling HP COBOL Source Programs HP Tandem Extensions for Codewright (TEC) Language-Sensitive Programming Support TEC provides language-specific menus to support the coding of these HP languages: • • • • HP C and HP C++ COBOL pTAL and TAL TACL When you open a source file, the appropriate language-specific menu appears on the menu bar.
Creating and Compiling HP COBOL Source Programs Compiling an HP COBOL Source Program Viewing Source Files TEC allows you to view or collapse source files by function, #PRAGMA, paragraph, or normal view. This feature helps you to locate code quickly by higher-level code segments and to provide a call map of the selected module. After you have located the code, you can return the source program to its normal expanded view.
Creating and Compiling HP COBOL Source Programs Running the Compiler Running the Compiler To run the compiler, use the ECOBOL command. Specify the name of the file containing the source program or programs that you want to compile; for example: 23> ECOBOL /IN XYZ/ The preceding ECOBOL command produces a loadfile only if the source file, XYZ, contains a RUNNABLE directive.
Creating and Compiling HP COBOL Source Programs Running the Compiler IN and OUT are options of the TACL command RUN. Other RUN command options that you might find useful when compiling HP COBOL programs are: • NOWAIT If you specify ECOBOL /IN XYZ, OUT $SPX.#LPPR, NOWAIT/; RUNNABLE the TACL program does not wait while the compiler runs, but returns a TACL prompt after starting the compiler. (The compiler runs in the background.) • CPU ECOBOL /IN XYZ, OUT $SPX.
Creating and Compiling HP COBOL Source Programs Naming the Object File Naming the Object File To simplify the compilation examples in the preceding topic, no name is specified for the object file that the compiler produces. In these examples, the object file is given the default name RUNUNIT.
Creating and Compiling HP COBOL Source Programs Specifying the Default COPY Library Specifying the Default COPY Library The default COPY library is the library from which COPY statements read text when no library name is specified in the COPY statement. If you do not specify the default COPY library (as in the compilation examples in the preceding topic), then COPYLIB is the default COPY library.
Creating and Compiling HP COBOL Source Programs Changing the Compilation Environment These DEFINEs have CLASS attribute SEARCH. Use them by entering ADD DEFINE commands before compiling your program, as in this example. (An ampersand at the end of a line means that the TACL command continues on the next line.) 91> 91> 92> 92> 93> ADD DEFINE =_SOURCE_SEARCH, CLASS SEARCH, SUBVOL0& (=_DEFAULTS,$VOL1.SUB2,$VOL1.SUB3) ADD DEFINE =_OBJECT_SEARCH, CLASS SEARCH, SUBVOL0& (=_DEFAULTS,$VOL2.SUB1,$VOL2.
Creating and Compiling HP COBOL Source Programs Improving Compilation Speed Compiler Space Allocation The PARAM SYMBOL-BLOCKS command specifies how much space the compiler allocates for its symbol dictionary and embedded SQL/MP statements—see PARAM SYMBOL-BLOCKS.
Creating and Compiling HP COBOL Source Programs Using COPY and SOURCE Libraries Example 22-2. COPY or SOURCE Library ?SECTION NAMEREC 01 NAME-REC. 03 LAST-NAME 03 M-I 03 FIRST-NAME 03 TITLE PICTURE PICTURE PICTURE PICTURE X(15). X(1). X(15). X(5). ?SECTION STANDARD-LINAGE LINAGE IS 55 LINES WITH FOOTING AT 45 LINES AT TOP 5 LINES AT BOTTOM 6 ?SECTION ZOO-FILE ASSIGN TO "$A0101.ZOO.
Creating and Compiling HP COBOL Source Programs Creating or Altering a COPY or SOURCE Library To use the library in Example 22-2 as a SOURCE library, include a line like this in your source program: ?SOURCE file-name (NAMEREC,ZOO-FILE) where file-name is the name of the file containing the library text in Example 22-2. The effect is the same as including these lines in your source program: 01 NAME-REC. 03 LAST-NAME 03 M-I 03 FIRST-NAME 03 TITLE PICTURE PICTURE PICTURE PICTURE X(15). X(1). X(15). X(5).
Creating and Compiling HP COBOL Source Programs Using Data Definition Language (DDL) Figure 22-3. DDL Input and Output Data Declaration (COPY) Library DDL Compiler Your Description FUP Command File Data Dictionary VST700.vsd Topics: • • • • Describing the Data Structures Data Declaration (COPY) Library File Utility Program (FUP) Commands Data Dictionary Describing the Data Structures You describe the data structures of your database with DEFINE statements.
Creating and Compiling HP COBOL Source Programs Using Data Definition Language (DDL) Example 22-3. Input to the DDL Compiler (page 2 of 2) DEFINE ADDRESS. 02 STREET-NUMBER 02 STREET-NAME 02 FLAT-NUMBER 02 MUNICIPALITY 02 STATE-OR-PROVINCE 02 NATION 02 POSTAL-CODE END PIC PIC PIC PIC PIC PIC PIC X(6). X(25). X(8). X(25). X(25). X(25). X(11). DEFINE NAME-AND-ADDRESS. 05 NAME TYPE *. 05 ADDRESS TYPE *. END RECORD PERSON-RECORD.
Creating and Compiling HP COBOL Source Programs Using Data Definition Language (DDL) Example 22-4. COPY Library Produced by the DDL Compiler (page 2 of 3) ?SECTION ADDRESS,HP * Definition ADDRESS created on 02/28/93 at 12:01 01 ADDRESS. 02 STREET-NUMBER PIC X(6). 02 STREET-NAME PIC X(25). 02 FLAT-NUMBER PIC X(8). 02 MUNICIPALITY PIC X(25). 02 STATE-OR-PROVINCE PIC X(25). 02 NATION PIC X(25). 02 POSTAL-CODE PIC X(11).
Creating and Compiling HP COBOL Source Programs Using Data Definition Language (DDL) Example 22-4. COPY Library Produced by the DDL Compiler (page 3 of 3) ?SECTION PERSON-RECORD,HP * Record PERSON-RECORD created on 02/28/93 at 12:01 01 PERSON-RECORD. 02 NAME-AND-ADDRESS. 03 NAME. 04 LAST-NAME PIC X(15). 04 MIDDLE-INITIAL PIC X(1). 04 FIRST-NAME PIC X(15). 03 ADDRESS. 04 STREET-NUMBER PIC X(6). 04 STREET-NAME PIC X(25). 04 FLAT-NUMBER PIC X(8). 04 MUNICIPALITY PIC X(25). 04 STATE-OR-PROVINCE PIC X(25).
Creating and Compiling HP COBOL Source Programs Including Text From a COPY Library Example 22-5.
Creating and Compiling HP COBOL Source Programs Including Text From a COPY Library Topics: • • • • • • Simple Copying Copying With Replacement Replacing Substrings Copying Into Debugging Lines Using Multiple COPY Libraries Using COPY Libraries Efficiently Simple Copying Simple copying means copying text from a COPY library into a source program. This example uses simple copying to copy the occurrence number in an OCCURS clause into more than one data description entry, as if it were a constant.
Creating and Compiling HP COBOL Source Programs Including Text From a COPY Library Copying With Replacement Copying with replacement means copying text from a COPY library, modifying it, and then writing it into a source program. Copying with replacement is achieved with the REPLACING phrase. Using the preceding example, suppose that the number of sales offices increases from 24 through 27.
Creating and Compiling HP COBOL Source Programs Including Text From a COPY Library Replacing Substrings The REPLACING phrase can only replace entire text-words (DAILY-TOTAL but not just TOTAL, for example); however, parenthesized words within pseudo-text are recognized as text-words, allowing you to write statements such as: COPY SUM-IT REPLACING ==(PREFIX)== BY ==DAILY==.
Creating and Compiling HP COBOL Source Programs Including Text From a COPY Library Copying Into Debugging Lines When the source line containing the word COPY is a debug line (has a D or d in the indicator area), the compiler changes each library line that has a space in its indicator area to a debug line. Example 22-7. Copying Into Debugging Lines Source line: D COPY DEB-DISP. Library lines: ?SECTION DEB-DISP DISPLAY KINGDOM PHYLUM CLASS ORDER FAMILY GENUS SPECIES.
Creating and Compiling HP COBOL Source Programs Including Text From a SOURCE Library Including Text From a SOURCE Library Text from a SOURCE library is included in a HP COBOL source program with a SOURCE directive. A SOURCE directive must be the last directive on its line. When the compiler reads a SOURCE directive, it suspends reading from its primary source file and begins reading (entire lines) from a specified section of a SOURCE library.
Creating and Compiling HP COBOL Source Programs Including Text From a SOURCE Library Example 22-8. Including Text From a Source File Resulting source code: 01 01 01 NAME-REC. 03 LAST-NAME 03 M-I 03 FIRST-NAME 03 TITLE ADDR-REC. 03 NUMBER 03 STREET 03 APT-NUM 03 CITY 03 STATE 03 ZIPCODE DATE-REC. 03 MONTH 03 DAY 03 YEAR PICTURE PICTURE PICTURE PICTURE X(15). X(1). X(15). X(5). PICTURE PICTURE PICTURE PICTURE PICTURE PICTURE X(5). X(15). X(3). X(15). X(2). X(5). PICTURE X(9). PICTURE X(2).
Creating and Compiling HP COBOL Source Programs Replacing Text-Words in an HP COBOL Source Program Replacing Text-Words in an HP COBOL Source Program You can replace text-words with other text-words in a HP COBOL source file with a REPLACE statement. A REPLACE statement is active from the time the compiler encounters it until the compiler encounters either another, overriding REPLACE statement or the end of a separately compiled program. The two Data Divisions in Example 22-9 are equivalent. Example 22-9.
Creating and Compiling HP COBOL Source Programs Replacing Substrings Replacing Substrings The REPLACE statement can only replace entire text-words (DAILY-TOTAL but not just TOTAL, for example); however, parenthesized words within pseudo-text are recognized as text-words, allowing you to write statements such as: REPLACE ==(PREFIX)== BY ==DAILY==.
Creating and Compiling HP COBOL Source Programs Replacing Text-Words From COPY Libraries Replacing Text-Words From COPY Libraries The compiler processes REPLACE statements after it has processed any COPY statements. REPLACE statements do not change COPY libraries. In Example 22-11, the compiler substitutes OFFICES for COPY OFFNUM and SQ-FTSIZE for COPY AREA first and then substitutes 10 for OFFICES and 5 for SQ-FTSIZE. Example 22-11.
Creating and Compiling HP COBOL Source Programs Replacing Text-Words From SOURCE Libraries Replacing Text-Words From SOURCE Libraries If a REPLACE statement is active when the compiler encounters a SOURCE directive, the REPLACE statement applies to the copy of the library text that the compiler includes in the HP COBOL source program (but not to the original text in the SOURCE library). Example 22-12.
Creating and Compiling HP COBOL Source Programs Understanding and Controlling the Compiler Listing When you compile several separately compiled programs at once (each of which could include nested programs), the listing includes one banner and one summary. After the banner, the listing includes a source program listing, symbol table, and symbolic code listing for each program that requested them (by default or directive).
Creating and Compiling HP COBOL Source Programs Compilation Banner Compilation Banner The ECOBOL compilation banner consists of this information: • • • • Page number of compiler listing, date and time at which compilation began (line 1) Version of the compiler (line 4) Copyright information (line 5) Directives included on compiler command line, if any (line 7) Example 22-13.
Creating and Compiling HP COBOL Source Programs Source Program Listing The two formats are aligned such that, even if your program mixes ANSI and Tandem formats, the COPY and comment indicators and areas A and B are aligned.
Creating and Compiling HP COBOL Source Programs Source Program Listing Text Altered by REPLACE Statement Each REPLACE statement is listed as the compiler encounters it. Each line on which a REPLACE statement has made a change is listed after the change has been made. If the line is too long, the compiler truncates it after a reasonable token and writes as many additional lines (with the same line number) as are necessary to deliver the entire replaced text.
Creating and Compiling HP COBOL Source Programs • Source Program Listing Text Before the Word COPY If the source line on which the COPY statement begins has text before the word COPY, the compiler tries to combine the original source line with the first line of the library text. This strategy succeeds only if at least one space separates the first nonspace character of the library text line from the last nonspace character of the source line.
Creating and Compiling HP COBOL Source Programs Source Program Listing Example 22-15. ANSI Format COPY Expansion (page 1 of 2) Source Program Lines: PD0023 A. ANSIFMT PD0024 ANSIFMT PD0024 ANSIFMT PD0026 ANSIFMT PD0027 ANSIFMT PD0028 ANSIFMT PD0029 ANSIFMT PD0030D ANSIFMT PD0031 ANSIFMT COPY MOVE1. COPY MOVE2. MOVE COPY SOURCE1. TO X. MOVE COPY SOURCE2. TO X. MOVE COPY SOURCE3. TO X. ADD COPY ADD1. COPY ADD2. COPY ADD3. COPY ADD4. TO ANSR. DISPLAY COPY SHOW-LIST OF SOMELIB. . STOP RUN.
Creating and Compiling HP COBOL Source Programs Source Program Listing Example 22-15. ANSI Format COPY Expansion (page 2 of 2) COPY Library Lines: ?SECTION MOVE1,ANSI MOVE ABLE TO BAKER. ?SECTION MOVE2,HP MOVE ABLE TO BAKER.
Creating and Compiling HP COBOL Source Programs Source Program Listing Text Retrieved by SOURCE Directive The compiler does not mark lines containing text that it copied from a SOURCE library. The compiler directives SHOWFILE and NOSHOWFILE determine whether the compiler listing indicates when the compiler stops reading from one source file and starts reading from another. The default, NOSHOWFILE, prevents the compiler from reporting when it switches from one source file to another.
Creating and Compiling HP COBOL Source Programs Diagnostic Messages Diagnostic Messages Table 22-2.
Creating and Compiling HP COBOL Source Programs Diagnostic Messages Compiler Warning Messages A warning message reports a questionable condition. A warning does not prevent the generation of code. You can suppress warning messages with the NOWARN directive. Example 22-16. Warning Message ** Warning 25 ** Blank continuation line Table 22-3. Compiler Directives That Produce Optional Warnings Directive Produces warnings for ...
Creating and Compiling HP COBOL Source Programs Diagnostic Messages Compiler Failure Messages A failure message reports a condition so severe that the compiler is unable to continue. Any code that the compiler has already generated during the current compilation session is lost. You cannot suppress failure messages. Example 22-18. Failure Message *** Failure: --> message-text [Warning message-number] The brackets are part of the message, not indicators that the bracketed material is optional.
Creating and Compiling HP COBOL Source Programs Symbol Table Listing Symbol Table Listing The compiler lists the symbol table if you explicitly request it with the MAP directive. The symbol table lists, in alphabetic order, each identifier in the program.
Creating and Compiling HP COBOL Source Programs Compilation Summary Compilation Summary Example 22-20. Symbolic Code Listing (page 1 of 23) COBOL - T0356H01 - (10SEP2004) (C)1997 Tandem (C)2003 Hewlett Packard Development Company, L.P. 2004 October 1, 17:22:28 Directives: -Woptimize=0 1. ?OPTIMIZE 0,INNERLIST 2. IDENTIFICATION DIVISION. 3. PROGRAM-ID. TESTT. 3. alloc r32=ar.pfs,0,17,8,0 3. add sp=-928,sp 3. nop 3. add r27=768,sp 3. stf.spill [r27]=f2,32 3. 3. 3. 3. 3. 3. nop add r26=784,sp stf.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 2 of 23) 3. 3. 3. 3. 3. 3. nop add st8 nop add st8 3. 3. 3. 3. 3. 3. nop add st8 nop add st8 3. 3. 3. 3. 3. 3. nop add st8 nop add st8 3. 3. 3. 3. 3. 3. nop add nop nop st8 add 3. 3. 3. 3. 3. 3. nop st8 add nop st8 add 3. 3. 3. 3. 3. nop st8 add nop ld8 3. 3. 3. 3. 3. 3. 3. nop mov add ld8 nop nop nop 3. 3. 3. 3. 3. 3. mov add ld8 nop nop nop r50=r35 r20=520,sp r36=[r20] 3. 3. 3.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 3 of 23) 3. 3. 3. 3. 3. 3. mov add ld8 nop nop nop r52=r37 r20=536,sp r38=[r20] 3. 3. 3. 3. 3. 3. mov add ld8 nop nop nop r53=r38 r20=544,sp r39=[r20] 3. 3. 3. 3. 3. 3. mov add ld8 nop nop nop r54=r39 r20=552,sp r40=[r20] 3. 3. 3. 3. 3. 3. mov add ld8 nop mov nop r55=r40 r20=560,sp r41=[r20] 3. 3. 3. 3. 3. 3. br.call.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 4 of 23) 3. 3. 3. 3. 3. 3. (p8) br.cond.dpnt.many .b1_4 add r34=@ltoff(__PUCB__TESTT#),gp ld8 r35=[r34] nop add r36=30,r35 ld2 r37=[r36] 3. 3. 3. 3. 3. 3. nop nop nop zxt2 add or r38=r37 r39=46080,r0 r40=r38,r39 3. 3. 3. 3. 3. 3. nop nop nop zxt2 add ld8 r41=r40 r42=@ltoff(__PUCB__TESTT#),gp r43=[r42] 3. 3. 3. 3. 3. nop add nop nop st2 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 20041010 14.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 5 of 23) 14. 15. 15. 15. 15. 15. 15. (p8) br.cond.dpnt.many .b1_8 DISPLAY STD-DATE nop nop mov r34=r0 add r35=@gprel(pack_TESTT_STD-DATE_#),gp ld4 r36=[r35] 15. 15. 15. 15. 15. 15. 15. 15. nop nop nop zxt4 add add add add 15. 15. 15. 15. 15. 15. mov mov nop nop mov mov 15. 15. 15. 15. 15. add r20=584,sp nop st8 [r20]=r34 nop br.call.sptk b0=_SharedMilli_CQA# 15. 15. 15. 15. 15.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 6 of 23) 15. 15. 15. 15. 15. 15. 15. st8 add nop st8 mov mov mov 15. 15. 15. 15. nop nop nop nop 15. 15. 15. 15. 15. 15. mov mov mov mov mov nop 15. 15. 15. 15. 15. br.call.sptk b0=COBLIB_DISPLAY_# add r20=496,sp ld8 r34=[r20] nop mov gp=r34 16. 16. 16. 16. 16. 16. 16.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 7 of 23) 16. 16. 16. 16. 16. 16. mov mov mov mov mov nop 16. 16. 16. 16. 16. 16. br.call.sptk b0=COBLIB_FUNC_DATES_# add r20=496,sp ld8 r34=[r20] nop nop nop 16. 16. 16. 16. 16. 16. mov mov add zxt4 add nop 16. 16. 16. 16. 16. 16. mov r49=r36 mov r50=r37 mov r51=r38 br.call.sptk b0=_SharedMilli_DivRem# add r20=496,sp ld8 r34=[r20] 16. 16. 16. 16. 16. 16. nop mov mov sxt4 nop nop 16. 16.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 8 of 23) 16. 16. 16. 16. 16. 16. (p9) 16. 16. 16. 16. 16. 16. (p9) 16. 16. 16. 16. 16. 16. (p9) (p9) (p9) nop nop nop fma.s1 nop nop f16=f2,f4,f0 fnma.s1 f17=f3,f4,f1 nop nop fma.s1 f18=f17,f16,f16 nop nop fma.s1 nop nop fma.s1 nop nop f19=f17,f17,f5 f4=f19,f18,f18 16. 16. 16. 16. 16. 16. mov f20=f4 nop nop fcvt.fx.trunc.s1 nop nop 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. xma.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 9 of 23) 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. (p10) 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. .b1_14: 16. 16. 16. 16. 16. 16. 16. 16. 16. .b1_15: 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. br.cond.dpnt.many add r20=608,sp ld8 r34=[r20] nop sub r35=r0,r34 nop sxt4 r36=r35 add r20=632,sp st8 [r20]=r36 nop nop nop br.cond.sptk.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 10 of 23) 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. (p8) br.cond.dpnt.many .b1_16 mov r34=r0 add r35=472,sp add r36=r35,r34 add r37=@gprel($cob_internal$6#),gp add r38=8,r0 mov r49=r36 mov r50=r37 mov r51=r38 add r20=648,sp st8 [r20]=r34 nop 17. 17. 17. 17. 17. 17. 17. 17. br.call.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 11 of 23) 17. 17. 17. 17. 17. 17. mov mov mov mov mov nop 17. 17. 17. 17. 17. 17. 17. br.call.sptk b0=COBLIB_DISPLAY_# add r20=496,sp ld8 r34=[r20] nop mov gp=r34 nop br.cond.sptk.many .b1_42 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. r52=r39 r53=r40 r54=r41 r55=r42 r56=r43 IF D = 1 THEN DISPLAY " MONDAY" ELSE .b1_16: add ld2 nop nop zxt2 nop cmp4.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 12 of 23) 18. 18. 18. 18. 18. 18. 18. 18. 18. add mov mov mov nop nop mov mov add 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. nop st8 add nop st8 add nop st8 add nop 18. 18. 18. 18. 18. 18. 18. 18. st8 mov mov mov nop nop nop nop [r47]=r0 r49=r35 r50=r36 r51=r38 18. 18. 18. 18. 18. 18. mov mov mov mov mov nop r52=r39 r53=r40 r54=r41 r55=r42 r56=r43 18. 18. 18. 18. 18. 18. 18. br.call.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 13 of 23) 19. 19. 19. 19. 19. 19. 19. 19. (p8) br.cond.dpnt.many .b1_22 mov r34=r0 add r35=480,sp add r36=r35,r34 add r37=@ltoff($cob_internal$9#),gp ld8 r38=[r37] add r39=9,r0 nop 19. 19. 19. 19. 19. 19. 19. mov mov mov add nop st8 nop r49=r36 r50=r38 r51=r39 r20=680,sp 19. 19. 19. 19. 19. 19. 19. 19. br.call.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 14 of 23) 19. 19. 19. 19. 19. 19. mov mov mov mov mov nop 19. 19. 19. 19. 19. 19. 19. br.call.sptk b0=COBLIB_DISPLAY_# add r20=496,sp ld8 r34=[r20] nop mov gp=r34 nop br.cond.sptk.many .b1_42 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. r52=r39 r53=r40 r54=r41 r55=r42 r56=r43 IF D = 3 THEN DISPLAY " WEDNESDAY" ELSE .
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 15 of 23) 20. 20. 20. 20. 20. 20. add mov mov mov nop nop r38=11,r37 r39=r0 r40=r0 r41=r0 20. 20. 20. 20. 20. 20. 20. mov mov add nop st8 add nop r42=r0 r43=r0 r44=16,sp 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. st8 add nop st8 add nop st8 mov mov mov [r45]=r0 r46=32,sp 20. 20. 20. 20. nop nop nop nop 20. 20. 20. 20. 20. 20. mov mov mov mov mov nop 20. 20. 20. 20. 20. 20. 20. br.call.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 16 of 23) 21. 21. 21. 21. 21. 21. 21. 21. (p8) br.cond.dpnt.many .b1_28 mov r34=r0 add r35=480,sp add r36=r35,r34 add r37=@ltoff($cob_internal$11#),gp ld8 r38=[r37] add r39=10,r0 nop 21. 21. 21. 21. 21. 21. 21. mov mov mov add nop st8 nop r49=r36 r50=r38 r51=r39 r20=712,sp 21. 21. 21. 21. 21. 21. 21. 21. br.call.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 17 of 23) 21. 21. 21. 21. 21. 21. mov mov mov mov mov nop 21. 21. 21. 21. 21. 21. 21. br.call.sptk b0=COBLIB_DISPLAY_# add r20=496,sp ld8 r34=[r20] nop mov gp=r34 nop br.cond.sptk.many .b1_42 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. r52=r39 r53=r40 r54=r41 r55=r42 r56=r43 IF D = 5 THEN DISPLAY " FRIDAY" ELSE .
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 18 of 23) 22. 22. 22. 22. 22. 22. add mov mov mov nop nop r38=8,r37 r39=r0 r40=r0 r41=r0 22. 22. 22. 22. 22. 22. 22. mov mov add nop st8 add nop r42=r0 r43=r0 r44=16,sp 22. 22. 22. 22. 22. 22. st8 add nop st8 add nop [r45]=r0 r46=32,sp 22. 22. 22. 22. 22. 22. 22. 22. st8 mov mov mov nop nop nop nop [r47]=r0 r49=r35 r50=r36 r51=r38 22. 22. 22. 22. 22. 22.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 19 of 23) 23. 23. 23. 23. 23. 23. 23. 23. (p8) br.cond.dpnt.many .b1_42 mov r34=r0 add r35=480,sp add r36=r35,r34 add r37=@ltoff($cob_internal$13#),gp ld8 r38=[r37] add r39=10,r0 nop 23. 23. 23. 23. 23. 23. 23. mov mov mov add nop st8 nop r49=r36 r50=r38 r51=r39 r20=744,sp 23. 23. 23. 23. 23. 23. 23. 23. br.call.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 20 of 23) 23. 23. 23. 23. 23. 23. mov mov mov mov mov nop 23. 23. 23. 23. 23. 24. 25. 26. 27. 28. 29. 29. 29. r52=r39 r53=r40 r54=r41 r55=r42 r56=r43 br.call.sptk b0=COBLIB_DISPLAY_# add r20=496,sp ld8 r34=[r20] nop mov gp=r34 END-IF END-IF END-IF END-IF END-IF END-IF nop nop 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. .b1_42: 29. 29. 29. 29. 29. 29.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 21 of 23) 31. 31. 31. 31. 31. 31. 31. 31. 31. .b1_8: nop nop br.call.sptk b0=COBLIB_STOP_# add r20=496,sp ld8 r34=[r20] nop mov gp=r34 nop 31. 31. 31. 31. 31. 31. 31. 31. 31. br.call.sptk b0=COBLIB_STOP_# add r20=496,sp ld8 r34=[r20] nop mov gp=r34 nop mov b0=r33 nop nop 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. mov ar.pfs=r32 add r27=928,sp ldf.fill f22=[r27],-32 nop add r26=912,sp ldf.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 22 of 23) 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. mov mov add nop st8 add nop st8 add nop r40=r0 r41=r0 r42=16,sp 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. st8 add nop st8 mov mov mov nop nop nop nop [r44]=r0 r45=40,sp 31. 31. 31. 31. 31. 31. mov mov mov mov mov nop r52=r37 r53=r38 r54=r39 r55=r40 r56=r41 31. 31. 31. 31. 31. 31. br.call.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-20. Symbolic Code Listing (page 23 of 23) 31. 31. 31. 31. 31. 31. 31. 31. st8 mov mov mov nop nop nop nop [r46]=r0 r49=r35 r50=r36 r51=r37 31. 31. 31. 31. 31. 31. mov mov mov mov mov nop r52=r38 r53=r39 r54=r40 r55=r41 r56=r42 31. 31. 31. 31. 31. 31. 31. 31. 31. br.call.sptk b0=COBLIB_ABEND_# add r20=496,sp ld8 r34=[r20] nop mov gp=r34 nop mov b0=r33 nop nop 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. mov ar.
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-21. Compilation Summary COBOL - T0356H01 - (20DEC2004) No failures detected. No errors detected. No warnings reported. No remarks issued. Maximum symbol table size = 10884 bytes eld - TNS/E Native Mode Linker - T0608H01 - 03DEC07 Copyright 2004 Hewlett-Packard Company eld command line: \drp12.$system.system.eld -o RUNUNIT RUNUNIT \DRP12.$SYSTEM.ZDLL031.ZCOBDLL \DRP12.$SYSTEM.ZDLL031.
Creating and Compiling HP COBOL Source Programs Compilation Summary If the ECOBOL compiler had reported any errors, the summary would have contained lines like these: COBOL - T0356H01 - (20DEC2004) No failures detected. *** 3 error(s) detected. *** Last error at page 2 line 51 [source \DRP12.$DATA4.EXCOB.EX3112CB line 96.]. *** 1 warning(s) reported. *** Last warning at page 3 line 17 [source \DRP12.$DATA4.EXCOB.EX3112CB line 116.]. No remarks issued.
23 Calling Other Programs and Routines Note. This section applies to the Guardian environment. For information on mixed-language programming in the OSS environment, see Mixed-Language Programs and Utility Routines. A HP COBOL program that calls one or more non-COBOL routines is called a mixedlanguage program (as is a non-COBOL program that calls one or more COBOL programs).
Calling Other Programs and Routines Calling Other COBOL Programs The CRE does not support all possible operations. For example, the CRE supports file sharing only for the three standard files: standard input, standard output, and standard log. The language-specific run-time libraries access all other files by calling run-time procedures directly, whether or not a program uses the CRE. For more information about writing programs that use the services provided by the CRE, see the CRE Programmer’s Guide.
Calling Other Programs and Routines Nested HP COBOL Programs Nested HP COBOL Programs Nested HP COBOL programs are contained in other HP COBOL programs. Nested programs can be directly or indirectly contained. In Figure 23-1, the compilation unit contains two separately compiled programs (Mane and Sub), which contain nested programs, and the programs have these relationships: The program ... Directly contains ... And indirectly contains ...
Calling Other Programs and Routines Common Programs An HP COBOL program can call any program directly contained within itself and any other separately compiled program. It cannot call a program indirectly contained within itself. The programs in Figure 23-1 can call each other: Can call the program ... The program ...
Calling Other Programs and Routines Static Calls Static Calls A static call is achieved with the statement CALL program-name, where programname is an alphanumeric literal whose value is known at compilation time. programname is the PROGRAM-ID of the called program, and it can be qualified with the phrase OF file-mnemonic or IN file-mnemonic. Quotation marks around program-name are not required, but are recommended.
Calling Other Programs and Routines Calling Non-COBOL Routines Every program that a dynamic call could possibly call (in the preceding example, the programs POSRTN and NEG0RTN) must be linked into the run unit or user library before you execute the program (see Linking HP COBOL Programs). If you want an HP COBOL program to be entirely free to call any other COBOL program that is prepared to be called, make the programs separate processes.
Calling Other Programs and Routines X/Open CALL Statement In the ENTER statement, you do not need to specify the language of the called routine, because the compiler can determine the language in which the program is written. If you do specify the language, it must be C or TAL. If you specify TAL, the compiler expects a pTAL program (it does not accept TAL programs). If you specify C, the compiler expects a routine written in either HP C or HP C++.
Calling Other Programs and Routines Operating System Routines Special Register RETURN-CODE The special register RETURN-CODE is accessible to an HP COBOL program that was compiled with the PORT directive and uses the X/Open CALL statement to call a function.The value of the function is returned in the special register RETURN-CODE, whose description is: 01 RETURN-CODE EXTERNAL PICTURE S9(5) COMPUTATIONAL. If the value of the function is greater than 99,999, arithmetic overflow occurs.
Calling Other Programs and Routines Operating System Routines Parameters Guardian operating system routines are documented in the Guardian Procedure Calls Reference Manual. When calling system routines from an HP COBOL program, use Table 23-1 to determine the appropriate form for the COBOL parameters.
Calling Other Programs and Routines Operating System Routines Table 23-1.
Calling Other Programs and Routines Operating System Routines Resolution The compiler leaves operating system routines unresolved, and the loader resolves them during fixup (see Fixup). The compiler is able to leave references to operating system routine calls unresolved because a file named ECOBEXT, which is part of every HP COBOL RVU, contains dummy versions of all the operating system routines.
Calling Other Programs and Routines HP COBOL Run-Time Routines Generations of Operating System Routines Like the file ECOBEXT, the files ECOBEX1 and ECOBEX0 are part of every HP COBOL RVU. Like the file EXTDECS, the files EXTDECS1 and EXTDECS0 are part of every operating environment RVU. This table shows the relationship between these files.
Calling Other Programs and Routines COBOL Utility Routines COBOL Utility Routines HP provides many COBOL utility routines that your COBOL program can call with the ENTER statement. These routines are described in Section 13, Libraries and Utility Routines. ENFORM Programs ENFORM, a component of the Encompass distributed database management system, is a powerful nonprocedural language for querying or developing reports on a relational database.
Calling Other Programs and Routines Restrictions on Calling Non-COBOL Routines HP C Routines An HP COBOL program must not call an HP C function that directly or indirectly accesses the HP C function getenv. An HP COBOL program indirectly calls HP C functions that allocate and deallocate memory and perform HP C input-output operations. Do not directly call the HP C function getenv from an HP COBOL program.
Calling Other Programs and Routines Restrictions on Calling Non-COBOL Routines Example 23-2. HP COBOL and HP C Programs Sharing Data HP COBOL Code: * The SEARCH directive references the HP C object file. ?SYMBOLS; SEARCH SHOWEXTO IDENTIFICATION DIVISION. PROGRAM-ID. TEST-EXTERNAL. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. SYMBOLIC NULLCHAR IS 1. DATA DIVISION. EXTENDED-STORAGE SECTION. 01 MYVAR EXTERNAL. 05 DATA-01 PIC X(20). 05 NULL-TERM PIC X. PROCEDURE DIVISION. STARTIT.
Calling Other Programs and Routines Passing Parameters HP C++ Function Name Consideration When a COBOL program calls a function compiled by HP C++, the function definition must include the extern "C" specification for the function name to be used in its original form. HP C++, by default, adjusts function names to accommodate generic functions and class methods.
Calling Other Programs and Routines What HP COBOL Can Pass by Content What HP COBOL Can Pass by Content An HP COBOL program can pass these types of items to non-COBOL routines by content: • • • • • Elementary Data Items Tables Numeric Literals Values of Arithmetic Expressions HP COBOL File Names Elementary Data Items The most practical categories and sizes for elementary data item parameters to be passed by content are: Parameter Category and Size USAGE Numeric 2-byte NATIVE-2 Numeric 4-byte NATIV
Calling Other Programs and Routines What HP COBOL Can Pass by Content Tables To pass a table (an array) by content, you must create a data structure that consists solely of the array elements and pass the name of that data structure. The corresponding formal parameter must be defined to use a content parameter. For example, to pass the table of Cs in Example 23-3, you must pass the name C-ARRAY. Example 23-3. Record Containing a Table 01 A-RECORD. 03 A PIC S999V99. 03 B PIC S999V99. 03 C-ARRAY.
Calling Other Programs and Routines What HP COBOL Can Pass by Reference What HP COBOL Can Pass by Reference An HP COBOL program can pass these to non-COBOL routines by reference: • • Elementary Data Items Records Elementary Data Items The only elementary data items that HP COBOL programs can always pass by reference are NATIVE-2, NATIVE-4, NATIVE-8, and PICTURE X (n ) data items.
Calling Other Programs and Routines Passing Parameters to COBOL Programs Passing Parameters to COBOL Programs A COBOL program can pass parameters to another COBOL program with the CALL statement. A non-COBOL routine can pass parameters to a COBOL program with the nonCOBOL language’s method of calling an external routine. The method varies from language to language; see the reference manual for appropriate non-COBOL language.
Calling Other Programs and Routines Passing Parameters to Non-COBOL Routines Example 23-4. TAL/pTAL Structures for Passing Parameters to COBOL Program TAL or pTAL declaration: STRUCT M; BEGIN INT X; STRING Y; UNSIGNED(8) Z; END; Corresponding HP COBOL parameter: 01 STRUCT-M. 03 X USAGE NATIVE-2. 03 YZ. 05 Y PIC X. 05 Z PIC X. HP COBOL temporary storage area: 01 TEMP-COMP. 03 ONE-WORD-NUMERIC USAGE NATIVE-2. 03 CHEATER REDEFINES ONE-WORD-NUMERIC. 05 FILLER PIC X. 05 LOW-HALF PIC X.
Calling Other Programs and Routines Passing Parameters to Non-COBOL Routines If a parameter is passed by reference so that the called routine can return a value to the calling program, the parameter declaration must match the expectation of the called routine, because HP COBOL code does not convert the values upon return from the routine. A COBOL program cannot pass a program name (a program-name in a PROGRAMID paragraph) to a non-COBOL routine as a parameter.
Calling Other Programs and Routines Passing Parameters to Non-COBOL Routines Example 23-5. Using Reference Parameters to Pass Integers to C Routine HP COBOL code: 01 PARAMS. 03 PAR1 USAGE IS NATIVE-2. 03 PAR2 USAGE IS NATIVE-4. 03 PAR3 USAGE IS NATIVE-8. 01 SQ USAGE IS NATIVE-8. ... ENTER C "blog" USING PAR1 PAR2 PAR3 GIVING SQ ... C code: long long blog (int *a, long *b, long long *c) { long long result; ...
Calling Other Programs and Routines Passing Parameters to Non-COBOL Routines Example 23-7. Passing a String to a C Routine (page 2 of 2) C routine: FUNCT1 (char *d) ... return void; pTAL • • • • If a pTAL parameter is to be passed by value, an HP COBOL program can pass a numeric literal, a numeric data item, or the value of an arithmetic expression. The compiler generates code that evaluates, scales, and converts the value to the form that the called pTAL procedure expects.
Calling Other Programs and Routines • Passing Parameters to Non-COBOL Routines pTAL has a parameter type called string:length that is defined: a^proc (a^string:length) string .ext a^string int length; An HP COBOL program that calls a pTAL routine that has a string :length parameter only passes one parameter, the string part. The compiler computes the length of the string and passes it to the pTAL routine.
Calling Other Programs and Routines Passing Parameters to Non-COBOL Routines Example 23-8. Passing Parameters to a pTAL Routine HP COBOL code: DATA DIVISION. WORKING-STORAGE SECTION. 01 ONE-WORD USAGE NATIVE-2. 01 TWO-WORD USAGE NATIVE-4. 01 FOUR-WORD USAGE NATIVE-8. 01 A-STRING PICTURE X(25). ... PROCEDURE DIVISION. ... ENTER TAL "proc1" USING ONE-WORD TWO-WORD FOUR-WORD A-STRING pTAL routine: PROC proc1 (a, b, c, d); INT a; INT(32) b; FIXED(0) c; STRING .d; -- pointer to array BEGIN ...
24 Issues Related to Linking Note. Most of this section applies to the Guardian environment. If you are binding HP COBOL programs in the OSS environment, see Section 19, Using HP COBOL in the OSS Environment and Mixed-Language Programs.
Issues Related to Linking Code and Data Blocks A compilation unit is a collection of source statements presented to a compiler in one compilation. It contains one or more separately compiled programs. For each compilation unit, the compiler produces a single object file.
Issues Related to Linking Code and Data Blocks How One Code Block Calls Another At the source program level, one program calls another with a CALL or ENTER statement; at the object program level, the calling program’s code block calls the called program’s code block. A CALL statement calls another COBOL program.
Issues Related to Linking Linking Linking Linking is the operation of examining, collecting, and modifying code and data blocks from one or more object files to produce a single object file. Two important aspects of linking a program are: • • Validating references to other programs or routines—determining whether the actual parameters of the calling program or routine correspond to the formal parameters of the called program or routine.
Issues Related to Linking Linking How the Compiler Validates and Resolves References The compiler translates each CALL statement and each ENTER statement in an HP COBOL source program into an external reference. When the compiler generates an implicit call to a routine that is to execute in another memory area, the parameters match those expected by the routine.
Issues Related to Linking Linking Figure 24-3.
Issues Related to Linking Loadfiles, Linkfiles, and Processes When the compiler processes an ENTER statement that calls a routine, but cannot find the routine, it delivers an error message and does not produce object code for the calling program.
Issues Related to Linking Linking HP COBOL Programs Linking HP COBOL Programs An HP COBOL program can be linked automatically, as part of compilation: If you specify the RUNNABLE or SEARCH directive, the ECOBOL compiler also calls the eld utility. If you do not link the program automatically, you must use the eld utility to link it after compilation.
Issues Related to Linking Linking Automatically Establishing a Mnemonic Name for an Object File If a CALL or ENTER statement contains a mnemonic name that specifies the object file that contains the called program, the compiler searches that file (and only that file) for the specified routine. If the compiler does not find the routine, it reports an error. You establish a mnemonic name for an object file with a File-Mnemonic clause in the SPECIAL-NAMES paragraph of the Environment Division.
Issues Related to Linking Linking Automatically Putting an Object File on the Tertiary Search List If the compiler does not find an external routine in the user library, it searches for the routine in the object libraries on the tertiary search list. If the compiler finds the routine in a library on the tertiary search list, it validates the routine’s actual parameters but does not include the routine in your object file. The system loader resolves the routine at fixup.
Issues Related to Linking Linking Programs to Be Called Dynamically Linking Programs to Be Called Dynamically A dynamic call is one in which the name of the called program is not known until run time (see Dynamic Calls). Every program that a dynamic call could possibly call must be bound into the run unit or user library before you execute the program. There are several ways to do this: • • • Compile all the programs in the run unit from a single source file.
Issues Related to Linking COBOL Segmentation HP COBOL Manual for TNS/E Programs —520347-003 24 -12
25 Executing and Debugging HP COBOL Programs Note. This section applies to the Guardian environment. If you are compiling HP COBOL programs in the OSS environment, see Running HP COBOL Programs. After you have compiled and bound your program, you can execute and, if necessary, debug it.
Executing and Debugging HP COBOL Programs Adding DEFINEs Table 25-1. Conditions Requiring Pre-Execution Preparation (page 2 of 2) Condition Preparation Required Before Program Execution You want the operating environment to return control to your program if a certain printer is unavailable or out of paper. Specify this preference (see Providing for an Unavailable Printer).
Executing and Debugging HP COBOL Programs Overriding File Assignments Made at Compilation Time DEFINE Names A DEFINE name begins with an equal sign (=) followed by a letter and up to 22 additional characters, which can be letters, digits, hyphens (-), underscores (_), and circumflexes (^). Example 25-1. DEFINE Names =NEWFILE =FILE25 =TAPE-FILE =FTEST_RESULTS =JEFFS^FILE DEFINE Attributes Every DEFINE has a CLASS attribute, which determines its other attributes.
Executing and Debugging HP COBOL Programs Specifying Characteristics of Files That a Program Creates The number of ASSIGN commands the command interpreter can store is limited by the amount of memory allocated to the command interpreter. The default amount of memory allocated to the command interpreter is 8 pages, which accommodates up to 19 ASSIGN commands. To allocate more memory to the command interpreter, use the MEM option in the RUN command that you use to run the command interpreter.
Executing and Debugging HP COBOL Programs Specifying a Default Input-Output Device You can use a single PARAM command to do several things; for example, this PARAM command overrides the NONSTOP directive and enables USE DEBUGGING SECTIONS: PARAM NONSTOP OFF, DEBUG ON For another example of a PARAM command that does several things, see Specifying Waited Input-Output. Specifying a Default Input-Output Device First, verify that you want to specify a default input-output device.
Executing and Debugging HP COBOL Programs Providing for an Unavailable Printer Providing for an Unavailable Printer If you want the operating environment to return control to your program if a certain printer is unavailable or out of paper, you must execute a PARAM PRINTERCONTROL command before executing your program.
Executing and Debugging HP COBOL Programs Using OBEY Files to Prepare for Execution Using OBEY Files to Prepare for Execution If you expect to have to enter the same set of preparation commands repeatedly, you can save time by putting those commands in an OBEY command file. You can create an OBEY command file with an HP editor (see the example in Running the Compiler).
Executing and Debugging HP COBOL Programs Finding Out What Preparation Commands Are Already Active You can achieve the same result with one command, OBEY PREP2, by putting these commands in an OBEY command file named PREP2: ADD DEFINE =BIGCUST, FILE \NICE.$FRNC.SIGNIF.CUST ASSIGN PROG1.NEWFILE,& \NICE.$FRNC.SIGNIF.NEWFILE,& EXT 5, CODE 101, EXCLUSIVE PARAM NONSTOP OFF PARAM INSPECT ON PARAM EXECUTION-LOG \NICE.$FRNC.SIGNIF.
Executing and Debugging HP COBOL Programs Changing or Clearing Unwanted Preparation Commands Changing or Clearing Unwanted Preparation Commands To change or clear a DEFINE, you must use these TACL commands: TACL Command Function ALTER DEFINE Changes the attribute values of an active DEFINE DELETE DEFINE Clears (deletes) an active DEFINE For details on the preceding TACL commands, see the TACL Reference Manual. To change or clear an ASSIGN or PARAM command, you use the TACL command CLEAR.
Executing and Debugging HP COBOL Programs Starting an HP COBOL Program From a TACL Prompt Starting an HP COBOL Program From a TACL Prompt To start an HP COBOL program from the TACL prompt, use the TACL command RUN. In the simplest case, the program retrieves input for unqualified ACCEPT statements from your home terminal and displays run-time diagnostic messages and the output of unqualified DISPLAY statements on your home terminal. If the file ID of your loadfile is $SYSTEM3.ECOBOL.
Executing and Debugging HP COBOL Programs Specifying the Home Terminal If you want separate default input and output devices, you must specify them with the IN and OUT options of the RUN command and must not use a PARAM EXECUTIONLOG command (because the PARAM EXECUTION-LOG command takes precedence over the IN and OUT options of the RUN command). The default input and output devices can be system files (including disk files) or DEFINE names that you have already associated with system files.
Executing and Debugging HP COBOL Programs Naming the New Process This command specifies the default input device INFILE for the program PROG1, no default output device, and the home terminal $TE1.#E02. The default output device will be the home terminal, $TE1.#E02. PROG1 /IN INFILE, TERM $TE1.#E02/ To find the name of a terminal, use the TACL command WHO. Example: 223> WHO Home terminal: $TE1.#E02 ...
Executing and Debugging HP COBOL Programs Running the New Process in the Background RUNNAMED Directive If you compile your program with the RUNNAMED directive, the operating environment assigns it a timestamp process name when you execute it. You do not need to include the NAME option in the RUN command (but you can, if you want to give it a specific name). The RUNNAMED directive works only if the RUNNABLE directive is active.
Executing and Debugging HP COBOL Programs Getting a Program to Enter Debugging Mode A run-time diagnostic message identifies the error, the process in which the error occurred, and the loadfile from which the process was loaded. The error number and format of a run-time diagnostic message depend on the run-time environment. For details, see Section 48, Run-Time Diagnostic Messages.
Executing and Debugging HP COBOL Programs Before Execution Before Execution To have an ordinary HP COBOL program (as opposed to one that is a Pathway server) enter debugging mode before executing any instructions, start it with the RUND command instead of the RUN command. Use the same options that you would use with the RUN command (see Executing an HP COBOL Program). To have a Pathway server enter debugging mode before executing any instructions, use the PATHCOM command SET SERVER DEBUG ON.
Executing and Debugging HP COBOL Programs HP COBOL Manual for TNS/E Programs —520347-003 25 -16 Forcefully
26 Input and Output Concepts Input and output are involved in virtually every HP COBOL program. The typical batch HP COBOL program obtains data (input), manipulates it, and produces a report (output). The typical interactive HP COBOL program is a server that obtains a request, collects data (input), and sends a reply (output). Input and output always involve files.
Input and Output Concepts System File Names System File Names A system file name is the name by which the Guardian or OSS file system recognizes a system file. That name is unique, not only on the system where the file is physically located, but also within that system’s network. These rules and the remainder of this topic apply to all system file names in the Guardian file system. For information about system file names in the OSS file system, see Files in the OSS Environment.
Input and Output Concepts System File Names volume-name is a dollar sign ($) followed by an alphabetic character and up to six alphanumeric characters. Example: $volume3. Default: default volume. subvolume-name is an alphabetic character followed by up to seven alphanumeric characters. Example: subvol10. Default: default subvolume. file-id is an alphabetic character followed by up to seven alphanumeric characters. Example: file1234. An example of a permanent disk file name is \mynode.$volume3.subvol10.
Input and Output Concepts COBOL File Names node-name is a backward slash (\) followed by an alphabetic character and up to six alphanumeric characters. Example: \mynode. ldev-number is a dollar sign ($) followed by an integer whose value is less than or equal to 34492. Example: $12345. device-name is a dollar sign ($) followed by an alphabetic character and up to six alphanumeric characters. Example: $printr2. qualifier is a number sign (#) followed by one to seven alphanumeric characters.
Input and Output Concepts Associating COBOL File Names With System File Names Associating COBOL File Names With System File Names The file-control entry for a file associates its COBOL file name with one of: • • • System File Name Special Name DEFINE Name If you want to associate the COBOL file name with a system file name at run time, see #DYNAMIC.
Input and Output Concepts Associating COBOL File Names With System File Names Special Name A special name is a place holder for a specific file whose system file name is determined at run time. Table 26-1. Special Names for System Files Special System File Name Place holder for ...
Input and Output Concepts Associating COBOL File Names With System File Names If you run the program PROG1 with this command, the special name #IN represents the system file INFILE, so INFILE is associated with the COBOL file name MAJRACCT. PROG1 /IN INFILE/ In the OSS environment, #IN is the default input device (FD 0). You cannot use it in SELECT clauses or the SPECIAL-NAMES paragraph as you can in the Guardian environment.
Input and Output Concepts Associating COBOL File Names With System File Names If you run the program PROG1 with this command, the system file $TE1.#E02 is associated with the special name #TERM and, therefore, with the COBOL file name HOME-TERMINAL. PROG1 /TERM $TE1.#E02/ #TEMP The special name #TEMP represents a temporary disk file on the default volume (which is specified by the program’s startup message).
Input and Output Concepts Associating COBOL File Names With System File Names To follow Step 2, you must declare Working-Storage data items to hold the name and the error value returned by the COBOL_ASSIGN_ routine, prompt the user for a file name, and then call the COBOL_ASSIGN_ routine: 01 ADJUSTABLE-STUFF. 03 ADJUSTABLE-NAME PICTURE X(34). 03 ADJUSTABLE-ERROR PICTURE S9(4). . . DISPLAY "What file shall I read?". ACCEPT ADJUSTABLE-NAME.
Input and Output Concepts Prereading File Records Prereading File Records To save execution time by overlapping reading and processing, the HP COBOL runtime routines perform record prereading (starting the read for record n +1 when returning record n to the program) when all of these conditions are true: • • • • • File access mode is SEQUENTIAL. File open mode is INPUT. File exclusion mode is PROTECTED (for a disk file) or EXCLUSIVE (for a disk or nondisk file).
Input and Output Concepts Intercepting Operating System Messages An HP COBOL process ignores operating system messages unless you arrange to have it intercept them. To have an HP COBOL process intercept operating system messages, you must include REPORT and MESSAGE SOURCE clauses in its RECEIVE-CONTROL paragraph. The MESSAGE SOURCE clause provides a mechanism through which a COBOL program can discover the sender of each message received.
Input and Output Concepts Intercepting Operating System Messages HP COBOL Manual for TNS/E Programs —520347-003 26 -12
27 Tape Input and Output HP COBOL batch programs must often read or write files that are on magnetic tape (tape files). Topics: • • • Reading and Writing Tape Files Adding DEFINEs for Tape Files Executing HP COBOL Programs That Use Tape Files If you need further information on reading and writing tape files, see the Guardian Programmer’s Guide. If you want to archive disk files on magnetic tape, use the operating environment’s BACKUP utility.
Tape Input and Output Saving Tape and Time Saving Tape and Time You can save both tape and time by blocking tape file records efficiently—that is, by specifying that each physical record is to contain more than one logical record (the default is one logical record per physical record). Because consecutive physical records are separated by an interrecord gap, longer physical records mean fewer interrecord gaps (less wasted tape).
Tape Input and Output Unlabeled Tape Files For further information on the BLOCK CONTAINS clause, see BLOCK CONTAINS Clause. Unlabeled Tape Files An unlabeled tape file is a tape file that does not have standard ANSI or IBM labels. If a HP COBOL program creates a tape file, the tape file is unlabeled, and any other HP COBOL program can easily read or write it.
Tape Input and Output Unlabeled Tape Files Topics: • • • • How to read or write One File on One Tape How to read or write Several Files on One Tape How to read or write One File on Several Tapes Mount Messages One File on One Tape To read or write one file on one tape, follow Step 1 through Step 5 under Unlabeled Tape Files and then execute this step: Close the file with the CLOSE statement. Do not use a NO REWIND phrase.
Tape Input and Output Unlabeled Tape Files Several Files on One Tape To read or write more than one file on one tape, follow Step 1 through Step 5 under Unlabeled Tape Files and then execute these steps: 1. Close the file with the CLOSE statement, specifying NO REWIND. The NO REWIND phrase prevents the run-time routines from rewinding the tape, so that you can read or write the file that immediately follows the file you just closed. 2.
Tape Input and Output Unlabeled Tape Files One File on Several Tapes To read or write one file that spans several tapes, follow Step 1 through Step 5 under Unlabeled Tape Files and then execute these steps: 1. Close the file with the CLOSE statement, specifying REEL FOR REMOVAL (or UNIT FOR REMOVAL). The REMOVAL phrase rewinds the tape for removal so that you can remove it from the tape drive and replace it with the next tape. 2. Read or write the file again (see Step 5 under Unlabeled Tape Files). 3.
Tape Input and Output Unlabeled Tape Files Example 27-3 assigns the COBOL file name HUGEFILE to the system file name $DRIVE2 (a name that the system administrator assigned to a tape drive) and declares its organization and access modes to be sequential. The first tape is on the tape drive $DRIVE2. The program opens HUGEFILE for exclusive input, reads it, and closes it, rewinding it for removal.
Tape Input and Output Labeled Tape Files If your HP COBOL program must read a FUP-created multitape file, try this: 1. In the SELECT clause of the file-control entry, declare the file to be OPTIONAL. 2. Have the program close and reopen the file when it detects EOF. 3. Have the operator mount the next tape. When the program detects EOF immediately after an OPEN statement, the last reel has been read. 4.
Tape Input and Output Labeled Tape Files Figure 27-1. Software Involved in Labeled-Tape Processing Home Terminal Command Interpreter Process COBOL Mount Messages COBOL Process File System Tape Process Tape Process $ZSVR Server for Tape Processes Operator's Console ($0) Tape Operation Messages TAPECOM Process Operator Responses and Commands VST706.vsd To use a labeled tape file with an HP COBOL program, you must: 1.
Tape Input and Output Labeled Tape Files Describing Labeled Tape Files in a HP COBOL Program In the file-control entry for a labeled tape file, assign the COBOL file name of the labeled tape file to a DEFINE name (for the syntax of a DEFINE name, see DEFINE Names). In the file description entry for a labeled tape file, include a RECORD CONTAINS clause to specify whether the file’s records are of fixed or variable length and to define their size.
Tape Input and Output Labeled Tape Files The system label-processing software checks that the DEFINE attributes are consistent with the tape label specifications; if they are not, the operating environment issues an open error. If the tape label and the data on the tape are inconsistent (for example, if the tape label specifies fixed-length records but the tape contains variable-length records), results are unpredictable.
Tape Input and Output Tape Files of Types Other Than HP Example 27-5.
Tape Input and Output Tape Files of Types Other Than HP Example 27-6. Copying an EBCDIC File to a New ASCII File FUP COPY $DRIVE1,$DRIVE2,EBCDICIN The FUP command in Example 27-7 copies the EBCDIC tape file on tape drive $DRIVE1 to the existing disk file $TEN.APP3.PQ5, converting it to ASCII in the process. Example 27-7. Copying an EBCDIC File to an Existing ASCII File FUP COPY $DRIVE1,$TEN.APP3.PQ5,EBCDICIN The FUP command in Example 27-8 creates the disk file $TEN.APP3.
Tape Input and Output Tape Files of Types Other Than HP HP COBOL data types: • BINARY or COMPUTATIONAL BINARY and COMPUTATIONAL are synonyms. HP COBOL stores a COMPUTATIONAL data item as a 2-byte, 4-byte, or 8-byte binary value, depending on the number of digits in its picture: • Picture Storage S9(01) - S9(04) 1 byte S9(05) - S9(09) 2 bytes S9(10) - S9(18) 4 bytes DISPLAY HP COBOL stores a DISPLAY data item as a sequence of ASCII characters, one for each digit.
Tape Input and Output • Adding DEFINEs for Tape Files NATIVE-n HP COBOL stores a NATIVE-n data item as a signed, numeric, twos-complement, binary integer.
Tape Input and Output Unlabeled Tape Files Unlabeled Tape Files The attributes of unlabeled tape files are: • • • • • • CLASS Attribute (Required) DEVICE Attribute (Required) BLOCKLEN Attribute (Conditional) LABELS Attribute (Optional) RECFORM Attribute (Optional) RETENTION or EXPIRATION Attribute (Optional) CLASS Attribute (Required) The value of the CLASS attribute must be TAPE.
Tape Input and Output Unlabeled Tape Files LABELS Attribute (Optional) The LABELS attribute must have the value OMITTED. With LABELS OMITTED, the system checks the mounted tape for standard ANSI or IBM labels; if the tape has them, the system rewinds and unloads the tape. The LABELS attribute of the DEFINE overrides any LABEL RECORDS clause in your HP COBOL program. Note. The 1985 COBOL Standard classifies the LABEL RECORDS clause as obsolete, so you are advised not to use it. Table 27-2.
Tape Input and Output Labeled Tape Files RETENTION or EXPIRATION Attribute (Optional) Use the RETENTION or EXPIRATION attribute when you want to save a file for any period of time, even part of a day; otherwise, the file expires as soon as you write it, and the system might overwrite the file. The value of the RETENTION or EXPIRATION attribute is an integer, the number of days before the file expires. Caution.
Tape Input and Output Labeled Tape Files Figure 27-2. DEFINE Names and COBOL File Names COBOL Source Program . . . SELECT SALES1Q ASSIGN TO " =SALES-1Q86" . . . FD SALES1Q RECORD CONTAINS 60 CHARACTERS BLOCK CONTAINS 3900 CHARACTERS LABEL RECORDS ARE STANDARD . . . OPEN INPUT SALES1Q. . . . DEFINEs Enabled for the Process =SALES-1Q86 CLASS TAPE, LABELS ANSI, VOLUME SLS86, USE IN, RECFORM F, RECLEN 60, BLOCKLEN 3900 =ACCTS-RECEIVABLE ...
Tape Input and Output Labeled Tape Files LABELS Attribute (Required) The value of the LABELS attribute for a labeled tape file must reflect the type of labels the tape has: Labels LABELS Attribute Value ANSI standard ANSI IBM standard IBM Any other BYPASS BYPASS tells the system to handle a labeled tape file like an unlabeled tape file. The labels are interpreted as data. Use BYPASS if either of these is true: • • The tape has labels that are not ANSI or IBM standard.
Tape Input and Output Labeled Tape Files RECFORM Attribute (Conditional) The RECFORM attribute is required unless you are bypassing labels (the value of the LABELS attribute is BYPASS). The value of the RECFORM attribute must reflect the type of records the tape has and must correspond to the RECORD CONTAINS clause in the file description entry in the program. Table 27-5.
Tape Input and Output Labeled Tape Files DEVICE Attribute (Conditional) The DEVICE attribute is required if you are bypassing labels (the value of the LABELS attribute is BYPASS); otherwise, it is optional. When the DEVICE attribute is required, its value must be the system file name of a tape drive. When the DEVICE attribute is optional, its value overrides the system’s automatic volume recognition. You cannot specify a different device in response to the system mount message.
Tape Input and Output Labeled Tape Files VOLUME Attribute (Optional) The VOLUME attribute identifies the tape. The value of the VOLUME attribute must be the name of the tape volume as it appears in the tape label. This automatic volume recognition enables you or the operator to mount the labeled tape on any available tape drive before or after you start your HP COBOL program.
Tape Input and Output Executing HP COBOL Programs That Use Tape Files Example 27-13.
Tape Input and Output Mount Messages Unlabeled Tapes Without labels, the operating environment cannot use automatic volume recognition to locate the tape, so the mount message from the HP COBOL run-time routine specifies the tape drive on which to mount the tape—the tape drive specified by the DEVICE attribute of the file’s DEFINE. If the mount message appears on a terminal display, you can specify a different tape drive on which to mount the tape.
Tape Input and Output Run-Time Errors Run-Time Errors Table 27-8.
28 Disk Input and Output Both batch programs and transaction-supporting servers use disk files.
Disk Input and Output Allocation Allocation The file system allocates physical storage for a disk file in the form of file extents. A file extent is a contiguous block of storage, starting on a disk sector boundary and containing a multiple of 2,048 bytes (up to 134,215,680 bytes). The file system permits a disk file to have up to 978 extents—one primary extent and up to 977 secondary extents. The primary extent can be a size different from that of the secondary extents.
Disk Input and Output Locking You can erase the contents of a file without purging the file with the FUP command PURGEDATA. An HP COBOL program erases the contents of a file without purging the file simply by opening the file for output. An HP COBOL program can erase the contents of a file by calling routine COBOL_CONTROL_.
Disk Input and Output Ownership and Security Topics: • • • Security Attributes Default File Security Accessing Files on Other Nodes Security Attributes Security attributes of a disk file allow the owner to control access to the file.
Disk Input and Output Ownership and Security Example 28-1. File Accessible Only to Owner and Only Locally FUP SECURE FILE3,"OOOO" The command in Table 28-2 is the same as the command in Table 28-1, except that you can read, write, execute, or purge FILE3 from anywhere on the Expand network. Example 28-2.
Disk Input and Output Fixed-Length and Variable-Length Records If a Pathway server written in HP COBOL creates a file, the security of the file is that of the DEFAULT command active when the monitor process (PATHMON process) governing the server class starts to execute. Accessing Files on Other Nodes For you, as a user on one node, to have any access at all to a file on another node, even when the file’s security attributes permit it, you must have two remote passwords declared on each node.
Disk Input and Output Time Limits Table 28-2. Exclusion Modes and Their Meanings Exclusion Mode While the process that opened the file has it open ... EXCLUSIVE No other process can read or write the file. PROTECTED Any other process can read the file, but no other process can write the file. SHARED Any other process can read or write the file. The exclusion mode can be specified in the OPEN statement or in an ASSIGN command.
Disk Input and Output Sharing Files Among HP COBOL Programs When a HP COBOL run unit opens a file, the file remains open until one of these happens: • • • The run unit explicitly closes the file. The calling program cancels the called program that has the file open (with the CANCEL statement). The run unit terminates execution. A well-structured program unit has all the file activity for a certain file within one called program.
Disk Input and Output Modification Modification With the ENABLE utility, you can build a file-maintenance application that allows you to modify a disk file. ENABLE uses a Data Definition Language (DDL) file description to create a Pathway application that you can use to read and change the data in the disk file. For details, see the ENABLE User’s Guide. Maximum Number of Files The maximum number of files on a volume is determined during system configuration.
Disk Input and Output Structured Files When using an unstructured file, an HP COBOL program still operates on the basis of records, but they are strictly logical records. If one HP COBOL program writes an unstructured file of 80-character records, another program can read it with any record length. If the reading program expects 37-character records, the run-time routines deliver 37-byte pieces of the continuous byte stream.
Disk Input and Output Structured Files Table 28-4. Comparison of Structured File Characteristics (page 2 of 2) Type of Structured File Characteristic Space occupied by a record ...
Disk Input and Output Structured Files Topics: • • • Entry-Sequenced (Sequential) Files Relative Files Key-Sequenced (Indexed or Queue) Files Entry-Sequenced (Sequential) Files An entry-sequenced file created by an HP COBOL program is either a series of fixedlength records or a series of variable-length records. Your program ordinarily reads entry-sequenced files sequentially.
Disk Input and Output Structured Files You can also read the file in record-number order. In this case, Enscribe does not report absent records—it returns the records that exist. Enscribe can report the record number of each record as it is read. When you read a relative file this way, the HP COBOL run-time routines set the relative key data item to reflect the record number. Both Enscribe and HP COBOL (as an HP extension) provide two special record numbers: -1 and -2.
Disk Input and Output Creating and Using HP COBOL Sequential Files Enscribe allocates only as much space on disk as necessary for each key-sequenced file record. Each record can vary in length from empty to the maximum record length defined for the file. In HP COBOL terms, you can write fixed-length or variable-length records (whichever the file was declared to have) of any length up to the limit.
Disk Input and Output Unstructured Files Outside an HP COBOL program, you can use the TACL command FUP CREATE to create an entry-sequenced file that has alternate keys. Unstructured Files An HP COBOL program cannot create an unstructured file directly because the HP COBOL language cannot describe a file as unstructured. To create an unstructured file indirectly, an HP COBOL program calls the FILE_CREATE_ procedure.
Disk Input and Output EDIT Files EDIT Files An EDIT file is a special form of unstructured file whose file code is 101. HP COBOL programs can read, write, and create EDIT files. The file code 101 must be assigned to the file in one of these ways before the HP COBOL program opens the file: • • • • Create the file outside the program (with an HP editor or FUP). Have the HP COBOL program create the file by calling the FILE_CREATE_ procedure.
Disk Input and Output Creating and Using HP COBOL Indexed Files The HP COBOL run-time routines that manipulate relative files convert HP COBOL record numbers to Enscribe record numbers by subtracting 1 from the value of each HP COBOL record number (except in the case of the two special record numbers -1 and -2 explained in Types of HP Disk Files). If a file contains numeric values that are to be used as record numbers, all programs that use the file must use the same record numbering scheme. Example 28-7.
Disk Input and Output Creating and Using HP COBOL Indexed Files An HP COBOL program can create, read, write, and purge indexed files. An HP COBOL program must use the FILE_CREATE_ procedure to create an indexed file that has alternate keys.
Disk Input and Output Creating and Using Queue Files Creating and Using Queue Files A queue file is an indexed file (and therefore, a key-sequenced file) that can function as a queue. Processes can queue and dequeue records in a queue file. Queue files contain variable-length records that are accessed by values in designated key fields. Unlike other key-sequenced files, queue files have prime keys but cannot have alternate keys.
Disk Input and Output Reading a Queue File Reading a Queue File When you read a record of a queue file, you have a choice of: • • Removing the Record From the Queue Leaving the Record in the Queue Removing the Record From the Queue To read a record and remove it from the queue, use the READ ... NEXT WITH LOCK statement. The compiler translates the READ ... NEXT WITH LOCK statement to a call to the Guardian routine READUPDATELOCK[X].
Disk Input and Output Key of Reference Topics: • • • • Key of Reference Alternate Record Keys Positioning Repositioning to New Record With Same Alternate Key Key of Reference COBOL defines the “key of reference” as “the prime or alternate key currently being used to access records within an indexed file.
Disk Input and Output Alternate Record Keys After you have established the key of reference, you can execute sequential READ statements (READ NEXT statements) to read successive records according to that key: records in a relative file in ascending record-number order, records in an indexed file in ascending prime-key order, or records in any structured (sequential) file in ascending alternate-key order. You can also execute sequential READ REVERSED statements to read records in reverse order.
Disk Input and Output Positioning Each record of an alternate-key file has three fields: the alternate key specifier, the value of the alternate key, and the value of the prime key. An alternate key specifier is a two-character code that identifies an alternate key defined for a primary file. An alternate-key file is a key-sequenced file. For every record in the primary file, there are at most as many records in the alternate-key file as there are alternate keys declared for that alternate-key file.
Disk Input and Output Positioning Table 28-5.
Disk Input and Output Positioning Example 28-11. Generic Positioning INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT NAME-FILE ASSIGN TO "$JUICE.APPLE.NAME" ORGANIZATION IS INDEXED ACCESS MODE IS DYNAMIC RECORD KEY IS KEY-NUMBER ALTERNATE RECORD KEY IS KEY-NAME WITH DUPLICATES ... DATA DIVISION. FILE SECTION. FD NAME-FILE RECORD CONTAINS 5 TO 100 CHARACTERS LABEL RECORDS ARE OMITTED. 01 NAME-FILE-REC. 02 KEY-NUMBER PIC X(5). 03 FILLER PIC X(3). 02 KEY-NAME PIC X(35). 02 REDEF-KEY REDEFINES KEY-NAME.
Disk Input and Output Repositioning to New Record With Same Alternate Key Suppose that NAME-FILE contains these records: 00005 00010 00121 01010 12532 43132 52353 54116 54396 ADAMS ADAMSKI JOHNSON ADAMS REITWIESNER SMITH ROTH ADAMS-JONES ADAMSSOHN Without the GENERIC phrase, if the first key is “ADAMS” followed by 30 spaces, the program displays: 00005---ADAMS 01010---ADAMS 54116---ADAMS-JONES 00010---ADAMSKI 54396---ADAMSSOHN 00121---JOHNSON 12532---REITWIESNER 52353---ROTH 43132---SMITH 99999-----EOF
Disk Input and Output Repositioning to New Record With Same Alternate Key The POSITION phrase enables a server to pass the value of the prime key of the most recently processed record back to a requester. The requester can then send the primekey value to a server with its next request, and the server can use that value in a POSITION phrase of the START statement (and also as the alternate key in the KEY phrase) to uniquely specify a record at which to resume processing.
Disk Input and Output Repositioning to New Record With Same Alternate Key Example 28-12. Use of START With the POSITION Phrase (page 2 of 4) INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT MESSAGE-IN ASSIGN TO "$RECEIVE" FILE STATUS IS RECEIVE-FILE-STATUS. SELECT MESSAGE-OUT ASSIGN TO "$RECEIVE" FILE STATUS IS RECEIVE-FILE-STATUS.
Disk Input and Output Repositioning to New Record With Same Alternate Key Example 28-12. Use of START With the POSITION Phrase (page 3 of 4) 1 PART-LIST-REPLY. 02 PRT-HEADER. 03 REPLY-CODE PIC S9(4) COMP. ... {same as PRT-HEADER of PART-DEL-GET-LIST-MSG } 02 LINE-COUNT PIC 9(04). 02 ALL-PART-LINES. 03 PART-LINE OCCURS 10 TIMES. 04 PART-NO PIC X(10). 04 PART-NAME PIC X(50). 04 CUST-NUM PIC 9(06). ... 0 FD PART-FILE LABEL RECORDS ARE OMITTED. 01 PART-DATA-RECORD. 02 PART. 03 PART-NO 03 PART-NAME ...
Disk Input and Output Repositioning to New Record With Same Alternate Key Example 28-12. Use of START With the POSITION Phrase (page 4 of 4) 120-READ-PART-INFO. MOVE PART-NO OF PART-DEL-GET-LIST-MSG TO PART-NO OF PART-DATA-RECORD. PERFORM 945-READ-PART-KEY. IF NO-ERROR PERFORM 914-GET-REPLY ELSE PERFORM 990-BUILD-ERROR-REPLY PERFORM 910-SERVER-REPLY. 200-GET-PART-LIST-RCD. PERFORM 210-INIT-REPLY. PERFORM 220-BUILD-REPLY. 210-INIT-REPLY. MOVE SPACES TO SERVER-REPLY.
Disk Input and Output Optimizing Disk File Processing Optimizing Disk File Processing The features of Enscribe that protect the database from corruption also slow down the Enscribe input and output routines. If you can afford less protection, you can improve the performance of the HP COBOL disk input and output routines.
Disk Input and Output Structured Files The value of number must be in the range 1 through 32 and is interpreted: Value of number Effect on Record Blocking 1 No buffering or HP COBOL Fast I-O 2 Sequential block buffering on input and buffered cache on output if the assigned file qualifies 3 or greater HP COBOL Fast I-O if the assigned file qualifies; if not, sequential block buffering for input and buffered cache for output if the assigned file qualifies; otherwise, normal I-O number is the number o
Disk Input and Output Structured Files Each disk has its own cache. Each cache is configured to have space for a certain quantity of disk data. Each disk device has an associated disk process that performs the physical operations of reading data from the disk into cache memory and writing data from cache memory to the disk. When a process requests a record from a given disk, the Enscribe record manager checks that particular cache for the block that contains the record.
Disk Input and Output Structured Files HP COBOL Fast I-O Fast I-O is an HP COBOL enhancement in input-output performance beyond that of sequential block buffering or buffered cache. With HP COBOL Fast I-O, the HP COBOL run-time routines use an auxiliary block buffer and perform the blocking and deblocking in local storage. This process operates 2 or 3 times faster than when the operating environment performs the blocking and deblocking operations.
Disk Input and Output Files With Alternate Keys For a file opened for input, HP COBOL Fast I-O allocates space for double buffering from a buffer pool that is in its own extended data segment and is of a fixed size. Buffer size is determined by multiplying the number in the RESERVE clause by the data block size of the file (to see this size, use the command FUP INFO file-name, DETAIL).
Disk Input and Output Partitioned Files Making the Main File Entry-Sequenced or Relative If your main file has several keys defined but no one key is used substantially more than any other keys, consider making that main file a relative or entry-sequenced file rather than a key-sequenced file. Every time you read a key-sequenced file by prime key, you cause two possible physical read operations: one for the key and one for the record.
Disk Input and Output Optimizing Disk File Storage To open a partitioned file when some partitions cannot be accessed, an HP COBOL program must use the routine COBOL_SPECIAL_OPEN_. If all partitions can be accessed, an HP COBOL program can open a partitioned file with the OPEN statement. For more information about partitioned files, see Partitioned Files.
Disk Input and Output Locking and Unlocking Files and Records Locking and Unlocking Files and Records The most complete way for a process to lock a file is to open the file for exclusive access (open it with the exclusion mode EXCLUSIVE). This strategy prevents all other processes from reading or writing the file. If it is not feasible for one process to have exclusive control of a file for when it has the file open, there are alternatives. One alternative is protected access.
Disk Input and Output Using Enscribe and Operating System Routines Suppose you have a file declared by these entries: SELECT OAK-FILE ASSIGN TO "$OAK.ACORN.TREE" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS OAK-STATUS. FD 01 OAK-FILE LABEL RECORDS ARE OMITTED. OAK-RECORD. 02 ... Suppose that you open the file with this statement: OPEN INPUT OAK-FILE WITH TIME LIMITS SHARED. Suppose that your program includes a declaratives section such as: DECLARATIVES. OAK-FILE-USE-SECTION.
Disk Input and Output Physical File Names An HP COBOL program can call an Enscribe or other operating system routine with the ENTER statement. Some Enscribe and operating system routines are not safe to use from an HP COBOL program; others are. Caution. Generally, it is not safe to mix HP COBOL input-output operations and direct calls to Enscribe input-output routines for the same open file.
Disk Input and Output Obtaining File Numbers and Other File Attributes The data item ONE-BYTE-SYSTEM-NUMBER is a 1-byte integer whose value is in the range 0 through 254. Each node in an Expand network has a unique system name and a unique system number. The number and name of a node are established during system generation. Obtaining File Numbers and Other File Attributes When a process opens a file, Enscribe assigns the file a number that is unique within that process.
Disk Input and Output Purging a File From an HP COBOL Program To enable your HP COBOL program to detect that two of its HP COBOL file names refer to the same external file, call operating system routine FILENAME_COMPARE_. FILENAME_COMPARE_ accepts two file names in internal form and returns a numeric value: Value Returned Meaning -1 The two internal file names do not refer to the same physical file. 0 The two internal file names refer to the same physical file.
Disk Input and Output Purging the Contents of a File From an HP COBOL Program Example 28-13. Purging a File From an HP COBOL Program (page 2 of 2) PROCEDURE DIVISION. ... MOVE "$FIFTY.NIFTY.SHIFTY" TO EXTERNAL-NAME. MOVE "$FIFTY" TO VOL-NAME. MOVE "NIFTY" TO SUBVOL-NAME. MOVE "SHIFTY" TO FILE-NAME. ENTER "FILE_PURGE_" USING EXTERNAL-NAME (1:19) GIVING FS-ERROR. ENTER TAL "COBOLFILEINFO" USING INTERNAL-NAME PURGE-RESULT IF PURGED-OK ...
Disk Input and Output Renaming a File From an HP COBOL Program The HP COBOL library routine COBOL_CONTROL_ is a multipurpose routine that calls the operating system routine CONTROL, and whose function is determined by an operation code. The operation code 20 enables a process to purge only the contents of a file if the process has write access to the file.
Disk Input and Output Creating a File Having Alternate Keys From an HP COBOL Program The file-control entry and file description entry are: SELECT T-file-1 ASSIGN TO "ISFILE" ORGANIZATION IS INDEXED RECORD KEY IS K1 ALTERNATE RECORD KEY IS AK1 ACCESS MODE IS DYNAMIC FILE STATUS IS Fs ... FD T-file-1 LABEL RECORDS OMITTED. 01 T-rec-1. 02 K1. 03 K1-fp PIC XX. 03 FILLER PIC X. 02 Ak1. 03 Fp PIC X(5). 03 Lp PIC X(5). 02 FILLER PIC X(20). 02 rw-flag PIC X(4). 02 T-rec-no PIC 999. ...
Disk Input and Output Creating a File Having Alternate Keys From an HP COBOL Program 01 Number-of-items NATIVE-2 VALUE 9. 01 01 01 01 Values-array. 02 File-type-v 02 Lrl-v 02 Key-offset-v 02 Key-length-v 02 Number-keys-v 02 Key-descriptor-v.
Disk Input and Output Creating a File Having Alternate Keys From an HP COBOL Program Example 28-14.
Disk Input and Output Creating a File Having Alternate Keys From an HP COBOL Program HP COBOL Manual for TNS/E Programs —520347-003 28 -48
29 Terminal Input and Output Most interaction between users and an HP system is conducted through video display terminals. The HP COBOL language has no mechanisms for full-screen block inputoutput. On an HP system, a typical application uses Pathway/TS to write requester programs in SCREEN COBOL to handle terminal input and output and uses HP COBOL or pTAL server programs to handle database input and output. Occasionally, an HP COBOL process must communicate with a terminal directly.
Terminal Input and Output Using ACCEPT and DISPLAY With a Terminal Using ACCEPT and DISPLAY With a Terminal ACCEPT and DISPLAY statements transfer small amounts of data between a device and a process. The device is not a file; it is neither mentioned in the HP COBOL program’s FILE-CONTROL paragraph nor described in the program’s File Section.
Terminal Input and Output Guardian Environment Example 29-1. ACCEPT and DISPLAY Statements With a Terminal (page 2 of 2) IDENTIFICATION DIVISION. PROGRAM-ID. TERMINAL-ACCEPT-DISPLAY. AUTHOR. MO COBOL. DATE-WRITTEN. 29 FEBRUARY 1984. DATE-COMPILED. ****************************************************** * This program illustrates ACCEPT and DISPLAY with * * and without mnemonic names. * ****************************************************** ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER.
Terminal Input and Output OSS Environment OSS Environment These are true in the OSS environment but not in the Guardian environment: • • • No prompt is given for an ACCEPT statement. If a DISPLAY statement includes mnemonic-name, it must be either the OSS pathname of a Guardian file or the name of an OSS text file. If an ACCEPT statement includes mnemonic-name, it must be the OSS pathname of a Guardian process or terminal.
Terminal Input and Output Using a Terminal as a File Example 29-2. Using a Terminal as a File IDENTIFICATION DIVISION. PROGRAM-ID. TERMINAL-READ-WRITE. AUTHOR. BO COBOL. DATE-WRITTEN. 29 FEBRUARY 1984. DATE-COMPILED. ************************************************************* * This program illustrates the use of a terminal as a * * file * ************************************************************* ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP TXP. OBJECT-COMPUTER. HP TXP.
Terminal Input and Output Prompting the Terminal Operator for Input Prompting the Terminal Operator for Input This topic assumes that you are using the terminal as a file (see Using a Terminal as a File). HP COBOL has a useful extension that can be used with terminal input and output. The HP COBOL READ statement is extended to include a PROMPT phrase.
Terminal Input and Output Prompting the Terminal Operator for Input Example 29-3. READ Statement With PROMPT Phrase IDENTIFICATION DIVISION. PROGRAM-ID. TERMINAL-READ-WRITE. AUTHOR. FLO COBOL. DATE-WRITTEN. 29 FEBRUARY 1984. DATE-COMPILED. ************************************************************* * This program illustrates the use of READ PROMPT * * for a terminal file * ************************************************************* ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP TXP.
Terminal Input and Output Sharing a Terminal Sharing a Terminal For development, you normally use a terminal that is associated during system generation with a command interpreter (such as TACL). That command interpreter uses your terminal as its IN file, its OUT file, and its home terminal. Most terminals on a production system do not have command interpreters associated with them.
Terminal Input and Output Getting Break Ownership Getting Break Ownership When you press Break on a terminal, the process that owns Break receives a system message on $RECEIVE. A process discovers that Break has been pressed by reading $RECEIVE. An HP COBOL process, lacking the ability to perform NOWAIT input and output directly, must open $RECEIVE with an OPEN statement with a TIME LIMITS phrase and then try to read $RECEIVE from time to time.
Terminal Input and Output Communicating With an Operator or Process Because the message that Break has been pressed is a system message, a nonprivileged process cannot directly transfer the message to another process. Some other protocol must be established between the two processes. Example 29-4. Transferring Break Ownership WORKING-STORAGE SECTION. 01 FILE-NUMBER PIC S9(4). 01 PROCESS-HANDLE PIC X(20). 01 ERROR-NUMBER PIC S9(5) COMP. 01 PREV-BREAK-OWNER. 03 PREV-OWNER NATIVE-2.
Terminal Input and Output Writing to a Console Topics: • • • • Writing to a Console Writing to a Terminal or Printer Reading From a Terminal or Process Reading and Writing Numeric Data Writing to a Console The system operator console terminal device on any HP system is named $0 (“dollar zero”). It can be a hard-copy device or the Operations and Service Processor (OSP).
Terminal Input and Output Writing to a Terminal or Printer Each console terminal device on your node has a unique name. The names of consoles other than the system operator console are determined by the system generation. A program can contain any number of mnemonic names, each associated with a terminal device. The syntax of the DISPLAY statement limits the name in the UPON phrase to be a mnemonic name.
Terminal Input and Output Reading and Writing Numeric Data The compiler accepts this form of the ACCEPT statement only if it has already encountered an entry in the SPECIAL-NAMES paragraph associating MY-NAME-FORDOLLAR-QQQ with some device or process; for example: SPECIAL-NAMES. FILE "$QQQ" IS MY-NAME-FOR-DOLLAR-QQQ. Each time an ACCEPT statement in a process executes, the process opens the terminal or process, collects the characters, and closes the terminal or process.
Terminal Input and Output Reading and Writing Numeric Data Example 29-6. Reading and Writing Numeric Data (page 2 of 2) DATA DIVISION. WORKING-STORAGE SECTION. 01 A PICTURE 99999. 01 B PICTURE 999V999. 01 C PICTURE S999V999. 01 D PICTURE 999.999. 01 E PICTURE 9999V9999 USAGE IS COMPUTATIONAL. 01 F PICTURE USAGE IS COMPUTATIONAL. PROCEDURE DIVISION. Z. ACCEPT A. DISPLAY ACCEPT B. DISPLAY ACCEPT C. DISPLAY ACCEPT D. DISPLAY ACCEPT E. DISPLAY ACCEPT F. DISPLAY STOP RUN. A. B. C. D. E. F.
Terminal Input and Output Logging Program Activity Information to a Terminal Logging Program Activity Information to a Terminal Whenever a process sends a message to the system operator console terminal device ($0), the operating environment can automatically duplicate the message to the standard log file, which can be a terminal.
Terminal Input and Output Logging Program Activity Information to a Terminal HP COBOL Manual for TNS/E Programs —520347-003 29 -16
30 Printer and Spooler Output There are two ways that a process can write a report to paper: it can write directly to a printer or it can write to a spooler collector. When a process writes directly to a printer, it has exclusive use of the printer from the time it opens the file until the time it closes the file. When a process writes to a spooler collector, the spooler collector accumulates the lines of the report on a disk and does not engage a printer until the process closes the file.
Printer and Spooler Output Understanding Spoolers GUARDIAN-ERR contains the file-system error number that specifies the reason the printer was not available. Typical values for GUARDIAN-ERR are 14 (device does not exist) and 12 (file in use). If the file is in use, the process can call the operating system routine DELAY to let some time pass and then try the open operation again. If the printer is available, the open operation succeeds, and the process can go ahead and write to the printer.
Printer and Spooler Output Spooler Components Supervisor Process The supervisor process communicates with and monitors the other processes and decides when and where to print output. The supervisor is an HP product and is started and managed by the system manager. A system can have more than one spooler supervisor; this can be useful for systems with vast numbers of print jobs or systems with special reporting needs. If a system has only one supervisor, its name is usually $SPLS.
Printer and Spooler Output Jobs Jobs A job is analogous to a file. When you write to the spooler, you are creating a job. The spooler assigns each job a number. It starts at 1 and advances by 1 up to a maximum (specified when the spooler was started), not to exceed 4095. When the spooler reaches the maximum job number, it starts over with 1. If the job number the spooler tries to use is currently being used, the spooler advances until it finds a job number that is not being used. Each job has an owner.
Printer and Spooler Output Jobs Suppose your installation has 12 printers, of which 4 are stocked with narrow paper. Three of them are at the other end of the building (in room 145), and one is near your work place (in room 301). Suppose your spooler designates this group of printers as NARROW, and within that group designates the printers as RM145A, RM145B, RM145C, and RM301. If you do not care which narrow-paper printer your report is printed on, you can assign the output file to $S.#NARROW.
Printer and Spooler Output Jobs A job in the HOLD state remains in the spooler until you or a system operator changes the job’s state or deletes the job. Remember that the number of jobs the spooler can hold is limited, as is the amount of disk space available for the text of those jobs. Number of Copies The default number of copies is 1. If you want several copies of your report, specify a number of copies (a number in the range from 1 through 32,767).
Printer and Spooler Output Using a Spooler If your installation prints invoices, you might specify INVOICE as the form name for a report. When the time comes to print the invoices, the operator loads the proper paper forms on the chosen device and sets the device’s form name to INVOICE. When both the location and form name of a spooler job match the location and form name of the device, the spooler prints the job.
Printer and Spooler Output Spooling Program Output Spooling Program Output For its output, an HP COBOL program can use any of: • • • Level-1 Spooling Level-2 Spooling Level-3 Spooling Level-1 Spooling Level-1 spooling uses the spooler collector as a simple output file: you assign the COBOL file name of the output file to a system name that is a spooler collector (with or without a location name) and operate on the file with the HP COBOL statements OPEN, WRITE, REWRITE, and CLOSE.
Printer and Spooler Output Spooling Program Output The other parameters of the COBOL_SPECIAL_OPEN_ routine enable you can specify: • • • • • • • • • • • • • • • Exclusion mode Sync depth Whether a page-eject precedes the first page printed Location name Form name Report name Number of copies Page size Flags that set the job priority and the attributes HOLD and HOLDAFTER Owner Maximum number of lines Maximum number of pages Whether to create a regular or code-129 spooler file Whether a form feed is to be
Printer and Spooler Output Spooling Program Output Example 30-2. Level-2 Spooling (page 2 of 2) FD 01 01 SPOOLER-FILE RECORD IS VARYING FROM 80 TO 132 CHARACTERS. SPOOLER-SHORT-LINE PIC X(80). SPOOLER-LONG-LINE PIC X(132). WORKING-STORAGE SECTION. 01 SPOOLER-FILE-STAT PIC XX. 01 LOCATION-NAME PIC X(16) VALUE 01 REPORT-NAME PIC X(16) VALUE * Flag for HOLDAFTER (32), PRIORITY 2 01 FLAGS PIC S9(4) VALUE 01 ERROR-CODE PIC S9(4). ... "#MYSTUF". "PRIVATE PROPERTY". (+2 = 34) 34. PROCEDURE DIVISION. ...
Printer and Spooler Output Using PERUSE Table 30-1.
Printer and Spooler Output Using PERUSE Example 30-3. PERUSE Output PERUSE - T9101D20 - (8JUN92) JOB 1171 2423 STATE READY READY PAGES 3 4 COPIES 1 1 SYSTEM PRI 4 4 HOLD A \LEO LOCATION #EXCEP R01 #MURPHY REPORT DEVELOP JAN DEVELOP JAN _ Topics: • • • Current Job Current Position Common PERUSE Operations For more information about PERUSE, see the Spooler Programmer’s Guide. Current Job The current job is the job to which the spooler is currently devoting its attention.
Printer and Spooler Output Using PERUSE HP COBOL Manual for TNS/E Programs —520347-003 30 -13
Printer and Spooler Output Using PERUSE Common PERUSE Operations After you have established a current job, you can perform the operations such as those listed in Table 30-2 (all operations apply to the current job unless otherwise specified). Table 30-2 is not a complete list of PERUSE commands; for more information, see the Guardian User’s Guide. Table 30-2.
Printer and Spooler Output Using PERUSE Suppose that the last page of the listing contains a summary, and you want to check that first. You enter: _LIST L The last page of the listing appears on your terminal screen. If it looks acceptable, you can relocate the listing to a defined device by entering a command such as: _LOC #LP5 If the printer associated with #LP5 is not busy, your job starts printing there. As soon as the job is printed, the spooler deletes the job unless its HOLDAFTER attribute is set.
Printer and Spooler Output Using SPOOLCOM If you have a job in the HOLD or READY state, you can delete it by making it the current job and issuing the DELETE command. Using SPOOLCOM Although most of your interaction with the spooler is likely to be through PERUSE or another perusal process, there are a few things you might want to do for which SPOOLCOM can be more helpful than PERUSE.
Printer and Spooler Output Using SPOOLCOM Table 30-3. SPOOLCOM Operations and Commands (Partial List) (page 2 of 2) Operation Command Report the status of the spooler’s print processes PRINT Report the status of the spooler SPOOLER The subcommands most useful to the application programmer are: • • JOB DEV JOB The SPOOLCOM command JOB is very powerful and flexible.
Printer and Spooler Output Using SPOOLCOM For two jobs, SPOOLCOM requires more keystrokes than PERUSE, but suppose you wanted to delete all your jobs created on or before January 11.
Printer and Spooler Output Controlling Vertical Spacing in a Printed Report This command tells the spooler to skip forward to page 98 of the job. The skipping capability is related to the device, not to the job. Skipping capability is useful is when the printer has jammed or the ribbon failed and ruined part of your listing.
Printer and Spooler Output Skipping Lines Skipping Lines To leave a blank line in your report before printing the record DETAIL-X, use this form of the WRITE statement: WRITE DETAIL-X AFTER ADVANCING 2 LINES To print the record DETAIL-Y and then leave a blank line, use this form of the WRITE statement: WRITE DETAIL-Y BEFORE ADVANCING 1 LINE Do not follow the preceding statement with another WRITE AFTER statement, or you will not get a blank line.
Printer and Spooler Output Skipping to a New Page Skipping to a New Page To have your program deliver a print line to the top of a new page, include an AFTER ADVANCING PAGE phrase in the WRITE statement. If you want the program to deliver a print line, then skip to the top of a page, include a BEFORE ADVANCING PAGE phrase in the WRITE statement.
Printer and Spooler Output Formatting Pages of a Printed Report This file description illustrates the LINAGE clause for this type of page: FD SHOW-LINAGE LABEL RECORDS ARE OMITTED LINAGE IS 60 LINES WITH FOOTING AT 55 LINES AT TOP 3 LINES AT BOTTOM 3. One tenet of structured programming is that there be one WRITE procedure for each output file; the program builds the line for delivery and then performs the write procedure. This situation is a perfect basis for using the LINAGE clause.
Printer and Spooler Output Logging Program Activity Information to a Printer Logging Program Activity Information to a Printer To record a log of program activity to a printer, you can use either of these statements: • • DISPLAY WRITE (usually preferable) DISPLAY If you use the DISPLAY statement to send messages to a printer for shared access, you must associate a mnemonic name with the printer device name (such as $LP) in the SPECIAL-NAMES paragraph.
Printer and Spooler Output WRITE HP COBOL Manual for TNS/E Programs —520347-003 30 -24
31 Process Initiation, Communication, and Management On a NonStop system, a process is a running program.
Process Initiation, Communication, and Management Memory and Virtual Memory Figure 31-1. Process Creation, Execution, and Termination Program File Creation Execution Termination Process Process Process CPU Memory Tables Allocation Deallocation Resources PCB Table Entry Resident Memory Virtual Disk Space VST709.
Process Initiation, Communication, and Management Initiating a Process From an HP COBOL Program A process can modify its data but not its code; therefore, the operating environment can fetch code pages needed from disk but does not need to restore them to disk; the operating environment must rewrite data pages to disk when their physical memory is surrendered.
Process Initiation, Communication, and Management $RECEIVE $RECEIVE $RECEIVE is like one end of a communications conduit. It is similar to a courier who brings you a message and can be dismissed or sent back with a reply. From the perspective of a process, $RECEIVE appears to be a sequential file. The syntax for communicating with $RECEIVE in an HP COBOL program is, therefore, based on the syntax for communicating with an ordinary HP COBOL sequential file.
Process Initiation, Communication, and Management $RECEIVE $RECEIVE as Separate Input and Output Files The most common way to use $RECEIVE is to open it in INPUT mode for one file, and in OUTPUT or EXTEND mode for one or more other files. Figure 31-2. $RECEIVE as Separate Input and Output Files Task Message through TASKS-IN Requester Server Reply Message through RESPONSE-OUT Reply Message through ERROR-MSG VST710.
Process Initiation, Communication, and Management $RECEIVE Example 31-1. Requester Code (page 2 of 2) PROCEDURE DIVISION. ... OPEN I-O TRANSACTIONS SYNCDEPTH 2. ... MOVE TASK-CODE TO TRAN-CODE. MOVE ACCOUNT-IN TO TRAN-ACCOUNT-NUMBER. READ TRANSACTIONS RECORD WITH PROMPT TRAN-REQUEST ... Example 31-2. Server Code (page 1 of 2) ... SELECT TASKS-IN ASSIGN TO "$RECEIVE" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL.
Process Initiation, Communication, and Management $RECEIVE Example 31-2. Server Code (page 2 of 2) PROCEDURE DIVISION. ... OPEN INPUT TASKS-IN. OPEN OUTPUT RESPONSE-OUT ERROR-MSG. ... READ-A-TASK. READ TASKS-IN AT END CLOSE TASKS-IN OPEN INPUT TASKS-IN GO TO READ-A-TASK. IF TCODE = 1 PERFORM ... IF WS-BALANCE > 0 MOVE WS-BALANCE TO BALANCE WRITE BALANCE ELSE MOVE WS-ERR-CODE TO ERROR-CODE MOVE MESSAGE(WS-ERR-CODE) TO ERR-MSG WRITE ERROR-ON-TASK. ...
Process Initiation, Communication, and Management $RECEIVE Example 31-3. Requester Code (page 2 of 2) FD 01 TRANSACTIONS LABEL RECORDS ARE OMITTED RECORD CONTAINS 1 TO 8 CHARACTERS. TRAN-RESPONSE. 05 RESULT-CODE PICTURE 9. 88 RESULT-OK VALUE IS 1. 88 RESULT-ERROR VALUE IS 2. ... 05 NEW-BALANCE PICTURE 9(7). ... WORKING-STORAGE SECTION. ... 01 TRAN-REQUEST. 05 TRAN-CODE PICTURE 9. 88 TRAN-PMT VALUE IS 1. ... 05 ACCOUNT-NUMBER PICTURE 9(6). ... PROCEDURE DIVISION. ... OPEN I-O TRANSACTIONS SYNCDEPTH 1. ..
Process Initiation, Communication, and Management Process Names Example 31-4. Server Code (page 2 of 2) DATA DIVISION. ... FD TASKS-IN LABEL RECORDS ARE OMITTED RECORD CONTAINS 1 TO 8 CHARACTERS. 01 TRAN-REQUEST. 05 TRAN-CODE PICTURE 9. 88 TRAN-PMT VALUE IS 1. ... 05 ACCOUNT-NUMBER PICTURE 9(6). ... 01 TRAN-RESPONSE. 05 RESULT-CODE PICTURE 9. 88 RESULT-OK VALUE IS 1. 88 RESULT-ERROR VALUE IS 2. ... 05 NEW-BALANCE PICTURE 9(7). ... PROCEDURE DIVISION. ... OPEN I-O TASKS-IN. ... READ TASKS-IN.
Process Initiation, Communication, and Management Example of Simple Interprocess Communication To find the names of processes currently active, use the TACL command PPD. NonStop systems maintain the list of process names in a destination control table (DCT). The systems recognize the PPD command as a request for a tabulation of information about named processes, not unnamed processes. Example 31-5. Report Produced by PPD Command NAME PID1 PID2 $Z000 $CRT2 $NULL $CMON $IMON $DM00 $DM01 ...
Process Initiation, Communication, and Management Example of Simple Interprocess Communication Figure 31-4. $RECEIVE From PITCHER to CATCHER text line "PITCHER" $CATCH VST712.vsd The bold text in Example 31-6 is significant. Note that, in PITCHER, the file for CATCHER is opened for I-O even though it is being used only for output.
Process Initiation, Communication, and Management Example of Simple Interprocess Communication Example 31-6. PITCHER Code (page 2 of 2) DATA DIVISION. FILE SECTION. FD REPORT-OUT LABEL RECORDS ARE OMITTED. 01 REPORT-LINE. 05 REPORT-END PICTURE X(3). 88 LAST-LINE-ARRIVED VALUE "END". 05 REPORT-REST PICTURE X(77). PROCEDURE DIVISION. A. OPEN I-O REPORT-OUT. PERFORM TRANSPUT UNTIL LAST-LINE-ARRIVED. STOP RUN. TRANSPUT. ACCEPT REPORT-LINE. WRITE REPORT-LINE. Example 31-7.
Process Initiation, Communication, and Management RECEIVE-CONTROL Paragraph Example 31-7. CATCHER Code (page 2 of 2) DATA DIVISION. FILE SECTION. FD PRINT-LINES-IN LABEL RECORDS ARE OMITTED. 01 LINE-IN PICTURE X(80). WORKING-STORAGE SECTION. 01 PRINT-STATUS PICTURE X(2). 88 SENDER-DISAPPEARED VALUE "10". PROCEDURE DIVISION. A. OPEN INPUT PRINT-LINES-IN. PERFORM TRANSPUT THROUGH END-TRANS UNTIL SENDER-DISAPPEARED. STOP RUN. TRANSPUT. READ PRINT-LINES-IN AT END GO TO END-TRANS. DISPLAY LINE-IN. END-TRANS.
Process Initiation, Communication, and Management • At-End Condition It designates a data item to contain the message source descriptor. This fixedformat item is defined in RECEIVE-CONTROL Paragraph.
Process Initiation, Communication, and Management Summary of $RECEIVE Rules This at-end condition is handled as an end of file for $RECEIVE. If a file status code data item is defined, it is set to “10” (EOF). Control passes to the statement in the AT END phrase or to a USE procedure if no AT END phrase is present. If the server is a Pathway server, it must stop itself when it detects an at-end condition.
Process Initiation, Communication, and Management Simple Server Example Simple Server Example The simple server in Example 31-8 looks up items in a telephone directory. Example 31-8. Simple Server (page 1 of 4) IDENTIFICATION DIVISION. PROGRAM-ID. BRIEF-EXAMPLE. AUTHOR. ZANE COBOL. DATE-WRITTEN. 29 February, 1988 DATE-COMPILED. ************************************************************************** * This simple server performs telephone-book lookups. * * Given a name, it reports the name and a number.
Process Initiation, Communication, and Management Simple Server Example Example 31-8. Simple Server (page 2 of 4) FD MESSAGE-OUT LABEL RECORDS ARE OMITTED record is variable length. RECORD CONTAINS 1 TO 200 CHARACTERS. 01 PHONE-REPLY-MSG. 05 REPLY-CODE PIC S9(4) COMP. 000 = OK, reply contains a value 900 = no match in phone book 05 LOOKUP-CODE PIC X. 88 NAME-LOOKUP VALUE "N". 88 PHONE-LOOKUP VALUE "#". 05 LOOKUP-NUM PIC X(10). 05 LOOKUP-NAME PIC X(35). 01 BAD-PHONE-REPLY-MSG.
Process Initiation, Communication, and Management Simple Server Example Example 31-8. Simple Server (page 3 of 4) ***************************************************************** UA-MESSAGE-OUT SECTION. USE AFTER ERROR PROCEDURE ON MESSAGE-OUT. UA-MESSAGE-OUT-PROC. IF R-STAT-1 > 1 DISPLAY " ERROR ON MESSAGE-OUT FILE " " STAT-1 = " R-STAT-1 " STAT-2 = " R-STAT-2. ***************************************************************** END DECLARATIVES.
Process Initiation, Communication, and Management Simple Server Example Example 31-8. Simple Server (page 4 of 4) B-01-NAME-LOOKUP-PROC. MOVE LOOKUP-NAME OF MESSAGE-IN TO PH-EMPLOYEE-NAME START PHONE-BOOK KEY IS = PH-EMPLOYEE-NAME. IF NOT PHONE-FILE-OK MOVE START-FAILED-REPLY TO REPLY-CODE OF MESSAGE-OUT ELSE READ PHONE-BOOK IF PHONE-FILE-OK PERFORM B-02-COPY-TO-REPLY ELSE MOVE NONE-FOUND-REPLY TO REPLY-CODE OF MESSAGE-OUT ... B-01-PHONE-LOOKUP-PROC. MOVE LOOKUP-NUM OF MESSAGE-IN TO PH-EMPLOYEE-PHONE-NUM.
Process Initiation, Communication, and Management Managing a Process Managing a Process Besides creating processes and communicating with processes, a process might need to obtain information about itself or about some other process in the same system or another system on the same Expand network.
Process Initiation, Communication, and Management Determining the Node (System Number) Example 31-9. PROCESSHANDLE_GETMINE_ and PROCESSHANDLE_DECOMPOSE_ Procedures WORKING-STORAGE SECTION. 01 PROCESS-HANDLE 01 CPU-PIN. 05 CPU 05 PIN 01 ERROR-NUMBER 01 NULL-PH ... PIC X(20). PIC S9(2) COMPUTATIONAL. NATIVE-2. PIC S9(5) COMPUTATIONAL. PIC X(20) VALUE ALL HIGH-VALUES. PROCEDURE DIVISION. ...
Process Initiation, Communication, and Management Identifying the Message Source Example 31-10. Determining a Process’s Node (System Number) (page 2 of 2) ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP TXP. OBJECT-COMPUTER. HP TXP. DATA DIVISION. WORKING-STORAGE SECTION. 01 PROCESS-HANDLE 01 CPU-PIN. 05 CPU 05 PIN 01 ERROR-NUMBER 01 SYSTEM-NAME 01 SYSTEM-NUMBER 01 SYSTEM-NAME-LENGTH PIC X(20). NATIVE-2. NATIVE-2. PIC S9(5) COMP. PIC X(8). NATIVE-2. NATIVE-2. PROCEDURE DIVISION.
Process Initiation, Communication, and Management Identifying the Message Source Example 31-11 uses the MESSAGE SOURCE clause to acquire the message-source record. It reads messages on $RECEIVE and displays the processor/PIN, process name, and message code of the message, then displays the message. WHO-SENTTHAT detects whether the sender has an explicit process name. If the sender had an explicit process name, the program determines the processor number and PIN and displays them and the process name.
Process Initiation, Communication, and Management Determining the Status Example 31-11. MESSAGE-SOURCE Clause (page 2 of 2) WATCH. READ MESSAGE-IN-FILE. * The READ causes the MESSAGE-SOURCE-REC to be set. PERFORM CHECK-STATUS. CHECK-STATUS. MOVE SPACES TO PROCESS-NAME. ENTER TAL "PROCESSHANDLE_DECOMPOSE_" USING PROCESS-HANDLE CPU PIN * No node number OMITTED * No node name OMITTED * No nodename length OMITTED PROCESS-NAME PROCESS-NAME-LEN GIVING ERROR-NUMBER.
Process Initiation, Communication, and Management Determining the Status Topics: • • Accessor IDs Search Mode Accessor IDs The creator accessor ID and process accessor ID are elements of the security system of the operating environment. Every user has a unique user name and a corresponding unique user ID. A user name is of the form: groupname.username where groupname is the name of the group to which the user belongs, and username is a name identifying the individual user within the group.
Process Initiation, Communication, and Management Determining the Status In Example 31-12, an HP COBOL program uses the PROCESS_GETINFO_ routine to discover its environment and then reports the information to its home terminal. Example 31-12. PROCESS_GETINFO_ Routine (page 1 of 3) IDENTIFICATION DIVISION. PROGRAM-ID. PROBE. AUTHOR. TRACY COBOL. INSTALLATION. TRANSACTIONS ANONYMOUS. DATE-WRITTEN. 03 FEBRUARY 2000. DATE-COMPILED. 03 FEBRUARY 2000.
Process Initiation, Communication, and Management Determining the Status Example 31-12. PROCESS_GETINFO_ Routine (page 2 of 3) PROCEDURE DIVISION. WHO. MOVE ZERO TO BYTE-AS-NUMBER. ENTER TAL "PROCESSHANDLE_GETMINE_" USING PROCESS-HANDLE GIVING ERROR-RETURN.
Process Initiation, Communication, and Management Determining the Status Example 31-12. PROCESS_GETINFO_ Routine (page 3 of 3) DISPLAY "I am process (" CPU "," PIN "), named " PROCESS-NAME. PERFORM CAPTURE-ACCESSOR-IDS. DISPLAY "My creator accessor ID is " CREATOR-EDITED. DISPLAY "My process accessor ID is " PROCESS-EDITED. DISPLAY "My priority is " PRIORITY. DISPLAY "My loadfile name is " PROGRAM-FILE-NAME. DISPLAY "My home terminal is " HOME-TERMINAL. STOP RUN. CAPTURE-ACCESSOR-IDS.
Process Initiation, Communication, and Management Determining the Status Example 31-13. Reporting Processes With Program’s Accessor ID (page 1 of 3) IDENTIFICATION DIVISION. PROGRAM-ID. WHAT-AM-I-DOING. AUTHOR. BRINDLEY COBOL. INSTALLATION. TRANSACTIONS ANONYMOUS. DATE-WRITTEN. 29 FEBRUARY 1988. DATE-COMPILED. ***************************************************************** * This program hunts out and reports all processes owned by * * the current user.
Process Initiation, Communication, and Management Determining the Status Example 31-13. Reporting Processes With Program’s Accessor ID (page 2 of 3) PROCEDURE DIVISION. WHATS-HAPPENING. * Start with cpu-PIN of 0,0 MOVE LOW-VALUES TO CPU-PIN. * Get owner's process accessor id ENTER TAL "PROCESS_GETINFO_" USING PROCESS-HANDLE OMITTED OMITTED PRIORITY OMITTED HOME-TERMINAL OMITTED OMITTED CREATOR-ACCESSOR-ID PROCESS-ACCESSOR-ID OMITTED OMITTED PROGRAM-FILE-NAME OMITTED OMITTED GIVING ERROR-RETURN.
Process Initiation, Communication, and Management Identifying the Creator Example 31-13. Reporting Processes With Program’s Accessor ID (page 3 of 3) REPORT-A-MATCH. PERFORM EDIT-CPU-PIN. DISPLAY "(" NUMERIC-CPU "," NUMERIC-PIN ") " PROCESS-EDITED " " PRIORITY " ". DISPLAY PROGRAM-FILE-NAME " " HOME-TERMINAL " ". EDIT-CPU-PIN. MOVE CPU-PIN TO BYTE-PAIR. PERFORM SEPARATE-BYTE-PAIR. MOVE NUMERIC-LEFT-BYTE TO NUMERIC-CPU. MOVE NUMERIC-RIGHT-BYTE TO NUMERIC-PIN. EDIT-ACCESSOR-ID.
Process Initiation, Communication, and Management Identifying the Creator Example 31-14. Identifying a Process’s Creator (page 1 of 2) IDENTIFICATION DIVISION. PROGRAM-ID. WHOA-MOM. AUTHOR. KRIS COBOL. INSTALLATION. TRANSACTIONS ANONYMOUS. DATE-WRITTEN. 29 FEBRUARY 1988. DATE-COMPILED. ********************************************************************* * This program obtains and reports the process ID of its creator, * * then attempts to stop its creator.
Process Initiation, Communication, and Management Monitoring Descendants’ Completion Example 31-14. Identifying a Process’s Creator (page 2 of 2) IF ERROR-RETURN NOT = 0 DISPLAY "Call to PROCESS_GETINFO_ returned an error code of " ERROR-RETURN STOP RUN. * -- Get my process accessor id ENTER TAL "PROCESS_GETINFO_" USING PROCESS-HANDLE OMITTED OMITTED OMITTED OMITTED OMITTED OMITTED OMITTED MOMS-CAID MY-PAID OMITTED OMITTED OMITTED OMITTED OMITTED OMITTED GIVING ERROR-RETURN.
Process Initiation, Communication, and Management Monitoring Descendants’ Completion The HP COBOL run-time routines report the receipt of system messages only when the RECEIVE-CONTROL paragraph specifies it. If you want a process that creates other processes to be notified about termination or failure of these descendant processes: • • Include a REPORT SYSTEM MESSAGES entry in the RECEIVE-CONTROL paragraph of the parent process.
Process Initiation, Communication, and Management Monitoring Descendants’ Completion Example 31-15. Monitoring Completion of Descendant Processes (page 2 of 3) WORKING-STORAGE SECTION. 01 MESSAGE-SOURCE-REC. 05 SYSTEM-FLAG 05 ENTRY-NUMBER 05 FILLER 05 PROCESS-HANDLE 10 CPU-PIN. 15 CPU 15 PIN 05 FILLER 01 CPU-PIN-REDEF. 05 ALPHA-CPU. 10 CPU-HIGH-BYTE 10 CPU-LOW-BYTE 05 NUMERIC-CPU PIC S9 COMP. PIC 999 COMP. PIC X(4). PIC S9(2) COMP. NATIVE-2. PIC X(16). 05 ALPHA-PIN.
Process Initiation, Communication, and Management Monitoring Descendants’ Completion Example 31-15. Monitoring Completion of Descendant Processes (page 3 of 3) * Start FUP ENTER "CLU_PROCESS_CREATE_" USING FUP GIVING SU-ERROR. * Await termination of FUP, or report it never started IF SU-ERROR = 0 PERFORM WATCH UNTIL SYS-MSG-STOP IF FUNCTION MOD (SYS-MSG-STOP-FLAG, 2) = 0 DISPLAY "FUP terminated normally" ELSE DISPLAY "FUP aborted" END-IF ELSE PERFORM DISPLAY-STARTUP-FAILURE. STOP RUN.
Process Initiation, Communication, and Management Changing the Creator ID Changing the Creator ID One reason the operating environment keeps track of the creator of a process is to be able to notify a creator when a descendant process terminates. If process $PARENT starts process $CHILD, the operating environment notifies $PARENT through the $RECEIVE mechanism when $CHILD terminates.
Process Initiation, Communication, and Management Suspending a Process Example 31-16. Suspending a Process (page 2 of 2) ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP TXP. OBJECT-COMPUTER. HP TXP. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT REPORT-OUT ASSIGN TO "\HQ.$BOSS" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS REPORT-STATUS. DATA DIVISION. FILE SECTION. FD REPORT-OUT LABEL RECORDS ARE OMITTED. 01 REPORT-LINE PIC X(80). WORKING-STORAGE SECTION.
32 Fault-Tolerant Processes A process is running in a fault-tolerant manner when no single point of failure can stop the process or corrupt its data or the files it is manipulating. Processes are not automatically fault tolerant—they must be designed and implemented to be fault tolerant. How might a single point of failure affect a process? Suppose a process is operating an automated teller machine (ATM) for a financial institution.
Fault-Tolerant Processes NonStop Operating System NonStop Operating System The NonStop operating system architecture is the underlying mechanism that enables you to write fault-tolerant processes. The full redundancy of processors, devices, controllers, and paths among them is the basis for the NonStop operating system’s fault tolerance.
Fault-Tolerant Processes Introduction to TMF Introduction to TMF The HP NonStop™ Transaction Management Facility (TMF) relies on the principle of archiving and backing out transactions. Every transaction has a beginning and an end. If the entire transaction cannot be completed (due to some single point of failure), any changes made to the database must be backed out.
Fault-Tolerant Processes Process Pairs After you have done these things, the fault-tolerant facility does the remainder of the work to assure fault-tolerant operation. Topics: • • • • • Process Pairs Checkpointing Using the Fault-Tolerant Facility Designing Programs for the Fault-Tolerant Facility Debugging Programs That Use the Fault-Tolerant Facility The information in these topics is general. For specific details on checkpointing, see the Guardian Programmer’s Guide.
Fault-Tolerant Processes Process Pairs In this primary-plus-backup structure, the fault-tolerant facility (as directed by the primary process) keeps the backup process informed of the executing state of the primary process. At critical points in the processing, the primary process sends checkpoint messages to the backup process to pass the current state of the data, the file buffers, and the files to the backup process.
Fault-Tolerant Processes Checkpointing This sequence of actions occurs when a process pair runs: 1. The primary process opens any files required for its execution. 2. The primary process starts its backup process in another processor module by executing a STARTBACKUP verb. This action also opens the files for the backup process and checkpoints the state of the primary process to the backup process.
Fault-Tolerant Processes Checkpointing Topics: • • • • Data Items Sync Blocks General Rules Rules for Servers to Follow With Fault-Tolerant Requesters Data Items These are usually file record areas but can be any desired data items in the File Section or the Working-Storage Section or the Extended-Storage Section of the Data Division.
Fault-Tolerant Processes Checkpointing Figure 32-3. Duplication in Takeover Restart point (c) Checkpoint data and sync block x Write log-rec *** FAILURE OF PRIMARY PROCESS*** VST718.vsd To prevent such duplicate write operations by the backup process, you must specify a nonzero SYNCDEPTH parameter in the OPEN statement. This action allows the file system to record the completion status of each input-output operation.
Fault-Tolerant Processes Using the Fault-Tolerant Facility When your program performs a series of updates to one or more disk files, you can combine checkpoints to reduce system overhead. Structure your program so that the series of write operations necessary to update a file are performed in a group. For each file to be checkpointed in this manner, the sync depth must equal the maximum number of write operations that occur between checkpoint operations (CHECKPOINT, OPEN, or CLOSE statements).
Fault-Tolerant Processes Using the Fault-Tolerant Facility OPEN and CLOSE Statements If a process is executing as a process pair (that is, the primary process has executed a STARTBACKUP statement), checkpointing occurs automatically when any OPEN or CLOSE statement executes and when the backup process is established. The execution of STARTBACKUP and CHECKPOINT statements sets the PROGRAMSTATUS variable to indicate the outcome of the checkpointing operation.
Fault-Tolerant Processes Using the Fault-Tolerant Facility Table 32-1. Values for PROGRAM-STATUS When STARTBACKUP Has Option 0, 1, or 2 (page 2 of 2) PROGRAM-STATUS Value Meaning 4nnn Indicates a PROCESS_CREATE_ failure. For more information, see the Guardian Procedure Calls Reference Manual.
Fault-Tolerant Processes Using the Fault-Tolerant Facility Example 32-1. Key Parts of Fault-Tolerant HP COBOL Program (page 1 of 2) ?NONSTOP ?SAVE PARAM * * Compiler directive specifies that the program is to be compiled for execution as a process pair. FILE SECTION. FD TEST-FILE LABEL RECORD IS OMITTED RECORD CONTAINS 100 CHARACTERS DATA RECORD IS TEST-REC. 01 TEST-REC. 05 REC-NUM PIC 9(4). 05 ALTKEY-1 PIC X(5). 05 ALTKEY-2 PIC X(5). ... WORKING-STORAGE SECTION. 01 CKPT-DATA.
Fault-Tolerant Processes Designing Programs for the Fault-Tolerant Facility Example 32-1. Key Parts of Fault-Tolerant HP COBOL Program (page 2 of 2) GET-CPUNUM. MOVE "BACKUPCPU" TO PARAM. ENTER "SMU_Param_GetText_" USING PARAM PARAM-RET GIVING ERROR-CODE. MOVE PARAM-RET TO BCPU. IF BCPU < 0 OR BCPU > 15 DISPLAY "BACKUP CPU INVALID, RUNNING WITHOUT BACKUP". UPDATE-RECS. ... READ TEST-FILE WITH LOCK. ... CHECKPOINT TEST-FILE, TEST-REC, CKPT-DATA.
Fault-Tolerant Processes • • • TMF You can compile your program with STARTBACKUP and CHECKPOINT statements in place, but disable them for batch testing by running the program with the run-time parameter NONSTOP OFF. With NONSTOP OFF, the program does not attempt to execute the STARTBACKUP and CHECKPOINT statements. To establish the run-time parameter, use the TACL command PARAM (or the SMU routine SMU_Param_PutText_ if you use a COBOL process to start your batch test programs).
Fault-Tolerant Processes Concepts Topics: • • • • • Concepts Designing Programs for the TMF Subsystem The TMF Subsystem and Requester Screen Transactions The TMF Subsystem for Batch Jobs Debugging Programs That Use the TMF Subsystem Concepts The basic concepts of TMF are: • • • • • • • Transactions in General Multiple-File Transactions Multiple Changes to a Single File Defining Transactions Audit Trails Online Dump and Roll-Forward Recovery Record Locking Transactions in General A transaction is a m
Fault-Tolerant Processes Concepts Multiple Changes to a Single File Suppose that the corporate personnel system does not use multiple files, but a single file. If you want to move an employee’s record from one department’s portion of the file to another department’s portion of the file, the same problem arises as that with multiple files. If the record is deleted from one place in the file and written to another place in the file, there is an interval during which the database is inconsistent.
Fault-Tolerant Processes Concepts HP COBOL Manual for TNS/E Programs —520347-003 32 -17
Fault-Tolerant Processes Concepts Every disk operation that changes the contents of a database protected by TMF is recorded in an audit trail. The before and after values of the information are both recorded, and the database is changed. If the transaction does not complete, TMF backs out the transaction—replaces the changed value with the previous value. You can specify that some files in a transaction are audited and some are not audited; however, this practice is risky.
Fault-Tolerant Processes Designing Programs for the TMF Subsystem If the process executes an UNLOCK operation on a record that was locked and modified in an audited file, TMF prevents the record from actually being unlocked until the transaction is completed or aborted. The TMF subsystem automatically unlocks these locked records at the end of a transaction, whether the process explicitly unlocks them or not.
Fault-Tolerant Processes The TMF Subsystem for Batch Jobs You recover from a failure during the series by adopting a strategy to protect records by allocating a field to mark the record “in use.” Then other transactions can read the record but agree not to attempt to change it. This mechanism puts more responsibility on the designer and the maintenance staff.
33 Migrating TNS/R Programs to TNS/E Programs Note. This section applies to migrating TNS/R HP COBOL programs to TNS/E HP COBOL programs, and assumes that you are running RVU G06.20 or later. To migrate TNS HP COBOL programs to TNS/R or TNS/E HP COBOL programs, see the COBOL Manual for TNS and TNS/R Programs. HP provides these native compilers for HP COBOL source programs: Compiler Objects Produced NMCOBOL TNS/R ECOBOL TNS/E The ECOBOL compiler is available both on NonStop systems and on the PC.
Migrating TNS/R Programs to TNS/E Programs Migrating HP COBOL Programs Migrating HP COBOL Programs The recommended procedure for migration from TNS/R HP COBOL to TNS/E HP COBOL is: 1. If necessary, change your source program (see Source Program Changes). To learn whether you must change your source program, compile it with the ECOBOL compiler, which will issue warnings when it encounters source constructs that it does not accept. 2. If your program calls TNS/R programs, migrate them to TNS/E.
Migrating TNS/R Programs to TNS/E Programs Source Program Changes 4. Compile your source program with the ECOBOL compiler. For the Guardian environment, see Running the Compiler. For the OSS environment, see Section 19, Using HP COBOL in the OSS Environment. The ECOBOL compiler needs more symbol table space than the NMCOBOL compiler does.
Migrating TNS/R Programs to TNS/E Programs Possible Changes Required Possible Changes Required • • Directives RENAMES Clause Make any necessary changes to these items before compiling your HP COBOL source program with the ECOBOL compiler. Directives • CONSULT Directive For the NMCOBOL compiler, each object-name in a CONSULT directive must designate a TNS/R native object file (otherwise the compiler reports an error).
Migrating TNS/R Programs to TNS/E Programs • Possible Changes Required SEARCH Directive For the NMCOBOL compiler, each object-name in a SEARCH directive must designate a TNS/R native object file (otherwise the compiler reports an error). For the ECOBOL compiler, each object-name in a SEARCH directive must designate a TNS/E native object file (otherwise the compiler reports an error). For a complete description of this directive, see SEARCH and NOSEARCH.
Migrating TNS/R Programs to TNS/E Programs Removal Optional To: 01 CARD-REC. 05 REFERENCE-NUMBER 05 CARD-CODES. 10 STORE-CODE 10 STATE-CODE 05 ACCOUNT-NUMBER 05 CHECK-DIGIT 66 CARD-DATA RENAMES PIC 9(6). PIC 9. PIC 9(4). PIC 9(6). PIC 9. REFERENCE-NUMBER THRU CHECK-DIGIT. For a complete description of the RENAMES clause, see Descriptions That Rename Items (Level 66). For a complete description of the REDEFINES clause, see REDEFINES Clause.
Migrating TNS/R Programs to TNS/E Programs Maintaining Common Source Code Maintaining Common Source Code To maintain “common source code” that can be compiled with D44.01 and later RVUs of the NMCOBOL compiler and the ECOBOL compiler, follow these guidelines: • Either do not use HP COBOL language features that are not supported by both compilers, or use conditional compilation to isolate those features.
Migrating TNS/R Programs to TNS/E Programs Using the Inspect and Visual Inspect Debuggers HP COBOL Manual for TNS/E Programs —520347-003 33- 8
34 Native COBOL Cross Compiler on PC The native COBOL cross compiler is an optional cross compiler that runs on the PC platforms in Table 34-1. Table 34-1. ECOBOL Cross Compiler Platforms Operating System COBOL Cross Compiler Name Product Number Windows 98 Windows NT 4.
Native COBOL Cross Compiler on PC Cross Compiler Features Cross Compiler Features The native COBOL cross compiler allows you to: • Write, compile, and link these kinds of NonStop Itanium-based server applications on the PC and transfer them to the OSS or Guardian platform for use in production: ° ° ° ° Executable programs Static libraries User libraries DLLs Object files built on the PC platform using the native COBOL compiler are compatible with object files built on the NonStop Itanium-based server
Native COBOL Cross Compiler on PC NonStop COBOL for TNS/E (ETK) NonStop COBOL for TNS/E (ETK) The optional native COBOL cross compiler for use with the ETK is called NonStop COBOL for TNS/E. The ETK is a GUI-based extension package to Visual Studio .NET that provides full application development functions targeted for NonStop servers. From the GUI, you can choose native COBOL cross-compiler options. Development, editing, and building functions are very similar on Visual Studio .NET and the ETK.
Native COBOL Cross Compiler on PC ecobol (PC Command Line) ecobol (PC Command Line) You can invoke the native COBOL cross compiler, ecobol, at the command line (DOS prompt) on your PC. ecobol -c -g -o cobol-opt comp-opt link-opt sqlmx-opt ecobol-opt file outfile sqlmp-opt VST821.vsd ecobol must be typed as shown, in lowercase letters. -c -g -o outfile are as described in the Open System Services Shell and Utilities Reference Manual.
Native COBOL Cross Compiler on PC • • • • • • • • • ecobol (PC Command Line) -W[no]innerlist -W[no]list -W[no]map -Woptimize={0|1|2} -Wshared -W[no]suppress -Wsyntax -Ww -Wsystype={guardian|oss} -Wsystype={guardian|oss} determines whether ecobol creates loadfiles for the Guardian environment or for the OSS environment. The default is the Guardian environment. For descriptions of the other flags, see the Open System Services Shell and Utilities Reference Manual.
Native COBOL Cross Compiler on PC ecobol (PC Command Line) sqlmx-opt is described in Using the Command-Line Cross Compilers on Windows (see Documentation). ecobol-opt is one of these ecobol flags: • • • • • • -Wdryrun -Whelp -Wsavetemps -Wusage -Wv -Wverbose file is the source file name.
Native COBOL Cross Compiler on PC Linking Linking Native COBOL cross compiler linking is performed using Windows eld. The ETK provides a GUI-based interface for you to select linking options. When you invoke eld through the command line, you must specify the run-time libraries to eld. For information about Windows eld and eld options, see the eld Manual. Debugging • • • ETK Platform Command-Line Platform RUNV ETK Platform On the ETK platforms, debug native COBOL source code using Visual Inspect.
Native COBOL Cross Compiler on PC RUNV program-file is the name of the loadfile to run. program-file can be represented as a filesystem file name or (in the Guardian environment) a DEFINE name. programfile is added to the list in Visual Inspect’s Application Control View. For information about Visual Inspect, see its online help. run-option-list run-option , run-option VST332.vsd run-option IN OUT accept-device display-device VST333.
Native COBOL Cross Compiler on PC Tools and Utilities program-parameter-list program-parameter , program-parameter VST806.vsd program-parameter is a parameter of the program that is to be run. In the Guardian environment, the NonStop TCP/IP address of your workstation is automatically detected when you invoke RUNV. In the OSS environment, you must either set the _TANDEM_VISUALINSPECT_WSADDR environment variable in your $HOME/.profile file or enter the workstation IP address as a command-line parameter.
Native COBOL Cross Compiler on PC TACL DEFINE Tool (ETK) The Windows-hosted ar utility does not differentiate between OSS and Guardian target files. To avoid run-time errors, be sure that procedures in archives used for resolving references work on the target platform. Note. The ar utility can also use archives created from TNS/E linkable files by the eld utility. For information about the eld utility, see the eld Manual.
Native COBOL Cross Compiler on PC HP COBOL Manual for TNS/E Programs —520347-003 34 -11 Documentation
Native COBOL Cross Compiler on PC HP COBOL Manual for TNS/E Programs —520347-003 34 -12 Documentation
Part III.
Part III.
35 • • • Commands Guardian Environment OSS Environment ecobol (PC Command Line) Guardian Environment • • • • • Before Running the Compiler (Optional) Running the ECOBOL Compiler Running the Native Cross Compiler Under Visual Inspect Before Running the Compiled Program (Optional) Running the Compiled Program Before Running the Compiler (Optional) PARAM SWAPVOL $ ns volume VST418.vsd PARAM SYMBOL-BLOCKS count VST419.
Commands Running the ECOBOL Compiler Running the ECOBOL Compiler ECOBOL / IN source-file / , OUT list-file , other-option target-name , copy-library ; compiler-directive VST807.vsd source-file file-name-1 define-name VST257.vsd list-file file-name-2 define-name VST259.vsd target-name file-name-4 define-name VST261.
Commands Running the Native Cross Compiler Under Visual Inspect copy-library file-name-4 define-name VST261.vsd Running the Native Cross Compiler Under Visual Inspect RUNV program-file / run-option-list / program-parameter-list VST805.vsd run-option-list run-option , run-option VST332.vsd run-option IN OUT accept-device display-device VST333.vsd program-parameter-list program-parameter , program-parameter VST806.
Commands Before Running the Compiled Program (Optional) Before Running the Compiled Program (Optional) • • • • ASSIGN CLEAR FIXERRS PARAM ASSIGN ASSIGN cobol-file-name program-name . * , system-file , characteristic VST334.vsd system-file name #IN #OUT #TERM #TEMP $RECEIVE VST335.
Commands Before Running the Compiled Program (Optional) characteristic EXT size-list CODE file-code EXCLUSIVE SHARED PROTECTED INPUT OUTPUT I-O REC record-size BLOCK block-size VST336.vsd size-list pri-extent-size ( ) pri-extent-size , sec-extent-size VST337.
Commands Before Running the Compiled Program (Optional) CLEAR CLEAR ALL ASSIGN PARAM ASSIGN assignation PARAM DEBUG EXECUTION-LOG INSPECT NONSTOP PRINTER-CONTROL WAITED-IO SWITCH- nn parameter-name VST340.vsd assignation COBOL-file-name program-name . * VST638.vsd FIXERRS FIXERRS error-file ; tedit-command VST372.
Commands Before Running the Compiled Program (Optional) PARAM PARAM name-value-pair , name-value-pair VST338.
Commands Running the Compiled Program name-value-pair SWITCH-nn ON DEBUG OFF NONSTOP INSPECT WAITED-IO EXECUTION-LOG system-file-name define-name * TAPE-DIALOGUE ON OFF PRINTER-CONTROL parameter-name cobol-file-name parameter-value VST339.vsd Running the Compiled Program RUN program-file RUND / run-option-list / program-parameter-list VST331.vsd run-option-list run-option , run-option VST332.
Commands OSS Environment run-option IN OUT accept-device display-device VST333.vsd program-parameter-list program-parameter , program-parameter VST806.vsd OSS Environment • • • Before Running the Compiler (Optional) Running the ecobol Compiler Running the Compiled Program Before Running the Compiler (Optional) To change one or more of the defaults in Table 35-1 before executing the ecobol command, use the OSS export command.
Commands Running the ecobol Compiler Table 35-1. Environment Variables (page 2 of 2) Variable Effect Default MXCMP Determines the pathname of the alternate SQL/MX compiler that the ecobol utility calls /G/system/system/ SQLCLIO Determines the pathname of the object file that describes the SQL/MX API to the ecobol utility /usr/tandem/sqlmx/lib/esql cli.o Running the ecobol Compiler ecobol pathname flag operand operand VST816.
Commands Running the Compiled Program pathname ns file ns . cbl cob ecbl ecob a m o dll VST817.vsd Note. The file suffixes (cbl, cob, and so on) are not case-sensitive. Running the Compiled Program Type the name of the loadfile and press Return; for example: a.out To run the program with the selected debugger, enter: run -debug a.out If the current directory is not in your search path, add it with this command: export PATH=$PATH:.
Commands ecobol (PC Command Line) ecobol (PC Command Line) ecobol -c -g -o cobol-opt comp-opt link-opt sqlmx-opt ecobol-opt file outfile sqlmp-opt VST821.vsd -c -g -o outfile -cobol-opt -comp-opt -link-opt -sqlmp-opt -sqlmx-opt -ecobol-opt file See ecobol (PC Command Line).
36 Compiler Directives On the compiler command line: directive ; , directive VST263.vsd In the program source text: ? directive ; , directive VST264.vsd In the OSS environment, include compiler directives in the ecobol command line with the -Wcobol flag. Note. “Default:” identifies the default for the compiler directive itself, not for its optional parameter(s). This default applies if a program does not contain the compiler directive at all.
Compiler Directives • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • ENDUNIT ERRORFILE ERRORS FIPS and NOFIPS FMAP HEADING IF and IFNOT INNERLIST and NOINNERLIST INSPECT and NOINSPECT LINES LIST and NOLIST MAIN MAP and NOMAP NONSTOP OPTIMIZE PERFORM-TRACE PORT and NOPORT RESETTOG RUNNABLE RUNNAMED SAVE SAVEABEND and NOSAVEABEND SEARCH and NOSEARCH SECTION SETTOG SHARED SHOWCOPY and NOSHOWCOPY SHOWFILE and NOSHOWFILE SOURCE SQL and NOSQL HP COBOL Manual for TNS/E Programs —520347-003 36- 2
Compiler Directives • • • • • • • • ANSI SUBSET SUBTYPE SUPPRESS and NOSUPPRESS SYMBOLS and NOSYMBOLS SYNTAX TANDEM UL WARN and NOWARN ANSI ANSI TANDEM VST266.vsd Default: TANDEM Placement: Anywhere Scope: ANSI or TANDEM within a section of text obtained from a copy library or source library is effective only for the length of that text section. When the compiler reverts to the source file where it found the COPY verb or SOURCE directive, the previously active reference format applies.
Compiler Directives CALL-SHARED CALL-SHARED CALL-SHARED NON-SHARED SHARED VST802.vsd Default: CALL-SHARED Placement: Anywhere Scope: The last CALL-SHARED or SHARED in the compilation unit applies to the entire compilation unit. Dependencies: References: • • • • • If RUNNABLE is active, CALL-SHARED uses the linker to create a PIC executable object file; otherwise, CALL-SHARED creates a PIC linkfile. Do not use with UL. SHARED RUNNABLE UL CANCEL and NOCANCEL CANCEL NOCANCEL VST383.
Compiler Directives CHECK CHECK CHECK check-level VST268.vsd Default: CHECK 1 Placement: Anywhere Scope: In each separately compiled program, the last CHECK in the program unit determines the check level for the code block being produced. Dependencies: None check-level What is Checked Comments 0 Nothing CHECK 0 results in the fastest execution time. 1 (default) Nothing CHECK 1 might have a different meaning in future versions of HP COBOL for HP NonStop systems (“HP COBOL”).
Compiler Directives COLUMNS COLUMNS COLUMNS length VST270.vsd Default: Placement: COLUMNS 132 • • • On a directive line, COLUMNS must begin with a question mark (?) in column 1, regardless of any active ANSI directive. In a COPY library or a source library, COLUMNS must be the only directive on its line and must precede all SECTION directives in that library.
Compiler Directives COMPILE COMPILE COMPILE SYNTAX VST272.vsd Default: COMPILE Placement: Outside the boundaries of a separately compiled program; that is, not between the Identification Division header of a separately compiled program and its end, which is marked by one of: • • • The corresponding END PROGRAM statement ENDUNIT The end of the source file Scope: The last COMPILE or SYNTAX in the compilation unit applies to the entire compilation unit.
Compiler Directives DIAGNOSE-74 and NODIAGNOSE-74 DIAGNOSE-74 and NODIAGNOSE-74 DIAGNOSE-74 NODIAGNOSE-74 VST277.vsd Default: NODIAGNOSE-74 Placement: Anywhere Scope: Applies until its opposite overrides it Dependencies: None DIAGNOSE-85 and NODIAGNOSE-85 DIAGNOSE-85 NODIAGNOSE-85 VST719.vsd Default: NODIAGNOSE-85 Placement: Anywhere Scope: Applies until its opposite overrides it Dependencies: None DIAGNOSEALL and NODIAGNOSEALL DIAGNOSEALL NODIAGNOSEALL VST470.
Compiler Directives ELD ELD ELD ( option ) VST157.vsd Default: None Placement: In the command line Scope: Applies to the compilation unit Dependencies: None ENDIF ENDIF toggle-number VST278.vsd Default: None Placement: Must be either on a directive line of its own or be the last of a sequence of directives Dependencies: Requires a preceding IF or IFNOT directive with the same togglenumber References: IF and IFNOT ENDUNIT ENDUNIT VST279.
Compiler Directives ERRORFILE ERRORFILE ERRORFILE file-name define-name VST281.vsd Default: None Placement: Either on the compiler command line or in the source file before the Identification Division Scope: Applies to the compilation unit Dependencies: None ERRORS ERRORS error-limit VST282.
Compiler Directives FIPS and NOFIPS FIPS and NOFIPS FIPS flag-option-list ( flag-option-list ) NOFIPS VST468.vsd flag-option-list flag-option , flag-option VST469.
Compiler Directives FMAP FMAP FMAP VST731.vsd Default: The compiler does not produce a source file map. Placement: Anywhere Scope: Applies to the compilation unit Dependencies: NOLIST and SUPPRESS do not suppress the source file map that FMAP produces. References: • • LIST and NOLIST SUPPRESS and NOSUPPRESS HEADING HEADING " character-string " VST283.vsd character-string Default values is all spaces.
Compiler Directives IF and IFNOT IF and IFNOT IF toggle-number IFNOT VST287.vsd Default: None Placement: IF must be either on a directive line of its own or be the last of a sequence of directives. IFNOT can be anywhere. Scope: IF or IFNOT applies until matching ENDIF appears. Dependencies: Requires a preceding IF or IFNOT directive with the same togglenumber References: IF and IFNOT INNERLIST and NOINNERLIST INNERLIST NOINNERLIST VST724.
Compiler Directives INSPECT and NOINSPECT INSPECT and NOINSPECT INSPECT NOINSPECT VST288.vsd Default: INSPECT Placement: Anywhere Scope: The last INSPECT or NOINSPECT in the compilation unit applies to the compilation unit. Dependencies: NOINSPECT and SAVEABEND override each other (whichever is last is active). References: SAVEABEND and NOSAVEABEND LINES LINES lines-per-page VST290.
Compiler Directives LIST and NOLIST LIST and NOLIST LIST NOLIST VST291.vsd Default: LIST Placement: Anywhere Scope: Applies until overridden by its opposite Dependencies: SUPPRESS overrides LIST (and therefore CODE, CROSSREF, ICODE, LMAP, MAP, SHOWCOPY, and SQL). NOLIST suppresses INNERLIST. References: • • • • • SUPPRESS and NOSUPPRESS INNERLIST and NOINNERLIST MAP and NOMAP SHOWCOPY and NOSHOWCOPY SQL and NOSQL MAIN Note.
Compiler Directives MAP and NOMAP MAP and NOMAP MAP NOMAP VST295.vsd Default: NOMAP Dependencies: MAP works only if LIST is active and SUPPRESS is not. Scope: The last MAP or NOMAP applies. Dependencies: MAP works only if LIST is active and SUPPRESS is not. References: • • LIST and NOLIST SUPPRESS and NOSUPPRESS NONSTOP Note. Do not use this directive in the OSS environment. NONSTOP VST296.vsd Default: The program cannot run as a process pair (even if it contains a PARAM NONSTOP ON command).
Compiler Directives OPTIMIZE OPTIMIZE OPTIMIZE level VST297.vsd level Level Effect 0 Code is not optimized. Provided in case other optimization levels cause errors. Supports symbolic debugging; data is always in memory. 1 (default) Code is optimized within statements and across statement boundaries. The resulting code is more efficient than that produced by lower levels of optimization. Supports symbolic debugging; data is not always in memory.
Compiler Directives PORT and NOPORT PORT and NOPORT PORT 1 2 3 NOPORT VST600.vsd Default: NOPORT Placement: Anywhere Scope: Applies to the compilation unit Dependencies: None RESETTOG RESETTOG toggle-number-list VST298.vsd toggle-number-list toggle-number , toggle-number VST299.vsd Default value is all toggles.
Compiler Directives RUNNABLE RUNNABLE RUNNABLE VST729.vsd Default: The compiler does not use the linker to produce a loadfile if there were no compilation errors. Placement: Anywhere Scope: Applies to the compilation unit Dependencies: SYNTAX overrides RUNNABLE. You must specify RUNNABLE to use RUNNAMED, SAVEABEND, NOSAVEABEND, or SUBTYPE in the compiler. With CALL-SHARED (the default), RUNNABLE uses the linker to produce a PIC loadfile.
Compiler Directives SAVE SAVE Note. Do not use this directive in the OSS environment. SAVE save-option-list ( ) save-option-list VST301.vsd save-option-list save-option , save-option VST302.vsd save-option PARAM STARTUP ASSIGNS ALL count VST303.vsd Default: The compiler does not save initialization messages.
Compiler Directives SAVEABEND and NOSAVEABEND SAVEABEND and NOSAVEABEND SAVEABEND NOSAVEABEND VST304.vsd Default: NOSAVEABEND Placement: Anywhere Scope: The last SAVEABEND or NOSAVEABEND in the compilation unit applies to the entire compilation unit. Dependencies: SAVEABEND and NOINSPECT override each other (whichever is last is active). SAVEABEND and NOSAVEABEND are appropriate only if the program was compiled with RUNNABLE.
Compiler Directives SEARCH and NOSEARCH SEARCH and NOSEARCH Note. The compiler ignores the NOSEARCH directive and issues a warning. SEARCH object-name-list ( object-name-list ) NOSEARCH VST305.vsd object-name-list object-name , object-name VST306.
Compiler Directives SETTOG SETTOG Note. The SETTOG directive must either be on a directive line of its own or be the last of a sequence of directives. SETTOG toggle-number-list VST308.vsd toggle-number-list toggle-number , toggle-number VST299.vsd Default value is all toggles. Default: None Placement: Must either be on a directive line of its own or be the last of a sequence of directives.
Compiler Directives SHARED SHARED SHARED CALL-SHARED NON-SHARED VST804.vsd Default: CALL-SHARED Placement: Anywhere Scope: The last SHARED or CALL-SHARED in the compilation unit applies to the entire compilation unit. Dependencies: References: • • • • • If RUNNABLE is active, SHARED uses the linker to create a PIC library file (DLL); otherwise, SHARED creates a PIC linkfile. Do not use with CALL-SHARED or UL. CALL-SHARED RUNNABLE UL SHOWCOPY and NOSHOWCOPY SHOWCOPY NOSHOWCOPY VST310.
Compiler Directives SHOWFILE and NOSHOWFILE SHOWFILE and NOSHOWFILE SHOWFILE NOSHOWFILE VST311.
Compiler Directives SOURCE SOURCE SOURCE edit-file-name ( section-name-list ) VST312.vsd section-name-list section-name , section-name VST313.vsd Default value is entire file. Default: None Placement: Must be the last directive on its line. Dependencies: None Format of a source library: section-text pre-text VST252.vsd section-text ? SECTION text-name , format text-line VST253.
Compiler Directives SQL and NOSQL SQL and NOSQL Note. The compiler ignores the NOSQL directive and issues a warning. SQL sql-option-list ( ) sql-option-list NOSQL VST315.vsd sql-option-list sql-option , sql-option VST316.vsd sql-option RELEASE1 RELEASE2 PAGES num-pages SQLMAP WHENEVERLIST VST317.vsd Default: None. If the program contains SQL/MP statements, the SQL directive is required; otherwise, it is unnecessary. Placement: In the compiler command line.
Compiler Directives SUBSET SUBSET Note. Put this directive before the Identification Division header of the first program unit in the compilation unit. SUBSET parameter-list ( parameter-list ) VST319.vsd parameter-list parameter , parameter VST320.vsd parameter HIGH EXTENDED DEB1 SEG1 SEG2 OBSOLETE VST321.vsd Default: None Placement: Must appear before the first COBOL source program (that is, before the first Identification Division header).
Compiler Directives SUBTYPE SUBTYPE Note. Do not use this directive in the OSS environment. SUBTYPE subtype-number VST323.vsd Default: SUBTYPE 0 Placement: Anywhere Scope: The last SUBTYPE in the program applies. Dependencies: SUBTYPE is appropriate only if the program was compiled with RUNNABLE. References: RUNNABLE SUPPRESS and NOSUPPRESS SUPPRESS NOSUPPRESS VST324.
Compiler Directives SYMBOLS and NOSYMBOLS SYMBOLS and NOSYMBOLS SYMBOLS NOSYMBOLS VST325.vsd Default: NOSYMBOLS Placement: Accepted anywhere, but to affect a program other than the first program in a compilation unit, SYMBOLS must follow either an ENDUNIT directive or an END PROGRAM statement, which signals the end of the preceding program’s Procedure Division. If you want a symbol table for a given separately compiled program, put SYMBOLS before its Identification Division header.
Compiler Directives SYNTAX SYNTAX SYNTAX COMPILE VST326.vsd Default: COMPILE Placement: Outside the boundaries of a separately compiled program; that is, not between the Identification Division header of a separately compiled program and its end, which is marked by one of: • • • The corresponding END PROGRAM statement ENDUNIT The end of the source file Scope: The last COMPILE or SYNTAX in the compilation unit applies to the entire compilation unit. Dependencies: SYNTAX overrides RUNNABLE.
Compiler Directives UL UL UL VST735.vsd Default: None Placement: Before the first IDENTIFICATION DIVISION header of the first program in the compilation unit Scope: Applies to the compilation unit Dependencies: • References: • • • If RUNNABLE is active, UL uses the linker to create a PIC library file (DLL); otherwise, UL creates a PIC linkfile. Do not use with CALL-SHARED or SHARED. CALL-SHARED SHARED WARN and NOWARN WARN NOWARN VST330.
37 Source Program Organization and Format • • Separately Compiled Source Program Reference Format Separately Compiled Source Program Identification Division Environment Division Data Division Procedure Division COBOL85 source program end-program-header VST373.vsd end-program-header END PROGRAM program-name . VST374.
Source Program Organization and Format Reference Format Reference Format • • TANDEM ANSI TANDEM Figure 37-1. Tandem Reference Format Margin: C Column: A 1 2 B 3 4 5 6 R 7 Area A 8 9 10 ... n* *n <= 132 Area B Indicator Area Line VST500.vsd Table 37-1.
Source Program Organization and Format ANSI ANSI Figure 37-2. ANSI Reference Format Margin: L Column: C 1 2 3 4 Sequence Number Area A 5 6 7 8 B R 9 10 11 12 ... 72 73 ... 80 Area A Indicator Field Area B Identification Field Line VST524.vsd Table 37-2.
Source Program Organization and Format HP COBOL Manual for TNS/E Programs —520347-003 37- 4 ANSI
38 Language Elements and Expressions • • • • • COBOL Character Set Character-Strings Arithmetic Expressions Conditional Expressions Concatenation Expressions See also Section 21, Reserved Words. COBOL Character Set Figure 38-1. COBOL Character Set COBOL Character Set Alphanumeric Characters (for COBOL words) Letters (A – Z a–z) Digits (0 – 9) Hyphen (–) Punctuation Characters Special Characters VST503.
Language Elements and Expressions Table 38-1. Alphanumeric Characters (for COBOL Words) Characters Name of Character Set 0 through 9 Digits A through Z Uppercase letters a through z Lowercase letters - Hyphen or minus sign Table 38-2. Punctuation Characters Character Name of Character Space , Comma ; Semicolon : Colon . Period " Quotation mark ( Left parenthesis ) Right parenthesis = Equal sign Table 38-3.
Language Elements and Expressions Character-Strings Character-Strings • • • COBOL Word Literals PICTURE Character-Strings COBOL Word char-1 ns char-n ns VST741.vsd Maximum length: 30 characters. Literals • • • • Numeric Literals ° ° Decimal Numeric Literal Hexadecimal Numeric Literal Nonnumeric Literals ° ° Simple Nonnumeric Literal Hexadecimal Nonnumeric Literal National Literal Figurative Constants Decimal Numeric Literal ns digits ns + - dp ns digits dp ns digits VST743.
Language Elements and Expressions Literals Hexadecimal Numeric Literal ns H ns ns " hex-digit ns hex-digit " ns VST612.vsd Maximum number of hexadecimal digits: 16 (8 pairs). Simple Nonnumeric Literal char " " VST744.vsd Maximum number of characters: 160. Hexadecimal Nonnumeric Literal ns X ns ns hex-digit " ns hex-digit ns " VST613.vsd Maximum number of hexadecimal digits: 320 (160 pairs). National Literal " char " N n VST745.vsd Maximum number of characters: 160.
Language Elements and Expressions Literals Figurative Constants Table 38-4.
Language Elements and Expressions PICTURE Character-Strings PICTURE Character-Strings • • • PICTURE Character-String Editing Characters Precedence Rules for PICTURE Symbols Precedence Rules for PICTURE Symbols Table 38-5. PICTURE Character-String Editing Characters Character Editing Operation B Space insertion Z Zero suppression 0 Zero + Plus - Minus CR Credit DB Debit * Check protect $ Currency sign , Comma or decimal point .
Language Elements and Expressions PICTURE Character-Strings Figure 38-2. Precedence Rules for PICTURE Symbols First Symbol Second Symbol NonFloating Insertion Symbols Nonfloating Insertion Symbols Other Symbols Floating Insertion Symbols B 0 / , .
Language Elements and Expressions Arithmetic Expressions Arithmetic Expressions num-id + - num-lit arith-expr arith-expr + * / ** ( arith-expr ) VST739.vsd • • • • Table 38-6, Arithmetic Operators, on page 38-8 Table 38-7, Hierarchy of Operators, on page 38-8 Table 38-8, Precedence in Arithmetic Expressions, on page 38-9 Table 38-9, Operator-Operand Combinations, on page 38-9 Table 38-6.
Language Elements and Expressions Conditional Expressions Table 38-8. Precedence in Arithmetic Expressions Ambiguous Interpretation *C (A / B) * C A/B/C (A / B) / C A ** B ** C (A ** B) A/B A+B/C+D ** E * F - G ** C ((A + (B / C)) + ((D ** E) * F)) - G Table 38-9.
Language Elements and Expressions Simple Relation Condition Nonpointer Operands subject relationship object IS VST118.vsd relationship GREATER NOT LESS THAN EQUAL TO > < = GREATER LESS OR THAN EQUAL TO >= <= VST119.vsd Pointer Operands pointer-subject relationship pointer-object IS VST602.
Language Elements and Expressions Simple Class Condition pointer-subject pointer-object ADDRESS OF identifier-1 identifier-2 NULL NULLS VST603.vsd relationship EQUAL IS NOT TO = VST604.vsd Simple Class Condition identifier IS NOT NUMERIC ALPHABETIC ALPHABETIC-LOWER ALPHABETIC-UPPER class-name VST120.
Language Elements and Expressions Simple Sign Condition Simple Sign Condition arithmetic-expression IS NOT POSITIVE NEGATIVE ZERO VST121.vsd Negated Condition simple-condition NOT ( condition ) VST122.vsd Combined Condition condition condition AND OR VST123.vsd Abbreviated Combined Relation Condition rel-condition combined-part VST124.vsd combined-part AND OR object NOT rel-operator VST125.
Language Elements and Expressions Concatenation Expressions Concatenation Expressions & literal-1 literal-2 figurative-constant figurative-constant concatenation-expr VST801.vsd Table 38-10. Maximum Length of Result of Concatenation Expression Class of Operands Length of Result Alphanumeric 160 alphanumeric character positions National 80 national character positions A figurative constant occupies one character position. Table 38-11.
Language Elements and Expressions HP COBOL Manual for TNS/E Programs —520347-003 38 -14 Concatenation Expressions
39 • • • • • • • • • • Data References Qualified Condition-Name Qualified Data-Name Qualified Paragraph-Name Qualified Text-Name Qualified LINAGE-COUNTER Qualified Identifier Subscripted Table Element Reference Modifier OSS Pathname for OSS File OSS Pathname for Guardian File Qualified Condition-Name condition-name OF conditional-variable-name IN mnemonic-name VST001.vsd Qualified Data-Name OF data-name data-name IN OF file-name IN VST002.
Data References Qualified Paragraph-Name Qualified Paragraph-Name OF paragraph-name section-name IN VST003.vsd Qualified Text-Name text-name OF library-name IN VST004.vsd Qualified LINAGE-COUNTER OF LINAGE-COUNTER file-name IN VST005.vsd Qualified Identifier data-name OF qualified-name IN ( ( subscript ) leftmost-character-position : ) length VST009.
Data References Subscripted Table Element Subscripted Table Element ( data-name ) subscript condition-name VST006.vsd subscript integer + - qualified-name index-name offset VST007.vsd Reference Modifier identifier ( leftmost-character-position : ) length VST008.vsd OSS Pathname for OSS File ns OSS /E/ ns node filename / ns ns directory / ns VST634.
Data References OSS Pathname for Guardian File OSS Pathname for Guardian File " ns ns GUARDIAN " device file-id-1 ns OSS file-id-2 ns /E/ ns node VST734.
40 Identification Division IDENTIFICATION DIVISION . PROGRAM-ID paragraph «AUTHOR paragraph» «INSTALLATION paragraph» «DATE-WRITTEN paragraph» «DATE-COMPILED paragraph» «SECURITY paragraph» VST010.vsd PROGRAM-ID paragraph . PROGRAM-ID . program-name program-type IS PROGRAM VST011.vsd program-kind INITIAL COMMON COMMON INITIAL VST012.
Identification Division «AUTHOR paragraph» . AUTHOR comment-entry VST400.vsd «INSTALLATION paragraph» . INSTALLATION comment-entry VST401.vsd «DATE-WRITTEN paragraph» . DATE-WRITTEN comment-entry VST402.vsd «DATE-COMPILED paragraph» . DATE-COMPILED comment-entry VST013.vsd «SECURITY paragraph» SECURITY . comment-entry VST404.
41 Environment Division ENVIRONMENT DIVISION . CONFIGURATION section INPUT-OUTPUT section VST014.vsd • • Configuration Section Input-Output Section Configuration Section CONFIGURATION SECTION . SOURCE-COMPUTER paragraph OBJECT-COMPUTER paragraph SPECIAL-NAMES paragraph VST015.
Environment Division SOURCE-COMPUTER Paragraph SOURCE-COMPUTER Paragraph . SOURCE-COMPUTER . name DEBUGGING MODE WITH VST016.vsd OBJECT-COMPUTER Paragraph . OBJECT-COMPUTER . name «MEMORY-SIZE clause» PROGRAM COLLATING SEQUENCE clause «SEGMENT-LIMIT clause» CHARACTER-SET clause VST017.vsd «MEMORY-SIZE clause» MEMORY integer SIZE WORDS CHARACTERS MODULES VST018.
Environment Division OBJECT-COMPUTER Paragraph PROGRAM COLLATING SEQUENCE clause SEQUENCE PROGRAM COLLATING alphabet-name IS VST019.vsd «SEGMENT-LIMIT clause» segment-number SEGMENT-LIMIT IS VST020.vsd CHARACTER-SET clause character-set-type CHARACTER-SET IS VST021.
Environment Division SPECIAL-NAMES Paragraph SPECIAL-NAMES Paragraph SPECIAL-NAMES . . System-Name clause File-Mnemonic clause ALPHABET clause SYMBOLIC CHARACTERS clause CLASS clause CURRENCY SIGN clause DECIMAL-POINT clause VST022.vsd System-Name clause system-name IS mnemonic-name STATUS phrase VST023.vsd STATUS phrase on-phrase off-phrase off-phrase on-phrase VST746.
Environment Division SPECIAL-NAMES Paragraph on-phrase switch-on ON STATUS IS VST025.vsd off-phrase switch-off OFF STATUS IS VST026.vsd File-Mnemonic clause FILE IS system-file-name file-mnemonic define-name-literal system-file-name-word VST027.vsd ALPHABET clause ALPHABET alphabet-name IS STANDARD-1 STANDARD-2 NATIVE EBCDIC literal-phrase VST028.
Environment Division SPECIAL-NAMES Paragraph literal-phrase literal-1 THROUGH literal-2 THRU ALSO literal-3 VST029.vsd SYMBOLIC-CHARACTERS clause character-list SYMBOLIC CHARACTERS VST030.vsd character-list IS symbolic-char position ARE alphabet-name IN VST031.vsd CLASS clause CLASS class-name IS literal-phrase VST032.vsd literal-phrase literal-1 THROUGH literal-2 THRU VST033.
Environment Division Input-Output Section CURRENCY-SIGN clause sign CURRENCY SIGN IS VST034.vsd DECIMAL-POINT clause DECIMAL-POINT COMMA IS VST380.vsd Input-Output Section INPUT-OUTPUT SECTION . FILE-CONTROL paragraph I-O-CONTROL paragraph RECEIVE-CONTROL paragraph VST035.
Environment Division FILE-CONTROL Paragraph FILE-CONTROL Paragraph . file-control-entry FILE-CONTROL VST036.vsd file-control-entry • • • • • • Sequential File Line Sequential File Relative File Indexed File Queue File Sort-Merge File Sequential File SELECT clause ASSIGN clause . RESERVE clause ORGANIZATION clause PADDING CHARACTER clause RECORD DELIMITER clause ACCESS MODE clause ALTERNATE RECORD KEY clause FILE STATUS clause VST037.
Environment Division FILE-CONTROL Paragraph SELECT clause SELECT file-name OPTIONAL VST038.vsd ASSIGN clause ASSIGN system-file-name define-name-literal TO VST039.vsd RESERVE clause number RESERVE AREA AREAS VST040.vsd ORGANIZATION clause SEQUENTIAL ORGANIZATION IS VST041.vsd PADDING CHARACTER clause pad-char PADDING IS CHARACTER VST042.vsd RECORD DELIMITER clause RECORD DELIMITER STANDARD-1 IS rec-delim VST043.
Environment Division FILE-CONTROL Paragraph ACCESS MODE clause ACCESS SEQUENTIAL MODE IS VST044.vsd ALTERNATE RECORD KEY clause ALTERNATE RECORD IS KEY alt-key WITH DUPLICATES VST045.vsd FILE STATUS clause filestat STATUS FILE IS VST046.vsd Line Sequential File SELECT clause ASSIGN clause . RESERVE clause ORGANIZATION clause ACCESS MODE clause FILE STATUS clause VST624.
Environment Division FILE-CONTROL Paragraph SELECT clause SELECT file-name OPTIONAL VST038.vsd ASSIGN clause ASSIGN system-file-name TO VST640.vsd RESERVE clause Ignored. ORGANIZATION clause LINE SEQUENTIAL IS ORGANIZATION VST625.vsd ACCESS MODE clause ACCESS SEQUENTIAL MODE IS VST044.vsd FILE STATUS clause filestat STATUS FILE IS VST046.
Environment Division FILE-CONTROL Paragraph Relative File SELECT clause . ASSIGN clause RESERVE clause ORGANIZATION clause ACCESS MODE clause ALTERNATE RECORD KEY clause FILE STATUS clause VST047.vsd SELECT clause SELECT file-name OPTIONAL VST038.vsd ASSIGN clause ASSIGN system-file-name define-name-literal TO VST039.vsd RESERVE clause RESERVE number AREA AREAS VST040.
Environment Division FILE-CONTROL Paragraph ORGANIZATION clause RELATIVE ORGANIZATION IS VST048.vsd ACCESS MODE clause ACCESS MODE IS SEQUENTIAL RANDOM RELATIVE KEY clause DYNAMIC VST049.vsd RELATIVE KEY clause rel-key RELATIVE KEY IS VST050.vsd ALTERNATE RECORD KEY clause ALTERNATE RECORD IS KEY alt-key WITH DUPLICATES VST045.vsd FILE STATUS clause filestat STATUS FILE IS VST046.
Environment Division FILE-CONTROL Paragraph Indexed File SELECT clause ASSIGN clause RESERVE clause ORGANIZATION clause ACCESS MODE clause . RECORD KEY clause ALTERNATE RECORD KEY clause FILE STATUS clause VST051.vsd SELECT clause SELECT file-name OPTIONAL VST038.vsd ASSIGN clause ASSIGN system-file-name define-name-literal TO VST039.vsd RESERVE clause RESERVE number AREA AREAS VST040.
Environment Division FILE-CONTROL Paragraph ORGANIZATION clause INDEXED ORGANIZATION IS VST052.vsd ACCESS MODE clause ACCESS SEQUENTIAL MODE IS RANDOM DYNAMIC VST053.vsd RECORD KEY clause reckey RECORD KEY IS VST054.vsd ALTERNATE RECORD KEY clause ALTERNATE RECORD IS KEY alt-key WITH DUPLICATES VST045.vsd FILE STATUS clause filestat STATUS FILE IS VST046.
Environment Division FILE-CONTROL Paragraph Queue File SELECT clause ASSIGN clause RESERVE clause ORGANIZATION clause ACCESS MODE clause RECORD KEY clause . FILE STATUS clause VST740.vsd For descriptions of clauses, see Indexed File. Sort-Merge File SELECT clause ASSIGN clause . VST055.vsd SELECT clause SELECT sd-name VST056.vsd ASSIGN clause ASSIGN system-file-name TO define-name-literal VST039.
Environment Division I-O-CONTROL Paragraph I-O-CONTROL Paragraph • • Line Sequential File All Other File Types Line Sequential File I-O-CONTROL . «RERUN clause» . SAME AREA clause VST632.vsd For descriptions of clauses, see All Other File Types. All Other File Types I-O-CONTROL . «RERUN clause» . SAME AREA clause «MULTIPLE FILE clause» VST057.
Environment Division I-O-CONTROL Paragraph «RERUN clause» Note. The 1985 COBOL standard classifies the RERUN clause as obsolete, so you are advised not to use it. RERUN rerun-file ON system-name rerun-file-2-phrase EVERY units CLOCK-UNITS condition VST058.vsd rerun-file-2-phrase recs RECORDS REEL OF END UNIT rerun-file-2 OF VST059.vsd SAME AREA clause SAME RECORD SORT AREA FOR MERGE same-file VST060.
Environment Division RECEIVE-CONTROL Paragraph «MULTIPLE FILE clause» MULTIPLE FILE TAPE CONTAINS tape-file position POSITION VST061.vsd RECEIVE-CONTROL Paragraph RECEIVE-CONTROL . . EXTERNAL TABLE OCCURS phrase SYNCDEPTH LIMIT phrase REPLY CONTAINS phrase ERROR CODE phrase MESSAGE SOURCE phrase REPORT phrase VST063.vsd TABLE OCCURS phrase TABLE OCCURS EXTENDED-STORAGE table-length TIMES VST064.
Environment Division RECEIVE-CONTROL Paragraph SYNCDEPTH LIMIT phrase sync-id SYNCDEPTH LIMIT IS VST065.vsd REPLY CONTAINS phrase REPLY CONTAINS reply-length CHARACTERS file-name RECORD VST066.vsd ERROR CODE phrase error ERROR CODE IS VST067.vsd MESSAGE SOURCE phrase message SOURCE MESSAGE IS VST068.vsd REPORT phrase REPORT message-type MESSAGES VST069.
Environment Division RECEIVE-CONTROL Paragraph message-type BREAK NEWPROCESSNOWAIT-COMPLETION CLOSE NODE-DOWN CONTROL NODE-UP CONTROLBUF OPEN CPU-DOWN PATHSEND-DIALOG-ABORT CPU-UP POWER-ON DEVICE-INFO PROCESS-CREATE-COMPLETION DEVICE-INFO-2-COMPLETION PROCESS-DELETION FILE-GETINFOBYNAMECOMPLETION PROCESS-TIME-SIGNAL FILE-FILENAME-COMPLETION REMOTE-CPU-DOWN JOB-PROCESS-CREATION REMOTE-CPU-UP LOGICAL-CLOSE RESETSYNC LOGICAL-OPEN SETMODE MEMORY-LOCK-COMPLETION SETPARAM MEMORY-LOC
Environment Division RECEIVE-CONTROL Paragraph HP COBOL Manual for TNS/E Programs —520347-003 41 -22
42 Data Division DATA DIVISION . FILE Section WORKING-STORAGE Section EXTENDED-STORAGE Section LINKAGE Section VST070.vsd FILE Section FILE SECTION . 66-or-88 FD-entry 66-or-88 SD-entry 66-or-88 VST071.vsd FD-entry FD file-description 01-data-description VST072.vsd SD-entry SD sort-merge-file-description 01-data-description VST073.
Data Division WORKING-STORAGE Section WORKING-STORAGE SECTION . 01-data-description 77-data-description 66-or-88 VST094.vsd EXTENDED-STORAGE Section EXTENDED-STORAGE SECTION . 01-data-description 77-data-description 66-or-88 VST095.vsd LINKAGE Section LINKAGE SECTION . 01-data-description 77-data-description 66-or-88 VST096.
Data Division File Descriptions File Descriptions • • • • Sequential File Line Sequential File Relative, Indexed, or Queue File Sort-Merge File Sequential File . file-name EXTERNAL clause GLOBAL clause BLOCK CONTAINS clause RECORD CONTAINS clause «LABEL RECORDS clause» «VALUE OF clause» «DATA RECORDS clause» LINAGE clause CODE-SET clause REPORT clause VST074.
Data Division Sequential File EXTERNAL clause EXTERNAL IS VST075.vsd GLOBAL clause GLOBAL IS VST076.vsd BLOCK CONTAINS clause BLOCK blk-2 CONTAINS blk-1 TO RECORDS CHARACTERS VST077.vsd RECORD CONTAINS clause RECORD contains-phrase-fixed «contains-phrase-range» VARYING phrase VST078.vsd contains-fixed-phrase length-fixed CONTAINS CHARACTERS VST079.
Data Division Sequential File «contains-phrase-range» length-min TO length-max CONTAINS CHARACTERS VST405.vsd VARYING phrase VARYING IS IN SIZE CHARACTERS length-min FROM length-max TO length-var DEPENDING ON VST092.vsd «LABEL RECORDS clause» LABEL RECORD STANDARD IS OMITTED RECORDS ARE VST083.vsd «VALUE OF clause» VALUE OF label-value label-name OF VST084.
Data Division Sequential File «DATA RECORDS clause» DATA rec-name RECORD IS RECORDS ARE VST085.vsd LINAGE clause LINAGE body IS LINES FOOTING foot AT WITH top TOP LINES AT BOTTOM LINES bottom AT VST086.vsd CODE-SET clause alphabet-name CODE-SET IS VST087.vsd REPORT clause report REPORT IS REPORTS ARE VST088.
Data Division Line Sequential File Line Sequential File . file-name EXTERNAL clause GLOBAL clause RECORD CONTAINS clause «LABEL RECORDS clause» «VALUE OF clause» «DATA RECORDS clause» REPORT clause VST633.vsd For descriptions of clauses, see Sequential File.
Data Division Relative, Indexed, or Queue File Relative, Indexed, or Queue File . file-name EXTERNAL clause GLOBAL clause BLOCK CONTAINS clause RECORD CONTAINS clause «LABEL RECORDS clause» «VALUE OF clause» «DATA RECORDS clause» VST637.vsd For descriptions of clauses, see Sequential File. Sort-Merge File . file-name RECORD CONTAINS clause DATA RECORDS clause VST089.vsd RECORD CONTAINS clause RECORD CONTAINS phrase VARYING phrase VST090.
Data Division Data Descriptions CONTAINS phrase length-fixed CONTAINS length-min TO length-max CHARACTERS VST091.vsd VARYING phrase VARYING IS IN length-min SIZE CHARACTERS FROM length-max TO length-var DEPENDING ON VST092.vsd DATA RECORDS clause DATA RECORD data-name IS RECORDS ARE VST093.
Data Division Record Item (Levels 01 through 49) Record Item (Levels 01 through 49) . level data-name-1 FILLER REDEFINES clause EXTERNAL clause GLOBAL clause PICTURE clause USAGE clause SIGN clause OCCURS clause SYNCHRONIZED clause JUSTIFIED clause BLANK WHEN ZERO clause VALUE clause VST098.
Data Division Record Item (Levels 01 through 49) USAGE clause BINARY USAGE IS COMPUTATIONAL COMP COMPUTATIONAL-3 COMP-3 COMPUTATIONAL-5 COMP-5 DISPLAY INDEX NATIVE-2 NATIVE-4 NATIVE-8 PACKED-DECIMAL POINTER VST099.vsd SIGN clause LEADING SIGN IS TRAILING SEPARATE CHARACTER VST100.
Data Division Record Item (Levels 01 through 49) OCCURS clause For a fixed-size table: OCCURS max TIMES key-order index INDEXED BY VST104.vsd For a variable-size table: OCCURS min TO max TIMES depend DEPENDING ON key-order INDEXED index BY VST106.vsd key-order ASCENDING DESCENDING KEY IS key VST105.
Data Division Level-66 Item SYNCHRONIZED clause SYNCHRONIZED SYNC LEFT RIGHT VST101.vsd Level-66 Item 66 new-name THROUGH RENAMES old-name . end-name THRU VST109.vsd Level-77 Item data-name-1 77 FILLER REDEFINES data-name-2 PICTURE clause INDEX USAGE IS SIGN clause OCCURS clause SYNCHRONIZED clause JUSTIFIED clause BLANK WHEN ZERO clause VALUE clause VST110.
Data Division Level-88 Item Level-88 Item 88 VALUE condition-name IS VALUES ARE value-1 THROUGH value-2 THRU VST112.vsd Clause for Data Descriptions in the Linkage Section ACCESS MODE IS EXTENDED-STORAGE STANDARD VST097.
43 Procedure Division PROCEDURE DIVISION USING parameter . declaratives-portion paragraph section VST113.vsd declaratives-portion DECLARATIVES section-name . . SECTION segment-number use-sentence paragraph END DECLARATIVES section . VST117.
Procedure Division section section-name . SECTION segment-number sentence paragraph VST116.vsd paragraph paragraph-name . sentence VST115.vsd sentence statement . VST114.vsd statement See Statements:. procedure paragraph section VST415.
Procedure Division • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • ALTER CALL CANCEL CHECKPOINT CLOSE for Sequential and Line Sequential Files CLOSE for Relative, Indexed, and Queue Files COMPUTE CONTINUE COPY DELETE DISPLAY DIVIDE INTO DIVIDE GIVING DIVIDE GIVING REMAINDER ENTER ENTER COBOL EVALUATE EXIT Unconditional GO TO Conditional GO TO Delimited-Scope IF Conditional IF INITIALIZE INSPECT TALLYING INSPECT REPLACING INSPECT TALLYING REPLACING INSPECT CONVERTING LOCKFILE MERGE MOVE TO HP C
Procedure Division • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • MOVE CORRESPONDING MULTIPLY BY MULTIPLY GIVING OPEN Unconditional PERFORM PERFORM TIMES PERFORM UNTIL PERFORM VARYING READ for Sequential or Dynamic Access READ for Line Sequential Access READ for Random or Dynamic Access RELEASE REPLACE RETURN REWRITE for Sequential, Relative, Indexed, and Queue Files REWRITE for Line Sequential Files SEARCH VARYING SEARCH ALL SET TO for Pointer Data Items SET TO for Nonpointer Data Items SET
Procedure Division • • • • • • • • ACCEPT With Mnemonic-Name UNLOCKFILE UNLOCKRECORD UNSTRING USE DEBUGGING USE AFTER EXCEPTION WRITE for Sequential Files WRITE for Line Sequential Files WRITE for Relative, Indexed, and Queue Files ACCEPT With Mnemonic-Name ACCEPT accept-name FROM mnemonic-name VST126.vsd ACCEPT With DATE, DAY, DAY-OF-WEEK, or TIME Phrase ACCEPT accept-name FROM DATE YYYYMMDD DAY YYYYDDD DAY-OF-WEEK TIME VST127.
Procedure Division ADD TO ADD TO addend ADD TO result ROUNDED SIZE ERROR ON imperative-stmt-1 NOT SIZE ERROR ON imperative-stmt-2 END-ADD VST128.
Procedure Division ADD GIVING ADD GIVING addend ADD addend GIVING TO result ROUNDED SIZE ERROR ON imperative-stmt-1 NOT SIZE ERROR ON imperative-stmt-2 END-ADD VST129.
Procedure Division ADD CORRESPONDING ADD CORRESPONDING ADD CORRESPONDING group-1 TO group-2 CORR ROUNDED SIZE ERROR ON imperative-stmt-1 NOT ERROR SIZE ON imperative-stmt-2 END-ADD VST130.vsd ALTER ALTER TO paragraph-name destination PROCEED TO VST131.
Procedure Division CALL CALL CALL called-entity END-CALL USING phrase on-phrase not-on-phrase historical-on-phrase VST132.vsd called-entity program-name file-mnemonic OF IN identifier VST133.vsd USING phrase USING parameter-1 REFERENCE BY CONTENT VALUE parameter-2 VST134.vsd on-phrase EXCEPTION excp-imperative-statement ON VST615.
Procedure Division CANCEL historical-on-phrase excp-imperative-statement EXCEPTION ON OVERFLOW VST135.vsd not-on-phrase NOT EXCEPTION ON non-excp-imperative-statement VST528.vsd CANCEL program-name CANCEL OF file-mnemonic IN identifier VST136.vsd CHECKPOINT Note. Do not use this directive in the OSS environment. CHECKPOINT data-name-1 FILE data-name-2 file-name FILE QUEUE checkpoint-list-name VST137.
Procedure Division CLOSE for Sequential and Line Sequential Files CLOSE for Sequential and Line Sequential Files CLOSE file-name file-info VST138.vsd file-info UNIT REEL FOR NO WITH REMOVAL REWIND LOCK VST139.vsd CLOSE for Relative, Indexed, and Queue Files CLOSE file-name WITH LOCK VST140.
Procedure Division COMPUTE COMPUTE result COMPUTE ROUNDED expression = SIZE ERROR imp-stmt-1 ON NOT SIZE ERROR imp-stmt-2 ON END-COMPUTE VST141.vsd CONTINUE CONTINUE VST142.vsd COPY COPY OF text-name . library-name IN REPLACING phrase VST244.
Procedure Division COPY library-name system-file-name define-name-literal VST245.vsd REPLACING phrase . REPLACING OFF original BY new VST247.vsd original pseudo-text-1 identifier-1 literal-1 word-1 VST248.vsd pseudo-text-1 == text-word == VST250.vsd new pseudo-text-2 identifier-2 literal-2 word-2 VST249.
Procedure Division DELETE pseudo-text-2 == == text-word VST251.vsd Format of a COPY Library section-text pre-text VST252.vsd section-text ? SECTION text-name , format text-line VST253.vsd DELETE DELETE file-name RECORD imperative-stmt-1 INVALID KEY NOT imperative-stmt-2 INVALID KEY END-DELETE VST143.
Procedure Division DISPLAY DISPLAY identifier DISPLAY literal mnemonic-name UPON NO ADVANCING WITH VST144.vsd DIVIDE INTO DIVIDE divisor INTO dividend ROUNDED SIZE ERROR imperative-stmt-1 ON SIZE NOT ERROR ON imperative-stmt-2 END-DIVIDE VST145.
Procedure Division DIVIDE GIVING DIVIDE GIVING divisor DIVIDE INTO dividend BY dividend GIVING divisor quotient ROUNDED SIZE ERROR imperative-stmt-1 ON NOT SIZE ERROR ON imperative-stmt-2 END-DIVIDE VST146.
Procedure Division DIVIDE GIVING REMAINDER DIVIDE GIVING REMAINDER DIVIDE divisor INTO dividend BY dividend GIVING divisor quotient ROUNDED remainder REMAINDER SIZE ERROR imperative-stmt-1 ON SIZE NOT ERROR ON imperative-stmt-2 END-DIVIDE VST147.vsd ENTER ENTER routine-name language OF file-mnemonic IN USING parameter OMITTED GIVING return-value VST148.
Procedure Division ENTER COBOL parameter data-name literal ( arithmetic-expression ) file-name VST149.vsd ENTER COBOL ENTER . COBOL VST150.vsd EVALUATE EVALUATE subject-list WHEN object-list WHEN OTHER match-imp-stmt no-match-imp-stmt END-EVALUATE VST151.vsd subject-list subject ALSO subject VST616.
Procedure Division EVALUATE subject identifier literal expression TRUE FALSE VST152.vsd object-list object ALSO object VST153.vsd object ANY condition TRUE FALSE range NOT VST154.vsd range identifier-1 literal-1 THROUGH identifier-2 arith-exp-1 THRU literal-2 arith-exp-2 VST155.
Procedure Division EXIT EXIT EXIT PROGRAM PARAGRAPH SECTION PERFORM CYCLE VST156.vsd Unconditional GO TO GO TO procedure-name VST158.vsd Conditional GO TO GO procedure-name TO DEPENDING ON depend VST159.vsd Delimited-Scope IF IF condition statement-1 THEN END-IF ELSE statement-2 VST160.
Procedure Division Conditional IF Conditional IF IF condition THEN statement-1 NEXT SENTENCE ELSE statement-2 NEXT SENTENCE VST161.vsd INITIALIZE INITIALIZE receiver REPLACING replacement VST162.vsd replacement ALPHABETIC ALPHANUMERIC NUMERIC ALPHANUMERIC-EDITED NUMERIC-EDITED BY DATA sender literal VST163.
Procedure Division INSPECT TALLYING INSPECT TALLYING INSPECT source-string tallying-phrase VST164.vsd tallying-phrase TALLYING tally FOR for-clause VST165.vsd for-clause CHARACTERS position ALL compare-string LEADING position VST166.vsd position BEFORE AFTER delim-string INITIAL VST167.vsd INSPECT REPLACING INSPECT source-string replacing-phrase VST168.
Procedure Division INSPECT REPLACING replacing-phrase REPLACING absolute-replacement matching-replacement VST169.vsd absolute-replacement CHARACTERS BY replace-string position VST170.vsd position BEFORE AFTER delim-string INITIAL VST167.vsd matching-replacement ALL LEADING FIRST compare-string BY replace-string position VST172.
Procedure Division INSPECT TALLYING REPLACING INSPECT TALLYING REPLACING INSPECT source-string tallying-phrase replacing-phrase VST174.vsd tallying-phrase TALLYING tally FOR for-clause VST165.vsd for-clause CHARACTERS position ALL compare-string LEADING position VST166.vsd position BEFORE AFTER delim-string INITIAL VST167.vsd replacing-phrase REPLACING absolute-replacement matching-replacement VST169.
Procedure Division INSPECT TALLYING REPLACING absolute-replacement CHARACTERS BY replace-string position VST170.vsd position BEFORE AFTER delim-string INITIAL VST167.vsd matching-replacement ALL LEADING FIRST compare-string BY replace-string position VST172.
Procedure Division INSPECT CONVERTING INSPECT CONVERTING INSPECT source-string CONVERTING match VST175.vsd match compare-string TO replace-string position VST173.vsd position BEFORE AFTER delim-string INITIAL VST167.vsd LOCKFILE LOCKFILE file-name TIME LIMIT wait-time VST176.
Procedure Division MERGE MERGE MERGE merge-file key-specifier COLLATING SEQUENCE phrase USING phrase output-specifier VST177.vsd key-specifier ASCENDING ON DESCENDING key KEY VST178.vsd COLLATING SEQUENCE phrase SEQUENCE COLLATING alphabet-name IS VST179.vsd USING phrase USING merge-in-1 merge-in-2 merge-in-n VST180.
Procedure Division MOVE TO output-specifier OUTPUT PROCEDURE outproc-1 IS THROUGH outproc-2 THRU GIVING merge-out VST181.vsd MOVE TO MOVE sender TO receiver VST182.vsd MOVE CORRESPONDING MOVE CORRESPONDING group-1 TO group-2 CORR VST183.
Procedure Division MULTIPLY BY MULTIPLY BY MULTIPLY BY multiplicand multiplier ROUNDED SIZE ERROR imperative-stmt-1 ON NOT SIZE ERROR ON imperative-stmt-2 END-MULTIPLY VST184.
Procedure Division MULTIPLY GIVING MULTIPLY GIVING MULTIPLY BY multiplicand multiplier GIVING result ROUNDED SIZE ERROR imperative-stmt-1 ON NOT SIZE ERROR ON imperative-stmt-2 END-MULTIPLY VST185.
Procedure Division OPEN OPEN OPEN file-specification VST186.vsd file-specification INPUT input-file-description OUTPUT I-O output-file-description i-o-file-description EXTEND extend-file-description VST187.vsd input-file-description For a sequential, relative, indexed, or queue file: infile TIME LIMITS WITH SHARED SYNCDEPTH PROTECTED «REVERSED» EXCLUSIVE sync NO REWIND WITH VST188.
Procedure Division OPEN For a line sequential file: infile SHARED PROTECTED EXCLUSIVE VST627.vsd output-file-description For a sequential, relative, indexed, or queue file: outfile TIME LIMITS WITH SHARED SYNCDEPTH PROTECTED sync NO EXCLUSIVE REWIND WITH VST189.vsd For a line sequential file: outfile SHARED PROTECTED EXCLUSIVE VST628.
Procedure Division OPEN i-o-file-description For a sequential, relative, indexed, or queue file: iofile TIME LIMITS WITH SYNCDEPTH SHARED sync PROTECTED EXCLUSIVE VST190.vsd For a line sequential file: iofile SHARED PROTECTED EXCLUSIVE VST626.vsd extend-file-description For a sequential, relative, indexed, or queue file: extfile TIME LIMITS WITH SHARED SYNCDEPTH sync PROTECTED EXCLUSIVE VST191.
Procedure Division Unconditional PERFORM For a line sequential file: extfile SHARED PROTECTED EXCLUSIVE VST629.vsd Unconditional PERFORM PERFORM procedure-group END-PERFORM imperative-statement VST192.vsd procedure-group proc-1 THROUGH proc-2 THRU VST193.vsd PERFORM TIMES PERFORM procedure-group count count TIMES TIMES imperative-statement END-PERFORM VST194.vsd procedure-group proc-1 THROUGH proc-2 THRU VST193.
Procedure Division PERFORM UNTIL PERFORM UNTIL PERFORM procedure-group test-site UNTIL condition UNTIL condition test-site END-PERFORM imperative-statement VST196.vsd procedure-group proc-1 THROUGH proc-2 THRU VST193.vsd test-site TEST WITH BEFORE AFTER VST197.
Procedure Division PERFORM VARYING PERFORM VARYING PERFORM procedure-group test-site varying-phrase after-phrase varying-phrase test-site after-phrase imperative-statement END-PERFORM VST198.vsd procedure-group proc-1 THROUGH proc-2 THRU VST193.vsd test-site TEST BEFORE WITH AFTER VST197.vsd varying-phrase VARYING UNTIL vary-1 FROM base-1 BY step-1 condition-1 VST199.
Procedure Division READ for Sequential or Dynamic Access after-phrase AFTER FROM vary-2 UNTIL base-2 BY step-2 condition-2 VST200.vsd READ for Sequential or Dynamic Access READ file-name NEXT REVERSED RECORD INTO data-name LOCK WITH PROMPT TIME LIMIT END prompt-item wait-time imperative-stmt-1 AT NOT END imperative-stmt-2 AT END-READ VST201.
Procedure Division READ for Line Sequential Access READ for Line Sequential Access READ file-name INTO data-name END imperative-stmt-1 AT NOT END imperative-stmt-2 AT END-READ VST630.
Procedure Division READ for Random or Dynamic Access READ for Random or Dynamic Access READ file-name RECORD INTO data-name LOCK WITH TIME LIMIT wait-time KEY key IS INVALID imperative-stmt-1 KEY NOT INVALID KEY imperative-stmt-2 END-READ VST202.vsd RELEASE RELEASE record-name FROM data-name VST203.
Procedure Division REPLACE REPLACE REPLACE pseudo-text-1 BY pseudo-text-2 . OFF VST254.vsd pseudo-text-1 == text-word == VST250.vsd pseudo-text-2 == == text-word VST251.
Procedure Division RETURN RETURN RETURN file-name INTO END data-name imperative-stmt-1 AT NOT END imperative-stmt-2 AT END-RETURN VST204.vsd REWRITE for Sequential, Relative, Indexed, and Queue Files REWRITE record-name FROM data-name UNLOCK WITH INVALID imperative-stmt-1 KEY NOT INVALID KEY imperative-stmt-2 END-REWRITE VST205.
Procedure Division REWRITE for Line Sequential Files REWRITE for Line Sequential Files REWRITE FROM record-name data-name END-REWRITE VST721.vsd SEARCH VARYING SEARCH table END VARYING indexer imperative-stmt-1 AT WHEN condition imperative-stmt-2 NEXT SENTENCE END-SEARCH VST206.
Procedure Division SEARCH ALL SEARCH ALL SEARCH ALL table END imperative-stmt-1 AT WHEN match-1 AND match-n imperative-stmt-2 NEXT SENTENCE END-SEARCH VST207.vsd match-1 match-n identifier-1 equal-part identifier-2 literal-2 arithmetic-expression-2 condition-name-1 VST208.vsd equal-part EQUAL IS TO = VST209.
Procedure Division SET TO for Pointer Data Items SET TO for Pointer Data Items SET TO pointer address VST605.vsd pointer ADDRESS OF identifier-1 identifier-2 VST606.vsd address ADDRESS OF identifier-3 identifier-4 NULL NULLS VST607.vsd SET TO for Nonpointer Data Items SET TO identifier-1 identifier-2 index-name-2 index-name-1 integer mnemonic-name TO ON OFF condition-name TO TRUE VST211.
Procedure Division SET UP or SET DOWN for Pointer Data Items SET UP or SET DOWN for Pointer Data Items SET UP pointer BY number-of-locations DOWN VST608.vsd number-of-locations identifier-1 integer VST609.vsd SET UP or SET DOWN for Nonpointer Data Items SET UP index-name BY DOWN identifier integer VST212.vsd SORT SORT sd-name key-specifier DUPLICATES phrase COLLATING SEQUENCE phrase input-specifier-1 output-specifier-1 input-specifier-2 output-specifier-2 VST213.
Procedure Division SORT key-specifier ASCENDING ON key DESCENDING KEY VST214.vsd DUPLICATES phrase DUPLICATES WITH IN ORDER VST215.vsd COLLATING SEQUENCE phrase SEQUENCE COLLATING alphabet-name IS VST216.vsd input-specifier-1 INPUT PROCEDURE inproc-1 IS THROUGH inproc-2 THRU VST217.vsd input-specifier-2 USING infile VST381.
Procedure Division START output-specifier-1 OUTPUT PROCEDURE outproc-1 IS THROUGH outproc-2 THRU VST218.vsd output-specifier-2 GIVING outfile VST382.vsd START START file-name KEY phrase APPROXIMATE GENERIC TIME LIMIT wait-time INVALID imperative-stmt-1 KEY NOT INVALID imperative-stmt-2 KEY END-START VST219.
Procedure Division START KEY phrase KEY relationship key IS position VST220.vsd relationship GREATER THAN OR EQUAL TO > >= = LESS NOT THAN < VST221.vsd If position is present, relationship is limited to: EQUAL TO = VST223.vsd position POSITION position-key BEFORE AFTER VST222.vsd Note. BEFORE is available only for the ECOBOL compiler.
Procedure Division STARTBACKUP STARTBACKUP Note. Do not use this directive in the OSS environment. STARTBACKUP cpu options backup-ext VST224.vsd options 0 The fault-tolerant facility is to read and process system messages, and the primary process is to terminate abnormally if a trap condition occurs. 1 Same as option 0 except that if the primary process stops, the backup process takes over processing of the application.
Procedure Division STRING STRING STRING DELIMITED part-1 delimiter BY INTO SIZE result POINTER pointer WITH OVERFLOW imperative-stmt-1 ON NOT OVERFLOW imperative-stmt-2 ON END-STRING VST226.
Procedure Division SUBTRACT FROM SUBTRACT FROM SUBTRACT subtrahend FROM minuend-result ROUNDED SIZE ERROR ON imperative-stmt-1 NOT SIZE ERROR ON imperative-stmt-2 END-SUBTRACT VST227.
Procedure Division SUBTRACT GIVING SUBTRACT GIVING SUBTRACT FROM subtrahend GIVING minuend result ROUNDED SIZE ERROR ON imperative-stmt-1 NOT SIZE ERROR ON imperative-stmt-2 END-SUBTRACT VST228.
Procedure Division SUBTRACT CORRESPONDING SUBTRACT CORRESPONDING Caution. SUBTRACT CORRESPONDING is not recommended, because minor changes to one data structure can change the correspondence between its elements and those of the other data structure, and this is difficult to detect. SUBTRACT CORRESPONDING group-1 CORR FROM group-2 ROUNDED SIZE ERROR ON imperative-stmt-1 NOT SIZE ERROR ON imperative-stmt-2 END-SUBTRACT VST229.vsd UNLOCKFILE UNLOCKFILE file-name VST230.
Procedure Division UNSTRING UNSTRING UNSTRING source DELIMITED delim-1 BY OR ALL delim-2 ALL INTO result-list POINTER pointer WITH TALLYING tally IN OVERFLOW imperative-stmt-1 ON NOT OVERFLOW imperative-stmt-2 ON END-UNSTRING VST232.
Procedure Division USE DEBUGGING result-list result DELIMITER delimstore IN COUNT count IN VST233.vsd USE DEBUGGING Note. The 1985 COBOL standard classifies USE DEBUGGING as obsolete. The compiler does not recognize it. For its description, see the COBOL Manual for TNS and TNS/R Programs. USE AFTER EXCEPTION Note. Do not use GLOBAL in a USE AFTER EXCEPTION statement in the declarativesportion. USE AFTER GLOBAL EXCEPTION STANDARD PROCEDURE ERROR ON file-name . INPUT OUTPUT I-O EXTEND VST235.
Procedure Division WRITE for Sequential Files WRITE for Sequential Files WRITE record-name FROM ADVANCING clause NOT from-name end-of-page clause not-end-of-page clause NOT invalid-key-phrase not-invalid-key-phrase END-WRITE VST236.vsd ADVANCING clause BEFORE AFTER ADVANCING LINE no-of-lines LINES mnemonic-name PAGE VST237.vsd end-of-page clause END-OF-PAGE AT imperative-statement EOP VST238.
Procedure Division WRITE for Line Sequential Files not-end-of-page clause END-OF-PAGE AT imperative-statement EOP VST238.vsd invalid-key-phrase INVALID imperative-statement KEY VST239.vsd not-invalid-key-phrase INVALID imperative-statement KEY VST239.vsd WRITE for Line Sequential Files WRITE record-name FROM from-name END-WRITE VST631.
Procedure Division WRITE for Relative, Indexed, and Queue Files WRITE for Relative, Indexed, and Queue Files WRITE record-name FROM from-name invalid-key NOT not-invalid-key END-WRITE VST240.vsd invalid-key INVALID imperative-statement KEY VST239.vsd not-invalid-key INVALID imperative-statement KEY VST239.
44 • • • • • • • • • • • • • • • • • • • • • • • • • • • • • Intrinsic Function Calls ACOS ANNUITY ASIN ATAN CHAR COS CURRENT-DATE DATE-OF-INTEGER DAY-OF-INTEGER FACTORIAL INTEGER INTEGER-OF-DATE INTEGER-OF-DAY INTEGER-PART LENGTH LOG LOG10 LOWER-CASE MAX MEAN MEDIAN MIDRANGE MIN MOD NUMVAL NUMVAL-C ORD ORD-MAX ORD-MIN HP COBOL Manual for TNS/E Programs —520347-003 44- 1
Intrinsic Function Calls • • • • • • • • • • • • • ACOS PRESENT-VALUE RANDOM RANGE REM REVERSE SIN SQRT STANDARD-DEVIATION SUM TAN UPPER-CASE VARIANCE WHEN-COMPILED ACOS FUNCTION ACOS ( argument ) VST421.vsd ANNUITY FUNCTION ( ANNUITY interest-rate number-of-periods ) VST422.vsd ASIN FUNCTION ASIN ( argument ) VST423.
Intrinsic Function Calls ATAN ATAN FUNCTION ( ATAN ) argument VST424.vsd CHAR FUNCTION ( CHAR ) argument VST425.vsd COS FUNCTION COS ( argument ) VST426.vsd CURRENT-DATE FUNCTION CURRENT-DATE VST427.vsd DATE-OF-INTEGER FUNCTION ( DATE-OF-INTEGER argument ) VST428.vsd DAY-OF-INTEGER FUNCTION DAY-OF-INTEGER ( argument ) VST429.
Intrinsic Function Calls FACTORIAL FACTORIAL FUNCTION ( FACTORIAL ) argument VST430.vsd INTEGER FUNCTION INTEGER ( ) argument VST431.vsd INTEGER-OF-DATE FUNCTION ( INTEGER-OF-DATE ) argument VST432.vsd INTEGER-OF-DAY FUNCTION ( INTEGER-OF-DAY ) argument VST433.vsd INTEGER-PART FUNCTION ( INTEGER-PART ) argument VST434.vsd LENGTH FUNCTION LENGTH ( argument ) VST435.
Intrinsic Function Calls LOG LOG FUNCTION LOG ( ) argument VST436.vsd LOG10 FUNCTION ( LOG10 ) argument VST437.vsd LOWER-CASE FUNCTION ( LOWER-CASE string ) VST438.vsd MAX FUNCTION MAX ( argument ) VST439.vsd MEAN FUNCTION MEAN ( argument ) VST440.vsd MEDIAN FUNCTION MEDIAN ( argument ) VST441.
Intrinsic Function Calls MIDRANGE MIDRANGE FUNCTION MIDRANGE ( ) argument VST442.vsd MIN FUNCTION MIN ( argument ) VST443.vsd MOD FUNCTION MOD ( argument-1 ) argument-2 VST444.
Intrinsic Function Calls NUMVAL NUMVAL FUNCTION ( NUMVAL ) string VST445.vsd string " sp " number + - sp sp number + - sp CR DB VST446.vsd number digits ns . ns digits . ns digits VST447.
Intrinsic Function Calls NUMVAL-C NUMVAL-C FUNCTION NUMVAL-C ( ) value-1 value-2 currency-sign VST448.vsd value-1 + spaces spaces number currency-sign spaces spaces VST450.vsd value-2 spaces currency-sign spaces number spaces + - spaces CR DB VST385.vsd number ns digits digits ns ns . ns digits . ns digits VST451.
Intrinsic Function Calls ORD ORD FUNCTION ORD ( argument ) VST452.vsd ORD-MAX FUNCTION ORD-MAX ( ) argument VST435.vsd ORD-MIN FUNCTION ORD-MIN ( ) argument VST454.vsd PRESENT-VALUE FUNCTION ( PRESENT-VALUE discount-rate ) period-end-amount VST455.vsd RANDOM FUNCTION RANDOM ( argument ) VST456.
Intrinsic Function Calls RANGE RANGE FUNCTION ( RANGE ) argument VST457.vsd REM FUNCTION ( REM dividend divisor ) VST458.vsd REVERSE FUNCTION ( REVERSE ) argument VST459.vsd SIN FUNCTION SIN ( argument ) VST460.vsd SQRT FUNCTION SQRT ( argument ) VST461.
Intrinsic Function Calls STANDARD-DEVIATION STANDARD-DEVIATION FUNCTION ( STANDARD-DEVIATION argument ) VST462.vsd SUM FUNCTION ( SUM ) argument VST463.vsd TAN FUNCTION TAN ( argument ) VST464.vsd UPPER-CASE FUNCTION ( UPPER-CASE ) string VST465.vsd VARIANCE FUNCTION VARIANCE ( argument ) VST466.vsd WHEN-COMPILED FUNCTION WHEN-COMPILED VST467.
Intrinsic Function Calls WHEN-COMPILED HP COBOL Manual for TNS/E Programs —520347-003 44 -12
45 ZCOBDLL Routine Calls If you omit an optional parameter when you call a ZCOBDLL routine, you must put the keyword OMITTED in its position if you specify subsequent parameters. Trailing OMITTEDs are not required. (The syntax diagrams do not reflect this, because it would make them much harder to read.
ZCOBDLL Routine Calls COBOL_CONTROL_ COBOL_CONTROL_ Caution. The HP COBOL run-time library does not attempt to validate calls to CONTROL. To avoid interfering with the operation of the HP COBOL run-time library, use COBOL_CONTROL_ only if absolutely necessary. OF ns " ENTER ns COBOL_CONTROL_ " library-reference USING file-name GIVING operation param error-return cpinfo VST610.vsd COBOL_GETENV_ ns ENTER ns COBOL_GETENV_ " USING env-var GIVING length " return-value VST722.
ZCOBDLL Routine Calls COBOL_RETURN_SORT_ERRORS_ COBOL_RETURN_SORT_ERRORS_ ENTER OF " ns COBOL_RETURN_SORT_ERRORS_ ns " library-reference USING sd-name error-report GIVING return-code VST809.vsd COBOL_REWIND_SEQUENTIAL_ ENTER OF " ns COBOL_REWIND_SEQUENTIAL_ ns " library-reference USING file-name GIVING return-code VST810.
ZCOBDLL Routine Calls COBOL_SET_SORT_PARAM_TEXT_ COBOL_SET_SORT_PARAM_TEXT_ " ENTER OF ns COBOL_SET_SORT_PARAM_TEXT_ ns " library-reference USING sd-name param-id param-text subsort-number GIVING return-code VST811.vsd COBOL_SET_SORT_PARAM_VALUE_ " ENTER OF ns ns COBOL_SET_SORT_PARAM_VALUE_ " library-reference USING sd-name param-id param-value GIVING subsort-or-file-number return-code VST811.
ZCOBDLL Routine Calls COBOL_SET_MAX_RECORD_ COBOL_SET_MAX_RECORD_ ns ENTER USING ns COBOL_SET_MAX_RECORD_ " " file-name new-length GIVING result VST737.vsd COBOL_SETMODE_ Caution. The HP COBOL run-time library does not attempt to validate calls to SETMODE. To avoid interfering with the operation of the HP COBOL run-time library, use COBOL_SETMODE_ only if absolutely necessary.
ZCOBDLL Routine Calls COBOL_SPECIAL_OPEN_ COBOL_SPECIAL_OPEN_ • • • • For Spoolers and Printers For System Log Files For Partitioned Disk Files For Tape Files For Spoolers and Printers ENTER OF " ns COBOL_SPECIAL_OPEN_ ns " library-reference USING file-name open-type = 1 exclusion sync-depth no-eject level-3 location form-name report-name copies page-size flags owner max-lines max-pages code-129 form-feed GIVING return-code VST813.
ZCOBDLL Routine Calls For System Log Files For System Log Files ENTER OF " ns COBOL_SPECIAL_OPEN_ ns " library-reference USING file-name open-type = 2 exclusion sync-depth GIVING time-limits return-code VST814.vsd For Partitioned Disk Files ENTER OF " ns COBOL_SPECIAL_OPEN_ ns " library-reference USING file-name open-type = 3 exclusion sync-depth open-mode GIVING time-limits return-code VST815.
ZCOBDLL Routine Calls For Tape Files For Tape Files ns ENTER OF " ns COBOL_SPECIAL_OPEN_ " library-reference USING file-name open-type = 4 exclusion sync-depth time-limits open-mode mount-messages end-of-tape-process GIVING return-code VST614.
46 ZCREDLL Routine Calls See the CRE Programmer’s Guide.
ZCREDLL Routine Calls HP COBOL Manual for TNS/E Programs —520347-003 46- 2
Part IV.
Part IV.
47 Compiler Diagnostic Messages Topics: • • • • • • Message Indicator Line Warning Message Format Error Message Format Failure Message Format Message List Other Products’ Error Messages Table 47-1.
Compiler Diagnostic Messages Message Indicator Line Message Indicator Line A message indicator line precedes each compiler diagnostic message.
Compiler Diagnostic Messages Error Message Format Error Message Format An error message has this format: *** Error: --> message-text [Error message-number] The brackets are part of the message, not indicators that the bracketed material is optional. Failure Message Format A failure message has this format: *** Failure: --> message-text [Failure message-number] The brackets are part of the message, not indicators that the bracketed material is optional.
Compiler Diagnostic Messages Message List 2 (Failure) OPEN failure on xxxx file (file-name): ddd Cause. One of: • • The compiler cannot open the file named file-name. The file name parameter of the CONSULT, SEARCH, LIBRARY, or ERRORFILE directive is either absent or does not have the form of a disk file name. The xxxx parameter is the type of compiler file (source, copy, list, or work). filename is the external form of the file name.
Compiler Diagnostic Messages Message List 4 (Failure) OPEN edit failure on xxxx file (file-name): ddd Cause. The compiler cannot initialize the indicated EDIT file for reading. xxxx is the type of compiler file (source or copy). file-name is the external form of the file name. ddd is the error code describing the problem. A negative ddd value indicates a format error in the file. A nonnegative value indicates a Guardian file management error.
Compiler Diagnostic Messages Message List 9 (Failure) Spooler failure on list file (file-name): ddd Cause. The compiler either cannot initiate or cannot terminate spooler processing for its list file. file-name is the external form of the file name. ddd is the error code describing the problem (explained in documentation of the SPOOLSTART and SPOOLEND procedures). 10 (Failure) Unable to allocate compiler data space: ddd Cause. The compiler cannot allocate its extended data segment.
Compiler Diagnostic Messages Message List 14 (Failure) End of file reached during error recovery Cause. The compiler reached the end of the source file during an attempt to recover from a syntax error. This usually occurs in one of these situations: • • A syntax error is near the end of the source file, so the remaining text does not provide enough context for the compiler to decide how to recover.
Compiler Diagnostic Messages Message List 16 (Failure) Too many errors Cause. The number of error messages exceeds the specified limit (100 unless specified otherwise in an ERRORS directive). 17 (Failure) Dictionary overflow Cause. The compiler’s symbol dictionary has insufficient space to describe all entities defined in the current separately compiled program. Divide the program into two or more separately compiled programs. Use PARAM SYMBOL-BLOCKS to allocate more space.
Compiler Diagnostic Messages Message List 25 (Warning) Blank continuation line Cause. A source line marked as a continuation line (having a hyphen in the indicator area) contains only spaces as its text. 26 (Warning) Improper indicator character Cause. One of: • • The character in the indicator area of a source line is not minus (-), asterisk (*), slash (/), question mark (?), d, D, or space. A continuation line is part of a comment-entry in a paragraph of the Identification Division.
Compiler Diagnostic Messages Message List 29 (Error) Missing quote character Cause. The terminating quotation-mark character (") is missing from a nonnumeric literal. 30 (Error) Null literal Cause. A nonnumeric literal contains no characters (has no textual value). 31 (Error) Literal exceeds 160 characters A nonnumeric literal contains more than 160 characters. 32 (Error) Token exceeds 160 characters Cause. A character-string appears (to the compiler) to contain more than 160 characters.
Compiler Diagnostic Messages Message List 36 (Warning or Error) Improper use of reserved word Cause. Warning: A COBOL reserved word is the text-name or library-name in a COPY statement. Error: A COBOL reserved word is in an improper context. Usually this message reports the use of a noncritical reserved word (one defined in an unsupported language module) as a user-defined word. 37 (Error) Do not quote PICTURE string Cause. A PICTURE character-string is specified as a nonnumeric literal.
Compiler Diagnostic Messages Message List 40 (Error) Improper syntax Cause. One of: • • The analysis of a COPY or REPLACE statement failed when it reached the indicated element because of a syntactic problem (for example, a required component is missing). The compiler found a syntactic problem in a Procedure Division statement after the general syntax analysis completed with apparent success. 41 (Error) Syntax error - replacing unexpected token with xxxx Cause.
Compiler Diagnostic Messages Message List 44 (Error) Syntax error detected at token xxxx Cause. The compiler’s syntax analyzer cannot accept the token xxxx (a characterstring or a separator) and the recovery mechanism cannot find a simple correction. The compiler tried to recover by discarding text following the token, along with as little text preceding the token as is necessary, until the remaining text was syntactically acceptable. 45 (Warning) Parsing resumed at token xxxx Cause.
Compiler Diagnostic Messages Message List 48 (Warning or Error) Improper context for this directive Cause. Warning: The SYMBOLS or NOSYMBOLS directive is within a separately compiled program. It is ignored in this context. Error: One of: • • • • The indicated directive (MAIN or NONSTOP) cannot appear at this point in the source text. It must precede the first source program’s Identification Division header. The indicated directive (SYNTAX or COMPILE) cannot appear at this point in the source text.
Compiler Diagnostic Messages Message List 52 (Error) Expected program-name Cause. The MAIN directive has either no parameter or a parameter that is not a COBOL word. 53 (Error) Expected comma or other delimiter valid for context Cause. One of: • • • Multiple compiler directives appear on the same line but are not separated by semicolons. Multiple parameters of a compiler directive are not separated by commas.
Compiler Diagnostic Messages Message List 56 (Warning) This directive permitted only on the command line Cause. The SQL directive must be specified on the command line. An SQL directive in the source program will be ignored. 58 (Error) Unable to convert continuation to debugging line Cause. The compiler could not convert a source line processed under the control of a COPY or REPLACE statement to a debugging line (by putting D or d in the indicator area) because the line is also a continuation line.
Compiler Diagnostic Messages Message List Error: Use of an unsupported language element, for example: • • • • The OPEN … REVERSED option Elements defined in the Communications module Elements defined in the Report Writer module An I/O statement in a nested program that implicitly references a GLOBAL declarative that is defined in a containing program 61 (Warning) Logic may differ from COBOL85 - move alphanumeric to numeric with invalid data Cause.
Compiler Diagnostic Messages Message List 63 (Error) Ambiguous reference Cause. A reference has insufficient qualification to identify a unique entity. 64 (Error) Zero not permitted in this context Cause. The indicated integer numeric literal has the value 0, which is not permitted in this context. 65 (Error) Integer not within expected range Cause. One of: • • The value of an integer numeric literal is either too small or too large for its context.
Compiler Diagnostic Messages Message List 69 (Error) Expected alphabet-name Cause. One of: • • The alphabet-name specified in the PROGRAM COLLATING SEQUENCE clause is not defined. A reference that must identify an alphabet-name does not. 70 (Error) Expected file name Cause. A reference that must identify a file name does not. 71 (Error) Expected symbolic character Cause. The indicated COBOL word appears in a context where a symbolic-character is expected, but it does not identify one.
Compiler Diagnostic Messages Message List 74 (Error) Too many actual parameters Cause. One of: • • A CALL statement specifies more parameters in its USING phrase than HP COBOL supports. An ENTER statement specifies more parameters in its USING phrase than the routine expects. 75 (Error) Out of order Cause. The indicated language element does not appear in the proper position within the source program. 76 (Error) Duplicate phrase Cause. The indicated phrase duplicates the function of a preceding one.
Compiler Diagnostic Messages Message List 80 (Error) Clause not permitted in this context Cause. The indicated clause cannot appear in the current entry. 81 (Error) Not permitted within contained program Cause. One of: • • • The Configuration Section is within a contained program. The RECEIVE-CONTROL paragraph is within a contained program. A program is not terminated by an END PROGRAM statement or an ENDUNIT directive. 82 (Error) Too many keys Cause.
Compiler Diagnostic Messages Message List 85 (Warning) Arithmetic expression too complex - floating-point used Cause. An arithmetic expression was too complex to produce a correct answer, probably because the intermediate result exceeded the capacity of the intermediate data item (36 digits) or because there was more than one division operation. The expression uses a floating-point, intermediate, data item, which might cause the result to be slightly off in the rightmost positions.
Compiler Diagnostic Messages Message List 90 (Error) Permitted only within contained program Cause. The COMMON phrase appears somewhere other than within a contained program. 91 (Error) System-name not defined in this context Cause. One of: • • • • The reference in the CHARACTER-SET clause is not one of the system-names defined for that clause. The system-name in the ALPHABET clause is not EBCDIC, the only value that HP COBOL supports.
Compiler Diagnostic Messages Message List 95 (Error) Duplicates not permitted Cause. One of: • • • A character has more than one collating position in a character set. A character appears more than once in the first operand of the CONVERTING phrase in an INSPECT statement. A section-name appears more than once in a SOURCE directive. 96 (Error) Too many or too few values Cause. The number of values in the SYMBOLIC CHARACTER clause differs from the number of symbolic-characters being defined.
Compiler Diagnostic Messages Message List 101 (Error) Relative key permitted only for relative organization Cause. A file that does not have relative organization has a RELATIVE KEY clause in its file-control entry. 102 (Error) Record key permitted only for indexed organization Cause. A file that does not have indexed organization has a RECORD KEY clause in its file-control entry. 103 (Error) Sequential organization requires sequential access Cause.
Compiler Diagnostic Messages Message List 107 (Warning) Duplicate file-name in SAME clause Cause. A file name appears more than once in a single SAME AREA, SAME RECORD AREA, or SAME SORT AREA clause. 108 (Error) File name permitted in only one SAME clause Cause. One of: • • • A particular file name appears in more than one SAME AREA clause. A particular file name appears in more than one SAME RECORD AREA clause. A particular sort-merge file name appears in more than one SAME SORT AREA clause.
Compiler Diagnostic Messages Message List 112 (Error) Too many file names Cause. A source program has too many CONSULT, LIBRARY, and SEARCH files for the available memory. 113 (Error) file name permitted only once in MULTIPLE FILE TAPE clauses Cause. The same file name appears more than once in a MULTIPLE FILE TAPE clause or in more than one MULTIPLE FILE TAPE clause. 114 (Error) File position required Cause.
Compiler Diagnostic Messages Message List 117 (Error) Receive control table too large Cause. The size of the receive control table as specified in the RECEIVE-CONTROL paragraph exceeds 62 KB (65,400 characters). Reduce table-length in the TABLE OCCURS phrase or reduce another factor in these formulas, which determine the size of the receive control table: ((max_requesters + 1) * 26) + ((((max_reply + 1) / 2) + 4) * (max_requesters * sync)) +4 121 (Error) Improper level-number Cause.
Compiler Diagnostic Messages • • Message List The GLOBAL clause appears in descriptions that are not within the File Section, Working-Storage Section, or Extended-Storage Section. The description of a data item defined within the File Section or Linkage Section includes a VALUE clause. 125 (Error) Not preceded by conditional variable Cause. The definition of a condition-name (a name whose data description entry has level-number 88) is not preceded by the entry for the data item whose value it tests.
Compiler Diagnostic Messages Message List 130 (Error) FILLER not permitted for this level-number Cause. One of: • • A data description entry with level-number 66 or 77 does not include the dataname. A data description entry with level-number 88 does not include the condition-name. 131 (Error) Redefined data item not found Cause. The reference in a REDEFINES clause does not identify a data item.
Compiler Diagnostic Messages Message List 135 (Error) Redefined data item not preceding item at this level Cause. The data description entry of a redefinition was separated from the data description entry of the redefined item by another data description entry with the same level-number, and the intervening entry did not redefine the same data item. 136 (Error) Redefined data item is table or has variable size Cause. The program tried to redefine a table or a data structure with a variable size.
Compiler Diagnostic Messages Message List 141 (Error) Too many digit positions Cause. The PICTURE character-string for a numeric or numeric-edited data item has more than 18 digit positions. 142 (Error) Too many character positions Cause. The PICTURE character-string has more than 134,217,726 character positions. 143 (Error) PICTURE clause not permitted for specified usage Cause. The PICTURE clause describes a data item with USAGE INDEX, NATIVE-2, NATIVE-4, or NATIVE-8.
Compiler Diagnostic Messages Message List 147 (Error) Display usage required when SIGN clause applies Cause. One of these items does not have USAGE DISPLAY, as it must: • • A data item described with a SIGN clause A signed numeric data item that is subordinate to a data structure described with a SIGN clause 148 (Error) Only signed numeric picture permitted when SIGN clause specified Cause.
Compiler Diagnostic Messages Message List 152 (Error) JUSTIFIED clause not permitted in group with value or condition-names Cause. A data item is described with a JUSTIFIED clause, but either the data item is subordinate to a data structure described with a VALUE clause or the data item is associated with condition-names. 153 (Error) BLANK WHEN ZERO clause requires display usage Cause. A data item is described with a BLANK WHEN ZERO clause, but the data item does not have USAGE DISPLAY, as it must.
Compiler Diagnostic Messages Message List 157 (Error) VALUE clause not permitted for index data item Cause. A data item with USAGE INDEX is described with a VALUE clause. 158 (Error) VALUE clause not permitted for redefinition Cause. A data item that is part or all of a redefinition is described with a VALUE clause. 159 (Error) VALUE clause not permitted for external data item Cause. An external data item is described with a VALUE clause.
Compiler Diagnostic Messages Message List 164 (Error) Table nesting too deep Cause. A table has more than 7 OCCURS clauses. 165 (Error) Variable occurrences not permitted for subordinate table Cause. A data item subordinate to a table item is described with an OCCURS clause that includes the DEPENDING phrase. 166 (Error) Variable occurrences not permitted in redefinition Cause. A data item that is part or all of a redefinition is described with an OCCURS clause that includes the DEPENDING phrase.
Compiler Diagnostic Messages Message List 171 (Error) Improper range for renamed data items Cause. One of: • • The second data item in a RENAMES clause contains no character positions that are not contained in the first data item. The initial character position of the second data item in a RENAMES clause precedes the initial character position of the first data item within their record item. 172 (Error) Missing PICTURE clause Cause.
Compiler Diagnostic Messages Message List 177 (Error) Data item attributes not compatible with CODE-SET clause Cause. A file description that includes the CODE-SET clause violates one of these rules: • • All data items defined in the record descriptions must have USAGE DISPLAY. All signed numeric data items must be described as having the sign in a separate character position. 178 (Error) Redefinition not properly aligned Cause.
Compiler Diagnostic Messages Message List 183 (Error) Table item permitted only as first key data item Cause. A reference in the KEY phrase of an OCCURS clause identifies the table item itself, and that reference is not the first reference in the KEY phrase. 184 (Error) Nonnumeric literal not permitted for numeric data item Cause.
Compiler Diagnostic Messages Message List 189 (Error) 01 or 77 level data item too large for section Cause. The size of a data item exceeds the maximum size permitted for the Data Division section in which it is defined. 190 (Error) Described with clauses not permitted for sort-merge file Cause. The file-control entry for a sort-merge file includes clauses other than the SELECT and ASSIGN clauses. 191 (Error) EXTERNAL clause not compatible with SAME clause Cause.
Compiler Diagnostic Messages Message List 194 (Error) Logical page too large Cause. The sum of the top margin, page body, and bottom margin of a logical page exceeds 9999 lines. 195 (Error) CODE-SET permitted only for sequential organization Cause. A file is described with the CODE-SET clause, but it does not have sequential organization, as it must. 196 (Error) Referenced alphabet-name not permitted in this context Cause.
Compiler Diagnostic Messages Message List 200 (Error) Record size exceeds block size Cause. The maximum record size for the file exceeds the block size specified by the BLOCK CONTAINS clause. 201 (Error) Fixed-size records incompatible with RECORD DELIMITER clause Cause. A file described with the RECORD DELIMITER clause does not have variablesize records, as it must. 202 (Error) Block size too large Cause. A block exceeds 32,767 characters. 203 (Error) Record key not found within file record Cause.
Compiler Diagnostic Messages Message List 206 (Error) Missing file description entry for file name Cause. A file name introduced in a file-control entry is not defined in a file description entry. 207 (Error) Padding item not found Cause. The PADDING clause references an undefined name. 208 (Error) Padding item not simple one character alphanumeric Cause.
Compiler Diagnostic Messages Message List 212 (Error) Relative key item not simple unscaled integer Cause. The RELATIVE KEY clause references an object about which one of these is true: • • • It is not an unsigned integer data item. It is described with P s in its PICTURE clause. It is a table or special register. 213 (Error) Relative key item not external Cause. The RELATIVE KEY clause for an external file references a data item that is not external.
Compiler Diagnostic Messages Message List 219 (Error) Linage control item not found Cause. The LINAGE clause references an undefined name. 220 (Error) Linage control item not simple unsigned integer Cause. The LINAGE clause references either an object that is not an unsigned integer data item or an object that is a table or special register. 221 (Error) Linage control item not external Cause. The LINAGE clause for an external file references a data item that is not external.
Compiler Diagnostic Messages Message List 225 (Error) Depending item in improper section Cause. The data item referenced in the DEPENDING phrase of a RECORD clause is not defined in the Working-Storage, Extended-Storage, or Linkage Section. 226 (Error) Depending item not external Cause. The DEPENDING phrase of an OCCURS or RECORD clause for an external data item or an external file references a data item that is not external. 227 (Error) Depending item not global Cause.
Compiler Diagnostic Messages Message List 230 (Error) Message source item not simple alphanumeric, has improper size, or not word-aligned Cause. The MESSAGE SOURCE clause references an object about which one of these is true: • • • • It is not a fixed-size alphanumeric data item. It is a table item. It has fewer than 32 character positions. It begins on an odd-character boundary within a record. 231 (Error) Error code item not found Cause. The ERROR CODE references an undefined name.
Compiler Diagnostic Messages Message List 234 (Error) No sort-merge file name in SAME SORT clause Cause. None of the file names in the SAME SORT AREA clause identifies a sortmerge file. 235 (Error) Too many external objects Cause. The program defines more external objects (files and records) than the compiler can allocate. 236 (Error) Too many internal files Cause. The program defines more internal files than the compiler can allocate. 237 (Error) Improper target for ADDRESS OF clause Cause.
Compiler Diagnostic Messages Message List 242 (Error) Data-name permitted only once as USING operand Cause. An operand appears more than once in the USING phrase. 243 (Error) Too many USING operands Cause. The USING phrase has more than 126 operands. 244 (Warning or Error) Linkage section data item not found as USING operand Cause. Warning: A data item defined in the Linkage Section is not referenced as a USING operand.
Compiler Diagnostic Messages Message List 248 (Error) Debugging procedures must be first declaratives Cause. Not all debugging procedures precede all nondebugging procedures in the Declaratives Portion of the Procedure Division. 249 (Error) Undefined debugging reference Cause. The indicated USE DEBUGGING statement cannot be resolved to any defined entity. 250 (Error) Debugging not supported for this object Cause. HP COBOL does not support debugging for this type of object.
Compiler Diagnostic Messages Message List 253 (Error) Conflicting debugging declarative assignments Cause. One of: • • • • A USE DEBUGGING statement specifies the same object more than once. More than one USE DEBUGGING statement in a source program specifies the same object. The program has more than one USE DEBUGGING ALL PROCEDURES statement. The program has a USE DEBUGGING ALL PROCEDURES statement and other USE DEBUGGING statements that reference paragraph-names or section-names.
Compiler Diagnostic Messages Message List 257 (Error) No declarative procedures Cause. The Declaratives Portion exists, but contains no procedures. 258 (Error) No nondeclarative procedures Cause. The current source program has an explicit Procedure Division, but its nondeclarative portion is empty. 259 (Error) Exception phrase not compatible with file description Cause. An exception phrase corresponds to a statement with which it cannot be associated.
Compiler Diagnostic Messages Message List 262 (Error) Improper context for WHEN phrase Cause. There is no preceding statement with which the WHEN phrase can be associated. 263 (Error) Improper context for scope delimiter Cause. There is no preceding statement with which the explicit scope delimiter can be associated. 264 (Error) Missing AT END phrase Cause. A RETURN statement does not have an associated AT END phrase. 265 (Error) Missing WHEN phrase Cause.
Compiler Diagnostic Messages Message List 268 (Error) Improper context for NEXT SENTENCE Cause. NEXT SENTENCE is neither in an IF or SEARCH statement nor a replacement for an imperative-statement. 269 (Error) Prior statement must be last in its sequence Cause. The prior statement appears in a sequence of statements, but is not the last one in the sequence, as it must be. 270 (Error) Expected integer numeric literal Cause. One of: • • Only an integer numeric literal can appear in this context.
Compiler Diagnostic Messages Message List 274 (Error) Expected data item Cause. The specified operand cannot appear in this context. (A data item with appropriate attributes would be acceptable here. Other types of operands, such as literals, might also be acceptable.) 275 (Error) Expected display data item Cause. The data item does not have USAGE DISPLAY, as it must. 276 (Error) Expected display data item, no Ps if numeric Cause.
Compiler Diagnostic Messages Message List 280 (Error) Expected numeric data item Cause. The data item is not numeric, as it must be. 281 (Error) Expected integer numeric data item Cause. The data item is not numeric without fraction digits, as it must be. 282 (Error) Expected unscaled numeric data item Cause. Either the data item is not numeric without fraction digits, or it has Ps in its PICTURE character-string. 283 (Error) Expected index data item or integer numeric data item Cause.
Compiler Diagnostic Messages Message List 287 (Error) Expected level 01 or level 77 or elementary data item Cause. One of: • • The FIPS directive specified NONSTANDARDEXT, but the data item is not a level01 item, a level-77 item, or an elementary item of a record. No FIPS directive specified NONSTANDARDEXT, but the data item is not elementary, level-01, level-77, or at a level other than 01 or 77 and aligned on a 2-byte boundary.
Compiler Diagnostic Messages Message List 292 (Error) Improper context for subscripts Cause. A subscript is in the specification of either the table operand in a SEARCH statement or the key operand in a START statement. 293 (Error) Too many or too few subscripts Cause. The reference to a table item or condition-name associated with a table item does not have the correct number of subscripts. 294 (Error) Table item not permitted in subscript Cause. A reference to a table item appears as a subscript.
Compiler Diagnostic Messages Message List 298 (Error) Expected arithmetic operand Cause. The operand of an arithmetic operator is not a numeric literal, a numeric data item, or an arithmetic expression, as it must be. 299 (Warning) Division by zero Cause. The value of a divisor is 0. 300 (Error) Expected relation operand Cause. The operand of a relational operator is not a literal, index-name, data item, or arithmetic expression, as it must be. 301 (Error) Have no implicit operand for relation Cause.
Compiler Diagnostic Messages Message List 303 (Error) No variable among relation operands Cause. A relation includes no references to data items; it is constructed solely from literal operands. 304 (Error) Expected class-name Cause. A name referenced in a context where it must identify a class-name does not. 305 (Error) Improper operand for class test Cause. The subject of a class test is not an identifier, as it must be. 306 (Error) Improper item for alphabetic or class-name test Cause.
Compiler Diagnostic Messages Message List 309 (Error) Expected data file Cause. Only a file name defined in a data file description entry (level indicator FD) is permitted in this context. 310 (Error) Expected sort-merge file Cause. Only a file name defined in a sort-merge file description entry (level indicator SD) is permitted in this context. 311 (Warning) No corresponding pairs Cause. The two data structures specified in a CORRESPONDING operation contain no corresponding subordinates.
Compiler Diagnostic Messages Message List 314 (Error) Expected mnemonic-name associated with a file name Cause. The referenced operand is not a mnemonic-name associated with an external file name in the SPECIAL-NAMES paragraph. 315 (Error) Permitted only when NONSTOP directive specified Cause. The program has a CHECKPOINT or STARTBACKUP statement, but was not compiled with the NONSTOP directive. 316 (Error) Improper context for ROUNDED Cause.
Compiler Diagnostic Messages Message List 321 (Error) Too many subject operands Cause. An EVALUATE statement has more than 127 subjects. 322 (Error) Too many object operands Cause. The number of objects in the WHEN phrase is greater than the number of subjects in the EVALUATE statement. 323 (Error) Too few object operands Cause. The number of objects in the WHEN phrase is less than the number of subjects in the EVALUATE statement. 324 (Error) Corresponding operands not compatible Cause.
Compiler Diagnostic Messages Message List 327 (Error) Receiving category not compatible with sending category Cause. The receiving operand cannot be assigned a value derived from the sending operand; for example: • • SPACE (or one of its equivalents), an alphabetic data item, or an alphanumericedited data item cannot be assigned to a numeric or numeric-edited data item.
Compiler Diagnostic Messages Message List 330 (Error) NO REWIND phrase not permitted for I-O or EXTEND mode Cause. The NO REWIND phrase appears when the open mode is I-O or EXTEND. 331 (Error) EXTEND mode permitted only for sequential access Cause. EXTEND mode is specified for a file access whose access is not sequential. 332 (Error) EXTEND mode not permitted for MULTIPLE FILE TAPE file Cause. EXTEND mode is specified for a file name that is specified in a MULTIPLE FILE TAPE clause.
Compiler Diagnostic Messages Message List 337 (Warning) PROMPT data item exceeds record size Cause. The size of the PROMPT phrase operand exceeds the maximum record size for the file. (The excess characters will not appear in the prompt.) 338 (Error) Operands not compatible for INTO assignment Cause. One of: • • The record descriptions of the file referenced in this statement require that the INTO phrase operand be alphanumeric, and it is not.
Compiler Diagnostic Messages Message List 343 (Error) Not permitted in declaratives Cause. A SORT or a MERGE statement appears in the Declaratives Portion of the Procedure Division. 344 (Error) Key within table or has variable size Cause. A reference in an ASCENDING KEY or DESCENDING key phrase identifies a data item that has a variable size or is referenced by an OCCURS clause. 345 (Error) Key not found within sort-merge file record Cause.
Compiler Diagnostic Messages Message List 348 (Error) Record size incompatible with sort-merge file description Cause. One of: • • The longest possible record of a USING file exceeds the record capacity of the sort-merge file. The longest possible record of the sort-merge file exceeds the record capacity of a GIVING file. 349 (Error) Random access not permitted Cause. A MERGE, SORT, or START statement specifies a file name described with random access. 350 (Error) File set conflict from xxxx Cause.
Compiler Diagnostic Messages Message List 352 (Error) KEY phrase not compatible with NEXT phrase Cause. The KEY phrase appears with a NEXT phrase. 353 (Error) KEY item not found within file record Cause. The reference in the KEY phrase does not identify a key of the specified file. 354 (Error) Length of combined keys exceeds 253 characters Cause. In a file-control entry with multiple keys, the sum of the lengths of the keys exceeds 253 characters. 355 (Error) File has no default prime key Cause.
Compiler Diagnostic Messages Message List 358 (Error) Position data item must be prime key Cause. The operand in the POSITION phrase is not the file’s prime key. (The prime key of a relative file is defined by the RELATIVE KEY clause; the prime key of an indexed file is defined by the RECORD KEY clause.) 359 (Error) ADVANCING mnemonic-name not compatible with LINAGE Cause. The ADVANCING mnemonic-name phrase is used for a file described with the LINAGE clause. 360 (Error) Operand too large Cause.
Compiler Diagnostic Messages Message List 364 (Error) Improper unit-name for language Cause. One of: • • The program-name does not conform to the spelling rules of COBOL. The routine-name does not conform to the spelling rules of its language. 365 (Error) Unit of proper language not found Cause. One of: • • Either the requested COBOL program does not exist in the specified object file, or an entity identified by the program-name exists but is not a COBOL program.
Compiler Diagnostic Messages Message List 369 (Warning) NONSTOP attribute conflict Cause. One of: • • • The source text from which the indicated COBOL program was compiled included the NONSTOP directive, but the current source text does not. The current source text includes a NONSTOP directive, but the source text from which the indicated COBOL program was compiled did not. The program searched an import library that includes a COBOL program that was compiled with the directive NONSTOP.
Compiler Diagnostic Messages Message List 372 (Error) Actual parameter is a file, so formal parameter must be a struct Cause. The actual parameter of an ENTER statement is a file name (FD or SD), but it does not correspond to a formal parameter that expects a struct. 373 (Warning) Potential odd byte address converted to even byte address Cause. The compiler cannot determine if a problem exists. Verify that the correct address is passed to the routine.
Compiler Diagnostic Messages Message List 377 (Warning) Reference with mnemonic-name resolved to contained program Cause. References to a COBOL program specify an object file from which it should be selected, but because the program-name identifies an accessible contained program, the compiler resolves the references to that program. Examine the program logic to verify that this result is acceptable. 378 (Warning) Expected digit string as sending operand Cause.
Compiler Diagnostic Messages Message List 382 (Error) Undefined procedure reference Cause. One of: • • The name indicated appears as a procedure reference, but does not identify a paragraph-name or section-name defined within the Procedure Division of the current source program.
Compiler Diagnostic Messages Message List 386 (Warning or Error) Improper ALTER scope Cause. Warning: One of: • • • An ALTER statement in the nondeclarative portion of the Procedure Division references a paragraph-name or section-name defined in a declarative procedure. An ALTER statement in a declarative procedure references a paragraph-name or section-name defined in another declarative procedure.
Compiler Diagnostic Messages Message List 388 (Warning or Error) Improper PERFORM scope Cause. Warning: A PERFORM statement specifies a range that includes two references. One identifies a paragraph-name or section-name defined in a declarative procedure. The other identifies a paragraph-name or section-name defined in another declarative procedure. It is recommended that both references identify items in the same declarative procedure.
Compiler Diagnostic Messages Message List 390 (Warning) Referenced program not found by compiler Cause. A CALL or CANCEL statement referenced a program that the compiler could not find in the source text or in any file on any search list. These programs must be bound into the run unit before it is executed.
Compiler Diagnostic Messages Message List 396 (Warning) Condition-name has too many values to be referenced by INSPECT Cause. A condition-name has more values than the compiler can send to the Inspect debugger. The compiler sends only the first value. To make all of the values available to the Inspect debugger, replace the condition-name with several condition names, each with a less demanding VALUE clause, and reference all of them wherever the original condition-name is currently referenced.
Compiler Diagnostic Messages • • Message List Find sequences of code that occur several times and make each of them a procedure (see Procedures and Procedure Execution). To transfer control to a paragraph or procedure, use the statement PERFORM. Change level-77 data items and elementary level-01 data items that are numeric from USAGE DISPLAY to USAGE COMP (see USAGE Clause). 401 (Error) Embedded program code exceeds 32767 words Cause.
Compiler Diagnostic Messages Message List 405 (Warning) Relation truth value is constant Cause. The compiler has determined that the value of this relation condition will be always TRUE or always FALSE. (Example: a literal is compared to a shorter data item.) This message might point only to the statement in error, not to the erroneous line of the statement. 406 (Warning) SET statement literal not in subscript range Cause.
Compiler Diagnostic Messages Message List 427 (Error) Multi-byte not permitted in this context Cause. A national data item or national literal appears where it is not permitted. 428 (Error) Literal and data item must both be multi-byte Cause. A literal or data item that is not in the national class appears where all the literals and data items must be in the national class. 429 (Error) Can only compare multi-byte type to multi-byte type Cause.
Compiler Diagnostic Messages Message List 443 (Error) Library object can only contain initial programs Effect. A program that is not an initial program is in a user library. 444 (Error) Embedded programs are not allowed in library object Cause. An embedded program is in a user library. 445 (Error) Global data item not allowed in library object Cause. A data item with the GLOBAL attribute is in a user library. 446 (Error) COLLATING SEQUENCE clause not allowed in library Cause.
Compiler Diagnostic Messages Message List 461 (Error) Internal SQL error Cause. The compiler’s internal consistency checker discovered a logic error. Please report this failure to your service provider. 462 (Error) Improper usage clause for host variable Cause. An SQL/MP or SQL/MX host variable has an improper USAGE clause. 463 (Error) Host variable picture string cannot contain 'P' Cause. An SQL/MP or SQL/MX host variable’s PICTURE string contains P.
Compiler Diagnostic Messages Message List 468 (Error) The RENAMES is ignored Cause. An SQL/MP or SQL/MX host variable contains a RENAMES clause. 470 (Error) Missing END-EXEC Cause. The compiler processed the maximum number of SQL/MP or SQL/MX statement lines without encountering the SQL/MP or SQL/MX statement terminator END-EXEC. 471 (Error) Ambiguous reference to SQLCA Cause. More than one SQLCA is declared in the program, and the SQLCA in this statement is ambiguous in this context.
Compiler Diagnostic Messages Message List 475 (Error) Ambiguous reference to SQLCODE Cause. More than one SQLCODE is declared in the program, and the SQLCODE in this statement is ambiguous in this context. 476 (Error) SQLCODE is declared incorrectly Cause. SQLCODE is declared incorrectly (it must be a COMPUTATIONAL data item with no editing characters). 477 (Error) Program is missing SQLCODE Cause. SQLCODE is required in the program, but is missing. 478 (Error) Ambiguous reference to SQLSA Cause.
Compiler Diagnostic Messages Message List 481 (Error) Improper context for CHARACTER SET clause Cause. A CHARACTER-SET clause appears somewhere other than the final clause in an OBJECT-COMPUTER paragraph. 482 (Error) Expecting elementary data item Cause. A data structure appears where an elementary data item is expected. 490 (Error) Improper context for ALL subscript Cause.
Compiler Diagnostic Messages Message List 495 (Error) Expression is too complex Cause. An expression is so complex that the compiler cannot process it. 496 (Error) Improper argument Cause. The argument has at least one wrong characteristic (such as type, class, category, or length). 497 (Error) Too many arguments Cause. More arguments have been supplied to the function than the function takes. 498 (Error) Argument not within expected range Cause.
Compiler Diagnostic Messages Message List 503 (Error) Expected alphabetic data item Cause. A nonalphabetic argument was supplied where an alphabetic argument is required. 504 (Error) Reference modifier permitted only for alphanumeric functions Cause. A reference modifier was applied to a function whose return type is not alphanumeric. 510 (Error) EXIT PERFORM [CYCLE] must be within an in-line perform Cause.
Compiler Diagnostic Messages Message List 514 (Error) An EXIT SECTION must be contained in a section Cause. An EXIT SECTION statement is not inside a section. (You must be within a section to exit from one.) 515 (Error) Expected YYYYMMDD after DATE or YYYYDDD after DAY Cause. In the ACCEPT statement, either DATE appears followed by something other than YYYYMMDD or DAY appears followed by something other than YYYYDDD. 520 (Error) Possible odd byte address for parameter Cause.
Compiler Diagnostic Messages Message List 525 (Error) This directive is not permitted in the OSS environment Cause. The program was compiled in the OSS environment with one of these compiler directives: • • • • ENV NONSTOP SAVE SUBTYPE 526 (Error) This phrase is not permitted for LINE SEQUENTIAL files Cause.
Compiler Diagnostic Messages Message List 527 (Error) LINE SEQUENTIAL files may not be opened in I-O mode Cause. The program contains a statement of the form OPEN I-O i-o-file-description where i-o-file-description is a LINE SEQUENTIAL file. 600 (Warning) Defunct directive ignored Cause. The compiler ignores this directive. 601 (Warning) Feature not yet available -- directive ignored Cause. The compiler ignores this directive. 602 (Error) No symbols for external name Cause.
Compiler Diagnostic Messages Message List 604 (Error) Error reading object file Cause. One of: • • A CALL or ENTER statement calls a program, specifying the object file that contains the program, but that object file cannot be read. A CALL or ENTER statement calls a program without specifying the object file that contains it, and one of the object files on the search list(s) cannot be read. 605 (Error) The NO prefix is not allowed on this directive Cause.
Compiler Diagnostic Messages Message List 610 (Error) Pointer data item not permitted Cause. A data item described as USAGE POINTER is specified where it is not allowed. 611 (Error) Expected index or pointer data item Cause. A statement (for example, SET) expects either an index data item or a pointer data item as a sending or receiving operand. 612 (Error) Expected pointer data item Cause. A statement expects a pointer data item as a sending or receiving operand.
Compiler Diagnostic Messages Other Products’ Error Messages Other Products’ Error Messages Products that are merged with the compiler sometimes cause compile-time error messages when you run the compiled program. Examples of such products are: • • ECOBOL Compiler Back End SCI, the SQL/MP compiler interface ECOBOL Compiler Back End Example 47-2. ECOBOL Compiler Back End Run-Time Error Message *** Failure: --> Compiler logic error 0_46204 [Failure 0] Cause.
Compiler Diagnostic Messages HP COBOL Manual for TNS/E Programs —520347-003 47 -96 SCI
48 Run-Time Diagnostic Messages This section explains the run-time diagnostic messages that can be reported if an HP COBOL process encounters an error condition.
Run-Time Diagnostic Messages Standard Message Format Standard Message Format The standard format of a run-time diagnostic message is: pn pn [ pn pn [ pn [ pn - *** Run-time Error nnn *** message File COBOL-file-name = assigned-file-name, open-status ] From prog-id + %pppppp, UC.00 prog-id + %pppppp ] ... additional-message ] ... [ ] surrounds optional material. pn is the process name or process ID of the process that caused the error report. nnn is the message number from the CRE.
Run-Time Diagnostic Messages Input-Output Error Messages Input-Output Error Messages An input-output error message refers to a COBOL file or to a device specified in an ACCEPT or DISPLAY statement. An input-output error message has additional messages that report: • • A Guardian error number A line identifying the file that caused the error Example 48-1. Input-Output Error Message \DRP12.$:0:622:163577460 \DRP12.$:0:622:163577460 \DRP12.$:0:622:163577460 \DRP12.$:0:622:163577460 \DRP12.
Run-Time Diagnostic Messages Abend The three most common causes of Guardian abnormal termination messages are: • • • Abend (abnormal termination) Arithmetic Overflow Stack Overflow These topics explain abnormal termination messages and describe what to do if they occur. Abend Abend is short for “abnormal end.” It follows any fatal error message that the run-time routines generate.
Run-Time Diagnostic Messages • Stack Overflow With the Debugger If the PARAM INSPECT ON command is active, the process stops and enters the selected debugger . You can use the debugger to find the problem. If the selected debugger is symbolic, using it is easier if you compiled the program with the SYMBOLS directive. If you did not, you might have to recompile the program with SYMBOLS to find the problem with the debugger.
Run-Time Diagnostic Messages Message List Message List The run-time diagnostic messages associated with COBOL85, in numeric order by CRE message number, are: 1 Unknown trap Cause. The CRE trap processing function was called with an unknown trap number. Effect. The run unit terminates abnormally. Recovery. Check the program’s logic. Use the selected debugger to help isolate the problem or consult your system administrator. 2 Illegal address reference Cause.
Run-Time Diagnostic Messages Message List 4 Arithmetic fault Cause. An arithmetic overflow occurred for one of these reasons: • • The result of a signed arithmetic operation could not be represented with the number of bits available for the particular data type. A division operation was attempted with a zero divisor. In most cases, a receiving item in an arithmetic statement is too small. Effect. The run unit terminates abnormally. Recovery.
Run-Time Diagnostic Messages Message List 7 Memory manager read error Cause. An unrecoverable, read error occurred while the program was trying to bring in a page from virtual memory. Effect. The run unit terminates abnormally. Recovery. Report this error to your service provider. 8 Not enough physical memory Cause. This fault occurs for one of these reasons: • A page fault occurred, but there were no physical memory pages available for overlay.
Run-Time Diagnostic Messages Message List 12 Logic error Cause. The CRE or run-time library detected a logic error within its own domain. For example, although each data item it is using is valid, the values of the data items are mutually inconsistent. Effect. The CRE calls PROCESS_STOP_, specifying the ABEND variant and the text “Logic error.” Recovery. To correct the problem, initialize uninitialized pointers. 13 MCB pointer corrupt Cause.
Run-Time Diagnostic Messages Message List Effect. The CRE calls PROCESS_STOP_, specifying the ABEND variant and the text “Premature takeover.” Recovery. If the takeover occurred because of faulty program logic, correct the program’s logic. If the takeover occurred for other reasons, such as a hardware failure, you might want to rerun the program, provided that doing so will not duplicate operations already performed, such as updating a database a second time. 15 Checkpoint list inconsistent Cause.
Run-Time Diagnostic Messages Message List 20 Cannot utilize file name Cause. A string, expected to be a valid file name, could not be interpreted as a Guardian external file name. Effect. The run unit terminates abnormally. Recovery. Check that the file names in the program are valid Guardian file names. 21 Cannot read initialization messages ( error ) Cause.
Run-Time Diagnostic Messages Message List 24 Conflict in application of ASSIGN program_name.logical_name Cause. ASSIGN values in your TACL environment conflict with each other. For example: ASSIGN A, $B1.C.D ASSIGN *.A, $B2.C.D The first ASSIGN specifies that the logical name A can appear in no more than one loadfile. The second assign specifies that the name A can appear in an arbitrary number of loadfiles. The CRE cannot determine whether to use the file C.D on volume $B1 or on volume $B2. Effect.
Run-Time Diagnostic Messages Message List Recovery. Modify the PARAM text and rerun your program. For more information on using PARAMs, see PARAM Command and the TACL Reference Manual. 27 Ambiguity in application of PARAM PARAM name 'value' Cause. A PARAM specifies a value that is ambiguous in the current context. For example, the PARAM specification: PARAM PRINTER-CONTROL A is ambiguous if the program contains more than one logical file named A. Effect. The run unit terminates abnormally. Recovery.
Run-Time Diagnostic Messages Message List Recovery. Correct the parameter you are passing. 41 Range fault Cause. An arithmetic overflow or underflow occurred while evaluating an arithmetic function. Effect. Program behavior is language and application dependent. An HP COBOL program cannot cause this error, so the problem must be in a non-COBOL program in the same run unit. Recovery. Modify the program to pass values to the arithmetic functions that do not cause overflow. 42 Arccos domain fault Cause.
Run-Time Diagnostic Messages Message List 46 Logarithm function domain fault Cause. The parameter passed to a logarithm function (LOG or LOG10) was less than or equal to zero. The parameter to a logarithm function must be greater than zero. Effect. Program behavior is language and application dependent. Recovery. Modify the program to pass a valid value to the logarithm function. 47 Modulo function domain fault Cause. The value of the second parameter to the MOD function was zero.
Run-Time Diagnostic Messages Message List 55 Missing or invalid parameter Cause. A required parameter is missing or too many parameters were passed. Effect. Program behavior depends on the function that was called. Recovery. Correct the program to pass a valid parameter. 56 Invalid parameter value Cause. The value passed as a procedure parameter was invalid. Effect. Program behavior depends on the function that was called. Recovery. Correct the program to pass a valid parameter value.
Run-Time Diagnostic Messages Message List Recovery. If the error was caused by a read request from your program, correct your program. You might need to verify that your program handles conditions that are beyond your control, such as losing a path to the device. Also refer to error handling in this manual and in the language manual for the routine in your program that detected the error. If the error was caused by a read request from the CRE, consult your system administrator.
Run-Time Diagnostic Messages Message List Recovery. Consult your system administrator. 63 Undefined shared file Cause. A parameter was not the number of a shared file where one was expected. Effect. Program behavior is language and application dependent. An HP COBOL program terminates abnormally. Recovery. Consult your system administrator. 64 File not open Cause. A request to open a file failed because the file device is not supported. Effect. Program behavior is language and application dependent.
Run-Time Diagnostic Messages Message List 67 Access mode not accepted Cause. The value of access to an open operation was not valid in the context in which it was used. For example, it is invalid to open a spool file for input. Effect. Program behavior is language and application dependent. An HP COBOL program terminates abnormally. Recovery. Consult your system administrator. 68 Nowait value not accepted Cause. The value of no_wait to an open operation was not valid in the context in which it was used.
Run-Time Diagnostic Messages Message List 71 Inconsistent attribute value Cause. A routine requested a connection to a shared file that was already open, and the attributes of the new open request conflict with the attributes specified when the file was first opened. Effect. Program behavior is language and application dependent. An HP COBOL program terminates abnormally. Recovery. If your program supplied the attribute values, correct and rerun your program; otherwise, consult your system administrator.
Run-Time Diagnostic Messages Message List 77 EDITREADINIT failed ( error ) Cause. A call to EDITREADINIT failed. In CRE message 77, error, if present, gives the reason for the failure. Possible values of error are: Error Code Error Name -1 End-of-file marker encountered -2 I-O error -3 Text file format error -6 Invalid buffer address Effect. The OPEN statement is unsuccessful with I-O status code “91.” Recovery. If the code is -2, there was an input-output error; try the statement again.
Run-Time Diagnostic Messages Message List 79 OpenEdit failed ( error ) Cause. The call to OpenEdit made during the OPEN processing for an EDIT file failed with Guardian error or nnn. A negative number is a format error. A positive number is a Guardian file system error. Effect. The OPEN statement is unsuccessful with I-O status code “30”. Recovery. Use the command interpreter ERROR command to discover the meaning of the Guardian error number. The message might suggest a corrective action.
Run-Time Diagnostic Messages Message List Recovery. Consult your system administrator. 83 Operation incompatible with file type or status (GE) Cause. One of: 1. COBOL_CONTROL_ or COBOL_SETMODE_ was called, and one of these was true: a. The associated file was assigned to $RECEIVE. b. HP COBOL Fast I-O was selected for the associated file. c. The CONTROL or SETMODE call was rejected by the file system (“(GE)” shows the error code). 2.
Run-Time Diagnostic Messages Message List 125 OCCURS DEPENDING ON data item out of range Cause. The data item referenced in an OCCURS DEPENDING clause is either less than the minimum or greater than the maximum number of occurrences. Effect. The run unit terminates abnormally. Recovery. Either change the maximum or minimum number of occurrences in the OCCURS clause or correct the program so that the DEPENDING data item has a legal value. 127 CALL references an active program Cause.
Run-Time Diagnostic Messages Message List 130 Improper context for RETURN statement Cause. A RETURN statement was executed when a SORT or MERGE output procedure was not executing. Effect. The run unit is terminated abnormally. Recovery. Correct the program. 132 SORT or MERGE statement executed while SORT or MERGE active Cause. A SORT or MERGE statement was executed while a SORT or MERGE input or output procedure was being executed. Effect. The run unit terminates abnormally. Recovery.
Run-Time Diagnostic Messages Message List 135 ACCEPT or DISPLAY requested for an unsupported device Cause. The device associated with the mnemonic-name specified in an ACCEPT statement is not a process or a terminal; or the device associated with the mnemonicname specified in a DISPLAY statement is not a process, terminal, operator console, printer, or existing disk file. Effect. The home terminal or the device specified as the EXECUTION-LOG is used instead.
Run-Time Diagnostic Messages Message List 138 CANCEL references an active program Cause. The program referenced in a CANCEL statement has been called but has not executed an EXIT PROGRAM (it is still active). Effect. The run unit terminates abnormally. Recovery. Correct the program. Reduce the number of files that are open simultaneously. 139 Cancelled program not found Cause. The program referenced in a CANCEL statement with identifier specified could not be located.
Run-Time Diagnostic Messages Message List 142 RELEASE operation failed - SORTMERGE message follows Cause. During the execution of a RELEASE statement in a SORT input procedure, the FastSort utility returned an error. The message from FastSort follows on the next line. Effect. The run unit terminates abnormally. Recovery. Action depends on the message FastSort returns. See the FastSort Manual for the meaning of these messages. 143 RETURN operation failed - SORTMERGE message follows Cause.
Run-Time Diagnostic Messages Message List 145 SORT or MERGE operation failed at start - SORTMERGE message follows Cause. At the start of the execution of a SORT or MERGE operation, the FastSort utility returned an error. The second line of the message is the text of the SORT error message returned by the FASTSORT procedure SORTERRORSUM. The third line is Sort error code = mm - System error code = nn where mm is the SORT error code defined in the FastSort Manual, and.
Run-Time Diagnostic Messages Message List Recovery. Correct the USING list in either the CALL statement or Procedure Division. 148 PERFORM nesting too deep Cause. The PERFORM stack overflowed. The maximum nesting depth is 50. Effect. The run unit terminates abnormally. Recovery. Check PERFORM statements for proper termination or reduce the complexity of the program. It might be helpful to recompile the program with the directive PERFORM-TRACE. 150 Alternate key not present in file Cause.
Run-Time Diagnostic Messages Message List 152 OPEN on a non-disk file that is specified with alternate keys Cause. The physical file assigned by the OPEN statement is not a structured disk file, but the COBOL program described it with alternate keys. Alternate keys are allowed only on structured disk files. Effect. The OPEN statement is unsuccessful with I-O status code “39.” Recovery. Either correct the program or assign the proper file. 153 Create of new file failed with error nnn Cause.
Run-Time Diagnostic Messages Message List 156 DELETE repositioning failed with error nnn Cause. The file positioning request issued after deleting a record during the processing of a DELETE statement was rejected with Guardian error nnn. Effect. The DELETE statement is unsuccessful with I-O status code “30”. Recovery. Type ERROR nnn to see the meaning of the Guardian error; it might indicate corrective action. 157 Wrong open mode for DELETE Cause.
Run-Time Diagnostic Messages Message List 160 OPEN on an EDIT file described with a record size that is too big Cause. The maximum record size for an EDIT file is 4095 bytes. Effect. The OPEN statement is unsuccessful with I-O status code “39.” Recovery. Correct the program, or assign other than an EDIT file. 161 OPEN EXTEND positioning failed with error nnn Cause. The attempt to position the file at the end during the processing of an OPEN … EXTEND statement failed with Guardian error nnn. Effect.
Run-Time Diagnostic Messages Message List 164 OPEN rewind failed with error nnn Cause. The attempt to rewind the file during the processing of an OPEN statement failed with Guardian error nnn. Effect. The OPEN statement is unsuccessful with I-O status code “30.” Recovery. Type ERROR nnn to see the meaning of the Guardian error; it might indicate corrective action. 165 OPEN requested for an unsupported device Cause. The device assigned to the COBOL file is not a legal device for COBOL input or output.
Run-Time Diagnostic Messages Message List 168 LINAGE file not on printer or process Cause. The file referenced in an OPEN statement for a file with LINAGE specified is not assigned to a printer or a process (a spooler, for example). Effect. The OPEN statement is unsuccessful with I-O status code “39.” Recovery. Either assign the correct device or remove the LINAGE clause from the file description (FD). 169 LOCK or UNLOCK operation failed with error nnn Cause.
Run-Time Diagnostic Messages Message List 172 OPEN on a nonexistent file and alternate keys specified Cause. A file with alternate keys specified does not exist when the attempt is made to open it. The file must have been created with a FUP CREATE or other means before it can be opened. Effect. The OPEN statement is unsuccessful with I-O status code “30.” Recovery. Create the file correctly before running the program, assign the correct file, or remove the alternate key specifications.
Run-Time Diagnostic Messages Message List 176 File is not opened for timed I/O Cause. A TIME LIMIT operation (such READ … TIME LIMIT nn ) was attempted on a file that was not opened with TIME LIMITS specified. Effect. The operation is unsuccessful with I-O status code “90.” Recovery. Correct the program to do an OPEN … TIME LIMITS. 177 OPEN OUTPUT for file not on output device Cause.
Run-Time Diagnostic Messages Message List 180 Non-disk or unstructured file and not sequential organization Cause. The COBOL program describes the file as ORGANIZATION RELATIVE or INDEXED, but the assigned file is not a structured disk file. Only structured disk files can be assigned to RELATIVE or INDEXED COBOL files. Effect. The OPEN statement is unsuccessful with I-O status code “39.” Recovery. Assign the correct file or correct the file description in the program.
Run-Time Diagnostic Messages Message List 184 Purge of file during OPEN failed with error nnn Cause. During the execution of an OPEN statement, the attempt to purge a file (the purge is due to some attribute conflicts) failed with Guardian error nnn. Effect. The OPEN statement is unsuccessful with I-O status code “30”. Recovery. Type ERROR nnn to see the meaning of the Guardian error; it might indicate corrective action.
Run-Time Diagnostic Messages Message List Effect. The READ statement is unsuccessful with I-O status code “91.” Recovery. For a Guardian file, either remove the LOCK or open the file for I-O. For an OSS file, remove the LOCK. 188 READ positioning failed with error nnn Cause. An attempt to position the file for a READ statement failed with Guardian error nnn. Effect. The READ statement is unsuccessful with I-O status code “30.” Recovery.
Run-Time Diagnostic Messages Message List Recovery. Correct the cause of the problem. 192 Sequential REWRITE must follow successful READ Cause. The program attempted to execute a REWRITE statement to a file for which ACCESS MODE SEQUENTIAL is specified, and the last operation on the file was not a successful READ statement (for example, an at-end condition resulted). Effect. The REWRITE statement is unsuccessful with I-O status code “43.” Recovery. Correct the program.
Run-Time Diagnostic Messages Message List 196 Sequential REWRITE permitted only with same record size Cause. At attempt to REWRITE a record on a file with sequential organization failed because the new record is not the same size as the old one. Effect. The REWRITE statement is unsuccessful with I-O status code “44.” Recovery. Correct the program. 197 REWRITE operation failed with error nnn Cause. The attempt to rewrite the record during execution of a REWRITE statement failed with Guardian error nnn.
Run-Time Diagnostic Messages Message List 200 Wrong open mode for START Cause. The file referenced in a START statement is not open for INPUT or I-O. Effect. The START statement is unsuccessful with I-O status code “47.” Recovery. Correct the program. 201 System node not available or does not exist Cause.
Run-Time Diagnostic Messages Message List 204 Writing end of file failed with error nnn Cause. The attempt to write an end of file on a tape during the execution of a CLOSE statement failed with Guardian error nnn. Effect. The CLOSE statement is unsuccessful with I-O status code “30.” Recovery. Type ERROR nnn to see the meaning of the Guardian error; it might indicate corrective action. 205 Writing end of reel failed with error nnn Cause.
Run-Time Diagnostic Messages Message List Recovery. Correct the program if it is in a loop, or increase the number of extents allocated for the file. You can use a FUP CREATE command for this purpose. 208 WRITE positioning failed with error nnn Cause. The attempt to position the file during the execution of a random WRITE statement failed with Guardian error nnn. Effect. The statement is unsuccessful with I-O status code “30.” Recovery.
Run-Time Diagnostic Messages Message List A WRITE statement was attempted on a sequential file that does not meet any of these criteria: 1. Its open mode is EXTEND or OUTPUT. 2. Its open mode is I-O and the device assigned is a process, a terminal or $RECEIVE. Effect. The statement is unsuccessful with I-O status code “48” except for Item 2 for sequential, in which the I-O status code is “90.” Recovery. Correct the program or assign the correct device.
Run-Time Diagnostic Messages Message List 215 Wrong or missing LABELS attribute Cause. A LABELS attribute in a DEFINE command that refers to the file contains other than OMITTED, BYPASS, ANSI, or IBM. Effect. The OPEN statement is unsuccessful with I-O status code “90.” Recovery. Before running this program again, verify that the DEFINE in the environment is correct. 216 Wrong or missing USE attribute Cause.
Run-Time Diagnostic Messages Message List Recovery. Before running this program again, verify that the DEFINE in the environment is correct or correct the file’s record description. 219 Wrong or missing BLOCKLEN attribute Cause.
Run-Time Diagnostic Messages Message List Recovery. You can use the command interpreter ERROR command to discover the meaning of the Guardian error number. The message might suggest a corrective action. 223 DEFINE required for LABEL RECORDS STANDARD Cause. A DEFINE command is required if LABEL RECORDS STANDARD is specified in the File Definition. Effect. The OPEN statement is unsuccessful with I-O status code “90.” Recovery.
Run-Time Diagnostic Messages Message List 226 File attributes don't match and file not opened OUTPUT or has alt keys Cause. The file attributes of the existing file conflict with the file description in the program and the file is not being opened for output, or (if it is being opened for output) the file description specifies alternate record keys (COBOL cannot create a file with alternate keys).
Run-Time Diagnostic Messages Message List Recovery. If you can resolve the Guardian error, do so; otherwise report the error to your service provider. 230 Loadwrite failed with internal error mmm, GUARDIAN error nnn Cause. The HP COBOL Fast I-O routine loadwrite returned the indicated error codes. Effect. The WRITE statement is unsuccessful with I-O status code “30.” Recovery. If you can resolve the Guardian error, do so; otherwise report the error to your service provider.
Run-Time Diagnostic Messages • Message List The specifications in the OPEN statement, or the attributes derived during the open operation by some other means (such as from an applicable command interpreter ASSIGN command), conform to: ° ° ° The open mode is INPUT or OUTPUT. The exclusion mode is EXCLUSIVE if OPEN OUTPUT is specified. The exclusion mode is PROTECTED if OPEN INPUT is specified. 233 OPEN OUTPUT SHARED specified for open disk file Cause.
Run-Time Diagnostic Messages Message List 234 CLOSE operation failed with error nnn Cause. The Guardian file system reported error nnn during execution of a close operation. Effect. The CLOSE statement is unsuccessful with I-O status “30.” Recovery. Type ERROR nnn to see the meaning of the Guardian error; it may indicate corrective action. 235 REVERSED not allowed for this file Cause.
Run-Time Diagnostic Messages HP COBOL Manual for TNS/E Programs —520347-003 48 -54 Message List
Part V.
Part V.
A ASCII Character Set This appendix contains two tables of the ASCII character set, both of which use these column headings: Column Heading Meaning Ord. Character’s ordinal number in the ASCII character set Octal Character’s octal representation (with left and right bytes) Hex. Character’s hexadecimal representation Dec.
ASCII Character Set ASCII Character Set in Numeric Order Table A-1. ASCII Character Set in Numeric Order (page 2 of 5) Octal Ord. Left Right Hex. Dec. Char.
ASCII Character Set ASCII Character Set in Numeric Order Table A-1. ASCII Character Set in Numeric Order (page 3 of 5) Octal Ord. Left Right Hex. Dec. Char. Meaning 44 025400 000053 2B 43 + Plus 45 026000 000054 2C 44 , Comma 46 026400 000055 2D 45 - Hyphen (minus) 47 027000 000056 2E 46 .
ASCII Character Set ASCII Character Set in Numeric Order Table A-1. ASCII Character Set in Numeric Order (page 4 of 5) Octal Ord. Left Right Hex. Dec. Char.
ASCII Character Set ASCII Character Set in Numeric Order Table A-1. ASCII Character Set in Numeric Order (page 5 of 5) Octal Ord. Left Right Hex. Dec. Char.
ASCII Character Set ASCII Character Set in Alphabetic Order ASCII Character Set in Alphabetic Order Table A-2 presents the ASCII character set in alphabetic order—that is, alphabetic character codes (in the column labelled “Char.”) are in alphabetic order. Table A-2. ASCII Character Set in Alphabetic Order (page 1 of 4) Octal Char. Meaning Ord. Left Right Hex. Dec.
ASCII Character Set ASCII Character Set in Alphabetic Order Table A-2. ASCII Character Set in Alphabetic Order (page 2 of 4) Octal Char. Meaning Ord. Left Right Hex. Dec.
ASCII Character Set ASCII Character Set in Alphabetic Order Table A-2. ASCII Character Set in Alphabetic Order (page 3 of 4) Octal Char. Meaning Ord. Left Right Hex. Dec.
ASCII Character Set ASCII Character Set in Alphabetic Order Table A-2. ASCII Character Set in Alphabetic Order (page 4 of 4) Octal Char. Meaning Ord. Left Right Hex. Dec.
ASCII Character Set ASCII Character Set in Alphabetic Order HP COBOL Manual for TNS/E Programs —520347-003 A -10
B Data Type Correspondence These tables contain the return value size generated by HP language compilers for each data type. Use this information when you need to specify values with the Accelerator ReturnValSize option. These tables are also useful if your programs use data from files created by programs in another language, or your programs pass parameters to programs written in callable languages. Refer to the appropriate SQL/MP or SQL/MX manual for a complete list of SQL data type correspondence.
Data Type Correspondence Table B-1.
Data Type Correspondence Table B-2.
Data Type Correspondence Table B-3.
Data Type Correspondence Table B-4. Character Types Varying Length Character String Character Character String HP C and HP C++ signed char unsigned char pointer to char struct { int len; char val [n] }; COBOL Alphabetic Numeric DISPLAY Alphanumeric-Edited Alphanumeric Numeric-Edited Alphabetic Numeric DISPLAY Alphanumeric-Edited Alphanumeric Numeric-Edited 01 name. 03 len USAGE IS NATIVE-21 03 val PIC X(n).
Data Type Correspondence Table B-5.
Data Type Correspondence Table B-6.
Data Type Correspondence Table B-7.
Glossary 16-bit addressing. Referencing a data item or parameter by using a 16-bit address (also called standard addressing). Compare to 32-bit addressing. 32-bit addressing. Referencing a data item or parameter by using a 32-bit address (also called extended addressing). Compare to 16-bit addressing. abbreviated combined relation condition.
Glossary alternate record key alternate record key. A data item, other than the prime record key, whose value identifies a record in a structured file. API. See application program interface (API). application program interface (API). A set of services (such as programming language functions or procedures) that are called by an application program to communicate with other software components.
Glossary at-end condition at-end condition. A condition that occurs at these times: • • • During the execution of a READ statement for a sequential file, when no more records exist During the execution of a RETURN statement, when no next logical record exists for the associated sort file or merge file During the execution of a SEARCH statement, when the search ends without satisfying a condition specified in any of the associated WHEN phrases BIND.
Glossary class condition class condition. The proposition that a data item’s contents are all alphabetic or all numeric. A process can determine whether a class condition is true or false. clause. An ordered set of consecutive COBOL character-strings that specifies an attribute of an entry. client. A software process, hardware device, or combination of the two that requests services from a server.
Glossary comma separator comma separator. A comma (,) followed by one or more spaces. command interpreter. The operating system’s primary user interface to an HP computer system, through which you can use system utilities and run programs. comment. A line in a source program that begins with an asterisk (*) or a slash (/) in the indicator area and contains any combination of ASCII characters in area A and area B. comment-entry.
Glossary condition condition. A proposition about the values of variables and literals of a program for which an executing program can determine a truth value. condition-name. One of these: • • A user-defined word assigned to a specific value, set of values, or range of values within the complete set of values that a conditional variable can have A user-defined word assigned to the status of a switch condition-name condition.
Glossary CRE library CRE library. See Common Run-Time Environment (CRE) library. CRE program. A program that runs in the Common Run-Time Environment (CRE). If a CRE program was compiled by the COBOL85 compiler, the directive ENV COMMON or ENV LIBRARY was specified. Compare to non-CRE program. CROSSREF utility program. The HP software product that produces cross-reference listings of source programs. It can be used directly or initiated by a compiler directive. currency sign. The character $.
Glossary deadlock deadlock. One of these situations: • • • Two processes cannot proceed because each is waiting for a reply from the other. Two transactions cannot proceed because each is waiting for the other to release a lock. A block to data access caused by processes contending for the same data. If two servers are deadlocked, their respective requesters are also deadlocked because neither requester receives a reply from its server. debugging line.
Glossary DLL DLL. See dynamic-link library (DLL). dynamic access. An access mode in which the process can read specific logical records from a disk file sequentially or nonsequentially and write such records to the file nonsequentially while the same OPEN statement is active for that file. Compare to sequential access and random access. dynamic file. A file whose COBOL file name is associated with its system file name at run time. dynamic-link library (DLL).
Glossary Enscribe Enscribe. The HP database record manager; provides access to and manipulation of records in disk files. EPIC. See explicitly parallel instruction set computing (EPIC). executable object file. See loadfile. execution time. Denotes events that occur at the time a process executes an object program (also called object time or run time). Expand. The HP data communication network, an extension of the operating system. explicit scope terminator.
Glossary external reference external reference. The call to a routine that is not present in the source file that a compiler is translating. external switch. A software device, defined and named by HP, that is used to indicate that one of two alternate states exists. Fast I-O. See HP COBOL Fast I-O. fault-tolerant facility. The software provided by HP and used by a process to cause the process to execute as a fault-tolerant process pair. figurative constant.
Glossary file position indicator file position indicator.
Glossary global name global name. A name that is declared in only one program but that can be referenced from that program and from any program directly or indirectly contained within that program. These names can be global names: condition-names, data-names, file-names, recordnames, and some special registers. Compare to local name. Guardian. An environment available for interactive or programmatic use with the HP NonStop™ operating system.
Glossary HP Transaction Application Language (TAL) HP Transaction Application Language (TAL). A systems programming language with many features specific to stack-oriented TNS systems. identifier. A data name followed, as required, by the combination of qualifiers, subscripts, and indexes necessary to make a unique reference to a data item. imperative statement.
Glossary Input-Output Section Input-Output Section. A section of the Environment Division that names the files and the external media required by an object program and that provides information a process needs for transmitting and handling data when it executes the object program. input-output statement. A statement that causes files to be processed by performing operations upon individual records or upon the file as a unit.
Glossary I-O mode I-O mode. The state of a file after a process executes an OPEN statement including an I-O phrase for the file and before the process executes a CLOSE statement (without the REEL or UNIT phrase for the file), allowing the process to read records from the file and write records to the file. I-O status. A conceptual entity that contains the two-character value indicating the resulting status of an input-output operation.
Glossary library-name library-name. A user-defined word that names a COPY library file for the compiler to copy text from during a compilation. LINAGE-COUNTER. A special register that the compiler generates for each file description that has a LINAGE clause. At any given time, a LINAGE-COUNTER contains the value of the current line number within the current page body. line sequential file.
Glossary main program main program. The first program to execute when a run unit is run. The main program determines the run-time environment for a program. man page. See reference page. map. A tabular representation of the elements of a program. merge file. A collection of records for a process to merge during execution of a MERGE statement; a file declared in the sort-merge file description entry, and created and used only by the merge function. migrate.
Glossary NATIVE-n data format NATIVE-n data format. NATIVE-2, NATIVE-4, and NATIVE-8 data formats, collectively. negated combined condition. A combined condition, within parentheses, immediately preceded by the NOT logical operator. negated simple condition. A simple condition immediately preceded by the NOT logical operator. next executable sentence. The next sentence to which the process is to transfer control after it finishes executing the current statement. next executable statement.
Glossary nonnumeric literal nonnumeric literal. A character-string, delimited by quotation marks, that can include any ASCII character (with any quotation mark within the character-string represented by two contiguous quotation marks). non-PIC. See position-dependent code (non-PIC). nonshared code. See position-dependent code (non-PIC). NonStop operating system. See HP NonStop™ operating system. NonStop Series architecture. See TNS architecture. NonStop Series/Itanium architecture. See TNS/E architecture.
Glossary object program object program. A set or group of executable machine language instructions and other material designed to interact with data to provide problem solutions; the machine language result of the operation of a COBOL compiler on a source program. open mode.
Glossary output procedure output procedure.
Glossary parameter parameter. A name specified in a prepared command for which the user substitutes a value when executing the command. pathname. In the Open System Services (OSS) file system and Network File System (NFS), the string of characters that uniquely identifies a file within its file system. A pathname can be either relative or absolute. See also ISO/IEC IS 9945-1:1990 (ANSI/IEEE Std. 1003.1-1990 or POSIX.1), Clause 2.2.2.57. Pathway/TS.
Glossary procedure procedure. One of these: • A paragraph, a group of logically successive paragraphs, a section, or a group of logically successive sections in the Procedure Division Such a procedure functions as a unit of code to be executed by a PERFORM, SORT, MERGE, or USE statement.
Glossary PS Text EDIT PS Text EDIT. An HP text-editing program, often abbreviated TEDIT. pseudo-text. A sequence of text-words, comments, and separators, preceded and followed by the pseudo-text pseudo-text delimiter (==). pseudo-text delimiter. Two contiguous equal signs (==) that identify the beginning or end of a pseudo-text, but are not part of the pseudo-text. punctuation character.
Glossary record area record area. A storage area the process allocates for processing a record described by a record description entry in the File Section. record description entry. The total set of data description entries associated with a particular record. record key. A data item whose value identifies a record in a structured file. See prime record key, relative key, and alternate record key. record-name.
Glossary relative record number relative record number. The ordinal number of a record in a relative file. This number is handled as a integer numeric literal. release version update (RVU). A collection of compatible revisions of NonStop operating system software products, identified by an RVU ID, and shipped and supported as a unit. An RVU consists of the object modules, supporting files, and documentation for the product revisions. An RVU also includes a set of documentation for the overall RVU.
Glossary SCREEN COBOL SCREEN COBOL. A procedural language developed by HP and based on COBOL that is used to define and control screen displays on terminals and other input-output devices. SCREEN COBOL allows programmers to write requester programs that communicate with operator terminals and intelligent input-output devices and that send data to server processes that manage application databases.
Glossary sequential block buffering sequential block buffering. An Enscribe feature, enabled by the RESERVE clause of the FILE-CONTROL paragraph, that speeds the reading of a sequential, relative, indexed, or queue file by reading a block of records together into a memory buffer. sequential file. A file that has sequential organization (includes entry-sequenced and unstructured files). sequential organization.
Glossary simple condition simple condition. Any single condition that is either: • • • • • • Relation condition class condition condition-name condition switch-status condition sign condition Simple condition enclosed in parentheses single-language program. A program in which all routines are written in the same programming language. sort file.
Glossary special character special character. One of: Character Meaning Character Meaning + Plus sign ; Semicolon - Minus sign . Period (decimal point) * Asterisk " Quotation mark / Slash (slant, virgule) ( Left parenthesis = Equal sign ) Right parenthesis $ Currency sign > Greater than symbol , Comma (decimal point) < Less than symbol special-character word. A reserved word that is an arithmetic operator or a relation character. SPECIAL-NAMES.
Glossary subprogram subprogram. See called program. subscript. An occurrence number represented by either an integer, a data-name optionally followed by an integer with the operator + or -, or an index-name optionally followed by an integer with the operator + or -, that identifies a particular table element. subvolume. A logical subdivision of a volume, used to group files on the volume. switch-status condition.
Glossary text-name text-name. A user-defined word that identifies library text. text-word. A character or a sequence of contiguous characters between margin A and margin R in a COBOL library, source program, or in pseudo-text which is: • • • • A separator, except for: a space, a pseudo-text delimiter, and the opening and closing delimiters for nonnumeric literals.
Glossary TNS interpreted mode TNS interpreted mode. A TNS emulation environment on a TNS/R or TNS/E system in which individual TNS instructions in a TNS object file are directly executed by interpretation rather than permanently translated into MIPS or Intel® Itanium® instructions. TNS interpreted mode runs slower than TNS accelerated mode. Each TNS instruction is decoded each time it is executed, and no optimizations between TNS instructions are possible.
Glossary TNS/E native compiler TNS/E native compiler. A compiler in the TNS/E development environment that generates TNS/E native object code, following the TNS/E native-mode conventions for memory, stack, registers, and call linkage. The ECOBOL compiler is an example of such a compiler. Contrast with TNS compiler and TNS/R native compiler. TNS/E native mode.
Glossary TNS/R native object code TNS/R native object code. The MIPS RISC instructions that result from processing program source code with a TNS/R native compiler. TNS/R native object code executes only on TNS/R systems, not on TNS systems or TNS/E systems. TNS/R native object file. An object file created by a TNS/R native compiler that contains MIPS RISC instructions and other information needed to construct the code spaces and the initial data for a TNS/R native process. TNS/R native process.
Glossary user library user library. 1. An object code file that the operating system links to a program file at run time. A program can have only one user library. See also TNS user library, TNS/R native user library, and TNS/E native user library. 2. A library loadfile associated with a program so that it emulates the user library feature of the operating system on TNS systems. For PIC programs on TNS/R and TNS/E systems, the user library is a dynamic-link library (DLL).
Glossary $RECEIVE $RECEIVE. A pseudodevice from which a server reads its request messages and to which it writes its replies; any process can read system messages from $RECEIVE by declaring in the RECEIVE-CONTROL paragraph which messages it requires.
Index Numbers 9 in PICTURE clause 7-56 A A in PICTURE clause 7-54 Abbreviated combined relation conditions 8-66 ABEND 25-6 Accelerated mode 1-3 ACCEPT statement description of 9-1/9-8 in OSS environment 19-22 terminals and 29-2/29-3, 29-13 Access mode description of 4-8 heritability of 7-39 of parameters 9-26 ACCESS MODE clause description of brief 6-23 complete 7-38/7-39 file type and 6-22 for indexed file 6-46 for line sequential file 6-36, 19-11 for relative file 6-40 for sequential file 6-29 Access pat
Index A ALPHABETIC-LOWER class test in simple condition 8-61 with default character set 6-7 ALPHABETIC-UPPER class test in simple condition 8-61 with default character set 6-7 Alphabet-name 6-13/6-15 Alphanumeric class and category 4-1 Alphanumeric data items description of 7-60 ACCEPT statement and 9-3 alignment of data in 4-15 MOVE statement and 9-117 Alphanumeric edited category 4-1 Alphanumeric edited data items description of 7-61 ACCEPT statement and 9-3 alignment of data in 4-15 MOVE statement and
Index A Area B in ANSI reference format 16-4 in Tandem reference format 2-6 Arithmetic expressions description of 8-45, 8-48 as parameters 14-7, 23-18 precision of 8-51/8-53 summary of 38-8/38-9 Arithmetic mean function 14-31 Arithmetic operands 8-46 Arithmetic operations 8-43/8-53 Arithmetic operators 8-46 Arithmetic overflow COMPUTATIONAL data format and 8-25 error messages for 48-4 Arithmetic precision 8-49/8-53 Arithmetic statements description of 8-43 common features of 8-43 ASCII character set in al
Index B At-end condition (continued) for SEARCH VARYING statement 9-198, 9-199, 9-200 input-output errors and 8-40 simulated 9-226 $RECEIVE and 31-14 Audited disk files audit trails and 32-16 cache buffering and 28-32 HP COBOL Fast I-O and 6-33 AUTHOR paragraph 5-2 Averaging function 14-31 Avoiding deadlock 28-37/28-39 B B in PICTURE clause 3-22, 7-54 Background processes 25-13 Backup processes description of 32-4/32-6 CHECKPOINT statement and 9-32 STARTBACKUP statement and 9-241 Banner, compilation 22-3
Index C Body of page 7-25 Break key 29-9/29-10 BREAK message 6-69 BUFFERED attribute 6-32 Buffering cache indexed files and 6-49 relative files and 6-42 sequential files and 6-32, 9-280 structured files and 28-32 HP COBOL Fast I-O 28-34/28-35 local for indexed files 6-49 for relative files 6-43 for sequential files 6-33 sequential block disk input-output and 28-33 for indexed files 6-48 for relative files 6-42 for sequential files 6-31 HP COBOL Fast I-O and 9-178 BUFFER-SIZE parameter 13-37, 13-38 Bypassi
Index C Caret (^) 12-19, 47-2 Case sensitivity ACCEPT statement and 9-3 in HP COBOL 3-3 in record keys 28-22 in simple nonnumeric literals 3-17 in system file names 26-2 user-defined currency sign and 6-19 Categories of data description of 4-1, 7-59 in Data Division 7-2 Changing the compilation environment 22-17/22-18 CHAR function 14-13/14-14 Character sets COBOL 3-2/3-3 nondefault 6-7 CHARACTER-SET clause 6-5, 6-6/6-7 Character-strings description of 3-6/3-23 COBOL words 3-6/3-14 comments 3-23 literals
Index C COBOL words description of 3-6 qualified names 3-11/3-14 reserved words 3-8 system-names 3-9 user-defined names 3-9 COBOLFILEINFO routine description of 13-69/13-70 disk input-output and 28-41 in OSS environment 19-23 COBOL_ASSIGN_ routine description of 13-65/13-68 COBOL_SET_MAX_RECORD routine and 13-48 in OSS environment 19-23 COBOL_COMPLETION_ routine 13-23/13-24 COBOL_CONTROL_ routine 13-25/13-26 COBOL_FILE_OPEN_ routine 13-71/13-72 COBOL_GETENV_ routine 13-27 COBOL_PUTENV_ routine 13-28 COBOL
Index C Common programs 2-12, 9-25, 23-4 Common Run-Time Environment See CRE Common semantic rules 8-21 COMP data format See COMPUTATIONAL data format COMPACT directive 11-34 Comparisons in EVALUATE statement 9-64 nonnumeric 8-55 numeric 8-55 of indexes 8-56 of national data items 8-57 of national literals 8-57 Compilation See also Compiler banner 22-36, 22-37 batch 22-18 details of 11-7/11-17 environment for 22-17/22-18 for syntax checking only 22-16 in Guardian environment 11-1/11-93, 22-12/22-18 in OSS
Index C Compiler listing (continued) reference format and 22-37 REPLACE statement and 10-16, 22-39 SOURCE libraries and 22-43 spooling 30-7 uncompiled lines in 11-57 Compilers, HP COBOL 1-3 Completion codes 11-21 Complex conditions 8-64 Composites of arithmetic operands 8-43 COMPUTATIONAL data format description of 7-68, 7-72 allocation for 4-14 arithmetic overflow and 8-25 compared to NATIVE-n data format 7-76 PORT directive and 11-65 SYNCHRONIZED clause and 7-86 tape I-O and 27-14 value 8224 or 224 and
Index C CONSULT directive description of 11-43/11-45 migrating TNS/R programs to TNS/E programs and 33-3 Content, passing parameters by 23-17/23-18 Continuation lines in ANSI reference format 16-3 in Tandem reference format 2-5 CONTINUE statement explicit 9-41, 9-78, 9-199, 9-204 implicit 9-69 CONTROL message 6-69 CONTROLBUF message 6-69 Conventions for MOVE statement 9-117 Conversion between EBCDIC and ASCII 27-12 for labeled tape files 27-11 of arithmetic operands 8-43 of other data types 27-13 COPY lib
Index D Creating HP COBOL files (continued) relative 28-16/28-17 sequential 28-14/28-16 Creating programs 22-4/22-10 Creator ID, changing 31-37 Credit (CR) 3-22, 7-56, 7-64 CROSSREF directive 11-32 CURRENCY SIGN clause 6-19 Current position 30-12 Current spooler job 30-12 CURRENT-DATE function 14-16 Cursors 9-2 Customizing the PS TEXT EDIT (TEDIT) editor 22-10 C++ routines calling 9-54, 23-16 constructs peculiar to 9-59 passing parameters to 9-58, 23-22/23-24 restrictions on 9-58/9-59 D D or d (the lette
Index D Data items (continued) external See External objects group See Data structures in File Section 7-46 in Linkage Section 7-45 independent 7-3 INDEX See INDEX data format initialization of in Linkage Section 7-38 in Working-Storage Section 7-34 very large 11-38 intermediate 8-21, 8-44 internal See Internal objects levels of description 4-1 level 01-49 See Records level 66 7-90 level 77 7-3, 7-92 level 88 7-94 national See National data items NATIVE-n See NATIVE-n data format noncontiguous elementary
Index D DATE-WRITTEN paragraph 5-2, 5-3, 40-2 DAY phrase 9-7 DAY-OF-INTEGER function 14-18 DAY-OF-WEEK phrase 9-8 DB (debit) 3-22, 7-56, 7-64 DDL See Data Definition Language (DDL) Deadlock 28-37/28-39 DEB1 parameter 11-86 Debit (DB) 3-22, 7-56, 7-64 Deblocking files 7-15 Debugger entering 25-14, 25-15 run-time 15-2 Debugging mode, entering 25-14/25-15 on native COBOL cross compiler 34-7/34-9 position-independent code (PIC) 33-7, 34-7 programs that use fault-tolerant facility 32-13 that use TMF 32-20 Debu
Index D DEFINEs (continued) names of 12-19, 25-3, 26-9 on PC 34-10 predefined 11-23, 22-16 propagation of 12-18 DELETE DEFINE command 25-9 DELETE statement 9-42/9-44 Deleted records 28-14 Delimited-scope statements 8-7 Depending items 7-83 Deploy command 34-10 Descendants of processes 31-33 Describing databases 22-20/22-25 DEV subcommand of SPOOLCOM utility 30-18 DEVICE attribute of DEFINE for labeled tape file 27-22 for unlabeled tape file 27-16 DEVICEINFO2-COMPLETION message 6-69 Devices default input a
Index E Disk files (continued) structured description of 28-10 entry-sequenced 28-12, 28-14 improving performance of 28-31/28-35 indexed 28-13/28-14, 28-17/28-18 key-sequenced 28-13/28-14 record blocking for 28-31/28-35 relative 28-12/28-13, 28-16/28-17 temporary 26-3 types of 28-9 unstructured description of 28-9 creating and using 28-15 faster processing of 28-31 with fixed-length records 28-6 with variable-length records 28-6 DISPLAY data format description of 7-69, 7-74 converting 27-14 SYNCHRONIZED c
Index E Editing in PICTURE clause description of 3-22, 7-62/7-67 fixed insertion 7-64 floating insertion 7-65 simple insertion 7-63 special insertion 7-63 zero suppression 7-66 of source code See Editors of TACL commands 22-3 Editors Codewright with TEC 22-10/22-12 EDIT 22-6 HP 22-20 PS TEXT EDIT (TEDIT) 22-8/22-9 VS full-screen 22-7 eld utility 34-9 Elementary data items description of 4-1 clauses restricted to 7-45 default USAGE for 7-74 initializing 9-85 passed by content 23-17 passed by reference 23-1
Index E Error messages compiler description of 22-44/22-46 See also Failure messages See also Warning messages characteristics of 47-1 ERROR directive and 11-53 ERRORFILE directive and 11-52, 22-13 format of 47-3 from other products 47-95 list of 47-3/47-93 run-time description of 25-13/25-14, 48-1 associated with tape files 27-26 external 8-34/8-39 fatal 8-42 format of 48-2 Guardian abnormal termination 48-3/48-5 input-output 8-33/8-39, 48-3 list of 48-5/48-53 procedures for handling 25-14 program logic
Index F EXTDECS file 23-11, 23-12 EXTDECS0 file 23-12 EXTDECS1 file 23-12 Extend open mode 4-10 Extended addressing 7-38 EXTENDED parameter 11-85 EXTENDED-STORAGE access mode 7-38 Extended-Storage Section description of 7-35/7-36 data description entries in 7-36 Extensible parameter lists 23-11 Extensions to ISO/ANSI COBOL 17-1/17-5 Extents, file 28-2 EXTERNAL clause description of 7-11/7-13, 7-51/7-52 heritability of 7-12 in record description entry 7-44 initializing data items and 7-34 REDEFINES clause
Index F File description entries description of 7-5/7-29 for line sequential files 19-13 record description entries and 7-46 File extents 28-2 File names COBOL associating with system file names 9-132, 26-5/26-9 characteristics of 26-4 HP, for permanent disk files 26-2 multiple, for one physical file 28-41 physical 28-40 scope of 2-11 special 26-6 system description of 26-2/26-4 for devices 26-3 for nondisk files 26-3 for temporary disk files 26-3 unqualified 11-23, 22-16 File numbers 28-41 File position
Index F Files (continued) locking 9-34, 9-105/9-108, 26-9, 28-38 nonexistent 9-136, 9-139 numbers of 28-41 OBEY command 22-14 object See Object files of dummy routines 13-15 open modes of 4-10 opening 9-126/9-144 organization of 4-7 OSS 19-8 partitioned 28-36 positioning description of 28-23/28-30 approximate 28-24 exact 28-23 generic 28-24/28-26 to record with same alternate key 28-26/28-30 prereading records of 26-10, 27-1 processes treated as 26-10 purging description of 28-2 contents only 28-43 entire
Index G File-status data item description of 6-24 CLOSE statement and 9-36 UNLOCKRECORD statement and 9-257 FILE_GETINFO_ routine 28-41 FILLER bytes 4-16/4-18 FILLER keyword in DATA RECORDS clause 7-23 in record description entry 7-44, 7-47 FIPS directive 11-53 Fixed insertion editing 7-64 Fixed-length records description of 4-5, 7-19 in entry-sequenced files 28-12 in indexed files 28-14 in key-sequenced files 28-14 in relative files 28-13 in unstructured files 28-9 Fixed-size tables 7-78 FIXERRS macro 15
Index H Heritability (continued) of global attribute 7-53 of global names 2-14 of internal file access 9-27 Hexadecimal literals nonnumeric 3-18 numeric 3-16 Hierarchy of arithmetic operators 8-47 of qualified names 3-12 HIGH parameter 11-85 HIGHPIN directive 11-35 HIGHREQUESTERS directive 11-36 HIGH-VALUE or HIGH-VALUES figurative constant 3-21 HISTORY command 22-2 Home terminal 25-11 HP extensions to ISO/ANSI COBOL 17-1/17-5 HP COBOL Fast I-O description of 28-34/28-35 audited files and 6-33 for indexed
Index I HP NonStop TS/MP system servers 32-3 HP Tandem Advanced Command Language See TACL HP Tandem Extensions for Codewright (TEC) 22-10/22-12 Hyphen (-) See also Minus sign (-) in ANSI reference format 16-3 in COBOL words 3-6, 3-7 in Tandem reference format 2-5 I IBM standard labels 27-20 ICODE directive 11-33 Identification Division description of 5-1/5-6 summary of 40-1/40-2 Identification field 16-4, 22-38 Identifiers 4-24/4-25 IF directive 11-55 IF sentences 9-79 IF statement description of 9-74/9-
Index I Indicator area description of 22-38 in ANSI reference format 16-2 in Tandem reference format 2-4/2-6 Indirectly contained programs 2-9, 23-3 Initial programs description of 2-12, 23-4 CALL statement and 9-26 CANCEL statement and 9-30 storage allocation for 9-26 Initial state of program 9-26, 12-22 Initialization messages caused by 11-70, 11-88 of data items in Linkage Section 7-38 in Working-Storage Section 7-34 very large 11-38 when it occurs 7-34 of STRING statement 9-245 tallying and 9-91 INITI
Index I Integer functions (continued) ORD-MAX 14-43/14-44 ORD-MIN 14-45/14-46 INTEGER-OF-DATE function 14-21 INTEGER-OF-DAY function 14-23 INTEGER-PART function 14-24 Intermediate data items 8-21, 8-44 Intermediate results 8-52 Internal objects description of 2-14, 7-2 CANCEL statement and 9-31, 12-24 file connectors 4-11 files, #RECEIVE blocks for 11-17 initialization of 7-34 status during program execution 12-23 Internal references 24-3 Interprocess communication example 31-10/31-13 Interrecord gaps 27-
Index J INVALID KEY phrase in DELETE statement 9-42 in READ statement 9-185 in REWRITE statement 9-191, 9-195 in START statement 9-230, 9-232, 9-233 in WRITE statement 9-276 USE AFTER EXCEPTION procedures and 9-270 Invalid-key condition description of 8-40 for READ statement 9-187 for REWRITE statement 9-195 for START statement 9-232 IN-FILE-COUNT parameter 13-37, 13-40 IN-FILE-EXCL parameter 13-37, 13-40 In-line PERFORM statement 9-146 I-O See Input-output I-O-CONTROL paragraph 6-52/6-58 I/O See Input-ou
Index L LABELS attribute of DEFINE for labeled tape file 27-20 for unlabeled tape file 27-17 Language elements HP extensions affecting 17-2 ignored 20-6 summary of 38-1/38-6 LARGEDATA directive 11-34, 33-6 LD directive 11-35 Leading characters 9-89 LEFT keyword 7-86 LENGTH function 14-25 LESS THAN operator 8-55 LESS THAN OR EQUAL TO operator 8-55 LESS-CODE directive 11-34 Level 66 data items 7-90 Level 77 data items 7-3, 7-92 Level 88 data items 7-94 Levels of data 4-1 Level-1 spooling 30-8 Level-2 spooli
Index M Literals description of 3-15/3-21 national See National literals NATIVE-8 data format and 7-75 nonnumeric See Nonnumeric literals numeric See Numeric literals LMAP directive 11-33 Loadfiles executing 1-6 in OSS 1-4 main programs and 11-3 of separately compiled parts 1-5 on PC 1-4 RUNNABLE directive and 11-68 running as processes 12-1 when compiler produces 11-19 Local buffering for indexed files 6-49 for relative files 6-43 for sequential files 6-33 Local names 2-13 LOCK phrase for relative, index
Index N MESSAGE SOURCE phrase description of 6-62, 6-66 operating system messages and 26-11 #RECEIVE and 11-17 Messages determining source of 31-22 error See Error messages failure 47-3 generated by asynchronous hardware events 6-68 initialization 11-70, 11-88 REPORT clause 6-69 saved 13-20 system intercepting 26-10 list of 6-67 tape mount 13-63 warning 8-34, 47-2 MESSAGE-CANCELLED message 6-69 MESSAGE-MISSED message 6-69 MIDRANGE function 14-34 Migrating TNS/R programs to TNS/E programs description of 33
Index N Names (continued) unqualified 11-23 user-defined 3-9 National class and category 4-1 National data items alignment of data in 4-15 BLANK WHEN ZERO clause and 7-87 CHARACTER-SET clause and 6-7 comparisons of 8-57 in INSPECT statements 9-89 in PICTURE clause 7-61 in STRING statement 9-246 in UNSTRING statement 9-266 MOVE statements and 9-117 SIGN clause and 7-78 SPECIAL-NAMES paragraph and 6-8 SYNCHRONIZED clause and 7-86 USAGE clause and 7-71 National literals description of 3-18 CHARACTER-SET clau
Index N NLD directive 11-35 NO ADVANCING phrase 9-47 NO REWIND phrase 9-35 NOBLANK directive description of 11-38 initial state of program and 12-22 initializing data items and 7-34 NOCANCEL directive description of 11-40 CANCEL statement and 9-31 NOCODE directive 11-32 NOCOMPACT directive 11-34 NOCONSULT directive 11-43/11-45 NOCROSSREF directive 11-32 NODE-DOWN message 6-69 NODE-UP message 6-69 NODIAGNOSEALL directive 11-50 NODIAGNOSE-74 directive 11-45/11-48 NODIAGNOSE-85 directive 11-49 NOFIPS directi
Index O NOT INVALID KEY phrase (continued) in START statement 9-230, 9-233 in WRITE statement 9-277 NOT LESS THAN operator 8-55 NOT modifier 8-60, 8-63 NOT SIZE ERROR phrase in ADD CORRESPONDING statement 9-14 in ADD GIVING statement 9-12 in ADD TO statement 9-9 in COMPUTE statement 9-39 NOTRAP2 directive 11-34 NOTRAP2-74 directive 11-35 NOWAIT option of RUN command 22-14, 25-13 NOWAIT-IO parameter 13-37, 13-42 NOWARN directive 11-93, 22-36 NO-CPU-MASK parameter 13-34 NULL pointer value in relation condit
Index O Object files (continued) adding to primary search list 24-9 adding to tertiary search list 24-10 binding 11-16 creating 11-19 default names for 22-15 description of 24-2 establishing mnemonic names for 24-9 manipulating 11-19 naming 22-15 reducing size of 11-40 specifying 24-8 OBJECT-COMPUTER paragraph 6-4/6-7 Obsolete elements 11-85 OBSOLETE parameter 11-86 OCCURS clause ALL subscript and 14-7 in record description entry for fixed-size table 7-78 for variable-size table 7-82 in redefined data ite
Index P Organization of files 4-7 of HP COBOL programs 2-1/2-22 ORGANIZATION clause description of 6-23 file type and 6-22 for indexed file 6-46 for line sequential file 6-36, 19-11 for queue file 6-50 for relative file 6-39 for sequential file 6-28 OSS See Open System Services (OSS) environment OSS ASCII text files See Line sequential files OUT option of RUN command 25-11, 26-7 Output See also Input-output default device for 25-10 description of 26-1/26-11 from compiler 1-5, 11-18/11-21 merged 9-108 open
Index P PARAM commands (continued) SWITCH-nn 12-9, 25-6 SYMBOL-BLOCKS 11-23, 22-18 migrating to native mode and 33-3 WAITED-IO 12-10, 25-6 PARAM message portions 13-21 Parameters adding formal 23-11 addressing 9-58 arithmetic expressions as 23-18 COBOL file names as 23-18 declaring 9-26 elementary data items as 23-17, 23-19 established with FastSort 13-16 established with =_SORT_DEFAULTS DEFINE 13-16 extensible 23-11 for operating system routines 23-9 formal, adding 23-11 index values as 9-27 lists of 23-
Index P PICTURE clause (continued) for NATIVE-n data item 7-75 in record description entry 7-44 NUMERIC class test and 8-60 Plus sign (+) as editing character 3-22 in PICTURE clause 7-56, 7-64, 7-65 Pointer class and category 4-1 POINTER data format description of 7-69, 7-76 in relation conditions 8-58 PORT directive and 11-66 SYNCHRONIZE clause and 7-86 Pointers as operands 8-58 assigning values to 9-207/9-209 decrementing 9-213 incrementing 9-213 initializing 7-89 on IBM/370 machine 9-213 SET TO stateme
Index P Printers (continued) output to description of 30-1/30-23 formatting of 30-21/30-22 vertical spacing in 30-19/30-21 unavailable 25-6 WRITE statement and 30-23 writing to 29-12 PRINTER-CONTROL parameter 12-11, 12-13 Priority of spooler jobs 30-6 PRIORITY parameter 13-37, 13-43 Procedure Division description of 8-1/8-69 components of 8-1, 8-2/8-3 example of 8-3 execution of 8-16/8-20 HP extensions affecting 17-4/17-5 summary of 43-1/43-58 syntax of 8-2 verbs in 9-1/9-287 Procedures error-handling 25-
Index Q Programs called See Called programs calling See Calling programs and routines ENFORM 23-13 HP COBOL See HP COBOL programs mixed-language See Mixed-language programs non-COBOL 9-54, 11-4, 23-6/23-16 source See HP COBOL programs PROGRAM-ID paragraph 5-2, 5-4/5-5 Program-name, scope of 2-10 PROGRAM-STATUS special register 9-241, 32-10/32-11 PROGRAM-STATUS-1 special register 9-241 PROGRAM-STATUS-2 special register 9-241 PROMPT phrase 9-169 Prompting an operator 29-6/29-7 PROTECTED exclusion mode 4-10,
Index R Queue files (continued) reading 28-20 removing records from 28-20 rewriting 9-190/9-195 writing 9-283/9-287, 28-20 Queuing printer file records 9-141 Quotation mark (") as separator 3-5 figurative constant for 3-21 in CALL statement 9-20, 24-9 in ENTER statement 9-55, 24-9 in literal hexadecimal nonnumeric 3-18 national 3-19 simple nonnumeric 3-17 QUOTE or QUOTES figurative constant 3-21 R Radix 10 7-68 Raising to a power See Exponentiation operator Random access mode description of 4-8 DELETE st
Index R Records (continued) deleted 28-14 description entries for description of 7-2, 7-42/7-89 file description entries and 7-46 displaying 9-47 elements of 4-5 external 7-51 fixed-length 7-19 gaps between 27-2 implicit FILLER bytes and 4-17 in Extended-Storage Section 2-15 in Linkage Section 2-15 in Working-Storage Section 2-15 keys to See Record keys length of 4-5 locking 28-38, 32-18 logical 4-4 names of identical 3-14 scope of 2-11 numbers for 28-12, 28-16 passed by reference 23-19 physical 4-4 prere
Index R Relative files (continued) closing 9-38 creating 28-16/28-17 file description entries for 7-10 file-control entries for 6-22, 6-37/6-43 opening 9-126 rewriting 9-190/9-195 writing 9-283/9-287 RELATIVE KEY clause description of 6-40 file type and 6-22 Relative record keys 6-42 RELEASE statement 9-188 REM function 14-52 Remainder function 14-52 Remote passwords 28-6 REMOTE-CPU-DOWN message 6-70 REMOTE-CPU-UP message 6-70 REMOVAL phrase 9-35 REMOVE-DUPLICATES parameter 13-37, 13-43 RENAMES clause des
Index R Reserved words (continued) categories of 21-1 HP COBOL 21-11/21-12 that cannot be split 2-6 RESETSYNC message 6-70 RESETTOG directive 11-67 Resolution control directives for 11-35 of external references in binding 24-4, 24-5/24-6 to COBOL programs 11-11/11-13 to non-COBOL programs 11-13/11-15 of operating system routines 23-11/23-12 RETENTION attribute of DEFINE for labeled tape file 27-23 for unlabeled tape file 27-18 RETURN statement 9-189/9-190 Returned values GIVING phrase and 11-16 sizes of B
Index S S S in PICTURE clause 7-55 SAME AREA clause description of 6-54 for input-output file 6-55 for sort-merge file 6-56/6-57 RESERVE clause and 6-34 SAME MERGE AREA clause 6-57 SAME RECORD AREA clause description of 6-57 GLOBAL clause and 7-14, 7-53 SAME SORT AREA clause 6-57 SAVE directive 11-70/11-71 SAVEABEND directive 11-72 Saveabend file 11-72 Saved Message Utility routines 13-18/13-21 Saved messages 13-20 SAVE-SCRATCH parameter 13-37, 13-43 Scope explicit terminators of 8-7 of condition-names 2-
Index S SELECT clause description of 6-23 file type and 6-22 for indexed file 6-44 for line sequential file 6-35, 19-10 for relative file 6-38 for sequential file 6-26 for sort-merge file 6-50 Semantic rules, common 8-21 Semicolon (;) 3-4 Sending data items description of 8-21 in INITIALIZE statement 9-85 Sentences execution of 8-17 syntax of 8-10 SEPARATE CHARACTER phrase 7-77 Separately compiled programs description of 1-5, 11-5, 23-2, 24-1 diagnostic messages and 22-45 sharing files 28-7 Separators 3-4
Index S SIGN clause (continued) for BINARY/COMPUTATIONAL data item 7-72 for NATIVE-n data item 7-75 in record description entry 7-45 Sign conditions 8-63 Simple conditions 8-54 Simple insertion editing 7-63 SIN function 14-54 Sine function 14-54 Single-tape files 9-36 Size error condition 8-24, 8-51 SIZE ERROR phrase description of 8-23/8-26 arithmetic precision and 8-49 for NATIVE-n data item 7-75 in ADD CORRESPONDING statement 9-14 in ADD GIVING statement 9-12 in ADD TO statement 9-9 in COMPUTE statemen
Index S SPECIAL-NAMES paragraph description of 6-8/6-20 migrating TNS/R programs to TNS/E programs and 33-3 SPI devices opening 13-57 sending events to 13-59 SPOOLCOM utility description of 30-3, 30-16/30-19 DEV subcommand 30-18 JOB subcommand 30-17 Spooler jobs description of 30-4/30-7 current 30-12 form names for 30-6 location of 30-4 number of copies of 30-6 priority of 30-6 report names for 30-6 state of 30-5 Spoolers components of 30-2/30-3 jobs for See Spooler jobs output to description of 30-1, 30-
Index S Statements (continued) imperative 8-5 nested conditional IF 9-79 delimited-scope IF 9-76 PERFORM 9-147 next executable 8-19 scope of 8-8 summary of 43-1/43-58 types of 8-4 Static calls 23-5 Statistics, compiler 11-19/11-20 Status Key 1 8-29 Status Key 2 8-30 STATUS-3270 message 6-70 STOP statement 9-242 Stopping compilation in Guardian environment 11-29 in OSS environment 19-1 Storage allocation for compiler 22-18 for data items data structures 7-45 elementary 7-45 redefined 7-48 for disk files 28
Index T SWAP-FILE parameter description of 13-35 MERGE statement and 9-114 Switches, external 9-212, 25-6 Switch-status conditions 8-62 Symbol table directives for 22-36 listing of 22-47 SYMBOLIC CHARACTERS clause 6-16 Symbolic code listing 22-36, 22-47 SYMBOLS directive 11-90 Sync blocks, checkpointing 32-7 SYNCDEPTH LIMIT phrase 6-61 SYNCDEPTH parameter 32-8 SYNCHRONIZED clause description of 7-85/7-86 for COMPUTATIONAL-3 data item 7-73 for COMPUTATIONAL-5 data item 7-74 for INDEX data item 7-75 for NAT
Index T Tandem reference format (continued) restrictions on 2-6/2-8 text libraries and 22-18 Tangent function 14-60 Tape files blocking 27-2 closing 9-36 DEFINEs for 27-15/27-24 EBCDIC 27-12 executing programs that use 27-24/27-26 input-output 27-1/27-26 labeled See Labeled tape files minimum record length 27-1 other data types in 27-13 other than HP 27-12/27-15 preventing prereading of 27-1 reading and writing description of 27-1/27-15 labeled 27-8/27-12 other than HP 27-12/27-15 unlabeled 27-3/27-8 shar
Index U Time limit (continued) for LOCKFILE statement 9-106, 9-107 for READ statement 9-167, 9-176, 9-187 for START statement 9-229, 9-232 for $RECEIVE 8-42 on disk file input-output 28-7, 28-38 on input-output 8-41/8-42 TIME LIMIT phrase in LOCKFILE statement 9-106, 9-107 in READ statement 9-167 in START statement 9-229, 9-232 TIME LIMITS phrase 9-127 TIME phrase 9-8 Timestamp process names 25-12 Time, current ACCEPT statement and 9-8 CURRENT-DATE function and 14-16 TIME-SIGNAL message 6-70 TMF See HP No
Index V USAGE clause description of 7-68/7-77 in record description entry 7-45 USE attribute of DEFINE 27-22 USE statement 9-269/9-273 User code space 13-3 User data space 13-3 User library description of 13-3 migrating TNS/R programs to TNS/E programs and 33-2 specifying 13-4 User-defined names description of 3-9 scope of 2-9 USING phrase in CALL statement 9-21 in ENTER statement 9-57 Linkage Section and 7-39 Utility routines description of 13-1/13-72 dummy 13-15 in OSS environment 19-23 list of 13-1/13-
Index W W Z WAITED-IO parameter 12-11 WARN directive 11-93, 22-36 Warning messages description of 8-34 format of 47-2 from Binder 11-93 from compiler 11-52, 11-93, 22-13 in compiler listing 22-45 list of 47-3/47-93 optional 22-45 WHEN-COMPILED function 14-64/14-65 While loop (PERFORM VARYING) 9-154/9-165 Working-Storage Section 7-32/7-35 WRITE statement 9-273/9-287 Write-through cache 28-32 Writing numeric data 29-13 to console 29-11 to printer 29-12, 30-23 to tape files description of 27-1/27-15 labele
Index Special Characters $0 opening 13-57 sending events to 13-59, 29-11 $0.#ZSPI opening 13-57 sending events to 13-59 $RECEIVE as input-output file 31-7/31-9 as separate input and output files 31-5/31-7 Break and 29-9 file number of 28-41 process communication and 31-4/31-9 RECEIVE-CONTROL paragraph and 6-58/6-70 rules for 31-15 time limit for 8-42 #RECEIVE blocks and 11-16/11-17 $SYSTEM.SYSnn subvolume ZCOBDLL and 13-17 ZCREDLL and 13-21 $SYSTEM.
Index Special Characters HP COBOL Manual for TNS/E Programs —520347-003 Index -54