HP COBOL Manual for TNS and TNS/R Programs Abstract This publication describes the HP implementation of the 1985 version of the COBOL language. It includes information on the COBOL85 and NMCOBOL compilers (T9257 and T8107, respectively) 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 Published 522555-001 COBOL85 D32, D42, D44, D46; NMCOBOL D44.01, D46; PC COBOL D45, G06.06 February 2002 522555-002 COBOL85 D32, D42, D44, D46; NMCOBOL D44.01, D46; TDS PC COBOL D45, G06.06; ETK PC COBOL G06.06, G06.15, G06.18, G06.20 May 2003 522555-003 COBOL85 D32, D42, D44, D46; NMCOBOL D44.01, D46; TDS PC COBOL D45, G06.06; ETK PC COBOL G06.06, G06.15, G06.18, G06.20 April 2004 522555-006 COBOL85 D32, D42, D44, D46; NMCOBOL D44.
HP COBOL Manual for TNS and TNS/R Programs Glossary Index What’s New in This Manual liii Manual Information liii New and Changed Information Examples Figures liv About This Manual lix Manuals to Which This Manual Refers Acknowledgment lxiv Notation Conventions lxv lix 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-9 Directly Contained Programs and Indirectly Contained Programs Scope of User-Defined Names 2-11 Common Programs 2-14 Programs in the Same Run Unit 2-14 Initial Programs 2-14 How Programs Share Resources 2-15 Global and Local Names 2-16 External and Internal Objects 2-17 Shared Data 2-18 Shared Files 2-24 3.
4. Data Fundamentals (continued) Contents 4. Data Fundamentals (continued) Implicit FILLER Bytes 4-16 Records 4-17 Tables 4-17 REDEFINES Clause 4-18 References to Data Items 4-18 Qualifiers 4-19 Subscripts 4-19 Reference Modifiers 4-22 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-256 STRING 9-257 SUBTRACT 9-262 SUBTRACT FROM 9-263 SUBTRACT GIVING 9-265 SUBTRACT CORRESPONDING 9-267 UNLOCKFILE 9-269 UNLOCKRECORD 9-270 UNSTRING 9-271 USE 9-283 USE DEBUGGING 9-284 USE AFTER EXCEPTION 9-288 WRITE 9-292 WRITE for Sequential Files 9-292 WRITE for Line Sequential Files 9-300 WRITE for Relative, Indexed, and Queue Files 9-301 10.
. Program Compilation (continued) Contents 11.
11. Program Compilation (continued) Contents 11.
11. Program Compilation (continued) Contents 11. Program Compilation (continued) Compiler Directives (continued) SUPPRESS and NOSUPPRESS 11-129 SYMBOLS and NOSYMBOLS 11-130 SYNTAX 11-131 TANDEM 11-132 TRAP2 and NOTRAP2 11-132 TRAP2-74 and NOTRAP2-74 11-134 UL 11-135 WARN and NOWARN 11-136 12.
Contents 13. Libraries and Utility Routines (continued) 13.
13. Libraries and Utility Routines (continued) Contents 13.
14. Intrinsic Functions (continued) Contents 14.
15. Debugging Tools Contents 15. Debugging Tools Standard COBOL Debugging Tools Run-Time Debuggers 15-4 Visual Inspect 15-4 Inspect 15-5 Debug 15-5 Debugger Selection 15-6 CROSSREF Utility Program 15-8 FIXERRS Macro 15-10 15-1 16. ANSI Reference Format Sequence Number Area 16-1 Indicator Area 16-2 Compiler Directive 16-2 Ordinary Comment 16-2 Comment for Top of Page 16-2 Debugging Line 16-2 Continuation Line 16-3 Area A 16-4 Area B 16-4 Identification Field 16-4 17.
Contents 18. HP COBOL CRE Support (continued) 18. HP COBOL CRE Support (continued) $RECEIVE Processing 18-4 EXTERNAL Clause 18-5 MESSAGE SOURCE Clause 18-5 REPORT Clause 18-5 Message Format 18-6 Message Replies 18-6 Arithmetic Overflow Processing 18-6 TNS HP COBOL Programs in TNS User Libraries 18-6 CHECKPOINT Access to Extended-Storage Section 18-6 CBL85UTL Routines 18-7 COBOLLIB Routines 18-8 COBOLASSIGN 18-8 COBOLFILEINFO 18-8 COBOLSPOOLOPEN 18-8 19.
. Using HP COBOL in the OSS Environment (continued) Contents 19. Using HP COBOL in the OSS Environment (continued) Features Unavailable in the OSS Environment 19-23 ASSIGN Commands 19-23 PARAM Commands 19-23 Compiler Directives 19-24 Process Pairs 19-24 Features That Operate Differently in the OSS Environment ACCEPT and DISPLAY Statements 19-24 Utility Routines 19-25 19-24 20. HP COBOL Limits Size 20-1 Number 20-4 Callability 20-7 External Names 20-7 Ranges of Values 20-7 Ignored Elements 20-8 21.
Contents 22. Creating and Compiling HP COBOL Source Programs (continued) 22.
Contents 23. Calling Other Programs and Routines 23.
24. Issues Related to Binding and Linking (continued) Contents 24. Issues Related to Binding and Linking (continued) Designing Programs With Large Amounts of Code 24-17 Separate Programs 24-18 Separate Processes 24-19 TNS User Library 24-19 Designing Programs With Large Amounts of Data 24-21 Extended-Storage Section 24-21 LESS-CODE Directive 24-22 COBOL Segmentation 24-23 25.
26. Input and Output Concepts Contents 26. Input and Output Concepts Files 26-1 System File Names 26-2 COBOL File Names 26-4 Associating COBOL File Names With System File Names Prereading File Records 26-10 Processes Handled as Files 26-10 Intercepting Operating System Messages 26-10 26-5 27.
28. Disk Input and Output (continued) Contents 28.
29. Terminal Input and Output Contents 29.
31. Process Initiation, Communication, and Management Contents 31.
Contents 33. Migrating TNS Programs to Native Programs 33.
35. Commands Contents Part III. Syntax Summary 35.
36. Compiler Directives (continued) Contents 36.
36. Compiler Directives (continued) Contents 36. Compiler Directives (continued) SUBSET 36-43 SUBTYPE 36-44 SUPPRESS and NOSUPPRESS 36-44 SYMBOLS and NOSYMBOLS 36-45 SYNTAX 36-46 TANDEM 36-46 TRAP2 and NOTRAP2 36-47 TRAP2-74 and NOTRAP2-74 36-48 UL 36-48 WARN and NOWARN 36-49 37. Source Program Organization and Format Separately Compiled Source Program Reference Format 37-2 TANDEM 37-2 ANSI 37-3 37-1 38.
39. Data References (continued) Contents 39. Data References (continued) Qualified Identifier 39-2 Subscripted Table Element 39-3 Reference Modifier 39-3 OSS Pathname for OSS File 39-3 OSS Pathname for Guardian File 39-4 40. Identification Division 41.
43. Procedure Division (continued) Contents 43.
43. Procedure Division (continued) Contents 43.
44. Intrinsic Function Calls (continued) Contents 44.
45. CBL85UTL and ZCOBSRL Routine Calls Contents 45.
46. COBOLLIB, CLULIB, and ZCRESRL Routine Calls (continued) Contents 46. COBOLLIB, CLULIB, and ZCRESRL Routine Calls (continued) Non-SMU Routines 46-10 COBOLASSIGN 46-11 COBOL_ASSIGN_ 46-11 COBOLFILEINFO 46-12 COBOL_FILE_INFO_ 46-12 COBOLSPOOLOPEN 46-13 CREATEPROCESS 46-14 Part IV. Error Message Summary 47.
A. ASCII Character Set Contents Part V. Appendixes A. ASCII Character Set ASCII Character Set in Numeric Order A-1 ASCII Character Set in Alphabetic Order A-6 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.
Examples (continued) Contents Examples (continued) Example 6-4. Example 6-5. Example 6-6. Example 6-7. Example 6-8. Example 6-9. Example 6-10. 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.
Examples (continued) Contents Examples (continued) Example 8-9. Example 8-10. Example 8-11. Example 8-12. Example 8-13. Example 8-14. Example 8-15. 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.
Examples (continued) Contents Examples (continued) Example 9-30. Example 9-31. Example 9-32. Example 9-33. Example 9-34. Example 9-35. 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.
Examples (continued) Contents Examples (continued) Example 9-65. Example 9-66. Example 9-67. Example 9-68. Example 9-69. Example 9-70. Example 9-71. Example 9-72. Example 9-73. Example 9-74. Example 9-75. Example 9-76. 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 11-11. Example 11-12. Example 11-13. Example 12-1. Example 12-2. Example 12-3. Example 12-4.
Examples (continued) Contents Examples (continued) 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. Example 13-13. Example 13-14. 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.
Examples (continued) Contents Examples (continued) Example 14-23. Example 14-24. Example 14-25. Example 14-26. Example 14-27. Example 14-28. Example 14-29. Example 14-30. Example 14-31. Example 14-32. Example 14-33. Example 14-34. Example 14-35. Example 14-36. 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 15-1. Example 15-2. Example 15-3. Example 16-1. Example 19-1. Example 19-2. Example 19-3. Example 22-1. Example 22-2.
Examples (continued) Contents Examples (continued) 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. Example 22-20. Example 22-21. Example 22-22. Example 22-23. Example 22-24. Example 22-25. Example 22-26. Example 22-27. Example 22-28. Example 23-1. Example 23-2. Example 23-3. Example 23-4.
Examples (continued) Contents Examples (continued) 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. Example 28-13. Example 28-14. Example 29-1. Example 29-2. Example 29-3. Example 29-4. Example 29-5. Example 29-6. Example 30-1. Example 30-2.
Examples (continued) Contents Examples (continued) 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 31-17. Example 32-1. Example 33-1. Example 47-1. Example 47-2. Example 47-3. Example 47-4. Example 48-1. Example 48-2. Example 48-3. Example 48-4.
Figures (continued) Contents Figures (continued) 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 11-3. Figure 11-4. Figure 11-5. Figure 13-1. Figure 13-2. Figure 13-3. Figure 15-1. Figure 15-2. Figure 15-3. Figure 16-1. Figure 21-1. Figure 22-1. Figure 22-2. Figure 22-3. Figure 22-4.
Figures (continued) Contents Figures (continued) Figure 23-1. Figure 24-1. Figure 24-2. Figure 24-3. Figure 24-4. 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 4-3. Table 4-4. Table 4-5. Table 4-6. Table 6-1. 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.
Tables (continued) Contents Tables (continued) Table 8-11. Table 8-12. Table 8-13. Table 8-14. Table 8-15. 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-11. Table 11-12.
Tables (continued) Contents Tables (continued) Table 11-13. Table 11-14. Table 11-15. Table 11-17. Table 11-16. Table 11-18. Table 11-19. Table 11-20. Table 11-21. Table 12-1. Table 12-2. Table 13-1. Table 13-2. Table 13-3. Table 13-4. 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 13-13. Table 13-14. Table 13-15. Table 13-16. Table 13-17. Table 13-18. Table 13-19. Table 14-1. Table 14-2. Table 14-3. Table 14-4. Table 14-5.
Tables (continued) Contents Tables (continued) Table 14-6. Table 16-1. Table 18-1. Table 18-2. Table 19-1. Table 19-2. Table 22-1. Table 22-2. Table 22-3. Table 23-1. Table 23-2. Table 23-3. 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. 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.
Tables (continued) Contents Tables (continued) Table 32-2. Table 33-1. 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 45-1. Table 46-1. Table 46-2. Table 47-1. Table 47-2. Table 48-1. Table A-1. Table A-2. Table B-1. Table B-2. Table B-3. Table B-4. Table B-5. Table B-6. Table B-7.
Contents HP COBOL Manual for TNS and TNS/R Programs —522555-006 lii
What’s New in This Manual Manual Information HP COBOL Manual for TNS and TNS/R Programs Abstract This publication describes the HP implementation of the 1985 version of the COBOL language. It includes information on the COBOL85 and NMCOBOL compilers (T9257 and T8107, respectively) 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.
New and Changed Information What’s New in This Manual Document History Part Number Product Version Published 522555-001 COBOL85 D32, D42, D44, D46; NMCOBOL D44.01, D46; PC COBOL D45, G06.06 February 2002 522555-002 COBOL85 D32, D42, D44, D46; NMCOBOL D44.01, D46; TDS PC COBOL D45, G06.06; ETK PC COBOL G06.06, G06.15, G06.18, G06.20 May 2003 522555-003 COBOL85 D32, D42, D44, D46; NMCOBOL D44.01, D46; TDS PC COBOL D45, G06.06; ETK PC COBOL G06.06, G06.15, G06.18, G06.
What’s New in This Manual • • • Changed “executable object file” was changed to “loadfile” “nonexecutable object file” was changed to “linkfile” Miscellaneous format changes Change bars identify important changes to content in the following topics. (Minor changes are marked by change bars but not listed here.
What’s New in This Manual • • • • • • SHARED SQL and NOSQL RUN or RUND Command PARAM Command COBOL85^ARMTRAP The description of library-reference in: ° ° ° COBOL85^COMPLETION and COBOL_COMPLETION_ ° ° COBOL85^REWIND^SEQUENTIAL and COBOL_REWIND_SEQUENTIAL_ ° COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ ° COBOL85^SPECIAL^OPEN and COBOL_SPECIAL_OPEN_: COBOL_CONTROL_ COBOL85^RETURN^SORT^ERRORS and COBOL_RETURN_SORT_ERRORS_ COBOL85^SET^SORT^PARAM^TEXT and COBOL_SET_SORT_PARAM_TEXT_ °
What’s New in This Manual • • • • Deleted Other Products’ Error Messages moved from Section 48, Run-Time Diagnostic Messages, to Section 47, Compiler Diagnostic Messages Arithmetic Overflow Stack Overflow Glossary has some changed entries Deleted • From Section 19, Using HP COBOL in the OSS Environment and Section 35, Commands: ° ° cobol Utility Flags nmcobol Utility Flags These flags are described in the Open System Services Shell and Utilities Reference Manual.
What’s New in This Manual HP COBOL Manual for TNS and TNS/R Programs —522555-006 lviii Deleted
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.
Manuals to Which This Manual Refers About This Manual Table i. HP Manuals to Which This Manual Refers (page 5 of 6) Manual Description 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. You need it if your HP COBOL program contains embedded SQL/MP statements. SQL/MP Reference Manual Describes HP NonStop SQL/MP.
Acknowledgment About This Manual Table i.
Notation Conventions About This Manual Notation Conventions This manual uses these conventions throughout: • • • • • • • • “Compiler” means both the COBOL85 and NMCOBOL compilers unless otherwise stated “Linker” means the nld and ld utilities 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 impl
Syntax Diagram Conventions About This Manual Syntax Diagram Conventions This manual presents syntax in railroad diagrams. Here is a generic railroad diagram: KEYWORD item1 item3 item2 , item4 «item5» VST406.vsd To use a railroad diagram, follow the direction of the arrows and specify syntactic items as indicated by the diagram pieces: Diagram Piece KEYWORD Meaning Type KEYWORD as shown. You can type letters in uppercase or lowercase. VST412.
Syntax Diagram Conventions About This Manual Some examples of the meanings of simple diagrams are: Diagram Piece Meaning Choose item1 or item2. item1 item2 VST407.vsd Choose item1, item2, or neither. item1 item2 VST408.vsd Specify item one or more times, separating occurrences with commas. item , VST409.vsd Specify item at most n times. item n VST742.vsd Note.
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: MULTIPLY integer1 , 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 processes and TNS/R native processes. (The COBOL Manual for TNS/E Programs explains how to use the HP COBOL language to create TNS/E 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/Rsystems support three execution modes: TNS Mode Accelerated Mode TNS/R Native Mode Programs are generated by TNS compilers. Programs are generated by TNS compilers and then processed by the Accelerator. Programs are generated by TNS/R native compilers. Programs use TNS process and memory architecture. Programs use TNS process and memory architecture. Programs use TNS/R native process and memory architecture.
HP COBOL Compilers for TNS and TNS/R Programs Introduction HP COBOL Compilers for TNS and TNS/R Programs For HP COBOL source programs, HP provides the compilers in Table 1-3. Table 1-3. HP COBOL TNS and TSN/R Compilers Compiler T Number Description COBOL85 T9257 Produces TNS object code, which is position-dependent code (non-PIC). Runs on TNS, TNS/R, and TNS/E systems. NMCOBOL* ** T8107 Produces native TNS/R object code, which is either non-PIC (the default) or positionindependent code (PIC).
Compiler Input Introduction Compiler Input The only required input to the compiler is: • • A source file containing the program text In some cases, compiler directives The optional input is: • • • One or more source library files from which the compiler can copy additional source text specified in COPY statements or SOURCE directives One or more user-specified object files that contain object code explicitly called by the program being compiled For the COBOL85 compiler: ° ° • The COBOL85 run-time
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 If compilation errors occurred: • • The COBOL85 compiler produces a partial object file if any program units in the compilation compile without errors. The NMCOBOL compiler produces no object file.
Combining Separately Compiled Source Programs Introduction Combining Separately Compiled Source Programs You can compile several source files separately and then combine their object code files into a single loadfile . The method you use depends on mode and operating environment, as this table shows: Mode Operating Environment Object Code Method For more information, see ...
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 An executing COBOL process (execute the loadfile as a separate process) CREATEPROCESS routine (to create a low-PIN process) CLU_PROCESS_CREATE_ routine (to create a high-PIN process) CRE Programmer’s Guide OSS Environment From ...
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 Restrictions Standard COBOL Practice Observe these restrictions to conform to standard COBOL practice (HP COBOL does not enforce them). • • Verify that the special constructs DECLARATIVES and END DECLARATIVES (along with each one’s terminating period separator) are completely contained in a single program text line with a space character in the indicator area. Start them in area A and precede them only by space characters.
Source Program Organization and Format COPY Libraries COPY Libraries Any line in a source program can contain a COPY statement, which tells the COBOL compiler to insert source text from a specified disk file, called a COPY library. A COPY library is an EDIT or OSS ASCII file divided into one or more sections that begin with a SECTION directive. In the COPY library, you can specify the reference format of the line or lines to be copied.
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 Scope of User-Defined Names When a program directly or indirectly contains other programs, each program can use identical user-defined names to name objects independent of the use of these userdefined names by other programs. If program X describes a data item named B, and program X includes another program Y, program Y can describe a different data item named B (or even a file connector named B).
Source Program Organization and Format Scope of User-Defined Names Program-Name The PROGRAM-ID paragraph of a program’s Identification Division declares that program’s program-name. Only the CALL and CANCEL statements and the END PROGRAM statement can refer to a program-name.
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 Global and Local Names Global and Local Names A data-name (which names a data item) or a file-name (which names a file connector) can be either global or local. Suppose that program X declares data-name Y, and program X contains program Z, which also declares data-name Y. When program Z references data-name Y, it is referencing the Y that it declared, not the Y that program X declared, whether program X declared its Y to be global or not.
Source Program Organization and Format External and Internal Objects External and Internal Objects An external object is stored in an area that is associated with the run unit rather than with any particular program within the run unit. An internal object is stored in an area that is associated only with the program that describes the object. An external object can be referenced by any program in the run unit that describes the object.
Source Program Organization and Format Shared Data Linkage Section Records Data records and any subordinate data items in the Linkage Section are representatives of data items defined in other programs. They are considered to be internal to the program describing them and are directly accessible only to that program; however, they are indirectly accessible to programs called by that program.
Source Program Organization and Format Shared Data Example 2-2.
Source Program Organization and Format Shared Data Example 2-2. Programs With Shared Data (page 2 of 4) * Storage 1. W of Bbb, w of Ccc, and w of Sub all refer to one location * Allocation * 2. Z of Mane and z of Sub each refer to one location. * * 3. All other identifiers refer to unique locations. / ?main Mane IDENTIFICATION DIVISION. PROGRAM-ID. Mane. DATA DIVISION. WORKING-STORAGE SECTION. 01 w PICTURE 99 VALUE 3. 01 y PICTURE 99 GLOBAL VALUE 1. 01 z picture 99 GLOBAL EXTERNAL. PROCEDURE DIVISION. m.
Source Program Organization and Format Example 2-2. Programs With Shared Data (page 3 of 4) PROCEDURE DIVISION. b. MOVE 1 TO w DISPLAY " Bbb begin" PERFORM show-me DISPLAY " Bbb adding 3 to w and to x" ADD 3 to w x PERFORM show-me CALL Ccc PERFORM show-me DISPLAY " Bbb end" EXIT PROGRAM . show-me. DISPLAY " in Bbb, w (ext)=/" w "/" " x (global in Bbb)=/" x "/" " y (global from Aaa)=/" y "/" . IDENTIFICATION DIVISION. PROGRAM-ID. Ccc. DATA DIVISION. WORKING-STORAGE SECTION. 01 w PICTURE 99 EXTERNAL.
Source Program Organization and Format Example 2-2. Programs With Shared Data (page 4 of 4) IDENTIFICATION DIVISION. PROGRAM-ID. Sub. DATA DIVISION. WORKING-STORAGE SECTION. 01 y PICTURE 99 GLOBAL VALUE 2. 01 w PICTURE 99 EXTERNAL. 01 x PICTURE 99 VALUE 0. 01 z PICTURE 99 EXTERNAL. PROCEDURE DIVISION. s.
Source Program Organization and Format Shared Data 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.
COBOL Character Set Language Elements Table 3-2. Punctuation Characters Character Name of Character Space , Comma ; Semicolon : Colon . Period " Quotation mark ( Left parenthesis ) Right parenthesis = Equal sign Table 3-3.
Punctuation Characters Language Elements Punctuation Characters Punctuation characters belong to the COBOL character set and are listed in Table 3-2.
Separators Language Elements Comma or Semicolon A comma (,) or semicolon (;) that immediately precedes one or more spaces acts as a comma separator or semicolon separator, respectively. Except where explicitly prohibited, you can use comma and semicolon separators anywhere that the specifications permit or require space separators. Colon The colon (:) is a separator that COBOL uses to distinguish a reference modifier from a subscript.
Comments Language Elements Comments All characters appearing within a comment-entry or comment line are a part of that entity and are never interpreted as separators in that context. Nonnumeric and National Literals Characters appearing within a character-string that represents a nonnumeric or national literal are components of its value and are never interpreted as separators.
COBOL Words Language Elements COBOL Words char-1 ns char-n ns VST741.vsd char-1 char-n If the COBOL word is a level-number or segment-number, then char-1 is a digit. If the COBOL word is a section-name or paragraph-name, then these rules apply: • • • • char-1 is a letter (uppercase or lowercase) or a digit. char-n is a letter (uppercase or lowercase), a digit, or a hyphen (-). The last character cannot be a hyphen. The maximum length of the word is 30 characters.
COBOL Words Language Elements With the exception described in the preceding paragraph, every name that you reference in a COBOL program must be unique, either because no other name has the same spelling (including hyphenation), or because the name is part of a hierarchy of names (such as a data-name defined within a record). In the latter case, you can qualify the name with one or more of the higher-level names.
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 Names Every name that you reference in a COBOL program must be unique, either because no other name has the same spelling (including hyphenation) or because the name is part of a hierarchy of names (such as a data-name defined within a record). In the latter case, you can qualify the name with one or more of the higher-level names. You must specify enough higher-level names to make the name unique, but you need not specify all levels.
COBOL Words Language Elements Qualified LINAGE COUNTER: LINAGE-COUNTER OF file-name IN VST005.vsd Within the Data Division, you can use file-names from file description (FD) or sortmerge file description (SD) entries and data-names from data description entries for qualification. Within the levels of qualification, file-names (names associated with level indicators FD and SD) are most significant, then data-names for level-01 items, and then data names for level-02 items, and so on to level-49 items.
COBOL Words Language Elements • A word can be defined as a paragraph-name more than once in a source program. If more than one paragraph in the same section of a source program has the same name, no statement anywhere in the program can refer to any of those paragraphs by name. If two or more sections of a source program each contains a paragraph with the same paragraph-name, unqualified references to that paragraph-name are acceptable only within such sections—all other references must be qualified.
Literals Language Elements It is possible to define a collection of program elements such that even complete qualification fails to establish uniqueness for some of their names. In this case, your program can never reference these elements. To avoid this situation, follow these rules: • • • • • • Do not define two identical data-names subordinate to a data structure unless their references can be made unique through qualification by intermediate data structure names.
Literals Language Elements Decimal Numeric Literals A decimal numeric literal is a character-string that has the value of the sequence of its digits. ns digits ns + dp - ns digits dp ns digits VST743.vsd digits is a string of one to 18 digits. The total number of digits in a decimal numeric literal cannot exceed 18. dp is a decimal point. It is a period (“.”) unless the program contains the DECIMAL POINT COMMA phrase in the SPECIAL-NAMES paragraph, in which case it is a comma (“,”).
Literals Language Elements Example 3-2. Integer Decimal Numeric Literals +601 -234116 0 15 1234. , (an integer followed by a period separator and a comma separator) Example 3-3. Noninteger Decimal Numeric Literals +601.1 89.6 0.0051 -.1 1234., (a noninteger followed by a comma separator) Hexadecimal Numeric Literals ns H ns ns " hex-digit ns hex-digit " ns VST612.vsd 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.
Literals Language Elements Simple Nonnumeric Literals A simple nonnumeric literal is a character-string that has the value of the sequence of its characters. " char " VST744.vsd char is an alphanumeric character or a quotation mark ("). If char is a quotation mark, it must be immediately followed by another quotation mark. Each pair of quotation marks represents a single embedded quotation mark. A simple nonnumeric literal can have at most 160 characters, excluding the delimiting quotation marks.
Literals Language Elements Hexadecimal Nonnumeric Literals ns X ns ns hex-digit " ns hex-digit ns " VST613.vsd 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. A hexadecimal nonnumeric literal can have at most 320 hexadecimal digits (160 pairs), excluding the delimiting quotation marks. A hexadecimal nonnumeric literal can appear anywhere that a simple nonnumeric literal can appear. Example 3-6.
Literals Language Elements 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. HP COBOL accepts only the double quotation mark ("), not the apostrophe ('), as a quotation mark. The value of a national literal is the ordered sequence of characters in its representation, excluding the delimiting quotation marks.
Literals Language Elements In general, you can use a figurative constant wherever the syntax rules of the language require or permit a literal. The exceptions to this rule are: • • • • When the literal must be a numeric literal, the only acceptable figurative constant is [ALL] ZERO[[E]S] (which generates the numeric value 0). The other forms of figurative constant always generate a nonnumeric value; therefore, such forms are not acceptable when the context requires a numeric value.
Literals Language Elements The result of associating a figurative constant that represents a nonnumeric value with a numeric or numeric-edited data item is defined only when the string the compiler generates from the figurative constant contains only digit characters. In this case, the generated nonnumeric value has the appearance of an integer whose length (in terms of the number of digits it contains) is the same as the length of the associated data item. Table 3-5.
PICTURE Character-Strings Language Elements PICTURE Character-Strings PICTURE character-strings (character-strings in the PICTURE clause) use the COBOL character set as described in PICTURE Clause. The editing characters in Table 3-6 specify the editing operations that a process performs on data when storing it in data items. The compiler recognizes these characters as editing characters only within PICTURE clauses.
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.
Level-Numbers Data Fundamentals Example 4-1. Level Numbers FD * 01 * * * * 01 01 BRANCH-OFFICE-FILE LABEL RECORDS ARE OMITTED RECORD CONTAINS 100 CHARACTERS DATA RECORDS ARE ADDRESS-RECORD, PERSONNEL-RECORD, MISC-RECORD. A record follows. ADDRESS-RECORD. A data structure follows. 05 OFFICE-NUMBER. An elementary item follows. 10 DISTRICT PICTURE 99. Condition-names follow. 88 NEW-YORK VALUE 21. 88 TAMPA VALUE 43. 88 OMAHA VALUE 55. ... 10 REGION PICTURE 999. 05 OFFICE-ADDRESS. 10 STREET PICTURE X(25).
Records Data Fundamentals Records A record is a sequence of character positions. It can be an elementary data item or a data structure. Its data description entry determines its internal structure (see PICTURE Clause). Records can be of fixed length or variable length. COBOL programs manipulate logical records and physical records. Most of the data in a typical COBOL program is in records. When a program reads data from or writes data to a file, the unit of transmission is the record.
Records Data Fundamentals The concept of logical records also applies to data outside files. You can group data into logical records in all sections of the Data Division. Once you describe the relationship between logical records and physical records, record manipulation is the responsibility of the HP COBOL or CRE run-time routines and the NonStop operating system. Record Elements In COBOL, the lowest subdivisions of a record (that is, those not further subdivided) are called elementary items.
Files Data Fundamentals When a file has the fixed-length record type attribute, every record contains the same number of character positions (bytes) and all input and output operations on the file process this fixed size. A program can specify more than one record description for the file, and some record descriptions can describe different numbers of character positions, but every record existing in the file still has the same fixed length.
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 2-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/R 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.
REDEFINES Clause Data Fundamentals REDEFINES Clause When a data structure that is the object of a REDEFINES clause contains implicit FILLER bytes, their character positions are included in the character positions redefined. 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.
Qualifiers Data Fundamentals Topics: • • • • • Qualifiers Subscripts Reference Modifiers 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.
Subscripts Data Fundamentals Subscript Syntax data-name ( ) subscript condition-name VST006.vsd data-name is either a data item described with an OCCURS clause or a data item subordinate to a data item described with an OCCURS clause. If data-name is qualified, the subscripts follow the qualifiers. 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.
Subscripts Data Fundamentals Example 4-7. Subscripting for Tables MOVE TOTAL OF REPORT-MARK (8) TO REPORT-TOTAL-8. MOVE MONTH-NAME (MONTH-NUMBER + 2) TO REPORT-MONTH. MOVE MATRIX (ROW COLUMN) TO OUTPUT-DISPLAY-LINE. 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.
Reference Modifiers Data Fundamentals Reference Modifiers Reference modifiers allow you to reference an arbitrary portion of a data item’s value, which is important in some applications. With reference modifiers, you define an elementary item by specifying a leftmost character position within a data item and a length for the new item. The unique data item created by reference modifiers can be used not only as a sending item, but also as a receiving item—you can store a new value into it.
Data Fundamentals Reference Modifiers If length is absent, the defined item begins with leftmost-characterposition and ends with the last character of identifier; thus the length of the defined item is (data-name-length - leftmost-character-position ) + 1 where data-name-length is the length of identifier. Rules for Reference Modifiers These rules for reference modifiers apply directly if the data item referenced by identifier is described as alphabetic or alphanumeric.
Data Fundamentals Identifiers Example 4-8. Reference Modifiers A program contains these data descriptions: 01 SPREAD. 03 LTH PIC 99 VALUE 10. 03 MM. 05 FF PIC A(10) VALUE "MARGARINE ". 05 GG PIC $$9.99. The same program contains these statements: MOVE 3.15 TO GG DISPLAY MM DISPLAY MM (1:LTH) MOVE "GONE" TO MM (11:) DISPLAY MM Executing the program produces these display: MARGARINE $3.
Data Fundamentals Condition-Names qualified-name is defined in Qualified Names. subscript is defined in Subscript Syntax. 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 data-name ; it represents the leftmost character of the portion of data-name you are selecting. length is an arithmetic expression.
Data Fundamentals Condition-Names Example 4-10. Condition-Name 01 INVENTORY. 02 PART-NUMBER OCCURS 100 03 PREFIX 03 USE-CODE 88 RESTRICTED-USE 03 SUPPLIER-SUFFIX TIMES. PICTURE 99. PICTURE 9. VALUE 1. PICTURE 99. 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.
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 Environment Division Syntax Environment Division Syntax ENVIRONMENT DIVISION . CONFIGURATION section INPUT-OUTPUT section VST014.vsd ENVIRONMENT DIVISION. is the division header. It must begin in area A. CONFIGURATION section is defined in Configuration Section. INPUT-OUTPUT section is defined in Input-Output Section.
Environment Division Configuration 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 . SOURCE-COMPUTER paragraph OBJECT-COMPUTER paragraph SPECIAL-NAMES paragraph VST015.vsd SOURCE-COMPUTER paragraph is defined in SOURCE-COMPUTER Paragraph.
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 SIZE WORDS CHARACTERS MODULES VST018.vsd integer must be in the range 1 through 32,767 but is otherwise ignored.
Environment Division OBJECT-COMPUTER Paragraph PROGRAM COLLATING SEQUENCE Clause The PROGRAM COLLATING SEQUENCE clause enables you to specify an arbitrary collating sequence for use in nonnumeric comparisons and changes the values of the figurative constants HIGH-VALUE, HIGH-VALUES, LOW-VALUE, and LOW-VALUES. This clause has no effect on national data items, which are collated in ascending order of binary value (of the 2-byte pair representing the character).
Environment Division OBJECT-COMPUTER Paragraph CHARACTER-SET Clause The CHARACTER-SET clause is an HP COBOL extension that enables you to specify the national character set defining the ALPHABETIC data class. character-set-type CHARACTER-SET IS VST021.
Environment Division OBJECT-COMPUTER Paragraph If you specify a character-set-type other than USASCII or UK, the ALPHABETIC class includes additional characters (see Table 6-2). The French character sets differ only in non-ALPHABETIC characters. Table 6-2.
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 on-phrase switch-on ON STATUS IS VST025.vsd 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 You cannot use the mnemonic-name in ACCEPT statements, because CONSOLE maps to $0, an output-only device. ° 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 literal-1 is an unsigned integer literal or a nonnumeric literal, but not a symboliccharacter figurative constant. 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).
Environment Division SPECIAL-NAMES Paragraph Example 6-4. Defining a Class of Octal Numerics OCT IS "0" THRU "7" 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 Paragraph If the FILE-CONTROL paragraph is present, it must be the first paragraph in the InputOutput Section. FILE-CONTROL file-control-entry . VST036.vsd 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 File-Control Entries for Sequential Files HP COBOL supports two types of sequential disk files: • • A disk file created as a sequential file (also called an entry-sequenced file on NonStop systems) An unstructured disk file Also, a COBOL file defined as sequential can be assigned to a tape file, to a device such as a terminal or process, or to $RECEIVE. See OPEN and RECEIVE-CONTROL Paragraph.
Environment Division FILE-CONTROL Paragraph 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 RESERVE number 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. number is a numeric literal, an unsigned integer.
Environment Division FILE-CONTROL Paragraph ORGANIZATION clause SEQUENTIAL ORGANIZATION IS VST041.vsd makes the organization of the file sequential (the default). PADDING CHARACTER clause pad-char PADDING IS CHARACTER VST042.vsd specifies pad-char, the character to be used for padding on sequential files on unlabeled magnetic tape when the physical record size (block size) exceeds the logical record size. HP COBOL handles this phrase as a comment, except for checking if pad-char is acceptable.
Environment Division FILE-CONTROL Paragraph rec-delim must be IMPLICIT, the only name predefined by HP COBOL for use in this clause. IMPLICIT signifies that the record delimiter is implied by the size of the records on the magnetic tape. ACCESS MODE clause ACCESS SEQUENTIAL MODE IS VST044.vsd makes the access mode of the file sequential (the default). ALTERNATE RECORD KEY clause ALTERNATE RECORD IS KEY alt-key WITH DUPLICATES VST045.vsd makes alt-key an alternate record key.
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 IO 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 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 RESERVE number 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 ORGANIZATION clause RELATIVE ORGANIZATION IS VST048.vsd makes the organization of the file relative. (The default is sequential.) 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.
Environment Division FILE-CONTROL Paragraph rel-key is an integer data item to be used as a prime key to specify records within the file. It must be large enough to hold the maximum record number. Its definition cannot be in a record description entry for that file. It can be in another record description entry or in the Working-Storage Section, Extended-Storage Section, or Linkage Section. ALTERNATE RECORD KEY clause ALTERNATE RECORD IS KEY alt-key WITH DUPLICATES VST045.
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. In the non-CRE environment, number must be in the range 1 through 8, and its value is interpreted: Value of number Effect 1 No buffering or HP COBOL Fast I-O 2 or greater Sequential block buffering for input and buffered cache for output if the assigned file qualifies number is the number of blocks to buffer.
Environment Division FILE-CONTROL Paragraph 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 record key or of an alternate key. The default access mode is sequential. DYNAMIC makes the access mode of the file dynamic.
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 alt-key size and location 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 operating system File Utility Program (FUP). (For information about FUP, see the File Utility Program (FUP) Reference Manual.
Environment Division FILE-CONTROL Paragraph The file-control entry can contain at most one ALTERNATE RECORD KEY clause that describes a particular alternate record key of the file. If a file in the file system is defined as having alternate record keys to which the COBOL program does not make any reference, you do not need to specify them in the File-Control paragraph.
Environment Division FILE-CONTROL Paragraph Example 6-7. Indexed File With One Alternate Key INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT RECEIVABLES-MASTER ASSIGN TO "=RECMAST" ORGANIZATION IS INDEXED RECORD KEY IS INVOICE-NUMBER ALTERNATE RECORD KEY IS COMPANY-NAME WITH DUPLICATES, FILE STATUS IS IO-STATUS. ... DATA DIVISION. FILE SECTION. FD RECEIVABLES-MASTER LABEL RECORDS ARE OMITTED RECORD CONTAINS 39 CHARACTERS. 01 INVOICE-RECORD. 05 INVOICE-NUMBER PICTURE 9(7). 05 COMPANY-NAME PICTURE X(15).
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 File-Control Entries for Sort-Merge Files A file-control entry for a sort-merge file defines a scratch file for a sort-merge process. SELECT clause ASSIGN clause . VST055.vsd SELECT clause SELECT sd-name VST056.vsd sd-name is a COBOL file-name (the file-name in a sort-merge file description entry). ASSIGN clause ASSIGN system-file-name TO define-name-literal VST039.
Environment Division FILE-CONTROL Paragraph Usage Considerations: • Different Devices for Files The sort-merge file is a temporary file used by a SORT or MERGE statement. Programs that define their sort-merge file on a different device than the input or output file of the SORT or MERGE statement must run more efficiently than those defining input or output files on the same device as the sort-merge file.
Environment Division I-O-CONTROL Paragraph 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. If the I-O-CONTROL paragraph is present, it must follow the FILE-CONTROL paragraph, because it refers to files established by file-control entries. Sequential, relative, or indexed file: 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 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 More than one SAME clause can be included in a program; however, there are some restrictions on the usage of SAME clauses: • • A file name must not appear in more than one SAME AREA clause or in more than one SAME RECORD AREA clause.
Environment Division I-O-CONTROL Paragraph same-file is the sd-name in the sort-merge file description entry or the fd-name in the file description entry for the file. Usage Considerations: • File Organization and Access Modes The files specified in the SAME AREA clause can have different types of organization or different access modes. • 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.
Environment Division I-O-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 RECEIVE-CONTROL Paragraph You can write server processes in HP COBOL. The system file process named $RECEIVE is the communication mechanism between a requester process and a server process or between the operating system and any process (as if the process were a server). When a COBOL server resumes execution upon the completion of a READ on $RECEIVE, it can require information about the source of the message that was delivered.
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 can only appear in a CRE program; enables COBOL external files to share communication with $RECEIVE and to share $RECEIVE properly with FORTRAN.
Environment Division RECEIVE-CONTROL Paragraph Each entry in the receive-control table records which requester opened the server process and which open operation the requester used (if a requester opens the server process more than once). table-length is an unsigned integer numeric literal in the range 1 through 255. The default value is 1. EXTENDED-STORAGE allows saved messages to be stored in extended storage.
Environment Division RECEIVE-CONTROL Paragraph REPLY CONTAINS phrase REPLY CONTAINS reply-length CHARACTERS file-name RECORD VST066.vsd specifies the number of characters of a reply message that are to be saved in the reply table. The default is 0. reply-length is an unsigned integer numeric literal. Its value is the maximum number of characters from a reply message to be saved in the reply table.
Environment Division RECEIVE-CONTROL Paragraph message is an alphanumeric item that is: ° Defined in the Working-Storage Section, Extended-Storage Section, File Section, or Linkage Section ° ° ° ° ° Aligned on an even character boundary within a record At least 32 characters long Not a table Not modified by a reference Not of a variable size (not a data structure that contains an OCCURS DEPENDING ON clause) The contents of message are updated automatically after a file assigned to $RECEIVE is success
Environment Division RECEIVE-CONTROL Paragraph MEMORY-LOCK-FAILURE STATUS-3270 MESSAGE-CANCELLED STOP MESSAGE-MISSED SYSTEM NETWORK TIME-SIGNAL NEWPROCESS-COMPLETION In the CRE, message-type has one of these values: 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-FILE
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 In the COBOL85 environment, if the RECEIVE-CONTROL paragraph’s TABLE OCCURS phrase includes EXTENDED-STORAGE, the reply table is in the ExtendedStorage Section. In the CRE, if the reply table exceeds an internal threshold value, the reply table is in the Extended-Storage 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 Example 6-10. MESSAGE SOURCE Phrase (CRE) 01 SOURCE-MESSAGE. 05 MESSAGE-TYPE 05 ENTRY-NUMBER 05 FILLER 05 PHANDLE 05 FILLER PICTURE PICTURE PICTURE PICTURE PICTURE S999 USAGE IS COMPUTATIONAL. 999 USAGE IS COMPUTATIONAL. X(4). X(20). X(4).
Environment Division RECEIVE-CONTROL Paragraph Table 6-8.
Environment Division RECEIVE-CONTROL Paragraph LOGICAL-OPEN and LOGICAL-CLOSE are conventions that enable a program to keep track of its active requesters simply and directly. LOGICAL-OPEN selects only the first OPEN message from each new requester. OPEN messages from requester backups are automatically handled by the run-time routines and not passed to the program. Similarly, LOGICAL-CLOSE selects only the final CLOSE message from a requester.
Environment Division RECEIVE-CONTROL Paragraph Table 6-10. REPORT Clause Message Types in the CRE (page 2 of 2) Message Type Code Message Type CRE COBOL85 Meaning NEWPROCESSNOWAITCOMPLETION -12 -12 NEWPROCESSNOWAIT completion NODE-DOWN -110 -08 Lost communication with node NODE-UP -111 -08 Established communication with node OPEN -103 -30 Open POWER-ON -11 -11 Power on PROCESS-CREATECOMPLETION -102 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 GLOBAL Clause The GLOBAL clause makes file-name a global name, meaning that it is available to every program contained within the program that describes it. The contained programs do not contain a description of the file. For an explanation of global names, see Global and Local Names. GLOBAL IS VST076.
Data Division File Description Entries BLOCK CONTAINS Clause Use the optional BLOCK CONTAINS clause to specify the number of logical records or the number of character positions in a physical record on tape or unstructured disk files only. For these types of files, if this clause is absent, the compiler assigns a block size of one logical record. The operating system handles all other file blocking and deblocking in a way that is transparent to the COBOL program.
Data Division File Description Entries When blk-1 is present, its value must be less than or equal to that of blk-2. When the RECORDS option is not specified, the value of blk-1 must be greater than or equal to the minimum record size of the file; otherwise, the value of blk-1 must be greater than 0. Although tape devices are capable of handling blocks of 32,767 characters, unstructured disk files are limited to a block size of 4,096.
Data Division ° File Description Entries Unstructured Disk Files If the actual file associated with the COBOL file at open time is an unstructured disk file, then blocking/deblocking occurs if the logical record size is an even number of character positions or the file has the odd-length access attribute; otherwise the BLOCK CONTAINS clause is ignored (that is, logical records are physically read or written one at a time).
Data Division File Description Entries «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.vsd length-min is an unsigned integer literal that specifies the minimum length, in characters, of variable-length records. Its value is in the range 0 through 32,767.
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 assume that the printer is positioned at the first line, omit the page eject, and advance the printer by top lines. Examples: Lines Skipped Value of top Page-Eject Issued? Additional Total 0 No 0 0 1 No 1 1 2 No 2 2 3 Yes (skips 3) 0 3 4 Yes (skips 3) 1 4 5 Yes (skips 3) 2 5 6 Yes (skips 3) 3 6 This logic applies only during initial positioning of the first logical page.
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 RECORD DATA 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 Data Description Entries The data description entries for unrelated items (level-77 items) or records or both follow the Working-Storage Section header.
Data Division Data Description Entries In Example 7-6, the Working-Storage Section has five record description entries. Example 7-6. Record Description Entries WORKING-STORAGE SECTION. 01 DATA-TO-CHECKPOINT. 05 USER-INPUTS. 10 COMMAND-IN 10 TRAN-CODE 10 REPORT-TO-PRINT 10 REPORT-NUMBER 05 PERFORM-FLAGS 88 BAD 88 GOOD 01 01 CURRENT-DATE. 05 CURRENT-YEAR 05 CURRENT-MONTH 05 CURRENT-DAY PICTURE PICTURE PICTURE PICTURE PICTURE REPORT-HEADING-1.
Data Division Initializing Data Items Initializing Data Items The value to which a data item is initialized is determined by: • EXTERNAL clause A data item described with an EXTERNAL clause (an external data item) cannot have a VALUE clause and is not affected by events that cause internal data items to be initialized. Its contents are unpredictable until a program assigns a value to it. Thereafter, it retains the last value assigned to it throughout the current execution of the run unit.
Data Division Extended-Storage Section Extended-Storage Section Note. TNS/R HP COBOL does not need an Extended-Storage Section. The NMCOBOL compiler handles any data items that are described in the Extended-Storage Section as if they were described in the Working-Storage Section, without issuing a warning. The Extended-Storage Section is similar to the Working-Storage Section, but it describes data to be stored in the single area of extended memory each program can address on a NonStop operating system.
Data Division Addressing Addressing Items described in the Extended-Storage Section are accessed using 32-bit addressing. Extended-storage items are allocated in a single extended data segment, which is managed entirely by the run-time routines. Instructions that involve 32-bit addresses consume more space in the object file and execute at a slightly slower speed than the instructions that involve 16-bit addresses. Size Limits In Section 20, HP COBOL Limits, see Data in a run unit.
Data Division Data Description Entries and Initializing Data Items 01-data-description 77-data-description are described under Working-Storage Section, except that each data description entry can include this clause: ACCESS MODE IS EXTENDED-STORAGE STANDARD VST097.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).
Data Division CALL Statement and USING Phrase EXTENDED-STORAGE specifies extended (32-bit) addressing. This is the default. STANDARD specifies standard (16-bit) addressing. STANDARD cannot be specified for a program that is to be called with a CALL identifier statement. The compiler cannot check for this, so the result of such a call is undefined. Note. If you specify STANDARD in a TNS/R program, the NMCOBOL compiler issues a warning and uses 32-bit addressing.
Data Division CALL Statement and USING Phrase Statements within the Procedure Division of the called program can refer to any items defined in the Linkage Section of the program. Global items can be referenced by contained programs. The Linkage Section can contain matched and unmatched items.
Data Division Index-Names Index-Names A Procedure Division reference to a Linkage Section data item in the called program refers to a location in the calling program; however, this convention does not extend to index-names. The index-name of a table in the calling program and the index-name of a table in the called program always refer to separate indexes. This remains true even when the names of the indexes are the same in the calling program and the Linkage Section of the called program.
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 Data Name or FILLER Keyword If the data-name appears, it specifies the name of the data item being described. You can give an entry a name so that the name can be used to refer to the entry. If you do not need to refer to the entry, you can give it the name FILLER, or omit the name entirely. Such unnamed or FILLER items act as place holders in records where not all the fields are referred to or as convenient names for constants, such as in report headings.
Data Division ° General Considerations 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. • Clauses Applying Only to Elementary Data Items The PICTURE, SYNCHRONIZED, JUSTIFIED, and BLANK WHEN ZERO clauses can be specified only for an elementary data item.
Data Division ° General Considerations Relationship with File Description Entries In the File Section, data description entries that describe records follow file description entries or sort-merge file description entries. The file description or sort-merge file description entry is not part of the data description entry (see Example 7-8). The record description entry defines a record area associated with the file named in the file description entry. Note.
Data Division FILLER Keyword FILLER Keyword The FILLER keyword, explicit or implicit, substitutes for a data-name when it is not important that an item have a name. It is allowed on elementary or data structures. Commonly, FILLER is used when you build records in the Working-Storage Section or Extended-Storage Section for heading lines or error messages, where most of the text is groups of literals. Example 7-10. FILLER Keyword WORKING-STORAGE SECTION. 01 HEAD-1. 05 FILLER PIC X(10) VALUE "PART NUM".
Data Division REDEFINES Clause Example 7-11. REDEFINES Clause WORKING-STORAGE SECTION. 01 RECORD-IN. 05 RECORD-CODE 05 RECORD-DETAIL 05 RECORD-SUBTOTAL 01 RECORD-TOTAL REDEFINES 05 TOTAL-1 05 TOTAL-2 05 TOTAL-3 05 TOTAL-4 05 TOTAL-5 PIC 9. PIC X(30). PIC 9(3)V99. RECORD-IN. PIC 9(5)V99. PIC 9(5)V99. PIC 9(5)V99. PIC 9(5)V99. PIC 9(6)V99.
Data Division • REDEFINES Clause Redefined Item Cannot Include OCCURS or REDEFINES The description of data-name-2 cannot include an OCCURS clause or REDEFINES clause; however data-name-2 can be subordinate to an item containing one or both clauses, and items subordinate to data-name-2 can contain one or both clauses. Because an OCCURS clause can occur in the description of data-name-1, it is common to declare a record first and then to declare an array that redefines the same storage.
Data Division • REDEFINES Clause Complete Description of Restrictions on Entry Order The first redefinition of a data item must begin immediately after the last data description entry associated with that item. Additional redefinitions can appear immediately after the first one in any convenient order.
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 Examples of floating insertion editing: ° Source Item PICTURE Edited Result 123 $$999 $123 1234 $$$$$ $1234 2 $$999 $002 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.
Data Division PICTURE Clause You specify zero suppression and replacement by using a string of one or more Z s or asterisks to represent leading numeric character positions that are to be replaced when any of those positions in the data are zero. Any of the simple insertion characters embedded in the string of symbols or to the immediate right of this string are part of the string.
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) Declaration: 05 RETURN-CODE PIC 99. 88 END-OF-FILE 88 ERROR-ON-READ 88 PERMANENT-ERROR 88 ERROR-ON-WRITE VALUE VALUE VALUE VALUE 01. 02. 03. 04. 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.
Data Division Descriptions of Condition-Names for Values (Level 88) As the syntax presentation shows, the only clause permitted in a condition-name entry is the VALUE clause containing the value, values, or range of values associated with the condition-name; therefore, the characteristics of the conditionname are implicitly those of the condition variable. • 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.
Data Division Descriptions of Condition-Names for Values (Level 88) HP COBOL Manual for TNS and TNS/R Programs —522555-006 7- 98
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 WORKING-STORAGE SECTION. 77 A PIC 99 COMP VALUE 99. 77 B PIC 99 COMP VALUE 88. 77 C PIC 99 COMP. 77 D PIC 99 COMP. PROCEDURE DIVISION. ... * TRAP2 directive does not catch this size error: COMPUTE C = A + B. COMPUTE D = C - B. DISPLAY D. * 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 “47” The execution of a READ or START statement is attempted on a file not open in the Input or I-O mode. “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.
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 If recovery from the exception is possible (either when Status Key 1 is “3,” or when it is “9” and Status Key 2 is not “0”), and the declarative procedure has not voluntarily terminated execution of the process, continue the execution: a. If the statement that caused the condition includes any negative exception handling phrase (NOT AT END or NOT INVALID KEY), transfer control to that phrase’s imperative statement.
Procedure Division Arithmetic Operations The value of the file position indicator becomes undefined when an operation exceeds its time limit. Because you cannot determine where in the operation the time limit was exceeded, you cannot necessarily try the operation again immediately at the current record. Overhead When a file is opened with timed I-O enabled, each I-O statement incurs more overhead than a file opened without a time limit. Avoid using timed I-O unnecessarily.
Procedure Division Common Features of Arithmetic Statements Topics: • • • Common Features of Arithmetic Statements Arithmetic Expressions Arithmetic Precision Common Features of Arithmetic Statements This section describes the common features of the arithmetic statements, which are: • • • • • Data Conversion and Alignment Composite of Operands Intermediate Data Items Multiple Results Incompatible Data Data Conversion and Alignment The data descriptions of the operands need not be the same; any neces
Procedure Division Common Features of Arithmetic Statements Intermediate Data Items For each arithmetic operation, an intermediate data item holds the result value until that value is either used as an operand in another operation or assigned to a receiving data item. The size of the intermediate data item depends on the operations and data items used in the operation and varies from 16 bits (about four digits) to 128 bits (about 39 digits).
Procedure Division Arithmetic Expressions Arithmetic Expressions num-id + - num-lit arith-expr arith-expr + * / ** ( arith-expr ) VST739.vsd num-id is the identifier of a numeric data item. num-lit is a numeric literal. arith-expr is an arithmetic expression. The value of an arithmetic expression is a numeric value.
Procedure Division Arithmetic Expressions Operands An operand is a numeric literal, the identifier of a numeric data item, or any arithmetic expression enclosed within balanced left and right parentheses. The identifiers and literals appearing in an arithmetic expression must represent numeric data items and numeric literals upon which arithmetic can be performed. Arithmetic Operators Each operator in Table 8-13 must be preceded and followed by a separator (usually spaces or parentheses). Table 8-13.
Procedure Division Arithmetic Expressions Formation and Evaluation Rules Parentheses can be used to specify the order in which the elements of an expression are to be evaluated. Expressions within parentheses are evaluated first. Within nested parentheses, evaluation proceeds from the least inclusive set to the most inclusive set. When parentheses are not used, or parenthesized expressions are at the same level of inclusiveness, the hierarchical order of execution is shown in Table 8-14. Table 8-14.
Procedure Division Arithmetic Precision Table 8-16.
Procedure Division Arithmetic Precision The largest value HP COBOL can store is the unsigned COMPUTATIONAL-5 value 18,446,744,073,709,551,615. The largest value HP COBOL can store associated with a DISPLAY or COMPUTATIONAL data item (independent of any decimal point or scale factor) is the 20-digit number which is the highest value for an unsigned 64-bit number. In evaluating arithmetic expressions, COBOL can manipulate intermediate values having up to 128 bits (about 39 digits).
Procedure Division Arithmetic Precision MULTIPLY Statement The number of fraction digits in the product is the sum of the number of fraction digits in the two operands. The number of accurate nonfraction digits in the product is the sum of the nonfraction digits in the two operands.
Procedure Division Arithmetic Precision Because the sum of the number of actual dividend digits and the number of appended zero digits cannot exceed 36, there are very few combinations of operands in a DIVIDE statement for which it is impossible to append enough zeros.
Procedure Division Arithmetic Precision The number of decimal places in the intermediate result (DR) is chosen first, then the number of integer places in the intermediate result is determined from that and the characteristics of the two operands. HP COBOL guarantees that the mathematical significance of results will be at least as good as application of these rules implies.
Procedure Division Conditional Expressions When a conditional expression compares two expressions, the compiler determines the smallest number of decimal places suitable for each of the expressions and then uses the larger of those numbers of decimal places. In a COMPUTE statement, the number of decimal places of the composite of operands of the receiving fields is the number of decimal places of the expression.
Procedure Division Simple Conditions Relation Conditions in General A relation condition causes a comparison of two operands. The relation condition has a truth value of TRUE if the relation exists between the operands; otherwise, it has a truth value of FALSE. Usage Considerations: • Terminology In the preceding syntax diagrams, the left-hand operand is called the subject of the condition; the right-hand operand is called the object of the condition.
Procedure Division • Simple Conditions Numeric Comparisons Numeric comparisons are made with respect to the algebraic values of the operands. The number of digits present in the representation of an operand is not significant. Comparison of numeric operands is permitted regardless of the manner in which their usage is described. Unsigned numeric operands are considered positive for purposes of comparison. Zero is considered a unique value regardless of its sign.
Procedure Division ° Simple Conditions Operands of equal size If the operands are of equal size, the process compares characters in corresponding character positions, starting with the leftmost character position and continuing until it either encounters a pair of unequal characters or exhausts the operands.
Procedure Division Simple Conditions Example 8-11. Simple Relation Conditions I + 1 > HIGH-I (I + 1) > HIGH-I HIGH-I < (I + 1) TAXABLE-INCOME GREATER THAN ZERO LAW-NAME = "MURPHY" "POOL" NOT EQUAL TROUBLE-SOURCE A-INDEX NOT > 23 Relation Conditions With Nonpointer Operands subject relationship object IS VST118.vsd subject object is an identifier, a literal, an arithmetic expression, an index-name. relationship GREATER NOT LESS THAN EQUAL TO > < = GREATER LESS OR THAN EQUAL TO >= <= VST119.
Procedure Division Simple Conditions 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. 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.
Procedure Division Simple Conditions Class Conditions The class condition determines whether the operand is numeric, alphabetic, lowercase alphabetic, uppercase alphabetic, or contains only characters in the set defined by a CLASS clause in the SPECIAL-NAMES paragraph of the Environment Division. identifier IS NOT NUMERIC ALPHABETIC ALPHABETIC-LOWER ALPHABETIC-UPPER class-name VST120.vsd identifier is the identifier of a data item for which either: • • It is described as USAGE DISPLAY.
Procedure Division Simple Conditions If the description of the tested item does not indicate the presence of an operational sign, the item belongs to the numeric class only if: ° The content of the item is numeric (consists entirely of the digit characters 0 through 9 ). ° No operational sign is present.
Procedure Division • Simple Conditions Class-name and NOT Class-name You cannot use the class-name and NOT class-name tests with a numeric data item. The result of the test is TRUE if the content of the data item consists entirely of the characters listed in the definition of the class-name in the SPECIAL-NAMES paragraph; otherwise the result is FALSE.
Procedure Division Simple Conditions Example 8-12. Conditional Variables WORKING-STORAGE SECTION. 01 ZIP-CODE. 03 ZIP-FIRST-3 PICTURE 999. ... 88 NEW-YORK VALUE IS 090 THRU 098, 100 THRU 149. 88 PENNSYLVANIA VALUE IS 150 THRU 196. ... PROCEDURE DIVISION. ... ELSE IF NEW-YORK MOVE "NY" TO STATE-FROM-ZIP ELSE IF PENNSYLVANIA MOVE "PA" TO STATE-FROM-ZIP ... IF STATE-INPUT NOT = STATE-FROM-ZIP PERFORM QUERY-ZIP-OR-STATE-CORRECTION.
Procedure Division Simple Conditions Sign Conditions The sign condition determines whether the algebraic value of an arithmetic expression is less than, greater than, or equal to zero. arithmetic-expression IS NOT POSITIVE NEGATIVE ZERO VST121.vsd arithmetic-expression is an arithmetic expression, as described in Arithmetic Expressions. Usage Considerations: • NOT Modifier When NOT appears, it and the next keyword are considered to form a single sign condition.
Procedure Division Complex Conditions Complex Conditions A complex condition is a combination of simple conditions and any of the logical operators NOT, AND and OR. Its truth value is the one that results from the interaction of the stated logical operators on the individual truth values of the simple conditions or conditions enclosed within parentheses. Table 8-17.
Procedure Division Complex Conditions Combined Conditions condition AND condition OR VST123.vsd condition is a simple or complex condition. Table 8-18.
Procedure Division Abbreviated Combined Relation Conditions Abbreviated Combined Relation Conditions COBOL enables you to abbreviate a sequence of complex relation conditions.
Procedure Division Abbreviated Combined Relation Conditions Table 8-19. Abbreviated Combined Relation Conditions Characteristics Example Simple relation conditions or negated simple relation conditions A=C are combined using AND and OR operators NOT A = B OR A = C in which a relation condition subject or subject and relational operator is repeated and there are no parentheses (except those delimiting subscripts or reference modifiers) within the sequence.
Procedure Division Condition Evaluation Rules Examples of abbreviated combined and negated relation conditions and expanded equivalents: Abbreviated Combined Relation Condition Expanded Equivalent A > B AND NOT < C OR D ((A > B) AND (A NOT < C)) OR (A NOT < D) A NOT EQUAL B OR C (A NOT EQUAL B) OR (A NOT EQUAL C) NOT (A GREATER B OR < C) NOT ((A GREATER B) OR (A < C)) NOT (A NOT > B AND C AND NOT D) NOT ((((A NOT > B) AND (A NOT > C)) AND (NOT (A NOT > D)))) (A + B - C) > D AND NOT < E OR F (A
Procedure Division Concatenation Expressions Using this order of evaluation, once a truth value for an entire complex condition is established, evaluation of the condition ceases. For example, in the complex condition A NOT < 1 AND A NOT > 10 AND B (A) > 5 no attempt is made to fetch B(A) if A is not a valid subscript, because determination that the first condition is FALSE guarantees that the complete complex condition is FALSE.
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 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, or the calling program was compiled by the COBOL85 compiler with the ENV LIBRARY directive, 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 or does not run in the CRE, 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 Binding or Linking a Program Called With a CALL identifier Statement Binding or linking a program called with a CALL identifier statement into a run unit is not automatic. Verify that all such programs are bound or linked into the run unit by doing one of: • ° ° Compile all the program units in a single source file.
Procedure Division Verbs • CALL Storage Allocation For programs with the INITIAL attribute, HP COBOL uses dynamic storage allocation, allocating space for data items in the Working-Storage Section each time the program is called and releasing it each time the program is exited. This can cause stack overflow, which can cause the run unit to terminate abnormally.
Procedure Division Verbs CALL The COBOL85 compiler determines the access mode of the parameters in one of these ways: ° The called program is found in an existing object file (either the object file named by mnemonic-name or an object file named in the SEARCH directive). The required parameter types are defined by the program in the existing object file. ° The called program has been compiled earlier in the current compilation.
Procedure Division Verbs ° ° ° • CALL Each program opens the file as an internal file with a separate file connector. The file name has the GLOBAL attribute. The file is declared in any program and is given the EXTERNAL attribute. Then the file belongs to the run unit, and any program in the run unit that declares the same file with the EXTERNAL attribute can share in its manipulation.
Procedure Division Verbs Example 9-8. Called Program That Calls Another Program (page 2 of 3) Level 1 Subprogram (source $DATA.MYSUBVOL.SUB1SRC, object $DATA.MYSUBVOL.SUB1OBJ) IDENTIFICATION DIVISION. PROGRAM-ID. COBSUB1. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP System. OBJECT-COMPUTER. HP System. SPECIAL-NAMES. FILE "$DATA.MYSUBVOL.SUB2OBJ" IS SUB2. DATA DIVISION. WORKING-STORAGE SECTION. 01 DATA-OUT PIC X(80) VALUE "I'M COBSUB1 ALIVE AND WELL". LINKAGE SECTION. 01 PARM1 PIC 99.
Procedure Division Verbs CALL Example 9-8. Called Program That Calls Another Program (page 3 of 3) DATA DIVISION. WORKING-STORAGE SECTION. 77 DATA-MESSAGE PIC X(80) VALUE "I'M COBSUB2 ALIVE AND WELL". LINKAGE SECTION. 01 PARM1 PIC 99. 01 PARM2 PIC XX. PROCEDURE DIVISION USING PARM1, PARM2. START-PROGRAM. DISPLAY DATA-MESSAGE DISPLAY PARM1 DISPLAY PARM2 DISPLAY "I WILL NOW RETURN TO THE MAIN PGM VIA COBSUB1".
Procedure Division Verbs CANCEL CANCEL CANCEL signals that you are done with a program that you called. On some computer systems, CANCEL releases memory used by a program that is no longer needed. On NonStop systems, CANCEL restores each specified program to its initial state (see Initial State). Nothing happens if a CANCEL statement specifies an initial program, a program that was not called, or a program that has already been cancelled. program-name CANCEL OF file-mnemonic IN identifier VST136.
Procedure Division Verbs CANCEL If a called program that does not have the INITIAL attribute opens an internal file, the file remains open until either: • • ° ° ° The called program closes the file. The calling program cancels the called program. The process terminates.
Procedure Division Verbs CHECKPOINT CHECKPOINT Note. • • Do not use this statement in the OSS environment. Before RVU D46.00 and G06.00, software product revision T8107AAT (run-time library T8108AAR), the NMCOBOL compiler ignores this directive and issues a warning. 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 • CHECKPOINT Sending Values to a Backup Process When CHECKPOINT executes, the values of the data items and file sync blocks are sent to the fault-tolerant facility in the backup process. If the primary process fails before another checkpoint is made, the backup begins processing from the current checkpoint. The set of values specified in any checkpoint must be sufficient for the backup process to continue processing correctly with only that information.
Procedure Division Verbs CLOSE CLOSE CLOSE terminates processing of one or more open files or reels of tape. An optional LOCK phrase prevents the program from reopening the file (unless the file is dynamically assignable—see #DYNAMIC). If a file is closed but not locked, the only I-O operation the process can perform on that file is an open operation. If the file is closed and locked, the process cannot perform any I-O operation on the file.
Procedure Division Verbs CLOSE for Sequential and Line Sequential Files UNIT REEL specify that the current reel is to be closed and rewound, and a new reel is to be mounted. REMOVAL specifies that the reel of a multiple-reel tape file be rewound and unloaded, and a new reel is to be mounted. NO REWIND specifies that the sequential file is to be left in its current position, not rewound. LOCK means the file associated with file-name cannot be opened again during the current run.
Procedure Division Verbs • CLOSE for Sequential and Line Sequential Files Closing Single-Tape and Multiple-Tape Files See Table 9-1. • Closing a File Open Under More Than One Name If a program has one operating system file open under more than one file name, closing one file name does not affect the availability of the operating system file through any other file name, except when the LOCK phrase is present.
Procedure Division Verbs • CLOSE for Relative, Indexed, and Queue Files ° ° The block is not transmitted to the file. ° ° Any applicable USE procedure executes. The close operation terminates immediately, setting any file-status variable associated with the file to 34 (for a sequential file) or 24 (for a relative or indexed file). The file is not closed.
Procedure Division Verbs COMPUTE LOCK means the file associated with file-name cannot be opened again during the current run. If the file is dynamically assignable, the LOCK phrase has no effect (see #DYNAMIC).
Procedure Division Verbs COMPUTE expression is an arithmetic expression. imp-stmt-1 is an imperative statement to be executed when a size error has been detected in the computation or in storing the result. 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.
Procedure Division Verbs COMPUTE Example 9-9. COMPUTE Statement (page 2 of 2) This statement specifies that the result be stored in COMPUTE-RESULT without being rounded: COMPUTE COMPUTE-RESULT = (((24.0 + 1) * (60 - 10)) / 125) ** 2 END-COMPUTE (The result is 100.) 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 CONTINUE CONTINUE CONTINUE is a no-operation statement. CONTINUE VST142.vsd Example 9-11. CONTINUE Statement IF SALARIED IF ANNUAL-SAL > 50000 IF BELOW-QUOTA CONTINUE ELSE PERFORM ADD-BONUS-TO-OVERPAID-SALESPERSON END-IF ELSE IF BELOW-QUOTA CONTINUE ELSE PERFORM ADD-BONUS-TO-FLUNKY END-IF ELSE IF OVERTIME ... Usage Considerations: • Effect of CONTINUE A CONTINUE statement has no effect on the execution of the program.
Procedure Division Verbs DELETE DELETE DELETE removes a record from a relative or indexed file that is open in I-O mode. DELETE file-name RECORD imperative-stmt-1 INVALID KEY NOT imperative-stmt-2 INVALID KEY END-DELETE VST143.vsd file-name is the name of a relative or indexed file that is open in I-O mode. imperative-stmt-1 is an imperative statement to be executed when the invalid-key condition arises during the delete operation.
Procedure Division Verbs DELETE Usage Considerations: • I-O Status Codes If the file being closed has an associated file-status data item, the DELETE 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 delete operation was successful. “23” The designated record does not exist. “30” The delete operation failed due to causes outside of COBOL. The specified record might or might not have been deleted.
Procedure Division Verbs • DISPLAY Record Deleted When File Access Mode is Random or Dynamic If the file’s access mode is random or dynamic, the record to be deleted is defined by the record key, or, for relative files, the relative key (indexed or prime key). If the designated record does not exist, an invalid-key condition occurs with I-O status code “23.” Example 9-12. DELETE Statement INPUT-OUTPUT SECTION. FILE-CONTROL.
Procedure Division Verbs DISPLAY 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. You must define mnemonicname in the SPECIAL-NAMES paragraph of the Environment Division. When you omit mnemonic-name, the process delivers the data to its output file, typically its home terminal.
Procedure Division Verbs • DISPLAY Specifying the Wrong Device If you specify a device that cannot be used for DISPLAY output, the process displays a run-time error message and the output on its home terminal. The error message includes this line: Device assigned to ACCEPT or DISPLAY not a legal device • Opening and Closing Devices The display operation opens and closes the terminal or printer (but not a process) for each DISPLAY statement.
Procedure Division Verbs • DIVIDE Displaying Records and Large Amounts of Data Use the WRITE statement to display records and character-strings longer than several lines. The DISPLAY statement is not designed to deliver logical records or large amounts of data to a device. • NO ADVANCING Phrase If you include the NO ADVANCING phrase, the device is not changed after it displays the final operand (for example, the device is not repositioned to the next line).
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.vsd divisor is the identifier of the elementary numeric data item or numeric literal that is the divisor.
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 DIVIDE GIVING REMAINDER 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.
Procedure Division Verbs ENTER ENTER ENTER calls a routine written in a language other than COBOL. (To call a COBOL routine, use CALL.) Note. If you use the ENTER statement in the OSS environment, see Mixed-Language Programs. In some implementations of COBOL, ENTER marks the beginning of an embedded routine in some other language. In HP COBOL, ENTER is analogous to CALL but is used to call a non-COBOL routine.
Procedure Division Verbs ENTER For the COBOL85 compiler, the absence or value of language determines these things: ° ° The protocol used to pass string parameters The language in which the called routine must have been written For the COBOL85 compiler: ° If language is absent, FORTRAN protocol is used to pass string parameters and the called routines must have been written in TAL.
Procedure Division Verbs ENTER parameter data-name literal ( arithmetic-expression ) file-name VST149.vsd is a value to be passed to the called routine. data-name can be qualified, subscripted, and include a reference modifier. If data-name is a TAL or pTAL string:length parameter, you can set its length with a reference modifier (see Restrictions on Calling TAL or pTAL Routines). literal is a numeric literal whose value corresponds to a value parameter in the routine being called.
Procedure Division Verbs ENTER Usage Considerations: • language If you call a routine with a particular value of language (or with language omitted), you must use the same value of language each time you call that routine in the same compilation unit. • file-mnemonic If you specify file-mnemonic but the compiler does not find the called routine in the associated object file, the compiler reports an error. For information on resolving external references, see Finding the Entered Program.
Procedure Division Verbs • ENTER Addressing Parameters All native instructions use 32-bit addressing. Some TNS instructions use 16-bit addressing and others use 32-bit addressing. Those that use 16-bit addressing execute faster, but cannot address data items in extended memory. The code in an called routine that handles parameters specified in the calling program is generated according to the addressing mode of the data descriptions in the called routine. Many COBOL data items are byte-addressed.
Procedure Division Verbs ° ENTER Pascal (TNS only) Each Pascal module uses the same addressing mode for all parameters and pointers it receives or passes—16-bit addressing and 16-bit pointer allocation by default, 32-bit addressing and 32-bit pointer allocation if the routine is compiled with the XMEM directive. (16-bit addressing is called the “smallmemory model” and 32-bit addressing is called the “large-memory model.”) All Pascal modules bound into one object file must use the same addressing mode.
Procedure Division Verbs ENTER In the non-CRE environment (but not the CRE), an HP COBOL program cannot call an HP C or HP C++ function for which any of these conditions are true: ° ° ° The function directly or indirectly allocates or deallocates controlled storage. The function performs HP C or HP C++ input-output operations. The function directly or indirectly accesses the HP C function getenv.
Procedure Division Verbs • ENTER Restrictions on Calling TAL or pTAL Routines If your HP COBOL program calls a TAL or pTAL routine that has a string:length parameter, you only need to give the name of the corresponding actual parameter, because the compiler can determine its length.
Procedure Division Verbs ENTER Example 9-17. HP COBOL Program Calling TAL Routine TAL procedure declarations: INT PROC SYS^PROCEDURE (T, I, FIX, N); STRING .T; ! REFERENCE ADDRESS INT I; ! VALUE FIXED(4) FIX; ! VALUE INT N; ! VALUE COBOL source code: WORKING-STORAGE SECTION. 77 T PIC X(40) 77 I PIC 9(4) 77 FIX PIC S9(13)V9999 77 RESULT PIC 9(4). ... PROCEDURE DIVISION. ... ENTER TAL "SYS^PROCEDURE" VALUE SPACES. VALUE ZERO COMP. VALUE -125641.3992 COMP.
Procedure Division Verbs ENTER COBOL ENTER COBOL HP COBOL compilers treat ENTER COBOL as a comment. In implementations that use ENTER to mark the beginning of an embedded routine in a language other than COBOL, the ENTER COBOL statement ends the embedded routine and the resumption of COBOL source code. ENTER . COBOL VST150.vsd EVALUATE EVALUATE defines a multiple-branch structure, a decision table.
Procedure Division Verbs EVALUATE subject identifier literal expression TRUE FALSE VST152.vsd identifier is any identifier (it can be qualified, subscripted, or reference-modified). literal is any literal. 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.
Procedure Division Verbs EVALUATE 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. A match occurs when the value of a subject differs from the value of the corresponding object or lies outside the range specified for the object.
Procedure Division Verbs EVALUATE THROUGH THRU indicate that a range of values is to be compared. Two operands combined by THROUGH or THRU must be of the same class (alphabetic, alphanumeric, or numeric). The two operands thus connected constitute a single selection object. match-imp-stmt is an imperative statement to be executed when the values of the objects in the associated object-list match the values of the corresponding subjects in the subject-list.
Procedure Division Verbs EVALUATE The EVALUATE statement extends the “case” statement concept by allowing several selection subjects and matching objects—the equivalent of a decision table. The EVALUATE statement in Example 9-21 uses the values of two distinct subjects to make its selection. Example 9-21. EVALUATE Statement With Two Distinct Subjects EVALUATE DEDUCTIONS ALSO SALARY WHEN 0 ALSO 0 THRU 14999.99 WHEN 0 ALSO 15000 THRU 29999.99 WHEN 0 ALSO 30000 THRU 49999.99 WHEN 1 THRU 2 ALSO 0 THRU 19999.
Procedure Division Verbs • EVALUATE Subject-Object Comparisons EVALUATE operates as if each corresponding subject and object were evaluated and assigned one of: ° ° ° ° A numeric or nonnumeric value A range of numeric or nonnumeric values TRUE FALSE The subject is determined: subject EVALUATE uses … identifier The value and class of the data item referenced by identifier literal The value and class of literal arithmetic expression The numeric value determined by the rules for evaluating arithme
Procedure Division Verbs • EVALUATE Execution of the EVALUATE Statement Execution of the EVALUATE statement begins with the comparison phase illustrated in Figure 9-3. A comparison is satisfied if one of these conditions is true: ° ° ° The object is ANY (and the value of the subject is irrelevant). The corresponding subject and object were both assigned TRUE or both assigned FALSE.
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 ? TRUE FALSE 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 Execute match-imp-stmt associated with qualifying object-list Control returns to point immediately after imperative statement? FALSE TRUE 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 Example 9-23. EXIT PERFORM Statement 0001-TEST-EXIT-PERF. INITIALIZE WS-ANS. INITIALIZE WS-NUMBER. INITIALIZE WS-NUMBER-PERF. INITIALIZE WS-TEST-RESULTS. DISPLAY "TEST EXITS-1 FOR EXIT PERFORM BEGINS". 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.
Procedure Division Verbs EXIT Example 9-24. EXIT PERFORM CYCLE Statement ?SYMBOLS IDENTIFICATION DIVISION. PROGRAM-ID. EXIT-PERFORM. DATA DIVISION. WORKING-STORAGE SECTION. 77 X PIC 999. 77 X PIC 999. 77 X PIC 999. PROCEDURE DIVISION. SUNRISE. DISPLAY "EXIT PERFORM TEST". MOVE 0 TO X MOVE 0 TO Y MOVE 0 TO Z * The loop appears to execute 200 times ... PERFORM UNTIL X=200 ADD 1 TO X * however, we exit after only 100 times.
Procedure Division Verbs • EXIT EXIT PROGRAM Statement in a Called Initial Program If an initial program that was called by another program executes an EXIT PROGRAM statement, the called program is cancelled (see CANCEL). • EXIT PROGRAM Statement in a Called Program That is Not Initial If a program that was called by another program and is not initial executes an EXIT PROGRAM statement, program execution continues with the executable statement following the CALL statement in the calling program.
Procedure Division Verbs GO TO GO TO Form Passes control to: Unconditional GO TO The beginning of a paragraph or section in the current program Conditional GO TO One of several procedures, depending on the value of a variable data item Unconditional GO TO Unconditional GO TO passes control to the beginning of a paragraph or section in the current program. GO TO procedure-name VST158.vsd procedure-name is the name of the procedure (paragraph or section) to which the process transfers control.
Procedure Division Verbs • Conditional GO TO Consecutive Imperative Statements in a Sentence When a GO TO statement includes procedure-name and the paragraph containing the GO TO statement is not referenced by an ALTER statement, the GO TO statement can be the last of a sequence of consecutive imperative statements within a sentence. Conditional GO TO Conditional GO TO passes control to one of several procedures, depending on the value of a variable data item.
Procedure Division Verbs • IF Debugging Declarative Procedures A GO TO statement in a debugging declarative procedure cannot refer to a nondebugging declarative procedure. A GO TO statement in a nondebugging declarative procedure cannot refer to a debugging declarative procedure. In Example 9-26, if BRANCH-FLAG equals 1, control passes to PROC-X. If BRANCH-FLAG equals 2, control passes to PROC-Y. If BRANCH-FLAG equals 3, control passes to PROC-Z.
Procedure Division Verbs Delimited-Scope Form ELSE ends statement-1. statement-2 is an imperative or conditional statement to be executed if the value of condition is FALSE. It can contain other IF statements. END-IF ends the scope of the IF statement, making it a delimited-scope statement. Without END-IF, the IF statement is a conditional statement that ends at the next period separator.
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-27. Simple Conditional IF Statement IF JULIAN-DAYS IS GREATER THAN 59, ADD LEAP-YEAR TO JULIAN-DAYS. Example 9-28. Delimited-Scope IF Statement IF JULIAN-DAYS IS GREATER THAN 59 ADD LEAP-YEAR TO JULIAN-DAYS END-IF Example 9-29 and Example 9-30 are equivalent. Example 9-29. 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-30.
Procedure Division Verbs Conditional Form Example 9-33.
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-36. 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 • INITIALIZE Determining the Sending Operands The initialize operation determines the sending operand in each implicit MOVE statement: ° If you include replacement, the sending operand is the literal or sender associated with the category of the receiving operand.
Procedure Division Verbs INSPECT INSPECT INSPECT scans a data item and counts and/or replaces occurrences of a single character or groups of characters.
Procedure Division Verbs INSPECT TALLYING 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 delim-string is the identifier of an 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 2. If source-string, compare-string, or delim-string is alphanumeric edited, numeric edited, or unsigned numeric, the source-string is inspected as though it had been redefined as alphanumeric and the INSPECT statement had been written to refer to the redefined item. 3.
Procedure Division Verbs • INSPECT TALLYING BEFORE and AFTER Phrases The BEFORE and AFTER phrases affect the comparison operation like this: 1. If no BEFORE or AFTER phrase is present, compare-string or the operand implied by CHARACTERS participates in the comparison operation. 2.
Procedure Division Verbs ° INSPECT TALLYING If CHARACTERS appears, tally is incremented by one for each character matched within source-string. In the Example 9-37, INSPECT TALLYING checks for spaces in a data item. If spaces are present (J-TALLY is greater than 0), the code reports an error. Example 9-37.
Procedure Division Verbs INSPECT TALLYING After execution of the INSPECT statement in Example 9-38, the counters have these values: Counter Value COUNTER-1 8 COUNTER-2 3 COUNTER-3 0 COUNTER-4 0 COUNTER-5 0 HP COBOL Manual for TNS and TNS/R Programs —522555-006 9 -101
Procedure Division Verbs HP COBOL Manual for TNS and TNS/R Programs —522555-006 9 -102 INSPECT TALLYING
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-40. 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 Example 9-42. LOCKFILE Statement With TIME LIMIT Phrase SELECT IN-MASTER-FILE ASSIGN ... ... FILE STATUS IS IN-MASTER-STATUS. ... FD IN-MASTER-FILE. ... PROCEDURE DIVISION. DECLARATIVES. DECL SECTION. USE AFTER ERROR PROCEDURE ON IN-MASTER-FILE. DECL-ROUTINE. IF GUARDIAN-ERR NOT = 40 STOP RUN END-IF END DECLARATIVES. ...
Procedure Division Verbs MERGE 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. MERGE can return records to an output procedure that can then write them to some file that is open to the COBOL program. MERGE merge-file key-specifier COLLATING SEQUENCE phrase USING phrase output-specifier VST177.
Procedure Division Verbs MERGE COLLATING SEQUENCE phrase SEQUENCE COLLATING alphabet-name IS VST179.vsd specifies a collating sequence for sorting. alphabet-name must be associated with a collating sequence in the SPECIAL-NAMES paragraph of the Environment Division (see SPECIAL-NAMES Paragraph). USING phrase USING merge-in-1 merge-in-2 merge-in-n VST180.vsd merge-in-1 merge-in-2 merge-in-n are file description (FD) names. Multiple-reel tape files are permitted.
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 Usage Considerations: • Placement of MERGE Statements A MERGE statement cannot appear in the Declaratives Portion of the Procedure Division. • 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.
Procedure Division Verbs MERGE When a key is in an ASCENDING phrase, the merged sequence is from the record with the lowest value in the key to the record with the highest value. When a key is in a DESCENDING phrase, the merged sequence is from the record with the highest value in the key to the record with the lowest value. In both cases, the rules for comparison of operands in a relation condition determine which value is higher.
Procedure Division Verbs MERGE When the MERGE statement begins execution, merge-file and the input files must be closed but not locked. The input-and-merge phase performs an implicit OPEN statement on merge-file and each of the input files. The input-andmerge phase opens each input file in INPUT mode, performs implicit READ NEXT statements to retrieve their records, and performs implicit RELEASE statements to release the records to the merge-file.
Procedure Division Verbs • MERGE How the Scratch File Is Determined Note. If a scratch file is specified but its value is all spaces, assume that no scratch file was specified. • ° If COBOL_SET_SORT_PARAM_TEXT_ specifies a SCRATCH-FILE, then that file is the scratch file. ° If the SELECT statement associated with merge-file specifies the =_SORT_DEFAULTS DEFINE as the define-name-literal, then: ° If the =_SORT_DEFAULTS DEFINE exists and specifies a scratch file, then that file is the scratch file.
Procedure Division Verbs ° MERGE If no =_SORT_DEFAULTS DEFINE exists, then the swap file is created on the volume used for the scratch file. For more information on the =_SORT_DEFAULTS DEFINE, see Establishing Parameters With =_SORT_DEFAULTS DEFINE. ° If the SELECT statement associated with merge-file does not specify the =_SORT_DEFAULTS DEFINE as the define-name-literal, then the swap file is created on the volume of the file that the SELECT statement specifies.
Procedure Division Verbs Example 9-43. 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 TO Example 9-44. MOVE TO Statements (page 2 of 2) PROCEDURE DIVISION. BEGIN-PROCESSING.
Procedure Division Verbs MOVE CORRESPONDING MOVE CORRESPONDING MOVE CORRESPONDING copies elements of one group to corresponding elements of another group. Groups of data correspond if they have the same names and qualifier names, beyond the group-names in the MOVE statement, and if they meet restraints explained under CORRESPONDING Phrase. Caution.
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-45 converts a length in feet to a length in inches. Example 9-45. MULTIPLY BY Statement 05 LENGTH PICTURE S9(6)V9(6). ... MULTIPLY 12 BY LENGTH Example 9-46 converts several dimensions from centimeters to inches, with rounding. Example 9-46. 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-47. 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 COBOLASSIGN or COBOL_ASSIGN_ routine (see COBOLASSIGN and COBOL_ASSI
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 ° The COBOL program describes the records of the file as having an odd number of characters, the file system description of the file does not include the “odd-unstructured” attribute, and the file size is some integer multiple of (COBOL record size plus 1).
Procedure Division Verbs OPEN Table 9-8. Open Modes for Structured Disk Files Not Present at Run Time Open Mode Action INPUT When the SELECT clause for the file contains the word OPTIONAL, the OPEN statement completes successfully, and COBOL simulates the existence of an empty disk file. If the file is not described as OPTIONAL, the open operation fails. OUTPUT or EXTEND or I-O If a file is described with alternate-record keys, the open operation fails.
Procedure Division Verbs OPEN Table 9-9. Open Modes for Structured Disk Files Present at Run Time Open Mode Action INPUT If the record length of the physical file is shorter than the record length declared in the File Section, and the record length is not declared as variable (rec-1 TO rec-2 CHARACTERS or VARYING SIZE), the OPEN statement fails. If the open operation succeeds and the file organization is relative, the relative key is established as the key of reference.
Procedure Division Verbs • OPEN HP COBOL Queues Printer File Records HP COBOL queues write operations to files that are associated with printers and to processes that behave like printers. The LINAGE clause of the file description entry and the ADVANCING phrase of the WRITE statement are valid only for such files.
Procedure Division Verbs • OPEN Exclusion Modes The EXCLUSIVE, SHARED, or PROTECTED phrase specifies the appropriate file system exclusion mode for the file.
Procedure Division Verbs • OPEN Record Prereading To save execution time by overlapping reading and processing, the run-time 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: ° ° ° The file access mode is SEQUENTIAL. ° ° The process is not running as a process pair. The file is open for INPUT.
Procedure Division Verbs PERFORM PERFORM PERFORM executes one or more procedures in a program, simply or with looping. When a procedure-name is a section-name, PERFORM executes all the paragraphs in that section.
Procedure Division Verbs Unconditional PERFORM proc-2 identifies the last procedure in the group. imperative-statement is defined under 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 • Unconditional PERFORM Procedure Relationships and the Ends of PERFORM Cycles There is no necessary relationship between proc-1 and proc-2, except that a PERFORM cycle begun at the procedure named by proc-1 ends when control reaches the return point following the last statement of the procedure named by proc-2. GO TO statements, PERFORM statements, CALL or ENTER statements, and so forth, can occur in the logical sequence of statements executed during a PERFORM cycle.
Procedure Division Verbs • Unconditional PERFORM Logical Range of the PERFORM Statement The logical range of any PERFORM statement is all statements that are executed as a result of the PERFORM statement, including the transfer of control to the statement following the PERFORM statement (or to the statement following the END-PERFORM).
Procedure Division Verbs • Unconditional PERFORM Placement of Procedures As a general rule, both proc-1 and proc-2 must be in the same logically discrete area of the Procedure Division (in a specific declarative procedure, including any associated sections, or in the portion of the Procedure Division that does not include declaratives).
Procedure Division Verbs PERFORM TIMES An in-line PERFORM statement can contain delimited-scope statements (such as a delimited-scope READ or IF statements) because they count as imperative statements. Example 9-51. In-Line PERFORM Statement With Delimited-Scope Statements PERFORM UNTIL END-IX READ IX-FILE RECORD AT END SET END-IX TO TRUE NOT AT END IF IX-NUMBER > 0 READ MASTR-FILE RECORD KEY IS IX INVALID KEY DISPLAY "Bad IX value: " IX STOP RUN END-READ END-IF MOVE MASTER-NAME TO CUST-NAME ...
Procedure Division Verbs PERFORM TIMES THROUGH THRU indicate that a group of procedures is to be executed. proc-2 is the last procedure in the group. count is an integer numeric literal or the identifier of an integer data item that tells the process how many times to execute the statements in the range of the PERFORM statement. 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.
Procedure Division Verbs PERFORM UNTIL Usage Considerations: • Negative or Zero Value in the TIMES Phrase The value of count can be a negative integer or 0, in which case the process does not perform the procedure or group. • See the usage considerations in Unconditional PERFORM. PERFORM UNTIL PERFORM UNTIL executes a procedure, group of procedures, or imperative statement repeatedly until a condition is true.
Procedure Division Verbs PERFORM UNTIL proc-2 identifies the last procedure in the group. 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.
Procedure Division Verbs PERFORM VARYING Example 9-54. 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 Restrictions for Identifiers When the vary-1 or vary-2 operand is an identifier, and the associated base-1 or base-2 is not an index-name, these restrictions apply: • ° The vary-1 or vary-2 identifier must designate a numeric data item. It cannot designate a special register. ° The associated base-1 or base-2 operand must be a numeric literal or an identifier that designates a numeric data item.
Procedure Division Verbs READ In Example 9-56, 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-56. 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 TIME PROMPT 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 The possible I-O status codes that result from successful read operations are: I-O Status Code Successful Read Operation “00” The read operation was unconditionally successful. “02” This is possible only when a file has the INSERTIONORDER attribute.
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 Variable-Length Records An Enscribe structured file is always capable of containing variable-length records. The file has a stated maximum allowable record length, but records can vary from a length of 0 up to the stated maximum.
Procedure Division Verbs READ for Sequential or Dynamic Access If the TIME LIMIT phrase is specified with a nonnegative value and the file is not opened with time limits enabled, the program terminates with an I-O status code “90,” and a message (File is not opened for timed I-O) is delivered to the process’s home terminal.
Procedure Division Verbs • READ for Sequential or Dynamic Access Use of the READ NEXT Statement on Relative, Indexed, or Queue Files The READ NEXT statement operates on a relative, indexed, or queue file only if the file is declared with ACCESS MODE SEQUENTIAL or ACCESS MODE DYNAMIC.
Procedure Division Verbs READ for Sequential or Dynamic Access Example 9-58. 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-59. Reading $RECEIVE With Timed Input-Output IDENTIFICATION DIVISION. ... ENVIRONMENT DIVISION. ... SELECT REQUEST ASSIGN TO "$RECEIVE" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS REQUEST-FILE-STATUS. ... 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. ...
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-60. 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) “43” The access mode is sequential, and the last input or output statement executed for the file was not a successful READ statement. The record is not released.
Procedure Division Verbs • REWRITE for Sequential, Relative, Indexed, and Queue Files UNLOCK Phrase If the UNLOCK phrase appears, the rewrite operation also assures that the record is not in the locked state at the completion of the rewrite operation. If the record was not in the locked state at the beginning of the rewrite operation, no report of this is made to the program.
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 AT END? TRUE 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-62. 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-63. SEARCH ALL Statement WORKING-STORAGE SECTION. 01 COMMANDS. 05 FILLER PIC X(6) VALUE "ADD". 05 FILLER PIC X(6) VALUE "DELETE". 05 FILLER PIC X(6) VALUE "EXIT". 05 FILLER PIC X(6) VALUE "LIST". ... 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 PIC 99 COMP VALUE 1. 05 COMMAND-IN PIC X(6). ... PROCEDURE DIVISION. ...
Procedure Division Verbs SET TO 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 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.
Procedure Division Verbs SET TO identifier-3 is a data item of any level except 88, anywhere in the Data Division. The value of ADDRESS OF identifier-3 is the address of identifier-3, not the value of identifier-3. identifier-4 is a data item with USAGE POINTER. 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.
Procedure Division Verbs SET TO SET TO identifier-1 identifier-2 index-name-2 index-name-1 integer mnemonic-name TO ON OFF condition-name TO TRUE VST211.vsd 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.
Procedure Division Verbs SET TO Usage Considerations: • Index-Names and Index Data Items An index-name is directly associated with a table and is declared in the INDEXED phrase of the table’s data description entry. The value associated with an indexname is related only to the table with which it is defined. An index data item is a separate data item, not associated with any table, that is declared with the USAGE INDEX clause.
Procedure Division Verbs • SET TO Index Values Before and After Execution If the sending item is an index-name, then before the execution of the SET TO statement, the value of the index must correspond to an occurrence number of an element in the associated table. If the receiving item is an index-name, then after the execution of the SET TO statement, the value of the index must correspond to an occurrence number of an element in the associated table.
Procedure Division Verbs SET UP or SET DOWN SET UP or SET DOWN SET UP increments data items addresses or indexes; SET DOWN decrements them. Topics: • • POINTER Data Items Nonpointer Data Items 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.
Procedure Division Verbs SET UP or SET DOWN Usage Considerations: • Do Not Use SET UP or SET DOWN for Record Pointers Do not use SET UP or SET DOWN to point a record pointer at a different record. This would be syntactically correct, but the memory positions of records are not defined in HP COBOL and can vary between implementations.
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-64. 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 If neither BEFORE nor AFTER is present, the file-position indicator is set to the record at the position defined by the values of key and position-key. 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 2. When the file does not contain a qualifying record, the invalid-key condition exists and the start operation terminates with the I-O status code “23.” When the search operation succeeds, the file position indicator is set to the value of the key of reference for the record found.
Procedure Division Verbs START The values of the I-O status data item for unsuccessful start operations are: • I-O Status Code Unsuccessful Start Operation “23” The file position indicator indicates that an optional input file is not present, the invalid-key condition exists, and the start operation terminates.
Procedure Division Verbs • START TIME LIMIT Phrase If the TIME LIMIT phrase appears, the time limit operand is evaluated and rounded, if necessary, to include at most two fractional digits. When the result is negative, the TIME LIMIT phrase does not apply, and the operation is not subject to a time limit; otherwise, the result specifies the time interval, in seconds, within which the start operation must complete.
Procedure Division Verbs START Whenever the start operation is successful, if a NOT INVALID KEY phrase is specified, control passes to the imperative statement in that phrase. If that imperative statement does not transfer control elsewhere using a GO TO statement, control then passes to the end of the START statement.
Procedure Division Verbs START Suppose a requester asks for a set of records from a member of a context-free server class: all the records that have a certain alternate key value, or partial value. If the message buffer cannot hold all such records, the server can return the first group of records plus the value of the unique key with the reply. This value is that of the prime record key, the relative key, or the entire alternate key declared as having no duplicates.
Procedure Division Verbs • START Next READ After a START with POSITION Might Fail When you use the POSITION phrase, there is no guarantee that the record you specify actually exists. In this aspect, the start-with-position operation differs from the ordinary COBOL start operation. The positioning operation merely sets the file position indicator to the file location where the record can be found if it exists; therefore, the invalid-key condition does not occur when the record does not exist.
Procedure Division Verbs Example 9-65. START Statement for Indexed File (page 2 of 2) PROCEDURE DIVISION. ... OPEN I-O RECEIVABLES-MASTER ... MOVE LOW-VALUES TO COMPANY-NAME START RECEIVABLES-MASTER KEY NOT LESS THAN COMPANY-NAME INVALID KEY DISPLAY "ERROR STARTING READ FOR REPORT" GO TO REPORT-EXIT END-START. GET-NEXT-RECORD. READ RECEIVABLES-MASTER NEXT RECORD AT END PERFORM... Example 9-66 reads all records for employees whose last names start with G. Example 9-66.
Procedure Division Verbs START Example 9-67, fragments of a server program, shows the use of a START statement with a POSITION phrase. The query the server gets through $RECEIVE includes a department number and a unique employee number. The server is to return an array containing information about all employees in the specified department. At the first call, the requester sends the chosen department number but an employee number of zero.
Procedure Division Verbs START Example 9-67. START Statement With POSITION Phrase (page 2 of 2) PROCEDURE DIVISION. ... OPEN INPUT EMP-FILE ... * Read $RECEIVE to get the query READ REC-IN ...
Procedure Division Verbs STARTBACKUP STARTBACKUP Note. • • Do not use this directive in the OSS environment. Before RVU D46.00 and G06.00, software product revision T8107AAT (run-time library T8108AAR), tThe NMCOBOL compiler ignores this directive and issues a warning. STARTBACKUP defines options for handling process pairs and starting the backup process. STARTBACKUP cpu options backup-ext VST224.vsd cpu is the processor module where the backup process is to run.
Procedure Division Verbs STARTBACKUP Value Meaning (page 2 of 2) 3 The primary process, rather than the fault-tolerant facility, reads the $RECEIVE file and takes appropriate action for system messages. In addition, if the primary process encounters a trap condition, it enters the DEBUG procedure. When this option is in force and the backup process fails, the primary process must re-execute the STARTBACKUP statement to reestablish the backup.
Procedure Division Verbs • STARTBACKUP Creation and Maintenance of a Backup Process Execution of the STARTBACKUP statement assigns a value to the special register PROGRAM-STATUS, reflecting the success or failure of the creation of the backup process. PROGRAM-STATUS is a record with two fields, PROGRAM-STATUS-1 and PROGRAM-STATUS-2: 01 PROGRAM-STATUS. 02 PROGRAM-STATUS-1 02 PROGRAM-STATUS-2 PIC X. PIC XXX.
Procedure Division Verbs ° STARTBACKUP TNS/R The fault-tolerant facility checkpoints the global-data portion of the globalsheap 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 STOP STOP STOP halts the execution of a run unit, either permanently or only to display a message. Note. The 1985 COBOL standard classifies the latter use as obsolete, so you are advised not to use it. STOP RUN «message» VST225.vsd RUN halts the execution of a run unit and transfers control to the operating system, closing any open files. message Note. The 1985 COBOL standard classifies message as obsolete, so you are advised not to use it.
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 delimiter is an alphanumeric literal or the identifier of a DISPLAY data item. It specifies the portion of part-1 that is moved. It also specifies that all characters up to but not including the value of delimiter are moved. If the literal is a figurative constant, it represents the equivalent one-character nonnumeric literal. If the data item is numeric, it must be described as an integer whose PICTURE character-string does not include P.
Procedure Division Verbs STRING END-STRING ends the scope of the STRING statement, causing the STRING to be a delimitedscope statement. If the STRING statement does not end with an END-STRING phrase, the presence of the OVERFLOW or the NOT OVERFLOW phrase causes the STRING statement to be a conditional statement, which ends at the next period separator.
Procedure Division Verbs ° STRING Copying the transfer string to the receiving item Assignment of the transfer string to the receiving item (result ) proceeds on a character by character basis. Beginning with the leftmost character, each character of the transfer string is moved into the receiving item character position designated by the pointer value, which is incremented by 1 after each character is moved.
Procedure Division Verbs STRING In Example 9-68, STRING builds a single data item from several data items. Also see the examples in UNSTRING. Example 9-68. 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-69, the UNLOCKFILE statement precedes a CLOSE statement to unlock the file before the process closes it. Example 9-69. 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 ALL causes the unstring operation to handle all consecutive occurrences of the value of delim-1 as if they were only one occurrence of delim-1. Without ALL, the unstring operation handles only the first occurrence of the value of delim-1 as the delimiter. 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.
Procedure Division Verbs UNSTRING result specifies the identifier of an alphanumeric, alphabetic, or numeric DISPLAY elementary data item into which the unstring operation copies characters from source. If result identifies a numeric data item, the PICTURE clause that describes it cannot contain any P s. result cannot reference a special register. An UNSTRING statement can have at most 127 result fields. delimstore is the identifier of an alphanumeric data item.
Procedure Division Verbs UNSTRING tally is the identifier of an integer data item to which the unstring operation adds the number of result data items it stored. The UNSTRING statement does not initialize tally but adds to its current value. If you want tally to begin at a given number, set it before the UNSTRING statement executes. tally cannot reference a special register.
Procedure Division Verbs • UNSTRING Execution of the UNSTRING Statement The execution of the UNSTRING statement consists of these three phases: 1. Initialization phase In the initialization phase, the UNSTRING statement performs these initialization operations before beginning to cycle through the list of INTO phrases: • • • • • • • It establishes the source item as the sending area.
Procedure Division Verbs UNSTRING If the statement includes the DELIMITED phrase, the examination proceeds left to right until it encounters either a delimiter string or the end of the sending area. A delimiter string is a contiguous set of characters, beginning with the character under examination, whose value exactly matches the value of any of the constants or data items specified in the DELIMITED phrase. If your program has these data items: 05 U PIC X(32) VALUE "The UNSTRING statement is handy." * ..
Procedure Division Verbs UNSTRING Each instance of delim-1 or delim-2 represents one delimiter. When a delimiter contains two or more characters, all of the characters must be present in contiguous positions in the source item, and in the order given, to be recognized as a delimiter. If you omit the DELIMITED phrase, the examination proceeds left to right until the number of characters examined equals the size of the current receiving area.
Procedure Division Verbs UNSTRING If you execute UNSTRING U DELIMITED BY SPACE OR "." INTO WORD-1 DELIMITER IN DEL-1 ... WORD-5 DELIMITER IN DEL-5 you get "The " in WORD-1, " " in DEL-1, and so on down to "handy " in WORD-5 and "." in DEL-5. If you include the DELIMITER phrase in the INTO phrase for this cycle, the unstring operation advances the current character position in the sending area to the first character following the delimiter string located in this cycle.
Procedure Division Verbs UNSTRING in WORD-3 but 9 in COUNT-3. If you include the POINTER phrase, the unstring operation increments the value of the pointer item by one for each character examined as a part of this cycle.
Procedure Division Verbs • UNSTRING National Data Items and National Literals If any of the data items delim-1, delim-2, result, or delimstore is a national data item or national literal, then all of them must be national items. In Example 9-70, UNSTRING breaks a data item into a collection of data items. UNSTRING uses the MOVE statement rules in transferring values into shorter data items. Example 9-70. UNSTRING Statement Input: DATA DIVISION. WORKING-STORAGE SECTION.
Procedure Division Verbs UNSTRING Example 9-71. 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-71 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, so you are advised not to use it, even in TNS HP COBOL programs. The NMCOBOL compiler does not recognize it. USE DEBUGGING traces procedure-names as a program executes. Immediately before a procedure is executed, the code for the section containing USE DEBUGGING is executed.
Procedure Division Verbs USE DEBUGGING ALL PROCEDURES traces every procedure-name and appears only once when used. It precludes the use of any USE procedure statements.
Procedure Division Verbs USE DEBUGGING Before the USE statement is executed, DEBUG-ITEM is filled with spaces. Immediately before the debugging section obtains control, DEBUG-ITEM is updated: DEBUG-LINE Contains the source line number where the procedure-name was called DEBUG-NAME Contains the first 30 characters of the procedure-name If it is a paragraph-name, any section-name qualifier is reported in DEBUG-ITEM. DEBUG-CONTENTS Contains a nonnumeric string varying in size and value.
Procedure Division Verbs USE DEBUGGING In Example 9-73, the debugging procedure displays the contents of the special register DEBUG-ITEM. Example 9-73. USE DEBUGGING Statement ... ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP WITH DEBUGGING MODE. ... PROCEDURE DIVISION. DECLARATIVES. TRACE-PROGRAM SECTION. USE FOR DEBUGGING ON ALL PROCEDURES. DISPLAY-DEBUG-ITEM. DISPLAY DEBUG-ITEM. END DECLARATIVES. BEGIN-PROCESSING. ...
Procedure Division Verbs USE AFTER EXCEPTION 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. It also executes USE AFTER EXCEPTION procedures when invalid-key or at-end conditions arise and no INVALID KEY or AT END phrases apply to the file.
Procedure Division Verbs USE AFTER EXCEPTION 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. Sort-merge file description names are not permitted. INPUT specifies that all files opened in INPUT mode that are not specified explicitly in another USE statement are to use this USE statement.
Procedure Division Verbs USE AFTER EXCEPTION It is usually best to write USE statements that explicitly reference individual files, because this gives you better control over the handling of exceptions. The declarative called by implicit reference has no simple way to determine the identity of the file that generated an exception.
Procedure Division Verbs USE AFTER EXCEPTION In Example 9-74, two files use the same error routine and another file uses a separate error routine. Example 9-74. 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. ...
Procedure Division Verbs WRITE WRITE WRITE delivers a record to its associated file. Forms: • • • WRITE for Sequential Files WRITE for Line Sequential Files WRITE for Relative, Indexed, and Queue 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.
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 In the CRE, the logical record is always transmitted to the file or spooler buffer immediately. • 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-75. 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-76. 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 and TNS/R Programs —522555-006 9 -306
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 Throughout this section, “compiler” means both the COBOL85 and NMCOBOL compilers unless otherwise stated. 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. In Example 11-2, a TNS HP COBOL program calls a FORTRAN program to get the base-10 logarithm of a value. Example 11-2.
Program Compilation Compilation Units If there are compilation errors in some, but not all, programs in a compilation unit, the COBOL85 compiler produces object programs for the programs in which there were no errors, but the NMCOBOL compiler produces no object file. Example 11-3 shows a compilation unit in which a main program and two called programs are included in the input file, contained in file CSOURCE.
Program Compilation Compilation Units Example 11-3. Compilation Unit (page 2 of 2) IDENTIFICATION DIVISION. PROGRAM-ID. CPGM2. * CALLED ... DATA DIVISION. ... LINKAGE SECTION. 01 LS-SUBASSY. 03 LS-SUBASSY-1 PICTURE 03 LS-SUBASSY-2 PICTURE 01 LS-MFGR. 03 LS-MFGR-NAME PICTURE 03 LS-MFGR-ADDR PICTURE ... PROGRAM 2. X(30). X(30). X(60). X(60). Figure 11-2.
Program Compilation Compilation Units Example 11-4. 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 ... CALL "CPGM2" IN C-ARCHIVE Figure 11-3. TNS Compilation With Object-File Inclusion SYMSERV CSOURCE Source File COBOL85 BINSERV Listing File Target File CPGM1 Copy Library CALLER CPGM2 COBJECT Object file (input) CPGM1 CPGM2 VST518.
Program Compilation Compilation Details Compilation Details • • • • • Processes Involved in Compilation Temporary File Placement CALL and ENTER Statement Processing: Overview CALL and ENTER Statement Processing: Detailed Explanation #RECEIVE Blocks Processes Involved in Compilation The processes involved in compilation differ for the COBOL85 and NMCOBOL compilers.
Program Compilation Processes Involved in Compilation COBOL85 Compiler The COBOL85 compiler consists of one process, COBOL85. Two other processes, SYMSERV and BINSERV, are present throughout the compilation. SYMSERV collects symbol table information, puts it into structures in a temporary file, and gives the temporary file to BINSERV. BINSERV writes the information from the temporary file into the object file. BINSERV also performs binding.
Program Compilation Temporary File Placement NMCOBOL Compiler The NMCOBOL compiler consists of a driver process, NMCOBOL, and a sequence of subordinate processes. For a successful compilation, the NMCOBOL compiler driver calls COBOLFE, UGEN, and AS1 in turn, using temporary files to pass information between them. If you specify the RUNNABLE or SEARCH directive when creating a non-PIC loadfile, the NMCOBOL compiler also calls the nld utility.
Program Compilation CALL and ENTER Statement Processing: Overview COBOL85 Compiler By default, the COBOL85 compiler creates its temporary files on the current default volume. The BINSERV and SYMSERV processes create their temporary files on the volume where the target file is located, unless that volume is on another node. If the volume is on another node, the BINSERV and SYMSERV processes create their temporary files on the current default volume of the node on which they execute.
Program Compilation CALL and ENTER Statement Processing: Overview To generate the proper code to call a separately compiled program, the compiler needs a description of the parameter list of that program. Each CALL or ENTER statement can include qualification that specifies where the compiler must find the program. Although the compiler must search for unqualified programs, qualification significantly restricts the activity of the compiler.
Program Compilation CALL and ENTER Statement Processing: Overview Topics: • • • • • • • Primary Search List Secondary Search List (COBOL85 Compiler Only) Tertiary Search List COBOLEXT File COBOLEX0 and COBOLEX1 Files NMCOBEXT File NMCOBEX0 and NMCOBEX1 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.
Program Compilation CALL and ENTER Statement Processing: Overview COBOLEXT File If you did not provide search lists, or if the compiler did not find the necessary external references on them, it uses the COBOLEXT file to perform parameter validation, but does not import any object code. Programs resolved from COBOLEXT are available to the program at load time. When you install the COBOL85 compiler, the COBOLEXT file is stored on the subvolume $SYSTEM.SYSTEM.
Program Compilation CALL and ENTER Statement Processing: Detailed Explanation When you install the NMCOBOL compiler, the NMCOBEX1 and NMCOBEXT files are stored on the subvolume $SYSTEM.SYSTEM. If you move either file to another subvolume, use the CONSULT directive to tell the compiler where to find it. Note. The preceding paragraph applies only to the NonStop system. For the locations of files on the PC, see NonStop COBOL for TNS/R (ETK).
Program Compilation CALL and ENTER Statement Processing: Detailed Explanation 2. If program S contains a common program named A, and also contains (directly or indirectly) program P, then if P calls A, the compiler chooses the common program A. In Example 11-6, the compiler issues a warning if a file-mnemonic appears. If common program A contains program P (directly or indirectly), the compiler leaves P’s reference to A unresolved, and Item 4 applies. 3.
Program Compilation CALL and ENTER Statement Processing: Detailed Explanation Example 11-5. 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-6. 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 COBOL85 compiler looks for the program in the current search lists, in this order: 1. Primary search list 2. Secondary search list 3. Tertiary search list If the COBOL85 compiler does not find the program in any of the search lists, and the language is TAL, the compiler searches the COBOLEXT file located on the same volume and subvolume as the compiler.
Program Compilation CALL and ENTER Statement Processing: Detailed Explanation Table 11-2. Resolution of External References (COBOL85 Compiler With No Search List Defined) (page 2 of 2) External reference found in ...
Program Compilation CALL and ENTER Statement Processing: Detailed Explanation Table 11-3. Resolution of External References (COBOL85 Compiler With Search List Defined) (page 2 of 2) External reference found in ...
Program Compilation CALL and ENTER Statement Processing: Detailed Explanation Table 11-4. Resolution of External References (NMCOBOL Compiler) (page 2 of 2) External reference found in ...
Program Compilation CALL and ENTER Statement Processing: Detailed Explanation Parameter Explanation (page 2 of 2) REFERENCE When a formal parameter has the REFERENCE attribute, the actual parameter supplies access to an object in the calling program. When an actual parameter is an identifier, the compiler generates code to pass the address of the associated data item to the called program. In this case, the calling program and the called program must agree on the interpretation of the data item value.
Program Compilation #RECEIVE Blocks #RECEIVE Blocks When BINSERV or the linker creates a run unit for the CRE, it compares the #RECEIVE blocks of all the programs and determines which argument values are to be used whenever another HP COBOL object file or a FORTRAN program opens $RECEIVE. Table 11-5.
Program Compilation Compiler Output If an internal file opens $RECEIVE, the values of the #RECEIVE arguments depend on whether the program that describes the internal file has a RECEIVE-CONTROL paragraph. If so, the #RECEIVE block associated with the program’s RECEIVECONTROL paragraph is used as the internal file’s #RECEIVE block (even in a TNS program whose RECEIVE-CONTROL paragraph is EXTERNAL).
Program Compilation Listing Creation 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. The listing file can be either a disk file or nondisk file (see Starting a Compilation). If it is a disk file, it must exist before you start the compilation.
Program Compilation Object File Creation Object File Creation The object file that the compiler produces is either a linkfile or a loadfile. Topics: • • • COBOL85 Compiler NMCOBOL Compiler Binder Object File Builder COBOL85 Compiler The COBOL85 compiler produces a loadfile if the compilation unit contains exactly one main program (see Main Programs). If the compilation unit contains no main program, the COBOL85 compiler produces a linkfile.
Program Compilation Manipulating Object Files An object program is the portion of an object file produced from one program unit. An object file contains one or more object programs. Within the object file, each object program maintains its identity, but is discernible only as a family of code blocks and data blocks. Any object file produced by either BIND or BINSERV can serve as object-file input either for BIND during an interactive session or for BINSERV during a COBOL85 compilation.
Program Compilation Compilation Statistics Compilation Statistics Statistics are printed at the end of every compilation: 1. Binder or linker statistics (if an object file was produced) 2. Compiler statistics Topics: • • • Binder Statistics COBOL85 Compiler Statistics NMCOBOL Compiler and Linker Statistics Binder Statistics Example 11-7. Binder Statistics Binder - OBJECT FILE Binder - T9621D05 - (12DEC91) Copyright Tandem Computers Incorporated 1982-1992 Object file \KIT.$VOL1.PROJ3.
Program Compilation Compilation Statistics Table 11-6. Meaning of Binder Statistics (page 2 of 2) Statistic Meaning Code pages1 Total number of words 2 used for all Procedure Division code in the loadfile, including TAL and FORTRAN routines The code size is itemized regarding procedure entry-point (PEP) table size, procedure code size, the gap at the 32K-word boundary (see COMPACT and NOCOMPACT), and external entry-point (XEP) table size.
Program Compilation Compilation Statistics Table 11-7. Meaning of COBOL85 Statistics Messages Message Meaning No object file produced. One of: • • Every separately compiled program in the compilation either contained errors or was subject to the SYNTAX directive.
Program Compilation Compilation Statistics Example 11-9. NMCOBOL Compiler Statistics COBOL - T8107D46 - (27 JUL 01) No failures detected. No errors detected. No warnings reported. No remarks issued. Maximum symbol table size = 6160 bytes Object file: opt2o Compiler driver: \SVLDEV.$SYSTEM.SYSTEM.NMCOBOL COBOL SRL: \SVLDEV.$SYSTEM.SYS00.ZCOBSRL CRE SRL: \SVLDEV.$SYSTEM.SYS00.ZCRESRL NMCOBEXT: \SVLDEV.$SYSTEM.SYSTEM.NMCOBEXT Compiler statistics phase CPU seconds elapsed time file name COBOLFE 0.
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 either the COBOL85^COMPLETION routine or COBOL_COMPLETION_ routine. Table 11-9. 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).
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-10.
Program Compilation PARAM Commands PARAM SWAPVOL The PARAM SWAPVOL command specifies the volume on which the compiler and its processes will create temporary files (if possible). It does not determine where the operating system creates the compiler’s own swap file—the Kernel-Managed Swap Facility (KMSF) does that. For more information, see the Kernel-Managed Swap Facility (KMSF) Manual. PARAM SWAPVOL $ ns volume VST418.
Program Compilation Predefined SEARCH DEFINEs Table 11-11. How the PARAM SYMBOL-BLOCKS Command Affects Space Allocation Space Allocated for Item Item When PARAM SYMBOL-BLOCKS command is specified ...
Program Compilation Predefined SEARCH DEFINEs =_SOURCE_SEARCH =_SOURCE_SEARCH tells the compiler where to search for unqualified source text files specified by: • • • COPY statements SOURCE directives The copy-library parameter of the compilation command The =_SOURCE_SEARCH DEFINE does not affect compiler searches in these cases: • • When the source text file name is qualified When the program uses the default COPY library, COPYLIB, for COPY text =_OBJECT_SEARCH =_OBJECT_SEARCH tells the compiler wh
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 COBOL85 compiler, use this compiler command: COBOL85 / IN / source-file , OUT list-file , other-option target-name , ( obj-1 , copy-library ; compiler-directive obj-n ) VST256.
Program Compilation Starting a Compilation To run the NMCOBOL compiler, use this compiler command: NMCOBOL / IN source-file / , OUT list-file , other-option target-name , copy-library ; compiler-directive VST728.vsd source-file file-name-1 define-name VST257.vsd is a file containing HP COBOL statements, comment lines, and compiler directives. It must be a disk file, terminal, magnetic tape unit, or process. The compiler reads source-file as 132-byte records.
Program Compilation Starting a Compilation 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. If list-file is unstructured, each record is 132 characters (partial lines are space-filled on the right).
Program Compilation Starting a Compilation target-name file-name-4 define-name VST261.vsd is the name of a disk file on which the single target object file is to be produced. This name is used only if all of these are true: • • • The compiler is instructed to produce a target file. This means that the SYNTAX directive is not specified. The compilation and binding are successful. The source file contains only one main program.
Program Compilation • • • • Starting a Compilation Each directive that applies to more than one separately compiled program in the source-file (for example, ICODE or NOBLANK) must be specified as a compiler-directive in the compiler command. Each separately compiled program in the source-file must end with an END PROGRAM statement or an ENDUNIT compiler directive. In the source-file, compiler directives must be contained in separately compiled programs. They cannot appear before, between, or after them.
Program Compilation Starting a Compilation Usage Considerations: • Compiler on D-Series System and Other Files on C-Series System If the COBOL85 compiler is running on a D-series system and any other file that the program uses (such as the source-file, a COPY or SOURCE library, a search or consult file, the OUT file, the home terminal, or the target file) is on a C-series system, then compiling with the HIGHPIN directive causes a compilation error.
Program Compilation Terminating a Compilation The next command initiates compilation of the program contained in file COBOLPRG on system \MM, volume $DEV, subvolume PYRL and directs that the listing output be discarded: COBOL85 /IN \MM.$DEV.PYRL.COBOLPRG,OUT/; SETTOG 3 NMCOBOL /IN \MM.$DEV.PYRL.COBOLPRG,OUT/; SETTOG 3 If the compilation succeeds, the loadfile is to be named RUNUNIT.
Program Compilation Where Compiler Directives Are Allowed Where Compiler Directives Are Allowed In general, one or more directives can be entered in the directive field of the TACL command to run the compiler (see Starting a Compilation) or can be included in the source text on lines beginning with a question mark (?) in the indicator area.
Program Compilation Where Compiler Directives Are Allowed directive is one of the directives listed in this section. With these exceptions, compiler directive lines can appear at any point in the source text, including those portions that a COPY statement retrieves from a source library file. • 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 OF text-name . library-name IN VST265.
Program Compilation Categories of Compiler Directives Categories of Compiler Directives Compiler directives fall into these categories: • • • • • • • Table 11-12, Source Text Manipulation Directives, on page 11-47 Table 11-13, Input Format Control Directives, on page 11-47 Table 11-14, Listing Control Directives, on page 11-48 Table 11-15, Code-Generation Control Directives, on page 11-49 Table 11-16, Resolution and Binding Control Directives, on page 11-51 Table 11-17, Miscellaneous Control Directives,
Program Compilation Categories of Compiler Directives Table 11-14.
Program Compilation Categories of Compiler Directives Table 11-15.
Program Compilation Categories of Compiler Directives Table 11-15.
Program Compilation Categories of Compiler Directives Table 11-16.
Program Compilation Categories of Compiler Directives Table 11-17. Miscellaneous Control Directives (page 2 of 2) Directive(s) Default Action HIGHREQUESTERS3 Allows the program to run as a server that communicates with requesters running at high PINs (greater than 255) 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 Note. The COBOL85 compiler does not recognize this directive. CALL-SHARED NON-SHARED SHARED VST802.vsd CALL-SHARED generates shared code (PIC). NON-SHARED generates nonshared code (non-PIC). SHARED generates shared code (PIC) for a DLL. Note. You cannot link PIC and non-PIC object files into a single object file.
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-19. 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 CODE and NOCODE CODE and NOCODE Note. The NMCOBOL compiler issues warnings for these directives. CODE NOCODE VST269.vsd CODE lists an octal image of the compiled code following successful compilation of a program unit. The octal image appears after the symbol table listing produced by MAP (if any) and before the mnemonic code produced by ICODE (if any). NOCODE suppresses the octal image of the compiled code.
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 COMPACT and NOCOMPACT COMPACT and NOCOMPACT Note. The NMCOBOL compiler, which does not use BINSERV, issues warnings for these directives. COMPACT NOCOMPACT VST271.vsd COMPACT causes BINSERV to attempt to compact the code space of the target file. NOCOMPACT prevents BINSERV from compacting the code space of the target file. Default: COMPACT Placement: Anywhere Scope: The last COMPACT or NOCOMPACT in the compilation unit applies.
Program Compilation COMPILE Suppose the compiler presents these code-space blocks to BINSERV in this order: Program A Program B Program C Program D Program E 20 KB 24 KB 32 KB 8 KB 10 KB Because no block exceeds 64 KB, none can span the 64 KB boundary. When they are bound with NOCOMPACT active, they occupy 116 KB.
Program Compilation CONSULT and NOCONSULT CONSULT and NOCONSULT Note. The NMCOBOL compiler ignores and issues a warning for the NOCONSULT directive. CONSULT object-name-list ( object-name-list ) NOCONSULT VST273.vsd CONSULT adds the files that object-name-list specifies to the tertiary search list. (See Tertiary Search List.) object-name-list object-name , object-name VST274.
Program Compilation CROSSREF and NOCROSSREF When object-name is an archive file, the entire archive file is generally not linked into the target object file. Only those member files are linked that contain procedures named either in the statement CALL or in the statement ENTER in the COBOL program being compiled. Whenever a procedure is needed from a member file, the entire member file is linked.
Program Compilation CROSSREF and NOCROSSREF CROSSREF without a class-list sets the class list to all classes except LITERALS and UNREFS and triggers the collection and reporting of cross-reference information for all classes currently in the class list (see the list under class ). class-list class , ONLY class INCLUDE EXCLUDE VST276.vsd specifies the classes to be cross-referenced.
Program Compilation CROSSREF and NOCROSSREF Class COBOL Identifiers Selected (page 2 of 2) PROCNAMES (or LABELS) * Procedure-names (paragraph-names, sectionnames) PROGRAMS * Program-names, routine-names UNREFS Items defined but not referenced (technically, not a class but a generalized request for all such items) The classes marked with an asterisk in the preceding table are, by default, selected for inclusion, but reporting of cross-reference information about them is suspended until a CROSSREF
Program Compilation • DIAGNOSE-74 and NODIAGNOSE-74 CROSSREF at the beginning of a program unit, followed by NOCROSSREF at the beginning of a SECTION, followed by CROSSREF after the end of the SECTION, collects cross-reference information for all of the program unit; it does not suppress the collection or reporting of data in the delimited section.
Program Compilation DIAGNOSE-74 and NODIAGNOSE-74 The possible suffixes, explained in Usage Considerations:, are: • • • • • • • • • Size of index data item Implied value of Figurative Constant Precision of division operation Action when program not found Search algorithm Size of receiving operand Identification of statement operand Assignment order of PERFORM operands Alphanumeric sender Usage Considerations: • Size of Index Data Item A data item within a record description has an explicit USAGE INDE
Program Compilation • DIAGNOSE-74 and NODIAGNOSE-74 Search Algorithm The SEARCH ALL statement in COBOL 74 performed a linear search. In HP COBOL, it performs a binary search. You must verify that the table being searched is properly organized (strictly ascending or descending order) so that a binary search is feasible.
Program Compilation 3. 4. 5. 6. 7. 8. 9. DIAGNOSE-74 and NODIAGNOSE-74 Sets y to the value of x (still 1), sets x to 2 Runs y from 1 through 4 Sets y to the value of x (now 2), sets x to 3 Runs y from 2 through 4 Sets y to the value of x (now 3), sets x to 4 Runs y from 3 through 4 Terminates In HP COBOL, the same statement performs these steps in this order: 1. 2. 3. 4. 5. 6. 7. 8. 9.
Program Compilation DIAGNOSE-85 and NODIAGNOSE-85 DIAGNOSE-85 and NODIAGNOSE-85 Note. The COBOL85 compiler does not recognize these directives. DIAGNOSE-85 NODIAGNOSE-85 VST719.vsd DIAGNOSE-85 causes the NMCOBOL 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 ENDUNIT ENDUNIT ENDUNIT signals the end of a program unit. Each independent HP COBOL program must end with either an ENDUNIT directive or an END PROGRAM statement; otherwise, programs appear to be nested but lacking their required END PROGRAM statement. ENDUNIT VST279.vsd Default: The compiler detects the end of a Procedure Division by encountering either an END PROGRAM statement or the end of the file.
Program Compilation ENV Table 11-20. Effects of ENV Directive Options COBOL85 Compiler ENV Option Guardian Environment OSS Environment NMCOBOL Compiler COMMON Selects CRE Selects CRE (required) Accepted but unnecessary (CRE is the default) LIBRARY Selects CRE and allows program to be put in a user library. Program must satisfy the criteria in Library Programs Not accepted Ignored, warning issued * OLD Selects non-CRE environment Not accepted Not accepted * To build a user library, use UL.
Program Compilation ENV If a program does not meet the preceding criteria and you try to compile it with the ENV LIBRARY directive, the compiler reports an error. If you compile a program with the ENV LIBRARY directive: • • ASSIGN and PARAM commands for the files in the program are ignored. The compiler does not create data blocks or references to data blocks for the program. Instead, the operating environment creates these at run time.
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 FIPS and NOFIPS 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 LE
Program Compilation FLOAT and NOFLOAT FLOAT and NOFLOAT Note. The NMCOBOL compiler ignores this directive and issues a warning. FLOAT NOFLOAT VST818.vsd FLOAT allows the compiler to use floating-point arithmetic for certain complex expressions. NOFLOAT prevents the compiler from using floating-point arithmetic for certain complex expressions. Default: FLOAT Placement: Outside the boundaries of any program Scope: Applies to all subsequent programs Dependencies: None FMAP Note.
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 HEAP HEAP Note. The NMCOBOL compiler ignores this directive and issues a warning. HEAP specifies heap space size in the CRE. HEAP is useful only in the Guardian environment and only if the program calls HP C functions that allocate heap space. HEAP size VST738.vsd size is an integer in the range 2048 through 2,147,483,684 that represents the number of bytes to allocate for the CRE user heap. Default: Guardian environment: the heap is nonexistent by default.
Program Compilation HIGHPIN Default: TNS program runs with a low PIN (less than or equal to 255). Placement: Any of: • • • Anywhere in the source program (but it is good practice to put it before the first program in a compilation unit) On the compiler command line In a stand-alone Binder session Scope: Applies to the program in which or before which it appears and to all subsequent programs in the compilation unit Dependencies: Program must be compiled with ENV COMMON.
Program Compilation HIGHPIN 2. You can set the HIGHPIN flag of an object file during compilation by including the HIGHPIN directive in the compilation command: COBOL85 /IN cobsrc,OUT $s.#coblst,NOWAIT/ cobobj; HIGHPIN 3. Alternatively, you can set the HIGHPIN flag of an object file after compilation by typing this Binder command: BIND CHANGE HIGHPIN ON IN cobobj 4. Before you run the object file, you can check the current setting of the TACL HIGHPIN built-in variable by typing: #HIGHPIN 5.
Program Compilation HIGHREQUESTERS HIGHREQUESTERS Note. The NMCOBOL compiler ignores this directive and issues a warning. A native HP COBOL program always runs at a high PIN. HIGHREQUESTERS allows the program to run as a server that communicates with requesters running at high PINs (process identification numbers greater than 255). HIGHREQUESTERS VST285.vsd Default: Program cannot run as a server that accepts requesters running with high PINs (greater than 255).
Program Compilation IF and IFNOT NOICODE suppresses the mnemonic image of the compiled code. Default: NOICODE Placement: Anywhere Scope: Last ICODE or NOICODE applies to program unit. Dependencies: ICODE works only if LIST is active and SUPPRESS is not. References: • • • • LIST and NOLIST SUPPRESS and NOSUPPRESS MAP and NOMAP CODE and NOCODE IF and IFNOT IF toggle-number IFNOT VST287.
Program Compilation IF and IFNOT COPY and REPLACE statements are not affected by this directive; they are still processed and expanded. In contrast, a SOURCE directive is ignored when it is part of the ignored text. If a given toggle is not set, any directives between an IF for that toggle and its subsequent ENDIF are parsed but are not acted upon; if a given toggle is set, any directives between an IFNOT for that toggle and its subsequent ENDIF are parsed but are not acted upon. Example 11-11.
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 Note. The COBOL85 compiler does not recognize these directives. For the COBOL85 compiler, use IICODE and NOICODE instead. 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.
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. The Inspect attribute partially determines the debugger for the compilation unit. For more information, see Debugger Selection.
Program Compilation LARGEDATA LARGEDATA item ( ) item , item VST725.vsd item is one of: • • • • An unsigned integer constant between 0 and 32767 A filename A level-01 data name A level-77 data name If LARGEDATA is specified without item, the COBOL85 compiler uses the value 256 and the NMCOBOL compiler uses the value 64. If the LARGEDATA directive is not specified, the COBOL85 compiler uses LARGEDATA 0 and the NMCOBOL compiler uses LARGEDATA 64.
Program Compilation LARGEDATA If item is a data name, the COBOL85 compiler allocates space for it in the user extended area; the NMCOBOL compiler allocates space for it in the large data area. If the data name is a file record area, the same thing occurs only if all of these conditions are true: • • • The data name is that of the first record area for the file. The filename is specified in a SAME RECORD AREA clause.
Program Compilation LD LD Note. The COBOL85 compiler does not accept this directive. LD ( option ) VST111.vsd option is an ld option to be passed to the ld utility. For information about ld options, see the ld Manual. Default: None Placement: In the command line Scope: Applies to the compilation unit Dependencies: None LESS-CODE Note. The compiler ignores this directive and issues a warning.
Program Compilation LESS-CODE bits-to-set is an integer in the range 0 through 7, which is interpreted: Value of bits-to-set Decimal Binary Result 0 000 Compiler generates code to initialize all areas.
Program Compilation LIBRARY Default: None Placement: The compiler accepts it anywhere, but to be effective, it must be before the main program. Scope: Applies to the compilation unit Dependencies: None LIBRARY Note. The NMCOBOL compiler ignores this directive and issues a warning. To specify a user library, see Specifying a User Library. LIBRARY specifies the name of a TNS user library for resolving unqualified external references. LIBRARY file-name VST289.
Program Compilation LINES LINES LINES determines the number of lines to be listed on each page of the output file. Whenever the next line of a listing would cause a page to exceed the specified line count, the compiler ejects the page and begins a new listing page. It prints the standard page heading at the top of the new page, followed by two blank lines, and then the next line of the listing. LINES lines-per-page VST290.vsd lines-per-page is an integer in the range 10 through 32767.
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 LMAP and NOLMAP LMAP and NOLMAP Note. The NMCOBOL compiler, which does not use BINSERV, ignores these directives and issues warnings. LMAP lm-option-list ( lm-option-list ) * NOLMAP lm-option-list ( lm-option-list ) VST292.vsd LMAP requests from BINSERV the load maps specified by lm-option-list. NOLMAP suppresses the load maps specified by lm-option-list. lm-option-list lm-option , lm-option VST293.
Program Compilation LMAP and NOLMAP * requests all load maps.
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. References: • • LIST and NOLIST SUPPRESS and NOSUPPRESS NLD NLD ( option ) VST082.
Program Compilation NONSTOP NONSTOP Note. • • Do not use this directive in the OSS environment. Before RVU D46.00 and G06.00, software product revision T8107AAT (run-time library T8108AAR), the NMCOBOL compiler ignores this directive and issues a warning. 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.
Program Compilation NON-SHARED NON-SHARED Note. The COBOL85 compiler does not recognize this directive. NON-SHARED CALL-SHARED SHARED VST803.vsd CALL-SHARED generates shared code (PIC). NON-SHARED generates nonshared code (non-PIC). SHARED generates shared code (PIC) for a DLL. Note. You cannot link PIC and non-PIC object files into a single object file.
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 has only a small effect on compilation speed. The effect of each level is: Effect Level COBOL85 Compiler NMCOBOL Compiler 0 Code is not optimized. Provided in case other optimization levels cause errors. Supports symbolic debugging; data is always in memory. Code is not optimized.
Program Compilation PERFORM-TRACE Default: OPTIMIZE 1 Placement: Outside the boundary of a separately compiled program Scope: The optimization level active at the beginning of a separately compiled program determines the level of optimization for that program and any programs it contains. Dependencies: None PERFORM-TRACE PERFORM-TRACE gives additional information if run-time error 148, “PERFORM nesting too deep,” occurs. PERFORM-TRACE VST800.
Program Compilation PORT and NOPORT PORT and NOPORT PORT and NOPORT determine: • • How BINARY/COMPUTATIONAL data items are aligned Whether the CALL statement in a program running in the CRE behaves as defined in X/Open and XPG4 specification. PORT 1 2 3 NOPORT VST600.vsd PORT aligns BINARY/COMPUTATIONAL data items on byte boundaries (unless they are described with the SYNCHRONIZED clause, which aligns them on 2-byte boundaries).
Program Compilation PORT and NOPORT Default: NOPORT Placement: Anywhere Scope: Applies to the compilation unit Dependencies: None Usage Considerations: • NATIVE-n Data Items and Pointers The PORT directive does not affect the alignment of NATIVE-n data items or pointers. • Run-Time Performance The PORT directive can severely impact n HP COBOL program’s run-time performance.
Program Compilation RESETTOG RESETTOG RESETTOG turns off all specified toggles, which are used by the IF directive. RESETTOG toggle-number-list VST298.vsd toggle-number-list toggle-number , toggle-number VST299.vsd toggle-number is an integer in the range 1 through 15. If toggle-number is omitted, all toggles are turned off.
Program Compilation RUNNABLE RUNNABLE Note. The COBOL85 compiler does not recognize this directive. RUNNABLE causes the NMCOBOL compiler to use the linker to produce a loadfile if there are no compilation errors. RUNNABLE VST729.vsd Default: The NMCOBOL 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.
Program Compilation RUNNAMED RUNNAMED RUNNAMED specifies that the run unit is to be run as a named process. RUNNAMED VST300.
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. In the non-CRE environment, the saved ASSIGN messages are in the data block #HIGHBUF. (See Code and Data Blocks). In the CRE, the saved ASSIGN messages are in the data block #CRE_HEAP.
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 NMCOBOL 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 clears the primary search list for the COBOL85 compiler, but is ignored by the NMCOBOL compiler. object-name-list object-name , object-name VST306.
Program Compilation SEARCH and NOSEARCH object-name is a name that designates an TNS/R 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 Note. The COBOL85 compiler does not recognize this directive. SHARED CALL-SHARED NON-SHARED VST804.vsd SHARED generates shared code (PIC) for a DLL. CALL-SHARED generates shared code (PIC). NON-SHARED generates nonshared code (non-PIC). Note. You cannot link PIC and non-PIC object files into a single object file.
Program Compilation SHOWCOPY and NOSHOWCOPY If you put an HP COBOL program in a DLL, you must export the program name when you build the DLL; otherwise, other programs cannot call the HP COBOL program. To export the HP COBOL program name, use one of these ld commands: Environment ld Commands Guardian ld (-export program-name ) or ld (-export_all) OSS or PC -Wld="-export program-name " or -Wld="-export_all" SHOWCOPY and NOSHOWCOPY SHOWCOPY NOSHOWCOPY VST310.
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 NMCOBOL 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.
Program Compilation SQL and NOSQL RELEASE1 is for the COBOL85 compiler only, and causes it to accept only SQL/MP Release1 features; however, the resulting object file can be executed with SQL/MP Release 1, Release 2, or 300 (or later).. RELEASE2 causes the compiler to accept only SQL/MP Release 2 features; however, the resulting object file can be executed with SQL/MP Release 2 or 300 (or later).
Program Compilation SQLMEM Default: None. If the program contains SQL/MP statements, the SQL directive is required; otherwise, it is unnecessary. Placement: The COBOL85 compiler accepts SQL and NOSQL in either the source code (before the first Identification Division in the program) or the compiler command line; the NMCOBOL compiler accepts them only in the compiler command line. Scope: Applies to the compilation unit Dependencies: SQL works only if LIST is active and SUPPRESS is not.
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 TRAP2 and NOTRAP2 NOTRAP2 specifies that the compiler does not expect the operating environment to trap arithmetic overflow in the current program. If the current program was called from an environment in which trapping was enabled, however, programs that the current program calls will have trapping enabled (unless overridden by the NOTRAP2-74 directive).
Program Compilation TRAP2-74 and NOTRAP2-74 If you compile the main program with the COBOL85 compiler, and include the NOTRAP2 directive, the compiler does not activate the arithmetic overflow trapping mechanism. This then approximates the behavior of COBOL 74, although any undefined results could have values that are different from those a COBOL 74 program would produce.
Program Compilation UL In object code produced by the COBOL85 compiler, if a size error condition occurs in an arithmetic computation for which no SIZE ERROR phrase is present, the program suspends execution and enters the selected debugger with a trap 2 (arithmetic overflow) condition. When a set of separately compiled COBOL programs constitute a run unit, if any of the programs is the product of compilation by the COBOL85 compiler, the main program must be a product of the COBOL85 compiler.
Program Compilation WARN and NOWARN For instructions on building and specifying native user libraries, see User Library. WARN and NOWARN WARN NOWARN VST330.vsd WARN reports compilation and Binder warnings in the listing. NOWARN suppresses compilation and Binder warnings in the listing.
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 RUN or RUND Command Both the RUN and RUND commands run a loadfile as a process. The RUND command calls the selected debugger (see Debugger Selection)before beginning execution. RUN program-file RUND / run-option-list / program-parameter-list VST331.vsd RUN runs the program without the debugger. RUND runs the program with the debugger. program-file is the name of the loadfile to run.
Program Execution RUN or RUND Command accept-device has a value that designates a terminal or a process and can be a filesystem file name or (in the Guardian environment) a DEFINE name. accept-device specifies the device from which an unqualified ACCEPT statement retrieves input. If you omit this option, unqualified ACCEPT statements retrieve input from the home terminal (unless PARAM EXECUTION-LOG specifies a different device).
Program Execution ASSIGN Command When a process begins executing, it obtains the current ASSIGN and PARAM values from the Guardian environment, and can act on the information they contain. See ASSIGN Command and PARAM Command. For additional information on TACL run-time commands, see the TACL Reference Manual or the Guardian User’s Guide.
Program Execution ASSIGN Command This partial syntax diagram of the ASSIGN command describes features of greatest interest to the COBOL programmer: ASSIGN cobol-file-name program-name . * , system-file , characteristic VST334.vsd program-name is the program-name in the PROGRAM-ID paragraph in the Identification Division, for which the file assignment is to take effect. This is distinct from the name of the loadfile. Do not specify program-name for an external file.
Program Execution ASSIGN Command 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. characteristic EXT size-list CODE file-code EXCLUSIVE SHARED PROTECTED INPUT OUTPUT I-O REC record-size BLOCK block-size VST336.
Program Execution ASSIGN Command sec-extent-size is an unsigned integer specifying the secondary extent size. If EXT is omitted, sec-extent-size defaults to 20. If sec-extent-size is omitted, the secondary extent size defaults to the primary extent size. file-code is 101 (for an EDIT file) or an unsigned integer in the range 0 through 99 or in the range 1000 through 32767, which specifies a file code for disk file creation. If the CODE clause is omitted, a file-code of 0 is used.
Program Execution • ASSIGN Command Special COBOL Names for Operating System Files See Operating system file names and Special names for operating system files. Example 12-2. #TEMP 17>ASSIGN temp-file,#TEMP 18>RUN program ... * File created on run-time default volume OPEN I-O temp-file ... * File purged CLOSE temp-file ... * New empty file created OPEN I-O temp-file ... * File automatically closed and purged STOP RUN. ...
Program Execution PARAM Command Example 12-3. ASSIGN Command With Special COBOL Names (page 2 of 2) 21> 22>ASSIGN OUTPUT-FILE, #OUT 23> == FD OUTPUT-FILE is the == file named in the == OUT option. 24>ASSIGN RECEIVE-FILE, $RECEIVE 25> 26> 27> == Run the loadfile, == designating NEWINP as == the IN file (thus 28>RUN PROG3 /IN NEWINP,OUT NEWOUT/ == equating it with the 29> == fd-name INPUT-FILE) 30> == and NEWOUT as the OUT 31> == file (thus equating it 32> == with the fd-name 33> == OUTPUT-FILE).
Program Execution PARAM Command 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 * specifies that all run-time messages are to be discarded. TAPE-DIALOGUE applies only to the non-CRE environment, in which it sets (ON) or clears (OFF) the tape dialogue. If the tape dialogue is cleared, the tape assigned in either the SELECT clause, TACL ASSIGN directive, or DEFINE is assumed to be the correct tape. No dialogue appears for any tape, whether or not NO REWIND is specified; however, if a reel swap occurs, the tape dialog appears for that file connector.
Program Execution • PARAM Command EXECUTION-LOG Parameter There are three circumstances in which a COBOL program can interact with the home terminal without your explicitly instructing it to do so: ° A DISPLAY statement does not include an UPON phrase, so it defaults to the OUT file, which itself is defaulted to the home terminal. ° An ACCEPT statement does not include a FROM phrase, so it defaults to the IN file, which itself is defaulted to the home terminal.
Program Execution PARAM Command The file is opened the first time the run unit attempts to write a message. This means that it will not be opened at all for most jobs. If the open operation fails, no messages can be written anywhere and run unit execution terminates abnormally. Once opened, the file remains open for the duration of the run unit. If any error occurs during a write or read operation on the execution log file, no messages can report this problem and the run unit terminates abnormally.
Program Execution PARAM Command The PRINTER-CONTROL parameter provides a way for the program to respond to printer faults. Suppose a PRINTER-CONTROL parameter specifies the file name CHEX. This causes the run-time library to keep track of each elementary control function or write request that it sends to the operating environment for the file CHEX.
Program Execution • PARAM Command Additional Considerations ° A parameter value that contains any embedded commas or leading or trailing spaces must be enclosed in quotation marks. Between the delimiting quotation marks, two consecutive quotation marks ("") represent any one quotation mark (") that is part of the value. The delimiting quotation marks are not stored. ° TACL provides internal storage for 1024 bytes of parameters.
Program Execution CLEAR Command CLEAR Command Use the CLEAR command to revoke a specific ASSIGN or PARAM command, all of the ASSIGN commands, all of the PARAM commands, or all of both commands. CLEAR ALL ASSIGN PARAM ASSIGN assignation PARAM DEBUG EXECUTION-LOG INSPECT NONSTOP PRINTER-CONTROL WAITED-IO SWITCH- nn parameter-name VST340.vsd ALL means clear all currently active ASSIGN and PARAM references. ALL ASSIGN means clear all currently active ASSIGN references.
Program Execution CLEAR Command 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. * means all programs in the object file. PARAM means clear the reference to the specified parameter. DEBUG EXECUTION-LOG INSPECT NONSTOP PRINTER-CONTROL SWITCH-nn WAITED-IO parameter-name are parameters of the PARAM command (see PARAM Command). Example 12-5.
Program Execution DEFINEs 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 The statements of a COBOL program refer to files through a COBOL file name. The ASSIGN clause in each file-control entry associates the COBOL file name with a system-file-name, the name by which a file is known to the operating environment. In the Guardian environment, the TACL command ASSIGN can override that association and DEFINEs provide a different form of name redirection.
Program Execution DEFINE Attributes Example 12-6. DEFINE Names =A =The_chosen_file =Long--but-not-too-long =The-File-of-The-Week =X_-^-_-_-^-_-_-^ Uppercase and lowercase letters are equivalent in DEFINE names. Wherever a DEFINE name can appear in the text of a COBOL source program, it must appear in quotation marks. Wherever a DEFINE name appears in commands to the command interpreter, such as on the command line that initiates a COBOL compilation, the DEFINE name must appear without quotation marks.
Program Execution DEFINE Attributes Table 12-2.
Program Execution ADD DEFINE Command 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. • • You Can Use SPOOL DEFINES instead of COBOLSPOOLOPEN Special DEFAULTS DEFINE: =_DEFAULTS DEFINE Processes can use the =_DEFAULTS DEFINE without referring to it explicitly. The file system uses this DEFINE whenever it needs the values stored in the DEFINE’s attributes.
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 Called Program Termination A called program terminates its own execution either by executing an EXIT PROGRAM statement or by allowing control to pass beyond the end of its Procedure Division.
13 Libraries and Utility Routines Utility routines are object programs that your HP COBOL program can call. Utility routines are in libraries. TNS libraries are categorized by the memory area in which their routines execute: Library Type Memory Area Where Routines Execute Private object library (linkfile) User code space System library System code space TNS user library User library space If a TNS HP COBOL program calls a utility routine, the routine must be bound into the program’s target file.
Libraries and Utility Routines Figure 13-2. Native SRLs and Their Utility Routines ZCOBSRL ZCRESRL FastSort Routines SMU Routines Other CBL85UTL routines Other COBOLLIB routines CLU_PROCESS_CREATE_ Routines whose TNS versions are in the system library Routines whose TNS versions are in the system library VST730.vsd PIC programs (native HP COBOL programs that are compiled with the NMCOBOL compiler and the directive CALL-SHARED or SHARED) can call dynamic-link libraries (DLLs), which you can build.
Libraries and Utility Routines • • • • • ZCRESRL Overview CBL85UTL and ZCOBSRL Routines COBOLLIB, CLULIB, and ZCOBSRL Routines Saved Message Utility (SMU) Routines Guardian Environment Level 3 Spooling Routines Table 13-1.
Libraries and Utility Routines Table 13-1.
Libraries and Utility Routines Table 13-1. All TNS and TNS/R Utility Routines (page 3 of 3) Utility Routines Environments Libraries SMU_Startup_Delete_ CRE CLULIB and ZCRESRL SMU_Startup_GetText_ CRE CLULIB and ZCRESRL SMU_Startup_PutText_ CRE CLULIB and ZCRESRL 1. Routines for the non-CRE environment are available only in the Guardian environment.
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.
Libraries and Utility Routines Memory Areas Table 13-2. Memory Area Characteristics (page 2 of 2) Memory Area Purpose Size Comments Holds data blocks of data declared in Extended-Storage Sections of COBOL programs and compiler-generated tables One segment of extended memory (134,217,726 bytes) The maximum data item size is 134,217,726 bytes. Small data area2 Holds data blocks produced by the compilation 32,768 characters See LARGEDATA.
Libraries and Utility Routines Linkfiles as Libraries Linkfiles as Libraries A linkfile can serve as your TNS user library (for the COBOL85 compiler) or user library (for the NMCOBOL compiler). A link file cannot be executed as a process, due to its lack of a main program; however, the code in the file can be executed. To call utility routines from a user library, use CALL or ENTER statements (see CALL and ENTER).
Libraries and Utility Routines User Library The language in which a routine is written determines whether it can execute in user library space: Language in Which Routine is Written Routine Can Execute in User Library Space HP COBOL Yes, if the ENV LIBRARY directive is specified HP C Yes, if the ENV EMBEDDED directive is specified HP C++ Yes, if the ENV EMBEDDED directive is specified FORTRAN Yes, but then it cannot have any COMMON, DATA, or SAVE statements Pascal No TAL Yes, if no global bloc
Libraries and Utility Routines Building a User Library Building a User Library A program can be put in a user library if: • • • It is not a main program. It does not contain embedded SQL/MP or SQL/MX statements. It does not contain external objects (data or files that are to be shared with code that is outside the library). Note. ASSIGN and PARAM commands for files in a user library are ignored.
Libraries and Utility Routines Dynamic-Link Libraries (DLLs) Dynamic-Link Libraries (DLLs) Note. This topic applies only to the NMCOBOL compiler. A TNS program uses a TNS user library (see TNS User Library). 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/R Systems.) You can put a program in a DLL if: • • • It is not a main program.
Libraries and Utility Routines Building a DLL From a Single Source File Topics: • • • • • • Guardian Environment: One-Step Method Guardian Environment: Two-Step Method 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 LD with either of these options: ° ° -export_all, which exports all program names in the source fi
Libraries and Utility Routines Building a DLL From a Single Source File 2. Link the linkfile, using the ld 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 -l ZCOBSRL -l ZCRESRL, which links your file with the SRLs named ZCOBSRL and ZCRESRL The resulting loadfile is a DLL.
Libraries and Utility Routines Building a DLL From a Single Source File OSS Environment: Two-Step Method 1. Compile the source file with these options: • • -Wshared -c The result is a linkfile. 2. Link the linkfile, using the ld 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 Building a DLL from Multiple Source Files Example 13-5. Building a DLL From a Single Source File in One Step (PC) nmcobol lib1.cob -Wshared -Wld="-export_all" -o mydll PC Environment: Two-Step Method 1. Compile the source file with these options: • • -Wshared -c The result is a linkfile. 2.
Libraries and Utility Routines Building a DLL from Multiple Source Files 2. Link the resulting linkfiles into a single loadfile. Topics: • • • Guardian Environment OSS Environment PC Environment 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.
Libraries and Utility Routines Building a DLL from Multiple Source Files OSS Environment 1. Compile each source file with these options: • • -Wshared -c The result of each compilation is a linkfile. 2. Link the linkfiles into a single loadfile, using the ld 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 ld 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 Specifying a DLL To use an existing DLL, you must specify it to both the compiler and the linker. You can do this in either one step or two.
Libraries and Utility Routines Specifying a DLL 2. Link the linkfile, using the ld utility with these ld options: • • • -L (which is similar to the nmcobol option -L) -l or -lib (which is similar to the nmcobol option -l) -optional_lib -l ZCOBSRL -l ZCRESRL, which links your file with the SRLs named ZCOBSRL and ZCRESRL For more information about the ld options -l or -lib, see the ld Manual.
Libraries and Utility Routines Specifying a DLL 2. Link the linkfile, using the ld utility with these ld options: • • • -L (which is similar to the nmcobol option -L) -l or -lib (which is similar to the nmcobol option -l) -optional_lib -l ZCOBSRL -l ZCRESRL, which links your file with the SRLs named ZCOBSRL and ZCRESRL For more information about the ld options -l or -lib, see the ld Manual. In Example 13-13, the first command compiles the source file main.
Libraries and Utility Routines Specifying a DLL PC Environment: Compile and Link in Two Steps 1. Compile the program that uses the DLL with these options: • • • -Wcall_shared -c -Wcobol, with the argument “CONSULT MYDLL” The result is a linkfile. 2.
Libraries and Utility Routines Files of Dummy Routines Files of Dummy Routines Files of dummy routines enable the compiler to accept ENTER statements that are to be resolved at program load time rather than by Binder during compilation (in the case of the COBOL85 compiler) or by the linker (in the case of the NMCOBOL compiler). Table 13-4.
Libraries and Utility Routines CBL85UTL Overview Table 13-5.
Libraries and Utility Routines FastSort Interface Overview FastSort Interface Overview The FastSort interface routines (in the CBL85UTL and ZCOBSRL files) give your HP COBOL program access to the FastSort utility program, which provides more extensive sorting features than HP COBOL has (such as parallel sorting). Use the FastSort interface routines only with FastSort. If you use them with SORT, the sort process might terminate abnormally.
Libraries and Utility Routines Establishing Parameters With =_SORT_DEFAULTS DEFINE For explanations of individual FastSort interface routines, see CBL85UTL and ZCOBSRL Routines. Establishing Parameters With =_SORT_DEFAULTS DEFINE Another way to establish FastSort parameters is with the default SORT DEFINE =_SORT_DEFAULTS. This method is recommended when it would be difficult to modify existing applications.
Libraries and Utility Routines COBOLLIB Overview Table 13-7. Where Versions of COBOLLIB Routines Are COBOL85 Compiler Routine Category Non-CRE Environment CRE NMCOBOL Compiler SMU COBOLLIB CLULIB ZCRESRL Other COBOLLIB COBOLLIB ZCOBSRL Table 13-8.
Libraries and Utility Routines COBOLLIB Routines in User Code Space You can put the routines that are in the file COBOLLIB in any one of these places: • • • • COBOLLIB Routines in User Code Space COBOLLIB Routines in User Library Space COBOLLIB Routines in a Special TNS User Library COBOLLIB Routines in System Code Space Topics Sources SMU routines in general Saved Message Utility (SMU) Overview Descriptions of individual SMU routines Saved Message Utility (SMU) Overview ZCOBSRL file ZCOBSRL Ove
Libraries and Utility Routines COBOLLIB Routines in System Code Space COBOLLIB Routines in System Code Space If you want the routines from the COBOLLIB file to run as part of the system library, and hence in the system code space, then your system manager must have incorporated the routines in the system library at system generation time. The COBOL85 compiler must be able to validate your ENTER statement, which requires the file CBLIBEXT. CBLIBEXT is part of every HP COBOL product version.
Libraries and Utility Routines CLULIB Overview Table 13-9. ZCOBSRL 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 ZCOBSRL routines, see: • • CBL85UTL and ZCOBSRL Routines COBOLLIB, CLULIB, and ZCOBSRL Routines.
Libraries and Utility Routines Saved Message Utility (SMU) Overview Table 13-10.
Libraries and Utility Routines Saved Message Utility (SMU) Overview Figure 13-3. 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 Saved Messages Modifies the messages Uses CREATEPROCESS to launch a new process that has customtailored ASSIGN, PARAM, and startup messages Descendent Process VST521.
Libraries and Utility Routines Saved Message Utility (SMU) Overview Table 13-11. Saved Message Utility (SMU) Routines (page 2 of 2) Original Routine1 New Routine2 GETASSIGNVALUE SMU_Assign_GetValue_ GETBACKUPCPU None GETPARAMTEXT SMU_Param_GetText_3 GETSTARTUPTEXT SMU_Startup_GetText_ PUTASSIGNTEXT SMU_Assign_PutText_ PUTASSIGNVALUE SMU_Assign_PutValue_ PUTPARAMTEXT4 SMU_Param_PutText_ PUTSTARTUPTEXT SMU_Startup_PutText_ 1. In the COBOLLIB file.
Libraries and Utility Routines Saved Message Utility (SMU) Overview The SMU consists of these routines. For complete descriptions of these routines, see Saved Message Utility (SMU) Routines.
Libraries and Utility Routines Checkpoint Lists for Process Pairs These routines operate upon copies of the process-creation messages that establish the execution environment of the program. Copies of these messages are not saved automatically and must be requested by a SAVE directive in the main program. For information on the SAVE directive, see SAVE.
Libraries and Utility Routines Defined Portions of Saved Messages Defined Portions of Saved Messages The SMU routines operate on the ASSIGN, PARAM, and startup messages, which have standard sets of defined portions. Table 13-13.
Libraries and Utility Routines ZCRESRL Overview ZCRESRL Overview ZCRESRL, a native SRL (public shared run-time library), is the native CRE run-time library. It contains the CRE routines which, for the COBOL85 compiler, resided in either the system library or CLULIB—that is, the CRE versions of the SMU routines. ZCRESRL routines are not bound into a user object file. The NMCOBOL compiler consults ZCRESRL automatically. ZCRESRL resides on the subvolume $SYSTEM.SYSnn.
Libraries and Utility Routines CBL85UTL and ZCOBSRL Routines CBL85UTL and ZCOBSRL Routines This topic explains the individual routines in the CBL85UTL file, which is for the COBOL85 compiler. The CRE routines are also in the ZCOBSRL file, which is for the NMCOBOL compiler. Table 13-16.
Libraries and Utility Routines COBOL85^ARMTRAP Topics: • • • • • • • • • • • • COBOL85^ARMTRAP COBOL85^COMPLETION and COBOL_COMPLETION_ COBOL_CONTROL_ COBOL_GETENV_ COBOL_PUTENV_ COBOL85^RETURN^SORT^ERRORS and COBOL_RETURN_SORT_ERRORS_ COBOL85^REWIND^SEQUENTIAL and COBOL_REWIND_SEQUENTIAL_ COBOL85^SET^SORT^PARAM^TEXT and COBOL_SET_SORT_PARAM_TEXT_ COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ COBOL_SET_MAX_RECORD_ COBOL_SETMODE_ COBOL85^SPECIAL^OPEN and COBOL_SPECIAL_OPEN_ COBOL85^ARMTRA
Libraries and Utility Routines COBOL85^COMPLETION and COBOL_COMPLETION_ COBOL85^COMPLETION and COBOL_COMPLETION_ The COBOL85^COMPLETION and COBOL_COMPLETION_ routines pass completion parameters to either the STOP or ABEND routine in the operating environment (depending on the abend-or-stop parameter). ns ENTER " ns COBOL85^COMPLETION " TAL OF library-reference USING abend-or-stop completion-code termination-info subsys-id text-length text VST342.
Libraries and Utility Routines COBOL85^COMPLETION and COBOL_COMPLETION_ The CRE equivalent of COBOL85^COMPLETION is COBOL_COMPLETION_. Unlike COBOL85^COMPLETION, COBOL_COMPLETION_ does not accept the parameter text-length. 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 COBOL85^COMPLETION and 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_ param is a numeric data item or arithmetic expression that is the param parameter of the Guardian environment routine CONTROL. For more information, see the Guardian Procedure Calls Reference Manual. 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.
Libraries and Utility Routines COBOL_GETENV_ Value Meaning (page 2 of 2) 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 Fast I-O. file-name specifies a closed file and there is not enough control space to allocate the queued information for the next open request. The program is running in the non-CRE environment and cpinfo has too few entries.
Libraries and Utility Routines COBOL_PUTENV_ COBOL_PUTENV_ The COBOL_PUTENV_ routine sets a specified environment variable to a specified value. This routine is available only to programs compiled for the CRE. 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.
Libraries and Utility Routines COBOL85^RETURN^SORT^ERRORS and COBOL_RETURN_SORT_ERRORS_ library-reference is a mnemonic-name in the SPECIAL-NAMES paragraph. For the COBOL85 compiler, this mnemonic-name is associated with either $SYSTEM.SYSTEM.CBL85UTL or some other object file containing an object copy of COBOL85^RETURN^SORT^ERRORS. For the NMCOBOL compiler, this mnemonic-name is associated with either $SYSTEM.SYSnn.ZCOBSRL or some other object file containing an object copy of COBOL_RETURN_SORT_ERRORS_.
Libraries and Utility Routines COBOL85^RETURN^SORT^ERRORS and COBOL_RETURN_SORT_ERRORS_ Usage Considerations: • Error Detection and Reporting If the process calls COBOL85^RETURN^SORT^ERRORS or COBOL_RETURN_SORT_ERRORS_ before it executes a SORT or MERGE statement, the HP COBOL run-time library returns the appropriate values in error-info after execution of a a RELEASE, RETURN, SORT, or MERGE statement.
Libraries and Utility Routines COBOL85^REWIND^SEQUENTIAL and COBOL_REWIND_SEQUENTIAL_ COBOL85^REWIND^SEQUENTIAL and COBOL_REWIND_SEQUENTIAL_ The COBOL85^REWIND^SEQUENTIAL and COBOL_REWIND_SEQUENTIAL_ routines enable you to reposition a sequential disk or single-file tape file to its beginning without closing and reopening it. ENTER ns " COBOL85^REWIND^SEQUENTIAL ns " COBOL_REWIND_SEQUENTIAL_ OF library-reference USING file-name GIVING return-code VST345.
Libraries and Utility Routines COBOL85^REWIND^SEQUENTIAL and COBOL_REWIND_SEQUENTIAL_ Usage Considerations: • File Criteria file-name must be a valid COBOL file name, the file associated with filename must be open at the time of the call and the file-control entry for file-name must specify ORGANIZATION SEQUENTIAL.
Libraries and Utility Routines COBOL85^SET^SORT^PARAM^TEXT and COBOL_SET_SORT_PARAM_TEXT_ COBOL85^SET^SORT^PARAM^TEXT and COBOL_SET_SORT_PARAM_TEXT_ The COBOL85^SET^SORT^PARAM^TEXT and COBOL_SET_SORT_PARAM_TEXT_ routines establish alphanumeric parameters in the option block (the local list of parameters that HP COBOL passes to FastSort for the next sort or merge operation).
Libraries and Utility Routines COBOL85^SET^SORT^PARAM^TEXT and COBOL_SET_SORT_PARAM_TEXT_ 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 a FastSort routine refers to the same sd-name and to the same parameter, that call resets the specifications for any subsequent SORT or MERGE statements that refer to the same file name.
Libraries and Utility Routines COBOL85^SET^SORT^PARAM^TEXT and COBOL_SET_SORT_PARAM_TEXT_ Table 13-17. 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.
Libraries and Utility Routines COBOL85^SET^SORT^PARAM^TEXT and COBOL_SET_SORT_PARAM_TEXT_ Table 13-17. 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.
Libraries and Utility Routines COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ The COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ routines establish numeric parameters in the option block. These parameters affect any subsequent SORT statement execution.
Libraries and Utility Routines COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ 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 statements that refer to this file name. If a subsequent call to a FastSort routine refers to the same file name and to the same parameter, that call resets the specifications for any subsequent sort operations that refer to the same file name.
Libraries and Utility Routines COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ subsort-or-file-number is a numeric operand whose value is the sort process to which the parameter pertains or, if the parameter applies to a file, it is a file ordinal. If a subsort-number is being supplied, the number of subsorts must have been set previously (with the SUBSORT-COUNT parameter) and subsort-number must be in the range 1 to that number.
Libraries and Utility Routines • COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ Value of param-value Depends on Value of param-id The default for each param-value is the same as the default for its param-id. For example, if you do not specify BUFFER-SIZE, you get the same result as you do if you specify BUFFER-SIZE with no param-value : you get 8192. ° BUFFER-SIZE specifies the size of the buffer used for processing records when an input procedure or an output procedure is specified.
Libraries and Utility Routines ° COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ CREATE-NEW-OUTPUT specifies whether the output (GIVING) file is to be created anew or the existing output file is to be used. Allowable Value for param-value Meaning 0 (default) If the output file exists and is large enough for the sort, the data is purged from the file. If the file is too small, the file is purged and a new one is created. nonzero The file is purged and a new one is created.
Libraries and Utility Routines COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ Large sorts (greater than 50K records) may terminate abnormally with the scratch file being too small if record-count is not used for sorts using tapes or sorts using an input procedure. Small sorts may use more system resources than necessary. If subsort-or-file-number specifies a file number, it must be in the range 1 through 32.
Libraries and Utility Routines COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ See the FastSort Manual for details. subsort-or-file-number must not be specified or must be 0. ° MINTIME specifies whether FastSort is to operate in the MINTIME mode; that is, whether FastSort should attempt to reduce execution time at the expense of physical memory. Allowable Value for param-value Meaning 0 (default) Operation is similar to MINSPACE mode.
Libraries and Utility Routines ° COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ OUT-FILE-EXCL specifies the exclusion mode with which the sort opens a GIVING file. Allowable values are: Value Exclusion Mode Specified -1 Default (exclusive for disk or tape, shared for any other file type) 0 Shared 1 Exclusive 3 Protected subsort-or-file-number must not be specified or must be 0. ° OUT-FILE-FORMAT specifies the format of the output file. Allowable values are 0, 1, 2, and 3.
Libraries and Utility Routines ° COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ REMOVE-DUPLICATES specifies whether FastSort should remove records with duplicate keys during the sort operation. Allowable Value for param-value Meaning 0 (default) Duplicates are not to be removed. nonzero FastSort must remove every record whose keys duplicate those of a previous record. subsort-or-file-number must not be specified or must be 0.
Libraries and Utility Routines ° COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ SCRATCH-CHECK specifies whether FastSort must check the size of each named scratch file to see whether it is large enough. Allowable Value for param-value Meaning 0 FastSort must check scratch file size. nonzero (default) FastSort must not check scratch file size. Nonzero is the default for HP COBOL—the default for the FastSort product by itself is 0).
Libraries and Utility Routines COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ If subsort-or-file-number is specified, SEGMENT applies to the indicated subsort. If subsort-or-file-number is 0, SEGMENT applies to the distributor/collector process. If the param-value associated with SUBSORT-COUNT is 0 or not specified, SEGMENT applies to the normal sort, and subsort-or-file-number must be omitted or 0.
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_SETMODE_ 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. For the non-CRE environment: the FD is external. 3 The second parameter has been omitted and no file exists from which to obtain the record length.
Libraries and Utility Routines ENTER " OF COBOL_SETMODE_ ns COBOL_SETMODE_ ns " library-reference USING file-name function param-1 param-2 lastparams cpinfo GIVING error-return VST611.vsd library-reference is a mnemonic-name associated in the SPECIAL-NAMES paragraph with either $SYSTEM.SYSTEM.CBL85UTL or some other object file containing an object copy of COBOL_SETMODE_. file-name is a COBOL file name associated with a file that is not $RECEIVE and is not open for HP COBOL Fast I-O.
Libraries and Utility Routines COBOL_SETMODE_ lastparams is a data item at least four characters long that corresponds to the last-params parameter of the Guardian environment routine SETMODE. For best results, define it as a group with two NATIVE-2 data items immediately subordinate to it; for example: 01 LASTPARAMS 02 PARAM1 02 PARAM2 NATIVE-2 NATIVE-2 cpinfo is a checkpoint list in which the routine records the changes to the message storage data space. Example: 01 CP-LIST-1.
Libraries and Utility Routines Value Meaning (page 2 of 2) 5 One of: • • • COBOL85^SPECIAL^OPEN and COBOL_SPECIAL_OPEN_ file-name specifies an open file that is either $RECEIVE or is open for HP COBOL Fast I-O. file-name specifies a closed file and there is not enough control space to allocate the queued information for the next open request. The program is running in the non-CRE environment and cpinfo has too few entries.
Libraries and Utility Routines • COBOL85^SPECIAL^OPEN and COBOL_SPECIAL_OPEN_ Acceptable Values for the Parameter open-type The value of the open-type parameter determines what type of device the COBOL85^SPECIAL^OPEN or COBOL_SPECIAL_OPEN_ routine opens. Acceptable values for open-type (after truncation to an integer value, if necessary) and their meanings are: Value Meaning 1 Open a printer or spooler. 2 Open a system log file. 3 Open a partitioned disk file. 4 Open a tape file in the CRE.
Libraries and Utility Routines ENTER COBOL85^SPECIAL^OPEN and COBOL_SPECIAL_OPEN_ ns " COBOL85^SPECIAL^OPEN ns " COBOL_SPECIAL_OPEN_ OF 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 VST348.vsd library-reference is a mnemonic-name in the SPECIAL-NAMES paragraph.
Libraries and Utility Routines COBOL85^SPECIAL^OPEN and 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.
Libraries and Utility Routines COBOL85^SPECIAL^OPEN and 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 COBOL85^SPECIAL^OPEN and 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 COBOL85^SPECIAL^OPEN and 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 COBOL85^SPECIAL^OPEN and COBOL_SPECIAL_OPEN_ In the Guardian environment, all the functions of this form of COBOL85^SPECIAL^OPEN or 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 COBOL85^SPECIAL^OPEN or 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 ENTER " COBOL85^SPECIAL^OPEN and COBOL_SPECIAL_OPEN_ ns COBOL85^SPECIAL^OPEN ns " COBOL_SPECIAL_OPEN_ OF library-reference USING file-name open-type = 2 exclusion sync-depth GIVING time-limits return-code VST349.vsd library-reference is a mnemonic-name in the SPECIAL-NAMES paragraph. For the COBOL85 compiler, this mnemonic-name is associated with either $SYSTEM.SYSTEM.CBL85UTL or some other object file containing an object copy of COBOL85^SPECIAL^OPEN.
Libraries and Utility Routines COBOL85^SPECIAL^OPEN and COBOL_SPECIAL_OPEN_ sync-depth is a numeric operand that specifies the sync-depth attribute for the open operation. The evaluation of this operand includes, if necessary, truncation to an integer value. If this parameter is present, it must be in the range 0 through 255; if it is omitted, the value assumed depends on the nature of the file. For a system log file, the routine uses a value of 1.
Libraries and Utility Routines COBOL85^SPECIAL^OPEN and COBOL_SPECIAL_OPEN_ Partitioned Disk Files When the parameter open-type has the value 3, the COBOL85^SPECIAL^OPEN or COBOL_SPECIAL_OPEN_ routine opens a partitioned disk file even though some partitions cannot be accessed. (The OPEN statement requires all partitions to be accessible.
Libraries and Utility Routines COBOL85^SPECIAL^OPEN and 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.
Libraries and Utility Routines COBOL85^SPECIAL^OPEN and COBOL_SPECIAL_OPEN_ When the COBOL85^SPECIAL^OPEN or COBOL85_SPECIAL_OPEN_routine with an open-type of 3 has performed a successful open operation, the special register GUARDIAN-ERR contains the value 3 (failure to open a partition) if the operating environment reports that file code. In this case, the I-O status code is “00.
Libraries and Utility Routines COBOL85^SPECIAL^OPEN and 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 tape file. open-type is a numeric operand whose value (after truncation to an integer value, if necessary) is 4. The value 4 signifies the opening of a tape file. exclusion is a numeric operand that specifies the exclusion attribute for the open operation.
Libraries and Utility Routines COBOL85^SPECIAL^OPEN and COBOL_SPECIAL_OPEN_ mount-messages is the name of a data item that describes the name of the file to be used for tape mount messages. The file name must be left-justified and in Guardian external format with no trailing spaces. Reference modification can give the length of the name. The file must be a process or terminal. If mount-messages is omitted, tape mount messages are written to the execution log file.
Libraries and Utility Routines COBOLLIB, CLULIB, and ZCOBSRL Routines COBOLLIB, CLULIB, and ZCOBSRL Routines This topic explains the individual routines in the COBOLLIB and ZCOBSRL files that are not Saved Message Utility (SMU) routines. Not all of the CRE equivalents are in the COBOLLIB file (see the table notes). Programs compiled with the COBOL85 compiler can call all of the routines listed in Table 13-18. Programs compiled with the NMCOBOL compiler can call only the new routines. Table 13-18.
Libraries and Utility Routines COBOLASSIGN COBOLASSIGN The COBOLASSIGN routine enables an HP COBOL program to perform an ASSIGNlike 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 COBOLASSIGN library-reference is a mnemonic-name associated, in the SPECIAL-NAMES paragraph, with either COBOLLIB or some other object file containing an object copy of COBOLASSIGN. See Files of Dummy Routines. fd-name is the fd-name of a file connector. The file specified in the ASSIGN phrase of the SELECT clause that references fd-name will be replaced by system-filename.
Libraries and Utility Routines COBOLASSIGN A CLOSE LOCK on a file using a dynamic fd-name closes the file but does not lock it. If locking were allowed, it would only prevent the reuse of the fd-name for the remainder of the run unit’s existence; the file would still be accessible through another dynamic fd-name. A command interpreter ASSIGN command cannot designate an fd-name as dynamically assignable—you must do this in the source program.
Libraries and Utility Routines COBOL_ASSIGN_ COBOL_ASSIGN_ COBOL_ASSIGN_ is the CRE-equivalent of the COBOL-environment routine COBOLASSIGN. If a CRE HP COBOL program calls COBOLASSIGN, it actually calls COBOL_ASSIGN_ indirectly. The advantages to calling COBOL_ASSIGN_ directly are: • • • You can pass all parameters from the Extended-Storage Section or Linkage Section. You can specify temporary file names. You can specify two additional parameters, file-code and file-type.
Libraries and Utility Routines COBOL_ASSIGN_ system-file-name is an alphanumeric data item holding the file-system file name of the file to be assigned. system-file-name is in external form. It must be left-justified in the data item and any unused portion of the name must contain spaces. 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.
Libraries and Utility Routines COBOLFILEINFO error-number is a numeric data item in which COBOL_ASSIGN_ returns an error code. Possible values for error-number and their respective meanings are: Value Meaning 0 No error occurred. 1 system-file-name has invalid syntax or the name has no length (such as a group containing an OCCURS DEPENDING whose length is 0). 2 system-file-name is open and cannot be changed. 4 There is not enough system space to add the new name.
Libraries and Utility Routines COBOLFILEINFO COBOLLIB to provide automatic resolution of the reference. The general form of the ENTER statement to use COBOLFILEINFO follows. ns ENTER " ns COBOLFILEINFO " TAL OF library-reference USING fd-name error-code file-name file-number VST357.vsd library-reference is a mnemonic-name associated, in the SPECIAL-NAMES paragraph, with either COBOLLIB or some other object file containing an object copy of COBOLFILEINFO.
Libraries and Utility Routines COBOL_FILE_INFO_ In the CRE, if file-name is composed entirely of spaces or has an 8-character volume name, it cannot be converted to internal form. To convert it to internal form, use the COBOL_FILE_INFO_ routine. The access mode (see Linkage Section) of file-name must be STANDARD. file-number is a numeric data item described as USAGE COMPUTATIONAL PICTURE S99. The COBOLFILEINFO routine returns the file’s open number to this data item.
Libraries and Utility Routines COBOL_FILE_INFO_ As with any ENTER statement, you must either qualify the name COBOL_FILE_INFO_ with the library-reference COBOLLIB or include a SEARCH directive specifying COBOLLIB to provide automatic resolution of the reference. The general form of the ENTER statement to use COBOL_FILE_INFO_ follows. ENTER " COBOL_FILE_INFO_ " TAL OF library-reference USING file-name name-buffer name-size file-number error VST636.
Libraries and Utility Routines COBOLSPOOLOPEN file-number is the Guardian or OSS file number. If the file is not open, file-number is 0. If, after the file was opened, the I-O status code was “05,” rather than “00” (see Nonexistent Files), file-number is -1. error is the last Guardian error number. If the file is an OSS file, error is 0.
Libraries and Utility Routines COBOLSPOOLOPEN COBOLSPOOLOPEN accepts an fd-name associated with either a process or a printer. If the file referred to is a process, it is assumed to be an HP spooler. If the designated file is a printer, COBOLSPOOLOPEN ignores all spooler-specific parameters and produces the same results as a HP COBOL OPEN statement.
Libraries and Utility Routines COBOLSPOOLOPEN library-reference is a mnemonic-name associated, in the SPECIAL-NAMES paragraph, with either COBOLLIB or some other object file containing an object copy of COBOLSPOOLOPEN. The mnemonic-name must be left-justified and can have trailing spaces. fd-name is a file name that identifies the COBOL logical file, described by the FD entry associated with the spooler. The file name must be left-justified and can have trailing spaces. file-status Note.
Libraries and Utility Routines COBOLSPOOLOPEN report-name is a 16-character alphanumeric, PIC X(16), that identifies the string passed to the spooler as its report-name parameter. The data item must be at least 16 characters. If longer, only the first 16 characters are passed to the spooler. Only letters, digits, and spaces are acceptable to the spooler. The first character cannot be a space. No character can be a hyphen. The access mode (see Linkage Section) of report-name must be STANDARD.
Libraries and Utility Routines COBOLSPOOLOPEN sync-depth is a numeric item (COMPUTATIONAL or DISPLAY), a numeric literal, or a parenthetical expression that evaluates to a positive integer, which is used as the sync-depth of the spooler file. Its default value is 3. A value greater than 32 results in a file-system error 28 from the spooler. The sync-depth specifies the number of write requests whose completion status the file system is to remember.
Libraries and Utility Routines COBOLSPOOLOPEN Establishing a Declarative-File Connection The HP COBOL compilers find the connection between generic file declarative sections and logical files by examining the context of OPEN statements. A declarative section preceded by a USE AFTER EXCEPTION PROCEDURE ON OUTPUT statement is implicitly associated with each file whose name appears in an OPEN OUTPUT statement.
Libraries and Utility Routines CREATEPROCESS CREATEPROCESS The CREATEPROCESS routine starts a new process according to parameters you specify. It can also send process-creation messages that might have been altered by SMU routines to the new process according to the option parameter specifications. The CREATEPROCESS routine is available only in the Guardian environment. In the OSS environment, use the OSS process create function fork() or tdm_fork(2) (see the Open System Services Programmer’s Guide).
Libraries and Utility Routines CREATEPROCESS program-file is an alphanumeric data item containing the file-system file name of the loadfile to be executed. Any trailing spaces are ignored. Example: 05 - PROGRAM-FILE PIC X(35) VALUE "\CENTRAL.$CRPMIS.DEVELOP.AMR1459". The access mode (see Linkage Section) of program-file must be STANDARD. process-name is an alphanumeric data item containing the name for the new process.
Libraries and Utility Routines CREATEPROCESS Normally, if NEWPROCESS reports a class one error, undefined externals, the new process stops. An application can force new process creation by adding 8 to the normal option value (8 instead of 0, 9 instead of 1, …, 11 instead of 3). CREATEPROCESS returns the class one error result even though the new process is created. The value 8 indicates the undefined externals are not considered an error. priority is the NEWPROCESS priority parameter.
Libraries and Utility Routines CREATEPROCESS process-id is a numeric data item to be assigned the process identification of the new process. The process-id data item must be COMPUTATIONAL or NATIVE-8 and described with 10 through 18 nines. process-id can be omitted by supplying the keyword OMITTED instead of a numeric data item. OMITTED indicates that no process identification is returned. Example: 08 PROCESS-ID PIC S9(18) COMPUTATIONAL.
Libraries and Utility Routines Saved Message Utility (SMU) Routines Saved Message Utility (SMU) Routines This topic explains the individual Saved Message Utility (SMU) routines in the COBOLLIB file, which are: • • • • • • • • • • • • • • • ALTERPARAMTEXT CHECKLOGICALNAME CHECKMESSAGE DELETEASSIGN DELETEPARAM DELETESTARTUP GETASSIGNTEXT GETASSIGNVALUE GETBACKUPCPU GETPARAMTEXT GETSTARTUPTEXT PUTASSIGNTEXT PUTASSIGNVALUE PUTPARAMTEXT PUTSTARTUPTEXT Note.
Libraries and Utility Routines ALTERPARAMTEXT ALTERPARAMTEXT Use the ALTERPARAMTEXT routine to create or replace a parameter value for the specified parameter name in the saved PARAM message with text from a string variable. Unlike the PUTPARAMTEXT routine, ALTERPARAMTEXT provides for parameter values with trailing spaces. The general form of the ENTER statement to use ALTERPARAMTEXT follows.
Libraries and Utility Routines ALTERPARAMTEXT cplist is a checkpoint list in which the routine records the changes to the message storage data space. 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.
Libraries and Utility Routines CHECKLOGICALNAME ALTERPARAMTEXT returns one of these integer values to report the routine’s success or failure: Value Meaning 0 or greater A nonnegative value, equal to the number of characters in the new parameter value, indicates that size characters of text value is assigned as the new parameter value. -1 Failure due to a logic error. The message is unchanged. These are possible logic errors: • • • • The portion identifier is not correct.
Libraries and Utility Routines CHECKLOGICALNAME logical-name file-name program-unit . * VST639.vsd program-unit is an alphanumeric data item that specifies the name of the program unit. file-name is an alphanumeric data item that specifies the logical file name. programunit and file-name together, or file-name alone, compose the logical file name. The logical file name can have a maximum of 63 characters (including the period). Any trailing spaces are ignored. Example: 02 LOGICAL-NAME PIC X(64).
Libraries and Utility Routines CHECKMESSAGE CHECKMESSAGE The CHECKMESSAGE routine determines whether a specific message exists or reports the greatest message number of the saved ASSIGN messages. CHECKMESSAGE operates on the saved messages. The program must have included a SAVE directive to save the message. The general form of the ENTER statement to use CHECKMESSAGE is: ns ENTER ns CHECKMESSAGE " " TAL OF library-reference USING message-number GIVING result VST353.
Libraries and Utility Routines DELETEASSIGN result is either a DISPLAY or COMPUTATIONAL numeric data item assigned the result returned by CHECKMESSAGE. Example: 08 RESULT PIC S9999 COMPUTATIONAL. Under these conditions, result has these values: Condition Value of result Value of message-number is not 0 and requested message exists Value of message-number Value of message-number is not 0 and requested message does not exist 0 Value of message-number is 0 and no saved ASSIGN messages exist.
Libraries and Utility Routines DELETEASSIGN portion is an alphanumeric data item that supplies the identifier for the particular part of the saved message to be deleted. The identifier must be one defined for the ASSIGN message (see Table 13-13). The first unused character position of portion, if any, must be a space. Any message part except the LOGICALNAME can be deleted individually. Example: 03 PORTION PIC X(30) VALUE "TANDEMNAME".
Libraries and Utility Routines DELETEASSIGN message-number identifies a specific saved ASSIGN message. message-number can be a DISPLAY or COMPUTATIONAL numeric data item, a numeric literal, or an expression enclosed in parentheses. The value must evaluate to a positive integer. Example: 14 MESSAGE-NUMBER PIC S9999 COMPUTATIONAL. Because each saved ASSIGN message is identified by a positive integer, message-number refers to the integer value of the specific message.
Libraries and Utility Routines DELETEPARAM DELETEPARAM The DELETEPARAM routine deletes either specific parts of a PARAM message or the entire PARAM message. The general form of the ENTER statement to use DELETEPARAM is: ns ENTER OF ns DELETEPARAM " " library-reference USING portion GIVING result cplist VST361.vsd Note. DELETEPARAM uses a protocol different from that used for normal TAL procedures. The ENTER verb must not be followed by the keyword TAL.
Libraries and Utility Routines DELETEPARAM The initial value of MAX-COUNT must be the same as the number of occurrences of ELEMENT. In the non-CRE environment, the initial value of MAX-COUNT is the maximum number of elements that cplist can contain. In the CRE, the maximum number of elements that cplist can contain is the initial value of MAX-COUNT divided by 2.5. The cplist in the preceding example can contain 100 elements in the non-CRE environment, but only 40 in the CRE.
Libraries and Utility Routines DELETESTARTUP DELETESTARTUP The DELETESTARTUP routine deletes an entire startup message. The general form of the ENTER statement to use DELETESTARTUP is: ns ENTER OF ns DELETESTARTUP " " library-reference USING portion GIVING result cplist VST362.vsd Note. DELETESTARTUP uses a protocol different from that used for normal TAL procedures. The ENTER verb must not be followed by the keyword TAL.
Libraries and Utility Routines DELETESTARTUP In the non-CRE environment, the initial value of MAX-COUNT is the maximum number of elements that cplist can contain. In the CRE, the maximum number of elements that cplist can contain is the initial value of MAX-COUNT divided by 2.5. The cplist in the preceding example can contain 100 elements in the non-CRE environment, but only 40 in the CRE. The required number of table elements depends on the number of operations the list must record.
Libraries and Utility Routines GETASSIGNTEXT GETASSIGNTEXT The GETASSIGNTEXT routine gets part of an ASSIGN message as text and assigns it to a string variable. The general form of the ENTER statement to use GETASSIGNTEXT is: ns ENTER OF ns GETASSIGNTEXT " " library-reference USING portion GIVING result text message-number VST363.vsd Note. GETASSIGNTEXT uses a protocol different from that used for normal TAL procedures. The ENTER verb must not be followed by the keyword TAL.
Libraries and Utility Routines GETASSIGNTEXT The text returned from a specific part of an ASSIGN message is: LOGICALNAME The text contains the program unit name and the logical file name, formatted like this, with a maximum of 63 characters: programunit.filename If the logical name does not include the program unit name, the text contains only this, with no qualifier: filename TANDEMNAME The text is the file-system file name and can have a maximum of 34 characters. The file name can be all spaces.
Libraries and Utility Routines GETASSIGNVALUE GETASSIGNTEXT returns an integer value that indicates the outcome of this operation. The integer values and their meanings are: Value Meaning 0 or greater A string of value characters, before truncation or padding, is assigned to text. If the file-system file name is all spaces and the TANDEMNAME is requested, a 0 is returned. -1 Failure due to a logic error; nothing is assigned to text.
Libraries and Utility Routines GETASSIGNVALUE portion is an alphanumeric data item that supplies the identifier for the particular integer part of the message to be retrieved. The identifier must be one defined for the ASSIGN message (see Table 13-13). The first unused character position of portion, if any, must be a space. Example: 05 PORTION PIC X(30) VALUE "SECEXT". val is a numeric data item into which the retrieved value is placed.
Libraries and Utility Routines GETBACKUPCPU GETBACKUPCPU The GETBACKUPCPU routine retrieves a backup processor number from the PARAM message of a COBOL program. Its operation depends on the existence of a saved PARAM message containing the parameter name BACKUPCPU with a digit string parameter value. GETBACKUPCPU is especially intended for TS/MP users. The general form of the ENTER statement to use GETBACKUPCPU is: ns ENTER " ns GETBACKUPCPU " TAL OF library-reference GIVING result VST365.
Libraries and Utility Routines GETPARAMTEXT GETPARAMTEXT The GETPARAMTEXT routine gets a specified part of the PARAM message as text and assigns it to a string variable. The general form of the ENTER statement to use GETPARAMTEXT is: ns ENTER OF ns GETPARAMTEXT " " library-reference USING portion GIVING result text VST366.vsd Note. GETPARAMTEXT uses a protocol different from that used for normal TAL procedures. The ENTER verb must not be followed by the keyword TAL.
Libraries and Utility Routines GETPARAMTEXT text is the alphanumeric data item in which the retrieved text is placed. If this data item is described with a JUSTIFIED clause, that clause is ignored. If the variable and the retrieved text differ in length, the retrieved text is truncated or extended with spaces as required. Example: 13 TEXT-VALUE PIC X(120). The text returned from a specific PARAM message parameter is the parameter value associated with that parameter name.
Libraries and Utility Routines GETSTARTUPTEXT GETSTARTUPTEXT The GETSTARTUPTEXT routine gets a specified part of the startup message as text and assign it to a string variable. The general form of the ENTER statement to use GETSTARTUPTEXT is: ns ENTER OF ns GETSTARTUPTEXT " " library-reference USING portion GIVING result text VST367.vsd Note. The ENTER verb must not be followed by the keyword TAL, because GETSTARTUPTEXT uses a protocol different from that of normal TAL procedures.
Libraries and Utility Routines GETSTARTUPTEXT The text values returned from specific startup message parts are: VOLUME The text contains the default system, volume, and subvolume names, formatted like this, with a maximum of 25 characters: \system.$volume.subvol If the volume part does not include the system name component, the text contains only this, with no system qualifier: $volume.subvol IN The text is the file system name of the input file and can have a maximum of 35 characters.
Libraries and Utility Routines PUTASSIGNTEXT PUTASSIGNTEXT The PUTASSIGNTEXT routine either creates or replaces a specified part of an ASSIGN message with text obtained from a string variable. The general form of the ENTER statement to use PUTASSIGNTEXT is: ns ENTER OF ns PUTASSIGNTEXT " " library-reference USING portion text cplist message-number GIVING result VST368.vsd Note. PUTASSIGNTEXT uses a protocol different from that used for normal TAL procedures.
Libraries and Utility Routines PUTASSIGNTEXT Appropriate text values for ASSIGN message parts are LOGICALNAME The text contains the program unit name and the logical file name, formatted like this, with a maximum of 63 characters: programunit.filename If the logical name does not include the program unit name, the text contains only this, with no qualifier: filename TANDEMNAME The text is the file-system file name and can have a maximum of 35 characters. The file name can be all spaces.
Libraries and Utility Routines PUTASSIGNTEXT Because each saved ASSIGN message is identified by a positive integer, message-number refers to the integer value of the specific message. The set of numbers associated with the ASSIGN messages are integers from 1 to N, where N is normally the number of ASSIGN messages saved during the initial process creation. result is a DISPLAY or COMPUTATIONAL numeric data item assigned the result returned by PUTASSIGNTEXT. Example: 04 RESULT PIC S9999 COMPUTATIONAL.
Libraries and Utility Routines PUTASSIGNTEXT PUTASSIGNTEXT returns an integer value that indicates the outcome of this operation. If the specified ASSIGN message does not exist, the PUTASSIGNTEXT routine attempts to create one containing the supplied text portion and default values for all other message parts. If this operation fails, a -1, -2, or -3 value is returned.
Libraries and Utility Routines PUTASSIGNVALUE PUTASSIGNVALUE The PUTASSIGNVALUE routine either creates or replaces a specified part of an ASSIGN message with the value obtained from an integer variable. The general form of the ENTER statement to use PUTASSIGNVALUE is: " ENTER OF ns ns PUTASSIGNVALUE " library-reference USING portion val cplist message-number GIVING result VST369.vsd Note. PUTASSIGNVALUE uses a protocol different from that used for normal TAL procedures.
Libraries and Utility Routines PUTASSIGNVALUE cplist is a checkpoint list in which the routine records the changes to the message storage data space. 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.
Libraries and Utility Routines PUTPARAMTEXT Changing a saved ASSIGN message has no effect on the current process. Any file assignments (except for dynamic assignments, as explained under COBOLASSIGN) are permanently established for a given process by the initialization code that the process executes before the first statement of the COBOL program. Any process initiated by the current process after execution of PUTASSIGNVALUE routine inherits the changed ASSIGN message.
Libraries and Utility Routines PUTPARAMTEXT Note. PUTPARAMTEXT uses a protocol different from that used for normal TAL procedures. The ENTER verb must not be followed by the keyword TAL. library-reference is a mnemonic-name associated in the SPECIAL-NAMES paragraph with either $SYSTEM.SYSTEM.COBOLLIB or some other object file containing an object copy of PUTPARAMTEXT. portion is an alphanumeric data item that supplies the identifier for the particular part of the message to be changed.
Libraries and Utility Routines PUTPARAMTEXT result is a DISPLAY or COMPUTATIONAL numeric data item assigned the result returned by PUTPARAMTEXT. Example: 04 RESULT PIC S9999 COMPUTATIONAL. PUTPARAMTEXT operates on the saved PARAM message. The program must have included a SAVE directive to save the message. Changing the saved PARAM message has no effect on the current process.
Libraries and Utility Routines PUTSTARTUPTEXT PUTSTARTUPTEXT The PUTSTARTUPTEXT routine either creates or replaces a specified part of the startup message with text obtained from a string variable. The general form of the ENTER statement to use PUTSTARTUPTEXT is: ns ENTER OF ns PUTSTARTUPTEXT " " library-reference USING portion GIVING result text cplist VST371.vsd Note. PUTSTARTUPTEXT uses a protocol different from that used for normal TAL procedures.
Libraries and Utility Routines PUTSTARTUPTEXT Appropriate text values for startup message parts are: VOLUME The text is the new default system, volume, and subvolume names, formatted like this, with a maximum of 26 characters: \system.$volume.subvol If the new volume part does not include the system name component, the text is just this, with no system qualifier. $volume.subvol IN The text is the file system name of the new input file and can have a maximum of 35 characters.
Libraries and Utility Routines PUTSTARTUPTEXT PUTSTARTUPTEXT operates on the saved startup message. The program must have included a SAVE directive to save the message. Changing the saved startup message has no effect on the current process. The IN and OUT files, the other run-command options, and any command-line parameters are permanently established for a given process by the initialization code that the process executes before the first statement of the COBOL program.
Libraries and Utility Routines Guardian Environment Level 3 Spooling Routines Guardian Environment Level 3 Spooling Routines Before the CBL85UTL file included the routines COBOL85^SPECIAL^OPEN and COBOL_SPECIAL_OPEN_, the Guardian environment routines in Table 13-19 were used for level 3 spooling. They were called with the ENTER verb. Table 13-19.
Libraries and Utility Routines Guardian Environment Level 3 Spooling Routines HP COBOL Manual for TNS and TNS/R Programs —522555-006 13- 140
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. Note. This function requires the CRE.
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. Note. This function requires the CRE.
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. Note. This function requires the CRE.
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. Note. This function requires the CRE.
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. Note. This function requires the CRE. To use this function in a TNS HP COBOL program, compile the program with the directive ENV COMMON. Example 14-18.
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. Note. This function requires the CRE. To use this function in a TNS HP COBOL program, compile the program with the directive ENV COMMON. Example 14-19.
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 =-1-----------------i-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 ORD-MIN 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 PRESENT-VALUE Function PRESENT-VALUE, a numeric function, returns a value that approximates the present value of a specified series of future period-end amounts at a specified discount rate. FUNCTION ( PRESENT-VALUE discount-rate period-end-amount ) VST455.vsd discount-rate is a numeric argument whose value is greater than -1. period-end-amount is a numeric argument.
Intrinsic Functions PRESENT-VALUE Function Example 14-32. PRESENT-VALUE 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 N OCCURS 5 TIMES PICTURE 9V99. 01 A PICTURE S99V99. PROCEDURE DIVISION. MOVE FUNCTION PRESENT-VALUE DISPLAY A. MOVE FUNCTION PRESENT-VALUE DISPLAY A.
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. Note. This function requires the CRE.
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 Note. This function requires the CRE. To use this function in a TNS HP COBOL program, compile the program with the directive ENV COMMON. Example 14-38. SQRT Function Code: DATA DIVISION. WORKING-STORAGE SECTION.
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. Note. This function requires the CRE.
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 WHEN-COMPILED 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 The returned value represents the current date this way (where character position 1 is the leftmost character position): Character Positions Date Part Represented Represented by 1-4 Year in Gregorian calendar Four digits 5-6 Month of the year Two digits in the range 01 through 12 7-8 Day of the month Two digits in the range 01 through 31 9-10 Hours past midnight Two digits in the range 00 through 23 11-12 Minutes past the hour Two digits in the r
15 Debugging Tools This section briefly describes the HP debugging tools and refers you to appropriate sources for more information. Topics: • • • • Standard COBOL Debugging Tools Run-Time Debuggers CROSSREF Utility Program FIXERRS Macro Standard COBOL Debugging Tools COBOL offers two batch-oriented debugging tools: Tool Applies to ...
Debugging Tools Standard COBOL Debugging Tools Debugging Declaratives Debugging declaratives are sections in the Declaratives Portion of the Procedure Division. A debugging declarative consists of a USE DEBUGGING statement followed by a procedure to be executed under the circumstances specified in the USE DEBUGGING statement. Note. The 1985 COBOL standard classifies USE DEBUGGING as obsolete, so you are advised not to use it, even in TNS HP COBOL programs. The NMCOBOL compiler does not recognize it.
Debugging Tools Standard COBOL Debugging Tools The contents of the elementary items within DEBUG-ITEM are: Elementary Item Contents DEBUG-LINE Number of source line that called the procedure being traced DEBUG-NAME First 30 characters of the name of the called procedure (including any section-name qualifier if the procedure is a paragraph) DEBUG-SUB-1 DEBUG-SUB-2 DEBUG-SUB-3 Not used DEBUG-CONTENTS Nonnumeric string varying in size and value (see next table) The contents of DEBUG-CONTENTS depend
Debugging Tools Run-Time Debuggers Run-Time Debuggers The HP run-time debuggers are: Debugger For PIC For Non-PIC Visual Inspect * Yes Yes Inspect No Yes Debug No Yes * PC-based Except for Debug, the HP run-time debuggers are interactive, and symbolic.
Debugging Tools Inspect Inspect • • • • • For non-PIC programs Symbolic Interactive Its LOW command allows you to reach machine code (the Inspect debugger in low-level mode is similar to the Debug debugger but more convenient) Handles TNS and native HP COBOL programs differently—see Using the Inspect and Visual Inspect Debuggers For more information, see the Inspect Manual.
Debugging Tools Debugger Selection More information: Topic Source Debug Debug Manual Load map listings Binder Manual Debugger Selection Figure 15-2. Debugger Selection for a TNS or Non-PIC Native Process Start INSPECT attribute on? No Yes Visual Inspect session? Yes Select Visual Inspect No Inspect available? No Yes Select Inspect Select Debug End VST195.
Debugging Tools Debugger Selection Figure 15-3. Debugger Selection for a PIC Native Process Start INSPECT attribute on? No Yes Visual Inspect session? No Yes Select Visual Inspect Select Debug End VST024.
Debugging Tools CROSSREF Utility Program Regarding Figure 15-3 and Figure 15-3: • • You can turn on the INSPECT attribute in any of these ways: ° Compile the program without a NOINSPECT directive (described in INSPECT and NOINSPECT). ° Compile the program with a SAVEABEND directive (described in SAVEABEND and NOSAVEABEND). ° ° Set the INSPECT attribute in the Binder or linker. ° Specify INSPECT ON as a run option in the RUN command that initiates the process.
Debugging Tools CROSSREF Utility Program Running the CROSSREF Utility You can run the CROSSREF utility interactively or with an OBEY command file. The command to run the CROSSREF utility interactively is: CROSSREF The command to run the CROSSREF utility with an OBEY command file (named XREFCMDS in this example) is: CROSSREF /IN XREFCMDS/ This explanation assumes that you are running CROSSREF interactively. If you run CROSSREF with an OBEY command file, put the CROSSREF commands in that file.
Debugging Tools FIXERRS Macro Example 15-3. Setting the Default COPY Library CROSSREF - CROSS-REFERENCE PROGRAM - T9622D20 - (8JUN92) ... &SET LANGUAGE COBOL85 &SET LIBRARY MYLIB &SET DIRECTIVES "ANSI;SETTOG 1" &SCAN PROBE &GENERATE /OUT $S.#CROS/ &EXIT Specifying Certain Identifier Types Only You can instruct CROSSREF to collect information about only certain types of identifiers.
Debugging Tools FIXERRS Macro tedit-command is the TEDIT command that you want to execute at the start of the FIXERRS session. You can move from error to error using the NEXTERR and PREVERR commands on the TEDIT command line. NEXTERR displays the error following the currently displayed error; PREVERR displays the error preceding the currently displayed error.
Debugging Tools FIXERRS Macro HP COBOL Manual for TNS and TNS/R Programs —522555-006 15 -12
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 A 5 6 7 Sequence Number Area 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 Procedure Division Verbs HP COBOL Manual for TNS and TNS/R Programs —522555-006 17- 6
18 HP COBOL CRE Support This section: • • Briefly describes the Common Run-time Environment (CRE) (see Introducing the CRE) Summarizes the changes to HP COBOL that allow HP COBOL programs to run in the CRE.
HP COBOL CRE Support Introducing the CRE Introducing the CRE On C-series systems, the HP C, HP C++, HP COBOL, FORTRAN, Pascal, and TAL programming languages each have their own unique run-time environments defined by their respective run-time libraries. These language-specific run-time environments are often incompatible with each other because each language’s run-time library is unaware of other run-time libraries.
HP COBOL CRE Support Compiler Directives D-series HP C, HP C++, and Pascal run-time libraries always call CRE library routines for services managed by the CRE; they can run in the CRE only. D-series HP COBOL and FORTRAN run-time libraries call CRE library routines if you compile all of the routines in a program to run in the CRE. In contrast, TAL routines call CRE library routines directly.
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).
HP COBOL CRE Support EXTERNAL Clause EXTERNAL Clause The EXTERNAL clause of the RECEIVE-CONTROL paragraph enables HP COBOL external files to share communication with $RECEIVE and to share $RECEIVE properly with FORTRAN. For more information, see RECEIVE-CONTROL Paragraph and #RECEIVE Blocks. MESSAGE SOURCE Clause If you specify the MESSAGE SOURCE clause in the RECEIVE-CONTROL paragraph, the last items in the message sender format change: Non-CRE Environment 02 02 CRE PROCESS-ID.
HP COBOL CRE Support Message Format Message Format Most of the SYSTEM messages in the CRE are longer than those in the non-CRE environment. If your CRE program is to process SYSTEM messages, make the record area of the $RECEIVE file at least 256 characters long. Message Replies The replies to some messages have changed, particularly the replies to the messages OPEN and CLOSE.
HP COBOL CRE Support CBL85UTL Routines CBL85UTL Routines Every CBL85UTL routine has a non-CRE version and a CRE version (except one, which is unnecessary in the CRE). The CBL85UTL file is for the COBOL85 compiler. Its CRE routines are also in the ZCOBSRL file, which is for the NMCOBOL compiler. Table 18-2.
HP COBOL CRE Support COBOLLIB Routines COBOLLIB Routines These COBOLLIB routines are affected by CRE support: • • • COBOLASSIGN COBOLFILEINFO COBOLSPOOLOPEN COBOLASSIGN In the CRE, the routine COBOL_ASSIGN_ has replaced the non-CRE routine COBOLASSIGN. If either a TNS HP COBOL program that runs in the CRE or a native HP COBOL program calls COBOLASSIGN, it actually calls COBOL_ASSIGN_ indirectly.
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 COBOL85 Compiler Running the COBOL85 Compiler In the OSS environment, the OSS utility cobol calls the COBOL85 compiler, optionally followed by the Binder (BIND), Accelerator (AXCEL), and SQL/MP compiler (SQLCOMP). The flags and the types of files in the operands determine which processes operate on the files in the operands. The cobol utility generates programs that run in the OSS environment.
Using HP COBOL in the OSS Environment Running the NMCOBOL Compiler Successful compilation always creates object files. If the -c flag is specified, the object files created for source files of the form file.cbl have the form file.o. For example, for a source file named main.cbl, successful compilation creates an object file named main.o in the current directory. Note.
Using HP COBOL in the OSS Environment Running HP COBOL Programs pathname ns file ns . cbl cob ecbl ecob a m o srl VST623.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. Topics: • • TNS Programs Native Programs TNS Programs A TNS HP COBOL program can call programs written in TNS HP COBOL, TNS HP C, TNS HP C++, or TAL, but not programs written in FORTRAN or Pascal. To produce a TNS HP COBOL program that contains TNS HP COBOL and TNS HP C modules, follow these steps: 1.
Using HP COBOL in the OSS Environment Native Programs Native 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 the nmcobol utility, compile the HP COBOL modules, specifying any necessary linking or SQL-compiling flags.
Using HP COBOL in the OSS Environment Changing Default Pathnames and Disk Volume Table 19-1.
Using HP COBOL in the OSS Environment Files in the OSS Environment Files in the OSS Environment In the OSS environment, you can use both OSS and Guardian files. OSS files are either line sequential files (see Line Sequential Files) or sequential files with fixedlength records and no alternate keys. Guardian files are all types of files that HP COBOL programs can access in the Guardian environment. In the OSS environment, both OSS and Guardian files must have OSS pathnames.
Using HP COBOL in the OSS Environment OSS Pathnames / specifies the root directory when it appears at the beginning of a pathname; elsewhere, it separates directory names and file names. directory is the name of a directory. A directory 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.
Using HP COBOL in the OSS Environment OSS Pathnames in HP COBOL Source Programs device specifies a Guardian device or either of the special names #DYNAMIC or #TERM. file-id-1 node.volume.subvolume.file_id 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. file-id-2 /G/volume/subvolume/file_id Example 19-2. OSS Pathnames for Guardian Files "GUARDIAN \qa.tests.cobol85.release4" "GUARDIAN S.
Using HP COBOL in the OSS Environment OSS Files in HP COBOL Source Programs OSS Files in HP COBOL Source Programs The only OSS files that an HP COBOL program can use are line sequential files (see Line Sequential Files) and sequential files with fixed-length records and no alternate keys.
Using HP COBOL in the OSS Environment File-Control Entries These topics explain these items with respect to line sequential files: • • • • • • • File-Control Entries File Description Entries I-O-CONTROL Paragraph OPEN Statement READ Statement REWRITE Statement WRITE Statement 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.
Using HP COBOL in the OSS Environment File-Control Entries file-name is the COBOL file name (the file-name in a file description entry). 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 Description 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 I-O-CONTROL Paragraph 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 GLOBAL clause RECORD CONTAINS clause «LABEL RECORDS clause» «VALUE OF clause» «DATA RECORDS clause» REPORT clause are described in File Description Entries. I-O-CONTROL Paragraph The syntax for an I-O-CONTROL paragraph for a line sequential file is: I-O-CONTROL . .
Using HP COBOL in the OSS Environment I-O-CONTROL Paragraph rerun-file-2-phrase recs RECORDS REEL OF END UNIT rerun-file-2 OF VST059.vsd 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.
Using HP COBOL in the OSS Environment OPEN Statement OPEN Statement The OPEN statement has this file-specification: INPUT OUTPUT I-O input-file-description output-file-description i-o-file-description EXTEND extend-file-description VST187.vsd INPUT specifies that the file or files in input-file-description are being opened for reading only. input-file-description infile SHARED PROTECTED EXCLUSIVE VST627.
Using HP COBOL in the OSS Environment OPEN Statement EXCLUSIVE prevents other processes from reading or writing the file while this process is open. EXCLUSIVE is the default for all other files. OUTPUT specifies that the file or files in output-file-description are being opened for writing only. output-file-description 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.
Using HP COBOL in the OSS Environment OPEN Statement SHARED PROTECTED EXCLUSIVE are the same as described earlier for infile. EXTEND specifies that the file or files in extend-file-description are being opened for writing additional data following any existing data. extend-file-description 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.
Using HP COBOL in the OSS Environment READ Statement READ Statement The READ statement for a line sequential file has this syntax: 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. 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.
Using HP COBOL in the OSS Environment REWRITE Statement 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.
Using HP COBOL in the OSS Environment WRITE Statement END-REWRITE ends the scope of the REWRITE statement, causing the REWRITE to be a delimited-scope statement. If the REWRITE statement does not end with an ENDREWRITE phrase, the presence of the INVALID KEY or the NOT INVALID KEY phrase causes the REWRITE statement to be a conditional statement, which ends at the next period separator.
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 ENV OLD ENV LIBRARY In the OSS environment, HP COBOL programs run in the CRE. 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 and TNS/R Programs —522555-006 19 -26 Utility Routines
20 HP COBOL Limits The HP architecture and the method of implementation of the HP COBOL compilers, COBOL85 and NMCOBOL, impose 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 TNS COBOL run unit A COBOL run unit can have up to 32 segments of code, each segment including up to 128 KB. If the program calls any code in user library space, the user code space can contain a maximum of 16 segments of COBOL, FORTRAN, TAL, C, and Pascal code, and the user library space can contain an additional 16 segments of COBOL, FORTRAN and TAL code.
HP COBOL Limits • Size Data in a run unit ° TNS HP COBOL The total size of all the items in the File Sections and Working-Storage Sections of all the programs of a run unit cannot exceed approximately 63,400 bytes. The upper 64 KB of the 128 KB of user data space is reserved for buffers and run-time data structures. Declare very large data items in the Extended-Storage Section.
HP COBOL Limits • Number Record or table Location of Record or Table Maximum Record or Table Size Extended-Storage Section No explicit limit—one record of 134,217,726 characters is possible File assigned to $RECEIVE 32 KB File assigned to another device Operating environment limits for the device apply File Section 32,767 characters Linkage Section 134 megabytes Working-Storage Section For a TNS program: 32,767 characters.
HP COBOL Limits • Number File names ° In a MULTIPLE FILE TAPE clause HP COBOL supports 31 file names within a single MULTIPLE FILE TAPE clause. ° In the GIVING or USING phrase of a MERGE or SORT statement HP COBOL supports a maximum of 31 file names within the USING or GIVING phrase of a SORT or MERGE statement. • Keys HP COBOL supports a maximum of 31 alternate record keys for a file, 31 key references in an OCCURS clause, and 31 keys in a SORT or MERGE statement.
HP COBOL Limits • Number Procedure names in a program (COBOL85 compiler only) The default maximum number of procedure names (paragraph names and section names) in a program is approximately 1K. You can change the default with the PARAM SYMBOL-BLOCKS command (see PARAM SYMBOL-BLOCKS). • Records ° External (COBOL85 compiler only) A record (or file) that has the EXTERNAL attribute belongs to the run unit itself, and is available to any program in the run unit that declares it consistently.
HP COBOL Limits • Callability Subscripts See Nesting depth. Callability TNS HP COBOL programs can call programs written in: • • • • • • TNS HP C TNS HP C++ TNS HP COBOL FORTRAN Pascal TAL In the non-CRE environment, if a run unit contains any HP COBOL program, then its main program must be a HP COBOL program.
HP COBOL Limits Ignored Elements The ranges of values for the type COMPUTATIONAL-5 are. Bracketed items are optional.
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 and TNS/R Programs —522555-006 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 and TNS/R Programs —522555-006 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 and TNS/R Programs —522555-006 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 and TNS/R Programs —522555-006 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 and TNS/R Programs —522555-006 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 and TNS/R Programs —522555-006 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 and TNS/R Programs —522555-006 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 and TNS/R Programs —522555-006 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 and TNS/R Programs —522555-006 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 and TNS/R Programs —522555-006 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 Using the TACL Command Log Using the TACL Command Log When you log onto an HP system, the HP Tandem Advanced Command Language (TACL) prompt appears.
Creating and Compiling HP COBOL Source Programs Reexecuting Previous Commands Reexecuting Previous Commands If you enter an exclamation mark (!), TACL displays and executes the last command: 5> 5> 1> 2> 3> 4> 5> 6> ! history who fileinfo view myfile history history 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
Creating and Compiling HP COBOL Source Programs Editing and Reexecuting Previous Commands Editing and Reexecuting Previous Commands If you enter the command FC, TACL displays the last command so that you can edit it: 8> fc 8> view myfile 8... You can edit the displayed command (view myfile) with the commands D (delete), I (insert), and R (replace). When you press Return, TACL displays the edited command. You can continue to edit the command or press Return.
Creating and Compiling HP COBOL Source Programs Creating or Altering an HP COBOL Source Program Creating or Altering an HP COBOL Source Program The compiler accepts source lines from any sequential file. On NonStop systems, the most common way to create or alter a HP COBOL source program is to use an HP editor or Starbase Corporation’s Codewright smart language editor with HP Extensions for Codewright. HP offers two editors, EDIT and PS TEXT EDIT (abbreviated “TEDIT”).
Creating and Compiling HP COBOL Source Programs Reference Format Reference Format Individual source program lines must follow a reference format that the compiler accepts. There are two choices of reference format: Tandem and ANSI. Tandem format, an HP extension to COBOL, is less restrictive than ANSI.
Creating and Compiling HP COBOL Source Programs EDIT Editor EDIT Editor The EDIT editor is not as powerful as the TEDIT editor, but it has some useful abilities that TEDIT either lacks or does not perform as simply. Examples of both cases are in this explanation. Caution. The EDIT editor works on your original file, not on a copy of it.
Creating and Compiling HP COBOL Source Programs TEDIT Editor If you are sure that you want to overwrite PAYROLS, you can avoid the question-andanswer routine by following PAYROLS with an exclamation mark: *GET PAYROLXX PUT PAYROLS! CURRENT FILE IS \NODE1.$VOL3.SUBVOL2.PAYROLS Another convenience the EDIT editor provides that the TEDIT editor lacks is the ability to list all lines that contain two or more combinations of text characters in any order.
Creating and Compiling HP COBOL Source Programs TEDIT Editor If you call the TEDIT editor with a file name, it does not display the help screen. If the file you specified exists, the TEDIT editor clears the screen and displays the first 24 lines of the file and a banner on line 25.
Creating and Compiling HP COBOL Source Programs TEDIT Editor TEDIT Commands Most TEDIT commands consist of a noun (such as LINE, SENTENCE, WINDOW, BALANCED-EXPRESSION, or REGION) and a verb (such as INSERT, MOVE, COPY, DELETE, FORWARD, BACKWARD, SEARCH, REPLACE, or UNDO). Some TEDIT commands also include a repeat count or parameters.
Creating and Compiling HP COBOL Source Programs HP Tandem Extensions for Codewright (TEC) HP Tandem Extensions for Codewright (TEC) Starbase Corporation’s Codewright is a smart language editor that allows you to edit source code and issue compiler, version-control, and operating-system commands. The base editor facilitates source code creation with keyword chromacoding, search and replace mechanisms, function execution, undo and redo commands, and general editing capabilities.
Creating and Compiling HP COBOL Source Programs HP Tandem Extensions for Codewright (TEC) Dictionaries and Templates TEC maintains four project dictionaries: user, parameter, class, and system. Information can be stored and retrieved from these dictionaries and used in conjunction with comment generation (see Comment Headers and Parameter Documentation). You can define text templates that contain values for function parameters. The values are defined when you insert the template into the dictionary.
Creating and Compiling HP COBOL Source Programs Compiling an HP COBOL Source Program Compiling an HP COBOL Source Program The COBOL85 and NMCOBOL compilers translate HP COBOL source programs into machine language. The COBOL85 compiler interacts with Binder, which collects any additional object programs needed to satisfy external references and validates any calls to routines that are part of the operating environment or are to be executed in a TNS user library.
Creating and Compiling HP COBOL Source Programs Running the Compiler The preceding NMCOBOL command produces a loadfile only if the source file, XYZ, contains a RUNNABLE directive. If it does not, the command that produces a loadfile is: 23> NMCOBOL /IN XYZ/; RUNNABLE The file XYZ must be an EDIT or entry-sequenced file. 24> COBOL85 /IN XYZ/ 24> NMCOBOL /IN XYZ/; RUNNABLE The preceding commands deliver the compiler listing to your terminal.
Creating and Compiling HP COBOL Source Programs Running the Compiler To specify a file for information about any compilation errors or warnings, use the ERRORFILE directive: 29> COBOL85 /IN XYZ, OUT $SPX.#XYZLST/; ERRORFILE EFILE 29> NMCOBOL /IN XYZ, OUT $SPX.#XYZLST/; RUNNABLE; ERRORFILE EFILE The error logging file is not an EDIT file. You can use it only with the FIXERRS TACL macro. For more information about the FIXERRS macro, see FIXERRS Macro.
Creating and Compiling HP COBOL Source Programs Naming the Object File Using an HP editor, you can create OBEY command files. OBEY command files contain TACL commands, such as the COBOL85 or NMCOBOL commands, which are executed when you specify the name of the OBEY command file in an OBEY command. Here is a sample session: 45> EDIT CFILE1 TEXT EDITOR - T9601D10 - (08JUN92) $VOL3.SUBVOL2.CFILE1 DOES NOT EXIST. SHALL I CREATE IT? Y CURRENT FILE IS $VOL3.SUBVOL2.CFILE1 *ADD 1 COBOL85 /IN XYZ,OUT $SPX.
Creating and Compiling HP COBOL Source Programs Naming the Object File If you specify the CALL-SHARED and RUNNABLE directives, and there are no compilation errors, the NMCOBOL compiler calls the ld utility, which produces a PIC loadfile. If you specify the SHARED and RUNNABLE directives, and there are no compilation errors, the NMCOBOL compiler calls the ld utility, which produces a DLL. Binder does the actual building of the object file.
Creating and Compiling HP COBOL Source Programs Specifying the Default COPY Library Use the TACL command FILES to detect ZZBInnnn or ZZNCnnnn files and the TACL command PURGE to purge the unwanted ones. 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.
Creating and Compiling HP COBOL Source Programs Specifying Subvolumes to Be Searched for Unqualified Files Directive for Specifying the Program’s Run-Time Environment Note. This topic applies only to TNS programs. Native programs always run in the CRE. For TNS programs in the Guardian environment, you have a choice of run-time environments: the non-CRE environment or the CRE.
Creating and Compiling HP COBOL Source Programs Changing the Compilation Environment Changing the Compilation Environment You can change these aspects of the compilation environment: • • • Processors the Compilation Processes Use Volume(s) for Temporary Files Compiler Space Allocation Processors the Compilation Processes Use Note. This topic applies only to the COBOL85 compiler.
Creating and Compiling HP COBOL Source Programs Changing the Compilation Environment If you have given the command PARAM SAMECPU and decide that you do not want it, you can clear it with the CLEAR command before running the compiler; for example: 91> PARAM SAMECPU 7 92> CLEAR PARAM SAMECPU 93> COBOL85 /IN XYZ, OUT $SPX/ XYZOBJ Volume(s) for Temporary Files By default, the COBOL85 compiler creates its temporary files on the current default volume.
Creating and Compiling HP COBOL Source Programs Improving Compilation Speed If you have given several PARAM commands, you can clear all of them before running the compiler with the command CLEAR ALL PARAM; for example: 101> 102> 103> 104> 105> PARAM SAMECPU 7 PARAM SWAPVOL $COBVOL PARAM SYMBOL-BLOCKS 1 CLEAR ALL PARAM COBOL85 /IN XYZ, OUT $SPX/ XYZOBJ Improving Compilation Speed Under these conditions, these actions can improve compilation speed: Condition Action Either or both of the processors that
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 01 STARTING-EMPLOYEE PICTURE 9(6). 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.
Creating and Compiling HP COBOL Source Programs Using Data Definition Language (DDL) Using Data Definition Language (DDL) Data Definition Language (DDL) is a language with which you describe the data structures of a database. The DDL compiler reads your description and generates a data declaration library (a COPY library) for the database and a File Utility Program (FUP) command file for building the database files. DDL also lets you create and maintain a data dictionary for your database.
Creating and Compiling HP COBOL Source Programs Using Data Definition Language (DDL) Example 22-3. Input to the DDL Compiler DEFINE NAME. 02 LAST-NAME 02 MIDDLE-INITIAL 02 FIRST-NAME END PIC X(15). PIC X(1). PIC X(15). 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 *.
Creating and Compiling HP COBOL Source Programs Using Data Definition Language (DDL) Example 22-4. COPY Library Produced by the DDL Compiler (page 1 of 2) * SCHEMA PRODUCED DATE - TIME : 2/28/93 12:01:42 ?SECTION NAME,HP * Definition NAME created on 02/28/93 at 12:01 01 NAME. 02 LAST-NAME PIC X(15). 02 MIDDLE-INITIAL PIC X(1). 02 FIRST-NAME PIC X(15). ?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).
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 2) ?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 Compiler directives also allow you to: • • Request different or additional load maps (see Load Maps) Suppress parts of the compiler listing (see Table 22-1) The minimum compiler listing, produced when you compile a program with the SUPPRESS directive, includes only a banner, any diagnostics and the source lines that caused them, and a summary.
Creating and Compiling HP COBOL Source Programs Compilation Banner Table 22-1.
Creating and Compiling HP COBOL Source Programs Source Program Listing The NMCOBOL 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-14.
Creating and Compiling HP COBOL Source Programs Source Program Listing Topics: • • • • • • • • Identification Field Line Number Sequence Number Indicator Area and Beyond Text Altered by REPLACE Statement Text Retrieved by COPY Statement Text Retrieved by SOURCE Directive SQL/MP and SQL/MX Statements Identification Field The identification field is copied from columns 72 through 80 of ANSI format source lines. Some installations use these columns for marking revisions to the program.
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-16. 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-16. 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 For a list of all the compiler diagnostic messages and their probable causes, see Section 47, Compiler Diagnostic Messages. For a list of all the Binder messages and their probable causes, see the Binder Manual. 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-17.
Creating and Compiling HP COBOL Source Programs Diagnostic Messages Although the compiler stops generating code when it encounters the first error, it continues with the compilation, reporting as many diagnostic messages as it can. Because an error can leave the compiler with incorrect or incomplete information, the compiler might report errors in later statements that are actually correct. (The later errors are side effects of the earlier ones.
Creating and Compiling HP COBOL Source Programs Diagnostic Messages Binder Messages A Binder message begins with one of these strings: **** Binder WARNING nnn **** **** Binder ERROR nnn **** **** Binder FATAL ERROR nnn **** (where n is a digit). For information about specific Binder messages, see the Binder Manual. Error Files The compiler directive ERRORFILE causes the compiler to document its warning and error messages in an error file.
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 Octal Code Listing Example 22-21. Symbol Table Listing (NMCOBOL Compiler) ...
Creating and Compiling HP COBOL Source Programs Symbolic Code Listing Symbolic Code Listing The COBOL85 compiler lists the instructions of the object program in symbolic (mnemonic) form after the source program listing if you explicitly request it with the ICODE directive (see Example 22-23). The NMCOBOL compiler lists the instructions of the object program in symbolic (mnemonic) form after each source statement if you explicitly request it with the INNERLIST directive (see Example 22-24). Note.
Creating and Compiling HP COBOL Source Programs Symbolic Code Listing Example 22-23. Symbolic Code Listing (COBOL85 Compiler) (page 2 of 3) * 000036 STARTT 14. 15. 16. 17. 17. 18. 18. 19. 19. 20. 20.
Creating and Compiling HP COBOL Source Programs Symbolic Code Listing Example 22-23. Symbolic Code Listing (COBOL85 Compiler) (page 3 of 3) 21. 21. 22. 22. 23. 23. 30. 31.
Creating and Compiling HP COBOL Source Programs Symbolic Code Listing Example 22-24. Symbolic Code Listing (NMCOBOL Compiler) (page 2 of 6) 12. 12. 12. 12. 12. 12. 12. 12. 12. 12. 12. 12. 12. 12. 12. PROCEDURE DIVISION.
Creating and Compiling HP COBOL Source Programs Symbolic Code Listing Example 22-24. Symbolic Code Listing (NMCOBOL Compiler) (page 3 of 6) 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15.
Creating and Compiling HP COBOL Source Programs Symbolic Code Listing Example 22-24. Symbolic Code Listing (NMCOBOL Compiler) (page 4 of 6) 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16.
Creating and Compiling HP COBOL Source Programs Symbolic Code Listing Example 22-24. Symbolic Code Listing (NMCOBOL Compiler) (page 5 of 6) 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19.
Creating and Compiling HP COBOL Source Programs Symbolic Code Listing Example 22-24. Symbolic Code Listing (NMCOBOL Compiler) (page 6 of 6) 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22.
Creating and Compiling HP COBOL Source Programs Cross-Reference Listing Cross-Reference Listing Note. This topic applies only to the COBOL85 compiler. The NMCOBOL compiler does not produce a cross-reference listing. If you need one, use the noft utility with the XREFPROC flag (see the nld Manual).
Creating and Compiling HP COBOL Source Programs Compilation Summary Example 22-26 is an ALPHA load-map for the program in Example 31-13. Example 22-26. Load-Map (ALPHA) PAGE 10 $MYDSC.PROBSBV.PROBE Tandem COBOL85 ENTRY POINT MAP BY NAME SP PEP BASE LIMIT ENTRY ATTRS 00 002 000003 002243 000051 M $MYDSC.PROBSBV.PROBE NAME PROBE DATE TIME LANGUAGE SOURCE FILE 1/02/93 13:14 COBOL - - - - - - - - - - - - - new page - - - - - - - - - - - - - - - - - - - - - - - - PAGE 11 $MYDSC.PROBSBV.
Creating and Compiling HP COBOL Source Programs Compilation Summary COBOL85 Compiler Example 22-27. COBOL85 Compilation and BINSERV Summary Binder - OBJECT FILE Binder - T9621D20 - (8JUN92) Object file name is $SECOND.AA9210.
Creating and Compiling HP COBOL Source Programs Compilation Summary NMCOBOL Compiler Example 22-28. NMCOBOL Compilation Summary COBOL - T8107D99 - (30 APR 97) No failures detected. No errors detected. No warnings reported. No remarks issued. Maximum symbol table size = 135998 bytes NLD - NATIVE MODE LINKER - T6017D42 - 03JUN96 Copyright Tandem Computers Incorporated 1993-1996 NLD's command line was: \node1.$system.sys01.nld -o RUNUNIT RUNUNIT \NODE1.$SYSTEM.SYS01.ECOBSRL \NODE1.$SYSTEM.SYS01.
Creating and Compiling HP COBOL Source Programs Compilation Summary If the NMCOBOL compiler had reported any errors, the summary would have contained lines like these: COBOL - T8107D99 - (01 APR 97) No object file produced ***** Number of COBOL errors = 6 Number of COBOL warnings = 2 Last message on page 2 Number of source lines read = 57 Maximum symbol table size = 840 words Elapsed time 0:00:29 HP COBOL Manual for TNS and TNS/R Programs —522555-006 22 -67
Creating and Compiling HP COBOL Source Programs HP COBOL Manual for TNS and TNS/R Programs —522555-006 22 -68 Compilation Summary
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. Your TNS HP COBOL program can call other TNS programs and routines, and your native HP COBOL program can call other native programs and routines. TNS and native programs cannot call each other.
Calling Other Programs and Routines Run-Time Environment Run-Time Environment Native programs (compiled with the NMCOBOL compiler) always run in the CRE. Programs compiled with the COBOL85 compiler can run in either the CRE or the nonCRE (COBOL-specific) environment. The non-CRE environment is the default for nonnative HP COBOL programs, but with the compiler directive ENV COMMON, you can request the CRE instead.
Calling Other Programs and Routines Calling Other COBOL Programs For more information about writing programs that use the services provided by the CRE, see the CRE Programmer’s Guide. Calling Other COBOL Programs A HP COBOL program calls another HP COBOL program with a CALL statement. The called program can be either a separately compiled HP COBOL program or a nested HP COBOL program. A nested program is usually accessible to more calling programs if it is a common program.
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 Dynamic Calls Quotation marks around program-name are not required, but are recommended. If, in some eventual program maintenance, someone adds a variable named APROG to a program that already calls a program named APROG, and the name APROG is not in quotation marks, the compiler assumes that APROG refers to the variable.
Calling Other Programs and Routines Calling Non-COBOL Routines 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. Separate processes communicate through the file process $RECEIVE—the sender writes to a named process, and the receiver reads a file named $RECEIVE. For more information about $RECEIVE, see $RECEIVE.
Calling Other Programs and Routines ENTER Statement TNS Programs If a TNS HP COBOL program is not compiled with the PORT directive, it can call routines written in TNS HP C, TNS HP C++, FORTRAN, Pascal, and TAL by using the ENTER statement. In the ENTER statement, you can specify the language of the called routine. Although you can specify the language COBOL, the COBOL85 compiler ignores any ENTER COBOL statements it encounters (to call another COBOL program, use the CALL statement).
Calling Other Programs and Routines X/Open CALL Statement X/Open CALL Statement If an HP COBOL program is compiled with the PORT directive and runs in the CRE, it can call non-COBOL routines with the CALL statement, which behaves like an X/Open CALL statement. If the called program is a function and it was compiled either by the COBOL85 compiler with the ENV COMMON directive or by the NMCOBOL compiler, the X/Open CALL statement returns its value in the special register RETURN-CODE.
Calling Other Programs and Routines Operating System Routines If the calling program cannot access RETURN-CODE, the value of RETURN-CODE is unchanged. Operating System Routines Operating system routines are written in TAL, pTAL, HP C, and HP C++. The language in which an operating system routine is written does not matter to the HP COBOL program that calls it.
Calling Other Programs and Routines Operating System Routines You must verify that the actual parameters in the ENTER statement (including return-value in the GIVING phrase) are of the HP COBOL types that correspond to the TAL types of the formal parameters in the operating system routine. The compiler performs the necessary conversions of sending parameters. Parameters passed by reference must match exactly. The HP COBOL data type INDEX does not correspond to any TAL or pTAL data type. Table 23-3.
Calling Other Programs and Routines Operating System Routines Table 23-3.
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 COBOLEXT (for the COBOL85 compiler) or NMCOBEXT (for the NMCOBOL compiler), which is part of every HP COBOL RVU, contains dummy versions of all the operating system routines.
Calling Other Programs and Routines Operating System Routines If an operating system routine’s formal parameter list changes from variable to extensible, the code that was compiled to expect a variable parameter list can usually call the new version of the routine that has an extensible parameter list (at a slight performance penalty). For more information about variable and extensible parameter lists, see the TAL Reference Manual (for TNS programs) or the pTAL Reference Manual (for native programs).
Calling Other Programs and Routines HP COBOL Run-Time Routines use a compilation command like RUN MYCOBVOL.COBOL85 /IN XYZ/ or RUN MYCOBVOL.NMCOBOL /IN XYZ/ where MYCOBVOL is the subvolume you created. • Use the system volume for your compilations, but use a CONSULT directive to tell the compiler to resolve external references from a file other than COBOLEXT or NMCOBEXT. HP COBOL Run-Time Routines Your HP COBOL program calls HP COBOL run-time routines implicitly, not with ENTER statements.
Calling Other Programs and Routines Restrictions on Calling Non-COBOL Routines Restrictions on Calling Non-COBOL Routines TNS HP COBOL programs can call only TNS programs, and native HP COBOL programs can call only native routines. This means that a TNS HP COBOL program can call routines written in TNS HP C, FORTRAN, Pascal, and TAL, and that a native HP COBOL program can call routines written in native HP C, native HP C++, and pTAL.
Calling Other Programs and Routines • • Restrictions on Calling Non-COBOL Routines Returns a structured value. Specifies a formal parameter whose type has no corresponding HP COBOL type (to see which HP C types have corresponding HP COBOL types, see Appendix B, Data Type Correspondence. A HP COBOL program and an HP C program can share data under these conditions: • • • • • • • The HP COBOL and HP C programs are compiled with compilers of RVU D20.00 or later.
Calling Other Programs and Routines Restrictions on Calling Non-COBOL Routines Example 23-2. HP COBOL and HP C Programs Sharing Data HP C Code: #include nolist extern char MYVAR[21]; void SHOWEXT(void){ int i; /* In the Guardian environment, the call to fopen_std_file is needed because the main program is in HP COBOL.
Calling Other Programs and Routines Passing Parameters In both the non-CRE environment and the CRE, if a program includes both HP COBOL and FORTRAN routines, all input-output operations done on a particular file must be performed within one language, or by routines provided by HP. Pascal Routines Only TNS HP COBOL programs in the Guardian environment can call Pascal routines.
Calling Other Programs and Routines TNS Addressing Modes TNS Addressing Modes TNS HP COBOL programs use standard (16-bit) addressing for all items in the File Section, all items in the Working-Storage Section, and items in the Linkage Section for which standard access mode is specified. HP COBOL programs use extended (32-bit) addressing for all items in the Extended-Storage Section and all items in the Linkage Section for which the standard access mode is not specified.
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 HP COBOL Manual for TNS and TNS/R Programs —522555-006 23 -27
Calling Other Programs and Routines • Passing Parameters to Non-COBOL Routines When the formal parameter for an HP C or HP C++ function is a scalar variable, its type designation cannot include the modifier “unsigned.” When the COBOL parameter is numeric, the type “char” is included in this prohibition, because the HP C or HP C++ compiler interprets it as equivalent to the type “unsigned char.” The type “signed char” is acceptable. When the COBOL parameter is not numeric, the type “char” is acceptable.
Calling Other Programs and Routines Passing Parameters to Non-COBOL Routines Example 23-6. Using External Declarations to Pass Integers to C Routine (page 2 of 2) C code: char *work; /* global to share with HP COBOL program */ int x; ... work = (char*)malloc(2); ... x = *(int*)flip; *(int*)flip++; y = ... Example 23-7. Passing a String to a C Routine HP COBOL code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A-STRING PICTURE X(25). ... PROCEDURE DIVISION. ...
Calling Other Programs and Routines Passing Parameters to Non-COBOL Routines In both the non-CRE environment and the CRE: • • An HP COBOL program cannot pass anything to a formal FORTRAN parameter of the type COMPLEX. FORTRAN stores multidimensional arrays in column-major order and HP COBOL stores them in row-major order.
Calling Other Programs and Routines Passing Parameters to Non-COBOL Routines Pascal Note. This topic applies only to TNS HP COBOL programs. Native HP COBOL programs cannot call Pascal routines. If you want your native HP COBOL program to call a FORTRAN routine, convert the Pascal routine to native HP C, native HP C++, or pTAL. By default, Pascal routines use 16-bit addressing for parameters and pointer allocation (the “small-memory model”).
Calling Other Programs and Routines Passing Parameters to Non-COBOL Routines Example 23-9. Passing Parameters to a Pascal 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 PASCAL "FUNCT1" USING ONE-WORD TWO-WORD FOUR-WORD A-STRING Pascal routine: FUNCT1 ( a: b: c: d: begin ...
Calling Other Programs and Routines Passing Parameters to Non-COBOL Routines Extended indirect addressing is indicated by type.EXT identifier ; for example: INT .EXT i; You can specify standard (16-bit) addressing in HP COBOL with an ACCESS MODE clause. Verify that each actual HP COBOL parameter uses the same addressing mode as its corresponding formal TAL or pTAL parameter.
Calling Other Programs and Routines Passing Parameters to Non-COBOL Routines The code for reference modification is: 01 A-FILENAME PIC X(20) ... MOVE 0 TO A-COUNT INSPECT FUNCTION REVERSE (A-FILENAME) TALLYING A-COUNT FOR LEADING SPACES ENTER "FILE_GETINFOBYNAME_" USING A-FILENAME (1: FUNCTION LENGTH (A-FILENAME) - A-COUNT) ... The code for using an OCCURS clause is: 01 01 A-FILENAME. 02 PIC X OCCURS 1 TO 20 TIMES DEPENDING ON A-FILENAME-LENGTH. A-FILENAME-LENGTH PIC 99 COMP.
24 Issues Related to Binding and 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 Binding and Linking Code and Data Blocks How the Compiler Produces Code and Data Blocks To understand how the compiler produces code and data blocks from HP COBOL source code, you must know about separately compiled programs and compilation units. A separately compiled program is an HP COBOL source program that is not nested within any other program. It can have other HP COBOL source programs nested within it.
Issues Related to Binding and Linking Code and Data Blocks These compilers also produce one object file per compilation unit: • • • • • • • • TNS HP C TNS HP C++ FORTRAN Pascal TAL Native (TNS/R and TNS/E) HP C Native (TNS/R and TNS/E) HP C++ pTAL The object file contains one relocatable code block for each procedure and zero or more data blocks.
Issues Related to Binding and Linking Binding or Linking When external references in two code blocks are resolved to entry points in each other, the two code blocks are called “crossbound.” The system code block and the system library blocks are all crossbound—a routine in any of these blocks can call a routine in any other of these blocks. The blocks of a multiblock user code space are all crossbound, as are the blocks of user library space.
Issues Related to Binding and Linking Binding or Linking BINSERV BINSERV, which runs as a separate process during a compilation, performs these tasks: • • • • Builds lists of references that must be resolved Tries to locate the required code blocks and reports its success or failure to do so Gives the compiler information about the code blocks it finds.
Issues Related to Binding and Linking Binding or 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 Binding and Linking Binding or Linking Figure 24-3.
Issues Related to Binding and Linking Loadfiles, Linkfiles, and Processes Unresolved References If an external reference in an object file refers to an entry point that is not among the code blocks in that object file, the external reference is called unresolved. Unresolved external references cause warning messages, but are allowed. They are expected to be resolved by the fixup operation of the system loader.
Issues Related to Binding and Linking Binding or Linking HP COBOL Programs External references call routines in: • • • • Other code blocks in the same user code space or user library space Code blocks in user library space The system code space Code blocks in system code extension To enable the system loader to fix up references to routines in user library space, you must provide the name of the user library file. The three ways to do this, in order of preference, are: 1.
Issues Related to Binding and Linking Binding or Linking Automatically Binding or Linking Automatically By default, the COBOL85 compiler automatically binds the program, interacting with the BINSERV process as explained under Binder. If you specify the RUNNABLE directive but not the CALL-SHARED or SHARED directive, the NMCOBOL compiler automatically links the program, interacting with the COBOLFE process and the nld utility.
Issues Related to Binding and Linking Binding or Linking Automatically You can use a predefined DEFINE, =_OBJECT_SEARCH, to specify one or more subvolumes for the compiler to search for unqualified object files (see Specifying Subvolumes to Be Searched for Unqualified Files).
Issues Related to Binding and Linking Binding or Linking Automatically Putting an Object File on the Primary Search List If a CALL or ENTER statement does not contain a mnemonic name that specifies the object file that contains the called program, the compiler searches for the called routine in the object files on the primary search list. If the COBOL85 compiler finds the routine, it validates the routine’s actual parameters and includes the routine in your object file.
Issues Related to Binding and Linking Binding or Linking Automatically To make a TNS object file the user library, see LIBRARY. To make a native object file the user library, see Specifying a User Library. 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.
Issues Related to Binding and Linking Binding or Linking Programs to Be Called Dynamically Binding or 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 Binding and Linking Binding With BIND Example 24-1. Interactive BIND Session :BIND Binder - OBJECT FILE Binder - T9621D20 - (8JUN92) @ADD * FROM BIGOBJ @REPLACE * FROM OPART7 @BUILD NUBIGOBJ @EXIT SYSTEM \AB Example 24-2.
Issues Related to Binding and Linking Binding or Linking Mixed-Language Programs Replacing a Code Block With One With Different Parameters Unless you have explicitly disabled parameter checking, BIND reports an error if you try to replace one code block with a code block that: • • Expects a different number of parameters Has has parameters that do not match those of the calling code block in size or mode (content or reference) For more information about the preceding topics and the many other features
Issues Related to Binding and Linking Designing Programs With Large Amounts of Code To accelerate an HP COBOL program, follow these steps: 1. Compile and bind the program. 2. Debug the program. 3. Run the Accelerator. If the Accelerator reports an error, the Accelerator does not produce an output file. Correct the error and run the Accelerator again. 4. If the program contains embedded SQL/MP or SQL/MX statements, run the SQL/MP or SQL/MX compiler. 5. Perform final testing on the accelerated program.
Issues Related to Binding and Linking Separate Programs Figure 24-4. Run Unit Containing HP COBOL Code Blocks Code Segment Code Segment Code Segment XEP Table XEP Table XEP Table Code Block Code Block ... Code Block Code Block Code Block Up to 64K words Code Block PEP Table PEP Table PEP Table Up to 16 VST705.vsd The maximum size of a code block depends on the language. The maximum size of an HP COBOL code block is 128 KB minus the number of bytes that the PEP and XEP tables occupy.
Issues Related to Binding and Linking Separate Processes Separate Processes You can break a batch program into a requester and one or more servers. In a Pathway environment, servers can have their own servers. A Pathway server can create another process and communicate with it through a READ statement with a PROMPT phrase (an HP COBOL extension). For information about COBOL85 requester-server pairs, see Simple Server Example.
Issues Related to Binding and Linking TNS User Library You can compile an HP COBOL routine with the ENV LIBRARY directive and put it into the user library if the program satisfies these criteria: • • • • • • • • It is not a main program. It is an initial program (its PROGRAM-ID paragraph specifies INITIAL). It is a separately compiled program (it is not embedded in another program). It does not contain any other programs. It does not specify the GLOBAL phrase on any level-01 record descriptions.
Issues Related to Binding and Linking Designing Programs With Large Amounts of Data Designing Programs With Large Amounts of Data For TNS programs, the address-space limitation is 128 KB. TNS HP COBOL reserves the upper 64 KB of the address space for its own use and reserves some of the lower 64 KB also. If the space reserved for your program data (user data space) is not enough, you can put some data in the Extended-Storage Section (user extended space).
Issues Related to Binding and Linking • • • • LESS-CODE Directive Records declared in the File Section are allocated in user data space, but you can move them to the Extended-Storage Section (user extended space) and back again with the MOVE statement, the INTO clause of the READ statement, or the FROM clause of the WRITE or REWRITE statement. In the HP COBOL environment, the CHECKPOINT statement cannot process data items declared in the Extended-Storage Section.
Issues Related to Binding and Linking COBOL Segmentation COBOL Segmentation Note. The 1985 COBOL Standard classifies the segmentation module as obsolete, so you are advised not to use it. HP COBOL ignores segment numbers, but issues warning messages for transfers of control forbidden by the segmentation rules of the ANSI COBOL Standard.
Issues Related to Binding and Linking HP COBOL Manual for TNS and TNS/R Programs —522555-006 24 -24 COBOL Segmentation
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 Overriding the NONSTOP Directive Overriding the NONSTOP Directive If your program was compiled with a NONSTOP directive (which causes it to execute as a process pair), and you want to override the NONSTOP directive (until you have debugged the program, for example), you must execute the command PARAM NONSTOP OFF before executing your program.
Executing and Debugging HP COBOL Programs Providing for an Unavailable Printer This command specifies the default input-output device \AKRON.$SLB.MAJ.ERRMSG: PARAM EXECUTION-LOG \AKRON.$SLB.MAJ.ERRMSG This command specifies the DEFINE name =ERRORS as the default input-output device. You must add the DEFINE name =ERRORS before you execute the program. PARAM EXECUTION-LOG =ERRORS ADD DEFINE =ERRORS, FILE \AKRON.$SLB.MAJ.
Executing and Debugging HP COBOL Programs Specifying Waited Input-Output Specifying Waited Input-Output To cause your HP COBOL program to do all its input-output in the wait mode, execute the command PARAM WAITED-IO ON before you execute the program. For more information, see PARAM Command. 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.
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 Running the New Process in the Background Run-Time Errors 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.
Executing and Debugging HP COBOL Programs Specifying the Home Terminal If you want the default input device to be the same as the default output device, you can specify a default input-output device with a PARAM EXECUTION-LOG command before you execute your program (see Specifying a Default Input-Output Device) and ignore the remainder of this topic.
Executing and Debugging HP COBOL Programs Naming the New Process This command specifies the home terminal $TE1.#E02 for the program PROG1. Because the default input and output devices are not specified, they will be the home terminal, $TE1.#E02, unless an earlier PARAM EXECUTION-LOG command specified a default input-output device. PROG1 /TERM $TE1.#E02/ This command specifies the default input device INFILE for the program PROG1, no default output device, and the 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 for the NMCOBOL compiler only if the RUNNABLE directive is active.
Executing and Debugging HP COBOL Programs Run-Time Errors Diagnostic Messages When a run-time error occurs, the run-time routine that detects it sends a run-time diagnostic message to the default output device. The run-time routine that detects the error is either a HP COBOL run-time routine (if the program is running in the non-CRE environment) or a CRE run-time routine (if the program is running in the CRE).
Executing and Debugging HP COBOL Programs Getting a Program to Enter Debugging Mode Getting a Program to Enter Debugging Mode You can get a program to enter debugging mode (that is, to enter the debugger for which you compiled the program) at any of these times: • • Before Execution During execution: ° ° Programmatically Forcefully For information on specific debuggers, see Section 15, Debugging Tools.
Executing and Debugging HP COBOL Programs Forcefully If the HP COBOL program is a Pathway server process, you can use the TACL DEBUG command only from a terminal that is connected to a command interpreter, not from a terminal that is configured to run a SCREEN COBOL terminal program. The reason is that you must be able to tell the debugger which process to debug.
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 Table 26-1. Special Names for System Files (page 2 of 2) Special System File Name Place holder for ...
Input and Output Concepts Associating COBOL File Names With System File Names #OUT In the Guardian environment, #OUT represents the file specified as the OUT parameter in the startup message of the current process. If you started the current process from a TACL prompt, #OUT refers to the file specified by the OUT option of the RUN command (or its default). (See Specifying Default Input and Output Devices.
Input and Output Concepts Associating COBOL File Names With System File Names #TEMP The special name #TEMP represents a temporary disk file on the default volume (which is specified by the program’s startup message). When the program opens a file that is assigned to #TEMP, the HP COBOL run-time routines create a disk file on the default volume. When the program closes a temporary disk file, the file system purges it. For more information about temporary disk files, see the Guardian Programmer’s Guide.
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 COBOLASSIGN or COBOL_ASSIGN_ routine, prompt the user for a file name, and then call the COBOLASSIGN or 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 and TNS/R Programs —522555-006 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. On a D-series system: Before the HP COBOL process can use the tape, the operator must use the Tape Utility Program (TAPECOM) command ACCEPT to approve opening the tape.
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 Topics: • • Unlabeled Tapes Labeled Tapes 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 If you want to do mixed-language programming, compiling your program to run in the CRE is highly recommended. Although mixed-language programming is possible in the non-CRE environment, it is very limited because of incompatibilities between different languages’ run-time libraries. The CRE supports the languages HP C, HP COBOL, FORTRAN, Pascal, and TAL.
Disk Input and Output Structured Files A program written entirely in HP COBOL can open unstructured files that are not in EDIT format for input or output, but cannot create an unstructured file.
Disk Input and Output Structured Files Table 28-4. Comparison of Structured File Characteristics Type of Structured File Characteristic Entry-Sequenced (Sequential) Records ordered by ... Order in which they were entered Record number Value of prime record key Access is by ...
Disk Input and Output Structured Files If an HP COBOL program describes fixed-length records, any zero-length records are discarded when read. If an HP COBOL program describes variable-length records, upon return from the READ statement, the entire record area is undefined. For this reason, you are advised to specify the DEPENDING phrase when reading variablelength records, and to process zero-length records appropriately (by ignoring them, for example).
Disk Input and Output Structured Files The record numbers of a relative file need not be consecutive; Enscribe does not require that there be a record for each ordinal number between that of the first record and the highest number associated with any record in the file.
Disk Input and Output Creating and Using HP COBOL Sequential Files You can also read the file in key-value order. In this case, Enscribe does not report absent records—it returns the records that exist. Because the key is part of the record, you have access to the key value when you have read the record. 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.
Disk Input and Output Unstructured Files An HP COBOL program can use the FILE_CREATE_ procedure to create an entrysequenced file that has alternate keys. An HP COBOL program cannot create an entry-sequenced file that has alternate keys directly, because the operating environment maintains the alternate keys in one or more separate files, whose names are recorded with the operating environment information about the entry-sequenced file (see Alternate Record Keys).
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).
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) 01 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). ... 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 In the non-CRE environment, the value of number must be in the range 1 through 8 and is interpreted: Value of number Effect on Record Blocking 1 No buffering or HP COBOL Fast I-O 2 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.
Disk Input and Output Structured Files By default, files that are audited by TMF use cache buffering, and files that are not audited do not. Caution. Do not use cache buffering with a program that requires that each record actually be written on the disk before the next statement in the program is executed.
Disk Input and Output Structured Files Without sequential block buffering, every time an application program performs a read operation, the HP COBOL run-time routines must call the READ routine, which causes the file system to send a message to the disk process and causes the disk process to return a message containing the record.
Disk Input and Output • Files With Alternate Keys The specifications in the OPEN statement, or the attributes derived during the open operation by some other means (such as from a TACL ASSIGN command), conform to: ° ° The open mode is INPUT or OUTPUT. ° If the open mode is OUTPUT, the exclusion mode is EXCLUSIVE. If the open mode is INPUT, the exclusion mode is PROTECTED or EXCLUSIVE. Note.
Disk Input and Output Files With Alternate Keys Declaring Null Values for Alternate Keys When you create an alternate-key file with FUP CREATE, you can declare a null value for any alternate key. When you insert a record, if each byte in the alternate-key field contains that null value, the alternate-key reference is not added to the alternate-key file. This reduces both the size of the alternate-key file and the access time for the records of a file being accessed according to that alternate key.
Disk Input and Output Partitioned Files Not Updating the Alternate-Key File Automatically Another way to improve the performance of alternate-key file access is to specify that the alternate-key file not be automatically updated by the operating environment when the value of an alternate-key field changes (use the FUP parameter NOUPDATE).
Disk Input and Output Avoiding Deadlock Avoiding Deadlock Deadlock is a situation in which two processes are in contention for a single-user resource. If both processes require exclusive use of both resources, they are deadlocked. Neither can proceed until the other surrenders control of the resource it has under its control. If two servers get into a deadlock, their respective requesters are also deadlocked because neither requester receives a reply from its server.
Disk Input and Output Setting Time Limits on Input-Output Operations To avoid deadlock when processes share and lock files, have each process lock and unlock records and files in the same sequence. Note. If a process is protected by TMF, all locks are retained (despite unlocking statements) until the current transaction is completed or backed out.
Disk Input and Output Using Enscribe and Operating System Routines Suppose that you attempt to read the file OAK with a statement such as: READ OAK-FILE RECORD TIME LIMIT 5 AT END PERFORM END-OAK. IF OAK-ERROR = TIME-OUT-CODE ... When the read operation cannot be completed within 5 seconds, control passes to the USE procedure for the OAK file, which can adjust the program’s behavior appropriately. The USE procedure displays a diagnostic to the OUT file.
Disk Input and Output Physical File Names Physical File Names A physical file name is the file name by which the Enscribe disk file handling routines recognize a file (as opposed to the COBOL file name, which is also called the internal file name). In the non-CRE environment, Enscribe disk file handling routines demand file names in one of two rigid formats—one for local files and one for files on other nodes of the Expand network.
Disk Input and Output Determining Whether Two COBOL File Names Specify the Same Physical File The HP COBOL routine COBOLFILEINFO or COBOL_FILE_INFO_ accepts a COBOL file name and returns: • • • The file number of the file The internal form of the file name associated with the file description The file-system error code of the last input-output operation attempted for that file For more information about the COBOLFILEINFO routine, see COBOLFILEINFO.
Disk Input and Output Purging a File From an HP COBOL Program Purging a File From an HP COBOL Program The HP COBOL language provides no mechanism for deleting a file from the system directory; an HP COBOL program can purge a file only through an explicit call to the FILE_PURGE_ procedure. The file being purged must be closed. The FILE_PURGE_ procedure accepts the internal form of a file name as a parameter.
Disk Input and Output Purging the Contents of a File From an HP COBOL Program Unless the CLEARONPURGE flag is set for a file, purging the file does not obliterate the data on the disk. If security is a major consideration, use one of these to set the CLEARONPURGE flag: • • The FUP SECURE command with the CLEARONPURGE option The SETMODE routine For more information about the FILE_PURGE_ and SETMODE routines, see the Guardian Procedure Calls Reference Manual.
Disk Input and Output Creating a File Having Alternate Keys From an HP COBOL Program Creating a File Having Alternate Keys From an HP COBOL Program At times, it is necessary within an HP COBOL process to create and operate on a file that has alternate keys. Suppose the file must be named and built during execution. The only way to do this is through a series of steps involving a few Enscribe routines: 1. Declare the records of the file in a file description entry. 2.
Disk Input and Output Creating a File Having Alternate Keys From an HP COBOL Program Declare parameters to pass to the FILE_CREATELIST_ procedure to create the indexed file (see the Guardian Procedure Calls Reference Manual for details on these parameters): • • • The file type (key-sequenced) The record length The prime record key parameters (key length = 16, key offset = 0, and index block length = default): 01 01 01 01 01 01 Create-error Error-item File-name File-name-len Fs Fp-chg NATIVE-2.
Disk Input and Output Creating a File Having Alternate Keys From an HP COBOL Program Example 28-14. Dynamic File Assignment ...
Disk Input and Output Creating a File Having Alternate Keys From an HP COBOL Program HP COBOL Manual for TNS and TNS/R Programs —522555-006 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 TAL 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 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. HP TXP.
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 Sharing a Terminal Example 29-3. READ Statement With PROMPT Phrase (page 2 of 2) DATA DIVISION. FILE SECTION. FD A-TERM RECORD CONTAINS 1 TO 79 CHARACTERS LABEL RECORDS ARE OMITTED. * Using 80 characters causes a blank line after the * WRITE. 01 A-TEXT-RECORD PICTURE X(79). WORKING-STORAGE SECTION. 01 TAUNT PIC X(17) VALUE "What do you want?". PROCEDURE DIVISION. A. * Open the terminal as a file, excluding other users. OPEN I-O A-TERM EXCLUSIVE. B. * Read one 79-character record.
Terminal Input and Output Terminal Associated With a Command Interpreter Terminal Associated With a Command Interpreter When a command interpreter has a terminal open for its IN and OUT file, an HP COBOL process can open that terminal as a file only if it opens it for shared access (the default). It cannot open such a terminal for exclusive access, even if the command interpreter does not accept messages from or send messages to that terminal for the duration of the HP COBOL process’s execution.
Terminal Input and Output Transferring Break Ownership When a command interpreter starts a process, whether or not the process uses the command interpreter’s terminal for any input or output, the command interpreter retains ownership of Break unless another process explicitly obtains ownership of Break from the operating environment.
Terminal Input and Output Communicating With an Operator or Process 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. 03 PREV-ACCESS-MODE NATIVE-2. ... PROCEDURE DIVISION. ... OPEN I-O A-TERM. ENTER TAL "COBOLFILEINFO" USING A-TERM OMITTED OMITTED FILE-NUMBER. * Get ownership of Break, saving previous info.
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 Logging Program Activity Information to a Terminal 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 If you use the DISPLAY statement to send messages to the console, and therefore to the standard log file terminal, you must associate a mnemonic name with $0 in the SPECIAL-NAMES paragraph. This association is established at compilation time. Each DISPLAY statement transmits characters to a single terminal or device.
Terminal Input and Output Logging Program Activity Information to a Terminal HP COBOL Manual for TNS and TNS/R Programs —522555-006 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 Form Name If a job must be printed on a specific form, give the job a form name. Each device known to the spooler can have a form name. 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.
Printer and Spooler Output Spooling Compiler Listings Spooling Compiler Listings To send your compiler listing to a spooler, specify a spooler collector and location for your OUT file when you compile your HP COBOL program; for example: COBOL85 /IN WHIZBANG, OUT $S.#WIZZ/;SYNTAX The compiler uses level 3 spooling when the OUT file is a spooler collector (device subtype 31).
Printer and Spooler Output Spooling Program Output Level-2 Spooling You use level-2 spooling the way you use level-1 spooling, except that instead of opening the output file with the OPEN statement, you open it with the routine COBOL85^SPECIAL^OPEN (in the non-CRE environment) or COBOL_SPECIAL_OPEN_ (in the CRE), giving the first parameter, open-type, the value 1, and either omitting the parameter level-3 or giving it the value 0.
Printer and Spooler Output Spooling Program Output Example 30-2. Level-2 Spooling SELECT SPOOLER-FILE ASSIGN TO "$S" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS SPOOLER-FILE-STAT. ... FD SPOOLER-FILE RECORD IS VARYING FROM 80 TO 132 CHARACTERS. 01 SPOOLER-SHORT-LINE PIC X(80). 01 SPOOLER-LONG-LINE PIC X(132). WORKING-STORAGE SECTION. 01 SPOOLER-FILE-STAT PIC XX.
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 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 Specify a spooler supervisor with which SPOOLCOM is to communicate OPEN 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.
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 • • Initiating a Process From an HP COBOL Program The number of memory pages the new process is to be allocated (optional) A numeric data item in which the operating environment is to return the process ID (name, processor number, and number of process within that processor) after the process is created (optional and of little use to the HP COBOL programmer) Note.
Process Initiation, Communication, and Management Initiating a Process From an HP COBOL Program Example 31-1. CREATEPROCESS Routine (page 2 of 3) * * * * * ENTER "CREATEPROCESS" USING COB-PROC-2 PROC-NAME Copy my IN, OUT, & default VOL/SUBVOL SEND-STD-STARTUP-MSG Default--same priority as me OMITTED Default--same processor as me OMITTED Default--use regular memory allocation OMITTED Report process ID of $QUEEN PROC-ID GIVING SU-ERROR. * Report any startup problem.
Process Initiation, Communication, and Management Communicating With a Process Example 31-1. CREATEPROCESS Routine (page 3 of 3) ELSE * * -- Received raw error from NEWPROCESS system procedure. -- Decompose it into left byte and right byte values. DIVIDE SU-ERROR BY 256 GIVING NEWPROCESS-ERR-LEFT REMAINDER NEWPROCESS-ERR-RIGHT. DISPLAY PROC-FAILED " -- NEWPROCESS error # = (" NEWPROCESS-ERR-LEFT "," NEWPROCESS-ERR-RIGHT ")" ...
Process Initiation, Communication, and Management $RECEIVE As with any other read operation, a process waiting to receive a message on $RECEIVE waits until a message is delivered, the process is stopped, or a timeout occurs on the read operation. Before a process can receive a message, some process must have sent a message to it. To send a message, a process must have the name of the process that is to receive the message (see Process Names).
Process Initiation, Communication, and Management $RECEIVE All files are assigned to $RECEIVE; however, when testing your system, you can assign all files to disk files and then reassign them to $RECEIVE when testing is completed. Example 31-2. Requester Code ... SELECT TRANSACTIONS ASSIGN TO "$BAL" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL. ... FD * 01 01 TRANSACTIONS LABEL RECORDS ARE OMITTED Variable-length records RECORD CONTAINS 1 TO 8 CHARACTERS. BALANCE PICTURE 9(8). ERROR-ON-TASK.
Process Initiation, Communication, and Management $RECEIVE Example 31-3. Server Code (page 2 of 2) SELECT ERROR-MSG ASSIGN TO "$RECEIVE" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL. RECEIVE-CONTROL. TABLE OCCURS 20 TIMES SYNCDEPTH LIMIT IS 2 REPLY CONTAINS 8 CHARACTERS. ... DATA DIVISION. FILE SECTION. FD TASKS-IN LABEL RECORDS ARE RECORD CONTAINS 7 01 TASK.
Process Initiation, Communication, and Management $RECEIVE $RECEIVE as Input-Output File In this case, $RECEIVE is opened in I-O mode to receive requests and reply to them through the same file. Each request is acted upon and paired with a reply message sent back in response to the task. Figure 31-3. $RECEIVE as Input/Output File Task Message Requester Server Reply Message VST711.vsd The requesting process follows the outline in Example 31-4. Example 31-4. Requester Code (page 1 of 2) ...
Process Initiation, Communication, and Management $RECEIVE Example 31-4. Requester Code (page 2 of 2) PROCEDURE DIVISION. ... OPEN I-O TRANSACTIONS SYNCDEPTH 1. ... MOVE TCODE TO TRAN-CODE. MOVE ACCOUNT-IN TO ACCOUNT-NUMBER. READ TRANSACTIONS WITH PROMPT TRAN-REQUEST. ... The server process receives the account number and transaction code from $RECEIVE and sends a response back to the requester, as Example 31-5 shows. Example 31-5. Server Code (page 1 of 2) INPUT-OUTPUT SECTION. FILE-CONTROL. ...
Process Initiation, Communication, and Management Process Names Example 31-5. Server Code (page 2 of 2) PROCEDURE DIVISION. ... OPEN I-O TASKS-IN. ... READ TASKS-IN. IF TRAN-PMT PERFORM ... IF SOME-ERROR MOVE 2 TO RESULT-CODE ELSE MOVE 1 TO RESULT-CODE MOVE WS-NEW-BALANCE TO NEW-BALANCE WRITE TRAN-RESPONSE ELSE ... Process Names A process that expects to receive messages must have a name by which the sending process can designate it.
Process Initiation, Communication, and Management Example of Simple Interprocess Communication The report in Example 31-6 shows that the process-pair named $Z000 consists of a primary process running in processor module 00 with the process identification number (PIN) 022 and a backup process running in processor 01 with the PIN 021. The processor and PIN of the process that started $Z000 (its ancestor) is 00,021.
Process Initiation, Communication, and Management Example of Simple Interprocess Communication Example 31-7. PITCHER Code IDENTIFICATION DIVISION. PROGRAM-ID. PITCHER. AUTHOR. JO COBOL. INSTALLATION. TRANSACTIONS ANONYMOUS. DATE-WRITTEN. 29 FEBRUARY 1988. DATE-COMPILED. ************************************************************* * This program illustrates the transmission of messages to * * another COBOL program, CATCHER, whose process name is * * $CATCH.
Process Initiation, Communication, and Management Example of Simple Interprocess Communication Example 31-8. CATCHER Code IDENTIFICATION DIVISION. PROGRAM-ID. CATCHER. AUTHOR. SANDY COBOL. INSTALLATION. TRANSACTIONS ANONYMOUS. DATE-WRITTEN. 29 FEBRUARY 1988. DATE-COMPILED. ********************************************************* * This program illustrates the receipt of messages from * * another COBOL program, PITCHER. * * * * This program must be run as a process named $CATCH.
Process Initiation, Communication, and Management RECEIVE-CONTROL Paragraph RECEIVE-CONTROL Paragraph The RECEIVE-CONTROL paragraph of the Environment Division is an HP extension to COBOL. The RECEIVE-CONTROL paragraph in process $XX serves these purposes: • • • • It defines the receive-control table for process $XX. This specifies the maximum number of other processes that can have process $XX open concurrently.
Process Initiation, Communication, and Management • At-End Condition SYNCDEPTH Usually set to 1 for Pathway servers unless they are multithreaded. • REPLY CONTAINS Specifies the length of the reply that the server sends back to the requester. It specifies the name of the file containing the longest record that is used as a reply or an explicit number of characters.
Process Initiation, Communication, and Management • • • • • Simple Server Example The OPEN SYNCDEPTH value in the requester process that opens the server process must not exceed the sync value in the RECEIVE-CONTROL paragraph of the server process. Only one reply WRITE to each READ on $RECEIVE is allowed. If you fail to reply to a message before you read the next one, the HP COBOL run-time routines send a default reply. In this situation, you cannot reply to that earlier message.
Process Initiation, Communication, and Management Simple Server Example Example 31-9. Simple Server (page 2 of 4) SELECT MESSAGE-OUT ASSIGN TO $RECEIVE FILE STATUS IS RECEIVE-FILE-STATUS. SELECT PHONE-BOOK ASSIGN TO "$AA.BB.PHONE" ORGANIZATION IS INDEXED ACCESS MODE IS DYNAMIC RECORD KEY IS PH-EMPLOYEE-NUM ALTERNATE RECORD KEY IS PH-EMPLOYEE-NAME ALTERNATE RECORD KEY IS PH-EMPLOYEE-PHONE-NUM FILE STATUS IS PHONE-FILE-STATUS. RECEIVE-CONTROL.
Process Initiation, Communication, and Management Simple Server Example Example 31-9. Simple Server (page 3 of 4) WORKING-STORAGE SECTION. 01 REPLY-CODE-VALUES. 05 OK-REPLY PIC 999 05 BAD-REQUEST-REPLY PIC 999 05 START-FAILED-REPLY PIC 999 05 NONE-FOUND-REPLY PIC 999 01 FILE-STATUSES. 05 RECEIVE-FILE-STATUS. 88 RECEIVE-FILE-OK 88 CLOSE-FROM-REQUESTER 10 R-STAT-1 10 R-STAT-2 05 PHONE-FILE-STATUS. 10 P-STAT-1 10 P-STAT-2 88 PHONE-FILE-OK VALUE VALUE VALUE VALUE ZERO. 1. 2. 900. VALUE IS ZEROS.
Process Initiation, Communication, and Management Simple Server Example Example 31-9. Simple Server (page 4 of 4) ***************************************************************** A-INIT. OPEN INPUT MESSAGE-IN SYNCDEPTH 1 OUTPUT MESSAGE-OUT INPUT PHONE-BOOK SHARED. ***************************************************************** C-EOJ. CLOSE MESSAGE-IN MESSAGE-OUT PHONE-BOOK. B-TRANS. READ MESSAGE-IN.
Process Initiation, Communication, and Management Managing a Process More information: Topics Sources Programming servers and Pathsend requesters in the Pathway environment TS/MP Pathsend and Server Programming Manual Programming SCREEN COBOL requesters in the Pathway environment Pathway/TS TCP and Terminal Programming Guide Configuring and managing servers in the Pathway environment TS/MP System Management Manual Managing a Process Besides creating processes and communicating with processes, a pr
Process Initiation, Communication, and Management Determining the Node (System Number) A process can obtain its process ID by passing its process number to the PROCESSHANDLE_DECOMPOSE_ procedure, which returns the processor and PIN values as separate integer values. If you do not know the process number, you can get it by calling the PROCESSHANDLE_GETMINE_ procedure. Example 31-10. PROCESSHANDLE_GETMINE_ and PROCESSHANDLE_DECOMPOSE_ Procedures WORKING-STORAGE SECTION. 01 PROCESS-HANDLE 01 CPU-PIN.
Process Initiation, Communication, and Management Identifying the Message Source Example 31-11. Determining a Process’s Node (System Number) (page 2 of 2) ************************************************************* * This program obtains and reports its own system number * * and system name. * ************************************************************* ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP TXP. OBJECT-COMPUTER. HP TXP. DATA DIVISION. WORKING-STORAGE SECTION.
Process Initiation, Communication, and Management Identifying the Message Source The capability of identifying the source of a message allows a process to respond differently to the same request coming from different processes or even to reject certain requests from certain processes. Example 31-12 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.
Process Initiation, Communication, and Management Determining the Status Example 31-12. MESSAGE-SOURCE Clause (page 2 of 2) AA SECTION. AA-1. OPEN INPUT MESSAGE-IN-FILE. MOVE ZERO TO SYS-MSG-CODE RECEIVE-FILE-STATUS. PERFORM WATCH UNTIL NOT RECEIVE-FILE-OK. STOP RUN. 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.
Process Initiation, Communication, and Management • • Determining the Status The system number (in a network of systems) on which the process is running An error value, indicating the success of (or the nature of the failure of) the request 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.
Process Initiation, Communication, and Management Determining the Status You can therefore provide a mechanism for passing nonsensitive data from a file containing both sensitive and nonsensitive data to a class of users who should not receive the sensitive data. For more information about these security features, see the operating environment user’s guide for your system.
Process Initiation, Communication, and Management Determining the Status Example 31-13. 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-13. 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-14. 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-14. 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-14. 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-15. 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-15. 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-16. 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-16. Monitoring Completion of Descendant Processes (page 3 of 3) * Start FUP ENTER "CREATEPROCESS" 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. DISPLAY-STARTUP-FAILURE.
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-17. Suspending a Process (page 2 of 2) 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. 01 REPORT-STATUS PIC XX VALUE " ". 01 REPEAT-INTERVAL PIC S9(10) VALUE 30000.
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 of the Data Division. You can only checkpoint data items in the Extended-Storage Section if your program runs in the CRE or is a native process.
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 4nnn Meaning In the non-CRE environment, 4nnn indicates a NEWPROCESS failure. If nnn is less than or equal to 255, nnn is the file system error associated with the disk file where the loadfile was to be found.
Fault-Tolerant Processes Using the Fault-Tolerant Facility The action your program should take in response to an exception status (a status other than “0000”) depends upon your application and the location of the error in your HP COBOL program. A takeover might need special processing. Most of the other status values indicate a program coding problem or a system configuration problem. Report the latter problem to the appropriate authority for your system.
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) PROCEDURE DIVISION. CENTRAL SECTION. ... OPEN I-O TEST-FILE SHARED SYNCDEPTH 1. PERFORM GET-CPUNUM. STARTBACKUP BCPU, 1. IF PROGRAM-STATUS NOT = "0000" DISPLAY "STARTBACKUP UNSUCCESSFUL, STATUS = ", PROGRAM-STATUS. STOP RUN. PERFORM UPDATE-RECS UNTIL UPDATES-DONE. ... GET-CPUNUM. ENTER "GETBACKUPCPU" IN COBOLLIB GIVING BCPU.
Fault-Tolerant Processes Debugging Programs That Use the Fault-Tolerant Facility If your SYNCDEPTH exceeds one, and you open or close a file during checkpointprotected operation, you must checkpoint the sync blocks and record areas of all other files before the next nonretryable operation. If you need to checkpoint data that is in the Extended-Storage Section, you must compile your program to run in the CRE.
Fault-Tolerant Processes Concepts Before TMF was available, the answer to the first question was to write application code to back out partial transactions and restore the affected parts of the database to the condition they were in when the failed transaction began. Further, this application code had to be fault tolerant to overcome possible single points of failure. The answer to question two was to stop the system periodically and make tape or disk backups.
Fault-Tolerant Processes Concepts Each transaction has a unique transaction identifier. The identifier includes information about the starting time of the transaction. If your transaction involves more than one file or if the single file it involves is available to other transactions, you can introduce inconsistency into the database. Multiple-File Transactions Suppose your process is maintaining a corporate personnel system in which each department has its own file of information.
Fault-Tolerant Processes Concepts Audit Trails An audit trail is a set of disk files in which a record is kept of before-images and afterimages of all records changed by each transaction that occurs in a certain file. A file is described as audited when it has an audit trail. In TMF, every disk file in which records are to be changed can be audited. If a disk is involved in transactions whose failure could leave the database in an inconsistent state, that disk file should be audited.
Fault-Tolerant Processes Designing Programs for the TMF Subsystem Record Locking As a transaction progresses in TMF, these types of resources must be locked: • • • Records that are changed or inserted into the database Records whose values affect the course of the transaction Keys of deleted records If you are going to rewrite a record in an audited file, you must first lock it when you read it. The TMF subsystem automatically locks records that are inserted and keys of records that are deleted.
Fault-Tolerant Processes The TMF Subsystem and Requester Screen Transactions The TMF Subsystem and Requester Screen Transactions Because the server’s TMF protection is governed by the requester, you need to coordinate the designs of the two. If the terminal user needs to traverse more than one screen for each transaction, you must consider how to package the transaction. Transactions that consist of several screens are easy and straightforward to program but can be expensive.
Fault-Tolerant Processes Debugging Programs That Use the TMF Subsystem Debugging Programs That Use the TMF Subsystem There are no debugging tools specific to TMF application debugging. You can use a symbolic debugger, to set breakpoints in both SCREEN COBOL terminal programs and in server programs.
33 Migrating TNS Programs to Native Programs Note. This section applies to migrating TNS HP COBOL programs to TNS/R or TNS/E HP COBOL programs. To migrate TNS/R HP COBOL programs to TNS/E HP COBOL programs, see the COBOL Manual for TNS/E Programs. HP NonStop Series/RISC and HP NonStop Series/Itanium enable you to write programs that are fully optimized for NonStop Series/RISC and NonStop Series/Itanium systems such as HP NonStop systems.
Migrating TNS Programs to Native Programs Reasons to Migrate Topics: • • • • • • • Reasons to Migrate Migrating HP COBOL Programs Data Alignment Source Program Changes Development and Management Changes Maintaining Common Source Code Using the Inspect and Visual Inspect Debuggers Reasons to Migrate A cost is associated with migrating from TNS HP COBOL to native HP COBOL, but in most cases, it is minor. You must decide whether the long-term return justifies the expense.
Migrating TNS Programs to Native Programs Migrating HP COBOL Programs For a native HP COBOL program, search lists are optional. If a program does not have search lists, or if the compiler cannot find an external reference in the files on the search lists: • TNS/R TNS/E The NMCOBOL compiler automatically searches the SRLs ZCOBSRL and ZCRESRL and then the file NMCOBEXT (the TNS/R equivalent of COBOLEXT).
Migrating TNS Programs to Native Programs Migrating HP COBOL Programs 3. If necessary, change your source program (see Source Program Changes). To learn whether you must change your source program, compile it with the NMCOBOL or ECOBOL compiler, which will issue warnings when it encounters source constructs that it does not accept. Running the NMCOBOL or ECOBOL compiler with the new DIAGNOSE-85 directive is especially recommended.
Migrating TNS Programs to Native Programs ° Migrating HP COBOL Programs FORTRAN and Pascal There are no native FORTRAN or Pascal compilers. Rewrite FORTRAN and Pascal programs in native HP C, native HP C++, native HP COBOL, or pTAL. You need not use the same language for all of them. ° Data Alignment The COBOL85 and NMCOBOL compilers generate code with the same data alignment. You need not change any data alignment directives before migrating a TNS HP COBOL program to native HP COBOL.
Migrating TNS Programs to Native Programs Data Alignment 6. Compile your source program with the NMCOBOL or 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 NMCOBOL or ECOBOL compiler needs more symbol table space than the COBOL85 compiler does.
Migrating TNS Programs to Native Programs Misalignment Tracing Facility In addition to HP COBOL, the data misalignment issue might affect programs that use this NonStop software.
Migrating TNS Programs to Native Programs Misalignment Handling Because a process can run for a long time, the tracing facility samples the process (that is, checks its exception data) periodically (approximately once an hour). If the process recorded an exception since the previous sample, the tracing facility records an entry in the EMS log. If the process ends and an exception has occurred since the last sample, the operating system produces a final Event Management Service (EMS) event.
Migrating TNS Programs to Native Programs Misalignment Handling Table 33-1. TNS Misalignment Handling Methods Method Description ROUND (default)* After rounding down a misaligned address, the system proceeds to access the address, as done in G06.16 and earlier RVUs. FAIL Instead of rounding down a misaligned address and proceeding to access the target, the operating system considers the instruction to have failed. For a Guardian process, this failure generates an Instruction Failure trap (trap #1).
Migrating TNS Programs to Native Programs Causes of Misalignment in HP COBOL Programs Causes of Misalignment in HP COBOL Programs In native HP COBOL programs, misaligned addresses might slow down program execution, but the misaligned addresses are never “rounded down” and do not cause the program to terminate abnormally. In TNS HP COBOL programs, reference parameters and the targets of pointers to BINARY or COMPUTATIONAL data items must be aligned on 2-byte memory boundaries for correct operation.
Migrating TNS Programs to Native Programs • Causes of Misalignment in HP COBOL Programs Using an explicit number for the offset of a record or for the size of a record This practice can cause misaligned addresses by overlooking the “implicit” filler bytes that the COBOL85 compiler adds to records: ° Within records, to ensure that every BINARY or COMPUTATIONAL field begins at an even-byte offset from the beginning of the structure ° At the end of any record that has an odd number of bytes, to give it
Migrating TNS Programs to Native Programs Causes of Misalignment in HP COBOL Programs Example 33-1. Misalignment (page 2 of 2) Subprogram: IDENTIFICATION DIVISION. PROGRAM-ID. PROG-2. DATA DIVISION. * * LINKAGE SECTION. Prog-2's reference containing 1-word, 01 indirect-group. 05 v16 PIC S9(4) 05 v32 PIC s9(9) 05 v64 PIC S9(18) parameter is a 16-bit-word-aligned group 2-word, and 4-word binary numeric items: COMP. COMP. COMP. PROCEDURE DIVISION USING indirect-group. main.
Migrating TNS Programs to Native Programs Source Program Changes Source Program Changes Source program changes fall into these categories: • • • • • General Migration Tasks Removal Required Possible Changes Required Removal Optional New Features (Optional) General Migration Tasks If your HP COBOL program calls obsolete or changed Guardian procedures, replace them.
Migrating TNS Programs to Native Programs • Removal Required USE DEBUGGING Statement The 1985 COBOL standard classifies the USE DEBUGGING statement as obsolete, so you are advised not to use it even in TNS HP COBOL programs.
Migrating TNS Programs to Native Programs Possible Changes Required References to TNS libraries can appear in these contexts: • • • • • CONSULT directive LIBRARY directive SEARCH directive File-mnemonic clause of the SPECIAL-NAMES paragraph OF or IN clause of the CALL or ENTER statement Possible Changes Required The COBOL85, NMCOBOL, and ECOBOL compilers handle these items differently: • • • • Checkpointing Directives ENTER Statement Floating-Point Arithmetic Make any necessary changes to these item
Migrating TNS Programs to Native Programs • Possible Changes Required CONSULT 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). For the ECOBOL compiler, each object-name in a CONSULT directive must designate a TNS/E native object file (otherwise the compiler reports an error). If a native HP COBOL program references the object in a CALL or ENTER statement, the object must have been compiled with symbols.
Migrating TNS Programs to Native Programs • Possible Changes Required SAVEABEND and NOSAVEABEND The SAVEABEND and NOSAVEABEND directives work in the NMCOBOL and ECOBOL compilers only if you specify the new RUNNABLE directive (see RUNNABLE directive). For a complete description of these directives, see SAVEABEND and NOSAVEABEND. • SEARCH 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).
Migrating TNS Programs to Native Programs Removal Optional Removal Optional The NMCOBOL and ECOBOL compilers ignore these items, so you can (but need not) remove them from your source program. The NMCOBOL and ECOBOL compilers give a warning when they find these items, except as noted. • CODE and NOCODE directives The NMCOBOL and ECOBOL compilers do not produce an octal code listing.
Migrating TNS Programs to Native Programs • Removal Optional HIGHREQUESTERS directive Native HP COBOL programs can always run as servers that communicate with requesters running at high PINs. • ICODE and NOICODE directives The NMCOBOL and ECOBOL compilers ignore these directives, warning you that they have done so. Use the INNERLIST and NOINNERLIST directives instead (see INNERLIST and NOINNERLIST directives).
Migrating TNS Programs to Native Programs New Features (Optional) New Features (Optional) You can (but need not) add these new features to your HP COBOL source program before you compile it with the NMCOBOL or ECOBOL compiler. • CALL-SHARED directive The CALL-SHARED directive generates shared code (PIC). See CALL-SHARED. For the ECOBOL compiler, this is the default.
Migrating TNS Programs to Native Programs Development and Management Changes This is not the default. If you run the NMCOBOL or ECOBOL compiler without the RUNNABLE directive and no compilation errors occur, you can produce a loadfile by running the appropriate linker separately.
Migrating TNS Programs to Native Programs Development and Management Changes The nld, ld, or eld utility does not support the Binder product’s SELECT SEARCH behavior. You can usually achieve similar results with the nld, ld, or eld utility by using archive files (files created by the ar utility). Because of this difference between Binder and the nld, ld, or eld utility, you might need to change the way you specify files in CONSULT and SEARCH directives.
Migrating TNS Programs to Native Programs Maintaining Common Source Code Maintaining Common Source Code To maintain “common source code” that can be compiled with D32.00 and later RVUs of the COBOL85 compilers, D44.01 and later RVUs of the NMCOBOL compiler, and H06.01 and later RVUs of the ECOBOL compiler, follow these guidelines: • Either do not use HP COBOL language features that are not supported by all compilers, or use conditional compilation to isolate those features.
Migrating TNS Programs to Native Programs Using the Inspect and Visual Inspect Debuggers HP COBOL Manual for TNS and TNS/R Programs —522555-006 33 -24
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. COBOL Cross Compiler Platforms Operating System Platform Cross Compiler Name Product Number Windows 98 Windows NT 4.0 Windows 2000 Windows XP TDS1 Tandem COBOL T0328 Yes Yes No No ETK2 NonStop COBOL for TNS/R T2776 No Yes Yes Yes PC command line3 nmcobol T2776 No Yes Yes Yes 1. HP Tandem Development Suite 2.
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 RISC-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 (ETK, RVU G06.
Native COBOL Cross Compiler on PC NonStop COBOL for TNS/R (ETK) NonStop COBOL for TNS/R (ETK) The optional native COBOL cross compiler for use with the ETK is called NonStop COBOL for TNS/R. 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 Tandem COBOL (TDS) Tandem COBOL (TDS) The optional native COBOL cross compiler for use with the TDS is called Tandem NMCOBOL. TDS allows you to select Tandem NMCOBOL options from the TDS addon to the Borland integrated development environment (IDE) GUI. You can develop, edit, and build COBOL applications from within the IDE. You can embed SQL/MP or SQL/MX statements in Tandem NMCOBOL source code.
Native COBOL Cross Compiler on PC nmcobol (PC Command Line) cobol-opt is one of these nmcobol flags: cobol-opt Sources -Wcobol="arguments " Using the Command-Line Cross Compilers on Windows (see Documentation) -Wcopylib=file Open System Services Shell and Utilities Reference Manual comp-opt is one of these nmcobol flags: • • • • • • • • • • • • • • • -I directory -O [ 0 | 1 ] -Wcall_shared -Wcolumns=N -Werrors=N -W[no]innerlist -W[no]list -W[no]map -Wnon_shared -Woptimize={0|1} (The PC does not ac
Native COBOL Cross Compiler on PC • • • • • • • • • • • • • nmcobol (PC Command Line) -W[no]inspect -Wld -Wld_obey -Wnld -Wnld_obey -Wnostdlib -W[no]optional_lib -Wr -W[no]reexport -Wrunnamed -W]no]saveabend -Wu -Wx sqlmp-opt is described in Using the Command-Line Cross Compilers on Windows (see Documentation). sqlmx-opt is described in Using the Command-Line Cross Compilers on Windows (see Documentation).
Native COBOL Cross Compiler on PC Linking You can embed SQL/MP or SQL/MX statements in NonStop COBOL source code. Valid NonStop COBOL source files have these extensions: Extension Meaning .cob or .cbl COBOL source code with or without embedded SQL/MP statements .ecob or .ecbl COBOL source code with embedded SQL/MX statements To complete SQL/MP or SQL/MX compilation, you must specify the host and the user logon. Specifying the NonStop server location (Guardian subvolume or OSS directory) is optional.
Native COBOL Cross Compiler on PC Command-Line Platform Command-Line Platform On the command-line platform, debug loadfiles that were compiled with the native COBOL cross compiler either with Visual Inspect on Windows (some restrictions might apply for files containing SQL/MX statements) or by running Inspect on the NonStop server. To use Inspect, you must copy the loadfiles and the source files to the host (see PC-to-NonStop-Host Transfer Tools). Note. You must use Visual Inspect to debug PIC loadfiles.
Native COBOL Cross Compiler on PC RUNV run-option IN OUT accept-device display-device VST333.vsd is an option of the RUN command, described in the TACL Reference Manual. For COBOL programs, two of the run options, IN and OUT, have special significance: accept-device has a value that designates a terminal or a process and can be a filesystem file name or (in the Guardian environment) a DEFINE name. accept-device specifies the device from which an unqualified ACCEPT statement retrieves input.
Native COBOL Cross Compiler on PC Tools and Utilities 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. RUNV reads the IP address from the environment variable or from the command line. If you have set the environment variable but enter a different IP address on the RUNV command line, the command-line entry overrides the environment variable definition.
Native COBOL Cross Compiler on PC PC-to-NonStop-Host Transfer Tools PC-to-NonStop-Host Transfer Tools The ETK allows you to transfer loadfiles and source files to the NonStop host using the Deploy command or the Transfer Tool. Deploy builds and copies each project in the active solution to the NonStop host. The Transfer Tool moves files to the NonStop host for execution and debugging. The Transfer Tool is better for transferring very large, complex applications to the NonStop host.
Native COBOL Cross Compiler on PC HP COBOL Manual for TNS and TNS/R Programs —522555-006 34 -12 Documentation
Part III.
Part III.
35 • • • Commands Guardian Environment OSS Environment nmcobol (PC Command Line) Guardian Environment • • • • • • Before Running the Compiler (Optional) Running the COBOL85 Compiler Running the NMCOBOL Compiler Running the Native Cross Compiler Under Visual Inspect Before Running the Compiled Program (Optional) Running the Compiled Program Before Running the Compiler (Optional) Note. The NMCOBOL compiler does not accept the PARAM SAMECPU command. PARAM SAMECPU dummy-value VST417.
Commands Running the COBOL85 Compiler Running the COBOL85 Compiler COBOL85 IN / / source-file , OUT list-file , other-option target-name , ( obj-1 , copy-library ; compiler-directive obj-n ) VST256.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 NMCOBOL Compiler obj-1 ... obj-n file-name-4 define-name VST261.vsd copy-library file-name-4 define-name VST261.vsd Running the NMCOBOL Compiler NMCOBOL / IN source-file / , OUT list-file , other-option target-name , copy-library ; compiler-directive VST728.vsd source-file list-file target-name obj-1 ... obj-n copy-library See source-file through copy-library.
Commands Running the Native Cross Compiler Under Visual Inspect 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.vsd 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.
Commands Running the Compiled Program Running the Compiled Program RUN program-file RUND / run-option-list / program-parameter-list VST331.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 Compiler (Optional) Before Running the Compiler (Optional) To change one or more of the defaults in Table 35-1 before executing the cobol or nmcobol command, use the OSS export command. To execute a cobol or nmcobol command with a specified set of environment variables, use the OSS env function with the environment variables in Table 35-1. Table 35-1.
Commands Running the cobol (COBOL85) Compiler Running the cobol (COBOL85) Compiler cobol pathname flag operand operand VST621.vsd flag is as described in the Open System Services Shell and Utilities Reference Manual. operand pathname -l library VST622.vsd pathname ns file ns . cbl cob a o srl VST623.vsd Running the nmcobol Compiler nmcobol pathname flag operand operand VST733.vsd flag is as described in the Open System Services Shell and Utilities Reference Manual.
Commands Running the Compiled Program operand pathname -l library VST622.vsd pathname ns file ns . cbl cob ecbl ecob a m o srl VST623.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 nmcobol (PC Command Line) nmcobol (PC Command Line) Beginning with RVU G06.14, you can invoke the native COBOL cross compiler, nmcobol, from the command line (DOS prompt) on your PC. nmcobol -c -g -o cobol-opt comp-opt link-opt sqlmx-opt nmcobol-opt file outfile sqlmp-opt VST820.vsd -c -g -o outfile -cobol-opt -comp-opt -link-opt -sqlmp-opt -sqlmx-opt -nmcobol-opt file See nmcobol (PC Command Line).
Commands nmcobol (PC Command Line) HP COBOL Manual for TNS and TNS/R Programs —522555-006 35 -14
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 cobol or nmcobol 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 • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • DIAGNOSEALL and NODIAGNOSEALL ENDIF ENDUNIT ENV ERRORFILE ERRORS FIPS and NOFIPS FLOAT and NOFLOAT FMAP HEADING HEAP HIGHPIN HIGHREQUESTERS ICODE and NOICODE IF and IFNOT INNERLIST and NOINNERLIST INSPECT and NOINSPECT LARGEDATA LD LESS-CODE LIBRARY LINES LIST and NOLIST LMAP and NOLMAP MAIN MAP and NOMAP NLD NLD NON-SHARED OPTIMIZE HP COBOL Manual for TNS and TNS/R Programs —522555-006 36- 2
Compiler Directives • • • • • • • • • • • • • • • • • • • • • • • • • • 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 SQLMEM SUBSET SUBTYPE SUPPRESS and NOSUPPRESS SYMBOLS and NOSYMBOLS SYNTAX TANDEM TRAP2 and NOTRAP2 TRAP2-74 and NOTRAP2-74 UL WARN and NOWARN HP COBOL Manual for TNS and TNS/R Programs —522555-006 36- 3
Compiler Directives ANSI 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. Dependencies: None References: TANDEM BLANK and NOBLANK BLANK NOBLANK VST267.
Compiler Directives CALL-SHARED CALL-SHARED Note. The COBOL85 compiler does not recognize this directive. CALL-SHARED NON-SHARED SHARED VST802.vsd Default: NON-SHARED Placement: Anywhere Scope: The last CALL-SHARED, NON-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.
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 CODE and NOCODE CODE and NOCODE Note. The NMCOBOL compiler issues warnings for these directives. CODE NOCODE VST269.vsd Default: NOCODE Placement: Anywhere Scope: In each separately compiled program, the last CODE or NOCODE in the program unit applies to the entire program unit. Dependencies: CODE works only if LIST is active and SUPPRESS is not.
Compiler Directives COLUMNS COLUMNS COLUMNS length VST270.vsd Default: COLUMNS 132 • Placement: • • 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 CROSSREF and NOCROSSREF CROSSREF and NOCROSSREF Note. The NMCOBOL compiler issues warnings for these directives and does not produce a cross-reference listing. If you need one, use the noft utility with the XREFPROC flag (see the noft Manual). CROSSREF class-list NOCROSSREF VST275.vsd class-list class , ONLY class INCLUDE EXCLUDE VST276.
Compiler Directives DIAGNOSE-74 and NODIAGNOSE-74 Default: NOCROSSREF Placement: Anywhere Scope: CROSSREF applies to all separately compiled program units, regardless of nesting; that is, all programs within a nest appear in the same crossreference listing. You need not repeat the CROSSREF directive for each program unit in a compilation unit; the class list active at the end of one program unit applies to the next program unit until explicitly altered by a NOCROSSREF directive.
Compiler Directives DIAGNOSEALL and NODIAGNOSEALL DIAGNOSEALL and NODIAGNOSEALL DIAGNOSEALL NODIAGNOSEALL VST470.vsd Default: NODIAGNOSEALL Placement: Anywhere Scope: Applies until its opposite overrides it Dependencies: None ENDIF ENDIF toggle-number VST278.
Compiler Directives ENV ENV Note. This directive is useful only for the COBOL85 compiler. The NMCOBOL compiler accepts this directive with the COMMON option (the default for this compiler), reports an error for the OLD option, and issues a warning for the LIBRARY option. ENV COMMON LIBRARY OLD VST280.vsd Default: ENV OLD Placement: Must appear before any source code lines Scope: Applies to all programs in its source file Dependencies: None ERRORFILE ERRORFILE file-name define-name VST281.
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 FLOAT and NOFLOAT FLOAT and NOFLOAT Note. The NMCOBOL compiler ignores this directive and issues a warning. FLOAT NOFLOAT VST818.vsd Default: FLOAT Placement: Outside the boundaries of any program Scope: Applies to all subsequent programs Dependencies: None FMAP Note. The COBOL85 compiler does not recognize this directive. FMAP VST731.vsd Default: The NMCOBOL compiler does not produce a source file map.
Compiler Directives HEADING HEADING HEADING " character-string " VST283.vsd character-string Default values is all spaces. Default: Standard top-of-page line Placement: Anywhere Scope: Applies until another HEADING overrides it Dependencies: None HEAP Note. The NMCOBOL compiler ignores this directive and issues a warning. HEAP size VST738.vsd Default: Guardian environment: the heap is nonexistent by default. PC and OSS environments: the heap is large by default and cannot be made larger.
Compiler Directives HIGHPIN HIGHPIN Note. The NMCOBOL compiler ignores this directive and issues a warning. A native HP COBOL program always runs at a high PIN. HIGHPIN VST284.vsd Default: TNS program runs with a low PIN (less than or equal to 255).
Compiler Directives HIGHREQUESTERS HIGHREQUESTERS Note. The NMCOBOL compiler ignores this directive and issues a warning. A native HP COBOL program always runs at a high PIN. HIGHREQUESTERS VST285.vsd Default: Program cannot run as a server that accepts requesters running with high PINs (greater than 255).
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 Note. The COBOL85 compiler does not recognize these directives.
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 LARGEDATA Note. This directive is useful only in the CRE. LARGEDATA item ( ) item , item VST725.
Compiler Directives LD LD Note. The COBOL85 compiler does not accept this directive. LD ( option ) VST111.vsd Default: None Placement: In the command line Scope: Applies to the compilation unit Dependencies: None LESS-CODE Note. The compiler ignores this directive and issues a warning. For the description of this directive, see the COBOL85 Manual for TNS and TNS/R. LESS-CODE bits-to-set VST384.
Compiler Directives LESS-CODE bits-to-set Value of bits-to-set Decimal Binary Result 0 000 Compiler generates code to initialize all areas. 1 001 Compiler generates code to initialize all areas except the Extended-Storage Section in: • • Main programs Other programs that are not initial programs and have NOCANCEL directives active Size of object file increases significantly, amount of code generated decreases significantly, and execution time decreases slightly.
Compiler Directives LIBRARY Default: None Placement: The compiler accepts it anywhere, but to be effective, it must be before the main program. Scope: Applies to the compilation unit Dependencies: None LIBRARY Note. The NMCOBOL compiler ignores this directive and issues a warning. LIBRARY file-name VST289.
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.
Compiler Directives LMAP and NOLMAP LMAP and NOLMAP Note. The NMCOBOL compiler, which does not use BINSERV, ignores these directives and issues warnings. LMAP lm-option-list ( lm-option-list ) * NOLMAP lm-option-list ( lm-option-list ) VST292.vsd lm-option-list lm-option , lm-option VST293.vsd For LMAP, the default value for lm-option-list is ALPHA; for NOLMAP, it is ALPHA, LOC, XREF.
Compiler Directives MAIN MAIN Note. Put this directive before the Identification Division header of the first program unit in the compilation unit. MAIN program-name VST294.vsd Default: Every program unit that does not have a Linkage Section is compiled as a main program. If more than one program unit of a compilation unit qualifies as a main program, the compiler reports this as an error, compiles the first qualifying program unit as the main program, and produces multiple object files.
Compiler Directives NLD NLD Note. The compiler does not accept this directive. For the description of this directive, see the COBOL85 Manual for TNS and TNS/R. NLD ( option ) VST082.vsd Default: None Placement: In the command line Scope: Applies to the compilation unit Dependencies: None NONSTOP Note. • • Do not use this directive in the OSS environment. Before RVU D46.00 and G06.
Compiler Directives NON-SHARED NON-SHARED Note. The COBOL85 compiler does not recognize this directive. NON-SHARED CALL-SHARED SHARED VST803.vsd Default: NON-SHARED Placement: Anywhere Scope: The last NON-SHARED, CALL-SHARED, or SHARED in the compilation unit applies to the entire compilation unit. Dependencies: If RUNNABLE is active, NON-SHARED creates a non-PIC executable object file; otherwise, NON-SHARED creates a non-PIC nonexecutable object file.
Compiler Directives OPTIMIZE OPTIMIZE OPTIMIZE level VST297.vsd level Effect Level COBOL85 Compiler NMCOBOL Compiler 0 Code is not optimized. Provided in case other optimization levels cause errors. Supports symbolic debugging; data is always in memory. 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, but not across statement boundaries.
Compiler Directives PERFORM-TRACE PERFORM-TRACE PERFORM-TRACE VST800.vsd Default: The compiler does not provide additional information if run-time error 148 occurs. Placement: Anywhere Scope: Applies to the compilation unit Dependencies: None PORT and NOPORT PORT 1 2 3 NOPORT VST600.
Compiler Directives RESETTOG RESETTOG RESETTOG toggle-number-list VST298.vsd toggle-number-list toggle-number , toggle-number VST299.vsd Default value is all toggles. Default: None Placement: Must be either on a directive line of its own or be the last of a sequence of directives Scope: Applies until SETTOG overrides it Dependencies: SETTOG overrides it.
Compiler Directives RUNNABLE RUNNABLE Note. The COBOL85 compiler does not recognize this directive. RUNNABLE VST729.vsd Default: The NMCOBOL 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 NMCOBOL compiler.
Compiler Directives RUNNAMED RUNNAMED RUNNAMED VST300.vsd Default: None Placement: Any of: • • • Anywhere in a source program In a stand-alone Binder session 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: For the NMCOBOL compiler, RUNNAMED is appropriate only if the program was compiled with RUNNABLE (because a linkfile is not a run unit)..
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). For the NMCOBOL compiler, SAVEABEND and NOSAVEABEND are appropriate only if the program was compiled with RUNNABLE.
Compiler Directives SEARCH and NOSEARCH SEARCH and NOSEARCH Note. The NMCOBOL 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 Note. The COBOL85 compiler does not recognize this directive. SHARED CALL-SHARED NON-SHARED VST804.vsd Default: NON-SHARED Placement: Anywhere Scope: The last SHARED, CALL-SHARED, or NON-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.
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 NMCOBOL 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.
Compiler Directives SQLMEM SQLMEM Note. The NMCOBOL compiler ignores this directive and issues a warning. The concept of extended memory does not exist for TNS/R processes. SQLMEM USER EXT VST318.vsd Default: SQLMEM EXT Placement: The first SQLMEM in a program must be preceded by SQL. Subsequent SQLMEMs can appear anywhere in the program. Scope: Applies to all SQL/MP tatements between it and the next SQLMEM Dependencies: SQLMEM is allowed only in programs that also contain SQL.
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: For the NMCOBOL compiler, 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 TRAP2 and NOTRAP2 TRAP2 and NOTRAP2 Note. The NMCOBOL compiler, which has traps set by default, ignores these directives and issues warnings. Use the NOTRAP2 directive only during the process of conversion from COBOL 74 to HP COBOL. It is provided to enable programs that do not include SIZE ERROR phrases to be compiled and executed in HP COBOL without investing programmer time in analyzing the potential for overflow problems.
Compiler Directives TRAP2-74 and NOTRAP2-74 TRAP2-74 and NOTRAP2-74 Note. The NMCOBOL compiler, which cannot call COBOL 74 programs, ignores these directives and issues warnings. Use the NOTRAP2-74 directive only during the process of conversion from COBOL 74 to HP COBOL. It is provided to enable programs that do not include SIZE ERROR phrases to be compiled and executed in HP COBOL without investing programmer time in analyzing the potential for overflow problems.
Compiler Directives WARN and NOWARN WARN and NOWARN WARN NOWARN VST330.vsd 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.
Compiler Directives WARN and NOWARN HP COBOL Manual for TNS and TNS/R Programs —522555-006 36 -50
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 PROGRAM END 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 and TNS/R Programs —522555-006 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.
Language Elements and Expressions Simple Class Condition Pointer Operands pointer-subject relationship pointer-object IS VST602.vsd 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 Concatenation Expressions HP COBOL Manual for TNS and TNS/R Programs —522555-006 38 -14
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 GUARDIAN ns device " file-id-1 OSS file-id-2 ns /E/ ns 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 RESERVE number 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 Non-CRE environment: ABEND NEWPROCESSNOWAIT-COMPLETION BREAK NODE-DOWN CLOSE NODE-UP CONTROL OPEN CONTROLBUF POWER-ON CPU-DOWN PROCESS-DELETION CPU-UP PROCESS-TIME-SIGNAL DEVICE-INFO REMOTE-CPU-DOWN DEVICE-INFO-2-COMPLETION REMOTE-CPU-UP JOB-PROCESS-CREATION RESETSYNC LOGICAL-CLOSE SETMODE LOGICAL-OPEN SETPARAM MEMORY-LOCK-COMPLETION SETTIME MEMORY-LOCK-FAILURE STATUS-3270 MESSAGE-CANCELLED STOP MESSAGE-MISSED SYSTE
Environment Division RECEIVE-CONTROL Paragraph MEMORY-LOCK-FAILURE SETTIME MESSAGE-CANCELLED STATUS-3270 MESSAGE-MISSED SYSTEM NETWORK TIME-SIGNAL NEWPROCESS-COMPLETION HP COBOL Manual for TNS and TNS/R Programs —522555-006 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 RECORD DATA 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-name ACCEPT 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 CANCEL program-name OF file-mnemonic IN identifier VST136.
Procedure Division CHECKPOINT CHECKPOINT Note. • • Do not use this statement in the OSS environment. Before RVU D46.00 and G06.00, software product revision T8107AAT (run-time library T8108AAR), the NMCOBOL compiler ignores this directive and issues a warning. CHECKPOINT data-name-1 FILE data-name-2 file-name FILE QUEUE checkpoint-list-name VST137.vsd CLOSE for Sequential and Line Sequential Files CLOSE file-name file-info VST138.
Procedure Division CLOSE for Relative, Indexed, and Queue Files CLOSE for Relative, Indexed, and Queue Files file-name CLOSE WITH LOCK VST140.vsd 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.
Procedure Division COPY COPY COPY . text-name OF library-name IN REPLACING phrase VST244.vsd 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.
Procedure Division COPY pseudo-text-1 == == text-word VST250.vsd new pseudo-text-2 identifier-2 literal-2 word-2 VST249.vsd 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.
Procedure Division DELETE DELETE DELETE file-name RECORD imperative-stmt-1 INVALID KEY NOT imperative-stmt-2 INVALID KEY END-DELETE VST143.vsd DISPLAY DISPLAY identifier literal UPON mnemonic-name NO ADVANCING WITH VST144.
Procedure Division DIVIDE INTO 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 file-mnemonic OF 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 TIME PROMPT 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 NMCOBOL compiler.
Procedure Division STARTBACKUP STARTBACKUP Note. • • Do not use this statement in the OSS environment. Before RVU D46.00 and G06.00, software product revision T8107AAT (run-time library T8108AAR), the NMCOBOL compiler ignores this directive and issues a warning. 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.
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 GIVING FROM subtrahend 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, so you are advised not to use it, even in TNS HP COBOL programs. The NMCOBOL compiler does not recognize it. USE DEBUGGING FOR ON ALL REFERENCES OF . name filename procedure ALL PROCEDURES VST234.
Procedure Division USE AFTER EXCEPTION USE AFTER EXCEPTION Note. If you are using the NMCOBOL compiler, do not use GLOBAL in a USE AFTER EXCEPTION statement in the declaratives-portion. USE AFTER GLOBAL EXCEPTION STANDARD PROCEDURE ERROR ON file-name . INPUT OUTPUT I-O EXTEND VST235.vsd 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.
Procedure Division WRITE for Sequential Files 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.vsd 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.
Procedure Division WRITE for Line Sequential Files WRITE for Line Sequential Files WRITE record-name FROM END-WRITE from-name VST631.vsd 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.
Procedure Division WRITE for Relative, Indexed, and Queue Files HP COBOL Manual for TNS and TNS/R Programs —522555-006 43 -60
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 and TNS/R Programs —522555-006 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 Note. This function requires the CRE. To use this function in a TNS HP COBOL program, compile the program with the directive ENV COMMON. ANNUITY FUNCTION ( ANNUITY interest-rate number-of-periods ) VST422.vsd Note. This function requires the CRE.
Intrinsic Function Calls ASIN ASIN FUNCTION ( ASIN ) argument VST423.vsd Note. This function requires the CRE. To use this function in a TNS HP COBOL program, compile the program with the directive ENV COMMON. ATAN FUNCTION ( ATAN ) argument VST424.vsd Note. This function requires the CRE. To use this function in a TNS HP COBOL program, compile the program with the directive ENV COMMON. CHAR FUNCTION ( CHAR ) argument VST425.vsd COS FUNCTION COS ( argument ) VST426.vsd Note.
Intrinsic Function Calls DATE-OF-INTEGER DATE-OF-INTEGER FUNCTION ( DATE-OF-INTEGER ) argument VST428.vsd DAY-OF-INTEGER FUNCTION ( DAY-OF-INTEGER ) argument VST429.vsd 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.
Intrinsic Function Calls INTEGER-PART INTEGER-PART FUNCTION ( INTEGER-PART ) argument VST434.vsd LENGTH FUNCTION ( LENGTH ) argument VST435.vsd LOG FUNCTION LOG ( ) argument VST436.vsd LOG10 FUNCTION ( LOG10 ) argument VST437.vsd Note. This function requires the CRE. To use this function in a TNS HP COBOL program, compile the program with the directive ENV COMMON. LOWER-CASE FUNCTION LOWER-CASE ( string ) VST438.vsd MAX FUNCTION MAX ( argument ) VST439.
Intrinsic Function Calls MEAN MEAN FUNCTION ( MEAN ) argument VST440.vsd MEDIAN FUNCTION ( MEDIAN ) argument VST441.vsd 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 Note. This function requires the CRE. To use this function in a TNS HP COBOL program, compile the program with the directive ENV COMMON. SQRT FUNCTION SQRT ( argument ) VST461.
Intrinsic Function Calls STANDARD-DEVIATION STANDARD-DEVIATION FUNCTION ( STANDARD-DEVIATION argument ) VST462.vsd Note. This function requires the CRE. To use this function in a TNS HP COBOL program, compile the program with the directive ENV COMMON. SUM FUNCTION ( SUM ) argument VST463.vsd TAN FUNCTION TAN ( argument ) VST464.vsd Note. This function requires the CRE. To use this function in a TNS HP COBOL program, compile the program with the directive ENV COMMON.
Intrinsic Function Calls WHEN-COMPILED WHEN-COMPILED FUNCTION WHEN-COMPILED VST467.
45 CBL85UTL and ZCOBSRL Routine Calls Table 45-1.
CBL85UTL and ZCOBSRL Routine Calls • • • • • COBOL85^ARMTRAP COBOL85^SET^SORT^PARAM^TEXT and COBOL_SET_SORT_PARAM_TEXT_ COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ COBOL_SET_MAX_RECORD_ COBOL_SETMODE_ COBOL85^SPECIAL^OPEN and COBOL_SPECIAL_OPEN_ COBOL85^ARMTRAP ns ENTER ns COBOL85^ARMTRAP " " VST341.
CBL85UTL and ZCOBSRL Routine Calls COBOL_COMPLETION_ COBOL_COMPLETION_ ns ENTER ns COBOL_COMPLETION_ " " TAL OF library-reference USING abend-or-stop completion-code termination-info subsys-id text VST343.vsd 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.
CBL85UTL and ZCOBSRL Routine Calls COBOL_GETENV_ COBOL_GETENV_ ns ENTER ns COBOL_GETENV_ " USING env-var GIVING length " return-value VST722.vsd COBOL_PUTENV_ " ENTER ns COBOL_PUTENV_ USING env-var GIVING return-value ns " VST723.vsd COBOL85^RETURN^SORT^ERRORS and COBOL_RETURN_SORT_ERRORS_ " ENTER ns COBOL85^RETURN^SORT^ERRORS ns " COBOL_RETURN_SORT_ERRORS_ OF library-reference USING sd-name error-report GIVING return-code VST344.
CBL85UTL and ZCOBSRL Routine Calls COBOL85^REWIND^SEQUENTIAL and COBOL_REWIND_SEQUENTIAL_ COBOL85^REWIND^SEQUENTIAL and COBOL_REWIND_SEQUENTIAL_ ENTER " ns COBOL85^REWIND^SEQUENTIAL ns " COBOL_REWIND_SEQUENTIAL_ OF library-reference USING file-name GIVING return-code VST345.
CBL85UTL and ZCOBSRL Routine Calls COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ ns " ENTER COBOL85^SET^SORT^PARAM^VALUE ns " COBOL_SET_SORT_PARAM_VALUE_ OF library-reference USING sd-name param-id param-value GIVING subsort-or-file-number return-code VST347.vsd Note. COBOL85 only: COBOL85^SET^SORT^PARAM^VALUE and COBOL_SET_SORT_PARAM_VALUE_ use a protocol different from that used for normal TAL procedures.
CBL85UTL and ZCOBSRL Routine Calls COBOL_SETMODE_ 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. ENTER " OF ns COBOL_SETMODE_ ns " library-reference USING file-name function param-1 param-2 lastparams cpinfo GIVING error-return VST611.
CBL85UTL and ZCOBSRL Routine Calls For Spoolers and Printers For Spoolers and Printers ENTER ns " COBOL85^SPECIAL^OPEN ns " COBOL_SPECIAL_OPEN_ OF 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 VST348.
CBL85UTL and ZCOBSRL Routine Calls For System Log Files For System Log Files ENTER " ns COBOL85^SPECIAL^OPEN ns " COBOL_SPECIAL_OPEN_ OF library-reference USING file-name open-type = 2 exclusion sync-depth GIVING time-limits return-code VST349.vsd For Partitioned Disk Files ENTER " ns COBOL85^SPECIAL^OPEN ns " COBOL_SPECIAL_OPEN_ OF library-reference USING file-name open-type = 3 exclusion sync-depth open-mode GIVING time-limits return-code VST350.
CBL85UTL and ZCOBSRL Routine Calls For Tape Files in the CRE For Tape Files in the CRE 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 COBOLLIB, CLULIB, and ZCRESRL Routine Calls • • SMU Routines Non-SMU Routines Note. If you omit an optional parameter when you call a COBOLLIB 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.) SMU Routines Programs compiled with the COBOL85 compiler can call all of the SMU routines listed in Table 46-1.
COBOLLIB, CLULIB, and ZCRESRL Routine Calls SMU Routines Table 46-1. Saved Message Utility (SMU) Routines (page 2 of 2) Original Routine1 New Routine2 PUTASSIGNVALUE SMU_Assign_PutValue_ PUTPARAMTEXT4 SMU_Param_PutText_ PUTSTARTUPTEXT SMU_Startup_PutText_ 1. In the COBOLLIB file. Extension to the HP COBOL and FORTRAN 77 products, except as noted. 2. In the CLULIB file for the COBOL85 compiler and the ZCRESRL file for the NMCOBOL compiler. 3.
COBOLLIB, CLULIB, and ZCRESRL Routine Calls ALTERPARAMTEXT ALTERPARAMTEXT ns ENTER OF ns ALTERPARAMTEXT " " library-reference USING portion GIVING result text cplist size VST351.vsd Note. ALTERPARAMTEXT uses a protocol different from that used for normal TAL procedures. The ENTER verb must not be followed by the keyword TAL. CHECKLOGICALNAME " ENTER OF ns ns CHECKLOGICALNAME " library-reference USING logical-name GIVING result VST352.vsd logical-name file-name program-unit .
COBOLLIB, CLULIB, and ZCRESRL Routine Calls CHECKMESSAGE CHECKMESSAGE ns ENTER " ns CHECKMESSAGE " TAL OF library-reference USING message-number GIVING result VST353.vsd DELETEASSIGN ns ENTER " OF ns DELETEASSIGN " library-reference USING portion GIVING result cplist message-number VST360.vsd Note. DELETEASSIGN uses a protocol different from that used for normal TAL procedures. The ENTER verb must not be followed by the keyword TAL.
COBOLLIB, CLULIB, and ZCRESRL Routine Calls DELETEPARAM DELETEPARAM ns ENTER OF ns DELETEPARAM " " library-reference USING portion GIVING result cplist VST361.vsd Note. DELETEPARAM uses a protocol different from that used for normal TAL procedures. The ENTER verb must not be followed by the keyword TAL. DELETESTARTUP ns ENTER " OF ns DELETESTARTUP " library-reference USING portion GIVING result cplist VST362.vsd Note.
COBOLLIB, CLULIB, and ZCRESRL Routine Calls GETASSIGNTEXT GETASSIGNTEXT ns ENTER OF ns GETASSIGNTEXT " " library-reference USING portion GIVING result text message-number VST363.vsd Note. GETASSIGNTEXT uses a protocol different from that used for normal TAL procedures. The ENTER verb must not be followed by the keyword TAL. GETASSIGNVALUE ns ENTER " OF ns GETASSIGNVALUE " library-reference USING portion GIVING result val message-number VST364.vsd Note.
COBOLLIB, CLULIB, and ZCRESRL Routine Calls GETBACKUPCPU GETBACKUPCPU ns ENTER " ns GETBACKUPCPU " TAL OF library-reference GIVING result VST365.vsd GETPARAMTEXT ns ENTER " OF ns GETPARAMTEXT " library-reference USING portion GIVING result text VST366.vsd Note. GETPARAMTEXT uses a protocol different from that used for normal TAL procedures. The ENTER verb must not be followed by the keyword TAL.
COBOLLIB, CLULIB, and ZCRESRL Routine Calls GETSTARTUPTEXT GETSTARTUPTEXT ns ENTER OF ns GETSTARTUPTEXT " " library-reference USING portion GIVING result text VST367.vsd Note. The ENTER verb must not be followed by the keyword TAL, because GETSTARTUPTEXT uses a protocol different from that of normal TAL procedures. PUTASSIGNTEXT ns ENTER OF ns PUTASSIGNTEXT " " library-reference USING portion text cplist message-number GIVING result VST368.vsd Note.
COBOLLIB, CLULIB, and ZCRESRL Routine Calls PUTASSIGNVALUE PUTASSIGNVALUE ns ENTER OF ns PUTASSIGNVALUE " " library-reference USING portion val cplist message-number GIVING result VST369.vsd Note. PUTASSIGNVALUE uses a protocol different from that used for normal TAL procedures. The ENTER verb must not be followed by the keyword TAL. PUTPARAMTEXT ns ENTER " OF ns PUTPARAMTEXT " library-reference USING portion GIVING result text cplist VST370.vsd Note.
COBOLLIB, CLULIB, and ZCRESRL Routine Calls PUTSTARTUPTEXT PUTSTARTUPTEXT ns " ENTER OF ns PUTSTARTUPTEXT " library-reference USING portion GIVING result text cplist VST371.vsd Note. PUTSTARTUPTEXT uses a protocol different from that used for normal TAL procedures. The ENTER verb must not be followed by the keyword TAL. Non-SMU Routines Programs compiled with the COBOL85 compiler can call all of the SMU routines listed in Table 46-2.
COBOLLIB, CLULIB, and ZCRESRL Routine Calls • • COBOLASSIGN COBOLSPOOLOPEN CREATEPROCESS COBOLASSIGN ns ENTER OF ns COBOLASSIGN " " library-reference USING fd-name GIVING error-number system-file-name VST354.vsd Note. COBOLASSIGN uses a protocol different from that used by normal TAL procedures. The ENTER verb must not be followed by the keyword TAL.
COBOLLIB, CLULIB, and ZCRESRL Routine Calls COBOLFILEINFO COBOLFILEINFO ns ENTER " ns COBOLFILEINFO " TAL OF library-reference USING fd-name error-code file-name file-number VST357.vsd COBOL_FILE_INFO_ ENTER " COBOL_FILE_INFO_ " TAL OF library-reference USING file-name name-buffer name-size file-number error VST636.
COBOLLIB, CLULIB, and ZCRESRL Routine Calls COBOLSPOOLOPEN COBOLSPOOLOPEN ENTER COBOLSPOOLOPEN " " TAL OF library-reference USING fd-name «file-status» location form-name report-name copies page-size flags exclusion sync-depth owner level-3 GIVING error-code VST358.
COBOLLIB, CLULIB, and ZCRESRL Routine Calls CREATEPROCESS CREATEPROCESS ns ENTER " OF CREATEPROCESS ns " library-reference USING program-file process-name option priority processor memory process-id GIVING result VST359.
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 Warning Message Format Warning Message Format For the COBOL85 compiler, a warning message has this format: ** Warning message-number ** message-text For the NMCOBOL compiler, a warning message has this format: *** Warning: --> message-text [Warning message-number] The brackets are part of the message, not indicators that the bracketed material is optional.
Compiler Diagnostic Messages Message List Message List Messages are listed in numeric order by message number, with message type (warning, error, or failure) noted. 0 (Failure) Compiler logic error Cause. The compiler’s internal consistency checks found a logic error. Please report this failure to your service provider. 1 (Failure) CREATE failure on work file (file-name): ddd Cause. The compiler cannot create one of its work files. file-name is the external form of the file name.
Compiler Diagnostic Messages • • • • • • Message List The file file-name is specified as the source file, but its attributes are inappropriate for a source file (usually because the device type does support read operations). The file file-name is specified as a SEARCH file, but it is not a code 700 object file. The file file-name is specified as a SEARCH file, but it was not created by a compilation with symbols specified.
Compiler Diagnostic Messages Message List 7 (Failure) WRITE failure on xxxx file (file-name): ddd Cause. The compiler cannot write a record to the file named file-name. xxxx is the type of compiler file (list or work). file-name is the external form of the file name. ddd is the file management error code that the operating environment returned. 8 (Failure) I/O failure on xxxx file (file-name): ddd Cause. The compiler cannot perform a miscellaneous input-output operation on the file named file-name.
Compiler Diagnostic Messages Message List 12 (Failure) Improper context for source text directive Cause. One of: • • The reserved word COPY appears where it is not expected (for example, within COPY library text). The reserved word REPLACE appears where it is not expected (for example, within source text produced by the editing activities of a REPLACE statement). 13 (Failure) Expected IDENTIFICATION Cause. The source program does not begin with an Identification Division header.
Compiler Diagnostic Messages Message List If PARAM SYMBOL-BLOCKS does not solve the problem, and the program uses COPY, REPLACE, or both COPY and REPLACE: • • • • Reduce the size of the pseudotext or literal in the REPLACE statement or REPLACING phrase. Use REPLACE OFF when replacement is no longer needed. Reduce the number of contiguous comment lines that can be read while COPY LIBRARY or REPLACE is active. Avoid having COPY and REPLACE active at the same time. 16 (Failure) Too many errors Cause.
Compiler Diagnostic Messages Message List 20 (Failure) Assigned CPU is not licensed for this compiler Cause. The processor in which the compiler is to run is not licensed for this compiler’s execution. 21 (Failure) SOURCE nesting too deep Cause. The compiler ran out of storage space because the nesting of SOURCE directives summoning text that includes other SOURCE directives is too deep. 25 (Warning) Blank continuation line Cause.
Compiler Diagnostic Messages Message List 28 (Error) Text not permitted here Cause. One of: • • • • A division header is followed by other text on the same source line. A section header is followed by other text on the same source line (other than a USE statement). The DECLARATIVES or END DECLARATIVES header is followed by other text on the same source line. A compiler directive that must be the last one on its line is followed by other text on the same directive line.
Compiler Diagnostic Messages Message List 33 (Error) Numeric literal exceeds 18 digits Cause. A numeric literal contains more than 18 digits. 34 (Error) Word exceeds 30 characters Cause. A COBOL word contains more than 30 characters. 35 (Error) Word ends with '-' Cause. The last character of the indicated COBOL word is a hyphen. 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.
Compiler Diagnostic Messages Message List 39 (Warning, Error or Failure) Improper actual file name Cause. Warning: The run unit file name (object file name) field in the command that called the compiler has improper punctuation or its content does not have the form of a disk file name. The compiler supplies RUNUNIT (with appropriate default volume and subvolume components) as the run unit file name.
Compiler Diagnostic Messages Message List 43 (Error) Syntax error - deleting unexpected token xxxx Cause. The compiler found a syntax error at the token xxxx (a character-string or a separator) and recovered by deleting that token. The problem could have been a misspelled optional reserved word or an extraneous separator. Deleting the token is probably just one of several possible corrections. You must determine the proper correction through careful examination of the text.
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 61 (Warning) Logic may differ from COBOL85 - move alphanumeric to numeric with invalid data Cause. The NMCOBOL compiler’s interpretation of the source program might differ from the COBOL85 compiler’s interpretation. See DIAGNOSE-85 and NODIAGNOSE85. You must determine what effects the NMCOBOL interpretation has on the program’s execution logic, decide if those effects are desired, and then revise the source program if needed.
Compiler Diagnostic Messages Message List 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. The expected range can be absolute (for example, many literals cannot exceed 32,767) or relative (for example, the FOOTING value in a LINAGE clause cannot exceed the number of lines in the page body).
Compiler Diagnostic Messages Message List 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. 72 (Error) Expected section-name Cause. One of: • • • The section-name parameter is missing from a SECTION directive. The text-name specified in a COPY statement is not a section-name in the COPY library. A section-name specified in a SOURCE directive is not in the source library.
Compiler Diagnostic Messages • Message List An ENTER statement specifies fewer parameters in its USING phrase than the routine expects, and the routine is not defined as EXTENSIBLE or VARIABLE (COBOL85 compiler only). 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. 77 (Error) Duplicate clause Cause.
Compiler Diagnostic Messages Message List 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. One of: • • • A file has more than 31 alternate record keys. An OCCURS clause has more than 31 key references. A SORT or MERGE statement has more than 31 keys.
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).
Compiler Diagnostic Messages Message List 124 (Error) Not permitted within this section Cause. One of: • • • • • A level-77 data item is defined in the File Section. A level-01 data item defined in the File Section is described with the REDEFINES clause. The EXTERNAL clause for a data description entry is not within the WorkingStorage Section or Extended-Storage Section. The GLOBAL clause appears in descriptions that are not within the File Section, Working-Storage Section, or Extended-Storage Section.
Compiler Diagnostic Messages Message List 128 (Error) FILLER not permitted for 01 level external data item Cause. A record data item that has no name, or is a FILLER data name, is either described with the EXTERNAL clause or is subordinate to a file description entry that includes the EXTERNAL clause. 129 (Error) FILLER not permitted for 01 level global data-name Cause.
Compiler Diagnostic Messages Message List 133 (Error) Redefined and redefinition data items not subordinate to same levels Cause. A redefined data item is a subordinate of a file description entry and/or one or more data structure description entries, but the redefinition item is not a subordinate of these entries. 134 (Error) Redefined data item is a redefinition Cause. The program tried to redefine a data item that was described with a REDEFINES clause.
Compiler Diagnostic Messages Message List 139 (Error) Picture string exceeds 30 characters Cause. A PICTURE character-string has more than 30 characters. 140 (Error) Improper picture string Cause. The PICTURE character-string does not conform to the rules of the COBOL language, possibly for one of these reasons: • • • • The characters are undefined in this context. The characters are combined improperly. The character-string has unmatched parentheses.
Compiler Diagnostic Messages Message List 145 (Error) Specified usage permitted only for numeric data item Cause. Only a numeric data item can be described with the specified usage. 146 (Error) Display usage required in group with value or condition-names Cause. A data item that is either subordinate to a data structure described with a VALUE clause or associated with condition-names does not have USAGE DISPLAY, as it must. 147 (Error) Display usage required when SIGN clause applies Cause.
Compiler Diagnostic Messages Message List 150 (Error) JUSTIFIED clause requires display usage Cause. A data item is described with a JUSTIFIED clause, but the data item does not have USAGE DISPLAY, as it must. 151 (Error) JUSTIFIED clause not permitted for numeric or edited data item Cause. A numeric, numeric-edited, or alphanumeric-edited data item is described with a JUSTIFIED clause. 152 (Error) JUSTIFIED clause not permitted in group with value or condition-names Cause.
Compiler Diagnostic Messages Message List 156 (Error) Access mode conflict for redefinition or subordinate Cause. One of: • • A data item that is part or all of a redefinition is described with an ACCESS MODE clause specifying a different mode than the data item it redefines. A data item that is subordinate to a data structure described with an ACCESS MODE clause is described with an ACCESS MODE clause specifying a different mode. 157 (Error) VALUE clause not permitted for index data item Cause.
Compiler Diagnostic Messages Message List 162 (Error) Value range not permitted for initial value Cause. The VALUE clause describing a data item contains a range of literals. 163 (Error) Only one initial value permitted Cause. The VALUE clause describing a data item contains more than one value. 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.
Compiler Diagnostic Messages Message List 169 (Error) Renaming not permitted for 66 level data item Cause. The RENAMES clause references a 66-level item. 170 (Error) Renamed data item in table or has variable size Cause. The RENAMES clause references a table item, a subordinate of a table item, or a data structure that has a variable size. 171 (Error) Improper range for renamed data items Cause.
Compiler Diagnostic Messages Message List 175 (Error) Elementary data item clause specified for group data item Cause. The description of a data structure includes a BLANK WHEN ZERO, JUSTIFIED, SYNCHRONIZED, or PICTURE clause. 176 (Warning) Group with SIGN clause has no signed numeric subordinate item Cause. A data structure described with a SIGN clause has no signed numeric subordinate data items. 177 (Error) Data item attributes not compatible with CODE-SET clause Cause.
Compiler Diagnostic Messages Message List 181 (Error) Key object not data item subordinate to its table Cause. A reference in the KEY phrase of an OCCURS clause identifies neither the table item nor a data item defined in the table item that the clause describes. 182 (Error) Key data item within subordinate table Cause. A table key data item is defined in, or as, a subordinate table item. 183 (Error) Table item permitted only as first key data item Cause.
Compiler Diagnostic Messages Message List 187 (Error) Signed literal not permitted for unsigned numeric data item Cause. The VALUE clause describing an unsigned numeric data item or a conditionname associated with an unsigned numeric data item contains a signed numeric literal. 188 (Error) Numeric literal value inconsistent with numeric data item Cause.
Compiler Diagnostic Messages Message List 193 (Error) LINAGE permitted only for sequential organization with no record keys Cause. One of: • • A file description entry includes the LINAGE clause, but the file organization is not sequential. A file description entry includes both the LINAGE clause and ALTERNATE RECORD KEY clauses. 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.
Compiler Diagnostic Messages Message List 198 (Warning) Record-names inconsistent with file description entry Cause. At least one reference in the DATA RECORDS clause does not identify any record-name defined by the record description entries. 199 (Error) Record sizes inconsistent with file description entry Cause. A record description entry describes a record longer or shorter than the maximum or minimum specified in the RECORD clause. 200 (Error) Record size exceeds block size Cause.
Compiler Diagnostic Messages Message List 204 (Error) Record key not simple fixed-size alphanumeric item Cause. The object referenced in a FILE STATUS clause either is not a fixed-size alphanumeric data item or is a table. 205 (Error) Record key aligned with another record key Cause. The first character position of one record key coincides with the first character position of another record key. 206 (Error) Missing file description entry for file name Cause.
Compiler Diagnostic Messages Message List 210 (Error) Padding item in improper section Cause. The padding data item for a file is not defined in the Working-Storage, Extended-Storage, or Linkage Section. 211 (Error) Relative key item not found Cause. The RELATIVE KEY clause references an undefined name. 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.
Compiler Diagnostic Messages Message List 216 (Error) File status item not simple two character alphanumeric Cause. The FILE STATUS clause references either an object that is not a fixed-size two-character alphanumeric data item or an object that is a table or special register. 218 (Error) File status in improper section Cause. The FILE STATUS clause references a data item that is defined in the File Section. 219 (Error) Linage control item not found Cause.
Compiler Diagnostic Messages Message List 223 (Error) Depending item not simple unsigned integer Cause. The DEPENDING phrase of a RECORD clause references either an object that is not an unsigned integer data item or an object that is a table or special register. 224 (Error) Depending item not simple integer Cause. The DEPENDING phrase of a OCCURS clause references either an object that is not an integer data item or an object that is a table or special register.
Compiler Diagnostic Messages Message List 229 (Error) Message source item not found Cause. The MESSAGE SOURCE references an undefined name. 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.
Compiler Diagnostic Messages Message List Error: One of: • • The maximum value assignable to the POINTER operand in a STRING statement is less than or equal to the size of the receiving operand. The maximum value assignable to the POINTER operand in an UNSTRING statement is less than or equal to the size of the sending operand. 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.
Compiler Diagnostic Messages Message List 241 (Error) USING operand subordinate or redefinition data-name Cause. The USING phrase specifies an operand about which one of these is true: • • It is not described as a level 01 or level 77 data-name. It is described as a redefinition of another data-name. 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.
Compiler Diagnostic Messages Message List 247 (Error) Improper context for USE sentence Cause. The USE sentence does not immediately follow a section header in the Declaratives Portion of the Procedure Division, as it must. 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.
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 363 (Error) Improper language name Cause. For the COBOL85 compiler, the language in an ENTER statement must be C, FORTRAN, Pascal, or TAL. For the NMCOBOL compiler, it must be C or TAL. 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.
Compiler Diagnostic Messages Message List 368 (Error—COBOL85 compiler only) Compiler version attribute conflict Cause. One of: • • The requested program was compiled by an incompatible version of the compiler. (Recompile it with the current version of the compiler.) The requested program was compiled to run in a language-specific environment when it must run in the CRE. Recompile it to run in the CRE. 369 (Warning) NONSTOP attribute conflict Cause.
Compiler Diagnostic Messages Message List 372 (Error) COBOL85 Compiler: Formal parameter for file name must have word address NMCOBOL Compiler: 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 2-byte address (for the COBOL85 compiler) or a struct (for the NMCOBOL compiler).
Compiler Diagnostic Messages Message List 376 (Error) Routine type not supported Cause. The routine returns a value of a type that HP COBOL does not support; therefore, it cannot have a GIVING phrase. 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.
Compiler Diagnostic Messages Message List 381 (Error) PROMPT/LOCK phrase cannot be specified with REVERSED Cause. A READ statement with a REVERSED phrase also has a PROMPT or LOCKED phrase. 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 Error: An ALTER statement appearing in one independent segment modifies a GO TO statement of a paragraph or section in another independent segment. 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.
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. The COBOL85 compiler issues this warning only once: at the end of the compiler listing, followed by the names of all the program units that it could not find.
Compiler Diagnostic Messages Message List 395 (Error) More than one implicit MAIN program Cause. Both the current COBOL program and a preceding one qualify for the MAIN attribute. Because the compiler cannot determine which one should be the main program, it does not produce an object file. 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 theInspect debugger. The compiler sends only the first value.
Compiler Diagnostic Messages Message List 400 (Error) Program code exceeds 65500 words Cause. The object code generated for a separately compiled program exceeds 131 KB, which is the maximum size supported. Recovery. Recompile the program without the CHECK directive and with the NOBLANK and LESS-CODE 1 directives. If error 400 still occurs, change the source program: • • • • Remove unused code. Break the program into two or more compilation units (see Compilation Units).
Compiler Diagnostic Messages Message List 404 (Warning) Size error on literal expression Cause. The compiler has determined that this expression, composed solely of literal operands, will always generate the size error condition during execution.
Compiler Diagnostic Messages Message List 425 (Error) Usage clause not permitted with specified picture Cause. A national data item contains a USAGE clause. 426 (Error) Synchronized clause not permitted with specified picture Cause. A national data item contains a SYNCHRONIZED clause. 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.
Compiler Diagnostic Messages Message List 441 (Error) External data item not allowed in library object Cause. A program in a user library references an external data item. 442 (Error) Library object cannot contain a main program Cause. A main program is in a user library. 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.
Compiler Diagnostic Messages Message List 448 (Error) EXTENDED-STORAGE not allowed in library object Cause. A program with an EXTENDED-STORAGE section is in a user library. 449 (Error) Parameter not allowed in old environment object Cause. An object file that was produced for the non-CRE environment (that is, the corresponding source program was compiled with the directive ENV OLD) contains a parameter that is not allowed in the non-CRE environment.
Compiler Diagnostic Messages Message List 464 (Error) Improper category for host variable Cause. An SQL/MP or SQL/MX host variable is in the wrong category. 465 (Error) Host variable's picture string cannot contain '*' Cause. An SQL/MP or SQL/MX host variable’s PICTURE string contains an asterisk (*). 466 (Error) JUSTIFIED clause not allowed for host variables Cause. An SQL/MP or SQL/MX host variable contains a JUSTIFIED clause. 467 (Error) OCCURS clause not allowed for host variables Cause.
Compiler Diagnostic Messages Message List 472 (Error) SQLCA is declared incorrectly Cause. SQLCA is declared incorrectly (it must be a data structure). 473 (Error) Ambiguous reference to SQLCODEX Cause. More than one SQLCODEX is declared in the program, and the SQLCODEX in this statement is ambiguous in this context. 474 (Error) SQLCODEX is declared incorrectly Cause. SQLCODEX is declared incorrectly (it must be a COMPUTATIONAL data item with no editing characters).
Compiler Diagnostic Messages Message List 478 (Error) Ambiguous reference to SQLSA Cause. More than one SQLSA is declared in the program, and the SQLSA in this statement is ambiguous in this context. 479 (Error) SQLSA is declared incorrectly Cause. SQLSA is declared incorrectly (it must be a COMPUTATIONAL data item with no editing characters). 480 (Error) Improper context for INCLUDE Cause. An SQL/MP or SQL/MX INCLUDE statement is outside of the Data Division. (It must be inside.
Compiler Diagnostic Messages Message List 491 (Error) Function nesting too deep Cause. Functions are nested so deeply within a single statement that the compiler cannot process them. 492 (Error) Subscripting not allowed on a function Cause. A subscript appears on a function. (A subscript can only appear on a table.) 493 (Error) Improper context for function Cause. An intrinsic function appears where it is not allowed (as a receiving item in a statement, for example). 494 (Error) Unknown function Cause.
Compiler Diagnostic Messages Message List 498 (Error) Argument not within expected range Cause. The literal being used as an argument to the function is outside the range allowed for that argument. 499 (Error) Too few arguments Cause. The function requires more arguments than have been supplied. 500 (Error) Expecting nonnumeric item Cause. A nonnumeric argument was supplied where a numeric argument is required. 501 (Error) This function is not allowed in old environment Cause.
Compiler Diagnostic Messages Message List 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. An EXIT PERFORM or EXIT PERFORM CYCLE statement appears in a context other than within an inline PERFORM statement. 511 (Error) Expected key-word CYCLE or other verb Cause.
Compiler Diagnostic Messages Message List 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. A data structure that could start on an odd byte was passed as a parameter to a CALL statement.
Compiler Diagnostic Messages Message List 526 (Error) This phrase is not permitted for LINE SEQUENTIAL files Cause.
Compiler Diagnostic Messages Message List 600 (Warning) Defunct directive ignored Cause. The NMCOBOL compiler ignores this directive. 601 (Warning) Feature not yet available -- directive ignored Cause. The NMCOBOL compiler ignores this directive. 602 (Error) No symbols for external name Cause. A CALL or ENTER statement calls a program for which the object file contains a name but not a symbol.
Compiler Diagnostic Messages Message List 606 (Warning) ACCESS MODE STANDARD is ignored for a non-parameter data item in the linkage section Cause. ACCESS MODE STANDARD is specified for a data item described in the Linkage Section, and the data item is not referenced in the USING phrase of the PROCEDURE DIVISION header. Delete the ACCESS MODE phrase. 607 (Error) Numeric hexadecimal literal exceeds 16 hex digits Cause. A hexadecimal literal has more than 64 bits (16 hexadecimal digits).
Compiler Diagnostic Messages Other Products’ Error Messages 613 (Warning) Directives: directive-1;directive-2 Duplicate setting, previous setting ignored Cause. The compilation unit contains incompatible directives; for example, CALLSHARED and NON-SHARED. Other Products’ Error Messages Products that are merged with the compiler sometimes cause compile-time error messages when you run the compiled program.
Compiler Diagnostic Messages HP COBOL Manual for TNS and TNS/R Programs —522555-006 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—Non-CRE Environment Standard Message Format—Non-CRE Environment In the non-CRE environment, the standard format of a run-time diagnostic message is: pn pn [ pn pn [ pn [ pn - *** COBOL85 Library Error nnn *** From prog-id + %pppppp prog-id + %pppppp ] ... message additional-message ] ... File COBOL-file-name, assigned-file-name: open-status ] [ ] surrounds optional material.
Run-Time Diagnostic Messages Standard Message Format—Non-CRE Environment COBOL-file-name applies only to I-O errors and is the name of the file in error (the file-name in the SELECT clause). assigned-file-name is the file system name of the file assigned to COBOL-file-name. open-status is an open mode (INPUT, OUTPUT, I-O, EXTEND or CLOSED). Example 48-1. Standard Run-Time Diagnostic Message (Non-CRE Environment) \HQSYS4.02,038 \HQSYS4.02,038 \HQSYS4.02,038 \HQSYS4.02,038 \HQSYS4.02,038 \HQSYS4.
Run-Time Diagnostic Messages Standard Message Format—Non-CRE Environment The last line (from the operating environment, not from COBOL85) reports that the process terminated abnormally. Note. In the non-CRE environment, if the executing program delivers a message of this form, the file containing the run-time diagnostic message texts is not available. Report this to the appropriate system support personnel. \SHEM.13,012 \SHEM.13,012 \SHEM.13,012 \SHEM.
Run-Time Diagnostic Messages Standard Message Format—CRE Standard Message Format—CRE In the CRE, 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.
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-2. Input-Output Error Message (Non-CRE Environment) \BEANS.11,047 \BEANS.11,047 \BEANS.11,047 \BEANS.11,047 \BEANS.11,047 \BEANS.11,047 \BEANS.
Run-Time Diagnostic Messages Guardian Abnormal Termination Messages Guardian Abnormal Termination Messages A Guardian abnormal termination message results from circumstances that cause the Guardian environment to terminate the execution of a run unit. The operating environment delivers its own message—the Guardian abnormal termination message—after (or instead of) delivering a COBOL run-time diagnostic message.
Run-Time Diagnostic Messages Arithmetic Overflow Arithmetic Overflow Arithmetic overflow means that an arithmetic operation resulted in an arithmetic overflow. Typical causes include: • • • • • Invalid data is associated with an item, such as an uninitialized USAGE COMPUTATIONAL or index item. A receiving item in an arithmetic statement is too small. An intermediate result in a COMPUTE statement exceeds the 36-digit maximum.
Run-Time Diagnostic Messages Stack Overflow Stack Overflow Stack overflow means that the control and data stack has overflowed. TNS Programs In a TNS program, the most common cause is a shortage of data space in the user data area. To determine whether this is the case, you need a data map of the run unit. For a TNS program, you can use the BIND command LIST LOC FROM fname to create a data map for file fname. Examine the data block map to find the last address less than 100000 octal.
Run-Time Diagnostic Messages • How to Use the Message List Remove the INITIAL phrase from the program header and explicitly cancel the program after every call to it (see CANCEL). How to Use the Message List This topic lists and explains all the run-time diagnostic messages that can be reported for an HP COBOL program that either runs in the non-CRE environment or runs in the CRE but does not call any non-COBOL routines.
Run-Time Diagnostic Messages How to Use the Message List When corresponding CRE and COBOL messages have different texts, they are listed this way: CRE Number CRE message text (COBOL85 Number) COBOL message text Cause. Cause of the error. Effect. What the run-time routines did. Recovery. Suggestions for recovering from the error or preventing its recurrence. Table 48-1. COBOL Message Mapping (page 1 of 5) Msg. No.
Run-Time Diagnostic Messages How to Use the Message List Table 48-1. COBOL Message Mapping (page 2 of 5) Msg. No.
Run-Time Diagnostic Messages How to Use the Message List Table 48-1. COBOL Message Mapping (page 3 of 5) Msg. No.
Run-Time Diagnostic Messages How to Use the Message List Table 48-1. COBOL Message Mapping (page 4 of 5) Msg. No.
Run-Time Diagnostic Messages Message List Table 48-1. COBOL Message Mapping (page 5 of 5) Msg. No.
Run-Time Diagnostic Messages Message List 2 Illegal address reference (121) A hardware/software trap occurred - the type follows Illegal address reference Cause. An address was specified that was not within either the virtual code area or the virtual data area allocated to the process. In most cases, a subscript or reference modifier was out of bounds. Effect. The run unit terminates abnormally. Recovery. Try recompiling with the CHECK 3 directive.
Run-Time Diagnostic Messages Message List 4 Arithmetic fault (121) A hardware/software trap occurred - the type follows Arithmetic fault Cause. For a TNS program, the overflow bit in the environment-register, ENV.<10>, was set to 1; for a native program, an arithmetic overflow occurred. This 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.
Run-Time Diagnostic Messages Message List Effect. The run unit terminates abnormally. Recovery. See Stack Overflow for an explanation of this condition and recovery information. 6 Process loop-timer timeout (121) A hardware/software trap occurred - the type follows Process loop-timer timeout Cause. The new time limit specified in the latest call to SETLOOPTIMER has expired. Effect. The run unit terminates abnormally. Recovery. Report this error to your service provider.
Run-Time Diagnostic Messages Message List 8 Not enough physical memory (121) A hardware/software trap occurred - the type follows 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. Disk space could not be allocated while the program is using extensible segments. Effect. The run unit terminates abnormally. Recovery. Report this error to your service provider.
Run-Time Diagnostic Messages Message List Recovery. • COBOL85 compiler In the CRE, the program might have written data in the upper 64 KB of the user data segment. The upper 64 KB are reserved for CRE and run-time library data. Check the program’s logic. Use the selected debugger to help isolate the problem or consult your system administrator. In the non-CRE environment, one of these things might have happened: ° ° ° The pointer at location G[0] is not %100000.
Run-Time Diagnostic Messages Message List Recovery. If the program was compiled with the COBOL85 compiler, check the program’s logic to see if it overwrote the MCB pointer at G[0]. Use the selected debugger to help isolate the problem. If the program was compiled with the NMCOBOL compiler: In a native object, the MCB is not at a fixed location. To find it, use the noft command EXTSYMTBL. Then use the selected debugger to help isolate the problem. The noft output can be very lengthy.
Run-Time Diagnostic Messages Message List 16 (none) Checkpoint list exhausted Cause. The CRE did not have enough room to store all of the checkpoint information required by the program. Effect. The run unit terminates abnormally unless the error occurred in an SMU routine. Recovery. If the error occurred in an SMU routine, increase the size of the checkpoint list. 17 Cannot obtain control space (012) Space allocation for ACCEPT or DISPLAY failed Cause.
Run-Time Diagnostic Messages Message List 21 (none) Cannot read initialization messages ( error ) Cause. During program initialization, the CRE could not read all of the messages (start-up message, PARAM message, ASSIGN messages, and so forth) it expected from the file system. error is the file system error number the CRE received when it could not read an initialization message. Effect. The run unit terminates abnormally. Recovery. Consult your system administrator.
Run-Time Diagnostic Messages Message List 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. The run unit terminates abnormally. Recovery. Correct the ASSIGNs in your TACL environment. For information on ASSIGN commands, see ASSIGN Command and the TACL Reference Manual.
Run-Time Diagnostic Messages Message List Effect. The run unit terminates abnormally. Recovery. Modify the PARAM text and rerun your program. For more information on using PARAMs, see PARAM Command and the TACL Reference Manual. 27 (none) 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.
Run-Time Diagnostic Messages Message List 40 (130) Invalid function parameter Cause. A function detected a problem with its parameters. Effect. Program behavior depends on the function that was called. Recovery. Correct the parameter you are passing. 41 (none) Range fault Cause. An arithmetic overflow or underflow occurred while evaluating an arithmetic function. Effect. Program behavior is language and application dependent.
Run-Time Diagnostic Messages Message List 44 (none) Arctan domain fault Cause. Both of the parameters to an ATAN function were zero. At least one of the parameters must be nonzero. Effect. Program behavior is language and application dependent. Recovery. Modify the program to pass the correct value to the ATAN function. 46 (none) Logarithm function domain fault Cause. The parameter passed to a logarithm function (LOG or LOG10) was less than or equal to zero.
Run-Time Diagnostic Messages Message List 49 (none) Square root domain fault Cause. The parameter to the SQRT function was a negative number. The parameter must be greater than or equal to zero. Effect. Program behavior is language and application dependent. Recovery. Modify the program to pass a nonnegative value to the SQRT function. 55 (none) Missing or invalid parameter Cause. A required parameter is missing or too many parameters were passed. Effect.
Run-Time Diagnostic Messages Message List Effect. The CRE can report this error when it closes your input file. All other instances are language and application dependent. An HP COBOL program terminates abnormally. 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.
Run-Time Diagnostic Messages Message List 62 (none) Invalid GUARDIAN file number Cause. A value that is expected to be a Guardian file number is not the number of an open file. Effect. Program behavior is language and application dependent. An HP COBOL program terminates abnormally. Recovery. Consult your system administrator. 63 (none) 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.
Run-Time Diagnostic Messages Message List 66 (none) Unsupported file device Cause. The CRE received a request to access a device that it does not support. Effect. Program behavior is language and application dependent. An HP COBOL program terminates abnormally. Recovery. Consult your system administrator. 67 (none) 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.
Run-Time Diagnostic Messages Message List 70 (none) Options not accepted Cause. The value of an open operation options parameter was not valid in the context in which it was used. Effect. Program behavior is language and application dependent. An HP COBOL program terminates abnormally. Recovery. Consult your system administrator. 71 (none) Inconsistent attribute value Cause.
Run-Time Diagnostic Messages Message List Effect. The OPEN statement is unsuccessful with I-O status code “91.” The COBOL_SPECIAL_OPEN_, COBOL85^SPECIAL^OPEN, or COBOLSPOOLOPEN call is unsuccessful with I-O status code “30.” Recovery. The program should close files as soon as it is done using them.
Run-Time Diagnostic Messages Message List 77 EDITREADINIT failed ( error ) (033) OPEN on an EDIT file and EDITREADINIT failed with code -n Cause. A call to EDITREADINIT failed. In CRE message 77, error, if present, gives the reason for the failure.
Run-Time Diagnostic Messages Message List In COBOL message 062, the program attempted to read an EDIT file, and the call to EDITREAD failed. The returned code is -n. 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. If the code is -3, there is a text file format error. Re-create the file. If the code is -4, there is a sequence number error. Use EDIT, TEDIT, or Codewright to correct the file.
Run-Time Diagnostic Messages Message List 81 (none) End of file Cause. A routine detected an end-of-file condition. Effect. Program behavior is language and application dependent. An HP COBOL program terminates abnormally. Recovery. Correct your program to allow for an end-of-file condition or verify that your program can determine when all of the data has been read. 82 (none) Guardian I/O error nnn Cause. A Guardian operating system routine returned error nnn.
Run-Time Diagnostic Messages Message List Recovery. One of these, depending on the cause number: 1. Either delete the call to COBOL_CONTROL_ or COBOL_SETMODE_ or correct it (depending on the cause): a. Change the file to a file other than $RECEIVE. b. Change the RESERVE clause so that it does not use HP COBOL Fast I-O. c. Take the action indicated by the Guardian error code “(GE).” 2. Correct the ASSIGN in the select clause or change LINE SEQUENTIAL to SEQUENTIAL.
Run-Time Diagnostic Messages Message List Recovery. Copy the value from the Linkage Section data item to a data item in the Working-Storage Section, and use the new data-name as the parameter in the ENTER statement. 127 (003) CALL references an active program Cause. A CALL statement is recursive—it references a program that has been called but has not executed an EXIT PROGRAM statement. Effect. The run unit terminates abnormally. Recovery. Correct the program.
Run-Time Diagnostic Messages Message List 131 (007) S location at end of paragraph not equal to that at beginning Cause. This message should never occur, because it indicates a compiler problem. It signals that some code generated in the preceding paragraph changed the S register setting and did not reset it. Effect. The run unit terminates abnormally. Recovery. Report it to your service provider. 132 (008) SORT or MERGE statement executed while SORT or MERGE active Cause.
Run-Time Diagnostic Messages Message List 135 (011) 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 (017) 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 (018) 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 (019) 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 (020) RETURN operation failed - SORTMERGE message follows Cause.
Run-Time Diagnostic Messages Message List 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.nn is the highorder 2 bytes of the error code return defined for SORTERRORSUM.
Run-Time Diagnostic Messages Message List 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 (024) Alternate key not present in file Cause. During the execution of an OPEN statement, the description of an alternate key in the COBOL program does not correspond to any alternate key in the physical file that is assigned.
Run-Time Diagnostic Messages Message List 153 (027) Create of new file failed with error nnn Cause. During the attempt to create a new file during the execution of an OPEN statement, Guardian error nnn was returned by the operating environment. 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. 154 (028) Sequential DELETE must follow successful READ Cause.
Run-Time Diagnostic Messages Message List 157 (031) Wrong open mode for DELETE Cause. A DELETE statement was executed, but the file was not open for I-O. Effect. The DELETE statement is unsuccessful with I-O status code “49.” Recovery. Correct the program. 158 (032) DELETE operation failed with error nnn Cause. The attempt to delete 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.
Run-Time Diagnostic Messages Message List 161 (036) 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. 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. 162 (037) OPEN on a nonexistent file that is not OPTIONAL Cause.
Run-Time Diagnostic Messages Message List Recovery. Type ERROR nnn to see the meaning of the Guardian error; it might indicate corrective action. 165 (040) OPEN requested for an unsupported device Cause. The device assigned to the COBOL file is not a legal device for COBOL input or output. Effect. The OPEN statement is unsuccessful with I-O status code “39.” Recovery. Assign a file on a legal device. 166 (041) OPEN requested for a locked file Cause.
Run-Time Diagnostic Messages Message List Recovery. Either assign the correct device or remove the LINAGE clause from the file description (FD). 169 (044) LOCK or UNLOCK operation failed with error nnn Cause. The attempt to lock or unlock a file or record with a LOCK or UNLOCK statement failed with Guardian error nnn. Effect. The 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 Recovery. Create the file correctly before running the program, assign the correct file, or remove the alternate key specifications. 173 (049) Indexed file not defined as ORGANIZATION INDEXED Cause. The file assigned is an indexed (key sequenced) file, but the COBOL loadfile description does not specify ORGANIZATION INDEXED. Effect. The OPEN statement is unsuccessful with I-O status code “39.” Recovery.
Run-Time Diagnostic Messages Message List 177 (053) OPEN OUTPUT for file not on output device Cause. A file is being opened for OUTPUT, but the device assigned is an illegal device or an input-only device (such as a card reader). Effect. The OPEN statement is unsuccessful with I-O status code “37.” Recovery. Assign the proper device or file. 178 (054) Relative file not defined as ORGANIZATION RELATIVE Cause.
Run-Time Diagnostic Messages Message List 181 (057) OPEN operation failed with error nnn Cause. A Guardian error nnn was returned during OPEN, COBOL_SPECIAL_OPEN_, COBOL85^SPECIAL^OPEN, or COBOLSPOOLOPEN processing. Effect. The OPEN statement or the call to COBOL_SPECIAL_OPEN_, COBOL85^SPECIAL^OPEN, or COBOLSPOOLOPEN 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 Recovery. Type ERROR nnn to see the meaning of the Guardian error; it might indicate corrective action. A value of “48,” for example, means that the program does not have permission to purge an existing file that has an improper record size and create a new one. 185 (061) Purge data from file during OPEN failed with error nnn Cause.
Run-Time Diagnostic Messages Message List 188 (065) 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. Type ERROR nnn to see the meaning of the Guardian error; it might indicate corrective action. 189 (066) Sequential READ requested when current position is undefined Cause.
Run-Time Diagnostic Messages Message List 192 (069) 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. 193 (070) REWRITE positioning failed with error nnn Cause.
Run-Time Diagnostic Messages Message List 196 (073) 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 (074) REWRITE operation failed with error nnn Cause.
Run-Time Diagnostic Messages Message List 200 (078) 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 (079) System node not available or does not exist Cause.
Run-Time Diagnostic Messages Message List 204 (082) 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 (083) 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 (086) 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 (094) 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 (095) 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 (098) 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 (102) 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 (113) 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 229 (116) Loadopen failed with internal error mmm, GUARDIAN error nnn Cause. The HP COBOL Fast I-O routine loadopen returned the indicated error codes. Effect. The OPEN 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. 230 (117) Loadwrite failed with internal error mmm, GUARDIAN error nnn Cause.
Run-Time Diagnostic Messages • • • • Message List The file description does not include a LINAGE clause or a CODE-SET clause. The file was not opened with time limits (as with the TIME LIMITS phrase in the OPEN statement). The program is not compiled with the NONSTOP directive.
Run-Time Diagnostic Messages Message List Each occurrence of this error produces a message on the home terminal or in the execution log. 234 CLOSE operation failed with error nnn (124) The CLOSE operation failed with Guardian 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.
Run-Time Diagnostic Messages Message List none (075) CLOSE LOCK while same file open elsewhere in run unit Cause. The program has two files open that are assigned to the same physical file and is attempting to close one with the LOCK phrase. Effect. The CLOSE statement is successful. The open file is not locked. Recovery. Correct the program. none (091) Descriptions for the same external file differ Cause. The file-control entry for an external file in one program differs from that in another.
Run-Time Diagnostic Messages Message List none (107) File referenced in PARAM EXECUTION-LOG is an invalid device Cause. The device assigned to the file specified in PARAM EXECUTION-LOG is not a disk, terminal, or process. Effect. The run unit terminates abnormally. Recovery. Specify a file on the proper device. none (120) The file name in PARAM PRINTER-CONTROL is not a legal COBOL file name Cause. The file name specified in the PARAM PRINTER-CONTROL does not conform to the rules for a COBOL file name.
Run-Time Diagnostic Messages Message List none (128) PARAM WAITED-IO ON specified and illegal OPEN attempted Cause. PARAM WAITED-IO ON was specified, and one of these OPEN operations was attempted: • • OPEN … TIME LIMITS OPEN file-name where file-name references $RECEIVE Effect. The run unit terminates abnormally. Recovery.
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 and TNS/R Programs —522555-006 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 CISC CISC. See complex instruction-set computing (CISC). 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. CLIBOBJ. The object file containing the COBOL run-time routines that can be bound into the executable object file built from a COBOL program. client.
Glossary COBOLLIB COBOLLIB. The object file of utility routines for HP COBOL, including COBOLSPOOLOPEN, COBOLFILEINFO, CREATEPROCESS, and the Saved Message Utility (SMU) routines. code block. In COBOL, the object code that the compiler generates from a single source program; in binding or linking, the smallest separately relocatable unit of code in an object file. collating sequence. The order of the characters of a character set, for the purpose of sorting, merging, or comparing. column.
Glossary compilation unit compilation unit. A set of source files compiled in one call to a compiler, including any compiler directives in the command that starts the compiler but not including any object files that the compiler summons to resolve external references; in COBOL, one or more source programs. compile time. The time at which a compiler translates a source file into an object file. compiler directive. An instruction to a compiler. complex condition.
Glossary contiguous data items contiguous data items. Two or more data items that have a hierarchical relationship to each other, which you describe by consecutive data description entries at the same level (except consecutive level-01 entries) in the Data Division; for example: 01 ABLE. 02 BAKER 02 CHARLIE 02 DOG. 04 EASY 04 FOX 02 GOOSE PIC X(2). PIC X(2). PIC X(2). PIC X(2). PIC X(2). BAKER, CHARLIE, DOG, and GOOSE are contiguous; EASY and FOX are contiguous. counter.
Glossary data item data item. One of these: • • A unit of storage that can hold a character (or set of contiguous characters) or a computational value defined as a unit of data by a COBOL program. The character, set of characters, or value that occupies such a unit of storage. data-name. One of these: • • A user-defined word that names a data item described in a data description entry.
Glossary delimiter delimiter. A character or sequence of contiguous characters that identify the beginning or end of a string of characters but are not part of the string of characters. digit position. The amount of physical storage required to store a single digit, an amount that depends on the USAGE of the data item described to hold the digit. directive. An instruction to a compiler (also called a compiler directive). directive line.
Glossary editing characters editing characters . One of: Character Meaning Character Meaning B Space Z Zero suppress 0 Zero * Check protect + Plus $ Currency sign - Minus , Comma (decimal point) CR Credit / Slash (slant, virgule) DB Debit eld utility. A utility that collects, links, and modifies code and data blocks from one or more position-independent code (PIC) object files to produce a target TNS/E native object file. See also ld utility and nld utility. elementary item.
Glossary EXTEND mode EXTEND mode. The state of a file after a process executes an OPEN statement including an EXTEND phrase for the file and before the process executes a CLOSE statement without the REAL or UNIT phrase for the file, allowing the process to extend the file by appending additional records. extended addressing. Data access through an extended (32-bit) pointer (also called 32-bit addressing). Compare to standard addressing. Extended-Storage Section.
Glossary file connector file connector. A storage area that contains information about a file; the linkage between a file name and a physical file and between a file name and its associated record area. FILE-CONTROL. The name of an Environment Division paragraph that declares the data files for the program. file-control entry.
Glossary fixed attributes fixed attributes. Information about a file that is established when a process creates a file and that cannot subsequently be changed during the existence of the file.
Glossary high PIN high PIN. A process identification number (PIN) that is greater than 255. Compare to low PIN. HP COBOL Fast I-O. A fast form of sequential block buffering in which run-time routines handle the record deblocking. HP COBOL program. A program written in the HP COBOL language. It can be compiled with the COBOL85, NMCOBOL, or ECOBOL compiler. HP NonStop™ operating system. The operating system for HP NonStop systems. HP NonStop™ Transaction Management Facility (TMF).
Glossary indexed organization indexed organization. A permanent logical file structure in which a process can identify each record by the value of one or more keys within the record. IN file. The input file of a process, either specified explicitly at process start time or inherited from the parent process. initial program. A program that is placed into an initial state every time the program is called in a run unit. initial state. The state of a program when it is first called in a run unit. input file.
Glossary internal data internal data. The data described in a program, including all internal data items and internal file connectors. Items described in the Linkage Section of a program are handled as internal data. internal data item. A data item that is described in one program in a run unit. An internal data item can have a global name. internal file connector. A file connector that is accessible to only one object program in the run unit. invalid key condition.
Glossary language-specific run-time library language-specific run-time library. A collection of routines outside the CRE that supports requests from a specific language for services such as I-O and heap management, math and string functions, exception handling, and error reporting. ld utility. A utility that collects, links, and modifies code and data blocks from one or more position-independent code (PIC) object files to produce a target TNS/R native object file. See also eld utility and nld utility.
Glossary loading loading. The operation of mapping an object file into the memory of a process. local name. A name that is not global, and therefore, can be referenced only by the program that declares it. Compare to global name. logical page. A conceptual page of a report consisting of a top margin area, a body (including a footing area), and a bottom margin; all governed by the LINAGE clause of the file description entry. logical operator.
Glossary mixed-language program mixed-language program. A program made up of routines compiled from more than one programming language. A program with HP C routines and TAL routines is an example of a mixed-language program. mnemonic-name. A user-defined word you associate with an implementor name in the SPECIAL-NAMES paragraph of the Environment Division and use elsewhere in the program to refer to the implementor name. native character set. The ASCII character set. native link editor. See nld utility.
Glossary noncontiguous items noncontiguous items. Elementary data items that bear no hierarchical relationship to other items and that you describe in the Working-Storage, Extended-Storage, and Linkage Sections of the Data Division: • • Level 77 items Level 01 items (each one of which is noncontiguous with respect to each other one) non-CRE environment. A set of services implemented by the COBOL85 run-time library.
Glossary numeric literal numeric literal. A string of these characters: • • • One or more digits (required) A decimal point in any character position except the rightmost (optional) An algebraic sign in the leftmost character position (optional) OBEY command file. An EDIT file that contains a series of commands and serves as a source of command input. OBJECT-COMPUTER. The name of an Environment Division paragraph that describes the computer environment in which you can execute the object program.
Glossary operand operand. In syntax formats, any lowercase word or words that appear in a statement or entry format; an implied reference to data or to a literal value. operational sign. An algebraic sign associated with a numeric data item or a numeric literal to indicate whether its value is positive or negative. optional file.
Glossary paragraph paragraph. In the Procedure Division, a paragraph-name followed by a period (.) and zero, one, or more sentences; in the Identification Division or Environment Division, a paragraph header followed by zero, one, or more entries. paragraph header. A reserved word, followed by a period (.), that indicates the beginning of a paragraph in the Identification Division or Environment Division.
Glossary PIC PIC. See position-independent code (PIC). PIN. See process identification number (PIN). position-dependent code (non-PIC). Executable code that must be modified to run at different virtual addresses. External reference addresses appear in non-PIC code. Non-PIC is also called nonshared code. position-independent code (PIC). Executable code that need not be modified to run at different virtual addresses.
Glossary process identification number (PIN) process identification number (PIN). An unsigned integer that identifies a process in a processor module. Internally, a PIN is used as an index into the process control block table. process pair. Two instances of the same executable object file (called the primary process and the backup process) that are executing in separate processors of a NonStop system.
Glossary qualifier qualifier. One of these: • • • A data name or file name used in a reference, together with a data name that is at a lower level in the same hierarchy. A section-name that you use in a reference together with a paragraph-name specified in that section. A library name you use in a reference together with a text name associated with that library. queue file. An indexed file that can function as a queue. random access.
Glossary reference page reference page. The online or hard-copy version of a file that provides reference information for a software facility. Some UNIX documentation uses the term man page instead, referring either to the online delivery mechanism used to display the file (usually the shell man command) or to the nature of the file as part of the manual. reference parameter. A parameter that is passed by reference (that is, its address is passed).
Glossary run-time library run-time library. A collection of routines that supports requests for I-O and heap management, math and string functions, exception handling, and error reporting. run-time routine. A subprogram, supplied as part of the COBOL product, which performs some function needed in the course of executing a statement in the COBOL language and which the object code produced by the COBOL compiler automatically calls when needed. run unit.
Glossary semicolon separator semicolon separator. A sequence of two or more characters where the first one is a semicolon, and the remaining ones are spaces. sentence. A sequence of one or more statements, the last terminated by a period (.). separately compiled program. A program that (together with its contained programs) is compiled separately from all other programs.
Glossary sign condition sign condition. The proposition, for which a process can determine a truth value, that the algebraic value of a data item or an arithmetic expression is less than, greater than, or equal to zero. signal. The method by which an environment notifies a process of an event. Signals are used to notify a process when an error that is not related to input or output has occurred. A signal is often an indication of a run-time event that requires immediate attention.
Glossary space separator space separator. A sequence of one or more space characters (which are not part of some other separator) used as a separator. special character. One of: Character Meaning Character Meaning + Plus sign ; Semicolon - Minus sign .
Glossary structured file structured file. A disk file of fixed-length records or variable-length records, to which a process gains access through the Enscribe record manager, that has one of three organizations: • • • Entry sequenced Key sequenced Relative subprogram. See called program. subscript.
Glossary terminal terminal. An input-output device. terminal control process (TCP). A process used for terminal management and transaction control, provided by HP as a part of the Pathway/TS product. A TCP is a multithreaded process that interprets compiled SCREEN COBOL requester programs (screen programs) in the user’s application, executing the appropriate program instructions for each I-O device or process for which the TCP is configured.
Glossary TNS instructions TNS instructions. Stack-oriented, 16-bit machine instructions that are directly executed on TNS systems by hardware and microcode. TNS instructions can be emulated on TNS/E and TNS/R systems by using millicode, an interpreter, and either translation or acceleration. Compare to MIPS RISC instructions and Intel® Itanium® instructions. TNS interpreted mode.
Glossary TNS/E architecture TNS/E architecture. NonStop Series/Itanium architecture. HP computers that are based on Itanium technology. TNS/E architecture implements the Itanium instruction set [explicitly parallel instruction set computing (EPIC)] and are upwardly compatible with the TNS and TNS/R system-level architectures. TNS/E native compiler.
Glossary TNS/R native mode TNS/R native mode. The primary execution environment on a TNS/R system, in which native-compiled MIPS object code executes, following TNS/R native-mode compiler conventions for data locations, addressing, stack frames, registers, and call linkage. Compare to TNS interpreted mode and TNS accelerated mode. See also TNS/E native mode. TNS/R native object code. The MIPS RISC instructions that result from processing program source code with a TNS/R native compiler.
Glossary unstructured file unstructured file. A disk file organized as a byte stream. Each byte is directly addressable by an application, which manages its own access to the file contents. In COBOL, unstructured files are limited to sequential organization and access with fixed-length records. The COBOL run-time routines handle any blocking and deblocking for unstructured files, which can improve performance. user-defined word. A COBOL word that you supply within the format of a clause or statement.
Glossary word word. An instruction-set-defined unit of memory that corresponds to the width of registers and to the most common and efficient size of memory operations. A TNS word is 2 bytes (16 bits) wide, beginning on any 2-byte boundary in memory. A MIPS RISC word is 4 bytes (32 bits) wide, beginning on any 4-byte boundary in memory. An Intel® Itanium® word is also 4 bytes (32 bits) wide, beginning on any 4-byte boundary in memory. Working-Storage Section.
Index Numbers 9 in PICTURE clause 7-57 A A in PICTURE clause 7-55 Abbreviated combined relation conditions 8-66 ABEND 25-6 Abnormal program termination 33-10 Accelerated mode 1-3 ACCEPT statement description of 9-1/9-8 in OSS environment 19-24 terminals and 29-2/29-3, 29-13 Access mode description of 4-8 heritability of 7-40 of parameters 9-27 ACCESS MODE clause description of brief 6-25 complete 7-39/7-40 file type and 6-24 for indexed file 6-49 for line sequential file 6-39, 19-13 for relative file 6-43
Index A ALPHABETIC class test in simple condition 8-60 with default character set 6-8 with nondefault character sets 6-9 Alphabetic data items description of 7-61 ACCEPT statement and 9-3 alignment of data in 4-15 MOVE statements and 9-129 ALPHABETIC-LOWER class test in simple condition 8-60 with default character set 6-8 ALPHABETIC-UPPER class test in simple condition 8-60 with default character set 6-8 Alphabet-name 6-15/6-17 Alphanumeric class and category 4-1 Alphanumeric data items description of 7-6
Index A Apostrophe (') in national literal 3-21 in simple nonnumeric literal 3-19 Approximate positioning 28-24 ar utility 34-10 Arccosine function 14-8 Archive files 34-10 Arcsine function 14-11 Arctangent function 14-12 Area A in ANSI reference format 16-4 in Tandem reference format 2-6 paragraph headers and 8-12 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-22 precision of 8-51/8-53 summary of 38-8/38-9 Arithm
Index B AT END phrase (continued) USE AFTER EXCEPTION procedures and 9-288 ATAN function 14-12 Atomic functions (pTAL) 33-8 Attributes CLASS 12-21 DEFINE description of 12-21/12-23 for labeled tape files 27-18/27-24 for unlabeled tape files 27-16/27-18 security 28-4/28-6 At-end condition See also AT END phrase for READ statement file position indicator and 9-182 multiple-reel tape files and 9-185 recoverable errors and 9-187 for SEARCH ALL statement 9-215, 9-218 for SEARCH VARYING statement 9-210, 9-211,
Index C Binding (continued) mixed-language programs 24-16 process of 24-4 BINSERV process description of 11-10, 11-12, 11-27, 11-43, 24-5 in compilation 24-10/24-13 selecting processor for 11-34 BLANK directive description of 11-54 initializing data items and 7-36 migrating to native mode and 33-15 Blank lines in replacement text 10-17 in Tandem reference format anywhere 2-6 in continuation lines 2-5 BLANK WHEN ZERO clause description of 7-88 for BINARY/COMPUTATIONAL data item 7-73 for INDEX data item 7-7
Index C C routines (continued) run-time environment for 23-2 sharing data with 23-17 C8LIB file 22-13 Cache buffering See Buffering, cache Cache, write-through 28-32 CALL statement description of 9-18/9-31, 11-12/11-16 at object program level 24-3 detailed explanation of 11-16/11-23 dynamic 23-6, 24-14 EXTENDED access mode and 7-40 PIC loadfiles and 9-25 STANDARD access mode and 7-40 static 23-5 X/Open See X/Open CALL statement Called programs description of 11-4 compilation units and 11-7/11-8 EXIT PROGR
Index C Character sets COBOL 3-2/3-3 nondefault 6-9 CHARACTER-SET clause 6-6, 6-8/6-9 Character-strings description of 3-6/3-24 COBOL words 3-7/3-16 comments 3-24 literals 3-16/3-23 PICTURE editing characters in 3-24 punctuation characters in 3-6 size of 7-55 CHECK directive 11-56/11-57 Check protect 3-24 CHECKLOGICALNAME routine 13-108/13-109 CHECKMESSAGE routine 13-110 CHECKPOINT statement description of 9-34/9-36 CRE and 18-6 Extended-Storage Section and 24-22 fault-tolerant facility and 32-2 migrating
Index C cobol utility (OSS) running COBOL85 compiler with 19-2/19-3 COBOL words description of 3-7 qualified names 3-13/3-16 reserved words 3-9 system-names 3-10 user-defined names 3-10 COBOL85 compiler See also cobol utility (OSS) See also Compiler description of 1-4 object files produced by 11-27 COBOL85^ARMTRAP routine 13-39 COBOL85^COMPLETION routine 13-40/13-42 COBOL85^RETURN^SORT^ERRORS routine 13-46/13-48 COBOL85^REWIND^SEQUENTIAL routine 13-49/13-50 COBOL85^SET^SORT^PARAM^TEXT routine 13-51/13-54
Index C COBOL_SPECIAL_OPEN_ routine (continued) for tape files in CRE 13-82/13-84 in OSS environment 19-25 Code blocks description of 11-27, 24-1/24-3 calling each other 24-3 replacing 24-15/24-16 CODE directive description of 11-58 compiler listing and 22-41 migrating to native mode and 33-18 sample output from 22-54 Code generation control directives 11-49 Code segments 24-17/24-18 Codewright See HP Tandem Extensions for Codewright (TEC) CODE-SET clause description of 7-29 in external file 7-13 Collecto
Index C Compilation (continued) statistics from 11-29/11-32 summary of description of 22-41 for COBOL85 compiler 22-65 for NMCOBOL compiler 22-66 terminating in Guardian environment 11-44 in OSS environment 19-1 units of description of 11-5/11-7, 23-3 called programs and 11-7/11-8 with native COBOL cross compiler 34-7 COMPILE directive 11-61 Compiler See also Compilation COBOL85 1-4 diagnostic messages from 47-1/47-93 directives for See Compiler directives errors See Error messages, compiler improving spe
Index C Compiler listing (continued) summary for COBOL85 compiler 22-65 for NMCOBOL compiler 22-66 uncompiled lines in 11-86 Completion codes 11-33 Complex conditions 8-64 Composites of arithmetic operands 8-43 COMPUTATIONAL data format description of 7-69, 7-73 allocation for 4-14 arithmetic overflow and 8-25 compared to NATIVE-n data format 7-77 PORT directive and 11-104 SYNCHRONIZED clause and 7-87 tape I-O and 27-14 value 8224 or 224 and 7-73 COMPUTATIONAL data items 33-10, 33-11, 33-12 COMPUTATIONAL-
Index C CONSULT directive description of 11-62/11-63 migrating to native mode and 33-15, 33-16, 33-17, 33-22 Content, passing parameters by 23-21/23-22 Continuation lines in ANSI reference format 16-3 in Tandem reference format 2-5 CONTINUE statement explicit 9-44, 9-86, 9-211, 9-216 implicit 9-77 CONTROL message 6-75 CONTROLBUF message 6-75 Conversion between EBCDIC and ASCII 27-12 for labeled tape files 27-11 from COBOL 74 to HP COBOL TRAP2 and NOTRAP2 directives 11-132 TRAP2-74 and NOTRAP2-74 directive
Index D CRE (Common Run-Time Environment) (continued) library 23-2 structured files and 28-32 CREATEPROCESS routine 13-101/13-104 CREATE-NEW-OUTPUT parameter 13-56, 13-59 CREATE-NEW-SCRATCH parameter 13-56, 13-59 Creating HP COBOL files indexed 28-17/28-18 queue 28-19 relative 28-16/28-17 sequential 28-14/28-16 Creating programs 22-5/22-10 Creator ID, changing 31-39 Credit (CR) 3-24, 7-57, 7-65 CROSSREF directive description of 11-63/11-66 compiler listing and 22-41 cross-reference listing and 22-63 migra
Index D Data items alignment of in memory 4-15/4-16 migrating to native mode and 33-5, 33-6/33-12 standard debugging tools and 15-1 alignment of data in 4-15 alphabetic 7-61 alphanumeric 7-61 alphanumeric edited 7-62 BINARY See BINARY data format categories of description of 4-1 in Data Division 7-2 checkpointing 32-7 classes of 4-1 COMPUTATIONAL See COMPUTATIONAL data format COMPUTATIONAL-3 See COMPUTATIONAL-3 data format COMPUTATIONAL-5 See COMPUTATIONAL-5 data format corresponding 8-22 description entr
Index D Data items (continued) synchronized 7-86 that cannot have VALUE clauses 7-89 Data misalignment See Address misalignment DATA RECORDS clause 7-23, 7-32 Data structures See also Files See also Records See also Tables description of 4-2/4-14, 22-25 initializing 7-90, 9-93 MOVE statement and 9-130 redefined 7-49 storage allocation for 7-46 that cannot have VALUE clauses 7-89 USAGE clause and 7-72 VALUE clause and 7-90 Data type correspondence B-1 Data types other than HP 27-13 Databases describing 22-
Index D DEBUG-NAME field 9-286 Decimal numeric literals 3-17/3-18 Decimal point See also Comma See also Period in decimal numeric literal 3-17 in intermediate results 8-52 in PICTURE clause 3-24 placement in division 8-50 DECIMAL-POINT clause 6-22 Decision tables 9-67 Declarative procedures conditional GO TO statement and 9-82, 9-83 for debugging 15-2/15-3 LOCKFILE statement and 9-117 unconditional GO TO statement and 9-81 Declaratives Portion execution of 8-20 syntax of 8-15/8-16 Declarative-file connect
Index D DEVICE attribute of DEFINE for labeled tape file 27-22 for unlabeled tape file 27-16 DEVICEINFO2-COMPLETION message 6-75 Devices default input and output 25-10 default input-output 25-5 DISPLAY statement and 9-48 OPEN statement and 9-144 system file names of 26-3 DEVICE-INFO message 6-75 DIAGNOSEALL directive 11-71 DIAGNOSE-74 directive 11-66/11-69 DIAGNOSE-85 directive description of 11-70 migrating to native mode and 33-20 Diagnostic messages compiler See Error messages, compiler directives that
Index E Disk files (continued) 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-70, 7-75 converting 27-14 SYNCHRONIZED clause and 7-87 DISPLAY statement description of 9-47/9-50 in OSS environment 19-24 unqualified 25-10 with NO ADVANCING phrase 9-2 with printer 30-22 with terminal 29-2/29-3, 29-10, 29-13 Displaying figurative constant values 9-49 large amounts of data
Index E Editors (continued) PS TEXT EDIT (TEDIT) 22-8/22-10 VS full-screen 22-8 Elementary data items description of 4-1 clauses restricted to 7-46 default USAGE for 7-75 initializing 9-93 passed by content 23-21 passed by reference 23-23 redefined 7-49 storage allocation for 7-46 that cannot have VALUE clauses 7-89 USAGE clause and 7-72 Elements of HP COBOL language 3-1/3-24 of records 4-5 of tables 4-12 Embedded NonStop SQL/MP compiler listing and 22-48 format restrictions on 2-7 in user libraries 33-22
Index E Error messages Binder 22-52 compiler description of 22-49/22-52 See also Failure messages See also Warning messages characteristics of 47-1 ERROR directive and 11-76 ERRORFILE directive and 11-75, 22-15 format of 47-3 from other products 47-95 list of 47-4/47-93 run-time description of 25-14, 48-1 associated with tape files 27-26 external 8-34/8-39 fatal 8-42 format of CRE 48-5 non-CRE 48-2/48-4 Guardian abnormal termination 48-7/48-10 input-output 8-33/8-39, 48-6 list of 48-10/48-70 procedures fo
Index F Expressions arithmetic See Arithmetic expressions concatenation description of 8-69/8-70 summary of 38-13 conditional description of 8-53/8-69 summary of 38-9/38-12 EXTDECS file 23-13, 23-14 EXTDECS0 file 23-14 EXTDECS1 file 23-14 Extend open mode 4-10 Extended addressing 7-40 Extended entry point (XEP) table 24-17 EXTENDED parameter 11-125 EXTENDED-STORAGE access mode 7-40 Extended-Storage Section description of 7-37/7-38 backing up 9-255 checkpointing and 9-35 data description entries in 7-37 la
Index F Federal Information Processing Standard (FIPS) 11-76 Figurative constants description of 3-21 defined by SYMBOLIC CHARACTERS clause 6-18 displaying values of 9-49 length associated with 3-22 program collating sequence and 6-18 where allowed 3-22 File assignments at compilation time 25-3 dynamic 26-8, 27-3 File attributes 28-41/28-42 File connectors description of 4-11 CANCEL statement and 9-32 external and internal 2-17 shared 7-11 File description entries description of 7-5/7-30 for line sequenti
Index F Files (continued) error 22-52 exclusion modes of 4-10 executable See Loadfiles external 7-12 See External objects, files in OSS environment 19-8/19-11 indexed See Indexed files internal See Internal objects, files key-sequenced See Indexed files labeled See Labeled tape files line sequential See Line sequential files locking 9-37, 9-115/9-118, 26-9, 28-38 nonexistent 9-148, 9-151/9-152 numbers of 28-41/28-42 OBEY command 22-16 object See Object files of dummy routines 13-23 open modes of 4-10 open
Index F File-control entries generally 6-23/6-27 for indexed files 6-47/6-53 for line sequential files 6-38/6-40, 19-12/19-14 for queue files 6-54 for relative files 6-40/6-46 for sequential files 6-28/6-37 for sort-merge files 6-55/6-56 FILE-CONTROL paragraph 6-23/6-56 FILE-GETINFOBYNAME-COMPLETION message 6-75 File-Mnemonic clause description of 6-14/6-15 migrating to native mode and 33-15 File-status data item description of 6-26 CLOSE statement and 9-38 UNLOCKRECORD statement and 9-271 FILE_GETINFO_ r
Index G G GENERIC phrase 9-238 Generic positioning 28-24/28-26 GETASSIGNTEXT routine 13-118/13-120 GETASSIGNVALUE routine 13-120/13-121 GETBACKUPCPU routine 13-122 getenv (C function) 9-64 GETPARAMTEXT routine 13-123/13-124 GETSTARTUPTEXT routine 13-125/13-126 GIVING phrase description of 9-61, 23-9 C functions and 9-64 GLOBAL clause 7-14, 7-53 Global names 2-16 GO TO statement description of 9-81/9-83 ALTER statement and 9-16 initial state of program and 12-24 PERFORM cycle and 9-158 program termination
Index I HP Tandem Extensions for Codewright (TEC) 22-11/22-12 HP COBOL Fast I-O description of 28-34/28-35 audited files and 6-36 for indexed files 6-52 for relative files 6-46 for sequential files 9-190 WAITED-IO and 12-12 HP COBOL programs altering 22-5/22-10 called description of 11-4 reading disk files from 28-7 calling 11-4 common 2-14, 9-25, 23-5 compiling See Compilation creating 22-5/22-10 designed for fault-tolerant facility 32-13 designed for TMF 32-18 directly contained 23-4 divisions of 2-2 ex
Index I IF statement description of 9-83/9-90 nested conditional 9-87 delimited-scope 9-84 IFNOT directive 11-84 Imperative statements 8-5 Implicit CLOSE statement 9-32 Implicit FILLER bytes 4-16/4-18, 33-11, 33-12 Implicit MOVE statement 9-93/9-94 Implicit transfer of control 8-18 Improving compilation speed 22-22 IN option of RUN command 22-13, 25-11, 26-6 Independent segments description of 8-14, 24-23 ALTER statement and 9-18 INDEX data format See also Indexes description of 7-70, 7-76 Indexed files d
Index I INNERLIST directive description of 11-87 compiler listing and 22-41 migrating to native mode and 33-20 sample output from 22-55 Input See also Input-output description of 26-1/26-11 default device for 25-10 from disk files 28-1/28-47 from tape 27-1/27-26 from terminals 29-1/29-15 open mode 4-10 to compiler 1-5, 11-2/11-8 Input-output See also Input See also Output description of 8-28/8-42 default device for 25-5 errors diagnosing 8-33/8-39 messages for 48-6 recovering from 8-39/8-41 mixing COBOL a
Index I Internal objects (continued) files, #RECEIVE blocks for 11-25 initialization of 7-36 status during program execution 12-25 Internal references 24-3 Interprocess communication example 31-13/31-15 Interrecord gaps 27-2 INTO phrase 8-27 Intrinsic functions description of 14-1/14-64 alphanumeric description of 14-3 CHAR 14-13/14-14 CURRENT-DATE 14-16 LOWER-CASE 14-28 REVERSE 14-53 UPPER-CASE 14-61 WHEN-COMPILED 14-63/14-64 arguments of 14-6 integer description of 14-5 DATE-OF-INTEGER 14-17 DAY-OF-INTE
Index J Invalid-key condition (continued) for REWRITE statement 9-207 for START statement 9-244 IN-FILE-COUNT parameter 13-56, 13-59 IN-FILE-EXCL parameter 13-56, 13-60 In-line PERFORM statement 9-159 I-O See Input-output I-O-CONTROL paragraph 6-57/6-63 I/O See Input-output Keys (continued) merge 9-122 of reference 28-21/28-22 record 6-51 relative 6-45 sort 9-231 Status Key 1 8-29 Status Key 2 8-30 Key-sequenced files See Indexed files L J JOB subcommand of SPOOLCOM utility 30-16 Jobs, spooler See Spoo
Index L Large-memory model 9-63 LD directive 11-91 ld utility native COBOL cross compiler and 34-7 NMCOBOL compiler and 33-21 Leading characters 9-97 LEFT keyword 7-87 LENGTH function 14-25 LESS THAN operator 8-54 LESS THAN OR EQUAL TO operator 8-54 LESS-CODE directive 11-91/11-93, 24-22 Level 2 spooler protocol 13-95/13-99 Level 66 data items 7-91 Level 77 data items 7-3, 7-93 Level 88 data items 7-95 Levels of data 4-1 Level-1 spooling 30-8 Level-2 spooling 30-9/30-10 Level-3 spooling 30-10 Level-number
Index L Linkfiles as libraries 13-8 combining into one DLL 13-16 when COBOL85 compler produces 11-27 when NMCOBOL compler produces 11-27 Linking called programs’ object code 11-23 HP COBOL programs automatically 24-10/24-13 to be called dynamically 24-14 with nld utility 24-14 native COBOL cross compiler and 34-7 PIC and non-PIC object files 11-55, 11-101, 11-116 LIST directive description of 11-95, 22-40 overriding 11-129 Listing cross-reference 22-41, 22-63, 33-22 directives that control 11-48 octal cod
Index M LOWER-CASE function 14-28 LOW-VALUE or LOW-VALUES figurative constant 3-23 M MAIN directive 11-98 Main programs description of 11-3, 11-98, 23-3 CANCEL statement and 9-33 identifying 7-42 Manipulating object files 11-28, 33-21 MAP directive 11-99, 22-41, 22-53 Margins See also Reference format A 2-4, 2-6, 16-4 B 16-4 C 2-4, 16-2 L 16-1 R 2-6, 16-4 top and bottom 7-26 MAX function 14-29/14-30 Maximum code block size 24-18 MEAN function 14-31 MEDIAN function 14-32 MEM option of RUN command 25-4 Mem
Index N Mixed-language programs (continued) CRE and 18-1 data type correspondence and B-1 DDL and 22-25 ENTER statement and 9-58 in OSS environment 19-5/19-6 sharing data 23-17 sharing standard files 28-8 Mnemonic codes in compiler listing COBOL85 compiler 11-83 NMCOBOL compiler 11-87 Mnemonic names for object files 24-11 for terminals 29-2 MOD function 14-37 Modules of HP COBOL 1-2 Mount messages See Tape mount messages MOVE statement explicit description of 9-128/9-132 instead of ALTER statement 9-17 im
Index N Native COBOL cross compiler description of 34-1/34-11 ar utility and 34-10 compilation with 34-7 debugging on 34-7/34-10 documentation for 34-11 environments for 34-1 features of 34-2 file extension for 34-4 from PC command line 34-4 in ETK (NonStop COBOL) 34-3 in TDS (Tandem NMCOBOL) 34-4 linking and 34-7 online help for 34-11 OSS environment and 34-5 PC-to-NonStop host transfer tools and 34-11 Native mode migrating HP COBOL programs to 33-1/33-23 Native programs debugging after migration 33-6 on
Index N NMCOBOL compiler See also Compiler See also nmcobol utility (OSS) description of 1-4 object files produced by 11-27, 33-21 nmcobol utility (OSS) 19-3/19-4 NO ADVANCING phrase 9-50 NO REWIND phrase 9-38 NOBLANK directive description of 11-54 initial state of program and 12-24 initializing data items and 7-36 migrating to native mode and 33-15 NOCANCEL directive description of 11-56 CANCEL statement and 9-33 NOCODE directive description of 11-58 compiler listing and 22-41 migrating to native mode an
Index N NONSTOP directive description of 11-100 fault-tolerant facility and 32-9 migrating to native mode and 33-19 overriding 25-5 NonStop SQL/MP See Embedded NonStop SQL/MP NonStop TS/MP See HP Nonstop TS/MP Non-COBOL programs 9-58, 11-4, 23-7/23-19 Non-CRE environment 11-72, 28-32 NON-SHARED directive 11-101 NOPORT directive 11-104 NOPURGE-OUTPUT parameter 13-56, 13-61 NOROUND misalignment handling method 33-9 NOSAVEABEND directive description of 11-111 migrating to native mode and 33-17 NOSEARCH direc
Index O Numeric edited data items ACCEPT statement and 9-3 alignment of data in 4-15 MOVE statements and 9-130 PICTURE clause and 7-62 Numeric functions description of 14-4 ACOS 14-8 ANNUITY 14-9 ASIN 14-11 ATAN 14-12 COS 14-15 LOG 14-26 LOG10 14-27 MEAN 14-31 MEDIAN 14-32 MIDRANGE 14-34 NUMVAL 14-38/14-39 NUMVAL-C 14-40/14-42 PRESENT-VALUE 14-47/14-48 RANDOM 14-49 REM 14-52 SIN 14-54 SQRT 14-55 STANDARD-DEVIATION 14-56/14-57 TAN 14-60 VARIANCE 14-62/14-63 Numeric literals COMPUTATIONAL-5 data items and 7
Index O OMITTED keyword in COBOLLIB routines 13-85 in ENTER statement 9-60 in ZCOBSRL routine 13-38 Omitted parameters 11-23 Online dumps 32-17 Online help for native COBOL cross compiler 34-11 OPEN message 6-76 Open modes description of 4-10 initial state of program and 12-24 of external files 7-13 summary of 9-148 OPEN routine 13-139 OPEN statement description of 9-138/9-156 fault-tolerant facility and 32-10 Open System Services (OSS) environment description of 19-1/19-25 native COBOL cross compiler and
Index P Output (continued) from compiler 1-6, 11-25/11-33 merged 9-119 open mode 4-10 to disk files 28-1/28-47 to printers 30-1/30-22 to spoolers 30-1, 30-7/30-22 to tape 27-1/27-26 to terminals 29-1/29-15 waited 23-10 OUT-FILE-EXCL parameter 13-56, 13-62 OUT-FILE-FORMAT parameter 13-56, 13-62 Out-of-line PERFORM statement 9-159 Overflow arithmetic COBOL85^ARMTRAP and 13-39 CRE and 18-6 TRAP2 and NOTRAP2 and 11-132 TRAP2-74 and NOTRAP2-74 and 11-134 in STRING statement 9-260 page 9-294, 9-298 size error c
Index P Parameters (continued) established with =_SORT_DEFAULTS DEFINE 13-26 extensible 23-13 for operating system routines 23-10 formal, adding 23-13 index values as 9-28 lists of 23-13 numeric literals as 23-22 omitted 9-60, 11-23 passing See Passing parameters presenting 11-22 records as 23-23 reference 33-10 replacing code blocks and 24-16 string:length 9-60, 9-65, 23-33, 33-4 tables as 23-22 validation of 9-27 variable 23-13 Parentheses as separators 3-5 in arithmetic expressions 8-47 in conditions 8
Index P PICTURE clause description of 7-54/7-68 for BINARY/COMPUTATIONAL data item 7-73 for COMPUTATIONAL-5 data item 7-75 for INDEX data item 7-76 for NATIVE-n data item 7-76 in record description entry 7-45 NUMERIC class test and 8-60 Plus sign (+) as editing character 3-24 in PICTURE clause 7-57, 7-65, 7-66 Pointer class and category 4-1 POINTER data format description of 7-70, 7-77 in relation conditions 8-58 PORT directive and 11-105 SYNCHRONIZE clause and 7-87 Pointers alignment of targets of 33-10
Index P Printers DISPLAY statement and 30-22 logging program activity to 30-22 out of paper 30-22 output to description of 30-1/30-22 formatting of 30-20/30-21 vertical spacing in 30-18/30-20 unavailable 25-6 WRITE statement and 30-22 writing to 29-12 PRINTER-CONTROL parameter 12-12, 12-14 Priority of spooler jobs 30-6 PRIORITY parameter 13-56, 13-62 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
Index Q PROCESS-DELETION message 6-76 PROCESS-TIME-SIGNAL message 6-76 Production systems 33-9 Program collating sequence 6-18 PROGRAM COLLATING SEQUENCE clause description of 6-5, 6-7 MERGE statement and 9-123 Program entry point (PEP) table 24-17 Program logic errors 8-33 Programs called See Called programs calling See Calling programs and routines compatible 11-74 ENFORM 23-15 HP COBOL See HP COBOL programs mixed-language See Mixed-language programs native See Native programs non-COBOL 9-58, 11-4, 23-7
Index R Qualification (continued) of names 3-13/3-16 of references 11-13 operand identification and 8-21 Question mark (?) as TACL command 22-2 in ANSI reference format 16-2 in Tandem reference format 2-4 Queue files description of 4-8, 28-13 access modes of 4-9 closing 9-40 creating 28-19 determining key value of last record of 9-248 file description entries for 7-10 file-control entries for 6-24, 6-54 opening 9-138, 28-19 reading 28-20 removing records from 28-20 rewriting 9-202/9-207 writing 9-301/9-30
Index R RECORD DELIMITER clause description of 6-25 file type and 6-24 for sequential file 6-31 in external file 7-12 RECORD KEY clause description of 6-50 file type and 6-24 Record keys alternate 28-22/28-23 OCCURS clause and 6-51 primary or prime 28-13 Records description of 4-4/4-6 blocking 27-2, 28-31/28-35 deleted 28-14 description entries for description of 7-2, 7-43/7-90 file description entries and 7-47 displaying 9-50 elements of 4-5 external 7-52 fixed-length 7-20 gaps between 27-2 implicit FILL
Index R References external 24-3 internal 24-3 qualification of 11-13 References (continued) to data items 4-18/4-26 unresolved 24-8, 24-9 validation of 24-4, 24-6/24-7 Relation conditions generally 8-54, 8-57 abbreviated combined 8-66 with nonpointer operands 8-57 with pointer operands 8-58 Relational operators 8-54 Relative files description of 4-7, 28-12/28-13 access modes of 4-9 alternate keys and 28-16, 28-36 closing 9-40 creating 28-16/28-17 file description entries for 7-10 file-control entries for
Index R RESERVE clause buffered cache and for indexed file 6-52 for relative file 6-45 for sequential file 6-35 file type and 6-24 for indexed file 6-48 for line sequential file 6-39, 19-13 for relative file 6-42 for sequential file 6-30 HP COBOL Fast I-O and 6-36 SAME AREA clause and 6-37 sequential block buffering and for indexed file 6-52 for relative file 6-45 for sequential file 6-34 Reserved words description of 3-9 all 21-1/21-11 categories of 21-1 HP COBOL 21-11/21-12 that cannot be split 2-6 RESE
Index S Routines (continued) in CBL85UTL file 13-24, 13-38 in CLULIB file 13-30, 13-85 in COBOLLIB file 13-26, 13-85 in ZCOBSRL file 13-29, 13-38, 13-85 in ZCRESRL file 13-37 operating system See Operating system routines Pascal See Pascal routines pTAL See pTAL routines putting in TNS user library 24-19 Saved Message Utility (SMU) See Saved Message Utility routines TAL See TAL routines utility See Utility routines RUN or RUND command 12-2/12-4 RUNNABLE directive description of 11-107 migrating to native
Index S Scope (continued) of record-names 2-13 of statements 8-8 of user-defined names 2-11 Scratch file MERGE statement and 9-125 SORT statement and 9-230, 9-236 SCRATCH-BLOCK parameter 13-56, 13-63 SCRATCH-CHECK parameter 13-56, 13-64 SCRATCH-FILE parameter description of 13-53 MERGE statement and 9-125 Screen transactions 32-19 SD entries See Sort-merge files, file description entries for SEARCH directive description of 11-112/11-113 migrating to native mode and 33-15, 33-22 Search lists primary adding
Index S Separately compiled programs (continued) sharing files 28-7 UL directive and 11-135 Separators 3-4/3-5 Sequence number 22-43 Sequence number area 16-1 Sequential access mode description of 4-8, 6-25 DELETE statement and 9-46 Sequential block buffering enabled by RESERVE clause 9-190 for indexed files 6-52 for relative files 6-45 for sequential files 6-34 for structured disk files 28-33 Sequential files description of 4-7 access modes of 4-8 closing 9-37/9-40 creating 28-14/28-16 file description e
Index S SIZE ERROR phrase (continued) in ADD CORRESPONDING statement 9-14 in ADD GIVING statement 9-12 in ADD TO statement 9-9 in COMPUTE statement 9-41 Size limits in Extended-Storage Section 7-38 in Working-Storage Section 7-36 list of 20-1/20-4 Skipping lines in output 30-19 to new page 30-20 Slash (/) as arithmetic operator 8-46 in ANSI reference format 16-2 in PICTURE clause 3-24, 7-57, 7-64 in Tandem reference format 2-4 Small data area description of 13-7 LARGEDATA directive and 11-88 UL directive
Index S SPOOLCOM utility description of 30-3, 30-15/30-18 DEV subcommand 30-17 JOB subcommand 30-16 SPOOLCONTROL routine 13-139 SPOOLCONTROLBUF routine 13-139 SPOOLEND routine 13-139 Spooler jobs description of 30-4/30-7 current 30-12 form names for 30-7 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 level 2 protocol for 13-95/13-99 output to description of 30-1, 30-7/30-22 formatting of 30-20/30-21
Index S Statements description of 8-4 arithmetic description of 8-42 common features of 8-43 common semantic rules of 8-21 compiler-directing See Compiler directives conditional 8-6/8-7 delimited-scope 8-7 execution of 8-16 imperative 8-5 nested conditional IF 9-87 delimited-scope IF 9-84 PERFORM 9-160 next executable 8-19 scope of 8-8 summary of 43-1/43-59 types of 8-4 Static calls 23-5 Statistics from Binder 11-29 from compiler 11-29/11-32 Status Key 1 8-29 Status Key 2 8-30 STATUS-3270 message 6-76 STO
Index T SUBTRACT statement description of 9-262/9-268 precision of 8-49 Subtraction operator 8-46 SUBTYPE directive description of 11-128 migrating to native mode and 33-17 Subvolumes to be searched 22-19 SUM function 14-58/14-59 Supervisor process 30-3 SUPPRESS directive 11-129, 22-40 Suppressing zero 3-24 Suspending a process 31-39 Swap file MERGE statement and 9-125 redirecting 6-56 SORT statement and 9-230 SWAP-FILE parameter description of 13-54 MERGE statement and 9-125 Switches, external 9-224, 25-
Index T Tables (continued) implicit FILLER bytes and 4-17 in Data Division 4-12/4-14 in Extended-Storage Section 24-21 multidimensional 7-82, 9-209, 9-212 passed by content 23-22 receive-control 6-70 reply 6-70 variable-size 7-83 TACL commands displaying 22-2 editing 22-4 log of 22-2/22-4 reexecuting 22-3, 22-4 TACL DEFINE file 34-2 TACL DEFINE tool 34-10 TAL routines calling 9-58 in TNS user library 24-19 migrating to native mode 33-4 passing parameters to 9-63, 23-32/23-34 record numbers and 28-17 restr
Index T Tape Utility Program (Tapecom) 27-16, 27-22, 27-24 TAPE-DIALOGUE parameter 12-12 Target file description of 11-28 construction of 11-43 in single program unit compilation 11-10, 11-11 TDS See Tandem Development Suite (TDS) TEC See HP Tandem Extensions for Codewright (TEC) TEDIT editor description of 22-8/22-10 commands of 22-10 customizing 22-10 second window of 22-9 Temporary files names for 26-3 placement of 11-11, 22-21 TERM option of RUN command 25-11, 26-7 Terminals ACCEPT statement and 29-2/
Index U TNS user library (continued) routines that can go in 24-19/24-20 specifying 24-9 TNSMISALIGN attribute (SCF) 33-8 TNS/R native mode 1-3 Toggles in ENDIF directive 11-71 in IF and IFNOT directives 11-84, 11-86 in RESETTOG directive 11-106 in SETTOG directive 11-115 Tracing facility 33-7/33-8 Transactions description of 32-15/32-16 screen 32-19 Transfer of control explicit 8-18 implicit 8-18 in PERFORM statement 9-159 in SIZE ERROR or NOT SIZE ERROR phrase 8-26 Transfer Tool 34-11 Trap 1 33-9 Trap 2
Index V USE statement description of 9-283/9-291 migrating to native mode and 33-14 User code space description of 13-6 COBOLLIB routines in 13-28 User data space description of 13-6 LARGEDATA directive and 11-88 User extended space description of 13-7 LARGEDATA directive 11-88 User library description of 13-8, 13-9 migrating to native mode and 33-16 native See Native user library specifying 13-10 TNS See TNS user library User library space description of 13-6 COBOLLIB routines in 13-28 User-defined names
Index W VARIANCE function 14-62/14-63 VARYING phrase 7-31 Verbs description of 9-1/9-305 imperative 8-5 Vertical spacing 30-18/30-20 Virgule (/) See Slash (/) Virtual memory 31-2 Visual Inspect debugger description of 15-4 on PC 34-8/34-10 Visual Studio .
Index Special Characters Special Characters 8-45/8-48, 8-54/8-57, 13-23/13-24, 13-26/13-29, 13-29/13-30, 13-31/13-36, 16-1/16-4 ! See Exclamation mark (!) #DYNAMIC special name description of 26-8 ASSIGN command and 26-9 in OSS environment 19-25 #IN special name description of 26-6 in OSS environment 19-11 #OUT special name description of 26-7 in OSS environment 19-11 #RECEIVE blocks 11-24/11-25 #TEMP special name 26-8, 28-43 #TERM special name 26-7 $ See Dollar sign ($) $0 opening 13-77 sending events to
Index Special Characters HP COBOL Manual for TNS and TNS/R Programs —522555-006 Index -62