HP COBOL Manual for TNS/E Programs HP Part Number: 520347-011 Published: April 2014 Edition: H06.08 and subsequent H-series RVUs and J06.
© Copyright 2014 Hewlett-Packard Development Company, L.P. Legal Notice Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor’s standard commercial license. The information contained herein is subject to change without notice.
Contents About This Document...................................................................................25 Supported Release Version Updates (RVUs)................................................................................25 Intended Audience..................................................................................................................25 Acknowledgment....................................................................................................................
Shared Files......................................................................................................................57 3 Language Elements...................................................................................59 COBOL Character Set.............................................................................................................59 Punctuation Characters............................................................................................................
File Description Entries......................................................................................................155 Sort-Merge File Description Entries......................................................................................173 Data Description Entries....................................................................................................175 Working-Storage Section.......................................................................................................
Operand Identification.....................................................................................................242 Overlapping Operands....................................................................................................243 Common Phrases..................................................................................................................243 CORRESPONDING Phrase...............................................................................................
FREE...................................................................................................................................333 GO TO ..............................................................................................................................334 Unconditional GO TO......................................................................................................334 Conditional GO TO...............................................................................................
USE DEBUGGING...........................................................................................................484 USE AFTER EXCEPTION....................................................................................................484 WRITE.................................................................................................................................487 WRITE for Sequential Files.................................................................................................
ENDIF............................................................................................................................549 ENDUNIT.......................................................................................................................549 ERRORFILE......................................................................................................................549 ERRORS................................................................................................................
ADD DEFINE Command...................................................................................................596 Initial State..........................................................................................................................596 Status of Internal Entities During Program Execution...................................................................597 Status of External Entities During Program Execution..................................................................
DAY-OF-INTEGER Function.....................................................................................................665 FACTORIAL Function.............................................................................................................666 INTEGER Function.................................................................................................................666 INTEGER-OF-DATE Function................................................................................................
17 HP Extensions to ISO COBOL.................................................................705 Source Program Organization and Format...............................................................................705 Language Elements...............................................................................................................705 Data Fundamentals...............................................................................................................706 Environment Division.........
H...................................................................................................................................736 I....................................................................................................................................736 J....................................................................................................................................737 K.....................................................................................................
Including Text From a COPY Library........................................................................................762 Simple Copying...............................................................................................................762 Copying With Replacement...............................................................................................763 Replacing Substrings........................................................................................................
25 Executing and Debugging HP COBOL Programs......................................820 Preparing to Execute an HP COBOL Program...........................................................................820 Adding DEFINEs..............................................................................................................820 Overriding File Assignments Made at Compilation Time........................................................821 Specifying Characteristics of Files That a Program Creates.........
Fixed-Length and Variable-Length Records...........................................................................859 Exclusion Modes..............................................................................................................859 Time Limits......................................................................................................................860 Reading Files From Called Programs...................................................................................
Getting Break Ownership......................................................................................................893 Transferring Break Ownership................................................................................................894 Communicating With an Operator or Process...........................................................................895 Writing to a Console........................................................................................................
Process Pairs...................................................................................................................946 Checkpointing.................................................................................................................948 Using the Fault-Tolerant Facility..........................................................................................949 Designing Programs for the Fault-Tolerant Facility..................................................................
CODECOV..........................................................................................................................981 COLUMNS..........................................................................................................................982 COMPILE.............................................................................................................................982 CONSULT and NOCONSULT.........................................................................................
Reference Format................................................................................................................1003 TANDEM......................................................................................................................1004 ANSI............................................................................................................................1004 38 Language Elements and Expressions.....................................................1006 COBOL Character Set...
43 Procedure Division..............................................................................1051 ACCEPT With Mnemonic-Name............................................................................................1054 ACCEPT With DATE, DAY, DAY-OF-WEEK, or TIME Phrase.......................................................1054 ADD TO............................................................................................................................1055 ADD GIVING...............................
REWRITE for Sequential, Relative, Indexed, and Queue Files....................................................1082 SEARCH VARYING.............................................................................................................1082 SEARCH ALL......................................................................................................................1083 SET TO for Pointer Data Items...............................................................................................
RANDOM.........................................................................................................................1098 RANGE.............................................................................................................................1098 REM.................................................................................................................................1098 REVERSE.....................................................................................................
B Data Type Correspondence....................................................................1234 Index.....................................................................................................
About This Document This publication describes the HP implementation of the 1985 version, and portions of the 2002 version, of the COBOL language. It includes information on the ECOBOL compiler (T0356) and program execution, task-oriented information to help an experienced COBOL programmer use HP COBOL for NonStop™ systems, and summaries of compiler and run-time error messages. Supported Release Version Updates (RVUs) This publication supports H06.08 and all subsequent H-series RVUs and J06.
• Added information on the allowed size of records for disk files in “SORT” (page 441). • Updated the information on the sum of the lengths of the keys limit in “Size” (page 726). • Updated the information on how larger partitioned files can be than non-partitioned files in “Partitioned Files” (page 856). • Updated the maximum prime record key length, alternate record key length, and logical record length limits allowed for key-sequenced (indexed) files in Table 123 (page 862).
Tool (page 525). Under that section and CODECOV (page 542), placed a reference to the caution in the Debugging section. • Added new intrinsic functions, TEST-NUMVAL and TEST-NUMVAL-C, to Chapter 14: Intrinsic Functions (page 655).
Document Organization Table 1 Summary of Contents Chapter Description Chapter 1: Introduction (page 38) Introduces the HP COBOL for NonStop systems (HP COBOL) language and explains how to use it to create TNS/E native processes. Chapter 2: Source Program Organization and Format (page 43) Describes how to organize and format a source program into a reference format that the compiler accepts.
Table 1 Summary of Contents (continued) Chapter Description Chapter 22: Creating and Compiling Describes various methods of creating and compiling HP COBOL source HP COBOL Source Programs (page 745) programs for the Guardian environment, primarily. Chapter 23: Calling Other Programs and Routines (page 794) Describes mixed-language programs, which are HP COBOL program that call one or more non-COBOL routines and non-COBOL programs that call one or more COBOL programs.
Table 1 Summary of Contents (continued) Chapter Description Chapter 41: Environment Division (page 1021) Describes the syntax of the environment division. Chapter 42: Data Division (page 1039) Describes the syntax of the data division. Chapter 43: Procedure Division (page 1051) Describes the syntax of the procedure division. Chapter 44: Intrinsic Function Calls (page 1093) Lists and describes intrinsic function calls.
Syntax Diagram Conventions This manual presents syntax in railroad diagrams. Here is a generic railroad diagram: To use a railroad diagram, follow the direction of the arrows and specify syntactic items as indicated by the diagram pieces: Diagram Piece Meaning Type KEYWORD as shown. You can type letters in uppercase or lowercase. Replace item with a value that fits its description, which follows the syntax diagram. Type content (punctuation mark, symbol, or letter) as shown.
Diagram Piece Meaning Specify item one or more times, separating occurrences with commas. Specify item at most n times. NOTE: To refer to a particular railroad diagram or figure when giving feedback to HP, use the number at the bottom right corner of that railroad diagram or figure (for example, VST742.vsd). Spacing rules are: • If the arrow between two diagram pieces is labelled “ns,” put no spaces between the syntactic items that they represent.
MULTIPLY34 • If two diagram pieces are separated by a separator character, separating the syntactic items that they represent by spaces is optional. For example: 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: means that you can type: END PROGRAM SORT. or END PROGRAM SORT .
Example 1 Code Example Without Ellipsis (...) WORKING-STORAGE SECTION. 01 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". 05 FILLER PICTURE X(9) VALUE "October".
Table 2 HP Manuals to Which This Manual Refers (continued) Data Definition Language (DDL) Reference Manual Describes the Data Definition Language (DDL), with which you can create COPY and SOURCE libraries for your HP COBOL program. DLL Programmer’s Guide for TNS/E Systems Explains position-independent code (PIC) and dynamic-link libraries (DLLs). EDIT User’s Guide and Reference Manual Explains how to create and modify source files.
Table 2 HP Manuals to Which This Manual Refers (continued) Open System Services Shell and Utilities Reference Manual Describes the syntax and semantics of each command that you can enter interactively to access the OSS command interpreter (the OSS shell), and utilities and other functions that perform general-purpose and program-development operations (intended for all audiences).
Publishing History Part Number Product Version Publication Date 520347-003 ECOBOL H01 HP Enterprise Toolkit—NonStop Edition (ETK) PC COBOL H01 July 2005 520347-004 ECOBOL H01 HP Enterprise Toolkit—NonStop Edition (ETK) PC COBOL H01 November 2006 520347-005 ECOBOL H01 HP Enterprise Toolkit—NonStop Edition (ETK) PC COBOL H01 August 2009 HP Encourages Your Comments HP encourages your comments concerning this document. We are committed to providing documentation that meets your needs.
1 Introduction This manual describes the HP COBOL for NonStop systems (HP COBOL) language and explains how to use it to create TNS/E native processes. (The COBOL Manual for TNS and TNS/R Programs explains how to use the HP COBOL language to create TNS processes and TNS/R native processes.) SPR Requirements for Increased Enscribe Limits for the H06.28/J06.17 Release As of H06.28 and J06.
1989:2002. HP offers high-level standard COBOL 1985, portions of standard COBOL 2002, and HP extensions.
Summary of Execution Modes TNS/E systems support three execution modes: TNS Mode Accelerated Mode TNS/E Native Mode Programs are generated by TNS compilers. Programs are generated by TNS Programs are generated by TNS/E compilers and then processed by the native compilers. TNS Object Code Accelerator (OCA). Programs use TNS process and memory architecture. Programs use TNS process and memory architecture. Programs use TNS/E native process and memory architecture.
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 • These COBOL external declarations files, which are used in resolving references to
You can combine multiple object files in a single loadfile only if the multiple object files are either all TNS object files, all TNS/R native object files, or all TNS/E native object files. Executing Loadfiles You can execute loadfiles for these environments: Guardian Environment From ... Use ... For more information, see ...
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.
program-name is a COBOL word. It names the same program unit that the PROGRAM-ID does (see PROGRAM-ID Paragraph (page 98)), 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. Tandem reference format, an HP extension to COBOL, is less restrictive than ANSI.
Table 7 Valid Indicator Area Characters (Tandem Reference Format) (continued) Character Character Name Meaning and Topic Name d Lowercase d Debugging Line (D or d) - Hyphen Continuation Line (-) Space Text Line Compiler Directive (?) A compiler directive has a question mark (?) in the indicator area. A compiler directive is an instruction to the compiler (for more information on compiler directives, see Compiler Directives (page 533)).
Example 3 Continuation Line in Tandem Reference Format ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 DISPLAY "THIS IS AN EXAMPLE OF CONTINUING A LITERAL " IN TANDEM REFERENCE FORMAT." Text Line The compiler handles any line that begins with a space character as a program text line.
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.
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.
Figure 2 Directly Contained Programs and Indirectly Contained Programs 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 user-defined 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).
These rules regulate the scope of a program-name: • If the program-name, X, is that of a program that does not have the common attribute and is directly contained within another program, Y, then only statements included in Y can refer to X.
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 index-name 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. Common Programs A common program is one that includes the COMMON clause in its Identification Division.
The program makes them accessible to the other programs by declaring them to be external. Any other program in the run unit can use them by likewise declaring them to be external. (The opposite of external is internal. Internal objects are only accessible to the program that declares them—or, if they have global names, to programs within that program—and only one program can declare them.
to an external object from different programs are always to the same object. In a run unit, there is only one representation of an external object. External and internal objects can have either global or local names. Data Records in Working and Extended-Storage To give a data record described in the Working-Storage or Extended-Storage Section the external attribute, include the keyword EXTERNAL in its data description entry. Only record data description entries can include the EXTERNAL clause.
Example 4 Programs With Shared Data * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * _______________________________________________________________________ | Program: Mane | | Data: w (local to Mane) | | y (global throughout Mane and its descendants) | | z (global throughout Mane and its descendants, and external) | | Can call: Aaa, Bbb because both are directly contained | | ________________________________________________________________
* 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. DISPLAY "Mane begin" MOVE 25 to z PERFORM show-me CALL Aaa PERFORM show-me CALL Bbb PERFORM show-me CALL Sub PERFORM show-me CALL Sub PERFORM show-me DISPLAY "Mane end" stop run . show-me. DISPLAY "in Mane, w=/" w "/ y=/" y "/ z=/" z "/" .
PROGRAM-ID. Ccc. DATA DIVISION. WORKING-STORAGE SECTION. 01 w PICTURE 99 EXTERNAL. 01 y PICTURE 99 VALUE 0. PROCEDURE DIVISION. c. DISPLAY " Ccc begin" PERFORM show-me DISPLAY " Ccc adding 4 to w, x, and y" ADD 4 to w x y PERFORM show-me CALL Ddd DISPLAY " Ccc end" EXIT PROGRAM . show-me. DISPLAY " in Ccc, w (ext)=/" w "/" " x (global from Bbb)=/" x "/" " y (local in Ccc)=/" y "/" . IDENTIFICATION DIVISION. PROGRAM-ID. Ddd. DATA DIVISION. PROCEDURE DIVISION. d.
Example 5 Output From Programs With Shared Data Mane begin in Mane, w=/03/ y=/01/ z=/25/ Aaa begin y (global from Mane)=/01/ z (global from Mane)=/25/ Aaa adding 2 to y y (global from Mane)=/03/ z (global from Mane)=/25/ Bbb begin in Bbb, w (ext)=/01/ x (global in Bbb)=/00/ y (global from Aaa)=/03/ Bbb adding 3 to w and to x in Bbb, w (ext)=/04/ x (global in Bbb)=/03/ y (global from Aaa)=/03/ Ccc begin in Ccc, w (ext)=/04/ x (global from Bbb)=/03/ y (local in Ccc)=/00/ Ccc adding 4 to w, x, and y in Ccc, w
• 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.
Figure 4 COBOL Character Set Table 9 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 10 Punctuation Characters Character Name of Character Space , Comma ; Semicolon : Colon .
Table 11 Special Characters (continued) Character Name of Character > Greater than sign < Less than sign Except in nonnumeric literals, the compiler handles lowercase letters as equivalent to the corresponding uppercase letters.
a comma, semicolon, or period separator as part of that separator and not as a distinct space separator. 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.
an exception exists if the apparent last character of such a character-string is a period or comma immediately followed by a space. In this case, the period or comma is always interpreted as part of the separator following the character-string, and not as the last character of the numeric literal or PICTURE character-string.
Figure 5 COBOL Words in a Source Program The same COBOL word can be used as a system-name and as a user-defined name within a source program. The class of a specific occurrence of the word is determined by context. 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).
Table 12 Reserved Word Categories (continued) Category Definition Examples Figurative constants Words that name and reference constant values SPACE ZERO Special-character words Required arithmetic and relational operators, used in arithmetic expressions and relation conditions, respectively + * / ** = < > <= >= * LINE-COUNTER and PAGE-COUNTER are associated with the Report Writer and are not available in HP COBOL. For a list of all reserved words, see Chapter 21: Reserved Words.
names. HP COBOL relaxes this restriction. The use of each particular system-name is limited to contexts appropriate for its category. The few minor restrictions on duplicate usages of system-names are discussed in SPECIAL-NAMES Paragraph. In HP COBOL, system-names are either resource names or file names in the form used by the operating system.
An OSS file name identifies one of these: ◦ Disk file ◦ Special file name (such as a temporary disk file) For details on OSS file names, see Files in the OSS Environment (page 713)Files in the OSS Environment.
Qualified Condition-Name: Qualified Data-Name: Qualified Paragraph-Name: Qualified Text-Name: Qualified LINAGE COUNTER: Within the Data Division, you can use file-names from file description (FD) or sort-merge file description (SD) entries and data-names from data description entries for qualification.
• If a word defined as a status condition-name is assigned to more than one element in a source program, the condition-name must be qualified by the mnemonic-name of its external switch each time it is mentioned in the Procedure Division. The qualification of status condition-names is an HP COBOL extension. • A word can be defined as a paragraph-name more than once in a source program.
• Do not associate two identical condition-names with the same data item. If a word used as a condition-name is also used to identify another program element, then it can be referenced if and only if the associated data item can be referenced. • Do not define two identical status condition-names within the same system-name clause of the SPECIAL-NAMES paragraph.
Decimal numeric literals follow these rules: • When a decimal numeric literal appears in a context where its value is assumed to be a sequence of characters, its size is equal to the number of digits in its representation. • A sign character (+ or -) has no effect on the size of a literal. Absence of a sign signifies a positive number.
Example 9 Hexadecimal Numeric Literals H"00" H"0F" H"0123456789ABCDEF" H"1003c55b" Simple Nonnumeric Literals A simple nonnumeric literal is a character-string that has the value of the sequence of its characters. 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.
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.
In general, you can use a national literal anywhere you can use a nonnumeric literal. Exceptions are: • A national literal cannot be compared to a nonnumeric or numeric literal or to a data item not defined as national. Compare national literals only to other national literals or national data items.
associated data item. This happens prior to and independently of the application of any JUSTIFIED clause for the data item. • When you use a figurative constant whose source form does not include the word ALL with a DISPLAY, STRING, STOP, or UNSTRING statement, the compiler generates exactly one character.
PICTURE Character-Strings PICTURE character-strings (character-strings in the PICTURE clause) use the COBOL character set as described in PICTURE Clause (page 191). The editing characters in Table 14 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. In all other places, these characters follow the rules for character-strings and separators.
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.
• Files • Tables Level-Numbers Level-numbers show the relationship of elementary data items to data structures. Level-Number Describes ... 01 through 49 A record (whose level-number starts at 01) and its subordinate data items (whose level-numbers are higher, but not necessarily successive). 66 An elementary item or a data structure introduced by a RENAMES clause. Use level-66 entries to regroup data structures.
01 15 PART-TIME 15 FULL-TIME 10 EXEMPT ... MISC-RECORD. ... PICTURE 99. PICTURE 99. PICTURE 9(4). 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 (page 191)). 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.
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. Consequently, a record is a series of elementary items, or the record itself can be an elementary item.
The OCCURS clause with a DEPENDING ON phrase defines a variable-size table. For more information, see OCCURS Clause for Variable-Size Tables (page 214). Files A file is the highest structural form. Each file is a collection of records, ordered by the file’s organization or by record attributes (keys), and maintained upon some storage medium. Use of the record structure is not limited to files; individual records can exist independently of files. In COBOL, a file is a group of records.
Table 16 File Organization (continued) Organization Description operation by providing the value of its relative record number. Because a program can fill or empty individual record areas independently, without regard to the presence or absence of logical records in any of the other areas, any combination of record areas can be full or empty at any given time in the file’s existence. Under the NonStop operating system, COBOL relative files are relative files.
Table 17 Relationship Between File Organization and Access Mode (continued) Access Mode File Organization Sequential Queue Random Dynamic or alternate record key value (record keys are fields within each record). If records with duplicate alternate key values exist, the order of retrieval is either by prime key or by date of entry. To specify that retrieval order is by date of entry, set a file attribute with FUP.* NEXT statements) or randomly (with READ statements).
Exclusion Mode In HP COBOL, you specify a file’s exclusion mode when you open it (see OPEN (page 375)). Table 19 Exclusion Modes Mode Other Processes Can Read File Other Processes Can Write to File Shared Yes Yes Protected Yes No Exclusive No No File Connector A COBOL program makes reference to files indirectly. It does not refer to a file by the file’s Guardian file name.
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. The item is a table element, and the item’s name and description apply to each repetition of the element. A table is a data structure composed of one or more occurrences of a specified data item. The repeated data item is called a table element.
Example 15 One-Dimensional Table With Variable Number of Elements WORKING-STORAGE SECTION. 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. Multidimensional Tables The elements of a table can be elementary items or groups of subordinate structures, some of which can also be tables. In Example 16, TOTAL-B is a table subordinate to the 1-dimensional table named TOTAL.
alignment considerations cause the compiler to allocate unused bytes between data items. These bytes are called implicit FILLER bytes (see Implicit FILLER Bytes). Data Alignment in Receiving Items Not all data storage locations in a COBOL program are the same size.
The compiler aligns a data item according to its size if one of these conditions is true: • The data item is described as USAGE BINARY or USAGE COMPUTATIONAL and the PORT directive is not specified. • The data item is described as USAGE NATIVE-n. • The data item is described with a SYNCHRONIZED clause. A data item that is aligned according to its size is usually aligned on a character position that is divisible by 2. This is not a TNS/E word size, but this alignment preserves data compatibility.
Tables When an elementary data item is described with an OCCURS clause, is subordinate to a data structure described with an OCCURS clause, or both, all occurrences of the data item must be aligned uniformly: 1. The first occurrence of the item is aligned to the required storage boundary. If the elementary item also begins a containing table’s first occurrence, that table’s first occurrence is defined to begin at the first character position of the item. 2.
To make references unique, you can use qualifiers, subscripts, and reference modifiers. A data-name made unique by a combination of qualifiers, subscripts, and reference modifiers is called an identifier. If an item in a record is tested frequently by a program, assigning a condition-name to the item is a convenient way to refer to the item and show the significance of the item’s value. Assigning a condition-name to the item is also good programming practice.
condition-name is a level-88 item associated with either a data item described with an OCCURS clause or a data item subordinate to a data item described with an OCCURS clause. If condition-name is qualified, the subscripts follow the qualifiers. subscript integer is a nonzero numeric literal. If it is signed, the sign must be positive. qualified-name is the identifier of an integer numeric data item. It can be qualified, but cannot have subscripts or reference modifiers.
Topics: • Reference Modifier Syntax • Rules for Reference Modifiers Reference Modifier Syntax identifier is the name of a data item with USAGE DISPLAY. If it is qualified or subscripted, the reference modifier appears after the qualifiers or subscripts. leftmost-character-position is an arithmetic expression. Its value must be a positive nonzero integer less than or equal to the number of characters in identifier; it represents the leftmost character of the portion of identifier you are selecting.
• Reference modifiers create a unique data item, which is a substring of the data item referenced by identifier. The program handles this unique data item as an elementary data item without the JUSTIFIED clause. When identifier references an alphabetic data item, the unique data item has the class and category alphabetic. When identifier references a data item of any other category, the unique data item has the class and category alphanumeric.
qualified-name is defined in Qualified Names (page 67). 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. Its value must be a positive, nonzero integer; it represents the size of the portion of data-name you are selecting.
88 RESTRICTED-USE VALUES ARE 1, 2. SET RESTRICTED-USE TO TRUE The SET statement sets USE-CODE to the value 1, the first value in the list.
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 DATE-COMPILED paragraph, whose presence causes the compiler to report the compilation time and date in the listing.
comment-entry is any combination of characters from the ASCII character set. The first keyword following a comment-entry must start on a program text line that has a space character in its indicator field. This keyword must start in area A and be preceded by space characters only. A comment-entry cannot be continued with the hyphen convention; however, it can be implicitly continued onto additional program text lines if area A of those lines contains space characters only.
Example 22 Identification Division With Obsolete Paragraphs IDENTIFICATION DIVISION. PROGRAM-ID. MYPROG AUTHOR. JANE DOE INSTALLATION. HEADQUARTERS DATE-WRITTEN. JANUARY 20, 1992 DATE-COMPILED. JANUARY 21, 1992 SECURITY. COMPANY CONFIDENTIAL Example 23 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.
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. When a program declares very large data items that do not have initial values assigned, including a NOBLANK directive in the compilation saves significant amounts of compilation time, object program storage space on disk, and run-time initialization time.
where: Number Range Represents yy 00 through 99 Year mm 01 through 12 Month dd 01 through 31 Day hh 00 through 23 Hour ss 00 through 59 Second Example 24 DATE-COMPILED Paragraph Source text: DATE-COMPILED. This is the final version. Listing text: DATE-COMPILED.
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.
SOURCE-COMPUTER paragraph is defined in SOURCE-COMPUTER Paragraph. OBJECT-COMPUTER paragraph is defined in OBJECT-COMPUTER Paragraph. SPECIAL-NAMES paragraph is defined in SPECIAL-NAMES 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. name is any sequence of ASCII characters except WITH, DEBUGGING, or MODE. It names the computer system on which the program is compiled.
name is any combination of character-strings except reserved words and separators (except period (.)). It is handled as a comment. MEMORY-SIZE clause NOTE: The 1985 COBOL standard classifies the MEMORY-SIZE clause as obsolete, so you are advised not to use it. is checked for proper syntax but otherwise ignored. For more information, see MEMORY-SIZE Clause. PROGRAM COLLATING SEQUENCE clause specifies a collating sequence for use in nonnumeric comparisons.
WORDS, CHARACTERS, MODULES are ignored. 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).
character-set-type Alphabets ESPANOL Spanish FRANCAIS-AZ French (AZERTY keyboard) FRANCAIS-QW French (QWERTY keyboard) SVENSK-SUOMI Swedish, Finnish UK United Kingdom USASCII United States ASCII In COBOL, this clause affects only the ALPHABETIC-UPPER, ALPHABETIC-LOWER, and ALPHABETIC tests. In SCREEN COBOL, the CHARACTER-SET IS clause has some additional semantics, including terminal configuration (see the Pathway/TS SCREEN COBOL Reference Manual).
National literals and national data items cannot be used in the SPECIAL-NAMES paragraph. Topics: • System-Name Clause • File-Mnemonic Clause • ALPHABET Clause • SYMBOLIC CHARACTERS Clause • CLASS Clause • CURRENCY SIGN Clause • DECIMAL-POINT Clause System-Name Clause 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: The operator console that CONSOLE specifies is $0, an output-only device. If you post an ACCEPT to this device, a run-time error occurs. mnemonic-name is a name you choose for the hardware device, carriage-control tape channel, or external switch specified by system-name.
Usage Considerations: • System-Name Clause Without a STATUS Phrase When 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 ◦ system-name is CONSOLE When system-name is CONSOLE, the System-Name clause assigns a mnemonic-name to the operator console.
You can give a mnemonic-name to the switch itself, but you must declare at least one STATUS phrase for the switch because only the condition-name of the STATUS phrase can be used for testing within the program. The mnemonic-name has no purpose other than to qualify the condition-name. You can code either the ON STATUS or the OFF STATUS phrase first, but you can use only one of each phrase for each system-name. Example 25 ON STATUS Phrase SPECIAL-NAMES.
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. file-mnemonic is a name you choose as an alias for the operating system file name or (in the Guardian environment) the DEFINE name. You can use it in ACCEPT, CALL, DISPLAY, and ENTER statements.
literal-1, literal-2, literal-3 are unsigned integer literals or nonnumeric literals, but not symbolic-character figurative constants. An unsigned integer literal must have a value in the range 1 through 256. It 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). A nonnumeric literal is an actual character or set of characters in the computer’s character set.
The relative order within the set of these unspecified characters is unchanged from their order in the collating sequence. • 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 (page 257). For information on sorting, see SORT (page 441).
CLASS Clause The CLASS clause defines classes other than the NUMERIC, ALPHABETIC, ALPHABETIC-UPPER, and ALPHABETIC-LOWER that the COBOL language defines. class-name is referenced in the program as a class-condition (see Class Conditions (page 269)). literal-phrase specifies a string of characters (literal-1 ) or a range of characters (literal-1 through literal-2 ) that make up the class you are defining.
Example 27 Defining a Class of Special Characters CLASS SPEC-CHAR IS 1 THRU 32 OCT IS "0" THRU "7" CLASS SPEC-CHAR IS 32 THRU 1 Example 28 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.
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. You connect the names in file-control entries in the Input-Output Section.
description entry (with a level indicator of FD) or sort-merge file description entry (with a level indicator of SD). A file-control entry connects an operating system file name to a COBOL file name, specifies the file’s organization and keys, and gives other information needed for input and output. For information about Guardian file names, see the Guardian Procedure Calls Reference Manual. For information about OSS file names, see Files in the OSS Environment (page 713).
Table 24 Descriptions of File-Control Entry Clauses (continued) Clause Description in a file description entry or sort-merge file description entry must also be in a SELECT clause. ASSIGN Associates the file name used within the program with an operating system file. The operating system file name is the one the operating system uses to refer to the file. ORGANIZATION Specifies the logical structure of a file, which was established when the file was created and which you cannot change.
1985 ISO/ANSI COBOL standard specifies insertion order, but HP COBOL provides a mechanism to enable you to choose either order. 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.
SELECT clause OPTIONAL makes the file optional, which means that an OPEN statement with an INPUT 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. When you open a nonexistent optional file for input, the first READ statement for that file uses the AT END option (or USE procedure if the READ statement has no AT END phrase).
quotation marks unless it forms a COBOL word. For more information about operating system file names, see the Guardian Procedure Calls Reference Manual. define-name-literal is allowed only in the Guardian environment. It is a nonnumeric literal representing a DEFINE name of class MAP, SPOOL, TAPE, or TAPECATALOG. Quotation marks must enclose define-name-literal. For more information about DEFINE names, see DEFINEs (page 593).
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. pad-char is either a nonnumeric literal that represents a single character, or a qualified or unqualified name that references an alphanumeric data item whose value is a single character.
DUPLICATES means that alternate key values are not necessarily unique. FILE STATUS clause defines filestat as the file-status data item for the file. When a COBOL run-time 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 (page 247)). filestat is a 2-character alphanumeric, nonnational data item defined in the Working-Storage Section, Extended-Storage Section, or Linkage Section.
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. An alt-key is permitted only for structured disk files and not for unstructured disk files or files that are not disk files. A file having a LINAGE clause in its file description cannot be a disk file (although it can be spooled to a printer by way of a disk).
nonaudited files can use buffered cache or write-through cache under DP2. Write-through cache transfers each record to the disk as it is written. You can use the File Utility Program (FUP) commands SET and ALTER to set the BUFFERED attribute for a file, specifying that any programs that open that file must use buffered cache.
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. If the file is not entry-sequenced, the file is unusable. An auxiliary block buffer can be shared by two files in a program as long as both are not open at the same time. The space is allocated as part of the open operation and deallocated as part of the close operation.
SELECT clause 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. When you open a nonexistent optional file for input, the first READ statement for that file uses the AT END option (or USE procedure if the READ statement has no AT END phrase).
FILE STATUS clause defines filestat as the file-status data item for the file. When a COBOL run-time 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 (page 247)). filestat is a 2-character alphanumeric, nonnational data item defined in the Working-Storage Section, Extended-Storage Section, or Linkage Section.
file-name is the COBOL file-name (the file-name in a file description entry). ASSIGN clause associates file-name with system-file-name or define-name-literal. Only the first system-file-name or define-name-literal has meaning. The compiler ignores subsequent names and literals and issues a warning. system-file-name is either the name of a disk file or the special file name #DYNAMIC or #TEMP.
ORGANIZATION clause makes the organization of the file relative. (The default is sequential.) ACCESS MODE clause SEQUENTIAL makes the access mode of the file sequential (the default). That means the records of the file are to be operated upon as if they were sequentially organized. RANDOM makes the access mode of the file random. That means the records of the file are to be operated upon in any order, as selected by the current value of the relative key or an alternate key.
alt-key is an alphanumeric or unsigned numeric data item declared in the record description entry of the file. It is used to access records within the file. Its size and location must agree with the size and location of the alternate key within the file, defined when the alternate key file was established by the Guardian environment File Utility Program (FUP). (For information about FUP, see the File Utility Program (FUP) Reference Manual.
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. • Sequential Block Buffering Sequential block buffering, enabled by the RESERVE clause when the file is open in INPUT or I-O mode, is discussed under File-Control Entries for Sequential Files.
SELECT clause 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. When you open a nonexistent optional file for input, the first READ statement for that file uses the AT END option (or USE procedure if the READ statement has no AT END phrase).
define-name-literal is a nonnumeric literal that represents the name of a DEFINE of class MAP that is associated with a disk file. Quotation marks must enclose any DEFINE name. For information about DEFINE names, see DEFINEs (page 593). RESERVE clause 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.
DYNAMIC makes the access mode of the file dynamic. That means the records of the file are accessible by either sequential or random access; you can position the file with START to a certain key value and read or write sequentially from there. The default access mode is sequential. RECORD KEY clause rec-key is an alphanumeric or unsigned numeric data item defined in the record description entry for the file. It is the prime key for accessing records within the file.
Usage Considerations: • Record Key The data description entry for reckey cannot contain an OCCURS clause. • Alternate Record Keys The records within the file can be accessed in ascending order of the alt-key value. The order in which records are obtained using alt-key can differ from the order obtained using reckey. You can define up to 31 alternate keys for a file.
Example 31 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). 05 INVOICE-DATE PICTURE 9(6).
SELECT clause sd-name is a COBOL file-name (the file-name in a sort-merge file description entry). ASSIGN clause associates the COBOL file-name (sd-name ) with a file designated by system-file-name, or define-name-literal. Only the first system-file-name or define-name-literal has meaning. The compiler ignores subsequent ones and issues a warning. system-file-name is the name of a disk file that the file system recognizes.
Example 32 File-Control Entry for Sort-Merge File INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT SORT-FILE ASSIGN TO "#TEMP". ... DATA DIVISION. FILE SECTION. SD SORT-FILE RECORD CONTAINS 40 CHARACTERS. 01 SORT-FIELDS. ... I-O-CONTROL Paragraph The optional I-O-CONTROL paragraph specifies positioning information for a tape file or the sharing of a memory area by more than one file.
rerun-file, system-name, units, condition are handled as comments. rerun-file-2-phrase is handled as a comment. SAME AREA clause 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.
specifies a multiple-file tape reel. For more information on multiple files, see MULTIPLE FILE Clause. tape-file is the name of a sequential file on magnetic tape, defined in a file-control entry and a file description entry. position is a numeric literal with a value of 1 or more. It defines the relative position of tape-file on a tape.
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.
AREA or SAME MERGE AREA clauses, then all of the files named in that SAME AREA clause must also be named in each of the affected SAME SORT AREA or SAME MERGE AREA clauses.
position is an integer data item whose value is the ordinal number of a file on the tape. The first file on the tape has position 1; the second, position 2; and so on. For information on multiple-tape format, see the Guardian Programmer’s Guide. RECEIVE-CONTROL Paragraph You can write server processes in HP COBOL.
EXTERNAL enables COBOL external files to share communication with $RECEIVE. EXTERNAL causes the compiler to create a special block, #RECEIVE, which contains the information used when $RECEIVE is opened by a COBOL external file. TABLE OCCURS phrase establishes the length of the receive-control table, governing the maximum number of requesters that can have this process open concurrently. In a Pathway environment, this number can be decreased at execution time but not increased.
establishes the length of the reply table, controlling how many replies are saved for each requesting process (opener). sync-id is an unsigned integer numeric literal in the range 1 through 255. In any requester process that opens the server process, the value in the SYNCDEPTH phrase of the OPEN statement cannot exceed sync-id. When you do not use the SYNCDEPTH LIMIT phrase, sync-id defaults to 1. A Pathway server never needs a SYNCDEPTH LIMIT greater than 1.
• 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 successfully read. REPORT phrase specifies the type of system messages to be passed to the program.
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.
Figure 6 Reply Table Reply messages saved in the reply table are identified by their requester process. These messages correspond to and answer the specific requester. For example, if REQUESTER PROCESS 3 in Figure 6 failed before it received REPLY MESSAGE 5, and its backup reissued the request based on the checkpoint information, the COBOL fault-tolerant facility would recognize that the request was performed. It would reissue REPLY MESSAGE 5 to REQUESTER PROCESS 3 without re-executing the request.
When you use ERROR CODE error, but the server is not executing a WRITE for each READ on $RECEIVE, the system acknowledges each message from a requester and also passes the value of error with each internal reply. If you take this approach, be careful to have the right value in error at all times. The operating system also returns the value of error with explicit or system-generated replies to reported system messages (system messages are reported when the REPORT message-type MESSAGES option is used).
Table 28 Message Types That the Program Generates (System) COBOL Keyword Message-Type Code ABEND Not used—see Table 30 CLOSE -104 CONTROL -32 CONTROLBUF -35 MEMORY-LOCK-COMPLETION -23 MEMORY-LOCK-FAILURE -24 NEWPROCESSNOWAIT-COMPLETION -12 OPEN -103 RESETSYNC -34 SETMODE -33 STOP Not used—see Table 30 TIME-SIGNAL -22 Messages generated by asynchronous hardware events must be explicitly requested.
Table 30 REPORT Clause Message Types Message Type Message Type Code Meaning BREAK -20 Break on device CLOSE -31 Close CONTROL -32 CONTROL system request CONTROLBUF -35 CONTROLBUF system request CPU-DOWN -02 Local processor failure CPU-UP -03 Local processor reload DEVICE-INFO -40 Device type inquiry DEVICEINFO2-COMPLETION -41 Nowait device type inquiry FILE-GETINFOBYNAMECOMPLETION N. A. Nowait FILE_GETINFOBYNAME_ completion FILENAME-FINDNEXTCOMPLETION N. A.
Table 30 REPORT Clause Message Types (continued) 152 Message Type Message Type Code Meaning SETTIME -10 Set time STATUS-3270 -21 3270 device status received SUBORDINATE-NAME N. A. Subordinate name inquiry SYSTEM N. A.
7 Data Division The Data Division is optional in a COBOL program. It has four sections: the File Section, the Working-Storage Section, the Extended-Storage Section, and the Linkage Section. Each section contains entries describing data that the program unit being compiled from the source program manipulates. If your program does not use the type of data that the section defines, then the section is optional.
More information: Record Levels Sources 01-49 Records (page 79) 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.
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 file-description defines the physical aspects of a data file. See 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.
Each file description entry must be followed by one or more record description entries. These describe the format or formats of the logical records in the file. When more than one record description entry appears, they can describe record images of different lengths and substructures. All record description entries associated with a single file represent implicit redefinitions of the file’s record area.
File Description Entry for Sequential File 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. GLOBAL clause is described in GLOBAL Clause. 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.
LINAGE clause is described in LINAGE Clause. CODE-SET clause is described in CODE-SET Clause. REPORT clause is described in REPORT Clause (page 173). File Description Entry for Line Sequential File NOTE: Available only in the OSS environment. 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. GLOBAL clause is described in GLOBAL Clause.
REPORT clause is described in REPORT Clause. File Description Entry for Relative, Indexed, or Queue File 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. GLOBAL clause is described in GLOBAL Clause. BLOCK CONTAINS clause is described in BLOCK CONTAINS Clause RECORD CONTAINS clause is described in RECORD CONTAINS Clause.
Usage Considerations: • Sharing a File Connector If more than one of the source programs compiled into a run unit contain file description entries defining the same file name, all entries that include the EXTERNAL clause describe the same external file connector. Any file name whose file description entry does not include the EXTERNAL clause refers to an internal file connector, even if the same file name identifies an external file connector in some other program of the run unit.
◦ BLOCK CONTAINS clause If any of the file description entries includes a BLOCK CONTAINS clause, all of them must include a BLOCK CONTAINS clause that specifies the same block size attribute.
Usage Considerations: • Referencing Global Items A statement in a program contained directly or indirectly within a program that describes a global name can reference that name without describing it again. • Subordinates of Global Names Are Global Names A file name described using a GLOBAL clause is a global name. All data-names subordinate to a global name are global names. All condition-names associated with a global name are global names.
Although tape devices are capable of handling blocks of 32,767 characters, unstructured disk files are limited to a block size of 4,096. Furthermore, an unstructured disk file can have a BLOCKSIZE attribute that is smaller than 4,096. Other devices have their own block size limitations. See the discussion of the WRITE procedure call in the Guardian Procedure Errors and Messages Manual for these limits.
contains-phrase-fixed length-fixed is an unsigned integer literal that specifies the exact length, in characters, of fixed-length records. If the ASSIGN clause specifies $RECEIVE, the value of length-fixed is in the range of 0 through 2,097,152 bytes (2MB). Otherwise, its value is in the range of 0 through 32,767 bytes. «contains-phrase-range» NOTE: The 1985 COBOL standard classifies contains-phrase-range as obsolete, so you are advised not to use it.
If the ASSIGN clause specifies $RECEIVE, the value of length-max has an upper limit of 2,097,152 bytes (2MB). Otherwise, the upper limit is 32,767 bytes. No record description entry for the file described with length-max can specify a number of character positions greater than the value of length-max. VARYING phrase explicitly declares that the file consists of variable-length records (records of different sizes). length-min is as defined previously.
The length you specify in the RECORD CONTAINS clause is the fixed length of the record area that holds individual records read from or to be written to the file during execution. Each record description entry can define the record area in a different way, possibly describing a record of a shorter length than the actual record has in the record area or in the file.
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. STANDARD specifies that standard system labeling conventions apply to the file.
DATA RECORDS Clause NOTE: The 1985 COBOL Standard classifies the DATA RECORDS clause as obsolete, so you are advised not to use it. Use the optional DATA RECORDS clause to enumerate the names of the records that are defined for the file. Each data-name corresponds to one level-01 name in the record descriptions following the file description. The existence of more than one data-name indicates the file has more than one type of data record.
body is either an unsigned integer literal or the data-name of an elementary unsigned numeric integer data item. Its value is the number of lines that can be written on a logical page, so it must be greater than 0. 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.
Figure 7 LINAGE Clause Layout • Restriction Because the purpose of the LINAGE clause is to control printing of data, it can be used only with files assigned to line printer devices or spooler processes. • Initial Positioning of First Logical Page Before printing the first logical page, a standard printer file issues a page eject, positioning itself at the fourth line of the physical page.
Lines Skipped Value of top Page-Eject Issued? Additional Total 5 Yes (skips 3) 2 5 6 Yes (skips 3) 3 6 This logic applies only during initial positioning of the first logical page. The printer does not perform page ejects for subsequent pages, and the value of top is not modified. • Handling the First Logical Page Specially If you know that the printer file does not behave in the standard way, you can program around the situation described in Initial Positioning of First Logical Page.
The value of LINAGE-COUNTER is automatically set to 1 when its file is opened. During execution of a WRITE statement to its file, LINAGE-COUNTER is automatically modified under these conditions: ◦ When the ADVANCING PAGE phrase of a WRITE statement is encountered, LINAGE-COUNTER is reset to 1. ◦ When the ADVANCING phrase is specified in a WRITE statement, LINAGE-COUNTER is increased by the number of lines given.
The most common use for CODE-SET EBCDIC is for reading or writing tapes for interchange with an EBCDIC-based system. • Restrictions Established by the CODE-SET Clause When the CODE-SET clause appears, it places these restrictions on all data items defined in the record description entries associated with the file description entry: ◦ Some SIGN SEPARATE clause must apply to every signed numeric data item ◦ Every data item must be USAGE DISPLAY.
CONTAINS phrase VARYING phrase length-min, length-max, length-var are integer values as in the file description entry. DATA RECORDS clause 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.
Example 38 Sort-Merge File Description Entry SD SORT-THIS RECORD CONTAINS 80 CHARACTERS DATA RECORD IS SORT-TEMPLATE. 01 SORT-TEMPLATE. 05 CUSTOMER-NAME PIC X(35). 05 FILLER PIC X(35). 05 CUSTOMER-ADDRESS PIC X(55). 05 CUSTOMER-ZIP PIC 9(15). ... Data Description Entries Data description entries in the File Section describe record areas associated with files.
Data Description Entries The data description entries for unrelated items (level-77 items) or records or both follow the Working-Storage Section header.
Example 39 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 01 01 01 CURRENT-DATE. 05 CURRENT-YEAR 05 CURRENT-MONTH 05 CURRENT-DAY PICTURE PICTURE PICTURE PICTURE PICTURE X(8) 999 99 99 9. VALUE VALUE VALUE VALUE SPACES. ZERO. ZERO. ZERO. VALUE 0. VALUE 1. PICTURE 99 PICTURE 99 PICTURE 99 VALUE ZERO. VALUE ZERO. VALUE ZERO. REPORT-HEADING-1.
An internal data item is initialized at each of these times: • The first time the program is executed. • The first time the program is called after a CANCEL statement that references it has been executed, unless a NOCANCEL directive affects the program. • Every time the program is called, if the program is an initial program (see Initial Programs (page 51)). The NOCANCEL directive does not affect initial programs.
Data Description Entries and Initializing Data Items Data description entries and data initialization rules are the same in the Extended-Storage Section as they are in the Working-Storage Section. See Data Description Entries and Initializing Data Items. 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.
• Index-Names • Absent Linkage Section Data Description Entries and Initializing Data Items Data description entries and data initialization rules are the same in the Linkage Section as they are in the Working-Storage Section, except that you can use the VALUE clause only for level-88 items. A BASED item declared in the Linkage Section has its implicit pointer initialized to NULL every time the program is called.
CALL Statement and USING Phrase The Linkage Section is required when parameters are passed from a calling program to a called program, which is signaled by the presence of a USING phrase in the Procedure Division header of the called program. The data items named in the CALL statement of the calling program correspond with the data items named in the USING phrase of the Procedure Division header of the called program. For details, see CALL (page 293).
Example 40 Correspondence Between Formal and Actual Parameters These lines are in the calling program: WORKING-STORAGE SECTION. 01 PARAMETER-TABLE. 02 ROW-PART OCCURS 20 TIMES. 03 COL-PART PIC 9999 COMPUTATIONAL OCCURS 10 TIMES. ... 77 ROW PIC 99 COMPUTATIONAL. 77 COL PIC 99 COMPUTATIONAL. ... PROCEDURE DIVISION. ... CALL "SUBPROG1" USING ROW, COL, PARAMETER-TABLE. ... These lines are in the called program: LINKAGE SECTION. 01 PARM-3-IN-OUT. 04 FORMAL-ROW OCCURS 20 TIMES.
level is a 1-character or 2-character string whose value is in the range “1” (or “01”) to “49,” which represents the record’s level number. 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.
• ◦ When the data item is an independent elementary data item, you must define it in a level-01 or level-77 data description entry in the Linkage, Working-Storage, or the Extended-Storage Section. ◦ When the data item is a subordinate part of a record, you must define it in a data description entry (with a level number in the range 02 through 49) associated with the appropriate record description entry.
◦ SIGN Clause The SIGN clause cannot be used for national data items. ◦ SYNCHRONIZED Clause The SYNCHRONIZED clause cannot be used for national data items. ◦ BLANK WHEN ZERO Clause The BLANK WHEN ZERO clause cannot be used for national data items. ◦ BASED Clause The BASED clause can be used only with level-01 or level-77 data items in the Working-Storage, Extended-Storage, or Linkage Sections.
description does not establish a record length, the longest data description entry associated with it does so. ◦ 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 41).
Example 43 FILLER Keyword WORKING-STORAGE SECTION. 01 HEAD-1. 05 FILLER PIC X(10) VALUE "PART NUM". 05 FILLER PIC X(25) VALUE "DESCRIPTION". 05 FILLER PIC X(30) VALUE SPACES. 05 FILLER PIC X(15) VALUE "UNITS ON HAND" 01 BAD-NEWS. 02 THE-VALUES. 05 PIC X(45) VALUE "That part number is invalid.". 05 PIC X(45) VALUE "That job code is invalid.". 05 PIC X(45) VALUE "That delivery date is a holiday.". ... 02 THE-MESSAGES REDEFINES THE-VALUES. 05 ERR-MESSAGE PIC X(45) OCCURS 15 TIMES.
Example 44 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.
• Restrictions on Level Numbers The level number of a data description entry with a REDEFINES clause can be 01 in the Working-Storage Section, Extended-Storage Section, or Linkage Section but not in the File Section (where consecutive level-01 items are always multiple definitions of the same storage space).
compiler issues a diagnostic message if alignment requirements of the elementary item make this impossible. • BASED Items and the REDEFINES Clause ◦ A redefinition entry cannot contain a BASED clause. ◦ A redefined item can be a BASED item. 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.
rules apply to these record description entries as well as those defined in the Working-Storage Section and Extended-Storage Section. Example 4: Programs With Shared Data (page 54) contains an example of the use of the EXTERNAL clause. GLOBAL Clause The GLOBAL clause specifies that a data-name is a global name. A global name is available to every program contained within the program that describes it, even though the contained programs do not contain a description of it.
These data items do not have PICTURE clauses: • An index (described only in an INDEXED phrase) • A data item described as USAGE INDEX • A data item described as USAGE NATIVE-n (where n is 2, 4, or 8) • A data item described as USAGE POINTER • A data item declared by a RENAMES clause Usage Considerations: • Size of character-string The maximum number of characters in character-string is 30.
Table 32 PICTURE Character-String Symbols (continued) Symbol Symbol Counts in Item’s Size Description P and the insertion character period (.) cannot be in the same character-string. In some operations that manipulate a data item whose character-string contains P, the algebraic value of the data item is used rather than the actual character representation of the data item. In this algebraic value, the decimal point is in the prescribed location and zero is in each digit position specified by P.
Table 32 PICTURE Character-String Symbols (continued) Symbol Symbol Counts in Item’s Size CR DB Description symbol, the sign-editing symbol represents the position where the sign-control symbol goes. * Yes Represents a leading numeric character position that is to be replaced by an asterisk (*) if its contents and the contents of all preceding numeric character positions are 0. All asterisks must precede any 9 s. $ Yes Represents the character position where the currency symbol is to be placed.
Figure 8 Precedence Rules for PICTURE Symbols • Data Item Size A data item’s size is determined by the symbols of its PICTURE character-string. Each A, B, N, X, Z, 9, zero (0), slash (/), comma (,), period (.), plus (+), minus (-), asterisk (*), or currency symbol (usually the dollar sign ($)) counts as one character position. CR or DB counts as two character positions. S is one character only if the item is subject to a SIGN clause with a SEPARATE phrase.
The size of a DISPLAY item is determined by the PICTURE character-string symbols. COMPUTATIONAL and BINARY items deviate from the rules for DISPLAY items. See USAGE Clause. The amount of storage given to a data item can exceed its size if the SYNCHRONIZED clause is used; however, any excess bytes so allocated (called “implicit FILLER” bytes) belong not to the synchronized item but to its parent item.
• Numeric Data Items An item is in the numeric category when its PICTURE character-string contains only the symbols from the set: 9, P, S, and V. The number of digits described must be greater than 0 and not more than 18. The contents are represented externally as a combination of 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. If the S is present, the sign of the value is retained. Example 46 Numeric Data Items 05 05 DIVISION-TOTAL FRACTION-AMOUNT PIC S9(10)V99. PIC VPP99.
Example 49 Numeric Edited Data Items 12 10 35 05 10 05 77 12 03 77 • R-TOTAL-1 ITEM-PRICE UNIT-PRICE AMOUNT-OWED AMOUNT-LEFT BACK-ORDERS START-DATE S-BLIVIT STARRED-X SUM-X PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC ZZZ,ZZZ.99. $999. $$$9. 999CR. ***99. -99. 99/99/99. +$99.99. ***.**. --B---.---. National Data Items An item is in the national category when its PICTURE character-string begins with N or n and contains no editing symbols.
◦ Fixed insertion ◦ Floating insertion ◦ Zero suppression The type of editing that you can perform on an item depends on the item’s category.
the appearance of the insertion character within the edited item value in the same position as it appears in the character-string. Here are some examples. The caret (^) in each source item is the decimal point location from its PICTURE character-string. ◦ Source Item PICTURE Edited Result 1234^56 PIC 9999.99 1234.56 1^23456 PIC 9.99999 1.23456 1^23456 PIC 99.999999 01.234560 123^4 PIC 99.9999 23.4000 12^345 PIC 99.99 12.
◦ Source Item PICTURE Edited Result 12^34 PIC 99.99CR 12.34 -12^34 PIC 99.99CR 12.34CR 12^34 PIC $99.99DB $12.34 -12^34 PIC $99.99DB $12.34DB 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.
◦ Source Item PICTURE Edited Result -23 +++99 -23 4 +++99 +04 123 ------9 123 -123 ------9 -123 1.23 $$$9.99 $1.23 -1.23 $$$9.99 $1.23 0.03 $$$9.99 $0.03 -0.03 $$$9.99 $0.03 1.23 $$$$.$$ $1.23 -1.23 $$$$.$$ $1.23 0.03 $$$$.$$ $.03 -0.03 $$$$.$$ $.03 1.23 ---9.99 1.23 -1.23 ---9.99 -1.23 0.03 ---9.99 0.03 -0.03 ---9.99 -0.03 1.23 ----.-- 1.23 -1.23 ----.-- -1.23 0.03 ----.-- .03 -0.03 ----.-- -.
suppression symbol is Z, the entire data item is set to spaces. If the value is 0 and the suppression symbol is the asterisk, the data item is set to all asterisks except for the actual decimal point. In this case, the actual decimal point appears in the data item. Only one of the symbols plus (+), minus (-), asterisk (*), Z, and the currency symbol can be used as a floating replacement character within a single PICTURE character-string.
left-hand (most significant) end of the data item and are set to zero. SeeTable 35, Table 35, and Table 37. COMPUTATIONAL-3/PACKED-DECIMAL is also called binary coded decimal form. The keyword PACKED-DECIMAL is an element of COBOL, but the data format is not. If your program is compiled with a FIPS directive with NONSTANDARDEXT in the flag-option-list, the compiler issues a warning message when it finds a COMPUTATIONAL-3/PACKED-DECIMAL data item.
Table 35 COMPUTATIONAL-3/PACKED-DECIMAL Digit Representation (continued) Hexadecimal Digit Representation Digit Value Left* Nibble (Odd Digit) Right* Nibble (Even Digit) 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.
A COMPUTATIONAL-3/PACKED-DECIMAL data item with PICTURE S9999 and value -1234 is stored as shown in Figure 9 except that F is replaced by D (1101), which represents the minus sign (-). Usage Considerations: • National Data Items Cannot Have USAGE Clauses Verify that national data items do not have USAGE clauses (inherited, explicit, or implicit) and are not mixed with nonnational data items in group descriptions.
◦ Cannot have BLANK WHEN ZERO clause A BLANK WHEN ZERO clause changes a numeric data item’s category from numeric to numeric edited; therefore, the item cannot be BINARY/COMPUTATIONAL. ◦ COMPUTATIONAL data item with value 8224 or 224 In HP COBOL, if you find that a data item of USAGE COMPUTATIONAL has the value 8224, it might be because it actually consists of 2 bytes, each containing a space character. If it is described as consisting of 3 digits, it appears to have the value 224.
Signed COMPUTATIONAL-5 data items are equivalent to NATIVE-n data items, but unsigned COMPUTATIONAL-5 data items can store a larger range of values than the corresponding NATIVE-n data items (see in PICTURE Clause (page 191)). ◦ 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.
• ◦ Elementary items whose data description entries contain SIGN, JUSTIFIED, or BLANK WHEN ZERO clauses ◦ See Trapping Size Errors under PICTURE Clause (page 191).
A program can specify a NATIVE-n data item as an operand anywhere that it can specify a BINARY/COMPUTATIONAL item (of equivalent size in character positions), such as in arithmetic expressions, MOVE statements, and so on. In all cases, the value of the item is interpreted as a signed integer.
When the SEPARATE phrase is present, the sign is maintained as a separate character to be considered in the size of the item. A plus (+) for a positive value or a minus (-) for a negative value is placed at the beginning or end of the item’s value, depending on the presence of LEADING or TRAILING. If the sign character position contains a value other than plus (+) or minus (-), any operation that uses the item as a numeric sending item has undefined results.
max is an integer literal that specifies the number of elements in the table. key-order 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. index is a name for a compiler-created item used to select an element from the table. Each index must be unique in the program because you cannot qualify it.
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. The representation of the reference to the key in this context does not include subscripts. The KEY phrase indicates that within the table occurrences, the values referenced by the keys are arranged in a consistent order.
• Index is a Variant of Subscript In COBOL, an index is a variant of a subscript. The program can define an indexed table within a nonindexed table (or the reverse). Both indexes and subscripts can be augmented with an increment or a decrement. That is, if a table is described: 01 A-TABLE. 03 ROWE OCCURS 20 TIMES INDEXED BY R. 05 KOLUMN OCCURS 10 TIMES. 07 ELEMENT PIC X.
min is an integer literal that specifies the minimum number of table elements. Its value is in the range 0 through max. 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.
Usage Considerations • See the usage considerations for OCCURS Clause for Fixed-Size Tables. • Depending Item The depending item (depend in the syntax diagram) must reference an integer numeric data item that is capable of containing the value of max.
Example 51 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 52 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). 07 CAPACITY-CU-FT PICTURE 9(4). 07 SERVICE-SCHEDULE PIC X. ...
of 8-bit bytes aligned on byte or 2-byte boundaries, whether or not they are described with the SYNCHRONIZED clause. • COMPUTATIONAL or BINARY Data Items If the program is not compiled with the PORT directive, then a data item is aligned on a 2-byte boundary unless it is described with the SYNCHRONIZED clause. If it is described with the SYNCHRONIZED clause, it is aligned on a 2-byte boundary if its size is less than 4 bytes, and on a 4-byte boundary if its size is 4 bytes or larger.
You can use the BLANK WHEN ZERO clause only with elementary numeric or elementary numeric edited data items. This clause revises the category of a numeric item to numeric edited; therefore, the item must be USAGE DISPLAY. NOTE: The BLANK WHEN ZERO clause has no effect on initialization by the VALUE clause. The BLANK WHEN ZERO clause cannot be used for national data items.
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. Initialization follows standard alignment rules for alphanumeric data items. The BLANK WHEN ZERO and JUSTIFIED clauses do not affect initialization.
• • Use in Linkage Section ◦ A BASED item declared in the Linkage Section cannot be listed in the USING phrase of the procedure division header, and has no corresponding actual parameter in the calling program-unit. ◦ The lifetime of the implicit pointer for a BASED item in the Linkage section ends when the program returns control to its calling program; the next time this program is called, the implicit pointer is again initialized to NULL.
entries can be written for a logical record. They can occur in any order but must immediately follow all other data description entries for the record. • 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.
data-name-1 is the name of the noncontiguous elementary item. FILLER is a place holder for a data item to which the program never refers. data-name-2 is the name of a data item being redefined. See REDEFINES Clause. 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.
VALUE clause is as described in VALUE Clause. Do not use the VALUE clause with INDEX. BASED clause is as described in BASED Clause. Do not use the BASED clause with the EXTERNAL clause or the REDEFINES clause. 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.
Example 55 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.
• Numeric data items If an item is in the numeric category, all literals in the VALUE clause must be numeric literals or figurative constants ZERO, ZEROS, or ZEROES (the keyword ALL cannot appear in this context), and they must be in the range of values set by the PICTURE character-string of the conditional variable. A signed numeric literal only applies to a signed numeric conditional variable.
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 Components and Syntax USING marks the beginning of a parameter list in a called program. The CALL statement in the calling program must contain a corresponding USING phrase. parameter is the identifier of a data item in the Linkage Section. See Linkage Section (page 179) and CALL (page 293). declaratives-portion is described in Declaratives Portion.
Example 57 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 ...PROCESS-INPUT-DATA. ... 300-TERMINATION SECTION. CLOSE-AND-QUIT. CLOSE MESSAGE-IN MESSAGE-OUT BASE-FILE STOP RUN.
Figure 11 Statement Examples Table 39 Statement Types Statement Type Definition Imperative Specifies an unconditional action for the process to take Conditional 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 Delimited-scope Terminates in its explicit scope terminator Compiler-directing Causes the compiler to take some specific action during compilation Topics: • Imperative Statement • Conditional Stat
Table 40 Imperative Verbs (continued) COMPUTE2 INSPECT SET CONTINUE LOCKFILE3 SORT WRITE9 1 Without INVALID KEY or NOT INVALID KEY phrase or else with a scope terminator 2 Without SIZE ERROR or NOT SIZE ERROR phrase or else with a scope terminator 3 HP extension 4 ALLOCATE and FREE are recognized as verbs only when the STANDARD 2002 directive is in effect.
DONE-WITH-MASTER was false, you would have to package the READ statement in a separate paragraph. Then you could end the AT END phrase with a period that did not also end the IF statement. Example 59 Conditional Statement IF NOT DONE-WITH-MASTER READ MASTER-FILE AT END MOVE DONE-VALUE TO MASTER-FLAG. Compare Example 59 to Example 60. Delimited-Scope Statement A delimited-scope statement is any statement that terminates in its explicit scope terminator.
The COPY statement directs the compiler to include additional source text at that point in the program. The REPLACE statement directs the compiler to replace source program text. The USE statement directs the compiler to include logic in the object program that calls the designated declarative section if the condition described in the USE statement arises during execution.
such READ statement’s AT END phrase. Both must be provided with scope terminators as shown in this example: READ PRIMARY-FILE AT END READ SECONDARY-FILE AT END DISPLAY "End of second file" END-READ END-READ • 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.
sentence is described in Sentences. A sentence ends with a period; therefore, a paragraph ends with the period at the end of its last sentence. Example 62 Paragraph With One Sentence CHK-REPORT-YY. IF CURRENT-YY IS LESS THAN 0 OR GREATER THAN 99 DISPLAY "REPORT YEAR IS NOT BETWEEN 00 AND 99, " "REENTER YEAR" ACCEPT CURRENT-YY GO TO CHK-REPORT-YY. Example 63 Paragraph With Several Sentences CONVERT-REPORT-DATE-TO-SERIAL-DAY. MOVE CURRENT-YY TO REPORT-SERIAL-YEAR. MOVE 0 TO DIVIDE-RESULT LEAP-YEAR.
but PERFORM CHECK-THE-INPUT returns control immediately to the statement following the PERFORM. • Paragraph Form Only for Use With the ALTER Statement There is a simpler form of the paragraph used in conjunction with an ALTER statement. For details, see ALTER (page 291). 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.
Usage Considerations: • Section Format ◦ Beginning After the period separator that precedes the first paragraph of a section, do not put anything on the same text line except space characters or a USE statement. ◦ End A section ends at the next section header, at the physical end of the Procedure Division, or at the keywords END DECLARATIVES. • Standard COBOL Format To conform to the COBOL standard, observe these rules. (HP COBOL compilers do not require that you follow these rules.
this set of be obvious; that is, the set of paragraphs executed by a PERFORM statement is determined by control flow, not solely by the order of the paragraphs in the source file. Declaratives Portion The optional Declaratives Portion is one or more sections at the beginning of the Procedure Division, bracketed by the keyword DECLARATIVES and the keywords END DECLARATIVES, that are executed individually when certain conditions arise during execution of statements in the rest of the Procedure Division.
the order in which they appear within their paragraphs, and statements are executed in the order in which they appear within their sentences. Topics: • Statement Execution • Sentence Execution • Paragraph Execution • Section Execution • Procedure Execution • Declaratives Portion Execution Statement Execution An individual imperative statement is always executed in its entirety.
programs (for example, by the execution of PERFORM or CALL statements) control remains within the paragraph until either: • The execution of a GO TO, STOP RUN, or EXIT PROGRAM statement transfers control out of the paragraph. • The final executable sentence of the paragraph completes without explicitly transferring control to some other procedure.
COBOL provides these types of implicit transfers of control that override the statement-to-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.
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. Following the execution of such a statement in these circumstances, control reaches the end of the Declaratives Portion, causing execution of both the program and the run unit to terminate abnormally.
item, its appropriate size is sometimes its maximum size. For details, see OCCURS Clause for Variable-Size Tables (page 214). 4. Reference Modifier If the operand contains a reference modifier, the run-time routines evaluate the reference modifier. Unless the rules for a statement state otherwise, identification of each operand in a statement occurs exactly once as the first operation (or series of operations) in the execution of that statement.
MOVE G OF F OF A TO G OF F OF H Example 65 CORRESPONDING Phrase 01 A 03 03 03 01 B 07 07 E F 04 C D H 05 05 05 G F 08 B C 09 09 09 G E D G ROUNDED Phrase When the number of fraction digits in the result of an arithmetic operation exceeds the number of fraction digits in the receiving item, the excess digits must be deleted by either truncation or rounding.
Usage Considerations: • SIZE ERROR Phrase and TRAP2 Directive NOTE: The ECOBOL compiler, which has traps set by default, ignores the TRAP2 directive and issues a warning. The SIZE ERROR phrase catches size errors in COMPUTATIONAL arithmetic that the TRAP2 directive (which is the default) does not; however, the SIZE ERROR phrase generates more code than the TRAP2 directive does. In Example 66, C=A+B causes a size error that the TRAP2 directive does not catch, but that the SIZE ERROR phrase does catch.
• 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: The ECOBOL compiler, which has traps set by default, ignores the NOTRAP2 directive and issues a warning.
INTO Phrase The INTO phrase is an optional component of the READ and RETURN statements, both of which specify a file name as their primary operand. This phrase can be specified in a READ or RETURN statement only if either: • The specified file has only one associated record description entry. • The data description entry for the data item specified by the identifier in the INTO phrase and all record description entries associated with the file describe data structures or elementary alphanumeric items.
Topics: • Status Key 1 • Status Key 2 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 42 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: • The physical end of the file was reached. • An optional file was not present.
Table 43 Status Key 2 Values: Successful Completion (continued) I-O Status Code File Exception Condition “05” The input-output statement executed successfully; however, for an OPEN statement, the referenced optional file is not present at the time the OPEN statement is executed (if the open mode is I-O or EXTEND, the file has been created).
Table 46 Status Key 2 Values: Unsuccessful Completion—Permanent Error Condition I-O Status Code File Exception Condition “30” A permanent error exists and no further information is available concerning the input-output operation. “34” A permanent error exists because of a boundary violation. This condition indicates that an attempt has been made to write beyond the externally-defined boundaries of a sequential file.
Diagnosing Input-Output Errors The I-O status code returned to the program indicates what type of input-output error occurred. The run-time routines send diagnostic messages for permanent error conditions and logic error conditions to the home terminal (or designated execution-log file), regardless of whether an error is recoverable.
Table 49 I-O Status Codes Augmented by GUARDIAN-ERR 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.
Table 49 I-O Status Codes Augmented by GUARDIAN-ERR (continued) Status Code GUARDIAN-ERR Value COBOL Statement(s) Cause of Status Code 45 WRITE File is full 46 WRITE Invalid (duplicated) key specified) xxx CLOSE Fatal error on WRITE to write final block, or to write held spacing or record for print files, or attempt to write tape marks on tape failed xxx CLOSE REEL Reel swap failed xxx DELETE Attempt to position failed, or attempt to delete record failed, or attempt to reposition after del
Table 49 I-O Status Codes Augmented by GUARDIAN-ERR (continued) Status Code GUARDIAN-ERR Value COBOL Statement(s) Cause of Status Code “37” 0 OPEN Opening for INPUT or OUTPUT: device won’t support it “38” 0 OPEN File is locked “39” 0 OPEN File is not disk or is an unstructured disk file and organization is not sequential or file has alternate keys LINAGE specified on file that is not a printer or process Multiple files specified on a device that is not a tape OUTPUT specified on an EDIT file
Table 49 I-O Status Codes Augmented by GUARDIAN-ERR (continued) Status Code GUARDIAN-ERR Value COBOL Statement(s) Cause of Status Code “91” xxx OPEN Unable to initialize EDIT file 0 OPEN No buffer space available in user data space xxx READ sequential Unable to read EDIT file 0 READ sequential Read with lock and preread on 9 READ, START A locked record was read or nominated in a START statement 0 OPEN The program described a file as having standard labels, and no standard label was fou
4. 5. If control reaches the end of declarative procedure, transfer control to the statement immediately following the terminating period or scope terminator of the I-O statement that caused the exception condition. If neither exception handling phrases nor declarative procedures apply, transfer control to the statement immediately following the terminating period or scope terminator of the I-O statement that caused the exception condition.
If a declarative procedure does apply to the file and the time limit expires, the declarative procedure is performed and program execution continues with the statement following the one terminated. 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.
Data Conversion and Alignment The data descriptions of the operands need not be the same; any necessary conversion and decimal point alignment is supplied by the COBOL compiler throughout the calculation. Composite of Operands The maximum size of each arithmetic operand is 18 decimal digits, independent of any decimal point. When the computer performs arithmetic, it must handle operands of different data descriptions.
Incompatible Data Normally, whenever the contents of a data item are used in the Procedure Division and the current contents of that data item are not compatible with the class and size specified by its PICTURE clause, the result of the reference is undefined; that is, the semantic rules of the COBOL language apply only when operands have values corresponding to their descriptions.
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 50 must be preceded and followed by a separator (usually spaces or parentheses).
Table 52 shows some expressions that appear to be ambiguous and the COBOL interpretation of them.
create intermediate data items as it evaluates the expression. Arithmetic expressions occur only in the COMPUTE, ENTER, and EVALUATE statements, the relation and sign conditions, function arguments, and in reference modification. In discussing precision, we ignore the presence of a scale factor or of any decimal point; the arithmetic processing records and handles these elements separately.
DIVIDE Statement Because division is a rather complicated mathematical operation, and because the computer is performing scaled integer arithmetic instead of floating-point arithmetic, the rules stating the precision of HP COBOL division are somewhat complicated. • Effect of GIVING When the GIVING phrase is present, a single quotient is computed. The appropriate number of fraction digits in that quotient is determined from the receiving operand having the greatest number of fraction digits.
The evaluation of an arithmetic expression is the result of the evaluation of a sequence of intermediate results. The maximum number of digits held for an intermediate result is 36. If this number is exceeded, the compiler might use binary floating-point arithmetic (and issue warning 85). The size error condition applies to both final results and intermediate results.
exactly, the result might be slightly larger or smaller than the exact number. You might have to use individual operations or revise the expression to guarantee accurate results. To obtain the maximum accuracy in an arithmetic expression that involves a division, use parentheses or revise the expression as necessary to assure that the division is the last operation performed. For example, you can rewrite the expression “a / b * c" as "(a * c) / b".
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. • Where Pointer Relations Are Allowed A relation with pointer operands is allowed in EVALUATE, IF, PERFORM, and SEARCH VARYING statements. It is not allowed in SEARCH ALL statements, because pointer data items have no meaningful order.
an integer and, if a data item, to have DISPLAY usage. HP COBOL removes both of these restrictions. ◦ – When the nonnumeric operand is either an elementary data item or a nonnumeric literal, the numeric operand is handled as though it were moved to an elementary alphanumeric data item, and the value of this item were then compared to the nonnumeric operand. The size of this conceptual data item is the same as the number of digit positions in the numeric operand.
Neither an index-name nor an index data item can be compared with any operand other than those mentioned in the preceding rules. • National Data Items and National Literals A national data item or a national literal can be compared only to another national data item or a national literal. The first three simple relation conditions in Example 67 are equivalent.
Relation Conditions With Pointer Operands pointer-subject pointer-object 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. NULL or NULLS can be used for pointer-subject or pointer-object, but not both.
identifier is the identifier of a data item for which either: • It is described as USAGE DISPLAY. • It is of the numeric class, and its usage is not DISPLAY. class-name is the name of a class described in the SPECIAL-NAMES paragraph. Usage Considerations: • NOT Modifier When NOT appears, the compiler considers it and the next keyword to form a single class condition. For example, NOT NUMERIC is a truth test that determines if the operand is nonnumeric.
CHARACTER-SET clause specifies a program character set other than USASCII or UK, the set of characters that constitute the alphabetic class is extended as appropriate (see OBJECT-COMPUTER Paragraph (page 102)). • Class-name and NOT Class-name You cannot use the class-name and NOT class-name tests with a numeric data item.
Usage Considerations: • TRUE Value The result of the test is TRUE if the switch is set to the position corresponding to the one identified by the condition-name; otherwise, the result of the test is FALSE. • Setting External Switches Set external switch value by using the PARAM command of the command interpreter (see SPECIAL-NAMES Paragraph (page 105)) or by the SET statement (see SET (page 436)). Example 69 External Switches SPECIAL-NAMES. SWITCH-1 IS IN-SWITCH ON OFF SWITCH-2 IS OUT-SWITCH ON OFF ..
Example 70 Sign Conditions ( A - 10 ) IS POSITIVE B NOT ZERO Complex Conditions A complex condition is a combination of simple conditions and any of the logical operators NOT, AND and OR. 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 55 Conditions, Logical Operators, and Parentheses Location in Conditional Expression Element First In a left-to-right sequence of elements Last When not first, element can be immediately preceded only by When not last, element can be immediately followed only by simple-condition Yes Yes AND, NOT, OR, ( AND, OR, ) AND or OR No No simple-condition, ) NOT, (, simple-condition NOT Yes No AND, OR, ( (, simple-condition ( Yes No AND, NOT, OR, ( NOT, (, simple-condition ) No Yes s
combined-part rel-operator is a relational operator. object is an identifier, a literal, an arithmetic expression, or an index-name. This abbreviation technique is available when a group of the characteristics shown in Table 56 is present.
Some examples of abbreviated combined and negated relation conditions and expanded equivalents follow: 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 + B - C) > D AND (A + B - C) NOT < E
literal-1 is either a simple nonnumeric literal, a hexadecimal nonnumeric literal, or a national literal. For information about these literals, see: • Simple Nonnumeric Literals (page 72) • Hexadecimal Nonnumeric Literals (page 72) • National Literals (page 73) literal-2 is either a simple nonnumeric literal, a hexadecimal nonnumeric literal, or a national literal of the same class (alphanumeric or national) as literal-1. figurative-constant is a figurative constant that does not include the word ALL.
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 (page 499) and REPLACE Statement (page 508). ACCEPT ACCEPT With Mnemonic-Name ACCEPT with a mnemonic-name delivers small amounts of data to a process from a terminal or another process.
Default Input-Output Device (page 822).) Do not specify the default input-output device as the mnemonic-name, because this causes the process to terminate abnormally. • If mnemonic-name Is Not Open If mnemonic-name specifies a process that has not been opened by an earlier ACCEPT or DISPLAY statement, or specifies a terminal, then the accepting process opens the process or terminal that mnemonic-name specifies as if it were a file.
response or a response containing only spaces is invalid for a numeric or a numeric edited accept-name. If the response to the read operation is not in numeric literal format, the ACCEPT statement reprompts with: ** Improper numeric value. Resupply input ** 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.
Figure 12 ACCEPT Statement Collecting Alphanumeric Data Example 74 ACCEPT Statement Reading Numeric Data ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP System. OBJECT-COMPUTER. HP System. SPECIAL-NAMES. FILE "#TERM" IS USER-TERMINAL. ... WORKING-STORAGE SECTION. 01 PROGRAM-CODE PICTURE 999V99. ... PROCEDURE DIVISION. DEMO.
Figure 13 ACCEPT Statement Collecting Numeric Data ACCEPT With DATE, DAY, DAY-OF-WEEK, or TIME Phrase ACCEPT with a DATE, DAY, DAY-OF-WEEK, or TIME phrase retrieves the numeric representation of the date, day, day of the week, or time from the operating system. NOTE: A simpler alternative is the CURRENT-DATE Function (page 664). 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).
Data Item Typical Definitions DAY-OF-WEEK PICTURE 9 TIME PICTURE 9(8) or PICTURE 99B99B99B99 DATE delivers the current date. YYYYMMDD Without YYYYMMDD, DATE behaves as if it were a data item described with the PICTURE character-string 9(6) organized as yymmdd where yy is the year of the century; for example, July 10, 1992, is represented as 920710.
Example 75 ACCEPT Statements Reading Current Data and Time WORKING-STORAGE SECTION. 01 DATE-AND-TIME-FIELDS. 05 DAY-SUB PIC 9 VALUE 05 TODAYS-DATE PIC 9(6) VALUE 05 TIME-RIGHT-NOW PIC 9(8) VALUE 77 USER-REPLY PIC X(40) VALUE ... PROCEDURE DIVISION. ... ACCEPT DAY-SUB FROM DAY-OF-WEEK ACCEPT TODAYS-DATE FROM DATE ACCEPT TIME-RIGHT-NOW FROM TIME ACCEPT USER-REPLY ZERO. ZERO. ZERO. SPACES.
ROUNDED specifies that result is to be rounded before being stored. 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.
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. 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.
Usage Considerations: • Changing Addend Values The ADD GIVING statement does not change the value of an addend unless you also specify that addend for result. • See these usage considerations in ADD TO: ◦ Operand Identification Order ◦ Arithmetic Operations ◦ Precision ◦ ROUNDED, SIZE ERROR, and NOT SIZE ERROR Phrases ADD CORRESPONDING ADD CORRESPONDING adds numeric elements of one data structure to corresponding numeric elements of another data structure.
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. 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.
Example 76 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. 05 WRITING-TOOLS. 10 PENCILS PIC 99. 10 ERASERS PIC 99. 10 PENS PIC 99. 05 PAPER-CLIPS PIC 99. 05 PAPER PIC 99. ... PROCEDURE DIVISION. ... ADD CORRESPONDING CABINET-SUPPLIES TO STOCKROOM-SUPPLIES.
• Compatible with malloc() function The ALLOCATE statement is compatible with the C Run-Time Library function malloc() and related functions. To release the memory, a non-NULL pointer returned by ALLOCATE can be passed to a C-language routine that calls free(). • Cannot be checkpointed Dynamic memory cannot be checkpointed to a backup process. ALLOCATE Memory for a BASED Item ALLOCATE with a BASED item allocates dynamic memory for the BASED item.
• Compatible with malloc() function The ALLOCATE statement is compatible with the C Run-Time Library function malloc() and related functions. To release the memory, a non-NULL pointer returned by ALLOCATE can be passed to a C-language routine that calls free(). • Dynamic memory cannot be checkpointed Dynamic memory cannot be checkpointed to a backup process. ALTER NOTE: The 1985 COBOL standard classifies ALTER as obsolete, so you are advised not to use it.
Example 77 ALTER Statement PROCEDURE DIVISION. ROUTINE-1. GO TO INITIALIZATION-ROUTINE. INITIALIZATION-ROUTINE. ... ALTER ROUTINE-1 TO PROCEED TO ROUTINE-2. GO TO ROUTINE-2. ROUTINE-2. ... Example 78 Alternative to ALTER Statement DATA DIVISION. WORKING-STORAGE SECTION. 77 FLAG VALUE IS 1. PROCEDURE DIVISION. ROUTINE-1. GO TO INITIALIZATION-ROUTINE ROUTINE-2 DEPENDING ON FLAG. INITIALIZATION-ROUTINE. ... MOVE 2 TO FLAG. GO TO ROUTINE-2. ROUTINE-2. ...
CALL CALL’s behavior is determined by the PORT directive. If the program is not compiled with the PORT directive, CALL transfers control from one COBOL program to another COBOL program. The called program can be in the current compilation unit or can be extracted from an object file, provided that the entry point called is in a code block created by a COBOL compiler on an HP system.
If the program is compiled with the PORT directive, the called program can be compiled by any of these TNS/E compilers: • C • C++ • ECOBOL • EpTAL file-mnemonic is the alias for the object file to be searched for the called program. The association between file-mnemonic and the object file is established by the File-Mnemonic clause of the SPECIAL-NAMES paragraph. The file-mnemonic is not part of program-name and is not a qualifier that can make program-name unique.
CONTENT specifies that the calling program makes a copy of the data item and passes the address of the copy to the called program. If the called program changes the value of the parameter, it does not change the value of the data item in the calling program. CONTENT applies to all the parameters that follow it until a REFERENCE or VALUE phrase appears. VALUE specifies that the calling program passes the value of the data item to the called program.
on-phrase historical-on-phrase 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.
continues according to the rules for that statement. Unless that statement transfers control elsewhere, control passes from that statement to the end of the CALL statement. If the object form of the called program is not included in the run unit, the action of the CALL statement depends on the presence or absence of an EXCEPTION phrase (on-phrase or historical-on-phrase ). If an EXCEPTION phrase is specified, control passes to excp-imperative-statement.
• Two COBOL Programs With the Same Name Two or more COBOL programs in a run unit can have the same program name. If this happens, the compilation distinguishes between them according to these scope rules: • ◦ If program A lacks the COMMON attribute and is directly contained in program B, then only CALL statements in B can call A.
• Correspondence of Formal and Actual Parameters The formal parameters in the USING phrase of the Procedure Division header and the actual parameters in the USING phrase of the CALL statement correspond by position, not by name. • Declaration Locations and Access Modes of Formal and Actual Parameters You must declare formal parameters in the Linkage Section. Every parameter has a 32-bit address. If you specify STANDARD access mode, the ECOBOL compiler ignores it and issues a warning.
Example 79 Called Program That Calls Another Program Main Program (source $DATA.MYSUBVOL.MAINSRC, object $DATA.MYSUBVOL.MAINOBJ) IDENTIFICATION DIVISION. PROGRAM-ID. COBOLMAIN. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP System. OBJECT-COMPUTER. HP System. SPECIAL-NAMES. FILE "$DATA.MYSUBVOL.SUB1OBJ" IS SUB1. DATA DIVISION. WORKING-STORAGE SECTION. 01 DATA-OUT PIC X(80) VALUE "I'M THE MAIN AND I'M ALIVE". 77 PARM1 PIC 99 VALUE 10. 77 PARM2 PIC XX VALUE "AB". 01 MAIN-TABLE.
IDENTIFICATION DIVISION. PROGRAM-ID. COBSUB2. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP System. OBJECT-COMPUTER. HP System. 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".
file-mnemonic specifies the object file containing the program to be canceled. Associate file-mnemonic with the operating system file name in the SPECIAL-NAMES paragraph of the Environment Division (see SPECIAL-NAMES Paragraph (page 105)). identifier is an alphanumeric, nonnational data item whose value (which is not known until run time) is the program-name in the PROGRAM-ID paragraph of the COBOL program to be cancelled.
CHECKPOINT defines a restart point for the backup process of a process pair and transfers the information that the backup requires to restart. data-name-1 is the name of a data item to checkpoint, typically an item used for an I-O transfer of data that is relevant to the current state of the program and is needed if the backup process is to continue the operation in the event of a failure. data-name-1 cannot be a BASED item. FILE indicates that the next data item is the name or number of a file.
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. After the CHECKPOINT statement transfers the information in the checkpoint list to the backup process, it resets the checkpoint list to empty and its storage space is available to record further message changes.
file-name is the name of the sequential file to be closed. When more than one file-name appears, the files can have different organization and access modes and the optional phrases following one file-name are independent of those following any other file-name. file-info 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.
• Closing Single-Tape and Multiple-Tape Files See Table 59. • 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.
• ◦ Any applicable USE procedure executes. ◦ The file is not closed. COBOL and FUP Closing Procedures Are Incompatible (Multiple-Tape File) When the run-time routine closes a nonfinal reel of a multiple-tape file, it writes an end-of-file mark, a trash record, and an end-of-file mark. When the File Utility Program (FUP) closes a multiple-reel tape file, it writes only the two consecutive end-of-file marks.
result is the identifier of a numeric elementary item or numeric edited elementary item where the result of the computation is to be stored. ROUNDED specifies that the value is rounded before being stored. 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.
Example 80 COMPUTE Statement WORKING-STORAGE SECTION. 01 COMPUTE-RESULT PIC 01 DIAGNOSTIC-FIELD PIC 01 WS-RESULT PIC 01 WS-99 PIC 01 WS-FIVE-ONES PIC 01 EXPONENT PIC 01 A PIC 01 B PIC 01 C PIC 01 U PIC 01 X PIC 999 VALUE X(35). S9(9) VALUE S99 VALUE S9(5) VALUE 9(5) VALUE 9(4)V99. 9(4)V99 VALUE 9(4)V99 VALUE 9(4)V99 VALUE 9V99. ZEROS. ZEROS. 99. 11111. ZERO COMP. 8. 5. 7. This statement specifies that the result be stored in COMPUTE-RESULT without being rounded: COMPUTE COMPUTE-RESULT = (((24.
Example 82 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. • Where CONTINUE Can Appear The CONTINUE statement can appear anywhere a conditional statement or an imperative statement can appear.
prohibited for a file whose access mode is sequential) when there is no USE procedure that applies to the file. imperative-stmt-2 is an imperative statement to be executed (after a declarative procedure) when no exception or an exception other than the invalid-key condition arises during the delete operation. END-DELETE ends the scope of the DELETE statement and makes it a delimited-scope statement.
Example 83 DELETE Statement INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT EMPLOYEE-MASTER ASSIGN TO "EMPMAST" ORGANIZATION IS INDEXED ACCESS MODE IS DYNAMIC RECORD KEY IS EMPLOYEE-NUMBER FILE STATUS IS FILE-STAT. ... FD EMPLOYEE-MASTER LABEL RECORDS ARE OMITTED ... 05 EMPLOYEE-NUMBER PIC X(7). ... PROCEDURE DIVISION. ... DELETE-RECORD.
Example 84 DISPLAY Statement IF IO-STATUS = "23" DISPLAY "I-O ERROR " IO-STATUS " - NO RECORD FOR KEY = " INVOICE-NUMBER END-IF If INVOICE-NUMBER is 00246, the output from the code in Example 74 looks like this: I-O ERROR 23 - NO RECORD FOR KEY = 00246 Usage Considerations: • Differences in the OSS and Guardian Environments In the OSS environment (but not in the Guardian environment), if a DISPLAY statement includes mnemonic-name, it must be either the OSS pathname of a Guardian file or the name of an OS
◦ Figurative constant values A figurative constant is displayed as a single occurrence of the constant value (even if the figurative constant includes the prefix ALL). ◦ Multiple values When you specify more than one value in a DISPLAY statement, DISPLAY combines the values (in the order you specify them) into a single character-string and displays the character-string. The size of the displayed item is the sum of the sizes of all the values.
divisor is the identifier of the elementary numeric data item or numeric literal that is the divisor. dividend is the identifier of an elementary numeric data item that is both the dividend and the receiver of the quotient. ROUNDED specifies that quotient is to be rounded before being 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.
divisor is the identifier of the elementary numeric data item or numeric literal that is the divisor. dividend is the identifier of an elementary numeric data item that is the dividend. quotient is the identifier of the elementary numeric item or elementary numeric edited data item in which the quotient is to be stored. ROUNDED specifies that quotient is to be rounded before being stored.
means store A /B into C. • Precision For information on the precision of HP COBOL division, see Arithmetic Precision (page 261). DIVIDE GIVING REMAINDER DIVIDE GIVING REMAINDER divides one data item into another data item and stores the quotient and remainder in specified data items. divisor is the identifier of the elementary numeric data item or numeric literal that is the divisor. dividend is the identifier of an elementary numeric data item that is the dividend.
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. 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.
Example 85 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 86 DIVIDE BY Statement With GIVING and REMAINDER Phrases WORKING-STORAGE SECTION. 01 ARITHMETIC-WORK-SPACE.
language is unnecessary, because the compiler can determine the language of the called program, but if specified, it must be C or TAL. If language is TAL, the compiler expects a pTAL program. The compiler does not accept TAL programs. routine-name is either the actual name of the called routine or it is a nonnumeric literal whose value is the name of the called routine.
parameter 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 pTAL Routines.). literal is a numeric literal whose value corresponds to a value parameter in the routine being called. arithmetic-expression is an arithmetic expression whose value corresponds to a value parameter in the routine being called.
Scaling of the function’s value (if needed) is performed before the value is assigned to return-value. If the function’s value is larger than the maximum value allowed for a COBOL identifier, the COBOL program terminates with an arithmetic overflow condition during the conversion process. The assignment operation follows MOVE conventions (see MOVE TO (page 368)).
functions, not constructs that are peculiar to HP C++ (such as member functions and templates). • Restrictions on Calling 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.
subject-list subject 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 ANY matches any corresponding selection subject. condition is a relation condition, class condition, condition-name condition, switch-status 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.
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. no-match-imp-stmt is an imperative statement to be executed when no match-imp-stmt applies. After no-match-imp-stmt executes, control passes to the end of the EVALUATE statement. END-EVALUATE ends the scope of the EVALUATE statement and makes it a delimited-scope statement.
Example 91 EVALUATE Statement as a Decision Table EVALUATE XXX ALSO "GONE" ALSO ( A + B ) / C ALSO X = Y WHEN 5 ALSO ANY ALSO 25 ALSO TRUE PERFORM PROC-A WHEN 10 THRU 30 ALSO YYY ALSO 2 ALSO FALSE PERFORM PROC-B WHEN OTHER ADD 1 TO VACUOUS-COUNT END-EVALUATE • Subject-Object Correspondence Every object-list must have an object for every subject in the subject-list. Each object in an object-list must correspond to the subject that has the same ordinal position in the subject-list.
• object EVALUATE uses … ZERO or ZEROS or ZEROES (without NOT or THRU) The value 0 and the class of the corresponding selection subject arithmetic expression (without NOT or THRU) The numeric value determined by the rules for evaluating arithmetic expressions condition The truth value determined by the rules for evaluating conditional expressions ANY No value—ANY matches any selection subject A range of items specified with the keyword THRU but without the keyword NOT The range of all permissibl
Figure 14 Comparison Phase of EVALUATE Statement EVALUATE 329
Figure 15 Execution Phase of the EVALUATE Statement 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 330 Procedure Division Verbs
PROGRAM, PARAGRAPH, SECTION, PERFORM, CYCLE are explained in Table 60. Table 60 EXIT Statement Restrictions and Effects Statement Restrictions Effect EXIT Must appear in a sentence by itself, and that sentence must be the only sentence in the paragraph. Provides a common end point for a group of procedures or indicates the logical end of a called program. Does not affect program compilation or execution.
UNTIL WS-NUMBER-PERF = 99 ADD 3 TO WS-NUMBER-PERF IF WS-NUMBER-PERF = 96 MOVE 1 TO WS-NUMBER-PERF EXIT PERFORM END-IF IF WS-NUMBER-PERF = 1 DISPLAY "DID NOT EXIT PERFORM SUCCESSFULLY" MOVE 99 TO WS-NUMBER-PERF END-IF END-PERFORM. IF WS-NUMBER-PERF = 1 DISPLAY "TEST EXITS-1 FOR EXIT PERFORM SUCCESSFUL." ELSE DISPLAY "TEST EXITS-1 FOR EXIT PERFORM FAILED .". 0001-TEST-EXIT-PERF-EXIT. EXIT. Example 93 EXIT PERFORM CYCLE Statement ?SYMBOLS IDENTIFICATION DIVISION. PROGRAM-ID. EXIT-PERFORM. DATA DIVISION.
Usage Considerations: • EXIT PROGRAM Statement in a Program That Was Not Called If a program that was not called by another program executes an EXIT PROGRAM statement, program execution continues with the next executable statement. • 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).
If the value of pointer is not NULL and is not the address of memory obtained by ALLOCATE, execution terminates with an error. Usage Considerations: • Use only when the STANDARD 2002 directive is in effect. • Freeing memory addressed by a BASED item The ALLOCATE statement can assign an address to either the implicit pointer of a BASED item or a USAGE POINTER item. The FREE statement can free memory only from a USAGE POINTER data item.
• ALTER Statement Because the 1985 COBOL standard classifies ALTER as an obsolete element, and because the ALTER statement can cause maintenance problems, so you are advised not to use it. For more information, see ALTER.
Example 95 Three-Way Conditional GO TO Statement PROCEDURE-BRANCH. GO TO PROC-X PROC-Y PROC-Z DEPENDING ON BRANCH-FLAG MOVE 0 TO BRANCH-FLAG IF IF transfers control if the value of a condition is TRUE or FALSE. Delimited-Scope Form condition is any conditional expression (see Conditional Expressions (page 265)). statement-1 is an imperative or conditional statement to be executed if the value of condition is TRUE. It can contain other IF statements. ELSE ends statement-1.
encounters is considered to correspond to the nearest previous IF phrase that has not already been paired with an ELSE, ELSE … END-IF, or isolated END-IF. • How the Delimited-Scope IF Statement Works The condition is evaluated. If its value is TRUE, statement-1 is executed. If control reaches the point immediately following statement-1 (that is, statement-1 completes without executing a GO TO statement or the equivalent), control passes to the end of the IF statement.
Conditional Form condition is any conditional expression (see Conditional Expressions (page 265)). 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. It is not recommended (see “Conditional Form” (page 338)). ELSE ends statement-1.
one that has not been previously terminated either explicitly or implicitly. The separator period that terminates the sentence also terminates all nested statements. • How the Conditional IF Statement Works The condition is evaluated. If its value is TRUE and NEXT SENTENCE is specified (as opposed to statement-1 ), control passes to the next executable sentence. The ELSE phrase, if present, is ignored.
Figure 17 How the Conditional IF Statement Works Example 96 and Example 97 are equivalent.
Example 96 Simple Conditional IF Statement IF JULIAN-DAYS IS GREATER THAN 59, ADD LEAP-YEAR TO JULIAN-DAYS. Example 97 Delimited-Scope IF Statement IF JULIAN-DAYS IS GREATER THAN 59 ADD LEAP-YEAR TO JULIAN-DAYS END-IF Example 98 and Example 99 are equivalent. Example 98 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.
ELSE NEXT SENTENCE ELSE DISPLAY "0 RECORDS DELETED" MOVE 0 TO FLAG ELSE NEXT SENTENCE ELSE MOVE 1 TO FLAG. Example 103 shows the equivalent delimited-scope IF statement with delimited-scope statements marked. Example 103 Delimited-Scope IF Statement INITIALIZE INITIALIZE sets selected types of data items to predetermined values; for example, numeric data to zeros or alphanumeric data to spaces. receiver is the identifier of an elementary item or data structure.
• Its description cannot include a RENAMES clause. • Its description (and the descriptions of its subordinate data items, if any) cannot include an OCCURS clause with a DEPENDING phrase. The maximum number of receivers in an INITIALIZE statement is 127. replacement specifies the category of elementary item in receiver to which the INITIALIZE operation is to assign a value.
Example 104 INITIALIZE Statements INITIALIZE UNSTRING-COUNTERS INSPECT-COUNTERS REPLACING NUMERIC DATA BY ZERO INITIALIZE UNSTRING-POINTERS INSPECT-POINTERS REPLACING NUMERIC DATA BY 1 The INITIALIZE statement in Example 105 assigns a value of zero to only the numeric-edited items in a table composed of a variety of categories. Example 105 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. ...
• 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.
tallying-phrase tally is the identifier of an elementary numeric item where the number of occurrences is to be stored. The INSPECT 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 INSPECT statement executes. for-clause CHARACTERS specifies that any character in source-string that has not satisfied a previous compare-string relation is counted, regardless of its value.
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. compare-string is the identifier of an elementary data item with USAGE DISPLAY or a nonnumeric literal.
3. 4. 5. • is no next compare-string. When there is no next compare-string, the character position in source-string immediately to the right of the leftmost character position considered in the last comparison cycle is considered to be the leftmost character position, and the comparison cycle begins again with the first compare-string. Whenever a match occurs, tallying occurs as described in tallying.
leftmost such occurrence is at the point where comparison began in the first comparison cycle in which compare-string was eligible to participate. ◦ If CHARACTERS appears, tally is incremented by one for each character matched within source-string. In the Example 106, INSPECT TALLYING checks for spaces in a data item. If spaces are present (J-TALLY is greater than 0), the code reports an error.
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 absolute-replacement CHARACTERS specifies that any character in source-string can be replaced, regardless of its value. If you use CHARACTERS, replace-string and delim-string must each be one character in length. replace-string is the identifier of an elementary item with USAGE DISPLAY or a nonnumeric literal.
AFTER specifies that scanning starts at the position immediately following the character or characters matching delim-string. If INSPECT does not find delim-string in source-string, it does not scan source-string. INITIAL is for documentation only and has no effect. 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.
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. ◦ LEADING causes each contiguous occurrence of compare-string in source-string to be replaced by replace-string, provided that the leftmost occurrence is at the point where comparison began in the first comparison cycle in which compare-string was eligible to participate.
source-string is the identifier of an elementary item or data structure with USAGE DISPLAY. Inspection proceeds from left to right within source-string. tallying-phrase tally is the identifier of an elementary numeric item where the number of occurrences is to be stored. The INSPECT 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 INSPECT statement executes.
AFTER specifies that scanning starts at the position immediately following the character or characters matching delim-string. If INSPECT does not find delim-string in source-string, it does not scan source-string . INITIAL is for documentation only and has no effect. 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.
position 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. If INSPECT does not find delim-string in source-string, it scans all of source-string.
FIRST specifies that only the first occurrence of compare-string is replaced. compare-string is the identifier of any type of elementary item with USAGE DISPLAY or nonnumeric literal. It can be a figurative constant that does not include the keyword ALL, in which case it represents one character. replace-string is an identifier of any type of elementary item with USAGE DISPLAY or a nonnumeric literal.
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. source-string is the identifier of an elementary item or data structure with USAGE DISPLAY. Inspection proceeds from left to right within source-string. match compare-string is the identifier of any type of elementary item with USAGE DISPLAY or a nonnumeric literal.
INITIAL is for documentation only and has no effect. 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. Example 110 shifts any lowercase letters found in IN-BUFFER to uppercase letters. Example 110 INSPECT CONVERTING Statement INSPECT IN-BUFFER CONVERTING "abcdefghijklmnopqrstuvwxyz" TO "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
file-name is the file description name of the file to lock. For LOCKFILE to work, file-name must specify a disk file. 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.
one terminated (see Expired Time Limit (page 256)). If error message 42 or 90 is returned after the declarative procedure executes, the run unit terminates abnormally. • Interaction of LOCKFILE and READ LOCK Statements If your process executes a READ LOCK statement on a file that it or any other process has locked with a LOCKFILE statement, or your process executes a LOCKFILE statement against a file that has an outstanding READ LOCK, the TIME LIMIT phrase determines what happens.
merge-file is a sort-merge file description (SD) name. merge-file can have variable-length or fixed-length records. Its record description entry defines the data item or items used as the key or keys. key-specifier ASCENDING specifies ascending merge order. DESCENDING specifies descending merge order. key is a data item to be used as a merge key.
merge-in-1, merge-in-2, merge-in-n are file description (FD) names. Multiple-reel tape files are permitted. The files can have variable-length or fixed-length records. The size of the records must be less than 4073 bytes for disk files. If merge-file has variable-length records, then the records of merge-in-1, merge-in-2, and merge-in-n must not be shorter than the shortest record that merge-file can have or longer than the longest record that merge-file can have.
alphabet-name must be associated with a collating sequence in the SPECIAL-NAMES paragraph of the Environment Division (see SPECIAL-NAMES Paragraph). USING phrase merge-in-1, merge-in-2, merge-in-n are file description (FD) names. Multiple-reel tape files are permitted. The files can have variable-length or fixed-length records.
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.
• Output Procedure The output procedure is outproc-1 or outproc-1 through outproc-2. The output procedure must have a RETURN statement. An output procedure can be any procedure needed to select, modify, or copy the records that the RETURN statement makes available to merge-file one at a time in merged order.
PERFORM retrieves the merge-file records by executing implicit RETURN statements. When the implicit PERFORM statement finishes executing, control returns to the merge operation. If the MERGE statement has a GIVING phrase, the output phase transfers the merged records to one or more merge-out files. When the MERGE statement begins execution, each merge-out file must be closed but not locked. The output phase uses implicit OPEN statements to open each merge-out file in OUTPUT mode.
The swap file is a temporary file with a volume but no subvolume. If you specify a swap file, including a volume, the volume is used but the file-id is not. If you specify only a file-id, the default volume is used. ◦ If COBOL_SET_SORT_PARAM_TEXT_ specifies a SWAP-FILE, then the swap file is created on that file’s volume.
Example 112 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.
Usage Considerations: • Evaluation of Subscripts and Indexes Subscripts or indexes in sender are evaluated only once, immediately before data is moved to the first receiver. Subscripts or indexes in receivers are evaluated in the order in which the receivers are specified.
size is equal to the number of 9s in the PICTURE clause. If its USAGE is not DISPLAY, it is converted to DISPLAY for the move operation. For example: PIC 999V99 VALUE 123.45 is treated as if it were PIC X(5); that is, as the value 12345. If the number of digits in sender is greater than 18 (for example, when a NUMVAL function is used), the leftmost 18 digits are moved and any to the right of this are discarded. The COBOL standard requires that the numeric item have no decimal positions.
* * MOVE SPACES TO RECORD-IN RECORD-IN is set to " " (9 spaces) MOVE ZEROS TO ITEM-B * * ITEM-B is set to 00v00 where "v" marks the decimal location MOVE 5280 TO ITEM-C. * * * * * * * * * * * * ITEM-C is set to " 5,280.00" MOVE ITEM-C TO TEMP-3. TEMP-3 is set to 05280v000 where "v" marks the decimal location MOVE ZEROS TO TEMP-5. Each 2-digit T in TEMP-5 is set to the 2-character value "00". Do not move ZEROS to any group containing COMP or NATIVE-n items, because the operation delivers characters.
multiplicand is a numeric literal or the identifier of an elementary numeric data item. multiplier is the identifier of an elementary numeric data item. ROUNDED specifies that the product is to be rounded before being stored as the new value of multiplier. 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 multiplier.
results in A being replaced by 4 x A and B being replaced by 16 x B. • Operand Identification For each multiplier, operand identification occurs just prior to the multiply-and store operation. For example, in the statement MULTIPLY 4 BY A B C(B) the subscript is not evaluated until B has been multiplied by 4. See Operand Identification (page 242).
multiplicand is a numeric literal or the identifier of an elementary numeric data item. multiplier is a numeric literal or the identifier of an elementary numeric data item. result is the identifier of an elementary numeric or numeric edited data item that is to receive the product. ROUNDED specifies that the product is to be rounded before being stored in result.
means store A x B into C, D, and E. The values of A and B do not change. • Operand Identification For each result, operand identification occurs just prior to the storage operation. For example, in the statement MULTIPLY A BY B GIVING C D(C) the subscript is not evaluated until C has been set to A x B. See Operand Identification (page 242).
file-specification INPUT specifies that the file or files in input-file-description are being opened for reading only. input-file-description for a sequential, relative, indexed, or queue file: for a line sequential file: 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.
SHARED allows other processes to read or write the file while this process is open. SHARED is the default for terminals. PROTECTED allows other processes to read but not write the file while this process is open. PROTECTED is the default for input files that are not terminals. EXCLUSIVE prevents other processes from reading or writing the file while this process is open. EXCLUSIVE is the default for all other files.
for a line sequential file: 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. I-O specifies that the file or files in i-o-file-description are being opened for reading or writing. i-o-file-description for a sequential, relative, indexed, or queue file: I-O mode is not supported for line sequential files.
for a line sequential file: extfile is the file description file name of a sequential file to open in EXTEND mode, for write operations that append records to the file. The file is positioned after the last logical record when opened. All operations on the file must be write operations, as if the file had been opened in OUTPUT mode. If the file is an Enscribe unstructured file, its size must be a multiple of the record size.
• ◦ A DEFINE of the class MAP, SPOOL, or TAPE (see DEFINEs (page 593)) ◦ The COBOL_ASSIGN_ routine (see COBOL_ASSIGN_ (page 646)) Devices That You Can Open The OPEN statement can open devices that accept normal read and write operations (as opposed to read and write operations that require special control information).
Table 62 I-O Status Codes for Unsuccessful Open Operations (continued) • I-O Status Code Unsuccessful Open Operation “38” The file is locked. “39” The attributes of the file under the file system do not correspond to the attributes specified for the file in the program, for example: ◦ The file was to be opened for INPUT but it is assigned to a printer device. ◦ The file description includes a LINAGE clause, but the file is assigned to a tape drive.
If a file opened for EXTEND is an Enscribe unstructured file, its size must be a multiple of the record size. • Key of Reference For a relative file, the key of reference is the relative key. For an indexed or queue file, the key of reference is the prime record key. • Locked System Files An HP COBOL program cannot open a system file that it closed and locked earlier in its current execution.
Table 63 I-O Statements You Can Use in Different Open Modes (continued) Open Mode I-O Statement INPUT OUTPUT I-O EXTEND R = Relative S = Sequential S* = Sequential (but only for START specifying an alternate key) Acc is the file’s access mode: S = Sequential R = Random D = Dynamic ALL means all organizations and access modes • Nonexistent Files When the INPUT, I-O, or EXTEND phrase applies and the SELECT clause includes the OPTIONAL phrase, the run-time routines determine whether or not the file is
Table 64 Open Modes for Files Assigned to Processes (continued) Open Mode Action the PROMPT phrase, is the only I-O statement that can be executed on the file; however, prompts are ignored in this open mode. OUTPUT or EXTEND If the process has a device subtype of 31, it is a spooler process, treated like a printer.
• – 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). – If the file code is 101 (EDIT format) because either the file already exists with that code or an ASSIGN command with a CODE phrase has been processed for the file, the file can be opened in INPUT, OUTPUT, or EXTEND modes.
entry-sequenced; if it is declared ORGANIZATION RELATIVE, the file must be relative; and if it is declared ORGANIZATION INDEXED, the file must be key-sequenced). ◦ If the file is key sequenced or has alternate keys, the declaration of the keys in the COBOL program must agree with the declaration of the keys in the file system. ◦ The file security must be appropriate for the open mode. You cannot open a file for INPUT or I-O if it is secured against your reading it.
Table 67 Open Modes for Structured Disk Files Present at Run Time (continued) Open Mode Action The file position indicator is set to the first record in the file. • 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.
A file that no process has open can be opened by any single process with any exclusion mode. If some process already has a file open EXCLUSIVE, no other process can open the file. A file intended for multi-user access must specify SHARED. If some process already has a file open SHARED for any access mode except OUTPUT, another process can open the same file SHARED for any access mode.
Example 117 OPEN Statements ?NONSTOP IDENTIFICATION DIVISION. ... INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT EMPLOYEE-MASTER ASSIGN TO "EMPMAST" ORGANIZATION IS INDEXED ACCESS MODE IS DYNAMIC. ... SELECT LISTING-FILE ASSIGN TO "LISTOUT" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL. ... PROCEDURE DIVISION. ... OPEN I-O EMPLOYEE-MASTER WITH TIME LIMITS SYNCDEPTH 1 OPEN OUTPUT LISTING-FILE PERFORM PERFORM executes one or more procedures in a program, simply or with looping.
END-PERFORM ends the scope of the PERFORM statement, causing the PERFORM to be a delimited-scope statement. If the PERFORM statement does not end with an END-PERFORM phrase, it is an out-of-line PERFORM. If the PERFORM statement ends with an END-PERFORM phrase, it is an in-line PERFORM. Usage Considerations: • Execution Cycle of a PERFORM Statement (PERFORM Cycle) Each execution of the range of a PERFORM statement is called a “PERFORM cycle.
The descriptions of the action of the PERFORM statement in this section are expressed in terms of the out-of-line PERFORM statement. The execution of an in-line PERFORM statement is exactly equivalent to that of an out-of-line PERFORM statement, with the exception that the statements contained in imperative-statement in the in-line PERFORM statement are executed in place of the statements within the range of procedure-group.
The maximum number of PERFORM statements that can be nested is 50. Violation of the preceding rules often causes run-time diagnostic 148. • 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).
Example 120 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 ... END-READ END-PERFORM PERFORM TIMES PERFORM TIMES executes a procedure, a group of procedures, or an imperative statement a specified number of times. procedure-group proc-1 is a paragraph-name or section-name.
out-of-line PERFORM. If the PERFORM statement ends with an END-PERFORM phrase, it is an in-line PERFORM. Example 121 specifies that the value of the identifier TRAN-COUNT controls the number of PERFORM cycles: Example 121 PERFORM TIMES Statement PERFORM LIST-TRANSACTIONS TRAN-COUNT TIMES. In Example 122, an in-line PERFORM uses a TIMES phrase to initialize a table of squares.
proc-1 is a paragraph-name or section-name. Without THROUGH or THRU, proc-1 identifies the only procedure that is to be executed. With THROUGH or THRU, proc-1 identifies the first procedure of a group. THROUGH, THRU indicate that a group of procedures is to be executed. proc-2 identifies the last procedure in the group. test-site 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.
Example 123 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.
proc-2 is the last procedure in the group. test-site BEFORE specifies that the condition is to be tested before the perform range is executed. This is the default. AFTER specifies that the condition is to be tested after the perform range is executed. varying-phrase specifies the outermost loop of the PERFORM statement control logic. 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.
vary-2 is a numeric data item or an index. It is an iteration variable—a variable whose value changes each time the process executes the code in an inner loop. base-2 is a numeric literal, an index-name, or the identifier of a numeric data item. It is the initial value for vary-2. step-2 is a numeric literal or the identifier of a numeric data item. It is the increment that is to be added to vary-2 each time control returns from the end of the range of the PERFORM. The value of step-2 must not be 0.
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 19 Execution of a PERFORM VARYING Statement With a TEST BEFORE Phrase and One AFTER Phrase After termination of the PERFORM statement, vary-1 has the value assigned, either by initialization or augmentation, at the point where the evaluation of condition-1 gave a result of TRUE. vary-2 has the value assigned by its last initialization from the base-2.
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.
Figure 20 Execution of a PERFORM VARYING Statement With a TEST AFTER Phrase and Without an AFTER Phrase List 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 the specified set of statements is executed. This is considered the inner loop. Each iteration of the inner loop ends by evaluating condition-2.
Figure 21 Execution of a PERFORM VARYING Statement With a TEST AFTER Phrase and One AFTER Phrase After termination of the PERFORM statement, vary-1 and vary-2 have the values they contained at the end of the last execution of the specified set of statements.
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.
Example 124 PERFORM VARYING Statement Used to Display a List WORKING-STORAGE SECTION. 01 COMMAND-DATA. 05 FILLER PIC X(36) VALUE "ADD - ADD A NEW RECORD". 05 FILLER PIC X(36) VALUE "DELETE - DELETE A RECORD". ... 01 COMMAND-TABLE REDEFINES COMMAND-DATA. 05 COMMAND-ENTRY PIC X(36) OCCURS 10 TIMES. 01 COMMAND-NUMBERS. 05 NO-OF-COMMANDS PIC 99 VALUE 9. 05 COMMAND-SUB PIC 99 COMP VALUE 1. PROCEDURE DIVISION. ...
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). NEXT is required for sequential reading of a relative, indexed, or queue file whose access is DYNAMIC. REVERSED indicates that the prior record is to be read (that is, the record before the current record, according to the key of reference). For restrictions, see Restrictions on Reversed.
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. PROMPT displays prompt-item to the file before a READ operation (as in a COBOL requester communicating with a server).
If REVERSED is specified, then: ◦ Neither LOCK nor PROMPT prompt-item can be specified. ◦ REVERSED cancels the effect of GENERIC (a positioning mode that the START statement can specify). REVERSED is not recommended if these conditions are true, because it is very inefficient: • ◦ File organization is RELATIVE. ◦ The relative key is the key of reference. ◦ Records are not contiguous.
◦ PROMPT phrase When the PROMPT phrase appears, and the device with which the file is associated is either a terminal or a process (typically, a server), and the file’s open mode is I-O, the value of prompt-item is sent to the file as part of the read operation. 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.
If, at the start of the read operation, the file position indicator is at the end-of-file mark or its value is not defined, execution of the READ statement is unsuccessful, and the file-status data item is set to a value other than “00.
If the file position indicator was established by an earlier READ statement, and its setting does not reflect an alternate record key for which duplicates are allowed, then the record selected for retrieval is one of: ◦ If NEXT is specified or implied, the first existing record in the file whose record number or key value is greater than the file position indicator ◦ If REVERSED is specified, the first existing record in the file whose record number or key value is less than the file position indicator
• Relative Key Data Item of Relative Files A successful execution of the READ statement for a relative file also assigns the relative record number of the retrieved record to the file’s relative key data item if the file description defines one. The relative key data item is optional for relative files being accessed sequentially. • LOCK Phrase When the READ statement includes a LOCK phrase, the read operation also locks the retrieved record.
• Handling Exception Conditions The READ statement enables you to specify explicitly that when an at-end condition occurs, a particular statement is to be executed. For general exception handling, a group of statements called declaratives can be placed at the beginning of the Procedure Division to respond to error conditions arising for a single file or for all files open in the same input mode (INPUT, OUTPUT, I-O, or EXTEND). See USE AFTER EXCEPTION (page 484).
• Use of wait-time wait-time must be either a numeric data item or a numeric literal, signed or unsigned, having a maximum of seven digits to the left of the decimal. Any fractional part to the right of the decimal is rounded to two decimal places; for example: 05 WAIT-FILEX PIC 9(7)V9(2) COMPUTATIONAL. A nonnegative value of wait-time indicates the time interval within which the operation must complete.
• 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.
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. ... MOVE 1 TO CUSTOMER-NUMBER START MASTER-IN KEY IS LESS THAN CUSTOMER-NUMBER IF MASTER-IN-FILE-STATUS NOT EQUAL TO ZERO PERFORM START-ERROR-ROUTINE ELSE READ MASTER-IN NEXT RECORD AT END PERFORM WRITE-TOTALS-AND-QUIT END-READ END-IF Example 128 Reading $RECEIVE With Timed Input-Output IDENTIFICATION DIVISION. ...
END-IF ... READ for Line Sequential Files READ for line sequential files reads the next record in the file. 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. data-name cannot be an index-name or the identifier of an index data item.
See these usage considerations in READ for Sequential or Dynamic Access (page 405): • In Action of the READ Statement (Sequential Read): ◦ Retrieval of a logical record ◦ Alignment within record area ◦ Unsuccessful read operation • File-Status Data Item • Retrieval • GUARDIAN-ERR Special Register • Handling Exception Conditions • Variable-Length Records • Setting the Value of the DEPENDING Item (Variable-Length Records) • Concept of Next Record • Sequential Block Buffering and HP COBO
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. 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.
key is the key of reference. If file-name specifies a relative file, key must be an alternate key for that file. If file name specifies an indexed file, key can be the prime key or an alternate key. If file-name specifies a queue file, key must be the prime key for that file. Unlike the START statement, the KEY clause provides only APPROXIMATE positioning—not GENERIC positioning.
One possible I-O status code that results from unsuccessful random or dynamic read operations is: I-O Status Code Unsuccessful Random or Dynamic Read Operation “23” The invalid-key condition exists, and the read operation is unsuccessful For other possible I-O status codes representing successful and unsuccessful operations, see File-Status Data Item under READ for Sequential or Dynamic Access (page 405).
◦ Interaction of LOCKFILE and READ LOCK Statements ◦ INTO Phrase ◦ GUARDIAN-ERR Special Register ◦ Variable-Length Records ◦ Use of wait-time Example 129 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. ...
file-name is a file name described by a sort-merge file description (SD) entry. data-name is the identifier of the area in your program (other than record area associated with file-name ) where the record is stored. imperative-stmt-1 is an imperative statement to be performed when the end of the file is encountered at the beginning of the return operation. This phrase is required.
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. data-name cannot specify an index-name or an index data item.
Usage Considerations: • Action of the REWRITE Statement The rewrite operation releases a logical record to the run-time routines as a replacement for a record that exists in the file. The size of the logical record (the number of character positions in the record) is determined: ◦ When the file has fixed length records (the file description entry includes a RECORD CONTAINS n CHARACTERS, or contains no RECORD clause at all), the size of the logical record is the fixed record size.
NOTE: After an unsuccessful execution of a REWRITE statement, these values are unpredictable: ◦ The value of the file position indicator ◦ The contents of the current record area ◦ The key of reference Any key value found in the current record area: that is, the value of the current key for indexed files or the value of the alternate key for any type of file-system file, because in HP COBOL sequential and relative files can have alternate keys.
accessed by the READ statement; therefore, for an indexed or queue file, the program logic must verify that the prime record key in the logical record has the same value as the prime record key of the record previously read. ◦ Random-access or dynamic-access files For relative files with random or dynamic access, the record replaced is the one indicated by the value of the RELATIVE KEY item. If the old record does not exist, an invalid-key condition occurs.
NOTE: Invalid-key conditions are taken care of by USE procedures instead of by INVALID KEY phrases on the READ and REWRITE statements. SEARCH SEARCH scans a table for an element that satisfies a condition.
indexer cannot specify a special register. indexer cannot be subscripted by the first (or the only) index-name specified in the INDEXED phrase of the OCCURS clause of the definition of table. When indexer is from the INDEXED phrase, that index is used to start the search. When it is a separate item, index-1 from the INDEXED option is used to search table, and indexer is incremented by 1 when index-1 is incremented. The SEARCH statement does not initialize its index (either indexer or index-1).
If, when execution of the SEARCH statement begins, the value of the index-name corresponds to an occurrence number greater than the one that identifies the last element of the table, the at-end condition exists and the search operation terminates immediately; otherwise, the search operation proceeds: 1. Each condition is evaluated, in the order in which they appear in the statement, until one of them evaluates to TRUE or all of them evaluate to FALSE.
Figure 22 Execution of a SEARCH VARYING Statement With WHEN Phrases SEARCH 431
Example 131 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. ... SET TABLE-INDEX TO 1 SEARCH COMMAND-ENTRIES VARYING TABLE-INDEX AT END PERFORM COMMAND-ERROR-ROUTINE WHEN COMMAND-ENTRIES(TABLE-INDEX) = COMMAND-IN CONTINUE END-SEARCH ...
match-1, match-n are matches that terminate the search operation. identifier-1 is a data-name that is subscripted by the first index-name listed in the INDEXED clause that defines the indexes of table, along with any other subscripts that are required to identify the element in a multidimensional table. identifier-1 must be defined as the first key of table. It can be qualified, but it cannot include a reference modifier. equal-part identifier-2 is any identifier. literal-2 is any literal.
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, imperative-stmt-2, or both can be CONTINUE statements. • Binary Search HP COBOL performs a binary search when these conditions are met: ◦ Each condition-name referenced in the WHEN clause must be defined as having a single value.
• Execution The SEARCH ALL statement specifies a search through the elements of a table. The results of a SEARCH ALL statement are predictable only when both of these are true: ◦ The data in the table are ordered in the manner described in the KEY phrase of the OCCURS clause that describes the table. ◦ The condition specified in the WHEN phrase (called the “target condition”) evaluates to TRUE only during the consideration of exactly one of the table elements.
... COMMAND-NUMBERS. 05 COMMAND-INDEX PIC 99 COMP VALUE 1. 05 COMMAND-IN PIC X(6). ... PROCEDURE DIVISION. ... SEARCH ALL COMMAND-ENTRIES AT END PERFORM COMMAND-ERROR-ROUTINE GO TO GET-ANOTHER-COMMAND WHEN COMMAND-ENTRIES(TABLE-INDEX) = COMMAND-IN CONTINUE END-SEARCH SET COMMAND-INDEX TO TABLE-INDEX ... 01 SET SET TO SET TO sets the values of data item addresses, indexes, switches, or conditional variables.
If address is ADDRESS OF identifier-3, then identifier-1 is linked to the address of identifier-3 (not the value of identifier-3 ). If address is identifier-4, then identifier-1 is linked to the address that identifier-4 contains. If address is NULL or NULLS, then identifier-1 is linked to a null address guaranteed to point to no data item. identifier-2 is a data item with USAGE POINTER. If pointer is identifier-2, the address specified by address is moved into identifier-2.
• Set an external switch to ON or OFF • Set a conditional variable to a value that makes an associated condition true identifier-1 is the name of an integer elementary item or an index data item to be set. identifier-2 is the name of an integer data item or an index data item. index-name-1 is the name of an index to be set. index-name-2 is the name of an index. integer is a numeric literal having no fractional part. If signed, it must have a positive value.
Table 68 summarizes these rules: ◦ The receiving item (index-name-n ) is set to a value causing it to refer to the table element corresponding in occurrence number to the table element specified by the sending item (identifier-1, index-name-1, or integer ). If the sending item is an index data item, or if it is an index-name that is related to the same table as the receiving item, no conversion occurs.
• integer Out of Range In the statement SET index-name-n TO integer the value of integer must be at least zero and not greater than the maximum number of occurrences plus one. If the value of integer is outside this range, a warning message is produced. If the warning message is produced and subscript checking is active, the run unit terminates abnormally.
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.
sd-name is the file name given in a sort-merge file description (SD) entry. key-specifier specifies one or more of the items described in the record descriptions of sd-name. key is used to sort the records in ascending or descending order. The first key is compared first, the second next, and so on. Two records equal in all sort keys are sorted by their original order in the file.
input-specifier-1 specifies a procedure that sends records one at a time to SORT using one or more RELEASE statements. The procedure input-specifier-1 cannot terminate before it finishes sending records. inproc-1, inproc-2 are sections or paragraphs of the Procedure Division. input-specifier-2 specifies one or more files (a maximum of 31) that contain the records to be sorted. infile is a file description name.
specifies one or more files (a maximum of 31) where the sorted records are to be written. outfile is a file description name. During execution of the SORT statement, outfile must be closed and cannot be locked.
If the SELECT statement associated with sd-name specifies the =_SORT_DEFAULTS DEFINE as the define-name-literal, then: ◦ If the =_SORT_DEFAULTS DEFINE exists and specifies a swap file, then the swap file is created on that file’s volume. ◦ If the =_SORT_DEFAULTS DEFINE exists but does not specify a swap file, then the swap file is created on the volume used for the scratch file. ◦ If no =_SORT_DEFAULTS DEFINE exists, then the swap file is created on the volume used for the scratch file.
If infile specifies a file whose SELECT clause does not include the OPTIONAL phrase, the file must be present at execution time. If an instance of outfile identifies an indexed or queue file, the major key must be associated with the ASCENDING phrase and the first instance of key must specify the same character positions in its record as are specified for the prime record key for that file.
cause the execution of any statement that manipulates any of the input files or accesses the record area associated with any input file. ◦ INPUT PROCEDURE phrase If the INPUT PROCEDURE phrase appears, the input phase executes an implicit PERFORM procedure-group statement (where procedure-group is procedure name, optionally followed by THROUGH or THRU and another procedure name).
The open and close operations are equivalent to OPEN OUTPUT and CLOSE statements having no optional phrases. All of these implicit functions are performed such that any associated declarative procedures are executed; however, the execution of a declarative procedure must not cause the execution of any statement that manipulates any of the output files or accesses the record area associated with any output file.
01 LABEL RECORDS ARE OMITTED RECORD CONTAINS 52 CHARACTERS. EMPLOYEE-DETAIL. 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. 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. .
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.
relationship If position is present, relationship is limited to: key determines, with relationship, where the file position indicator is to be set. The file position indicator is to be set such that the next record to be read from file-name contains a key value having the specified relationship to the current value of key. The value of key is restricted by the presence or absence of position.
position specifies that a combination of alternate key or prime key (specified by key in the KEY phrase) and position-key (specified either by the file prime key or by a unique alternate key) is to be used to position the file. This phrase is not permitted for files having sequential organization, or files having the INSERTIONORDER attribute. BEFORE specifies that the file position indicator is set to the record before the position defined by the values of key and position-key .
complete alternate key is used for positioning (as explained in START Statement With the POSITION Phrase). 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. Any fractional portion is truncated to two decimal places.
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. The execution of the START statement does not alter the contents of the record area associated with file-name or the content of the depending item specified in the DEPENDING phrase of the RECORD clause that describes file-name.
• Invalid-Key Condition If the START statement contains the INVALID KEY phrase, control passes to the imperative statement in that phrase, and no USE procedure is executed. If the START statement does not contain an INVALID KEY phrase, but an applicable USE procedure exists, that procedure is executed. • Key Data Item The data item specified by key is the comparison data item for the start operation.
When the execution of the START statement is successful, the key of reference established for the start operation is also used for any subsequently executed READ NEXT statements for the file, until the execution of some statement explicitly establishes a different key of reference. Whenever the start operation is successful, if a NOT INVALID KEY phrase is specified, control passes to the imperative statement in that phrase.
positioning and to establish the key of reference and the comparison length (for partial keys) accompanies the request. ◦ GENERIC Positioning Mode and the POSITION Phrase The choice of APPROXIMATE or GENERIC positioning mode, coupled with the KEY clause, govern where the next READ statement starts reading and what constitutes the end of the file (or the beginning of the file, if the file is being read in reverse).
Table 69 Using the POSITION and KEY Phrases (continued) Position-Key Key Length Used and Restriction Effect 4 (which is the length of the Relative key used alone relative key) Prime key (ORGANIZATION Alternate or alternate (1:n ) INDEXED) Prime key length (entire alternate) + length (prime) < 2541 Full value of alternate AND of prime used length (prime) Prime key used alone Alternate key Same alternate or alternate (ORGANIZATION INDEXED) (1:n ) Full alternate must be unique Full value of alternate
05 EMP-NAME. 10 LAST-NAME. 15 FIRST-LETTER 15 FILLER 10 FIRST-NAME PIC X. PIC X(14). PIC X(9). ... PROCEDURE DIVISION. ... OPEN I-O INPUT-FILE ... MOVE "G" TO FIRST-LETTER START INPUT-FILE KEY = FIRST-LETTER GENERIC INVALID KEY GO TO START-ERROR-ROUTINE END-START READ INPUT-FILE AT END Example 136, 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.
ELSE * * * * * * * START EMP-FILE KEY = DEPT-NO OF EMP-DATA AFTER POSITION EMP-NO GENERIC END-IF Zero the counter Perform (with test after) until EOF or 10 employees found: Read EMP-FILE NEXT record If EOF, return array to requester with signal for EOF else add 1 to the counter copy info to the array end-if In Example 136, suppose that department 1572 has 12 employees: 000131Smith 001552Nguyen 001744Dietrich 001745Wellhausen 001746Thomas 001991Chew 004451O'Hara 005433Logan 006112McClure 009733Kinoshita 0
2 This option is the same as option 1 except that if the primary process encounters a trap condition, it enters the DEBUG procedure instead of being terminated abnormally. (For an explanation of traps and the DEBUG procedure, see the Guardian Programmer’s Guide.) 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.
the backup’s processor is operable, the fault-tolerant facility re-creates the backup process immediately. If the backup’s processor is inoperable, the fault-tolerant facility re-creates the backup process when backup’s processor becomes operable.
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. If a data item is numeric, it must be described as an integer without P in its PICTURE character-string. When a figurative constant is used, it represents a one-character nonnumeric literal. delimiter is an alphanumeric literal or the identifier of a DISPLAY data item. It specifies the portion of part-1 that is moved.
pointer ’s value is its initial value plus the total number of characters moved. pointer cannot reference a special register. imperative-stmt-1 is an imperative statement to be executed when the internal index points past the end of result. OVERFLOW also occurs if the initial value of pointer is less than 1 or greater than the length of result. If no OVERFLOW statement is given, control passes to the next statement after STRING.
string is moved into the receiving item character position designated by the pointer value, which is incremented by 1 after each character is moved. ◦ Overflowing the size of the receiving item Overflow occurs if not all of the characters of a transfer string can be moved to the receiving item. The overflow condition exists when the pointer value exceeds the size of the receiving item during assignment of any transfer string or after completing assignment of any transfer string except the last one.
DISPLAY "ENTER PART-2 (MAX 26 CHARACTERS)" ACCEPT PART-2 DISPLAY "ENTER PART-3 (MAX 10 CHARACTERS)" ACCEPT PART-3 MOVE 1 TO COUNT-1 STRING PART-1 DELIMITED BY ZERO SPACE DELIMITED BY SIZE PART-2 DELIMITED BY SPACE SPACE DELIMITED BY SIZE PART-3 DELIMITED BY SPACE INTO RESULT-1 WITH POINTER COUNT-1 END-STRING DISPLAY "PART-1 = " PART-1 DISPLAY "PART-2 = " PART-2 DISPLAY "PART-3 = " PART-3 DISPLAY "COUNT-1 = " COUNT-1 DISPLAY "RESULT-1 AFTER STRING = " RESULT-1 STOP RUN.
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. 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. imperative-stmt-2 is an imperative statement to be executed when no size error is detected in the subtraction or in storing the result.
means store D - (A + B + C) in D and store E - (A + B + C) in E. • Specifying the Same Data Item for More Than One Result If more than one minuend-result specifies the same data item, the final value of that item reflects multiple subtractions of the intermediate sum. For example, SUBTRACT A FROM B B means the final value of B is (B - A) - A.
subtrahend is a numeric literal or the identifier of a numeric elementary data item. 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.
Usage Considerations: • Mathematics The values of all the subtrahend s are totaled. That sum is subtracted from minuend, and the result of this subtraction is then stored after rounding, if ROUNDED was specified as the new value of each result. For example, the statement SUBTRACT A B C FROM D GIVING E means store D - (A + B + C) in E. • Changing Operand Values The SUBTRACT GIVING statement does not change the value of any subtrahend or the minuend, unless one is also named as a result.
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. The composite picture of any pair of items aligned by decimal points must not involve more than 18 digits of representation.
Usage Considerations: • Definition of Correspondence Groups of data correspond if they have the same names and qualifier names, beyond the group-names in the SUBTRACT statement, and if they meet restraints explained under CORRESPONDING Phrase (page 243). • Problem Inherent in Using SUBTRACT CORRESPONDING The SUBTRACT CORRESPONDING statement can save keystrokes, but can cause problems when someone adds a name to a data structure: the name might be included in an unintended subtraction operation.
Example 138 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. ... UNLOCKRECORD UNLOCKRECORD restores access by other processes to the last record read (the record selected by the file position indicator).
• Disk Files Only The UNLOCKRECORD statement has no effect unless the file specified is a disk file. • Key of Reference, File Position Indicator, and Record Area The key of reference, the file position indicator, and the record area are not affected by the execution of an UNLOCKRECORD statement, whether it succeeded or not. UNSTRING UNSTRING partitions a data item (the source) into strings of consecutive characters and stores those strings into other data items (the results).
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. source can be qualified or subscripted, but cannot include reference modification. 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.
delim-2 is the identifier of an alphanumeric data item or an alphanumeric literal. If it is a figurative constant, it must represent a single character. The delimiter delim-2 marks the end of a portion of the value of source. The value that the unstring operation stores into a result item does not include the value of delim-2. result-list result specifies the identifier of an alphanumeric, alphabetic, or numeric DISPLAY elementary data item into which the unstring operation copies characters from source.
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.
1. Initialization phase In the initialization phase, the UNSTRING statement performs these initialization operations before beginning to cycle through the list of INTO phrases: 2. ◦ It establishes the source item as the sending area. Even if the item has a variable size (is defined with the OCCURS DEPENDING clause), the initial size is used as the sending area size for the duration of statement execution.
UNSTRING U DELIMITED BY SPACE INTO WORD-1 WORD-2 WORD-3 WORD-4 WORD-5 WORD-6 the first item to be copied is “The” and the second is “UNSTRING” and so on. If you specify two or more delimiters, the unstring operation compares their values with the sending area in the same order as they appear in the phrase. If a match occurs, the corresponding set of characters in the sending area forms the delimiter string; any delimiters not yet tested are ignored.
item and copies it to delimstore in accordance with the rules for the MOVE statement. If the delimiting condition is the end of the sending area (that is, there is no delimiter string), then the unstring operation fills the delimiter data item with spaces. If the delimiter is described as a figurative constant with the ALL qualifier, only one occurrence of the unqualified figurative constant is moved. If you execute UNSTRING U DELIMITED BY SPACE OR "." INTO WORD-1 DELIMITER IN DEL-1 ...
If the sending area still contains any unexamined characters and the current receiving area is not the last one, then the unstring operation establishes the next result item as the new current receiving area and begins another unstring cycle. If the sending area still contains any unexamined characters but the current receiving area is the last one, then the overflow condition exists and the unstring operation terminates.
Example 139 UNSTRING Statement Input: DATA DIVISION. WORKING-STORAGE SECTION. 77 SOURCE-STRING PIC X(18) VALUE "12345 MICKEY ABCDE". 77 UNPART-1 PIC X(3). 77 UNPART-2 PIC X(3). 77 UNPART-3 PIC X(3). PROCEDURE DIVISION. A10-START. UNSTRING SOURCE-STRING DELIMITED BY " " INTO UNPART-1 UNPART-2 UNPART-3 DISPLAY "UNPART-1 = " UNPART-1 DISPLAY "UNPART-2 = " UNPART-2 DISPLAY "UNPART-3 = " UNPART-3 STOP RUN.
Example 140 UNSTRING Statement WORKING-STORAGE SECTION. 01 NAMES-TABLE. 03 NAMES PIC X(50) OCCURS 10 TIMES INDEXED BY NAME-INDEX, FIRST-NAME-INDEX. 01 WORK-GROUP. 03 NAME-COUNT PIC 99 COMP. 03 WHOLE-NAME PIC X(50). 03 LAST-NAME PIC X(50). 03 REST-OF-NAME PIC X(50). 03 POINTER-1 PIC 99 COMP. ... 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):".
?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. If you want spaces, make the STRING statement look like this: STRING NAMES (NAME-INDEX) DELIMITED BY SPACE " " DELIMITED BY SIZE INTO REST-OF-NAME POINTER POINTER-1.
GLOBAL NOTE: Do not use GLOBAL in the Declaratives Portion (page 238). applies the declarative exception procedure to the program in which the USE statement appears and to any programs nested within that program, unless such a nested program has its own declarative exception procedure for that particular exception.
to procedure-names defined within another logically discrete area. For detailed restrictions and permissions, see ALTER, GO TO, and PERFORM. • ◦ Procedure names defined within a nondebugging declarative procedure (and procedure-names defined within utility sections associated with that declarative procedure) can be referred to by PERFORM statements located anywhere in the Procedure Division.
Example 141 USE AFTER EXCEPTION Statement ... PROCEDURE DIVISION. DECLARATIVES. MASTER-FILES SECTION. USE AFTER EXCEPTION PROCEDURE ON MASTER-1 MASTER-2. MASTER-ERROR-ROUTINE. IF FILE-STATUS.... ... DETAIL-FILE SECTION. USE AFTER EXCEPTION PROCEDURE ON DETAIL-IN. DETAIL-ERROR-ROUTINE. ... END DECLARATIVES. MAIN-SECTION SECTION. BEGIN-PROGRAM. ... WRITE WRITE delivers a record to its associated file.
ADVANCING clause 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. AFTER specifies that the record is to be printed after any lines are skipped.
not-end-of-page clause executes imperative-statement when the write operation does not encounter the end-of-page condition. The file description must include a LINAGE clause. imperative-statement is to be executed when the end-of-page condition is satisfied when LINAGE-COUNTER is either greater than the defined page length or is at a line in the footing area. In both cases, the line is written before imperative-statement is executed.
Usage Considerations: • Action of the WRITE Statement The write operation releases a logical record to the run-time routines for inclusion in the file. For a file of sequential organization, the order of the records in the file therefore corresponds to the order in which they are released.
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.
Do 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. See FILE-CONTROL Paragraph (page 115). • Variable-Length Records An Enscribe structured file can have variable-length records. See READ for Sequential or Dynamic Access (page 405).
Example 142 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. 01 PRINT-LINE-OUT PIC X(132). ... WORKING-STORAGE SECTION. 01 LINAGE-STUFF.
WRITE for Line Sequential Files record-name is a logical record described in the File Section of the Data Division. The record-name 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. from-name is the identifier of a data area whose contents are to be moved to the record specified by record-name before the WRITE occurs. from-name must specify a data area other than that specified by record-name.
record-name is a logical record described in the File Section of the Data Division. The record-name can be qualified by the name of the file with which the record is associated. from-name is the identifier of a data area whose contents are to be moved to the record specified by record-name before the WRITE occurs. from-name must specify a data area other than that specified by record-name. It also cannot specify an index data item.
The I-O status codes that result from an unsuccessful write operation are: • I-O Status Code Unsuccessful Write Operation “21” The file is defined to have indexed organization and sequential access mode, and the prime record key value of the logical record is less than or equal to the prime record key value of the most recently released record.
• 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.
Example 143 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). ... WORKING-STORAGE SECTION. 01 VKF-NR PICTURE 97. 01 J-W-D. 03 NATION PIC X(15).
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.
library-name is the name of the COPY library file that contains the text to be copied. 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 (page 529)), 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.
• ◦ 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. ◦ The keyword COPY must be preceded by a space character, unless it immediately follows the indicator field. ◦ A COPY statement cannot appear on the same line as an SQL/MP or SQL/MX statement. ◦ All four characters of the keyword COPY must appear on the same source text line.
Similarly, the compiler interprets the character sequence X/9 as one text-word (presumably a PICTURE character-string) rather than as three text-words; however, the compiler always considers a left parenthesis, right parenthesis, or colon character to be a separator unless it appears within a nonnumeric literal.
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.
pseudo-text-2 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. identifier-1, identifier-2 are identifiers of data items. literal-1, literal-2 are literals (but not national literals). Neither can be a concatenation expression. word-1, word-2 are COBOL words.
3. 4. 5. 6. • separators as a single space. The compiler ignores any comment or directive line in the library text or in pseudo-text-1. The REPLACING phrase operand matches the library text if the two sequences of text-words are equal, character for character.
Specifying Library Names There are three places you can specify the name of the library from which a COPY statement is to collect text: • The COPY statement itself can include an IN library-name phrase (see COPY Statement), in which the name can be a file-system file name or (in the Guardian environment) an alphanumeric literal containing a DEFINE name.
text-line is a line of source text. There is no limit on the number of such lines. No text line can begin with “?SECTION.” 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).
before. If you put sections that most programs use in the front of the library and those that few programs use at the end, compilation speed is improved. • Adding Source Text to a COPY Library Since COPY libraries are files in the EDIT format or OSS ASCII files, you can add a section of source text to a library by editing it. You can put a SECTION directive line and the source text that follows it before, between, or after sections already in the library.
Usage Considerations: • Comment Lines and Directive Lines in Pseudo-Text Pseudo-text can contain comment lines and directive lines (that is, the text-words in pseudo-text can be organized as comment lines and directive lines). • Where REPLACE Statements Can Be Used With these exceptions, a REPLACE statement can occur anywhere in the source text that a character-string can occur: ◦ A REPLACE statement cannot appear within the body of another REPLACE statement.
4. 5. 6. • If the compiler compares all the occurrences of pseudo-text-1 without finding a match, it considers the next text-word of the source program as the leftmost source program text-word and starts the comparison cycle again with the first occurrence of pseudo-text-1. Whenever a match occurs between pseudo-text-1 and the source program text, the compiler replaces the matched text in the source program with the corresponding pseudo-text-2.
Of course, with either EDIT or PS Text Edit (TEDIT), you could easily change all instances of reserved words in a source program to another word; but if your data dictionary contains any fields whose names have become reserved words, you might find the REPLACE statement a handy tool. The REPLACE operation occurs conceptually after the COPY operation, but before the remainder of the compilation. Example 146 REPLACE Statement DATA DIVISION. REPLACE ==OFFICES== BY ==10== ==SQ-FT-SIZE== BY ==5==. ... 01 OFFS.
11 Program Compilation The compiler can run at a high PIN (a process identification number greater than 255) and can be requested by other processes running at high PINs. The compiler accepts one source file as input. That source file can use SOURCE directives and COPY statements to read text from other source files.
and, under some circumstances, they can also call non-COBOL programs. The source file that is input to the compiler is also called a compilation unit. Main Programs A main program is either compiled with the MAIN directive (see MAIN) or it has no Linkage Section (see Absent Linkage Section (page 182)). 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.
The statement a COBOL program uses to call another program depends on the language in which the called program was written. Table 70 Statements for Calling Programs Language of Called Program Statement for Calling Program HP COBOL CALL HP C ENTER or X/Open CALL HP C++ ENTER or X/Open CALL pTAL ENTER or X/Open CALL Called programs are not required to be in the main program’s compilation unit (see Compilation Units).
COBJECT is called the target file. It contains the object programs that the compiler produces. Example 148 Compilation Unit IDENTIFICATION DIVISION. PROGRAM-ID. CPGM1. * CALLED PROGRAM 1. ... DATA DIVISION. ... LINKAGE SECTION. 01 LS-NAMES. 03 LS-A-NAME PICTURE X(30). 03 LS-B-NAME PICTURE X(30). ... END PROGRAM CPGM1. IDENTIFICATION DIVISION. PROGRAM-ID. CALLER. * THE MAIN PROGRAM FOR THIS COMPILATION. ... DATA DIVISION. ... WORKING-STORAGE SECTION. 01 WS-PARTS. 03 WS-FIRST-PART PICTURE X(30).
Example 149 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 Compilation Details Processes Involved in Compilation The ECOBOL compiler consists of a driver process, ECOBOL, and a sequence of subordinate processes. For a successful compilation, the ECOBOL compiler driver calls ECOBFE, using temporary files to pass information between them.
In the CALL statement, the called program must be a COBOL program. It can be part of the same compilation unit as the calling program, or it can be an external reference to a COBOL program outside the compilation unit (but in the same object file). All ENTER statements cause external references, because they call programs compiled from source languages other than COBOL. To generate the proper code to call a separately compiled program, the compiler needs a description of the parameter list of that program.
in the CONSULT directives. When trying to resolve unqualified external references, the compiler searches the files of the tertiary search list in the order that they appear. If the compiler resolves an external reference from the tertiary search list, the object program that the compiler finds is not bound into the target file. Programs resolved from the tertiary search list do not have to be in the system library. They can be elsewhere and can be bound in later or can be referenced in a run-time library.
and does not try to locate the program for that CALL. You are responsible for the conformance of the parameters. A compilation source text consists of one or more separately compiled HP COBOL programs. Each such program can include nested programs. Suppose separately compiled program S includes program P, which contains the statement CALL A. The compiler follows this procedure: 1. If program P directly contains a program named A, the compiler always chooses that program.
5. When the compiler reaches the end of the source text, it issues a warning if it was unable to resolve any program references. You must supply the missing programs (using the linker) before you execute the loadfile. Example 150 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.
2. If the compiler has not yet encountered the routine-name during the current compilation, the compiler conducts a search for the program: a. If file-mnemonic appears, the compiler tries to find a program with the specified name in the file associated with file-mnemonic. If the compiler finds the program, it verifies that language is the language in which the program was written. If the compiler does not find such a program, it reports an error. b. If no file-mnemonic appears: The i. ii. iii. iv. v. c.
Presenting Parameters to the Called Program A formal parameter in the called program can have one of two attributes: value or reference. Depending on the description of the actual parameter in the calling program and the description of the formal parameter in the called program, the compiler generates code to convert the value of the actual parameter to match the description of the formal parameter.
Table 72 How Final Values of #RECEIVE Arguments Are Chosen #RECEIVE Argument Final Value TABLE OCCURS Maximum value specified by a TABLE OCCURS argument in any #RECEIVE block SYNCDEPTH Maximum value specified by a SYNCDEPTH argument in any #RECEIVE block REPLY CONTAINS Maximum value specified by a REPLY CONTAINS argument in any #RECEIVE block REPORT Logical OR QUEUE DEPTH Maximum value specified by a QUEUE DEPTH argument in any #RECEIVE block* * HP COBOL does not have a QUEUE DEPTH argument, so
the ERROR CODE and MESSAGE SOURCE clauses of the RECEIVE-CONTROL paragraph in other programs are ignored. Compiler Output The output of a compilation can include a listing (to an existing file or spooler) and an object file, but it always includes compilation statistics and a completion code. You can manipulate the object file. 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).
Generating Instrumented Object Code for Use With the Code Coverage Tool The Code Coverage Tool evaluates the code coverage provided by application test cases. The tool uses information provided by a specially-instrumented object file to produce a report that indicates which functions and blocks were executed, and how many times each was executed. Using the Code Coverage Tool requires a special compilation to produce an object file containing the required instrumentation.
Example 152 ECOBOL Compiler Statistics COBOL - T0356H01 - (20DEC2004) No failures detected. No errors detected. No warnings reported. No remarks issued. Maximum symbol table size = 10884 bytes Object file: opt2o Compiler driver: \DRP12.$SYSTEM.SYSTEM.ECOBOL COBOL DLL: \DRP12.$SYSTEM.ZDLL031.ZCOBDLL CRE DLL: \DRP12.$SYSTEM.ZDLL031.ZCREDLL ECOBEXT: \DRP12.$SYSTEM.SYSTEM.ECOBEXT Compiler statistics phase CPU seconds elapsed time file name ECOBFE 0.9 00:00:05 \DRP12.$SYSTEM.SYSTEM.ECOBFE total 0.
Completion Codes The compiler reports an appropriate completion code when it terminates execution. An HP COBOL program can set its own completion code at termination by calling the COBOL_COMPLETION_ routine. Table 73 Completion Codes Code Termination Explanation 0 Normal No diagnostic messages were issued. The object file is complete and valid (unless a SYNTAX directive suppressed its creation). 1 Normal At least one compiler warning occurred.
$volume is a dollar sign ($) immediately followed by one to seven alphanumeric characters. The first alphanumeric character must be alphabetic. The $volume is the name of the volume on which the temporary files are to be created. The $volume must exist on the system on which the compiler resides. If the compiler cannot create its first temporary file on the specified volume, compilation proceeds with temporary files created as though no PARAM SWAPVOL command were active.
=_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 where to search for unqualified object files s
source-file 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. The default is the current command interpreter IN file (usually the home terminal). source-file must be an EDIT file. file-name-1 is a disk file name (if source-file is a disk file) or nondisk file name (if source-file is a terminal, magnetic tape unit, or process).
file-name-2 is a disk file name (if list-file is a disk file) or nondisk file name (if list-file is a terminal, magnetic tape unit, process, line printer, or spooler collector). For syntax, see the Guardian Procedure Calls Reference Manual. define-name is the name of a DEFINE established in the current run-time environment. other-option is any other command interpreter RUN option (see the description of the RUN command in the TACL Reference Manual).
• 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.
Terminating a Compilation There are two ways to terminate a compilation before normal completion: • Press Break and type STOP. • Press Break and type: STATUS *, TERM Find the processor (cpu ) and process number (process ) for the compiler. Type: STOP cpu,process With either method, the supporting processes stop when the compiler stops. NOTE: If you expect to have multiple compilations active at one time, give each ECOBOL process a different name with the command interpreter NAME parameter.
? is a source text format indicator (like the asterisk and the slash) and is not part of the compiler directive. The question mark must be in the indicator area (column 1 for Tandem format and column 1 or 7 for ANSI format). 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.
◦ SYNTAX ◦ UL • The COLUMNS directive can appear in a COPY library, but only once, before the first SECTION directive • The SQL directive cannot appear in a source program Categories of Compiler Directives Compiler directives fall into these categories: • Table 76: Source Text Manipulation Directives (page 535) • Table 77: Input Format Control Directives (page 535) • Table 78: Listing Control Directives (page 535) • Table 79: Code-Generation Control Directives (page 536) • Table 80: Resolut
Table 78 Listing Control Directives (continued) Directive(s) Default Action For a cross-reference listing, use the enoft utility with the XREFPROC flag (see the enoft Manual ).
Table 79 Code-Generation Control Directives (continued) Directive(s) Default Action CANCEL and NOCANCEL CANCEL Controls whether code is generated to initialize data for a program that does not have the INITIAL attribute CHECK Controls the level of run-time checking included in the loadfile CODECOV No code coverage instrumentation in generated object code Controls whether instrumented object code is generated for use with the Code Coverage Tool COMPACT and NOCOMPACT1 COMPACT Ignored (warning iss
1 The compiler ignores and issues warnings for these directives.
Table 81 Miscellaneous Control Directives (continued) Directive(s) Default Action STANDARD STANDARD 1985 Specifies whether the compiler is to apply the COBOL-1985 or COBOL-2002 standard SUBTYPE1 Specifies that the program runs as a process with the designated subtype number 1 These directives are not available in the OSS environment. 2 The compiler ignores and issues warnings for these directives.
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. NOBLANK prevents the addition of implicit VALUE SPACES clauses.
Dependencies: • 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. References: • SHARED (page 568) • RUNNABLE • UL CANCEL and NOCANCEL CANCEL generates code that initializes the program the first time the program is called after being canceled by a CANCEL statement.
Table 83 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. For the fastest execution (and no subscript checking) in current and future versions of HP COBOL, specify CHECK 0.
length is an integer whose value is at least 12. Any value greater than 132 is considered to equal 132. Default: COLUMNS 132 Placement: • On a directive line, COLUMNS must begin with a question mark (?) in column 1, regardless of any active ANSI. • 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.
CONSULT and NOCONSULT NOTE: The compiler ignores and issues a warning for the NOCONSULT directive. CONSULT adds the files that object-name-list specifies to the tertiary search list. (See Tertiary Search List.) object-name-list can be continued onto subsequent lines, but the left parenthesis must appear on the same directive line as the keyword CONSULT. Each continuation line for a CONSULT directive must have a question-mark (?) in the indicator area.
NOCONSULT is ignored. Default: NOCONSULT Placement: Anywhere Dependencies: None If more than one CONSULT is present, the object names are appended to the list in the order they are read; however, if any object name specified is already in the list, it retains its current position in the list.
Usage Considerations: • Size of Index Data Item A data item within a record description has an explicit USAGE INDEX clause. Indexes occupied two bytes in COBOL 74, but occupy four bytes in HP COBOL. You must convert any files that include records in which index data items occur. • Implied Value of Figurative Constant A MOVE statement attempts to assign a value of ALL literal to a numeric or numeric-edited item, or a relation condition involves such a value.
• Identification of Statement Operand In COBOL 74, STRING and UNSTRING statements deferred some subscript evaluations until just before the subscripted item was used. HP COBOL evaluates all subscripts once at the beginning of the statement’s execution. You must check that the STRING and UNSTRING statements do what you want them to do.
"05 " in ITEM-B for HP COBOL. If you cannot avoid moving left-justified numbers with trailing spaces between these data types, use an UNSTRING statement with a DELIMITED BY SPACES phrase rather than a MOVE statement. DIAGNOSE-85 and NODIAGNOSE-85 DIAGNOSE-85 causes the ECOBOL compiler to issue warnings when it encounters source constructs that could cause the program to produce different results than it would if it were compiled with the COBOL85 compiler.
Default: None Placement: In the command line Scope: Applies to the compilation unit Dependencies: None option is an eld option. For information about eld options, see the eld Manual. ENDIF ENDIF terminates the effect of a preceding IF or IFNOT directive. toggle-number is the toggle-number specified in a preceding IF or IFNOT directive. Default: None Placement: Must be either on a directive line of its own or be the last of a sequence of directives.
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. Default: None Placement: Either on the compiler command line or in the source file before the Identification Division.
FIPS and NOFIPS FIPS and NOFIPS determine whether the compiler identifies language elements as required by the Federal Information Processing Standard (FIPS). FIPS identifies the language elements specified by flag-option-list. NOFIPS prevents identification of language elements which violate the FIPS.
Default: The compiler does not produce a source file map. Placement: Anywhere Scope: Applies to the compilation unit Dependencies: NOLIST and SUPPRESS do not suppress the source file map that FMAP produces. References: • LIST and NOLIST • SUPPRESS and NOSUPPRESS GLOBALIZED The GLOBALIZED directive directs the compiler to generate preemptable object code.
IF and IFNOT IF enables compilation of subsequent source text if the toggle with toggle-number is set; disables it otherwise. IFNOT suppresses compilation of subsequent source text if the toggle with toggle-number is set; enables it otherwise. toggle-number is an integer in the range 1 through 15.
Example 155 Nested IF and IFNOT Directive Scopes IF and IFNOT scopes can be nested. Given this program fragment: 01 MASTER-RECORD. 03 HEADER PICTURE X(30). ?IF 1 03 ACCOUNT-ID PICTURE X(50). ?IF 2 03 ACCOUNT-ID-REDEF REDEFINES ACCOUNT-ID. 05 ACCOUNT-GROUP PICTURE X(20). 05 ACCOUNT-CLASS PICTURE X(10). 05 ACCOUNT-NUMBER PICTURE X(20). ?ENDIF 2 03 TRAILER PICTURE X(100).
Example 156 Omitting Uncompiled Lines from Compiler Listing ?IF n ?NOLIST ?ENDIF n ?IFNOT n * Lines compiled if toggle n is not set go here ?ENDIF n ?IF n ?LIST ?ENDIF n ?IFNOT n ?NOLIST ?ENDIF n ?IF n * Lines compiled if toggle n is set go here ?ENDIF n ?IFNOT n ?LIST ?ENDIF n INNERLIST and NOINNERLIST INNERLIST lists, immediately after each source statement, the generated machine instructions in mnemonic form. NOINNERLIST suppresses the listing of generated machine instructions.
NOINSPECT turns off the Inspect attribute for the debugging tool for the compilation unit. Default: INSPECT Placement: Anywhere Scope: The last INSPECT or NOINSPECT in the compilation unit applies to the compilation unit. Dependencies: NOINSPECT and SAVEABEND override each other (whichever is last is active). References: SAVEABEND and NOSAVEABEND LINES LINES determines the number of lines to be listed on each page of the output file.
MAIN MAIN identifies the main program unit. 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.
MIGRATION-CHECK MIGRATION-CHECK causes the compiler to issue a warning message when it encounters a user-defined COBOL word that is a reserved word in the COBOL-2002 standard. MIGRATION-CHECK applies only when used with the STANDARD 1985 directive. Use the DIAGNOSEALL and NODIAGNOSEALL directives to control whether the compiler issues a message for every occurrence of a given user-defined word or only for the first occurrence, respectively.
extent-size specifies the number of pages to use for the primary and secondary extents of the generated object file. extent-size is an integer in the range 2 through 1070. Use this directive to increase the capacity of the generated object file.
If the program was compiled with the PERFORM-TRACE directive and run-time error 148 occurs, this additional information is given: Line numbers of PERFORMs from latest to earliest Line Number File Number llllll.lll nnn ... The file number nnn is the number of the source file. The source-file specified in the compilation command has file number 001. A file number is shown for each file referenced by the directive SOURCE or a COPY Statement (page 499).
NOPORT aligns BINARY/COMPUTATIONAL data items according to standard alignment rules and prevents the CALL statement in a program from calling non-COBOL routines, passing parameters by value, and returning the values of functions. 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.
toggle-number-list toggle-number is an integer in the range 1 through 15. If toggle-number is omitted, all toggles are turned off. 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. References: SETTOG RUNNABLE RUNNABLE causes the compiler to use the linker to produce a loadfile if there are no compilation errors.
Default: None Placement: Any of: • Anywhere in a source program • In a linker session (specify -change) Scope: Applies to the program in which or before which it appears, to all subsequent programs in the compilation unit, and to all target files Dependencies: RUNNAMED is appropriate only if the program was compiled with RUNNABLE (because a linkfile is not a run unit).
save-option PARAM specifies that the PARAM message is to be saved. STARTUP specifies that the startup message is to be saved. ASSIGNS specifies that all ASSIGN messages are to be saved. count is an unsigned integer in the range 1 through 100, an estimate of the number of messages to be saved. The default is 19. The compiler uses count to estimate process data-space requirements for the saved ASSIGN messages. The saved ASSIGN messages are in the data block #CRE_HEAP.
SAVEABEND and NOSAVEABEND 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. Dependencies: SAVEABEND and NOINSPECT override each other (whichever is last is active).
object-name is a name that designates a TNS/E object file—either a file-system file name or (in the Guardian environment) a DEFINE name. In the OSS environment, object-name must be an OSS pathname. If the file-system file name is not fully qualified with system, volume, and subvolume names, the compiler uses the current default system, volume, and subvolume names or those specified by an =_OBJECT_SEARCH DEFINE (see =_OBJECT_SEARCH (page 529)). The linker links the entire file designated by object-name.
Scope: Applies only to the section of text that it specifies Dependencies: None If you do not specify TANDEM or ANSI in the SECTION directive, the compiler assumes that the format of the library text is the same as the current source-text format. Although you can override this by inserting a compiler directive as the first line following the SECTION directive, the input format control directive (ANSI or TANDEM) of the SECTION directive is usually more convenient for this purpose.
SHARED SHARED generates shared code (PIC) for a DLL. CALL-SHARED generates shared code (PIC). NON-SHARED is ignored. Default: CALL-SHARED Placement: Anywhere Scope: The last SHARED or CALL-SHARED in the compilation unit applies to the entire compilation unit. The last SHARED, CALL-SHARED, or NON-SHARED in the compilation unit applies to the entire compilation unit.
NOSHOWCOPY suppresses the display of COPY statements. Default: SHOWCOPY Placement: Anywhere Scope: Applies until its opposite overrides it Dependencies: SHOWCOPY works only if LIST is active and SUPPRESS is not. References: • LIST and NOLIST • SUPPRESS and NOSUPPRESS SHOWFILE and NOSHOWFILE SHOWFILE displays the identity of the file from which source text is being read under the control of the SOURCE directive.
You can also use the predefined SEARCH DEFINEs to specify one or more subvolumes to be searched for unqualified files (see Predefined SEARCH DEFINEs). edit-file-name is a file-system file name that identifies an accessible EDIT file. If any of the system, volume, or subvolume components are omitted, the compiler supplies the missing ones from its process defaults. edit-file-name can be the name of a DEFINE of the class MAP.
The text from the section summoned by the SOURCE directive is listed, subject only to the LIST and SUPPRESS directives. • Nesting of SOURCE Directives The text introduced by a SOURCE directive can include one or more SOURCE directives. The compiler processes nested SOURCE directives when it encounters them.
If the compiler is unable to access a section specified in the SOURCE directive (because the section-name is invalid or the section is not in the file) the compiler issues a diagnostic message, but does not terminate the compilation. • Format of a Source Library A source library has the same format as a COPY library; in fact, the only difference between a source library and a COPY library is context—a source library is referenced by a SOURCE directive and a COPY library is referenced by a COPY statement.
RELEASE2 causes the compiler to accept only SQL/MP Release 2 features; however, the resulting object file can be executed with SQL/MP Release 350 (or later). If you do not specify RELEASE2, the ECOBOL selects the latest SQL/MP product version (350 or later). PAGES allocates num-pages of memory to the SQL compiler interface for processing SQL/MP statements. Each page is 2048 bytes. num-pages has a minimum (and default) value of 860 and the maximum value of 1000.
2002 Causes the compiler to apply the COBOL-2002 standard. Default: STANDARD 1985 Placement: In the command line Scope: Applies to the compilation unit Dependencies: STANDARD 2002 is incompatible with the FIPS, and SUBSET directives. Whichever directive is specified first takes effect; whichever is specified next causes the compiler to issue a warning and has no other effect. STANDARD 2002 is compatible with the BASED, ALLOCATE, and FREE features.
EXTENDED accepts all defined syntax without comment (HP extensions plus those of HIGH), with respect to the required functional modules. 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.
and then describes each nonconforming element. Each reported instance of nonconformance or obsolescence identifies the context of the syntax, describes its location in the source text, and characterizes the syntax as “obsolete” or “nonconforming.” If an instance is both obsolete and nonconforming, only “obsolete” is reported.
Dependencies: SUBTYPE works only with RUNNABLE. References: RUNNABLE The compiler installs the value of subtype-number in the object file header. When the object file executes as a named process, it is assigned the process subtype specified by the value of subtype-number. Any user can create a named process that has a subtype in this range.
Scope: Applies until its opposite overrides it Dependencies: SYMBOLS does not work when SYNTAX is active. References: • ENDUNIT • SYNTAX You can include or exclude the symbol table from the object file on a program-unit-by-program-unit basis. If the SYMBOLS directive is active, the compiler does not perform certain object code optimizations, so the object program might execute slightly more slowly and be slightly larger in size. SYNTAX SYNTAX checks the syntax of the source text.
ANSI specifies that subsequent source text is in ANSI reference format, which is described in Chapter 16: ANSI Reference Format (page 702). Default: TANDEM Placement: Anywhere Scope: TANDEM or ANSI 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: 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.
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 (page 712). For detailed information about the TACL commands, see the TACL Reference Manual. For more information about running COBOL programs in the Guardian environment, see Chapter 25: Executing and Debugging HP COBOL Programs (page 820). When a system executes a loadfile, the running program is called a process.
display-device can be a file-system file name or (in the Guardian environment) a DEFINE name. Its value designates a terminal, line printer, process, existing entry-sequenced disk file, or operator console to which unqualified DISPLAY statements are to deliver output. If you omit display-device, unqualified DISPLAY statements deliver output to the home terminal (unless PARAM EXECUTION-LOG specifies a different device).
other attributes, of a file specified in the source program. This command is fully discussed in the TACL Reference Manual. When a process begins to execute, it can request its ASSIGN messages and use their contents to modify the information it possesses about its files before opening them. During the initialization of any process compiled from a COBOL source, the run-time routines automatically handle any ASSIGN messages made available by the Guardian environment.
characteristic size-list specifies the extent size for disk file creation. Extent sizes are specified as a number of file pages to be allocated for one extent of the file. A file page is 2048 bytes of storage. pri-extent-size is an unsigned integer specifying the primary extent size. If EXT is omitted, pri-extent-size defaults to 4. sec-extent-size is an unsigned integer specifying the secondary extent size. If EXT is omitted, sec-extent-size defaults to 20.
NOTE: To see what ASSIGN commands are currently in force, enter just ASSIGN followed by a carriage return. Usage Considerations: • Places for ASSIGN Commands You can give ASSIGN commands individually at the TACL prompt before you enter the RUN command, or you can place the ASSIGN commands in an EDIT-format file and use the OBEY command to execute all the commands in the file. You could also include the RUN command in the OBEY command file.
18> 19>ASSIGN WORK-FILE, #TEMP 20> == FD WORK-FILE is to be == a temporary disk file == on the default volume. 21> 22>ASSIGN OUTPUT-FILE, #OUT 23> == FD OUTPUT-FILE is the == file named in the == OUT option.
SWITCH-nn sets (ON) or clears (OFF) the specified switch. In the Guardian environment, the value of nn can be a one-digit integer between 1 and 9 or a two-digit integer between 01 and 15. In the OSS environment, the value of nn can be a one-digit integer between 1 and 9 or a two-digit integer between 10 and 15. (For an explanation of these switches, see SPECIAL-NAMES Paragraph (page 105). In the absence of a PARAM SWITCH-nn ON command, SWITCH-nn is off.
The default EXECUTION-LOG is the home terminal. system-file-name is the name of the file to which run-time messages are directed. It must be an existing entry-sequenced (TYPE E) file (that is, a file-system file name). If system-file-name does not begin with a dollar sign ($), backward slash (\), or number sign (#), then it must be enclosed in quotation marks unless it forms a COBOL word. For more information about operating system file names, see the Guardian Procedure Calls Reference Manual.
The EXECUTION-LOG parameter can also redirect unintentional input-output activity from #IN and #OUT to the execution log file. In the absence of an EXECUTION-LOG parameter, the execution log file is the home terminal. If the EXECUTION-LOG parameter specifies asterisk (*), such output is discarded.
the operation is an ACCEPT statement, the default values are returned to the receiving item. In the case of tape mount messages, the run unit terminates abnormally. • PRINTER-CONTROL Parameter When an application program is writing to a printer, and the printer leaves the ready state (perhaps it is out of paper or it is off line), the program does not automatically regain control.
WRITE CHEX BEFORE ADVANCING 10 END-PERFORM • 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.
ALL means clear all currently active ASSIGN and PARAM references. ALL ASSIGN means clear all currently active ASSIGN references. ALL PARAM means clear all currently active PARAM references. ASSIGN means clear the reference to the specified COBOL file name. assignation 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.
Example 161 CLEAR Command 43>CLEAR 44>CLEAR 45>CLEAR 46>CLEAR 47>CLEAR ALL ALL ASSIGN ALL PARAM ASSIGN in-file PARAM DEBUG { { { { { Clears Clears Clears Clears Clears all ASSIGN and PARAM values } all ASSIGN values } all PARAM values } assignment for in-file only } the DEBUG switch } DEFINEs A DEFINE is a named set of attribute/value pairs. DEFINEs are similar to ASSIGN messages, but more versatile. DEFINEs involve too many commands to be described completely here.
SELECT MAJORACCT ASSIGN TO "\AKRON.$SLB.MAJ.ACC" If you execute PROG1, when it opens MAJORACCT, the file it actually opens is \AKRON.$SLB.MAJ.ACC. If, when you execute the program, you want to redirect the assignment to a different file, you can issue a command interpreter ASSIGN command such as ASSIGN PROG1.MAJORACCT,\NICE.$FRNC.SIGNIF.CUST and then run PROG1. When the COBOL program opens MAJORACCT, it opens the file \NICE.$FRNC.SIGNIF.CUST.
Table 85 DEFINE Attributes Other Attributes of DEFINE CLASS Attribute Value Required CATALOG SUBVOL DEFAULTS VOLUME MAP (default) FILE SEARCH SUBVOL n SORT Optional SWAP BLOCK CPU CPUS MODE NOTCPUS PRI PROGRAM SCRATCH SEGMENT SUBSORTS SWAP SPOOL LOC BATCHID BATCHNAME COPIES FORM HOLDAFTER MAXPRINTLINES MAXPRINTPAGES OWNER PAGESIZE REPORT SELPRI SUBSORT SCRATCH BLOCK CPU PRI PROGRAM SEGMENT SWAP TAPE VOLUME* BLOCKLEN DENSITY, DEVICE EBCDIC, EXPIRATION FILEID, FILESECT, FILESEQ GEN LABEL
Usage Considerations: • TAPE DEFINE Provides the Only Way to Use Labeled Tapes For details, see Chapter 25: Executing and Debugging HP COBOL Programs (page 820), 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.
• The control mechanisms for all PERFORM statements in the program are set to their initial state (inactive). • GO TO statements whose destinations can be modified by ALTER statements are restored to the forms specified in the source program. A program is placed in its initial state at these times: • The first time the program is executed in a run unit. For a main program, this is at the beginning of each separate execution of the run unit.
were executed for each of the affected files. If the program is called again, it is placed in its initial state. When a called program that does not have the initial attribute terminates its own execution, each internal entity (except a data item described in the Linkage Section) retains its status: • Each internal data item (except those described in the Linkage Section) retains its current value.
13 Libraries and Utility Routines Utility routines are in dynamic-link libraries (DLLs) named ZCOBDLL and ZCREDLL. (You can also create a user library for an HP COBOL program.) If a program calls a utility routine, the ECOBOL compiler automatically searches the DLLs for the routine, but the routine is not bound into the program’s target file.Utility routines Programs can call dynamic-link libraries (DLLs), which you can build. NOTE: In this section, references to $SYSTEM apply only to the NonStop system.
For information about individual routines: Library Source ZCREDLL CRE Programmer’s Guide ZCOBDLL ZCOBDLL Routines 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 87 Memory Area Characteristics Memory Area Purpose Size Comments User code space Holds code blocks produced 256 megabytes by the compilation Routines from loadfiles execute here.
Table 88 Linker Options That Export Program Names Option exports ...
Example 163 Building a DLL From a Single Source File in One Step (Guardian) ECOBOL /IN LIB1/ MYDLL; SHARED; RUNNABLE; & &ELD(-export_all) Guardian Environment: Two-Step Method 1. Compile the source file with the directive SHARED (page 568). NOTE: Do not use the RUNNABLE directive. The result is a linkfile. 2.
Example 165 Building a DLL From a Single Source File in One Step (OSS) ecobol lib1.cob -Wshared -Weld="-export_all 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 eld utility with these options: • • Either: ◦ -export_all, which exports all program names in the source file ◦ -export program-name, which exports only the specified program name.
Example 167 Building a DLL From a Single Source File in One Step (PC) ecobol lib1.cob -Wshared -Weld="-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. Link the linkfile, using the eld utility with these options: • • Either: ◦ -export_all, which exports all program names in the source file ◦ -export program-name, which exports only the specified program name.
2. Link the linkfiles into a single loadfile, using the eld utility with these options: • Either: ◦ -export_all, which exports all program names in the source file ◦ -export program-name, which exports only the specified program name. You must repeat this option for every program name that you want to export.
Example 170 Building a DLL From Multiple Source Files (OSS) ecobol lib1.cob -Wshared ecobol lib2.cob -Wshared ecobol lib3.cob -Wshared ecobol lib4.cob -Wshared eld lib1.o lib2.o lib3.o -optional_lib -l ZCOBDLL -c -c -c -c lib4.o -shared -export_all -l ZCREDLL -o mydll PC Environment 1. Compile each source file with these options: • -Wshared • -c The result of each compilation is a linkfile. 2.
• PC Environment: Compile and Link in One Step • PC Environment: Compile and Link in Two Steps Guardian Environment: Compile and Link in One Step Compile the program that uses the DLL with these directives: • CALL-SHARED (page 540) (default) • CONSULT with the name of the DLL as an object-name (see CONSULT and NOCONSULT (page 544)) • ELD (page 548) with these options: ◦ -L (which is similar to the ecobol option -L) ◦ -l or -lib (which is similar to the ecobol option -l) For more information ab
Example 173 Specifying a DLL When You Compile and Then Link (Guardian) ECOBOL /IN MAIN/ MAINO; CALL-SHARED; CONSULT MYDLL ELD MAINO -CALL_SHARED -L $VOL.SUBVOL -l MYDLL -optional_lib -l ZCOBDLL -l ZCREDLL -O MYPROG OSS Environment: Compile and Link in One Step Compile the program that uses the DLL with these options: • -Wcall_shared • -L • -l NOTE: Do not use -c. The result is a loadfile. The command in Example 174 compiles the source file main.
• -L, where directory is the name of the directory of libraries • -l, where library is the name of the DLL NOTE: Do not use -c. The result is a loadfile. The command in Example 176 compiles the source file main.cob and links the resulting object file with the DLLs named ZCOBDLL and ZCREDLL and the DLL named mydll, creating the loadfile main.exe. MYDLL is in dll-location. (An example of dll-location is C:\xxx\yyy.) Example 176 Specifying a DLL When the Compiler Calls the Linker (PC) ecobol main.
Table 89 Files of Dummy Routines File Name Description of File (as released by HP) ECOBEX0 Contains one dummy routine for each operating system routine in the EXTDECS0 file. Represents the latest RVU. ECOBEX1 Contains one dummy routine for each operating system routine in the EXTDECS1 file. Represents the next-to-latest RVU. ECOBEXT Contains one dummy routine for each operating system routine in the EXTDECS file. Represents the second-next-to-latest RVU.
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.
For descriptions of individual ZCOBDLL routines, see Non-SMU Routines. Saved Message Utility (SMU) Overview The Saved Message Utility (SMU) consists of several routines that manipulate saved ASSIGN, PARAM, and startup messages. SMU routines can be used only in the Guardian environment. The Open System Services environment does not have ASSIGN, PARAM, or startup messages. The internal data structures of the saved ASSIGN, PARAM, and startup messages differ from COBOL data structures.
The SMU consists of these routines. For complete descriptions of these routines, see the CRE Programmer’s Guide.
Table 94 Portions of the Startup Message Portion What It Identifies Portion Type VOLUME Default volume and subvolume names Text message portion IN Input file name Text message portion OUT Output file name Text message portion STRING Message’s parameter string Text message portion The PARAM message portions consist of the set of parameter names and their values. A legal parameter name identifier is any combination of letters, digits, hyphens, and circumflexes.
Topics: • COBOL_COMPLETION_ • COBOL_CONTROL_ • COBOL_GETENV_ • COBOL_PUTENV_ • COBOL_RETURN_SORT_ERRORS_ • COBOL_REWIND_SEQUENTIAL_ • COBOL_SET_SORT_PARAM_TEXT_ • COBOL_SET_SORT_PARAM_VALUE_ • COBOL_SET_MAX_RECORD_ • COBOL_SETMODE_ • COBOL_SPECIAL_OPEN_ COBOL_COMPLETION_ The COBOL_COMPLETION_ routine passes completion parameters to either the STOP or ABEND routine in the operating environment (depending on the abend-or-stop parameter).
completion-code 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 completion-code parameter for that routine. 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.
library-reference is a mnemonic-name in the SPECIAL-NAMES paragraph. This mnemonic-name is associated with the DLL containing an object copy of COBOL_CONTROL_. file-name is a COBOL file name associated with a file that is not $RECEIVE and that is not open for HP COBOL Fast I-O. If the file is not open, the call to the Guardian environment routine CONTROL is made during the next successful open request for the file.
Usage Consideration: In a fault-tolerant program, put the CHECKPOINT statement that specifies cpinfo immediately before the call to COBOL_CONTROL_; otherwise, the queued information can be lost if a backup process takes over. COBOL_GETENV_ The COBOL_GETENV_ routine returns the value of a specified environment variable. env-var is the name of the environment variable whose value is to be returned. It cannot have trailing spaces or a zero-byte terminator.
library-reference is a mnemonic-name in the SPECIAL-NAMES paragraph. This mnemonic-name is associated with the DLL containing an object copy of COBOL_RETURN_SORT_ERRORS_. sd-name is the COBOL name of a file defined in an SD entry. The specification of the remaining parameter is applied to any subsequent SORT or MERGE statements that refer to this file name.
Usage Considerations: • Error Detection and Reporting If the process calls 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. If the sort/merge routines do not detect errors during the execution of one of the above statements, sort-code is set to 0 and the contents of the other data items is undefined (unpredictable).
1 file-name is missing or is invalid. 5 An operation error occurred (for example, the file could not be rewound). Usage Considerations: • File Criteria file-name must be a valid COBOL file name, the file associated with file-name must be open at the time of the call and the file-control entry for file-name must specify ORGANIZATION SEQUENTIAL.
the same file name. Certain parameters can be reset to their default values, as indicated in the discussion of the parameters below. param-id is one of: CPU-MASK SCRATCH-FILE SWAP-FILE NO-CPU-MASK SORT-PROGRAM param-text is the identifier of an alphanumeric data item whose contents is used for the parameter specified by param-id. If this parameter is omitted, any text previously set for this value of param-id is reset to its default value.
Table 96 Relationship Between param-id, subsort-number, and param-text (continued) param-id subsort-number param-text If the value of the data item is “0” (ASCII zero), that processor will not be used. If the value is “1,” that processor is a candidate for use. Any other value is an error. NO-CPU-MASK overrides CPU-MASK. SCRATCH-FILE File system name of file to be used by sort as a scratch file.
library-reference is a mnemonic-name in the SPECIAL-NAMES paragraph. This mnemonic-name is associated with the DLL containing an object copy of COBOL_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.
return-code is an identifier of a numeric data item in which an error value will be returned. The expected values and their respective meanings are: Value Meaning 0 The call was correct. 1 The file-name does not name a sort-merge file. 2 The param-id does not have one of the allowed values. 3 The param-value is outside the allowed range.
Usage Considerations: 626 Libraries and Utility Routines
• 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. The value of param-value must be greater than 4095 and less than 8193. The default is 8192.
Allowable Value for param-value Meaning 0 (default) If the scratch 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. subsort-or-file-number must not be specified or must be 0. ◦ DATA-SLACK specifies a percentage of slack space in each data block for an indexed output file.
◦ INDEX-SLACK specifies a percentage of slack space in each index block for an indexed output file. It is applicable only if one GIVING file is specified and that file is an indexed file. The value of param-value is in the range 0 through 99. The default is 0. subsort-or-file-number must not be specified or must be 0. ◦ MINSPACE specifies whether FastSort is to operate in the MINSPACE mode; that is, whether FastSort should attempt to restrict the use of physical memory at the expense of sort time.
◦ NOWAIT-IO specifies whether FastSort performs NOWAIT I-O in passing records to and from the HP COBOL run-time interface (for input and output procedures, for example). Allowable Value for param-value Meaning 0 (default) FastSort must use waited I-O. nonzero FastSort must use NOWAIT I-O. subsort-or-file-number must not be specified or must be 0. If param-value is nonzero, you must also specify SECOND-BUFFER. NOWAIT-IO is ignored if the file if being read or written by FastSort.
◦ 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. ◦ SAVE-SCRATCH specifies whether FastSort should save the scratch file after a sort run.
◦ 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). subsort-or-file-number must not be specified or must be 0.
◦ SUBSORT-COUNT specifies the number of parallel sorts that FastSort is to use to improve performance. Allowable Value for param-value Meaning 0 (default) FastSort uses normal, non-parallel sort. 2-8 FastSort uses parallel sort, and the value of param-value is the number of processes to be used. (A parallel sort might be faster, but it uses more system resources. In a busy system, this might cause an overall loss in system throughput.) subsort-or-file-number must not be specified or must be 0.
file-name is the COBOL file name of the file to be affected. It must be the name of a file defined by an FD, not a sort-merge file description (SD). At the time the ENTER statement is executed, the file connector referenced by file-name must not be open. new-length is the new maximum record size.
library-reference is a mnemonic-name associated in the SPECIAL-NAMES paragraph with the DLL 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. If the file is not open, the call to the Guardian environment routine SETMODE is made during the next successful open request for the file.
The required number of table elements depends on the number of operations the list must record. The worst-case situation uses six elements. A complete checkpoint list is required only when a program has a backup that must be kept current. When a record of changes is not required, a null checkpoint list can be used. This is an example description: 03 CP-LIST-1 PIC 9(9) COMP VALUE IS 0.
Usage Considerations: • Acceptable Values for the Parameter open-type The value of the open-type parameter determines what type of device the 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. Any other value for open-type causes an error.
file-name is the name of a COBOL data file; that is, a file described in a File Description entry. It must be an FD name associated with a file-system file name that specifies a line printer (device type 5) or a spooler collector (device type 0, subdevice type 31). open-type is a numeric operand whose value (after truncation to an integer value, if necessary) is 1. The value 1 (the default) signifies the opening of a line printer or a spooler collector.
report-name is an alphanumeric or equivalent data item that specifies the spooler job report name. Any value provided is adjusted to a length of 16 characters (by extending with spaces or truncating). The first character cannot be a space. No character can be a hyphen (-). If no value is specified, the routine uses the user name associated with the calling process. This parameter applies only to spooler collectors.
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. See the description of SPOOLSTART in the Guardian Procedure Calls Reference Manual for details on spooler job files.
When a file is assigned to a process that is not a spooler collector, the records are written immediately, with no optimization attempted and no SETMODE or CONTROL procedure involvement.
time-limits is a numeric operand that specifies the TIME-LIMITS attribute for a system log file only when the subdevice type is other than 0; if the subdevice type is 0, this parameter is ignored. The evaluation of this operand includes, if necessary, truncation to an integer value.
library-reference is a mnemonic-name in the SPECIAL-NAMES paragraph. This mnemonic-name is associated with the DLL containing an object copy of COBOL_SPECIAL_OPEN_. file-name is the name of a COBOL data file; that is, a file described in a File Description entry. It must be an FD name associated with a file-system file name that specifies a disk file (device type 3). open-type is a numeric operand whose value (after truncation to an integer value, if necessary) is 3.
If a subsequent input-output statement attempts to make reference to a logical record which resides in an unavailable partition of the file, the HP COBOL run-time routines assign a value of 72 (attempt to access unmounted partition) to the special register GUARDIAN-ERR, because that is the file code reported by the operating environment. The I-O status code in this case is “30” (COBOL permanent error).
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. time-limits is a numeric operand that specifies the TIME-LIMITS attribute for the open operation. The evaluation of this operand includes, if necessary, truncation to an integer value. The presence of a nonzero value for this parameter is equivalent to the presence of a TIME LIMITS phrase with a nonzero value in an ordinary OPEN statement.
Non-SMU Routines This topic explains the individual routines in the ZCOBDLL file that are not Saved Message Utility (SMU) routines. Table 97 Non-SMU ZCOBDLL Routines Routine Comment COBOL_SPECIAL_OPEN_ (page 636) COBOL_ASSIGN_ For the Guardian environment COBOLFILEINFO For the Guardian environment COBOL_FILE_INFO_ For the OSS environment CREATEPROCESS Cannot create a high-PIN process.
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 COBOL_ASSIGN_. 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-file-name.
file-type can be specified in the Guardian environment only. It is a numeric data item whose content, or a numeric literal whose value, is either 0 (for an unstructured file) or 2 (for an entry-sequenced file). You can specify file-type only for a file whose organization is sequential. For other file organizations, the organization determines the file type (relative for ORGANIZATION RELATIVE and key sequenced for ORGANIZATION INDEXED).
Example 178 COBOL_ASSIGN_ Routine IDENTIFICATION DIVISION. ... ENVIRONMENT DIVISION. ... SPECIAL-NAMES. FILE "$SYSTEM.SYSTEM.COBOLLIB" IS COBOLLIB. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT PARTNO ASSIGN #DYNAMIC. DATA DIVISION. ... WORKING-STORAGE SECTION. 01 PART-FILE-NAME PICTURE X(35). 01 ASSIGN-ERROR COMP PICTURE 9999. PROCEDURE DIVISION. SETUP.
library-reference is a mnemonic-name associated, in the SPECIAL-NAMES paragraph, with either ZCOBDLL or some other object file containing an object copy of COBOLFILEINFO. fd-name is the COBOL name of the file in the FD entry. error-code is a numeric data item described as USAGE COMPUTATIONAL PICTURE 9999 (or S9999)or USAGE NATIVE-2. The COBOLFILEINFO routine returns the last file system file-system error code to this data item. The value returned is always positive.
created for that purpose. Certain operations, such as a READ statement operating on the $RECEIVE file, deliver meaningful values to GUARDIAN-ERR, but a call to COBOLFILEINFO would return an inappropriate value of zero or an arbitrary, undefined value. COBOL_FILE_INFO_ The COBOL_FILE_INFO_ routine is for both the OSS and Guardian environments.
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.
The cobsetjmp() macro is used with the coblongjmp() function for handling errors and interrupts encountered in low-level functions of a mixed-language program. The cobsetjmp() macro provides functionality similar to the standard HP C setjmp() function. The cobsetjmp() macro cannot be called directly from an HP COBOL program. Applications must call cobsetjmp() from an HP C module. NOTES All restrictions on the use of setjmp() apply to cobsetjmp() also.
The coblongjmp() function returns control to the HP C function that called cobsetjmp(). The HP C function that called cobsetjmp() must still be active. The coblongjmp() function cannot be called directly from an HP COBOL program. Applications must call coblongjmp() from an HP C function. NOTES All restrictions on the use of longjmp() apply to coblongjmp() also. EXAMPLES The following example illustrates the use of coblongjmp(): #include extern struct cobjmp_buf void { buf; c_prog_2(void) ...
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.
Table 98 Alphanumeric Intrinsic Functions (continued) Function Name Value Returned UPPER-CASE Function Its argument with all letters set to uppercase WHEN-COMPILED Function Date and time when program was compiled Numeric Intrinsic Functions A numeric intrinsic function returns a numeric value.
Table 100 Integer Intrinsic Functions (continued) Function Name Value Returned INTEGER Function Greatest integer not greater than argument INTEGER-OF-DATE Function Integer date equivalent of standard date (YYYYMMDD )* INTEGER-OF-DAY Function Integer date equivalent of Julian date (YYYYDDD )* INTEGER-PART Function Integer part of argument LENGTH Function Length of argument MOD Function First argument modulo second argument ORD Function Ordinal position of argument in program collating sequence
Table 103 Argument Types Argument Type What You Must Specify What is Used in Determining the Function’s Value Numeric Arithmetic expression Value of arithmetic expression, including operational sign Integer Arithmetic expression that always results in integer value Value of arithmetic expression, including operational sign Alphabetic Elementary data item of the class Value of argument and possibly its size alphabetic, or nonnumeric literal containing only alphabetic characters Alphanumeric Data
Example 179 ACOS Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A PICTURE S9V99. PROCEDURE DIVISION. MOVE FUNCTION ACOS (-1) DISPLAY A. MOVE FUNCTION ACOS (.25) DISPLAY A. MOVE FUNCTION ACOS (.5) DISPLAY A. MOVE FUNCTION ACOS (.75) DISPLAY A. MOVE FUNCTION ACOS (1) DISPLAY A. TO A. TO A. TO A. TO A. TO A.
Example 180 ANNUITY Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A PICTURE 9V99. PROCEDURE DIVISION. MOVE FUNCTION ANNUITY (1 12) TO A. DISPLAY A. MOVE FUNCTION ANNUITY (1 6) TO A. DISPLAY A. MOVE FUNCTION ANNUITY (2 6) TO A. DISPLAY A. MOVE FUNCTION ANNUITY (5 2) TO A. DISPLAY A. MOVE FUNCTION ANNUITY (0 DISPLAY A. 5) TO A. Output: 1.00 1.01 2.00 5.14 0.20 ASIN Function ASIN, a numeric function, returns a value in radians that approximates the arcsine of its argument.
Example 181 ASIN Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A PICTURE S9V99. PROCEDURE DIVISION. MOVE FUNCTION ASIN DISPLAY A. MOVE FUNCTION ASIN DISPLAY A. MOVE FUNCTION ASIN DISPLAY A. MOVE FUNCTION ASIN DISPLAY A. MOVE FUNCTION ASIN DISPLAY A. (-1) TO A. (.25) TO A. (.5) TO A. (.75) TO A. (1) TO A. Output: -1.57 0.25 0.52 0.84 1.57 ATAN Function ATAN, a numeric function, returns a value in radians that approximates the arctangent of its argument. argument is a numeric argument.
Example 182 ATAN Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A PICTURE S9V99. PROCEDURE DIVISION. MOVE FUNCTION ATAN (-10) DISPLAY A. MOVE FUNCTION ATAN (0) DISPLAY A. MOVE FUNCTION ATAN (.25) DISPLAY A. MOVE FUNCTION ATAN (15.5) DISPLAY A. MOVE FUNCTION ATAN (45) DISPLAY A. TO A. TO A. TO A. TO A. TO A. Output: -1.47 0.00 0.24 1.50 1.54 CHAR Function CHAR, an alphanumeric function, returns a character whose ordinal number in the program collating sequence is the value of its argument.
Example 183 CHAR Function Without ALPHABET Clause Code: DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION CHAR CHAR CHAR CHAR CHAR (36) (43) (54) (69) (99) Output: # * 5 D b Example 184 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 DIVISION. Startt.
Example 185 COS Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A PICTURE S9V99. PROCEDURE DIVISION. MOVE FUNCTION COS (-10) DISPLAY A. MOVE FUNCTION COS (0) DISPLAY A. MOVE FUNCTION COS (.25) DISPLAY A. MOVE FUNCTION COS (15.5) DISPLAY A. MOVE FUNCTION COS (45) DISPLAY A. TO A. TO A. TO A. TO A. TO A. Output: -0.83 1.00 0.96 -0.97 0.
Example 186 CURRENT-DATE Function Code: DISPLAY FUNCTION CURRENT-DATE Output: 1997041116522224-0700 The date in Example 186 is April 11, 1997 (19970411). The time is 16:52:22.24 or 4:52:22.24 PM (16522224), which is 7 hours behind Greenwich mean time (-0700). 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 ).
Example 188 DAY-OF-INTEGER Function Code: DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION DAY-OF-INTEGER DAY-OF-INTEGER DAY-OF-INTEGER DAY-OF-INTEGER DAY-OF-INTEGER (1) (365) (36500) (12345) (100000) Output: 1601001 1601365 1700341 1634292 1874289 FACTORIAL Function FACTORIAL, an integer function, returns the factorial of its argument. argument is an integer greater than or equal to zero.
Example 190 INTEGER Function Code: DISPLAY DISPLAY DISPLAY DISPLAY FUNCTION FUNCTION FUNCTION FUNCTION INTEGER INTEGER INTEGER INTEGER (-3.5) (-3) (3) (3.5) Output: -4 -3 3 3 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.
Example 192 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.
argument is an integer of the form YYYYDDD, whose value is calculated from the equation (YYYY * 1000) + DD where: Factor Date Part Represented Represented by YYYY Year in Gregorian calendar Integer in the range 1,601 through 9,999 DD Day of the year Integer in the range 1 through 366 that is a valid day for the year specified by YYYY The returned value is an integer that is the number of days that the date represented by argument succeeds December 31, 1600, in the Gregorian calendar.
Example 194 INTEGER-PART Function Code: DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION INTEGER-PART INTEGER-PART INTEGER-PART INTEGER-PART INTEGER-PART (-1.5) (-1) (0) (1) (1.5) Output: -1 -1 0 1 1 LENGTH Function LENGTH, an integer function, returns the length of its argument (the number of character positions it has, regardless of its current value). argument is a nonnumeric literal or data item of any class or category.
Example 195 LENGTH Function Code: 01 STUFF-1 PIC XXXX. 01 STUFF-2 PIC 9999. MOVE "AB" TO STUFF-1. MOVE 12 TO STUFF-2. DISPLAY FUNCTION LENGTH(STUFF-1). DISPLAY STUFF-2. DISPLAY FUNCTION LENGTH(STUFF-2). DISPLAY FUNCTION LENGTH("ABC"). Output: 4 0012 4 3 LOG Function LOG, a numeric function, returns a value that approximates the logarithm to the base e (natural logarithm) of its argument. argument is a numeric argument greater than zero.
argument is a numeric argument greater than zero. The returned value is approximately the logarithm to the base 10 of the value of argument. Example 197 LOG10 Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A PICTURE S9V99. PROCEDURE DIVISION. MOVE FUNCTION LOG10 (1) DISPLAY A. MOVE FUNCTION LOG10 (10) DISPLAY A. MOVE FUNCTION LOG10 (100) DISPLAY A. MOVE FUNCTION LOG10 (1000) DISPLAY A. MOVE FUNCTION LOG10 (10000) DISPLAY A. TO A. TO A. TO A. TO A. TO A. Output: 0.00 1.00 2.00 3.00 4.
Example 198 LOWER-CASE Function Code: DISPLAY FUNCTION LOWER-CASE ("HEWLETT-PACKARD COMPANY 2003") DISPLAY FUNCTION LOWER-CASE ("Hewlett-packard Company 2003") DISPLAY FUNCTION LOWER-CASE ("hewlett-packard company 2003") Output: hewlett-packard company 2003 hewlett-packard company 2003 hewlett-packard company 2003 MAX Function MAX is a function that returns the value of its maximum argument.
Example 199 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". 01 ALPHA-ARRAY REDEFINES ALPHABETIC-ARRAY.
Example 200 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.2 9) TO A. DISPLAY A. Output: 5.6 4.0 5.
Example 201 MEDIAN 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 MEDIAN (NUM(ALL)) TO A. DISPLAY A. MOVE FUNCTION MEDIAN (NUM(1) NUM(3) NUM(5)) TO A. DISPLAY A. MOVE FUNCTION MEDIAN (4 1 7 5 2 3 6) TO A. DISPLAY A.
Example 202 MIDRANGE 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 MIDRANGE (NUM(ALL)) TO A. DISPLAY A. MOVE FUNCTION MIDRANGE (NUM(1) NUM(3) NUM(5)) TO A. DISPLAY A. MOVE FUNCTION MIDRANGE (8 1 3 6) TO A. DISPLAY A. Output: 6.0 4.
Example 203 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". 01 ALPHA-ARRAY REDEFINES ALPHABETIC-ARRAY.
Example 204 MOD Function Code: DISPLAY DISPLAY DISPLAY DISPLAY FUNCTION FUNCTION FUNCTION FUNCTION MOD MOD MOD MOD (11 5) (-11 5) (11 -5) (-11 -5) Output: 00001 00004 -00004 -00001 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. string sp is a string of zero or more space characters.
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. Using it is inefficient, so it is best to avoid using a string that is longer than 9 characters. If the NUMVAL function is moved to an alphanumeric item, the results might not be what is expected because of the implied PICTURE described previously.
value-2 spaces is a string of zero or more space characters. 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 If the program contains the DECIMAL POINT COMMA phrase in the SPECIAL-NAMES paragraph, use a comma instead of a decimal point in number. digits is a string of one to 18 digits. The total number of digits in string cannot exceed 18.
Example 206 NUMVAL-C Function Code: DATA DIVISION WORKING-STORAGE SECTION. 01 A PICTURE S99V99. PROCEDURE DIVISION. MOVE FUNCTION NUMVAL-C ("35") TO A. DISPLAY A. MOVE FUNCTION NUMVAL-C ("$35") TO A. DISPLAY A. MOVE FUNCTION NUMVAL-C ("35$") TO A. DISPLAY A. MOVE FUNCTION NUMVAL-C ("35.75") TO A. DISPLAY A. MOVE FUNCTION NUMVAL-C (".35") TO A. DISPLAY A. MOVE FUNCTION NUMVAL-C (" - 35.75 ") TO A. DISPLAY A. MOVE FUNCTION NUMVAL-C (" 35.75 CR") TO A. DISPLAY A. Output: 35.00 35.00 35.00 35.75 00.35 -35.
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. argument can be an array; for example, FUNCTION ORD-MAX (ARRAY1(ALL)) returns the ordinal number of the largest element of the array ARRAY1.
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. argument can be an array; for example, FUNCTION ORD-MIN (ARRAY1(ALL)) returns the ordinal number of the smallest element of the array ARRAY1. The returned value is the ordinal number of the argument with the least value (according to the rules for evaluating simple conditions).
discount-rate is a numeric argument whose value is greater than -1. period-end-amount is a numeric argument. period-end-amount can be an array; for example, FUNCTION PRESENT-VALUE (DISCOUNT-RATE ARRAY1(ALL)) uses the elements of the array ARRAY1 as a series of numeric arguments. The returned value is approximately where n is the number of period-end-amount s. Example 210 PRESENT-VALUE Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 NUMERIC-ARRAY. 05 PICTURE 9V99 VALUE 0.05.
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. Each subsequent time that the run unit calls RANDOM without specifying argument, RANDOM returns the next pseudorandom number in the series.
Example 212 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 DIVISION. DISPLAY FUNCTION RANGE (NUM(ALL)) DISPLAY FUNCTION RANGE (9 2 5 3.5) DISPLAY FUNCTION RANGE (1.5 3.6 7.8 4.9) Output: 4.50 7.0 6.
Example 213 REM Function Code: DISPLAY DISPLAY DISPLAY DISPLAY FUNCTION FUNCTION FUNCTION FUNCTION REM REM REM REM (11 5) (-11 5) (11 -5) (-11 -5) Output: 01 -01 01 -01 REVERSE Function REVERSE, an alphanumeric function, returns a string that is the same as its argument, except that the characters are in reverse order. 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.
Example 215 SIN Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A PICTURE S9V99. PROCEDURE DIVISION. MOVE FUNCTION SIN (-10) DISPLAY A. MOVE FUNCTION SIN (0) DISPLAY A. MOVE FUNCTION SIN (.25) DISPLAY A. MOVE FUNCTION SIN (15.5) DISPLAY A. MOVE FUNCTION SIN (45) DISPLAY A. TO A. TO A. TO A. TO A. TO A. Output: 0.54 0.00 0.24 0.20 0.85 SQRT Function SQRT, a numeric function, returns a value that approximates the square root of its argument.
Example 216 SQRT Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A PICTURE S9V99. PROCEDURE DIVISION. MOVE FUNCTION SQRT (0) DISPLAY A. MOVE FUNCTION SQRT (25) DISPLAY A. MOVE FUNCTION SQRT (100) DISPLAY A. MOVE FUNCTION SQRT (47) DISPLAY A. MOVE FUNCTION SQRT (7.923) DISPLAY A. TO A. TO A. TO A. TO A. TO A. Output: 00.000 05.000 10.000 06.855 02.814 STANDARD-DEVIATION Function STANDARD-DEVIATION, a numeric function, returns a value that approximates the standard deviation of its arguments.
Example 217 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. MOVE FUNCTION STANDARD-DEVIATION (9 2 5 3.5) TO A. DISPLAY A.
Example 218 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 DIVISION. DISPLAY FUNCTION SUM (NUM(ALL)) DISPLAY FUNCTION SUM (9 2 5 3) DISPLAY FUNCTION SUM (1.5 3.6 7.8 4.9) Output: 012.00 19 17.
Example 219 TAN Function Code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A PICTURE S9V99. PROCEDURE DIVISION. MOVE FUNCTION ATAN (-10) DISPLAY A. MOVE FUNCTION ATAN (0) DISPLAY A. MOVE FUNCTION ATAN (.25) DISPLAY A. MOVE FUNCTION ATAN (15.5) DISPLAY A. MOVE FUNCTION ATAN (45) DISPLAY A. TO A. TO A. TO A. TO A. TO A. Output: -0.64 0.00 0.25 -0.21 1.
Example 220 TEST-NUMVAL Function Code: IDENTIFICATION DIVISION. PROGRAM-ID. TEST-NUMVAL. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-DATA. 03 A PIC S9(4). PROCEDURE DIVISION. MAIN-LOGIC SECTION. MOVE FUNCTION TEST-NUMVAL("35") to A. DISPLAY A. MOVE FUNCTION TEST-NUMVAL("35.") to A. DISPLAY A. MOVE FUNCTION TEST-NUMVAL("35.75") to A. DISPLAY A. MOVE FUNCTION TEST-NUMVAL(".35") to A. DISPLAY A. MOVE FUNCTION TEST-NUMVAL("=35.75") to A. DISPLAY A. MOVE FUNCTION TEST-NUMVAL("35.75 CR") to A. DISPLAY A.
Example 221 TEST-NUMVAL-C Function Code: IDENTIFICATION DIVISION. PROGRAM-ID. TEST-NUMVAL-C. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-DATA. 03 A PIC S9(4). PROCEDURE DIVISION. MAIN-LOGIC SECTION. MOVE FUNCTION TEST-NUMVAL-c("35") to A. DISPLAY A. MOVE FUNCTION TEST-NUMVAL-c("$35") to A. DISPLAY A. MOVE FUNCTION TEST-NUMVAL-c("35$") to A. DISPLAY A. MOVE FUNCTION TEST-NUMVAL-c("35.75") to A. DISPLAY A. MOVE FUNCTION TEST-NUMVAL-c(".35") to A. DISPLAY A. MOVE FUNCTION TEST-NUMVAL-c("=35.75") to A.
Example 222 UPPER-CASE Function Code: DISPLAY FUNCTION UPPER-CASE ("HEWLETT-PACKARD COMPANY 2003") DISPLAY FUNCTION UPPER-CASE ("Hewlett-packard Company 2003") DISPLAY FUNCTION UPPER-CASE ("hewlett-packard company 2003") Output: HEWLETT-PACKARD COMPANY 2003 HEWLETT-PACKARD COMPANY 2003 HEWLETT-PACKARD COMPANY 2003 VARIANCE Function VARIANCE, a numeric function, returns a value that approximates the variance of its arguments. argument is a numeric argument.
Example 223 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 (NUM(ALL)) TO A DISPLAY A.. MOVE FUNCTION VARIANCE (9 2 5 3) TO A. DISPLAY A. MOVE FUNCTION VARIANCE (1.5 3.6 7.8 4.9) TO A. DISPLAY A.
Character Positions Date Part Represented Represented by 18-19 Hours behind or ahead of Greenwich mean time If character position 17 is minus (-), two digits in the range 00 through 12; if character position 17 is plus (+), two digits in the range 00 through 13 20-21 Additional minutes from Greenwich mean time Two digits in the range 00 through 59 The returned value matches the compilation time and date on the listing and object code files (if they have it), but the representation and precision may
15 Debugging Tools This section briefly describes the HP debugging tools and refers you to appropriate sources for more information. CAUTION: If you use the CODECOV (page 542) compiler directive to direct your compiler to generate instrumented object code, the Code Coverage Utility connects to the application program as a debugger to read its memory and so on. This causes all the debug requests to wait until the Code Coverage Utility (the active debugger) detaches from the application.
Any mechanism that calls the debugging facility calls the selected run-time debugger.
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.
16 ANSI Reference Format In ANSI reference format, each line has 80 characters (columns). Five margins divide each line into five areas. Figure 26 ANSI Reference Format 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.
Compiler Directive A compiler directive has a question mark (?) in the indicator area. If the question mark is in column 1 instead of column 7, the compiler treats the line as if it begins with the indicator area. A compiler directive is an instruction to the COBOL compiler, and a compiler directive line has no sequence number area. (For more information on compiler directives, see Compiler Directives (page 533).) Ordinary Comment An ordinary comment has an asterisk (*) in the indicator area.
on the line depends on the column in which the character-string begins. It might take a few compilations before you have the literal string divided properly over multiple lines. Area A Area A begins at Margin A and uses columns 8 through 11.
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 (page 743) • Chapter 18: HP COBOL CRE Support (page 709) • Chapter 4
• HP COBOL allows you to qualify status condition-names. • COBOL does not permit the decimal point as the rightmost (last) character of a numeric literal; HP COBOL relaxes this restriction somewhat: ◦ If the apparent last character of a numeric literal qualifies as a decimal point and the immediately following character is not a space (but is a semicolon, comma, or right parenthesis), the compiler interprets that last character as the decimal point.
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 (page 302) ◦ STARTBACKUP (page 460) ◦ SYNCDEPTH phrase of OPEN (page 375) • To mark the beginning of a parameter list, the USING phrase of ENTER (page 319) • To specify a data item that stores the value a function returns, the GIVING phrase of ENTER (page 319) • To control file access and maintain the integrity of data ba
file status is 30 (permanent error), GUARDIAN-ERR contains the file system error number identifying the cause. See Diagnosing Input-Output Errors (page 251). • Additional special registers: ◦ PROGRAM-STATUS ◦ PROGRAM-STATUS-1 ◦ PROGRAM-STATUS-2 ◦ RETURN-CODE • If the program is compiled with the PORT directive, CALL (page 293) behaves like the X/OPEN CALL statement, which is not an element of COBOL (see PORT and NOPORT (page 560)).
18 HP COBOL CRE Support All native programs run in the CRE. Native HP COBOL programs can call and be called by programs written in native HP C, native HP C++, and pTAL, even if the main program is not written in HP COBOL. For more information about writing HP COBOL programs for the CRE, see the CRE Programmer’s Guide. Introducing the CRE The Common Run-Time Environment (CRE) is a set of services that supports mixed-language programs. The CRE library is a collection of routines that implements the CRE.
OFF, the CRE causes the program to terminate abnormally with a run-time diagnostic message and a trace to the offending statement.
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.
pathname 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. If the current directory is in your search path, you can run your program by typing the name of the loadfile and pressing Return. For example, if the name of the loadfile is a.out, enter: a.
Then you use the nmecobol utility to do this: • Compile the HP COBOL modules • Link the ecobol compiler output, the object file cprog.o, and the native HP C library. • Produce the loadfile myprog: ecobol -o myprog cprog.o cobol1.cbl cobol2.cbl The ecobol utility automatically links the HP C DLLs to myprog.
Programmer’s Guide and the filename(5) reference page either online or in the Open System Services System Calls Reference Manual. OSS Pathnames for OSS Files The OSS pathname of an OSS file has this format: OSS specifies that the file is an OSS file (the default). If OSS is specified, the entire pathname must be enclosed in quotation marks. node specifies the name of a remote node. The operating system on the node must be version D40.00 or later, and the node must have a compatible OSS name server.
Example 226 OSS Pathnames for OSS Files file2 vol1/file2 usr/vol1/file2 /usr/vol1/file2 /usr/vol1/part3/file2 "OSS /usr/vol1/file2" /E/qa2/usr/vol1/file2 "OSS /E/qa2/usr/vol1/file2" OSS Pathnames for Guardian Files The OSS pathname of a Guardian file has this format: 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.
Within an HP COBOL program, the maximum length of an OSS pathname is the maximum length of a literal (160 characters). 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.
SELECT clause OPTIONAL makes the file optional, which means that an OPEN statement with an INPUT or EXTEND phrase can open the file regardless of whether 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. When you open a nonexistent optional file for input, the first READ statement for that file calls the AT END option (or USE procedure if the READ statement has no AT END phrase).
makes the organization of the file line sequential. ACCESS MODE clause makes the access mode of the file sequential (the default). FILE STATUS clause defines filestat as the file-status data item for the file. When a COBOL run-time 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 (page 247)).
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 (page 155). I-O-CONTROL Paragraph The syntax for an I-O-CONTROL paragraph for a line sequential file is: «RERUN clause» NOTE: use it.
SAME AREA clause 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. OPEN Statement The OPEN statement has this file-specification: INPUT specifies that the file or files in input-file-description are being opened for reading only.
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 is the file description file name of a file to open in OUTPUT mode, for write operations only. SHARED, PROTECTED, EXCLUSIVE are the same as described earlier for infile.
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. 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.
record-name is a logical record described in the File Section of the Data Division. The record-name 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. from-name is the identifier of a data area whose contents are to be moved to the record specified by record-name before the WRITE occurs. from-name must specify a data area other than that specified by record-name. It cannot specify an index data item.
Table 106 Analogous PARAM Commands and OSS Environment Variables (continued) PARAM Command OSS Environment Variable1 PARAM NONSTOP OFF export NONSTOP=OFF PARAM PRINTER-CONTROL name export PRINTER_CONTROL=name PARAM SWITCH-n ON2 export SWITCH_n =ON2 PARAM SWITCH-n OFF2 export SWITCH_n =OFF2 1 Type nonvariables with the cases and spacing shown. 2 n is “1” through “9” or “10” through “15” (without quotes).
The utility routine COBOLFILEINFO does not return useful information in the OSS environment. Use the routine COBOL_FILE_INFO_ instead. When using #DYNAMIC in the OSS environment to dynamically assign Guardian file names or Guardian spooler process names, you must use "GUARDIAN #DYNAMIC" in the file-control entry. The file name passed by the COBOL_ASSIGN_ utility is a standard Guardian name.
20 HP COBOL Limits The HP architecture and the method of implementation of the HP COBOL compiler ECOBOL, impose these kinds of limits on HP COBOL programs: • Size (page 726) • Number (page 727) • Callability (page 729) • External Names (page 729) • Ranges of Values (page 729) • Organization (page 81) • Block size of record in a data file Size The maximum block size of a record in a data file is 32,768 characters.
of the keys cannot exceed 2046 characters for Indexed files; for other files, the sum cannot exceed 253 characters. For a list of the required H06.28/J06.17 SPRs, see “SPR Requirements for Increased Enscribe Limits for the H06.28/J06.17 Release” (page 38). • Index An index (index-name or index data item) occupies four bytes, in any section: File, Working-Storage, or Extended-Storage. • Length of a numeric literal A numeric literal has a maximum length of 18 digits.
• 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.
have a maximum of 32,767 references to level-88 condition-names. There is no limit to the number of references to condition-names for external switches. • Subjects in an EVALUATE statement The maximum number of receivers in an EVALUATE statement is 127. • Subscripts See Nesting Depth.
Ignored Elements HP COBOL compilers ignore these elements of COBOL because they are unnecessary in the HP implementation: • In the entire source program: In ANSI format, columns 1 through 6 and beyond 72 • In the Environment Division: ◦ In the SOURCE-COMPUTER paragraph: Source computer name ◦ In the OBJECT-COMPUTER paragraph: ◦ – Object computer name – MEMORY SIZE clause – SEGMENT-LIMIT clause In the INPUT-OUTPUT section: – – • In the FILE-CONTROL paragraph: in the file-control-entry : –
21 Reserved Words This section contains these alphabetized lists: • All Reserved Words • HP Reserved Words Figure 27 How Lists of Reserved Words Are Related 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), words reserved by the COBOL 2002 standard (indicated with an asterisk), and reserved words found only in HP COBOL (HP additions to COBOL).
AND ANY *ANYCASE APPROXIMATE AREA AREAS *AS ASCENDING ASSIGN AT AUTHOR B *B-AND *B-NOT *B-OR *B-XOR *BASED BEFORE BINARY *BINARY-CHAR *BINARY-DOUBLE *BINARY-LONG *BINARY-SHORT *BIT BLANK BLOCK *BOOLEAN BOTTOM BY C CALL CANCEL CD CF CHARACTER CHARACTERS CHARACTER-SET CHECKPOINT CLASS *CLASS-ID CLOCK-UNITS 732 Reserved Words
CLOSE COBOL CODE CODE-SET *COL COLLATING *COLS COLUMN COMMA COMMON COMMUNICATION COMP COMP-3 COMP-5 COMPUTATIONAL COMPUTATIONAL-3 COMPUTATIONAL-5 COMPUTE *CONDITION CONFIGURATION *CONSTANT CONTAINS CONTENT CONTINUE CONTROL CONTROLS CONVERTING COPY CORR CORRESPONDING COUNT *CRT CURRENCY *CURSOR D DATA *DATA-POINTER DATE DATE-COMPILED DATE-WRITTEN DAY All Reserved Words 733
DAY-OF-WEEK DE DEBUG-CONTENTS DEBUG-ITEM DEBUG-LINE DEBUG-NAME DEBUG-SUB-1 DEBUG-SUB-2 DEBUG-SUB-3 DEBUGGING DECIMAL-POINT DECLARATIVES *DEFAULT DELETE DELIMITED DELIMITER DEPENDING DESCENDING DESTINATION DETAIL DISABLE DISPLAY DIVIDE DIVISION DOWN DUPLICATES DYNAMIC E *EC EGI ELSE EMI ENABLE END *END-ACCEPT END-ADD END-COMPUTE END-DELETE *END-DISPLAY END-DIVIDE END-EVALUATE 734 Reserved Words
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 *EO EOP EQUAL ERROR ESI EVALUATE EVERY EXCEPTION *EXCEPTION-OBJECT EXCLUSIVE EXIT EXTEND EXTENDED-STORAGE EXTERNAL F *FACTORY FALSE FD FILE FILE-CONTROL FILLER FINAL FIRST *FLOAT-EXTENDED *FLOAT-LONG *FLOAT-SHORT All Reserved Words 735
FOOTING FOR *FORMAT *FREE FROM FUNCTION *FUNCTION-ID G GENERATE GENERIC *GET GIVING GLOBAL GO *GO BACK GREATER GROUP GUARDIAN-ERR H HEADING HIGH-VALUE HIGH-VALUES I I-O I-O-CONTROL IDENTIFICATION IF IN INDEX INDEXED INDICATE *INHERITS INITIAL INITIALIZE INITIATE INPUT INPUT-OUTPUT INSPECT INSTALLATION *INTERFACE 736 Reserved Words
*INTERFACE-ID INTO INVALID *INVOKE IS J JUST JUSTIFIED K KEY L LABEL LAST LEADING LEFT LENGTH LESS LIMIT LIMITS LINAGE LINAGE-COUNTER LINE LINE-COUNTER LINKAGE *LOCAL-STORAGE *LOCALE LOCK LOCKFILE LOW-VALUE LOW-VALUES M MEMORY MERGE MESSAGE *METHOD *METHOD-ID *MINUS MODE MODULES MOVE All Reserved Words 737
MULTIPLE MULTIPLY N *NATIONAL *NATIONAL-EDITED NATIVE *NESTED NEGATIVE NEXT NO NOT NULL NULLS NUMBER NUMERIC NUMERIC-EDITED O *OBJECT OBJECT-COMPUTER *OBJECT-REFERENCE OCCURS OF OFF OMITTED ON OPEN OPTIONAL *OPTIONS OR ORDER ORGANIZATION OTHER OUTPUT OVERFLOW *OVERRIDE P PACKED-DECIMAL PADDING PAGE PAGE-COUNTER 738 Reserved Words
PERFORM PF PH PIC PICTURE PLUS POINTER POSITION POSITIVE *PRESENT PRINTING PROCEDURE PROCEDURES PROCEED PROGRAM PROGRAM-ID *PROGRAM-POINTER PROGRAM-STATUS PROGRAM-STATUS-1 PROGRAM-STATUS-2 PROMPT *PROPERTY PROTECTED PURGE Q QUEUE QUOTE QUOTES R *RAISE *RAISING RANDOM RD READ RECEIVE RECEIVE-CONTROL RECORD RECORDS REDEFINES REEL REFERENCE All Reserved Words 739
REFERENCES RELATIVE RELEASE REMAINDER REMOVAL RENAMES REPLACE REPLACING REPLY REPORT REPORTING REPORTS *REPOSITORY RERUN RESERVE RESET *RESUME *RETRY RETURN *RETURNING REVERSED REWIND REWRITE RF RH RIGHT ROUNDED RUN S SAME *SCREEN SD SEARCH SECTION SECURITY SEGMENT SEGMENT-LIMIT SELECT *SELF SEND SENTENCE 740 Reserved Words
SEPARATE SEQUENCE SEQUENTIAL SET SHARED *SHARING SIGN SORT SORT-MERGE SOURCE *SOURCES 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 *SUPER SUPPRESS SYMBOLIC SYNC SYNCDEPTH SYNCHRONIZED *SYSTEM-DEFAULT T TABLE TAL TALLYING TAPE TERMINAL All Reserved Words 741
TERMINATE TEST TEXT THAN THEN THROUGH THRU TIME TIMES TO TOP TRAILING TRUE TYPE *TYPEDEF U UNIT *UNIVERSAL UNLOCK UNLOCKFILE UNLOCKRECORD UNSTRING UNTIL UP UPON USAGE USE *USER-DEFAULT USING V *VAL-STATUS *VALID *VALIDATE *VALIDATE-STATUS VALUE VALUES VARYING W WHEN WITH 742 Reserved Words
WORDS WORKING-STORAGE WRITE Z ZERO ZEROES Special Characters + * / ** < > = HP Reserved Words This is an alphabetic list of reserved words found only in HP COBOL (HP additions to COBOL).
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 744 Reserved Words
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 Chapter 19: Using HP COBOL in the OSS Environment (page 711). If you want to include SQL/MP or SQL/MX commands in your HP COBOL program, see the SQL/MP Programming Manual for COBOL or the SQL/MX Programming Manual for C and COBOL.
If you enter an exclamation mark followed by a number, TACL displays and executes the command with that number: 6> 6> 1> 2> 3> 4> 5> 6> 7> !4 history who fileinfo view myfile history history history If you enter an exclamation mark followed by text, TACL displays and executes the most recent command that begins with that text: 7> !v 7> view myfile 8> Editing and Reexecuting Previous Commands If you enter the command FC, TACL displays the last command so that you can edit it: 8> fc 8> view myfile 8...
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 an 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”). Both editors create and allow you to alter the same type of file, the EDIT format file (abbreviated “EDIT file”).
Figure 28 Tandem Reference Format Figure 29 ANSI Reference Format You can write a COBOL source program entirely in either format or in a mixture of both. The default is Tandem format. Unless you direct the compiler to accept ANSI format, the compiler assumes the entire program is in Tandem format. 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.
To retrieve lines from a non-EDIT file (in this example, PAYROLXX) and put them into an EDIT file (in this example, PAYROLS), use the GET and PUT commands together: *GET PAYROLXX PUT PAYROLS (With the TEDIT editor, you cannot combine the GET and PUT commands.
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.
You execute TEDIT commands in two ways: • Press predefined command keys and key combinations (see the TEDIT keyboard template for your terminal). • Type the commands on the command line and press Return (to access the command line, press Shift and Return simultaneously, or use the key specified by the TEDIT keyboard template for your terminal). If a command requires parameters and you do not supply them, the TEDIT editor prompts you for them.
• pTAL and TAL • TACL When you open a source file, the appropriate language-specific menu appears on the menu bar. For all languages, you can search (GREP) commands in the file, keywords are chromacoded (see Chromacoding), and you can save function call parameters in the dictionary for later use (see Dictionaries and Templates). For HP C and HP C++, you can create or insert modules or work with #PRAGMAS and #INCLUDES. For HP C++, you have additional support for creating classes and class members.
From the user’s viewpoint, compilation is a single-step process. (If you are interested in the details of the compilation process, see Compilation Details (page 516).
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 (page 700). For more information about the ERRORFILE directive, see ERRORFILE (page 549). IN and OUT are options of the TACL command RUN. Other RUN command options that you might find useful when compiling HP COBOL programs are: • NOWAIT If you specify ECOBOL /IN XYZ, OUT $SPX.
and RUNNABLE directives, and there are no compilation errors, the ECOBOL compiler calls the eld utility, which produces a DLL. The ECOBOL compiler: 1. If the object file already exists and it is not a code 800 file, the compiler attempts to create the file named OBJECT. If this file exists or is open by another process, the compiler creates a file named ZZNCnnnn, where nnnn is a sequence of randomly chosen alphanumeric characters. 2.
Another way to find syntax errors in your program is with the FIXERRS macro, which requires that you compile your program with the ERRORFILE directive. For more information about the FIXERRS macro, see FIXERRS Macro (page 700). For more information about the ERRORFILE directive, see ERRORFILE (page 549). Specifying Subvolumes to Be Searched for Unqualified Files In your HP COBOL source program, an unqualified file is a file whose name does not contain a volume and subvolume.
94> PARAM SWAPVOL $COBVOL 95> CLEAR PARAM SWAPVOL 96> ECOBOL /IN XYZ, OUT $SPX/ XYZOBJ Compiler Space Allocation The PARAM SYMBOL-BLOCKS command specifies how much space the compiler allocates for its symbol dictionary and embedded SQL/MP statements—see PARAM SYMBOL-BLOCKS (page 528).
Example 230 COPY or SOURCE Library ?SECTION NAMEREC 01 NAME-REC. 03 LAST-NAME PICTURE X(15). 03 M-I PICTURE X(1). 03 FIRST-NAME PICTURE X(15). 03 TITLE PICTURE 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 or Altering a COPY or SOURCE Library You can create a COPY or SOURCE library with an HP editor or with Data Definition Language (DDL). You can alter a COPY or SOURCE library with an HP editor unless it was created with DDL, in which case you must alter it with DDL.
Example 231 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 *. END RECORD PERSON-RECORD. FILE IS "folks" Entry-Sequenced. 02 NAME-AND-ADDRESS TYPE *.
02 STATE-OR-PROVINCE PIC X(25). 02 NATION PIC X(25). 02 POSTAL-CODE PIC X(11). ?SECTION NAME-AND-ADDRESS,HP * Definition NAME-AND-ADDRESS created on 02/28/93 at 12:01 01 NAME-AND-ADDRESS. 02 NAME. 03 LAST-NAME PIC X(15). 03 MIDDLE-INITIAL PIC X(1). 03 FIRST-NAME PIC X(15). 02 ADDRESS. 03 STREET-NUMBER PIC X(6). 03 STREET-NAME PIC X(25). 03 FLAT-NUMBER PIC X(8). 03 MUNICIPALITY PIC X(25). 03 STATE-OR-PROVINCE PIC X(25). 03 NATION PIC X(25). 03 POSTAL-CODE PIC X(11).
SET NO ALTCREATE SET ALTFILE ( 0, folks0 ) SET TYPE E SET REC 357 SET BLOCK 512 CREATE folks RESET SET TYPE K SET KEYLEN 41 SET REC 41 SET BLOCK 512 SET IBLOCK 512 CREATE folks0 Data Dictionary A data dictionary is a set of files that documents the structure and location of each file in your database. You can use the DDL compiler to translate DDL source statements into a data dictionary, and then you can use the DDL compiler to modify the data dictionary and re-create the data declaration (COPY) library.
In every table whose length must be the same as the number of sales offices, use a COPY statement; for example: 01 RENT RATE 01 EMPLOYEES 03 MANAGEMENT 03 ADMINISTRATIVE 03 SALES 03 SUPPORT 03 OTHER PICTURE 9(6) OCCURS COPY OFFICES. TIMES. OCCURS COPY OFFICES. TIMES. PICTURE 9(3). PICTURE 9(3). PICTURE 9(3). PICTURE 9(3). PICTURE 9(3). Each COPY statement ends with a period.
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==.
Example 235 Copying Into Debugging Lines Source line: D COPY DEB-DISP. Library lines: ?SECTION DEB-DISP DISPLAY KINGDOM PHYLUM CLASS ORDER FAMILY GENUS SPECIES. Compiled as: D D DISPLAY KINGDOM PHYLUM CLASS ORDER FAMILY GENUS SPECIES. Using Multiple COPY Libraries There is no limit to the number of COPY libraries the compiler can use in a single compilation. To specify a nondefault COPY library, use an OF or IN phrase in the COPY statement; for example: COPY RECORD1 OF LIBRARY3.
03 TITLE ?SECTION ADDRREC 01 ADDR-REC. 03 NUMBER 03 STREET 03 APT-NUM 03 CITY 03 STATE 03 ZIPCODE ?SECTION DATEREC 01 DATE-REC. 03 MONTH 03 DAY 03 YEAR PICTURE 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). PICTURE X(4). Line in HP COBOL source program: ?SOURCE SRCFILE Resulting source code: 01 01 01 NAME-REC. 03 LAST-NAME 03 M-I 03 FIRST-NAME 03 TITLE ADDR-REC.
==SQ-FT-SIZE== BY ==5== 01 OFFS. 03 OFFICE-INFO OCCURS OFFICES TIMES. 05 DISTRICT PICTURE 99. 05 SQUARE-FEET PICTURE S9(SQ-FT-SIZE) PROCEDURE DIVISION. PERFORM REPORT-OFFICE OFFICE TIMES. REPLACE OFF. DATA DIVISION. 01 OFFS. 03 OFFICE-INFO OCCURS 10 TIMES. 05 DISTRICT PICTURE 99. 05 SQUARE-FEET PICTURE S9(5) PROCEDURE DIVISION. PERFORM REPORT-OFFICE 10 TIMES.
77 AVG-MONTHLY-COST 77 AVG-ANNUAL-COST PIC S9(8).99. PIC S9(8).99. Compare the preceding example to the example in Replacing Substrings. 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 239, the compiler substitutes OFFICES for COPY OFFNUM and SQ-FT-SIZE for COPY AREA first and then substitutes 10 for OFFICES and 5 for SQ-FT-SIZE.
01 OFFS. 03 OFFICE-INFO OCCURS 10 TIMES. 05 DISTRICT PICTURE 99. 05 SQUARE-FEET PICTURE S9(5). Understanding and Controlling the Compiler Listing By default, the compiler produces a listing that includes: • Compilation Banner • Source Program Listing • Compilation Summary With compiler directives, you can include one or more of these in the compiler listing: • Symbol Table Listing • Symbolic Code Listing Compiler directives also allow you to suppress parts of the compiler listing (see Table 107).
Compilation Banner The ECOBOL compilation banner consists of this information: • Page number of compiler listing, date and time at which compilation began (line 1) • Version of the compiler (line 4) • Copyright information (line 5) • Directives included on compiler command line, if any (line 7) Example 241 ECOBOL Compilation Banner Page 1 2004 September 29, 12:14:31 COBOL - T0356H01 - (10SEP2004) (C)1997 Tandem (C)2003 Hewlett Packard Development Company, L.P.
• 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. Line Number When the file being listed is an EDIT file, the line number in the listing is the EDIT file line number. If the file is in ANSI format, the fractional part of the number, if any, is omitted.
Printed lines: MOVE ABLE TO X. If “ABLE” in the library line begins in column 22, you get: Printed lines: • MOVE ABLE TO X. 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.
?SECTION MOVE1,ANSI MOVE ABLE TO BAKER. ?SECTION MOVE2,HP MOVE ABLE TO BAKER.
For embedded SQL/MX statements, you always use the preprocessor to produce the object file (see the SQL/MX Programming Manual for C and COBOL). If you used the preprocessor, the SQL/MP or SQL/MX commands in your HP COBOL source program appear in the compiler listing in their processed form (that is, as SQL/MP or SQL/MX data structures, PERFORM statements, and calls to TAL routines).
Table 109 Compiler Directives That Produce Optional Warnings (continued) Directive Produces warnings for ... FIPS Statements as required by the Federal Information Processing Standard (FIPS) SUBSET HP extensions to ANSI COBOL and obsolete elements For more information about the directives in Table 109, see Compiler Directives (page 533). Compiler Error Messages An error message reports a serious violation of HP COBOL syntax or semantics.
The error file is not an EDIT file; it is of type 106. You can use it only with the TACL macro FIXERRS. For information about the FIXERRS macro, see FIXERRS Macro (page 700). In this example, the error file is ERRORS on the default volume and subvolume: 90> COBOL85 /IN XYZ, OUT $SPX/ XYZOBJ; ERRORFILE ERRORS 90> NM ECOBOL /IN XYZ, OUT $SPX/ XYZOBJ; ERRORFILE ERRORS If the file ERRORS does not exist, the compiler creates an entry-sequenced file of type 106 and names it ERRORS.
NOTE: In a symbolic code listing for a very large program, lines at the end of the program have asterisks in place of line numbers. Compilation Summary Example 248 Symbolic Code Listing COBOL - T0356H01 - (10SEP2004) (C)1997 Tandem (C)2003 Hewlett Packard Development Company, L.P. 2004 October 1, 17:22:28 Directives: -Woptimize=0 1. ?OPTIMIZE 0,INNERLIST 2. IDENTIFICATION DIVISION. 3. PROGRAM-ID. TESTT. 3. alloc r32=ar.pfs,0,17,8,0 3. add sp=-928,sp 3. nop 3. add r27=768,sp 3. stf.spill [r27]=f2,32 3.
3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3.
3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 14. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. add r41=32768,r0 and r42=r40,r41 nop cmp4.ne p8,p0=r42,r0 add r19=0,r0 (p8) add r19=1,r0 add r20=568,sp st8 [r20]=r19 nop nop nop (p8) br.cond.dpnt.many .
15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 15. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. nop mov r51=r40 mov r52=r41 add r20=584,sp nop st8 [r20]=r34 nop br.call.
16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16.
16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. 16. (p8) (p9) (p10) (p10) nop nop mov f20=f4 nop nop fcvt.fx.trunc.s1 f21=f20 nop nop xma.l f22=f7,f21,f0 nop getf.sig r41=f22 sub r42=r37,r41 nop mov r43=r42 cmp4.
16. 16. 16. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 17.
17. 17. 17. 17. 17. 17. 17. 17. 17. 17. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. mov r55=r42 mov r56=r43 nop br.call.sptk b0=COBLIB_DISPLAY_# add r20=496,sp ld8 r34=[r20] nop mov gp=r34 nop br.cond.sptk.many .b1_42 IF D = 1 THEN DISPLAY " MONDAY" ELSE .
18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 18. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. mov r54=r41 mov r55=r42 mov r56=r43 nop br.call.sptk b0=COBLIB_DISPLAY_# add r20=496,sp ld8 r34=[r20] nop mov gp=r34 nop br.cond.sptk.many .b1_42 IF D = 2 THEN DISPLAY " TUESDAY" ELSE .
19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 19. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. nop nop mov r52=r39 mov r53=r40 mov r54=r41 mov r55=r42 mov r56=r43 nop br.call.sptk b0=COBLIB_DISPLAY_# add r20=496,sp ld8 r34=[r20] nop mov gp=r34 nop br.cond.sptk.many .
20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. mov r50=r36 mov r51=r38 nop nop nop nop mov r52=r39 mov r53=r40 mov r54=r41 mov r55=r42 mov r56=r43 nop br.call.
21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 21. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. add r47=40,sp nop st8 [r47]=r0 mov r49=r35 mov r50=r36 mov r51=r38 nop nop nop nop mov r52=r39 mov r53=r40 mov r54=r41 mov r55=r42 mov r56=r43 nop br.call.
22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 22. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. st8 [r46]=r0 add r47=40,sp nop st8 [r47]=r0 mov r49=r35 mov r50=r36 mov r51=r38 nop nop nop nop mov r52=r39 mov r53=r40 mov r54=r41 mov r55=r42 mov r56=r43 nop br.call.
23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 23. 24. 25. 26. 27. 28. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 29. 30. 31. 31. 31. 31. 31. 31. 31. 31. 31.
31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. nop br.call.sptk b0=COBLIB_STOP_# add r20=496,sp ld8 r34=[r20] nop mov gp=r34 nop mov b0=r33 nop nop mov ar.pfs=r32 add r27=928,sp ldf.fill f22=[r27],-32 nop add r26=912,sp ldf.
31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31. 31.
Example 249 Compilation Summary COBOL - T0356H01 - (20DEC2004) No failures detected. No errors detected. No warnings reported. No remarks issued. Maximum symbol table size = 10884 bytes eld - TNS/E Native Mode Linker - T0608H01 - 03DEC07 Copyright 2004 Hewlett-Packard Company eld command line: \drp12.$system.system.eld -o RUNUNIT RUNUNIT \DRP12.$SYSTEM.ZDLL031.ZCOBDLL \DRP12.$SYSTEM.ZDLL031.ZCREDLL **** INFORMATIONAL MESSAGE **** [1019]: Using DLL \DRP12.$SYSTEM.ZDLL031.ZCOBDLL.
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 (page 712) and Utility Routines (page 724). An HP COBOL program that calls one or more non-COBOL routines is called a mixed-language program (as is a non-COBOL program that calls one or more COBOL programs).
The CALL statement can call another program statically (with the program specified at compilation time) or dynamically (with the program specified at run time). The former is more efficient; the latter is more flexible. The CALL statement can pass parameters from the calling program to the called program either by reference (the default) or by content.
Figure 32 Directly Contained Programs and Indirectly Contained 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 32 can call each other: Can call the program ... The program ...
Initial Programs If a program has the INITIAL clause in its Identification Division, it is an initial program. Its program state is initialized whenever it is called. The data in its Working-Storage Section is allocated when it is called rather than being statically allocated. For more information about initial programs, see Initial Programs (page 51).
Calling Non-COBOL Routines The way an HP COBOL program can call a non-COBOL routine depends on whether the calling program was compiled with the PORT directive. An HP COBOL program that was not compiled with the PORT directive calls a non-COBOL routine with the ENTER statement. An HP COBOL program that was compiled with the PORT directive calls a non-COBOL routine with either the ENTER statement or the CALL statement, which behaves like an X/Open CALL statement.
Functions (Routines That Return Values) A function is a routine that returns a value to the calling program. COBOL has no mechanism for returning a function’s value to the calling program, but HP COBOL has two: • GIVING Phrase • Special Register RETURN-CODE GIVING Phrase The GIVING phrase allows you to specify a data item, return-value, to hold the value that the function returns.
Parameters Guardian operating system routines are documented in the Guardian Procedure Calls Reference Manual. When calling system routines from an HP COBOL program, use Table 110 to determine the appropriate form for the COBOL parameters. 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.
Table 110 HP COBOL and pTAL Parameter Correspondence (continued) pTAL Data Type COBOL Data Category Passed by Reference Passed by Value Alphanumeric Edited STRING Not applicable Alphanumeric STRING Not applicable Resolution The compiler leaves operating system routines unresolved, and the loader resolves them during fixup (see Fixup (page 816)Fixup).
compiled with ECOBEX1 might execute only on the two most recent RVUs of the operating environment, and programs compiles with ECOBEXT might execute only on the three most recent RVUs of the operating environment. Your system manager must verify that the appropriate file has the name ECOBEXT when you compile your program. Any of the files ECOBEX0, ECOBEX1, or ECOBEXT can be named ECOBEXT.
HP C Routines An HP COBOL program must not call an HP C function that directly or indirectly accesses the HP C function getenv. An HP COBOL program indirectly calls HP C functions that allocate and deallocate memory and perform HP C input-output operations. Do not directly call the HP C function getenv from an HP COBOL program.
Example 251 HP COBOL and HP C Programs Sharing Data HP COBOL Code: * The SEARCH directive references the HP C object file. ?SYMBOLS; SEARCH SHOWEXTO IDENTIFICATION DIVISION. PROGRAM-ID. TEST-EXTERNAL. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. SYMBOLIC NULLCHAR IS 1. DATA DIVISION. EXTENDED-STORAGE SECTION. 01 MYVAR EXTERNAL. 05 DATA-01 PIC X(20). 05 NULL-TERM PIC X. PROCEDURE DIVISION. STARTIT. MOVE "abcdefghijlmnopqrstu" TO DATA-01. MOVE NULLCHAR TO NULL-TERM. ENTER C "SHOWEXT".
• What HP COBOL Can Pass by Value. • Passing Parameters to COBOL Programs • Passing Parameters to Non-COBOL Routines Addressing Modes Native programs use 32-bit addressing for all data items. Many HP COBOL items are byte-addressed. Some data items in other languages are 2-byte addressed.
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 252, you must pass the name C-ARRAY. Example 252 Record Containing a Table 01 A-RECORD. 03 A PIC S999V99. 03 B PIC S999V99. 03 C-ARRAY. 05 C OCCURS 7 TIMES USAGE NATIVE-2. 03 D PIC X(15).
Some values on NonStop systems that fit into an HP COBOL data item described as PICTURE S9(n -s)V9(s ) COMPUTATIONAL exceed HP COBOL’s limits. More importantly, HP COBOL generates computational code based on the descriptions of data items, so if an external routine installs a value in a PICTURE S9(n -s )V9(s ) COMPUTATIONAL field that HP COBOL could not have stored, the computational results could be invalid. Records HP COBOL programs must pass record parameters by reference.
Enabling HP COBOL to obtain a numeric value from a single byte requires a work-around in the HP COBOL program. In your HP COBOL program, define a corresponding parameter and a temporary storage area, as in Example 253. Example 253 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.
Topics: • HP C or HP C++ • pTAL HP C or HP C++ • An HP COBOL program can pass numeric arguments to an HP C or HP C++ routine either by reference or by value. • An HP COBOL program must pass nonnumeric arguments to an HP C or HP C++ routine by reference. • If the data type of a value parameter differs from the data type of the corresponding formal parameter, the compiler converts the value of the value parameter to the data type of the formal parameter.
01 FLIP USAGE IS NATIVE-2 EXTERNAL. 01 FLAP USAGE IS NATIVE-4 EXTERNAL. 01 FLOP USAGE IS NATIVE-8 EXTERNAL. C code: extern short FLIP; extern long FLAP; extern long long FLOP; FLOP = (long long)((long)FLIP * FLAP); Example 256 Passing a String to a C Routine HP COBOL code: DATA DIVISION. WORKING-STORAGE SECTION. 01 A-STRING PICTURE X(25). ... PROCEDURE DIVISION. ... ENTER C "FUNCT1" USING A-STRING C routine: FUNCT1 (char *d) ...
a^proc (a^string:length) string .ext a^string int length; An HP COBOL program that calls a pTAL routine that has a string :length parameter only passes one parameter, the string part. The compiler computes the length of the string and passes it to the pTAL routine. For example, suppose that your HP COBOL program calls the pTAL routine FILE_GETINFOBYNAME_, which has the parameter file-name :maxlen. To have your HP COBOL program pass the entire item, you can use this code: 01 A-FILENAME PIC X(20) ...
24 Issues Related to Linking NOTE: Most of this section applies to the Guardian environment. If you are binding HP COBOL programs in the OSS environment, see Chapter 19: Using HP COBOL in the OSS Environment (page 711) and Mixed-Language Programs (page 712).
Figure 33 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.
Figure 34 Internal and External References 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.
• If the compiler does not find the routine on the primary search list, it searches for the routine in the files on the tertiary search list if one exists. (One or more CONSULT directives build the tertiary search list; see Putting an Object File on the Tertiary Search List (page 818).) • If the compiler does not find the routine in a file on the tertiary search list, it searches for the routine in the file ECOBEXT, ZCOBDLL, and ZCREDLL.
warning messages, but are allowed. They are expected to be resolved by the fixup operation of the system loader. If the compiler cannot resolve an external reference to a non-COBOL routine, it must at least be able to validate it. When the compiler processes a CALL statement that calls another COBOL program, but cannot find the other COBOL program, it delivers a warning message and produces an object file.
Topics: • Linking Automatically (page 817) • Linking Programs to Be Called Dynamically (page 818) Linking Automatically If you specify the RUNNABLE directive, the compiler automatically links the program, interacting with the eld utility. For simplicity, this explanation attributes actions of internal processes and the eld utility to the compiler.
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 compiler finds the routine, it validates the routine’s actual parameters and includes the entire object file (from the primary search list) in the object file that it is creating.
At run time, if identifier specifies the name of a program that is unavailable, the run-time routines raise an exception. 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.
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 (page 712). After you have compiled and bound your program, you can execute and, if necessary, debug it.
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 258 DEFINE Names =NEWFILE =FILE25 =TAPE-FILE =FTEST_RESULTS =JEFFS^FILE DEFINE Attributes Every DEFINE has a CLASS attribute, which determines its other attributes.
• A file code • An exclusion mode (EXCLUSIVE, SHARED, or PROTECTED) for reading and writing (but it does not override any exclusion mode that the program explicitly specifies) The ASSIGN command Example 259 specifies that the file that the program calls NEWFILE has the system file name \AKRON.$SLB.MAJ.NEWFILE, is allocated five file pages, is an EDIT file (type 101), and EXCLUSIVE exclusion mode (unless the OPEN statement that opens the file specifies a different exclusion mode).
(see Adding DEFINEs). If default input-output device is an asterisk, all run-time messages are discarded. 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.
ADD DEFINE =BIGCUST, FILE \AKRON.$SLB.MAJ.ACC ASSIGN PROG1.NEWFILE,& \AKRON.$SLB.MAJ.NEWFILE,& EXT 5, CODE 101, EXCLUSIVE PARAM NONSTOP OFF PARAM INSPECT ON PARAM EXECUTION-LOG \AKRON.$SLB.MAJ.ERRMSG PARAM PRINTER-CONTROL THE-PRINTER PARAM SWITCH-1 ON, SWITCH-2 ON Then you can execute all of the preceding commands with the single command: OBEY PREP1 Suppose that you occasionally want to execute PROG1 with the file \NICE.$FRNC.SIGNIF.CUST in place of the file \AKRON.$SLB.MAJ.
SHOW DEFINE FILE SHOW DEFINE * To find out what ASSIGN commands are active, give the ASSIGN command with no parameters: ASSIGN To find out what PARAM commands are active, give the PARAM command with no parameters: PARAM 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 com
#SET #PMSEARCHLIST #DEFAULTS $VOLUME.SUBVOL $SYSTEM.SYSTEM Then you can start the program whose file ID is $VOLUME.SUBVOL.
If the suspended Pathway server’s requester is also suspended, the performance of the Pathway application is degraded. If your program has the previously described problem, specify a different home terminal for your ECOBOL process with the TERM option of the RUN command. Verify that the new home terminal is available. 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.
Running the New Process in the Background By default, your TACL process suspends itself while your HP COBOL program executes. You can prevent this by running your program in the background with the NOWAIT option of the RUN command. Beware of using the NOWAIT option if your program has ACCEPT and DISPLAY statements that use the home terminal. With NOWAIT, your HP COBOL program cannot accept input from, or display output to, the home terminal until you pause the terminal.
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 Chapter 15: Debugging Tools (page 699).
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.
Other rules depend on the category of the system file name. The categories are: • Permanent Disk File Names • Temporary Disk File Names • Nondisk File (Device) Names For information about process file names, see Processes Handled as Files. Permanent Disk File Names Permanent disk files are named when they are created. After being created, a permanent disk file remains on the disk until explicitly purged.
Nondisk File (Device) Names Nondisk files are devices such as terminals, printers, magnetic tape drives, and data communications lines. A nondisk file can be accessed by its name (the recommended method) or its logical device number, both of which are assigned by system management. 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 260 COBOL File Names MAJRACCT MAJOR-ACCOUNT MajorAccount-3 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 • Nonnumeric and National Literals If you want to associate the COBOL file name with a system file name at run time, see #DYNAMIC.
(page 821)). The new system-file-name in the overriding ASSIGN command can also be a special name—any special name except #DYNAMIC. #IN In the Guardian environment, #IN represents the file specified as the IN parameter in the startup message of the current process. If you started the current process from a TACL prompt, #IN refers to the file specified by the IN option of the RUN command (or its default). (See Specifying Default Input and Output Devices (page 826).
PROG1 /TERM $TE1.#E02/ #TEMP The special name #TEMP represents a temporary disk file on the default volume (which is specified by the program’s startup message). 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.
DEFINE Name NOTE: This topic applies only to the Guardian file system. DEFINEs do not accept OSS pathnames. If the file-control entry assigns the COBOL file name (the file-name in the SELECT clause) with a DEFINE name (the define-name-literal in the ASSIGN clause), then you must associate the DEFINE name with a system file name before executing the program (see Adding DEFINEs (page 820)).
The MESSAGE SOURCE clause provides a mechanism through which a COBOL program can discover the sender of each message received. During the successful execution of a read operation on $RECEIVE, the $RECEIVE mechanism places a set of values into the storage space designated in the MESSAGE SOURCE clause. Example 261 MESSAGE SOURCE Format 01 SOURCE-MESSAGE. 05 SYSTEM-FLAG 05 ENTRY-NUMBER 05 05 05 FILLER PHANDLE FILLER PICTURE USAGE IS PICTURE USAGE IS PICTURE PICTURE PICTURE S9 COMPUTATIONAL.
27 Tape Input and Output HP COBOL batch programs must often read or write files that are on magnetic tape (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. To restore archived disk files from a tape back to a disk (which you must do before an HP COBOL program can read them), use the operating environment’s RESTORE utility.
• When the block size is specified in characters, it is a multiple of the number of characters in the logical record size. Also, when a RECORD CONTAINS clause extends the record size, the block size expressed is a multiple of the number of characters in that specified record size. • The file description entry does not have a LINAGE or ALTERNATE RECORD KEY clause. On NonStop systems, physical record (block) sizes for tapes range from 24 through 32,767 bytes.
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. Use a LOCK phrase if the file was not dynamically assigned and you want to prevent the tape from being reopened (the run-time tape routine ignores LOCK for a dynamically assigned file).
WRITE TAPE1 ... CLOSE TAPE1 NO REWIND *WRITE SECOND FILE OPEN OUTPUT TAPE1 EXCLUSIVE NO REWIND WRITE TAPE1 ... CLOSE TAPE1 LOCK ... 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).
Example 265 Multitape File ... ENVIRONMENT DIVISION. ... INPUT-OUTPUT SECTION. ... FILE-CONTROL SELECT HUGEFILE ASSIGN $DRIVE2 ORGANIZATION SEQUENTIAL ACCESS MODE SEQUENTIAL. ... PROCEDURE DIVISION. ... OPEN INPUT HUGEFILE EXCLUSIVE. *READ FIRST TAPE READ HUGEFILE... CLOSE HUGEFILE REEL FOR REMOVAL. *READ SECOND TAPE READ HUGEFILE... CLOSE HUGEFILE REEL FOR REMOVAL. *READ THIRD TAPE READ HUGEFILE... CLOSE HUGEFILE LOCK. ...
Figure 36 Software Involved in Labeled-Tape Processing To use a labeled tape file with an HP COBOL program, you must: 1. Describe the labeled tape file in a file-control entry in the HP COBOL program, assigning the file’s COBOL file name to a DEFINE name. 2. Enable the creation of DEFINEs with the TACL command SET DEFMODE ON. 3. Add a DEFINE that has the name assigned to the file in Step 1 and the appropriate attributes (see Adding DEFINEs for Tape Files). 4.
ACCESS MODE SEQUENTIAL. ... DATA DIVISION. FILE SECTION. FD SEQ-FILE RECORD CONTAINS 30 CHARACTERS 01 SEQ-RECORD PIC X(30). ...
ACCESS MODE SEQUENTIAL FILE STATUS IS STATUS-KEY. ... HP COBOL file description entry for a tape file: FD MONTHLY-SALES RECORD CONTAINS 80 CHARACTERS LABEL RECORDS ARE OMITTED.
Example 270 Copying an EBCDIC File to an Existing ASCII File FUP CREATE $TEN.APP3.PQ5, TYPE E, & EXT (1000 RECS,1000 RECS), REC 80 The preceding discussion does not completely explain FUP. There are many considerations involved in choosing parameters for the COPY and CREATE commands. For details, see the Guardian Programmer’s Guide. CAUTION: The EBCDIC-to-ASCII conversion mechanism described in this topic handles data of the type DISPLAY, but not data of the type COMPUTATIONAL.
• Data Description Binary Value Stored PIC S99 SIGN TRAILING VALUE 5 00110000 00110101 PIC S99 SIGN TRAILING VALUE -5 00110000 10110101 PIC S99 SIGN TRAILING VALUE 0 00000000 00000000 NATIVE-n HP COBOL stores a NATIVE-n data item as a signed, numeric, twos-complement, binary integer.
• 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. The CLASS attribute must be the first attribute in the ADD DEFINE command, because it determines what other attributes the DEFINE can have and clears any existing attribute settings, including any that precede it in the ADD DEFINE command.
Table 114 Correspondence Between RECORD CONTAINS Clause and RECFORM Attribute Value Record Length RECORD CONTAINS Clause RECFORM Attribute Value Variable (undefined) RECORD CONTAINS min-length TO max-length CHARACTERS U Fixed RECORD CONTAINS length-fixed F CHARACTERS 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 ov
Figure 37 DEFINE Names and COBOL File Names CLASS Attribute (Required) The value of the CLASS attribute must be TAPE. The CLASS attribute must be the first attribute in the ADD DEFINE command, because it determines what other attributes the DEFINE can have and clears any existing attribute settings, including any that precede it in the ADD DEFINE command.
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. • The HP COBOL program does its own label processing. The LABELS attribute of the DEFINE overrides any LABEL RECORDS clause in your HP COBOL program.
DEVICE Attribute (Conditional) The DEVICE attribute is required if you are bypassing labels (the value of the LABELS attribute is BYPASS); otherwise, it is optional. When the DEVICE attribute is required, its value must be the system file name of a tape drive. When the DEVICE attribute is optional, its value overrides the system’s automatic volume recognition. You cannot specify a different device in response to the system mount message.
The value of the RETENTION or EXPIRATION attribute is an integer, the number of days before the file expires. CAUTION: On a multiple-file volume, the operating environment might overwrite an unexpired file that follows an expired one; a volume on which the first file has expired is a scratch volume. Example 273 adds a DEFINE for a labeled tape file with variable-length records whose labels are to be bypassed. The file is on the tape on the tape drive named $DRIVE.
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.
Input-output errors that are not specific to tape files can also occur. For a complete list of HP COBOL run-time errors and suggestions for recovering from them, see Chapter 48: Run-Time Diagnostic Messages (page 1178).
28 Disk Input and Output Both batch programs and transaction-supporting servers use disk files. Common Disk File Topics 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.
2. After setting the CLEARONPURGE flag, call the PURGE routine (directly or through FUP). The CLEARONPURGE flag has no effect on the outcome of a PURGEDATA operation performed through FUP or through the CONTROL routine. Locking An HP COBOL program can lock and unlock an entire file with the LOCKFILE and UNLOCKFILE statements. Batch programs lock entire files more often than transaction processing programs do.
To display a file’s current security attributes, use the FUP INFO command. To alter a file’s security from an HP COBOL program, call the routine COBOL_SETMODE_ (page 634). Suppose that your HP system is part of an Expand network and you own the disk file FILE3. The command in Table 120 prevents everyone but you from reading, writing, executing, or purging FILE3, but you can only read, write, execute, or purge the file on your local system.
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. The TACL command REMOTEPASSWORD enables you to set the remote passwords on your own node. You must arrange with the system manager of the other node to have the same two passwords established on that node. For further information about remote passwords, see the Guardian User’s Guide.
Time Limits If you include a TIME LIMITS phrase in an OPEN statement, you can then include a TIME LIMIT phrase in a LOCKFILE, READ, or START statement to cause the statement to be abandoned if it does not finish executing in a certain amount of time. The TIME LIMIT phrase in a LOCKFILE, READ, or START statement sets the file’s status code so that the requester can tell that the data is not currently accessible. This action helps avoid deadlock.
Modification With the ENABLE utility, you can build a file-maintenance application that allows you to modify a disk file. ENABLE uses a Data Definition Language (DDL) file description to create a Pathway application that you can use to read and change the data in the disk file. For details, see the ENABLE User’s Guide. Maximum Number of Files The maximum number of files on a volume is determined during system configuration.
Table 122 Corresponding HP and HP COBOL Disk File Terms HP Term HP COBOL Term Relative Relative Entry-sequenced Sequential Key-sequenced Indexed The HP COBOL run-time routines that access structured disk files (entry-sequenced, relative, and key-sequenced) do so with the help of the operating system routines that are collectively called the Enscribe database record manager.
the DEPENDING phrase when reading variable-length records, and to process zero-length records appropriately (by ignoring them, for example). Under Enscribe, entry-sequenced files can have alternate keys. You must create these files by calling Enscribe directly in one of these ways: • From your TACL session, use FUP. • From within an HP COBOL program, call the FILE_CREATE_ procedure.
any length up to the limit, or variable-length records of any length up to the limit. If HP COBOL creates the file for you, that limit is the larger of: • The length of the longest record description entry for the file • The maximum record length explicitly stated in the RECORD clause of the file description entry for the file If a relative file has alternate keys, you can use a START statement not only to specify the next record to read, but also to change the key of reference.
HP COBOL programs can create, read, write, and purge all of the preceding forms of sequential file. To create an entry-sequenced file that has alternate keys, however, the COBOL program must use the FILE_CREATE_ procedure (see Unstructured Files). Entry-Sequenced Files An HP COBOL program can create and write an entry-sequenced file that any other HP product can later read. An HP COBOL program can read an entry-sequenced file created by any HP product.
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.
FD RELFILE RECORD CONTAINS 5 TO 200 CHARACTERS LABEL RECORDS ARE OMITTED. REL-RECORD. 01 ... WORKING-STORAGE SECTION. ... 01 KEYS-GROUP. 03 FIDLKEY PIC 9(8) COMPUTATIONAL. These FUP commands declare the same relative file as the HP COBOL code in Example 282: SET TYPE R SET EXT (1000 RECS, 2000 RECS) SET REC 200 SET BLOCK 2048 CREATE $FIDDL.DEE.
SET TYPE K SET EXT (1000 RECS, 2000 RECS) SET REC 200 SET BLOCK 2048 CREATE $COBOL.PROGS.JAKE 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.
Writing to a Queue File To write to a queue file, be sure that it exists and then open it for input and output; for example: OPEN queue-file I-O SHARED SYNCDEPTH 0 In the file-control entry, specify ACCESS MODE IS RANDOM. After the file is open, use any form of the WRITE statement to write to it. The value that you write to the timestamp field does not matter, because the system replaces that value with its own timestamp.
in any structured (sequential) file in ascending alternate-key order. You can also execute sequential READ REVERSED statements to read records in reverse order. The key-of-reference concept enables you to select one of several possible keys and then use a single sequential READ statement to read a subset of records in a file. Suppose that you have the personnel record in Example 285, and that the employee number (which is not even part of the record) is the record number and therefore the prime key.
If you have a structured file without alternate keys and you want it to have alternate keys, you can use FUP to create the alternate-key file and to load the alternate-key file. If you describe your database with DDL, the DDL compiler can produce the necessary FUP commands to create prime-key and alternate-key files. For more information about alternate keys, see the Guardian Programmer’s Guide.
the five characters “Adams,” the statement must raise the EOF condition and not deliver that record to the program. You usually use generic positioning with partial keys. Using key values that include trailing spaces, you can achieve an effect similar (but not identical) to exact positioning. Consider the case of “Adams.” If you want to find only the Adamses (but not any Adamsons), you can use a complete key of “Adams” plus enough spaces to fill out the key.
54116 54396 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 With the GENERIC phrase, if the first key specifies that its first five characters must be “ADAMS,” the program displays: 00005---ADAMS 01010---ADAMS 54116---ADAMS-JONES 00010---ADAMSKI 54396---ADAMSSOHN 99999-----E
useful for servers. The server need only be implemented with a continuation request and can depend on the requester to supply LOW-VALUES (or 1) for the prime key in the initial request. Example 287 is a skeleton program for a server. It accepts several types of request, one of which calls for a list of part records (beginning at a specified part name) to be returned to the requester.
03 ERROR-TEXT PIC X(65). PART-GET-REPLY. 02 PRT-HEADER. 03 REPLY-CODE PIC S9(4) COMP. ... {same as PRT-HEADER of PART-DEL-GET-LIST-MSG } 02 PART-DATA. 03 PART. 04 PART-NO PIC X(10). 04 PART-NAME PIC X(50). ... 1 PART-LIST-REPLY. 02 PRT-HEADER. 03 REPLY-CODE PIC S9(4) COMP. ... {same as PRT-HEADER of PART-DEL-GET-LIST-MSG } 02 LINE-COUNT PIC 9(04). 02 ALL-PART-LINES. 03 PART-LINE OCCURS 10 TIMES. 04 PART-NO PIC X(10). 04 PART-NAME PIC X(50). 04 CUST-NUM PIC 9(06). ...
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. MOVE PRT-HEADER OF PART-DEL-GET-LIST-MSG TO PRT-HEADER OF SERVER-REPLY. MOVE ZERO TO REPLY-CODE OF PART-LIST-REPLY LINE-COUNT OF PART-LIST-REPLY MOVE SPACES TO ALL-PART-LINES OF PART-LIST-REPLY. 220-BUILD-REPLY. MOVE PART-NO OF PART-DEL-GET-LIST-MSG TO PART-NO OF PART-DATA-RECORD.
These topics explain how to use these types of files to optimize disk file processing: • Unstructured Files • Structured Files • Files With Alternate Keys • Partitioned Files Unstructured Files A process can read and write unstructured files faster than it can read structured files, whether the logical records of the unstructured file are blocked or not. A process can read and write blocked unstructured files considerably faster than it can read and write unblocked unstructured 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.
HP COBOL Fast I-O Fast I-O is an HP COBOL enhancement in input-output performance beyond that of sequential block buffering or buffered cache. With HP COBOL Fast I-O, the HP COBOL run-time routines use an auxiliary block buffer and perform the blocking and deblocking in local storage. This process operates 2 or 3 times faster than when the operating environment performs the blocking and deblocking operations.
Files With Alternate Keys You can improve the performance of alternate-key file access by: • Declaring Null Values for Alternate Keys • Making the Main File Entry-Sequenced or Relative • Not Updating the Alternate-Key File Automatically 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.
You can divide an indexed file according to the value of the prime key and have, for example, A through C on the first disk volume and U through Z on the last disk volume. If one of the disks is taken offline for maintenance, or if one system of the network is inaccessible due to communication problems, the remainder of the partitioned file is still accessible. To open a partitioned file when some partitions cannot be accessed, an HP COBOL program must use the routine COBOL_SPECIAL_OPEN_.
Another alternative is shared access. When a process opens a file for shared access (opens it with the exclusion mode SHARED), other processes can read and write the file while the opening process has it open. When a file is open for shared access and one process needs exclusive access to the file temporarily, that process can lock the file with a LOCKFILE statement, operate on it, and then unlock it with an UNLOCKFILE statement.
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. The program could retry a certain number of times, or (if it is a server) report back to its requester that the read operation could not be completed, which is another way to handle a file that might be locked at the file or record level.
Many Enscribe routines require file numbers instead of file names. Each of these routines returns a file number: • HP COBOL routine COBOLFILEINFO or COBOL_FILE_INFO_ • Enscribe routine FILE_GETINFO_ Each of the preceding routines can return other file attributes in addition to the file number; use the routine best suited to your needs.
The FILE_PURGE_ procedure accepts the internal form of a file name as a parameter. To determine whether the purge operation was successful, call the HP COBOL routine COBOLFILEINFO with the file name as its parameter. COBOLFILEINFO returns an error value. If the purge operation was successful, the error value is zero. One common reason for a purge operation to fail is that the process’s accessor ID was not authorized to purge the file according to the security attributes of the file.
when you have finished working with it, because merely purging the file does not erase the data from the disk. The HP COBOL library routine COBOL_CONTROL_ is a multipurpose routine that calls the operating system routine CONTROL, and whose function is determined by an operation code. The operation code 20 enables a process to purge only the contents of a file if the process has write access to the file.
02 02 rw-flag PIC X(4). T-rec-no PIC 999. ... 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. NATIVE-2. PIC X(128) VALUE "ISFILE".
MOVE FUNCTION LENGTH (Values-array) TO Values-length * Create the primary file ENTER "FILE_CREATELIST_" USING File-name, File-name-len, Item-list, Number-of-items, Values-array, Values-length, Error-item GIVING Create-error IF Create-error NOT = 0 DISPLAY "Creation failed with error ", Create-error, " in parameter " Error-item STOP RUN END-IF * Create the alternate key file * The key length has to be 2 greater than the real one COMPUTE Akf-key-len = 2 + A-Key-len * The record length has to be 5 greater than
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 input-output. On an HP system, a typical application uses Pathway/TS to write requester programs in SCREEN COBOL to handle terminal input and output and uses HP COBOL or pTAL server programs to handle database input and output. Occasionally, an HP COBOL process must communicate with a terminal directly.
Example 290 shows the use of ACCEPT and DISPLAY statements with the IN file and the OUT file and with a terminal that is known to the file system as $TRM053. Example 290 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.
statement to receive a record of exactly the length declared (explicitly or implicitly) in the file description, and they raise a run-time error if too short a record is typed at the terminal. If a record of more than the declared number of characters is typed at the terminal, the run-time routine does not deliver the excess characters to the process. When an HP COBOL process opens a file assigned to a terminal, it establishes communication with that terminal.
HIT-EOF. STOP RUN. 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.
MOVE "So what?" TO A-TEXT-RECORD. Deliver response. WRITE A-TEXT-RECORD. * Loop. GO TO B. HIT-EOF. STOP RUN. * Sharing a Terminal For development, you normally use a terminal that is associated during system generation with a command interpreter (such as TACL). That command interpreter uses your terminal as its IN file, its OUT file, and its home terminal. Most terminals on a production system do not have command interpreters associated with them.
unless another process explicitly obtains ownership of Break from the operating environment.
ENTER "COBOL_SETMODE_ " USING FILE-NUMBER, 11, PREV-OWNER, PREV-ACCESS-MODE. Communicating With an Operator or Process A running HP COBOL program can use the DISPLAY statement to write to the operator console (a write-only device). Likewise, a running HP COBOL program can use the DISPLAY statement to write characters to any terminal or printer and can use the ACCEPT statement to read characters from any terminal or process.
cannot be a data item; therefore, if you have a message that must be displayed on several devices, you need one DISPLAY statement for each device. Writing to a Terminal or Printer When a process includes code from an HP COBOL program having a DISPLAY statement without a mnemonic name attached, the process delivers characters to its OUT file.
Example 295 Reading and Writing Numeric Data IDENTIFICATION DIVISION. PROGRAM-ID. FRIENDLY-ACCEPT. AUTHOR. KIT COBOL. INSTALLATION. TRANSACTIONS ANONYMOUS. DATE-WRITTEN. 29 FEBRUARY 1984. DATE-COMPILED. ****************************************************** * This program shows the flexibility of the ACCEPT * * statement. * ****************************************************** ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP TXP. OBJECT-COMPUTER. HP TXP. SPECIAL-NAMES. DATA DIVISION.
If you use the WRITE statement to send messages to the console, and therefore to the standard log file terminal, you can determine the assignment between the file and the device in any one of these ways: • During program compilation, through the SELECT clause of the FILE-CONTROL paragraph • Before program execution, through the ASSIGN or ADD DEFINE command • During program execution, with the COBOL_ASSIGN_ routine.
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.
• SPOOLCOM • PERUSE The two spooler components that you are most likely to use are SPOOLCOM and PERUSE. Unlike the supervisor, collectors, and print processes that run continuously and are named processes, SPOOLCOM and PERUSE are processes you start when you need one and they usually are not named. Both interact with the supervisor. Supervisor Process The supervisor process communicates with and monitors the other processes and decides when and where to print output.
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. When an application program opens the spooler collector for output, the created job is marked as owned by the user number of the application program.
If you do not specify a location, the spooler uses the location #DEFAULT. Each installation determines for itself the identity of the device or devices that compose the default group. State A job is always in one of four states: State Meaning OPEN A process is writing to the collector. READY The originating process has closed its file and the job is ready to be printed, but the device on which it is to print is not currently available or its location is not associated with a device.
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. When both the location and form name of a spooler job match the location and form name of the device, the spooler prints the job.
Example 296 Level-1 Spooling SELECT SPOOLER-FILE ASSIGN TO "$S.#MYSTUF" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL.... FD SPOOLER-FILE RECORD CONTAINS 80 TO 132 CHARACTERS LABEL RECORDS ARE OMITTED. 01 SPOOLER-SHORT-LINE PIC X(80). 01 SPOOLER-LONG-LINE PIC X(132).... PROCEDURE DIVISION.... OPEN OUTPUT SPOOLER-FILE... WRITE SPOOLER-SHORT-LINE...
Example 297 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. 01 LOCATION-NAME PIC X(16) VALUE "#MYSTUF". 01 REPORT-NAME PIC X(16) VALUE "PRIVATE PROPERTY". * Flag for HOLDAFTER (32), PRIORITY 2 (+2 = 34) 01 FLAGS PIC S9(4) VALUE 34.
Table 125 Guardian Environment Routines for Level 3 Spooling (continued) Routine Action horizontal pitch, prespacing or post-spacing, get device status, or reset to configured values SPOOLSTART Establishes the level-3 buffer, location name, form name, report name, number of copies, page size, and attributes such as HOLD and PRIORITY SPOOLWRITE Writes text to the spooler For information about these routines, see the Spooler Programmer’s Guide.
The current job is undefined when you first start the spooler and after a DELETE command executes. To define the current job, use the JOB command.
Here are some examples of spooler commands that involve the current job and the current position. Suppose you have just started the spooler. The spooler always begins by listing all jobs in its queues that belong to you.
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. The main value of SPOOLCOM is that it shows you the date each job was created, and it also enables you to perform operations on groups of jobs. SPOOLCOM is intended primarily for system operators (members of the super group). These users have privileged access to the system.
1595 1671 1672 1737 1739 1779 2423 READY HOLD PRINT READY HOLD HOLD READY 4 4 4 4 4 4 4 A A A A 5,40 5,40 5,40 5,40 5,40 5,40 5,40 01/20 12/15 12/15 01/28 01/11 01/28 01/20 1 1 1 1 1 1 1 59 1 1 8 1 1 4 DEVELOP DEVELOP DEVELOP DEVELOP DEVELOP DEVELOP DEVELOP QUINN QUINN QUINN QUINN QUINN QUINN QUINN #ANON #LP3 #LP3 #ANON #HT #HT #MURPHY This is much like the report that PERUSE gives you at the beginning of its execution, except that you have to ask for jobs belonging to user 5,40, or SPOOLCOM lis
Suppose you have a 100-page report in the spooler and you want to print its last 3 pages on $LP1. First, use either PERUSE or the SPOOLCOM JOB command to get the job printing on $LP1. Then use this form of the DEV command: DEV $LP1, SKIPTO 98 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.
Skipping to a Printer Control Tape Channel Punch If you are writing to a printer that has a VFU control feature, handled either by punched paper tape or an electronic equivalent, you can specify that the printer is to advance to a certain vertical position before (or after) the record delivered by the WRITE statement is written on the paper.
A standard 11-inch page printed at 6 lines per inch can accommodate 66 lines. You could establish 3 blank lines at the top, 3 blank lines at the bottom, and 60 lines of body between them. If you establish a footing line at 55, then the end-of-page condition arises after line 54 is written.
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. This association is established at compilation time. Each DISPLAY statement transmits characters to a single device—there is no mechanism for changing the destination of a DISPLAY statement.
31 Process Initiation, Communication, and Management On a NonStop system, a process is a running program.
Memory and Virtual Memory Memory is one resource consumed by a process. Each processor in an HP system has its own physical memory. Each processor in a system can have one to four increments of memory, and different processors in the same system can have different amounts of memory. The size of the increments depends on the type of processor—see the system description manual for your processor. The operating environment allows several processes to occupy different areas of physical memory concurrently.
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). The sending process opens a file having the same name as the receiving process (using an OPEN statement).
READ TRANSACTIONS RECORD WITH PROMPT TRAN-REQUEST... Example 301 Server Code ... SELECT TASKS-IN ASSIGN TO "$RECEIVE" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL. SELECT RESPONSE-OUT ASSIGN TO "$RECEIVE" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL. 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.
$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 41 $RECEIVE as Input/Output File The requesting process follows the outline in Example 302. Example 302 Requester Code ... SELECT TRANSACTIONS ASSIGN TO "$BAL" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL. FD 01 ...
TABLE OCCURS 20 TIMES SYNCDEPTH LIMIT IS 1 REPLY CONTAINS 8 CHARACTERS.... DATA DIVISION. ... FD TASKS-IN LABEL RECORDS ARE OMITTED RECORD CONTAINS 1 TO 8 CHARACTERS. 01 TRAN-REQUEST. 05 TRAN-CODE PICTURE 9. 88 TRAN-PMT VALUE IS 1. ... 05 ACCOUNT-NUMBER PICTURE 9(6). ... 01 TRAN-RESPONSE. 05 RESULT-CODE PICTURE 9. 88 RESULT-OK VALUE IS 1. 88 RESULT-ERROR VALUE IS 2.... 05 NEW-BALANCE PICTURE 9(7).... PROCEDURE DIVISION.... OPEN I-O TASKS-IN.... READ TASKS-IN. IF TRAN-PMT PERFORM ...
Example 304 Report Produced by PPD Command NAME $Z000 $CRT2 $NULL $CMON $IMON $DM00 $DM01 ... PID1 00,022 00,021 07,004 07,005 00,031 00,032 01,024 PID2 01,021 01,022 00,024 00,026 01,025 ANCESTOR 00,021 $Z000 00,025 00,025 06,010 $IMON $IMON The report in Example 304 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.
DATE-WRITTEN. 29 FEBRUARY 1988. DATE-COMPILED. ************************************************************* * This program illustrates the transmission of messages to * * another COBOL program, CATCHER, whose process name is * * $CATCH. * * * * Records entered at this process's home terminal are sent * * $CATCH. * ************************************************************* ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP TXP. OBJECT-COMPUTER. HP TXP. INPUT-OUTPUT SECTION. FILE-CONTROL.
INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT PRINT-LINES-IN ASSIGN TO "$RECEIVE" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS PRINT-STATUS. DATA DIVISION. FILE SECTION. FD PRINT-LINES-IN LABEL RECORDS ARE OMITTED. 01 LINE-IN PICTURE X(80). WORKING-STORAGE SECTION. 01 PRINT-STATUS PICTURE X(2). 88 SENDER-DISAPPEARED VALUE "10". PROCEDURE DIVISION. A. OPEN INPUT PRINT-LINES-IN. PERFORM TRANSPUT THROUGH END-TRANS UNTIL SENDER-DISAPPEARED. STOP RUN. TRANSPUT.
NOTE: If the process is running at a high PIN, the process ID that the operating environment returns is synthetic. For information about synthetic IDs of high-PIN processes, see the Guardian Application Conversion Guide. • It specifies which classes of operating environment messages are to be passed to process $XX. An ordinary Pathway server uses only three entries of the RECEIVE-CONTROL paragraph: • TABLE OCCURS Specifies how many requesters can have the server open at one time.
• 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. • A program can use $RECEIVE whether or not the program runs as a process pair.
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. * Up to five requesters can have this server open TABLE OCCURS 5 TIMES SYNCDEPTH LIMIT IS 1 REPLY CONTAINS MESSAGE-OUT RECORD. DATA DIVISION. FILE SECTION.
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. VALUE IS "10". PIC X. PIC X. PIC X. PIC X. VALUE IS ZEROS. PROCEDURE DIVISION. DECLARATIVES.
PHONE-BOOK. B-TRANS. READ MESSAGE-IN. * Declarative handles EOF IF RECEIVE-FILE-STATUS = "00" IF NAME-LOOKUP OF MESSAGE-IN PERFORM B-01-NAME-LOOKUP-PROC ELSE IF PHONE-LOOKUP OF MESSAGE-IN PERFORM B-01-PHONE-LOOKUP-PROC ELSE MOVE SPACES TO PHONE-REPLY-MSG MOVE BAD-REQUEST-REPLY TO BAD-REPLY-CODE OF MESSAGE-OUT ... IF RECEIVE-FILE-STATUS = "00" WRITE PHONE-REPLY-MSG ELSE WRITE BAD-REPLY-MSG. B-01-NAME-LOOKUP-PROC. MOVE LOOKUP-NAME OF MESSAGE-IN TO PH-EMPLOYEE-NAME START PHONE-BOOK KEY IS = PH-EMPLOYEE-NAME.
Managing a Process Besides creating processes and communicating with processes, a process might need to obtain information about itself or about some other process in the same system or another system on the same Expand network.
************************************************************* * 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. 01 PROCESS-HANDLE PIC X(20). 01 CPU-PIN. 05 CPU NATIVE-2. 05 PIN NATIVE-2. 01 ERROR-NUMBER PIC S9(5) COMP. 01 SYSTEM-NAME PIC X(8). 01 SYSTEM-NUMBER NATIVE-2.
01 MESSAGE-IN. 05 SYS-MSG-CODE PIC S9(4) COMP. 05 SYS-MSG-TEXT PIC X(80). WORKING-STORAGE SECTION. 01 MESSAGE-SOURCE-REC. 05 SYSTEM-FLAG PIC S9 COMP. 05 ENTRY-NUMBER PIC 999 COMP. 05 FILLER PIC X(4). 05 PROCESS-HANDLE PIC X(20). 05 CPU-PIN. 06 CPU PIC S9(2) COMPUTATIONAL. 06 PIN NATIVE-2. 05 ERROR-NUMBER PIC S9(5) COMPUTATIONAL. 05 NULL-PH PIC X(20) VALUE ALL HIGH-VALUES. 01 FILE-DATA. 05 RECEIVE-FILE-STATUS PIC XX. 88 RECEIVE-FILE-OK VALUE "00". 88 RECEIVE-FILE-EOF VALUE "10". 01 PROCESS-NAME PIC X(8).
DISPLAY "PROCESS " PROCESS-NAME. DISPLAY "MESSAGE CODE " SYS-MSG-CODE. DISPLAY "MESSAGE CONTENTS: " SYS-MSG-TEXT. Determining the Status Using the ENTER verb, a process can call the PROCESS_GETINFO_ routine to obtain information about any process.
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. In Example 311, an HP COBOL program uses the PROCESS_GETINFO_ routine to discover its environment and then reports the information to its home terminal.
GIVING ERROR-RETURN. ENTER TAL "PROCESS_GETINFO_" * processhandle USING PROCESS-HANDLE * proc-fname OMITTED * proc-fname-len OMITTED * priority PRIORITY * moms-processhandle OMITTED * hometerm HOME-TERMINAL * hometerm-len HOME-TERMINAL-LEN * process-time OMITTED * creator-access-id CREATOR-ACCESSOR-ID * process-access-id PROCESS-ACCESSOR-ID * gmoms-processhandle OMITTED * jobid OMITTED * program-file PROGRAM-FILE-NAME * program-len PROGRAM-FILE-NAME-LEN * ...
MOVE MOVE MOVE MOVE MOVE MOVE MOVE RIGHT-BYTE OF CONSECUTIVE-BYTES TO NUMERIC-RIGHT-BYTE. BYTE-AS-NUMBER TO CREATOR-MEMBER. PROCESS-ACCESSOR-ID TO BYTE-PAIR. LEFT-BYTE OF CONSECUTIVE-BYTES TO NUMERIC-RIGHT-BYTE. BYTE-AS-NUMBER TO PROCESS-GROUP. RIGHT-BYTE OF CONSECUTIVE-BYTES TO NUMERIC-RIGHT-BYTE. BYTE-AS-NUMBER TO PROCESS-MEMBER.
05 LEFT-BYTE PIC X. 05 RIGHT-BYTE PIC X. 01 SEPARATED-BYTES. 05 LEFT-BYTE. 10 LEFT-HIGH-BYTE PIC X. 10 LEFT-LOW-BYTE PIC X. 05 NUMERIC-LEFT-BYTE PIC S9(2) COMP REDEFINES LEFT-BYTE. 05 RIGHT-BYTE. 10 RIGHT-HIGH-BYTE PIC X. 10 RIGHT-LOW-BYTE PIC X. 05 NUMERIC-RIGHT-BYTE PIC S9(2) COMP REDEFINES RIGHT-BYTE. 01 PROCESS-ACCESSOR-ID PIC S9(4) COMP. 01 PROCESS-EDITED. 05 PROCESS-GROUP PIC ZZ9. 05 FILLER PIC X(1) VALUE ",". 05 PROCESS-MEMBER PIC 999. 01 CREATOR-ACCESSOR-ID PIC S9(4) COMP.
OMITTED OMITTED GIVING ERROR-RETURN. IF ERROR-RETURN < 2 * Found a match PERFORM REPORT-A-MATCH ADD 1 TO CPU-PIN ELSE IF ERROR-RETURN = 2 * No more on current CPU PERFORM INCREMENT-CPU-OR-QUIT ELSE IF ERROR-RETURN < 99 * CPU not configured or incommunicado PERFORM INCREMENT-CPU-OR-QUIT ELSE DISPLAY "INTERNAL ERROR IN PARAMETERS" STOP RUN. REPORT-A-MATCH. PERFORM EDIT-CPU-PIN. DISPLAY "(" NUMERIC-CPU "," NUMERIC-PIN ") " PROCESS-EDITED " " PRIORITY " ". DISPLAY PROGRAM-FILE-NAME " " HOME-TERMINAL " ".
Example 313 Identifying a Process’s Creator 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. * ********************************************************************* ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP TXP.
* -- 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. IF ERROR-RETURN NOT = 0 DISPLAY "Call to PROCESS_GETINFO_ returned an error code of " ERROR-RETURN STOP RUN. * -- If my process accessor id matches MOM's creator accessor id, I can * -- stop MOM before continuing IF MY-PAID = MOMS-CAID ENTER TAL "PROCESS_STOP_" USING MOMS-PROCESS-ID.
Example 314 Monitoring Completion of Descendant Processes ?ENV COMMON ?SAVE ALL ?SEARCH $SYSTEM.SYSTEM.COBOLLIB IDENTIFICATION DIVISION. PROGRAM-ID. FUPPERWARE. AUTHOR. TERRY COBOL. INSTALLATION. TRANSACTIONS ANONYMOUS. DATE-WRITTEN. 29 FEBRUARY 1988. DATE-COMPILED. ************************************************************************* * This program creates a FUP process and watches for its termination. * ************************************************************************* ENVIRONMENT DIVISION.
88 CLOSE-FROM-REQUESTOR VALUE 1 THRU 3. 10 STAT-2 PIC 9. 01 SAVE-MESSAGE-STUFF. 05 FUP PIC X(21) VALUE "$SYSTEM.SYSTEM.FUP". 05 SU-ERROR PIC S9(4) VALUE ZERO COMP. 05 NEWPROCESS-ERR-LEFT PIC 9(4). 05 NEWPROCESS-ERR-RIGHT PIC 9(4). 05 FUP-FAILED PIC X(19) VALUE "Failed to start FUP". 05 STRING-PORTION PIC X(6) VALUE "STRING". 05 INFO-COMMAND PIC X(6) VALUE "INFO *". 05 STARTUP-RESULT PIC S9(4) VALUE ZERO COMP. 05 NULL-CPLIST PIC S9(9) VALUE ZERO COMP. PROCEDURE DIVISION. DECLARATIVES.
* * WHEN OTHER IF SU-ERROR < 256 DISPLAY FUP-FAILED " -- File management error #" SU-ERROR 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 FUP-FAILED " -- NEWPROCESS error # = (" NEWPROCESS-ERR-LEFT "," NEWPROCESS-ERR-RIGHT ")" END-IF END-EVALUATE ... WATCH. READ MESSAGE-IN-FILE.
INSTALLATION. TRANSACTIONS ANONYMOUS. DATE-WRITTEN. 29 FEBRUARY 1988. DATE-COMPILED. ************************************************************************** * This program sends one message to $BOSS on system \HQ. If that * * process cannot be opened, the program tries again every five minutes. * ************************************************************************** ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP TXP. OBJECT-COMPUTER. HP TXP. INPUT-OUTPUT SECTION. FILE-CONTROL.
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.
At certain points in your program, you code CHECKPOINT statements, which instruct the operating environment to copy a specific list of one or more of your data elements into the backup process’s data space. If the primary process fails, the operating environment activates the backup process. The backup process starts executing at the code location following the last CHECKPOINT statement executed.
The information in these topics is general. For specific details on checkpointing, see the Guardian Programmer’s Guide. For details on the STARTBACKUP and CHECKPOINT statements, see STARTBACKUP (page 460) and CHECKPOINT (page 302). Process Pairs A process is the basic executable unit known to the operating environment—the execution (in a processor) of a program.
Figure 44 illustrates the activity of a process pair. The backup process stays in monitor state while the primary process is operating. If the primary fails, the backup leaves the monitor state and begins executing at the point indicated by the last call to CHECKPOINT by the primary. Figure 44 Activity of a Process Pair This sequence of actions occurs when a process pair runs: 1. The primary process opens any files required for its execution. 2.
Checkpointing When the primary process executes a CHECKPOINT statement, one of its fault-tolerant facility routines formats a message containing the information to be checkpointed and sends it to the backup process in the form of an interprocess message. A fault-tolerant facility routine in the backup process receives and acts upon the message. The two types of information you must usually checkpoint are data items and sync blocks.
of performing the operation, the file system returns the recorded completion status of the operation to the backup process. If, however, the requested operation has not been performed, it is performed and the completion status is returned to the backup process. The course of action taken by the file system is completely invisible to the backup process.
STARTBACKUP and CHECKPOINT Statements Normally, the STARTBACKUP statement is executed once at the beginning of run-unit execution (after the opening of the files) to establish a process pair. A CHECKPOINT statement is then executed at critical points during processing to pass (that is, checkpoint) information to the backup process.
If option 3 of the STARTBACKUP statement is specified (that is, if your program monitors the backup process), then the possible values of PROGRAM-STATUS are as shown in Table 129.
05 NEW-BASE PIC 9(4) VALUE 0. 77 BCPU PIC S9(2) COMP VALUE -1. 77 PARAM PIC X(9) VALUE SPACES. 77 PARAM-RET PIC X VALUE SPACES. 77 ERROR-CODE PIC S9(4) COMP VALUE 0. 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. MOVE "BACKUPCPU" TO PARAM.
Debugging Programs That Use the Fault-Tolerant Facility Debugging a program that uses the fault-tolerant facility requires at least as careful an analysis as designing the program. This list of suggestions is not exhaustive. • Test the program thoroughly as a simple batch job. You might create files of transactions that the job must successfully process before you try testing the fault-tolerance mechanisms. You can have the program read the files instead of having the program read from $RECEIVE.
• Online Dump and Roll-Forward Recovery • Record Locking Transactions in General A transaction is a multistep operation that affects the consistency of a database by transforming the database from one consistent state to a new consistent state. A transaction is also a unit of recovery. During a transaction, the database can be inconsistent. But either the entire transaction must happen, or none of it must happen. Each transaction has a unique transaction identifier.
On NonStop systems, under DP2 (Disk Process 2), all disks permit TMF auditing. To instruct TMF to audit a file, use the attribute AUDITED, which you set with the FUP command SET or ALTER. The AUDITED attribute is an attribute of the disk file itself; an HP COBOL program is unaware of and cannot affect this attribute. Every disk operation that changes the contents of a database protected by TMF is recorded in an audit trail.
Designing Programs for the TMF Subsystem Like any other programming task, the most important part of designing for TMF is planning. Someone must plan the training, hardware, development, installation, testing, and operation. Before development can proceed, the designers must be trained in TMF. Eventually, some training is necessary for everyone involved. When the designers understand TMF, the project must be planned. Identify the transactions in the system.
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. If the symbolic debugger that you use can accept its commands from an OBEY command file, you can create a script that interrupts transactions at various points in the requester and the server and tests the recovery mechanisms.
33 Migrating TNS/R Programs to TNS/E Programs NOTE: This section applies to migrating TNS/R HP COBOL programs to TNS/E HP COBOL programs, and assumes that you are running RVU G06.20 or later. To migrate TNS HP COBOL programs to TNS/R or TNS/E HP COBOL programs, see the COBOL Manual for TNS and TNS/R Programs. HP provides these native compilers for HP COBOL source programs: Compiler Objects Produced NMCOBOL TNS/R ECOBOL TNS/E The ECOBOL compiler is available both on NonStop systems and on the PC.
information on tools that can help you migrate HP C or HP C++ programs to TNS/E, see the C/C++ Programmer’s Guide. • pTAL Recompile pTAL programs with the EpTAL compiler, using the SYMBOLS directive if you want to reference a pTAL routine in a CALL or ENTER statement. For information about the EpTAL compiler, see the pTAL Reference Manual.
Removal Required Replace any references to TNS/R libraries with references to the analogous TNS/E libraries: Replace ... With ...
OPTIMIZE 0 (no optimization) is recommended when you are debugging a program using the ECOBOL compiler. OPTIMIZE 1 (most optimizations) is recommended for production. For a complete description of this directive, see OPTIMIZE (page 559). • SEARCH Directive For the NMCOBOL compiler, each object-name in a SEARCH directive must designate a TNS/R native object file (otherwise the compiler reports an error).
Removal Optional The ECOBOL compiler ignores these items, so you can (but need not) remove them from your source program. • LARGEDATA For the NMCOBOL compiler, the LARGEDATA directive determines whether individual data items are located in the small data area or the large data area. The default value for the LARGEDATA directive’s parameter is 64. The ECOBOL compiler ignores the LARGEDATA directive and issues a warning.
The Native Inspect debugger replaces Inspect as the TNS/E command line debugger on the NonStop server. Native Inspect is based on the industry-standard GNU GDB debugger. It provides most of the same capabilities as Inspect, but has a different command syntax.
34 Native COBOL Cross Compiler on PC The native COBOL cross compiler is an optional cross compiler that runs on the PC platforms listed in Table 130. Table 130 ECOBOL Cross Compiler Platforms Operating System Platform Cross Compiler Product Name Number Windows 98 Windows NT 4.
native COBOL cross-compiler options. Development, editing, and building functions are very similar on Visual Studio.NET and the ETK. NonStop COBOL for TNS/E components are: Component Name File NonStop ECOBOL driver executable ecobol.exe NonStop ECOBOL front end ecobfe.exe The directory structure of NonStop COBOL for TNS/E is: Directory Files bin ecobol.exe eld.exe cmplr ecobfe.exe lib ecobext.o libcob.so libraries in libc.
ecobol must be typed as shown, in lowercase letters. -c, -g, -o outfile are as described in the Open System Services Shell and Utilities Reference Manual.
• -Ww • -Wsystype={guardian|oss} -Wsystype={guardian|oss} determines whether ecobol creates loadfiles for the Guardian environment or for the OSS environment. The default is the Guardian environment. For descriptions of the other flags, see the Open System Services Shell and Utilities Reference Manual.
• -Wv • -Wverbose file is the source file name. On the Guardian platform, you issue these commands (if desired) before you issue the compilation command: On the PC, you put these arguments in the -Wcobol flag in the compilation command: DEFINE1 DEFINEname[=]value 2 PARAM SYMBOL-BLOCKS count SYMBOL-BLOCKS [=]count 1 For information about DEFINE, see DEFINEs (page 593) 2 For information about PARAM SYMBOL-BLOCKS, see PARAM SYMBOL-BLOCKS (page 528).
RUNV RUNV, which is a TACL macro in the Guardian environment and a script in the OSS environment, starts a program under the control of Visual Inspect. RUNV without program-file, displays the RUNV help. program-file is the name of the loadfile to run. program-file can be represented as a file-system file name or (in the Guardian environment) a DEFINE name. program-file is added to the list in Visual Inspect’s Application Control View. For information about Visual Inspect, see its online help.
program-parameter-list program-parameter is a parameter of the program that is to be run. In the Guardian environment, the NonStop TCP/IP address of your workstation is automatically detected when you invoke RUNV. In the OSS environment, you must either set the _TANDEM_VISUALINSPECT_WSADDR environment variable in your $HOME/.profile file or enter the workstation IP address as a command-line parameter. RUNV reads the IP address from the environment variable or from the command line.
The Transfer Tool is better for transferring very large, complex applications to the NonStop host. For most applications, Deploy is more convenient. From the PC command line, you can use any FTP application to transfer loadfiles and source files to the NonStop host. Documentation The ETK has online help that provides conceptual, reference, task-oriented, and error message information, as well as a quick-start tutorial.
35 Commands Guardian Environment Before Running the Compiler (Optional) Running the ECOBOL Compiler source-file list-file 972 Commands
target-name copy-library Running the Native Cross Compiler Under Visual Inspect run-option-list run-option program-parameter-list Guardian Environment 973
Before Running the Compiled Program (Optional) ASSIGN system-file characteristic size-list 974 Commands
CLEAR assignation FIXERRS PARAM Guardian Environment 975
name-value-pair Running the Compiled Program run-option-list run-option 976 Commands
program-parameter-list OSS Environment Before Running the Compiler (Optional) To change one or more of the defaults in Table 131 before executing the ecobol command, use the OSS export command. To execute an ecobol command with a specified set of environment variables, use the OSS env function with the environment variables in Table 131.
pathname 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:.
36 Compiler Directives On the compiler command line: In the program source text: In the OSS environment, include compiler directives in the ecobol command line with the -Wcobol flag. NOTE: “Default:” identifies the default for the compiler directive itself, not for its optional parameter(s). This default applies if a program does not contain the compiler directive at all.
BLANK and NOBLANK Default: NOBLANK Placement: Anywhere Scope: The last BLANK or NOBLANK in the program applies. Dependencies: None CALL-SHARED Default: CALL-SHARED Placement: Anywhere Scope: The last CALL-SHARED or SHARED in the compilation unit applies to the entire compilation unit. Dependencies: • 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.
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 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”).
COLUMNS 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. • The COBOL85 compiler accepts at most one COLUMNS for each source file (that is, one for the primary source file and one for each COPY library or source library called by the primary source file).
object-name-list Default: NOCONSULT Placement: Anywhere Dependencies: None DIAGNOSE-74 and NODIAGNOSE-74 Default: NODIAGNOSE-74 Placement: Anywhere Scope: Applies until its opposite overrides it Dependencies: None DIAGNOSE-85 and NODIAGNOSE-85 The COBOL85 compiler does not recognize these directives.
DIAGNOSEALL and NODIAGNOSEALL Default: NODIAGNOSEALL Placement: Anywhere Scope: Applies until its opposite overrides it Dependencies: None ELD Default: None Placement: In the command line Scope: Applies to the compilation unit Dependencies: None Default: None Placement: Must be either on a directive line of its own or be the last of a sequence of directives Dependencies: Requires a preceding IF or IFNOT directive with the same toggle-number References: IF and IFNOT ENDIF ENDUNIT
ERRORFILE Default: None Placement: Either on the compiler command line or in the source file before the Identification Division Scope: Applies to the compilation unit Dependencies: None ERRORS Default: ERRORS 100 Placement: Anywhere Scope: Applies to the compilation unit Dependencies: None FIPS and NOFIPS flag-option-list flag-option Value Identified OBSOLETE Obsolete language elements ABOVEMIN Language elements above the minimum subset ABOVEINTER Language elements above the inter
Value Identified LEVEL1DEB Debug language elements ABOVELEVEL1DEB * Debug language elements above level 1 of Debug REPORTWRITER * Report Writer language elements LEVEL1SEG Segmentation language elements ABOVELEVEL1SEG Segmentation language elements above level 1 of segmentation NONSTANDARDEXT Nonstandard extensions to COBOL * This option does not affect compilation because the compiler does not support this module. If you use this option, the compiler issues a warning and ignores the option.
character-string Default values is all spaces. Default: Standard top-of-page line Placement: Anywhere Scope: Applies until another HEADING overrides it Dependencies: None IF and IFNOT 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.
Scope: The last INSPECT or NOINSPECT in the compilation unit applies to the compilation unit. Dependencies: NOINSPECT and SAVEABEND override each other (whichever is last is active). References: SAVEABEND and NOSAVEABEND LINES Default: LINES 60 Placement: Anywhere Scope: Applies until another LINES overrides it Dependencies: LINES works only if paging applies to the compilation list device.
program, the compiler reports this as an error, compiles the first qualifying program unit as the main program, and produces multiple object files. Placement: Before the Identification Division header of the first program unit in the compilation unit Scope: Applies to the program that contains it Dependencies: None MAP and NOMAP Default: NOMAP Scope: The last MAP or NOMAP applies. Dependencies: MAP works only if LIST is active and SUPPRESS is not.
Dependencies: PARAM NONSTOP OFF command suppresses NONSTOP. References: PARAM Command OBJEXTENT NOTE: Do not use this directive in the OSS or Windows environment. extent-size specifies the number of pages to use for the primary and secondary extents of the generated object file. extent-size is an integer in the range 2 through 1070. Use this directive to increase the capacity of the generated object file. For more information about extents, see the Guardian Programmer’s Guide.
PERFORM-TRACE Default: The compiler does not provide additional information if run-time error 148 occurs.
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. References: SETTOG RUNNABLE Default: The compiler does not use the linker to produce a loadfile if there were no compilation errors. Placement: Anywhere Scope: Applies to the compilation unit Dependencies: SYNTAX overrides RUNNABLE.
SAVE NOTE: Do not use this directive in the OSS environment. save-option-list save-option Default: The compiler does not save initialization messages. Placement: Anywhere Scope: Applies to the compilation unit Dependencies: None SAVEABEND and NOSAVEABEND 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).
SEARCH and NOSEARCH NOTE: The compiler ignores the NOSEARCH directive and issues a warning. object-name-list Default: NOSEARCH Placement: Anywhere Scope: Applies to the compilation unit Dependencies: Must be used with either RUNNABLE or CONSULT if you are creating a PIC object file References: • RUNNABLE • CONSULT and NOCONSULT SECTION If you do not specify TANDEM or ANSI, the compiler assumes that the format of the text is the current source-text format.
toggle-number-list 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. Scope: Applies until RESETTOG overrides it Dependencies: None References: RESETTOG SHARED Default: CALL-SHARED Placement: Anywhere Scope: The last SHARED or CALL-SHARED in the compilation unit applies to the entire compilation unit.
SHOWCOPY and NOSHOWCOPY Default: SHOWCOPY Placement: Anywhere Scope: Applies until its opposite overrides it Dependencies: SHOWCOPY works only if LIST is active and SUPPRESS is not. References: • LIST and NOLIST • SUPPRESS and NOSUPPRESS SHOWFILE and NOSHOWFILE Default: NOSHOWFILE Placement: Anywhere Scope: Applies until its opposite overrides it Dependencies: None SOURCE section-name-list Default value is entire file. Default: None Placement: Must be the last directive on its line.
section-text SQL and NOSQL NOTE: The compiler ignores the NOSQL directive and issues a warning. sql-option-list sql-option Default: None. If the program contains SQL/MP statements, the SQL directive is required; otherwise, it is unnecessary. Placement: In the compiler command line.
Dependencies: SQL works only if LIST is active and SUPPRESS is not. References: • LIST and NOLIST • SUPPRESS and NOSUPPRESS STANDARD For complete list of all reserved COBOL words, see “All Reserved Words” (page 731). 1985 Causes the compiler to apply the COBOL-1985 standard. 2002 Causes the compiler to apply the COBOL-2002 standard.
parameter Default: None Placement: Must appear before the first COBOL source program (that is, before the first Identification Division header). Scope: The last valid SUBSET in the program applies. Dependencies: SUBSET is incompatible with STANDARD 2002 SUBTYPE NOTE: Do not use this directive in the OSS environment. Default: SUBTYPE 0 Placement: Anywhere Scope: The last SUBTYPE in the program applies. Dependencies: SUBTYPE is appropriate only if the program was compiled with RUNNABLE.
Dependencies: SUPPRESS overrides LIST (and therefore, it also overrides CODE, CROSSREF, ICODE, LMAP, MAP, SHOWCOPY, and SQL).
Dependencies: SYNTAX overrides RUNNABLE. References: • ENDUNIT • RUNNABLE TANDEM Default: TANDEM Placement: Anywhere Scope: TANDEM or ANSI 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: 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.
37 Source Program Organization and Format Separately Compiled Source Program end-program-header Division syntax: • Chapter 40: Identification Division (page 1019) • Chapter 41: Environment Division (page 1021) • Chapter 42: Data Division (page 1039) • Chapter 43: Procedure Division (page 1051) Reference Format • TANDEM • ANSI Separately Compiled Source Program 1003
TANDEM Figure 46 Tandem Reference Format Table 132 Valid Indicator Field Characters (Tandem Reference Format) Valid Character Character Name Means that the line is a … ? Question mark Compiler directive * Asterisk Ordinary comment / Slash Comment to be printed at the top of the next page D Uppercase D Debugging line d Lowercase d Debugging line - Hyphen Continuation line Space Text line ANSI Figure 47 ANSI Reference Format Table 133 Valid Indicator Area Characters (ANSI Reference Fo
Table 133 Valid Indicator Area Characters (ANSI Reference Format) (continued) Valid Character Character Name Indicates that the line is a … d Lowercase d Debugging line - Hyphen Continuation line Reference Format 1005
38 Language Elements and Expressions See also Chapter 21: Reserved Words (page 731).
Table 135 Punctuation Characters (continued) Character Name of Character ) Right parenthesis = Equal sign Table 136 Special Characters Character Name of Character + Plus sign - Hyphen or minus sign * Asterisk / Stroke or slash $ Dollar sign > Greater than sign < Less than sign Character-Strings COBOL Word Maximum length: 30 characters.
Decimal Numeric Literal Maximum number of digits in one decimal numeric literal: 18. Hexadecimal Numeric Literal Maximum number of hexadecimal digits: 16 (8 pairs). Simple Nonnumeric Literal Maximum number of characters: 160. Hexadecimal Nonnumeric Literal Maximum number of hexadecimal digits: 320 (160 pairs). National Literal Maximum number of characters: 160.
Figurative Constants Table 137 Figurative Constants Figurative Constant * What It Represents ZERO ZEROS ZEROES One or more of the character zero (0), depending on the context SPACE SPACES One or more spaces, depending on the context HIGH-VALUE HIGH-VALUES One or more of the character that has the highest position in the program collating sequence, except in the SPECIAL-NAMES paragraph, where it represents the character that has the highest position in the ASCII character set (the 256th character, whi
Table 138 PICTURE Character-String Editing Characters (continued) Character Editing Operation .
Arithmetic Expressions • Table 139: Arithmetic Operators (page 1011) • Table 140: Hierarchy of Operators (page 1011) • Table 141: Precedence in Arithmetic Expressions (page 1011) • Table 142: Operator-Operand Combinations (page 1012) Table 139 Arithmetic Operators Operator Symbol Kind Meaning + Unary Multiplication by +1 Binary Addition Unary Multiplication by -1 Binary Subtraction * Binary Multiplication / Binary Division ** Binary Exponentiation - Table 140 Hierarchy of Oper
Table 142 Operator-Operand Combinations Successor Element First Element Variable Binary Operator + - * / ** Unary Operator + or - ( ) Identifier or literal No Yes No No Yes Binary Operator + - * / ** Yes No Yes Yes No Unary Operator + or - Yes No No Yes No ( Yes No Yes Yes No ) No Yes No No Yes Conditional Expressions • Simple Relation Condition • Simple Class Condition • Simple Sign Condition • Negated Condition • Combined Condition • Abbreviated Combined Relat
relationship Pointer Operands pointer-subject, pointer-object relationship Conditional Expressions 1013
Simple Class Condition Simple Sign Condition Negated Condition Combined Condition Abbreviated Combined Relation Condition 1014 Language Elements and Expressions
combined-part Concatenation Expressions Table 143 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.
39 Data References Qualified Condition-Name Qualified Data-Name Qualified Paragraph-Name Qualified Text-Name Qualified LINAGE-COUNTER 1016 Data References
Qualified Identifier Subscripted Table Element subscript Reference Modifier Qualified Identifier 1017
OSS Pathname for OSS File OSS Pathname for Guardian File 1018 Data References
40 Identification Division PROGRAM-ID paragraph program-kind «AUTHOR paragraph» 1019
«INSTALLATION paragraph» «DATE-WRITTEN paragraph» «DATE-COMPILED paragraph» «SECURITY paragraph» 1020 Identification Division
41 Environment Division Configuration Section SOURCE-COMPUTER Paragraph Configuration Section 1021
OBJECT-COMPUTER Paragraph «MEMORY-SIZE clause» PROGRAM COLLATING SEQUENCE clause «SEGMENT-LIMIT clause» CHARACTER-SET clause 1022 Environment Division
SPECIAL-NAMES Paragraph System-Name clause STATUS phrase on-phrase Configuration Section 1023
off-phrase File-Mnemonic clause ALPHABET clause literal-phrase SYMBOLIC-CHARACTERS clause 1024 Environment Division
character-list CLASS clause literal-phrase CURRENCY-SIGN clause DECIMAL-POINT clause Configuration Section 1025
Input-Output Section FILE-CONTROL Paragraph file-control-entry • Sequential File • Line Sequential File • Relative File • Indexed File • Queue File • Sort-Merge File 1026 Environment Division
Sequential File SELECT clause ASSIGN clause RESERVE clause ORGANIZATION clause Input-Output Section 1027
PADDING CHARACTER clause RECORD DELIMITER clause ACCESS MODE clause ALTERNATE RECORD KEY clause FILE STATUS clause 1028 Environment Division
Line Sequential File SELECT clause ASSIGN clause RESERVE clause Ignored.
FILE STATUS clause Relative File SELECT clause ASSIGN clause RESERVE clause 1030 Environment Division
ORGANIZATION clause ACCESS MODE clause RELATIVE KEY clause ALTERNATE RECORD KEY clause FILE STATUS clause Input-Output Section 1031
Indexed File SELECT clause ASSIGN clause RESERVE clause ORGANIZATION clause 1032 Environment Division
ACCESS MODE clause RECORD KEY clause ALTERNATE RECORD KEY clause FILE STATUS clause Input-Output Section 1033
Queue File For descriptions of clauses, see Indexed File.
Line Sequential File For descriptions of clauses, see All Other File Types. All Other File Types «RERUN clause» NOTE: The 1985 COBOL standard classifies the RERUN clause as obsolete, so you are advised not to use it.
rerun-file-2-phrase SAME AREA clause «MULTIPLE FILE clause» 1036 Environment Division
RECEIVE-CONTROL Paragraph TABLE OCCURS phrase SYNCDEPTH LIMIT phrase REPLY CONTAINS phrase Input-Output Section 1037
ERROR CODE phrase MESSAGE SOURCE phrase REPORT phrase message-type BREAK NEWPROCESSNOWAIT-COMPLETION CLOSE NODE-DOWN CONTROL NODE-UP CONTROLBUF OPEN CPU-DOWN PATHSEND-DIALOG-ABORT CPU-UP POWER-ON DEVICE-INFO PROCESS-CREATE-COMPLETION DEVICE-INFO-2-COMPLETION PROCESS-DELETION FILE-GETINFOBYNAME-COMPLETION PROCESS-TIME-SIGNAL FILE-FILENAME-COMPLETION REMOTE-CPU-DOWN JOB-PROCESS-CREATION REMOTE-CPU-UP LOGICAL-CLOSE RESETSYNC LOGICAL-OPEN SETMODE MEMORY-LOCK-COMPLETION SETPARAM ME
42 Data Division FILE Section FD-entry SD-entry 1039
WORKING-STORAGE Section EXTENDED-STORAGE Section LINKAGE Section File Descriptions • Sequential File • Line Sequential File • Relative, Indexed, or Queue File • Sort-Merge File 1040 Data Division
Sequential File EXTERNAL clause GLOBAL clause File Descriptions 1041
BLOCK CONTAINS clause RECORD CONTAINS clause contains-fixed-phrase «contains-phrase-range» VARYING phrase 1042 Data Division
«LABEL RECORDS clause» «VALUE OF clause» «DATA RECORDS clause» LINAGE clause CODE-SET clause File Descriptions 1043
REPORT clause Line Sequential File For descriptions of clauses, see Sequential File.
Relative, Indexed, or Queue File For descriptions of clauses, see Sequential File.
VARYING phrase DATA RECORDS clause Data Descriptions • Record Item (Levels 01 through 49) • Level-66 Item • Level-77 Item • Level-88 Item • Clause for Data Descriptions in the Linkage Section 1046 Data Division
Record Item (Levels 01 through 49) USAGE clause Data Descriptions 1047
SIGN clause OCCURS clause For a fixed-size table: For a variable-size table: key-order 1048 Data Division
SYNCHRONIZED clause BASED clause Level-66 Item Level-77 Item Data Descriptions 1049
Level-88 Item Clause for Data Descriptions in the Linkage Section 1050 Data Division
43 Procedure Division declaratives-portion section 1051
paragraph sentence statement See Statements.
• DIVIDE GIVING REMAINDER (page 1064) • ENTER (page 1064) • ENTER COBOL (page 1065) • EVALUATE (page 1065) • EXIT (page 1066) • FREE (page 1066) • Unconditional GO TO (page 1067) • Conditional GO TO (page 1067) • Delimited-Scope IF (page 1067) • Conditional IF (page 1067) • INITIALIZE (page 1068) • INSPECT TALLYING (page 1068) • INSPECT REPLACING (page 1069) • INSPECT TALLYING REPLACING (page 1070) • INSPECT CONVERTING (page 1071) • LOCKFILE (page 1072) • MERGE (page 1072)
• SORT (page 1084) • START (page 1085) • STARTBACKUP (page 1086) • STOP (page 1087) • STRING (page 1087) • SUBTRACT FROM (page 1087) • SUBTRACT GIVING (page 1088) • SUBTRACT CORRESPONDING (page 1088) • UNLOCKFILE (page 1088) • UNLOCKRECORD (page 1089) • UNSTRING (page 1089) • USE DEBUGGING (page 1089) • USE AFTER EXCEPTION (page 1090) • WRITE for Sequential Files (page 1090) • WRITE for Line Sequential Files (page 1091) • WRITE for Relative, Indexed, and Queue Files (page 1091
ADD TO ADD TO 1055
ADD GIVING 1056 Procedure Division
ADD CORRESPONDING ALLOCATE Bytes ALLOCATE Based Item ALTER ADD CORRESPONDING 1057
CALL called-entity USING phrase on-phrase historical-on-phrase 1058 Procedure Division
not-on-phrase CANCEL CHECKPOINT NOTE: Do not use this directive in the OSS environment.
CLOSE for Relative, Indexed, and Queue Files COMPUTE CONTINUE COPY 1060 Procedure Division
library-name REPLACING phrase original pseudo-text-1 new pseudo-text-2 COPY 1061
Format of a COPY Library section-text DELETE DISPLAY 1062 Procedure Division
DIVIDE INTO DIVIDE GIVING DIVIDE INTO 1063
DIVIDE GIVING REMAINDER ENTER 1064 Procedure Division
parameter ENTER COBOL EVALUATE subject-list subject ENTER COBOL 1065
object-list object range EXIT FREE 1066 Procedure Division
Unconditional GO TO Conditional GO TO Delimited-Scope IF Conditional IF Unconditional GO TO 1067
INITIALIZE replacement INSPECT TALLYING tallying-phrase for-clause 1068 Procedure Division
position INSPECT REPLACING replacing-phrase absolute-replacement position INSPECT REPLACING 1069
matching-replacement INSPECT TALLYING REPLACING tallying-phrase for-clause position 1070 Procedure Division
replacing-phrase absolute-replacement position matching-replacement INSPECT CONVERTING INSPECT CONVERTING 1071
match position LOCKFILE MERGE key-specifier COLLATING SEQUENCE phrase 1072 Procedure Division
USING phrase output-specifier MOVE TO MOVE CORRESPONDING MOVE TO 1073
MULTIPLY BY MULTIPLY GIVING 1074 Procedure Division
OPEN file-specification input-file-description For a sequential, relative, indexed, or queue file: For a line sequential file: output-file-description For a sequential, relative, indexed, or queue file: OPEN 1075
For a line sequential file: i-o-file-description For a sequential, relative, indexed, or queue file: I-O mode is not supported for line sequential files.
For a line sequential file: Unconditional PERFORM procedure-group PERFORM TIMES Unconditional PERFORM 1077
procedure-group PERFORM UNTIL procedure-group test-site 1078 Procedure Division
PERFORM VARYING procedure-group test-site varying-phrase after-phrase PERFORM VARYING 1079
READ for Sequential or Dynamic Access READ for Line Sequential Access 1080 Procedure Division
READ for Random or Dynamic Access RELEASE REPLACE pseudo-text-1 READ for Random or Dynamic Access 1081
pseudo-text-2 RETURN REWRITE for Sequential, Relative, Indexed, and Queue Files REWRITE is not supported for line sequential files.
SEARCH ALL match-1, match-n equal-part SET TO for Pointer Data Items pointer address SEARCH ALL 1083
SET TO for Nonpointer Data Items SET UP or SET DOWN for Pointer Data Items number-of-locations SET UP or SET DOWN for Nonpointer Data Items SORT key-specifier DUPLICATES phrase 1084 Procedure Division
COLLATING SEQUENCE phrase input-specifier-1 input-specifier-2 output-specifier-1 output-specifier-2 START START 1085
KEY phrase relationship If position is present, relationship is limited to: position NOTE: BEFORE is available only for the ECOBOL compiler. STARTBACKUP NOTE: Do not use this directive in the OSS environment. options 0 The fault-tolerant facility is to read and process system messages, and the primary process is to terminate abnormally if a trap condition occurs. 1 Same as option 0 except that if the primary process stops, the backup process takes over processing of the application.
STOP STRING SUBTRACT FROM STOP 1087
SUBTRACT GIVING 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.
UNLOCKRECORD UNSTRING result-list USE DEBUGGING NOTE: The 1985 COBOL standard classifies USE DEBUGGING as obsolete. The compiler does not recognize it.
USE AFTER EXCEPTION NOTE: Do not use GLOBAL in a USE AFTER EXCEPTION statement in the declaratives-portion.
ADVANCING clause end-of-page clause not-end-of-page clause invalid-key-phrase not-invalid-key-phrase WRITE for Line Sequential Files WRITE for Relative, Indexed, and Queue Files WRITE for Line Sequential Files 1091
invalid-key not-invalid-key 1092 Procedure Division
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 • PRESENT-VALUE • RANDOM • RANGE • REM • REVERSE • SIN • SQRT 1093
• STANDARD-DEVIATION • SUM • TAN • UPPER-CASE • VARIANCE • WHEN-COMPILED ACOS ANNUITY ASIN ATAN CHAR COS CURRENT-DATE DATE-OF-INTEGER DAY-OF-INTEGER 1094 Intrinsic Function Calls
FACTORIAL INTEGER INTEGER-OF-DATE INTEGER-OF-DAY INTEGER-PART LENGTH LOG LOG10 LOWER-CASE MAX MEAN FACTORIAL 1095
MEDIAN MIDRANGE MIN MOD NUMVAL string number 1096 Intrinsic Function Calls
NUMVAL-C value-1 value-2 number ORD ORD-MAX ORD-MIN NUMVAL-C 1097
PRESENT-VALUE RANDOM RANGE REM REVERSE SIN SQRT STANDARD-DEVIATION SUM TAN 1098 Intrinsic Function Calls
UPPER-CASE VARIANCE WHEN-COMPILED UPPER-CASE 1099
45 ZCOBDLL Routine Calls If you omit an optional parameter when you call a ZCOBDLL routine, you must put the keyword OMITTED in its position if you specify subsequent parameters. Trailing OMITTEDs are not required. (The syntax diagrams do not reflect this, because it would make them much harder to read.
COBOL_GETENV_ COBOL_PUTENV_ COBOL_RETURN_SORT_ERRORS_ COBOL_GETENV_ 1101
COBOL_REWIND_SEQUENTIAL_ COBOL_SET_SORT_PARAM_TEXT_ COBOL_SET_SORT_PARAM_VALUE_ 1102 ZCOBDLL Routine Calls
COBOL_SET_MAX_RECORD_ 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.
For Spoolers and Printers For System Log Files 1104 ZCOBDLL Routine Calls
For Partitioned Disk Files For Tape Files COBOL_SPECIAL_OPEN_ 1105
46 ZCREDLL Routine Calls See the CRE Programmer’s Guide.
47 Compiler Diagnostic Messages Table 145 Warning, Error, and Failure Characteristics Message Type Reports Warning Compilation Continues Code Generation is Suppressed Object File is Suppressed Questionable condition Yes No No Error Serious syntactic or semantic violation For current separately compiled program In some cases Failure Condition so severe that No compilation cannot continue Yes Yes Yes Message Indicator Line A message indicator line precedes each compiler diagnostic message.
The brackets are part of the message, not indicators that the bracketed material is optional. Failure Message Format A failure message has this format: *** Failure: --> message-text [Failure message-number] The brackets are part of the message, not indicators that the bracketed material is optional. Message List Messages are listed in numeric order by message number, with message type (warning, error, or failure) noted.
• The file file-name is specified as a SEARCH file, but it was not created by a compilation with symbols specified. • The file file-name is specified as a COPY library, but its attributes are inappropriate for a COPY file (file-name is not an EDIT file or has been modified since the start of the current compilation). • The default COPY library named file-name in the command that called the compiler has improper punctuation or its content does not have the form of a disk file name.
Cause The compiler either cannot initiate or cannot terminate spooler processing for its list file. file-name is the external form of the file name. ddd is the error code describing the problem (explained in documentation of the SPOOLSTART and SPOOLEND procedures). 10 (Failure) Unable to allocate compiler data space: ddd Cause The compiler cannot allocate its extended data segment. ddd is the error code describing the problem (explained in the documentation of the ALLOCATESEGMENT procedure).
- too many editable lines - too many edited lines If the message has the suffix - statement nesting too deep rewrite the statement, reducing the number of nested scopes. Use PARAM SYMBOL-BLOCKS (page 528) to allocate more space. 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.
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 A source line marked as a continuation line (having a hyphen in the indicator area) contains only spaces as its text. 26 (Warning) Improper indicator character Cause One of: • The character in the indicator area of a source line is not minus (-), asterisk (*), slash (/), question mark (?), d, D, or space.
31 (Error) Literal exceeds 160 characters A nonnumeric literal contains more than 160 characters. 32 (Error) Token exceeds 160 characters Cause A character-string appears (to the compiler) to contain more than 160 characters. If the indicated text is intended to represent several consecutive language elements, correct the problem by inserting space separators between them. 33 (Error) Numeric literal exceeds 18 digits Cause A numeric literal contains more than 18 digits.
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.
Cause The compiler’s syntax analyzer cannot accept the token xxxx (a character-string or a separator) and the recovery mechanism cannot find a simple correction. The compiler tried to recover by discarding text following the token, along with as little text preceding the token as is necessary, until the remaining text was syntactically acceptable.
49 (Error) Expected directive parameter Cause The compiler did not find the directive parameter keyword that it expected in one of these places: • Following a directive keyword • After the punctuation following a completed directive parameter 50 (Error) Unknown directive parameter Cause The indicated word must be a parameter keyword of the current directive, but is not. 51 (Error) Expected quoted string Cause The HEADING directive has a parameter that is not a string surrounded by quotation marks.
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.
You must determine what effects the ECOBOL interpretation has on the program’s execution logic, decide if those effects are desired, and then revise the source program if needed. The ECOBOL compiler reports potential logic differences only when the DIAGNOSE-85 directive is specified.
67 (Error) Expected single character Cause The indicated nonnumeric literal contains more than one character, which is not allowed in this context. 69 (Error) Expected alphabet-name Cause One of: • The alphabet-name specified in the PROGRAM COLLATING SEQUENCE clause is not defined. • A reference that must identify an alphabet-name does not. 70 (Error) Expected file name Cause A reference that must identify a file name does not.
Cause One of: • A CALL statement specifies more parameters in its USING phrase than HP COBOL supports. • An ENTER statement specifies more parameters in its USING phrase than the routine expects. 75 (Error) Out of order Cause The indicated language element does not appear in the proper position within the source program. 76 (Error) Duplicate phrase Cause The indicated phrase duplicates the function of a preceding one.
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. 83 (Error) Too many receiver items Cause The number of receiver items in the statement exceeds the maximum number allowed. For the maximum number allowed, see Chapter 19: Using HP COBOL in the OSS Environment (page 711).
Cause The same name identifies both a separately compiled COBOL program and a routine in the same run unit. The conflict arises because the name is the subject of CALL or CANCEL statements in the current separately compiled program, and these references must be resolved to another separately compiled COBOL program not yet defined in the source text; however, the compiler has already found references to this name as the identifier of a routine.
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.
Cause The program tried to access a file that was described with sequential organization randomly or dynamically. 104 (Error) PADDING clause permitted only for sequential organization Cause A file that does not have sequential organization has a PADDING clause in its file-control entry. 105 (Error) RECORD DELIMITER clause permitted only for sequential organization Cause A file that does not have sequential organization has a RECORD DELIMITER clause in its file-control entry.
Cause One of these rules was violated: • When a file name that appears in a SAME AREA clause also appears in a SAME RECORD AREA clause, every other file name in that SAME AREA clause must also appear in the SAME RECORD AREA clause. • When a file name that appears in a SAME AREA clause also appears in a SAME SORT AREA clause, every other file name in that SAME AREA clause must also appear in the SAME SORT AREA clause.
((max_requesters + 1) * 26) + ((((max_reply + 1) / 2) + 4) * (max_requesters * sync)) +4 121 (Error) Improper level-number Cause A level-number is not 66, 77, 88, or in the range 01 through 49. The compiler converts the improper level-number to 50. 122 (Error) Missing 01 level entry Cause A data description entry with a level-number from 02 through 49 inclusive is not subordinate to a data description entry with level-number 01.
127 (Error) Not permitted after variable occurrence table Cause Within a record description, a data description entry that includes an OCCURS clause with the DEPENDING phrase is followed by a data description entry with a lesser level-number. 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.
Cause The program tried to redefine a data item that was described with a REDEFINES clause. (A subordinate of a redefinition can be redefined unless it is also described with a REDEFINES clause.) 135 (Error) Redefined data item not preceding item at this level Cause The data description entry of a redefinition was separated from the data description entry of the redefined item by another data description entry with the same level-number, and the intervening entry did not redefine the same data item.
Cause The PICTURE character-string for a numeric or numeric-edited data item has more than 18 digit positions. 142 (Error) Too many character positions Cause The PICTURE character-string has more than 134,217,726 character positions. 143 (Error) PICTURE clause not permitted for specified usage Cause The PICTURE clause describes a data item with USAGE INDEX, NATIVE-2, NATIVE-4, or NATIVE-8.
Cause A data item is described with a SYNCHRONIZED clause, but either the data item is subordinate to a data structure described with a VALUE clause or the data item is associated with condition-names. 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.
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 A data item with USAGE INDEX is described with a VALUE clause.
Cause A table has more than 7 OCCURS clauses. 165 (Error) Variable occurrences not permitted for subordinate table Cause A data item subordinate to a table item is described with an OCCURS clause that includes the DEPENDING phrase. 166 (Error) Variable occurrences not permitted in redefinition Cause A data item that is part or all of a redefinition is described with an OCCURS clause that includes the DEPENDING phrase.
Cause An elementary data item that is described with neither USAGE INDEX nor a PICTURE clause. It must be described with at least one of these. 173 (Error) Missing RENAMES clause Cause A data description entry with level-number 66 does not have a RENAMES clause, as it must. 174 (Error) Missing VALUE clause Cause A data description entry with level-number 88 does not have a VALUE clause, as it must.
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 A reference in the KEY phrase of an OCCURS clause identifies the table item itself, and that reference is not the first reference in the KEY phrase.
189 (Error) 01 or 77 level data item too large for section Cause The size of a data item exceeds the maximum size permitted for the Data Division section in which it is defined. 190 (Error) Described with clauses not permitted for sort-merge file Cause The file-control entry for a sort-merge file includes clauses other than the SELECT and ASSIGN clauses.
Cause One of: • The alphabet-name specified in the CODE-SET clause is defined by a sequence of literal phrases. • The alphabet-name specified in the CODE-SET clause is defined by NATIVE, STANDARD-1, or STANDARD-2 when the file’s description includes ALTERNATE RECORD KEY clauses. 197 (Error) File description has no record descriptions Cause A file description entry is not followed by any record description entries.
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 A file name introduced in a file-control entry is not defined in a file description entry.
Cause The RELATIVE KEY clause references an object about which one of these is true: • It is not an unsigned integer data item. • It is described with P s in its PICTURE clause. • It is a table or special register. 213 (Error) Relative key item not external Cause The RELATIVE KEY clause for an external file references a data item that is not external. 214 (Error) Relative key item within its file record Cause The relative key data item for a file is defined in the file’s record description entries.
222 (Error) Depending item not found Cause A name referenced in the DEPENDING phrase of an OCCURS or RECORD clause is not defined. 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.
230 (Error) Message source item not simple alphanumeric, has improper size, or not word-aligned Cause The MESSAGE SOURCE clause references an object about which one of these is true: • It is not a fixed-size alphanumeric data item. • It is a table item. • It has fewer than 32 character positions. • It begins on an odd-character boundary within a record. 231 (Error) Error code item not found Cause The ERROR CODE references an undefined name.
236 (Error) Too many internal files Cause The program defines more internal files than the compiler can allocate. 237 (Error) Improper target for ADDRESS OF clause Cause One of these is true about the identifier-1 parameter in an ADDRESS OF clause: • It is not a level-01 or level-77 data item in the Linkage Section. • It is not a level-01 or level-77 data item declared with the BASED clause.
Cause The DECLARATIVES header does not precede all procedures in the Procedure Division. 246 (Error) Declarative paragraph not within section Cause A paragraph-name in the Declaratives Portion of the Procedure Division is not subordinate to any section-name, as it must be. 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.
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.
Cause An exception phrase corresponds to a statement with which it cannot be associated. Possible reasons are: • The statement references a file whose description is incompatible with the phrase. • A READ statement specifies the NEXT phrase and the exception phrase is INVALID KEY or NOT INVALID KEY. • A READ statement does not specify the NEXT phrase and the exception phrase is AT END or NOT AT END.
Cause An EXIT or GO TO statement that does not specify a procedure-name is not the only statement in its sentence, as it must be. 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.
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 Either the data item does not have USAGE DISPLAY (as it must), or it is a numeric item with P s in its PICTURE character-string (which it must not have). 277 (Error) Expected display data item, not edited nor justified Cause One of is true about the data item: • It does not have USAGE DISPLAY.
283 (Error) Expected index data item or integer numeric data item Cause The data item does not have USAGE INDEX and is not a numeric item without fraction digits. 284 (Error) Expected group data item Cause The data item is not a data structure, as it must be. 285 (Error) Expected data file record data item Cause The data item is not a level-01 item subordinate to a data file description entry (level indicator FD), as it must be.
Cause The receiving data item is described as alphabetic when the data source for an ACCEPT statement is DATE, DAY, DAY-OF-WEEK, or TIME. 291 (Error) Numeric-edited data item not permitted Cause A numeric-edited data item is specified as an arithmetic operand. 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.
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 There is no implicit left-hand operand to complete the relation.
Cause The subject of a class-name such as ALPHABETIC or NOT ALPHABETIC is numeric. 307 (Error) Improper item for numeric test Cause The subject of a NUMERIC or NOT NUMERIC test is either alphabetic or is a data structure that has a subordinate described with an embedded operational sign. 308 (Error) Expected condition as operand Cause The operand indicated appears in a context that requires a simple or complex condition, such as the operand of an AND, OR, or NOT operator or the operand of a WHEN phrase.
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 ROUNDED appears in the REMAINDER phrase of a DIVIDE statement.
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 The object in the WHEN phrase is incompatible with the corresponding subject in the EVALUATE statement.
Cause The attributes of the receiving operand do not permit assigning it a value derived from the sending operand; for example: • A numeric data item is being set to the value of a nonnumeric literal, nonnumeric data item, or index data item. • An index data item is being set to the value of a nonnumeric literal or nonnumeric data item. • A data item other than an index-name is being set UP or DOWN. • A data item other than a mnemonic-name associated with an external switch is being set ON or OFF.
335 (Error) NEXT/REVERSED not compatible with random access Cause The NEXT phrase is used with a READ statement that specifies a file name described with random access. 336 (Error) PROMPT data item overlaps file record Cause The data item specified in the PROMPT phrase overlaps the file record area, but the data item and file record area do not begin at the same character position.
Cause The VARYING phrase is appears in a SEARCH ALL statement. 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.
350 (Error) File set conflict from xxxx Cause A SORT or MERGE statement specifies conflicting files. xxxx is one of these phrases: Phrase Meaning duplicate file names The same file name appears more than once in a MERGE statement. SAME AREA clause Two or more file names specified in one SAME AREA clause appear in a MERGE statement or in the GIVING phrase of a SORT statement. SAME RECORD clause Two or more file names specified in one SAME RECORD clause appear in the USING phrase of a MERGE statement.
Cause One of: • The operator in the KEY phrase is not equal sign (=), greater-than sign (>), greater-than-or-equal sign (>=), or one of their equivalents. • The POSITION or GENERIC phrase is present, and the operator in the KEY phrase is not the equal sign (=) or EQUAL.
363 (Error) Improper language name Cause The language in an ENTER statement 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.
Cause One of: • The source text from which the indicated COBOL program was compiled included the NONSTOP directive, but the current source text does not. • The current source text includes a NONSTOP directive, but the source text from which the indicated COBOL program was compiled did not. • The program searched an import library that includes a COBOL program that was compiled with the directive NONSTOP (page 558).
374 (Error) OMITTED permitted only for extensible or variable routine Cause OMITTED appears as an actual parameter, but the called routine does not have the EXTENSIBLE or VARIABLE attribute. 375 (Error) GIVING phrase permitted only for function routine Cause An ENTER statement includes the GIVING phrase, but the called routine is not a function (that is, it does not return a value).
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.
Cause Warning: One of: • An ALTER statement in the nondeclarative portion of the Procedure Division references a paragraph-name or section-name defined in a declarative procedure. • An ALTER statement in a declarative procedure references a paragraph-name or section-name defined in another declarative procedure. • An ALTER statement modifies a GO TO statement so that its execution will transfer control from one declarative procedure to another declarative procedure.
If one is defined in an independent segment, the other must be defined in the same independent segment. 389 (Warning or Error) Improper SORT/MERGE scope Cause Warning: An INPUT PROCEDURE or OUTPUT PROCEDURE phrase 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 a different declarative procedure.
Cause No END PROGRAM statement appeared for the contained program whose program-name is xxxx. 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 the Inspect debugger.
• Find sequences of code that occur several times and make each of them a procedure (see Procedures (page 237) and Procedure Execution (page 242)). To transfer control to a paragraph or procedure, use the statement PERFORM (page 389). • Change level-77 data items and elementary level-01 data items that are numeric from USAGE DISPLAY to USAGE COMP (see USAGE Clause (page 203)).
407 (Warning) Improper SEARCH ALL condition - serial search used Cause A SEARCH ALL statement specifies a condition that does not conform to the rules of the COBOL language. HP COBOL employs a serial rather than a binary search technique in this situation. 408 (Error) Program buffer space exceeds 31000 words Cause The sum of the buffer space needed for files exceeds 62 KB.
Cause A program in a user library references an external file. 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.
Cause An object file contains a call to the COBOLSPOOLOPEN routine. 461 (Error) Internal SQL error Cause The compiler’s internal consistency checker discovered a logic error. Please report this failure to your service provider. 462 (Error) Improper usage clause for host variable Cause An SQL/MP or SQL/MX host variable has an improper USAGE clause. 463 (Error) Host variable picture string cannot contain 'P' Cause An SQL/MP or SQL/MX host variable’s PICTURE string contains P.
Cause The compiler processed the maximum number of SQL/MP or SQL/MX statement lines without encountering the SQL/MP or SQL/MX statement terminator END-EXEC. 471 (Error) Ambiguous reference to SQLCA Cause More than one SQLCA is declared in the program, and the SQLCA in this statement is ambiguous in this context. 472 (Error) SQLCA is declared incorrectly Cause SQLCA is declared incorrectly (it must be a data structure).
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.
494 (Error) Unknown function Cause The compiler does not recognize the function name. 495 (Error) Expression is too complex Cause An expression is so complex that the compiler cannot process it. 496 (Error) Improper argument Cause The argument has at least one wrong characteristic (such as type, class, category, or length). 497 (Error) Too many arguments Cause More arguments have been supplied to the function than the function takes.
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 The keyword PERFORM is followed by something other than the keyword CYCLE or another verb.
521 (Error) Parameter must be passed BY REFERENCE to a FORTRAN routine Cause An ENTER statement tried to pass a parameter by value to a FORTRAN routine. This parameter must be passed by reference. 522 (Error) Parameter must be passed BY REFERENCE to a C function Cause An ENTER statement tried to pass a parameter by value to an HP C function. This parameter must be passed by reference.
• • ◦ SYNCDEPTH ◦ TIME LIMITS In a READ statement: ◦ PROMPT ◦ REVERSED ◦ TIME LIMITS ADVANCING in a WRITE statement 527 (Error) LINE SEQUENTIAL files may not be opened in I-O mode Cause The program contains a statement of the form OPEN I-O i-o-file-description where i-o-file-description is a LINE SEQUENTIAL file. 600 (Warning) Defunct directive ignored Cause The compiler ignores this directive.
Cause One of: • A CALL or ENTER statement calls a program, specifying the object file that contains the program, but that object file cannot be read. • A CALL or ENTER statement calls a program without specifying the object file that contains it, and one of the object files on the search list(s) cannot be read.
613 (Warning) Directives: directive-1;directive-2 Duplicate setting, previous setting ignored Cause The compilation unit contains incompatible directives; for example, CALL-SHARED and NON-SHARED. 614 (Warning) Cannot use file specified in CONSULT or SEARCH directive filename Cause A CONSULT or SEARCH directive references a file that is either nonexistent, corrupt, or not a TNS/E object file compiled with debugging symbols.
705 (Error) Expected key-word INITIALIZED, RETURNING, or a verb Cause The syntax of the ALLOCATE statement is incorrect. Other Products’ Error Messages Products that are merged with the compiler sometimes cause compile-time error messages when you run the compiled program.
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. Where Messages Are Reported If an EXECUTION-LOG parameter is currently defined, run-time diagnostic messages are reported to the destination that the EXECUTION-LOG parameter specifies (see PARAM Command (page 586)); otherwise, they are delivered to the home terminal of the process.
Example 321 Input-Output Error Message (CRE) \DRP12.$:0:622:163577460 \DRP12.$:0:622:163577460 \DRP12.$:0:622:163577460 \DRP12.$:0:622:163577460 \DRP12.$:0:622:163577460 \DRP12.$:0:622:163577460 \DRP12.$:0:622:163577460 \DRP12.$:0:622:163577460 - *** Run-time Error 181 *** OPEN operation failed with error 48 File BWORK = \DRP12.$DATA4.PTR.GRIP, closed From COBLIB_IO_ERROR_ + 0x660 (DLL zcobdll) COBLIB_OPEN_ + 0x5120 (DLL zcobdll) .BBB + 0x1C0 (UCr) .
• A USAGE COMPUTATIONAL operand in an arithmetic statement contains a number larger than the number of digits specified in the PICTURE clause for that item. • A subscript or a reference modifier is too big. You can determine the cause of arithmetic overflow in any of these ways: • Without the Debugger This method is recommended for production runs. If the PARAM INSPECT OFF command is active, the process stops executing with a trace-back to the highest-level program.
1 Unknown trap Cause The CRE trap processing function was called with an unknown trap number. Effect The run unit terminates abnormally. Recovery Check the program’s logic. Use the selected debugger to help isolate the problem or consult your system administrator. 2 Illegal address reference Cause 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.
Recovery Check the statement in your program at the address given by offset and correct it. Also, see Arithmetic Overflow for alternative ways to handle this problem. 5 Stack overflow Cause A stack overflow fault occurs if: • An attempt was made to execute a program whose dynamically allocated data did not fit within the remaining area available for the stack. • There was not enough remaining virtual data space for an operating environment procedure to execute.
Effect The run unit terminates abnormally. Recovery Report this error to your service provider. 9 Uncorrectable memory error Cause An uncorrectable memory error occurred. Effect The run unit terminates abnormally. Recovery Report this error to your service provider. 11 Corrupted environment Cause CRE run-time library data is invalid. Effect The CRE calls PROCESS_STOP_, specifying the ABEND variant and the text “Corrupted environment.” Recovery To correct the problem, initialize uninitialized pointers.
message. In that case, it calls PROCESS_STOP_, specifying the ABEND variant and the text “Corrupted Environment.” Recovery In a native object, the MCB is not at a fixed location. To find it, use the enoft command EXTSYMTBL. Then use the selected debugger to help isolate the problem. The enoft output can be very lengthy. Example 322 shows the location of the MCB for the native object file DOMS1400 is 0x0800e3e0.
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 Cause The CRE or a run-time library could not obtain space for all of its data. If the offending statement is an ACCEPT or DISPLAY statement, its buffer could not be allocated due to a lack of allocatable space. Effect The run unit terminates abnormally. Recovery Increase the available space.
23 Cannot determine file name ( error ) program_name.logical_name Cause The CRE could not determine the physical file name associated with program_name.logical_name. Effect The run unit terminates abnormally. Recovery Correct the program_name.logical_name and rerun your program. For information on ASSIGN commands, see ASSIGN Command (page 582) and the TACL Reference Manual. 24 Conflict in application of ASSIGN program_name.logical_name Cause ASSIGN values in your TACL environment conflict with each other.
Effect The run unit terminates abnormally. Recovery Modify the PARAM text and rerun your program. For more information on using PARAMs, see PARAM Command (page 586) and the TACL Reference Manual. 27 Ambiguity in application of PARAM PARAM name 'value') Cause A PARAM specifies a value that is ambiguous in the current context. For example, the PARAM specification: PARAM PRINTER-CONTROL A is ambiguous if the program contains more than one logical file named A. Effect The run unit terminates abnormally.
Effect The run unit terminates abnormally. Recovery Check the program’s logic. Use the selected debugger to help isolate the problem or consult your system administrator. 40 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 Range fault Cause An arithmetic overflow or underflow occurred while evaluating an arithmetic function.
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 Logarithm function domain fault Cause The parameter passed to a logarithm function (LOG or LOG10) was less than or equal to zero. The parameter to a logarithm function must be greater than zero. Effect Program behavior is language and application dependent.
Effect Program behavior is language and application dependent. Recovery Modify the program to pass a nonnegative value to the SQRT function. 55 Missing or invalid parameter Cause A required parameter is missing or too many parameters were passed. Effect Program behavior depends on the function that was called. Recovery Correct the program to pass a valid parameter. 56 Invalid parameter value Cause The value passed as a procedure parameter was invalid.
a path to the device. Also refer to error handling in this manual and in the language manual for the routine in your program that detected the error. If the error was caused by a read request from the CRE, consult your system administrator. 60 Standard output file error ( error ) Cause The Guardian file system reported an error when the CRE called a file system procedure to access standard output. error is the Guardian file system error. Effect The CRE can report this error when it closes your output file.
Recovery Consult your system administrator. 64 File not open Cause A request to open a file failed because the file device is not supported. Effect Program behavior is language and application dependent. An HP COBOL program terminates abnormally. Recovery Consult your system administrator. 65 Invalid attribute value Cause A parameter to an open operation was not a meaningful value. For example, the CRE_File_Open sync_receive_depth parameter must be a nonnegative number.
68 Nowait value not accepted Cause The value of no_wait to an open operation was not valid in the context in which it was used. For example, it is invalid to specify a nonzero value for no_wait for a device that does not support nowait operations. Effect Program behavior is language and application dependent. An HP COBOL program terminates abnormally. Recovery Consult your system administrator.
75 Cannot obtain buffer space Cause An attempt to allocate buffer space failed. The possible reasons are: • COBOL_SPECIAL_OPEN_ attempted to get space for level 3 spooling or for at least one record. • An OPEN of a file assigned to $RECEIVE attempted to get space for various tables. • An OPEN of an EDIT file attempted to get space to process the file. • An OPEN of other files attempted to get space for ADVANCING processing. Effect The OPEN statement is unsuccessful with I-O status code “91.
78 EDITREAD failed ( error ) Cause A call to EDITREAD failed. In CRE message 78, error, if present, gives the reason for the failure. Possible values of error are: Error Code Error Name -1 End-of-file marker encountered -2 I-O error -3 Text file format error -4 Sequence number error -5 Checksum error -6 Invalid buffer address Effect The OPEN statement is unsuccessful with I-O status code “91.” Recovery If the code is -2, there was an input-output error; try the statement again.
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 Guardian I/O error nnn Cause A Guardian operating system routine returned error nnn.
Cause An ECOBOL object is being run on a system that does not contain the run-time library. Instead, a “stub” is installed and it produces the diagnostic. Effect The run unit terminates abnormally. Recovery Ensure that either T0356 or T0357 is licensed to the system and installed correctly. 125 OCCURS DEPENDING ON data item out of range Cause The data item referenced in an OCCURS DEPENDING clause is either less than the minimum or greater than the maximum number of occurrences.
Recovery Correct the program. 130 Improper context for RETURN statement Cause A RETURN statement was executed when a SORT or MERGE output procedure was not executing. Effect The run unit is terminated abnormally. Recovery Correct the program. 132 SORT or MERGE statement executed while SORT or MERGE active Cause A SORT or MERGE statement was executed while a SORT or MERGE input or output procedure was being executed. Effect The run unit terminates abnormally. Recovery Correct the program.
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 mnemonic-name 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. If the home terminal or the device specified as the EXECUTION-LOG cannot be used, the run unit terminates abnormally.
139 Cancelled program not found Cause The program referenced in a CANCEL statement with identifier specified could not be located. It must be present in the run unit or in the TNS or user library, and must be within the scope of the CANCEL statement. Effect The run unit continues. Recovery Correct the program. Reduce the number of files that are open simultaneously.
Cause During the execution of a RETURN statement in a SORT or MERGE output 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.
Recovery Action depends on the message FastSort returns. See the FastSort Manual for the meaning of these messages. 147 Parameter mismatch for CALL identifier Cause The number of parameters in the USING list of a CALL identifier statement does not match the number of parameters specified in the called program’s USING list in the Procedure Division. Effect The run unit terminates abnormally. Recovery Correct the USING list in either the CALL statement or Procedure Division.
NOTE: If the Common Run-Time Environment (CRE) DLL used is earlier than version T1269H03, the following run-time diagnostic message is displayed instead: *** Run-time Error 149*** Unknown error ordinal 150 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.
Recovery Type ERROR nnn to see the meaning of the Guardian error; it might indicate corrective action. 154 Sequential DELETE must follow successful READ Cause A DELETE statement was executed on a file with ACCESS MODE SEQUENTIAL, and the preceding statement was not a successful READ statement. Effect The DELETE statement is unsuccessful with I-O status code “43.” Recovery Correct the program.
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 Type ERROR nnn to see the meaning of the Guardian error; it might indicate corrective action. 159 OPEN on an EDIT file and wrong open mode Cause An EDIT file is opened for other than INPUT. HP COBOL cannot write to an EDIT file. Effect The OPEN statement is unsuccessful with I-O status code “39.
Recovery If you want the file to be created for EXTEND or I-O, put OPTIONAL in the SELECT clause; otherwise, verify that the file exists when the program is run. 163 OPEN page eject failed with error nnn Cause The attempt to eject the first page during the processing of an OPEN statement referencing a LINAGE file or during the process of COBOL_SPECIAL_OPEN_ failed with Guardian error nnn. Effect The OPEN statement or call to COBOL_SPECIAL_OPEN_ is unsuccessful with I-O status code “30.
167 OPEN requested for an open file Cause The file referenced in an OPEN statement is already open. Effect The OPEN statement is unsuccessful with I-O status code “41.” Recovery Correct the program. 168 LINAGE file not on printer or process Cause The file referenced in an OPEN statement for a file with LINAGE specified is not assigned to a printer or a process (a spooler, for example). Effect The OPEN statement is unsuccessful with I-O status code “39.
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. 172 OPEN on a nonexistent file and alternate keys specified Cause A file with alternate keys specified does not exist when the attempt is made to open it. The file must have been created with a FUP CREATE or other means before it can be opened. Effect The OPEN statement is unsuccessful with I-O status code “30.
176 File is not opened for timed I/O Cause A TIME LIMIT operation (such READ … TIME LIMIT nn ) was attempted on a file that was not opened with TIME LIMITS specified. Effect The operation is unsuccessful with I-O status code “90.” Recovery Correct the program to do an OPEN … TIME LIMITS. 177 OPEN OUTPUT for file not on output device Cause 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).
Cause The COBOL program describes the file as ORGANIZATION RELATIVE or INDEXED, but the assigned file is not a structured disk file. Only structured disk files can be assigned to RELATIVE or INDEXED COBOL files. Effect The OPEN statement is unsuccessful with I-O status code “39.” Recovery Assign the correct file or correct the file description in the program. 181 OPEN operation failed with error nnn Cause A Guardian error nnn was returned during OPEN or COBOL_SPECIAL_OPEN_ processing.
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 Purge data from file during OPEN failed with error nnn Cause During the execution of an OPEN statement, the attempt to purge the data from the file (the purge is due to an OPEN OUTPUT on a file that contains data) failed with Guardian error nnn.
189 Sequential READ requested when current position is undefined Cause The program attempted to execute a sequential READ statement when the last operation was not a successful READ, OPEN, or START. One common cause is attempting to do a READ after an at-end condition occurs. Effect The READ statement is unsuccessful with I-O status code “46.” Recovery Correct the program.
Cause An attempt to position the file for a REWRITE statement failed with Guardian error nnn. Effect The REWRITE 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. 194 REWRITE repositioning failed with error nnn Cause An attempt to reposition the file after the rewrite operation during execution of a REWRITE statement failed with Guardian error nnn.
198 START operation failed with error nnn Cause The attempt to read the selected record during execution of a START statement failed with Guardian error nnn. Effect The START 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. 199 START positioning failed with error nnn Cause The attempt to position the file during execution of a START statement failed with Guardian error nnn.
Effect The statement is unsuccessful with I-O status code “42.” Recovery Correct the program. 203 OPEN on unstructured file described without fixed length records Cause An unstructured file is assigned to a COBOL file name whose RECORD CONTAINS clause in the file description indicates that the records are variable. Effect The OPEN statement is unsuccessful with I-O status code “39.” Recovery Either correct the RECORD CONTAINS clause or assign the correct file.
Recovery Type ERROR nnn to see the meaning of the Guardian error; it might indicate corrective action. For example, a Guardian error value of 21 is a File System error that indicates “illegal count specified,” which could arise from a block size error in the file description. 207 WRITE failed because file is full Cause The attempt to write the record during the execution of a WRITE statement or the attempt to write a saved record during the execution of a CLOSE statement failed because the file is full.
211 Wrong open mode for WRITE Cause A WRITE statement was attempted on a relative or indexed on a file that does not meet any one of these criteria: • Its open mode is OUTPUT. • Its open mode is EXTEND and its access mode is sequential. • Its open mode is I-O and its access mode is not sequential. 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.
Effect The OPEN statement is unsuccessful with I-O status code “37.” Recovery Assign the proper device or file. 215 Wrong or missing LABELS attribute Cause A LABELS attribute in a DEFINE command that refers to the file contains other than OMITTED, BYPASS, ANSI, or IBM. Effect The OPEN statement is unsuccessful with I-O status code “90.” Recovery Before running this program again, verify that the DEFINE in the environment is correct.
Recovery Before running this program again, verify that the DEFINE in the environment is correct or correct the file’s record description. 219 Wrong or missing BLOCKLEN attribute Cause A BLOCKLEN attribute in a DEFINE command that refers to a file contains more than 6 digits, is not correctly formed, is negative, is omitted for tapes specified with LABEL RECORDS STANDARD, is greater than the record length when BLOCK CONTAINS is not specified, or does not match file File Definition.
Recovery You can use the command interpreter ERROR command to discover the meaning of the Guardian error number. The message might suggest a corrective action. 223 DEFINE required for LABEL RECORDS STANDARD Cause A DEFINE command is required if LABEL RECORDS STANDARD is specified in the File Definition. Effect The OPEN statement is unsuccessful with I-O status code “90.” Recovery Before running this program again, verify that the DEFINE in the environment is correct or correct the file description.
Recovery Either correct the program descriptions or assign the correct file. 227 Loadclose failed with internal error mmm, GUARDIAN error nnn Cause The HP COBOL Fast I-O routine loadclose returned the indicated error codes. Effect The CLOSE statement is unsuccessful. If the Guardian error is 43, the I-O status code is "34"; otherwise it is "30". Recovery If you can resolve the Guardian error, do so; otherwise report the error to your service provider.
Cause The HP COBOL Fast I-O routine initnewdatablock failed. Effect The READ statement is unsuccessful with I-O status code “30.” Recovery Report the error to your service provider. 232 An illegal operation was attempted on a fast i/o file Cause The program attempted to execute a READ REVERSED, REWRITE, or START statement to a file that is using HP COBOL Fast I-O. Effect The REWRITE statement is unsuccessful with I-O status code “40.
If you do want to delete all of the information in the file, add a null Declarative Portion for this file to the program, recompile it (to allow the run unit to continue), and change the code to something like this: PERFORM WITH TEST AFTER UNTIL file-status (1: 1) = "0" OPEN OUTPUT the-file SHARED IF file-status (1: 1) NOT = "0" IF file-status = "30" AND GUARDIAN-ERR = 12 (count these, send a message, or take other appropriate action) ENTER TAL "DELAY" USING some-time ELSE (issue some other error and termin
• Use something other than an edit file. • Remove BLOCK CONTAINS from the unstructured file FD.
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.
Table 147 ASCII Character Set in Numeric Order (continued) Octal Ord. Left Right Hex. Dec. Char.
Table 147 ASCII Character Set in Numeric Order (continued) Octal Ord. Left Right Hex. Dec. Char.
Table 147 ASCII Character Set in Numeric Order (continued) Octal Ord. Left Right Hex. Dec. Char.
Table 147 ASCII Character Set in Numeric Order (continued) Octal Ord. Left Right Hex. Dec. Char.
Table 148 ASCII Character Set in Alphabetic Order (continued) Octal Char. Meaning Ord. Left Right Hex. Dec.
Table 148 ASCII Character Set in Alphabetic Order (continued) Octal Char. Meaning Ord. Left Right Hex. Dec.
Table 148 ASCII Character Set in Alphabetic Order (continued) Octal Char. Meaning Ord. Left Right Hex. Dec.
Table 148 ASCII Character Set in Alphabetic Order (continued) Octal Char. Meaning Ord. Left Right Hex. Dec.
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.
Table 150 Integer Types, Part 2 64-Bit Integer Bit Integer of 1 to 31 Bits Decimal Integer HP C and HP C++ long long -- -- COBOL PIC S9(n) COMP or PIC 9(n) COMP without P or V, 10 <= n <= 18 NATIVE-81 -- Numeric DISPLAY FORTRAN INTEGER*8 -- -- Pascal INT64 UNSIGNED(n), 1 <= n <= 16 INT(n), 1 <= n <= 16 DECIMAL SQL/MP or SQL/MX NUMERIC(10)… NUMERIC(18) PIC 9(10) COMP… PIC 9(18) COMP LARGEINT -- DECIMAL (n,s) PIC 9(n) DISPLAY TAL pTAL FIXED(0), INT(64) UNSIGNED(n), 1 <= n <= 31 -- R
Table 152 Character Types (continued) Character Character String Numeric-Edited Numeric-Edited FORTRAN CHARACTER CHARACTER array CHARACTER*n Pascal CHAR or BYTE value parameter PACKED ARRAY OF CHAR Enumeration, unpacked, FSTRING(n) <= 256 members Subrange, unpacked n…m, 0 <= n and m <= 255 STRING(n) SQL/MP or SQL/MX PIC X CHAR CHAR(n) PIC X(n) VARCHAR(n) TAL pTAL STRING STRING array -- Return Value Size (Words) 1 1 or 2, depends on declared pointer size 1 or 2, depends on declared point
Table 154 Pointer Types (continued) Procedure Pointer Byte Pointer Word Pointer Extended Pointer SQL/MP or SQL/MX -- -- -- -- TAL -- 16-bit pointer, byte-addressed 16-bit pointer, word-addressed 32-bit pointer pTAL PROCPTR 16-bit pointer, byte-addressed 16-bit pointer, word-addressed 32-bit pointer Return Value Size (Words) 1 or 2, depends on declared pointer size 1 or 2, depends on declared pointer size 1 or 2, depends on declared pointer size 1 or 2, depends on declared pointer size
Index Symbols #DYNAMIC special name, 835 ASSIGN command and, 835 in OSS environment, 725 #IN special name description of, 834 in OSS environment, 716 #OUT special name description of, 834 in OSS environment, 716 #RECEIVE blocks, 522 #TEMP special name, 835, 885 #TERM special name, 834 $ see Dollar sign ($) $0 opening, 641 sending events to, 642, 895 $0.
MOVE statements and, 369 ALPHABETIC-LOWER class test in simple condition, 270 with default character set, 105 ALPHABETIC-UPPER class test in simple condition, 270 with default character set, 105 Alphanumeric class and category, 77 Alphanumeric data items description of, 197 ACCEPT statement and, 279 alignment of data in, 87 MOVE statement and, 369 Alphanumeric edited category, 77 Alphanumeric edited data items description of, 197 ACCEPT statement and, 279 alignment of data in, 87 MOVE statement and, 369 Alp
Associating COBOL and system file names, 833 Asterisk (*) as arithmetic operator, 260 in EXECUTION-L0G parameter, 589 in PICTURE clause, 76, 194, 202 in Tandem reference format, 45 Asterisk (*):in ANSI reference format, 703 AT END phrase in READ statement for line sequential file, 722 for other files, 407, 413, 414 in RETURN statement, 423 in SEARCH ALL statement, 435 in SEARCH VARYING statement, 430 USE AFTER EXCEPTION procedures and, 484 At-end condition $RECEIVE and, 924 for READ statement file position
Bypassing labels, 850 C C routines migrating TNS/R programs to TNS/E programs, 958 migrating to native mode, 958 passing parameters to, 322, 809 restrictions on, 322 sharing data with, 803 C++ routines calling, 804 passing parameters to, 322 restrictions on, 322 Cache buffering, 877 see also Buffering, cache Cache, write-through, 877 CALL statement, 293, 516 :X/Open see X/Open CALL statement at object program level, 813 detailed explanation of, 518 dynamic, 797 EXTENDED access mode and, 180 PIC loadfiles a
system-names, 65 user-defined names, 65 COBOL85^ARMTRAP routine, 616 COBOL_ASSIGN_ routine description of, 646 COBOL_SET_MAX_RECORD routine and, 634 in OSS environment, 724 COBOL_COMPLETION_ routine, 615 COBOL_CONTROL_ routine, 616 COBOL_FILE_OPEN_ routine, 651 COBOL_GETENV_ routine, 618 COBOL_PUTENV_ routine, 618 COBOL_RETURN_SORT_ERRORS_ routine description of, 618 in OSS environment, 724 COBOL_REWIND_SEQUENTIAL_ routine, 620 COBOL_SET_MAX_RECORD_ routine, 633 COBOL_SET_SORT_PARAM_TEXT_ routine descriptio
for miscellaneous control, 538 for warning messages, 775 in ANSI reference format, 703 in COPY libraries, 507 in OSS environment, 724 in Tandem reference format, 45 locations for, 533, 755 summary of, 979 Compiler input Input to the compiler, 512 Compiler listing banner, 769 controlling, 769 COPY statement and, 502, 771 creation of, 524 directives that control, 769 embedded NonStop SQL/MP and, 773 IF and IFNOT directives and, 554 INNERLIST directive and, 769 minimal, 769 mnemonic codes in, 555 reference for
COPY libraries:copying from, 763 COPY library for COPY statements, 755 COPY statement compared to SOURCE directive, 758 compiler listing and, 771 debugging lines and, 764 diagnostic messages and, 772 directives that control, 769 IF directive and, 553 REPLACING phrase of, 503, 763 simple, 762 SOURCE directive and, 571 source manipulation and, 499 substrings and, 764 Correspondence in DATA RECORDS clause, 168 in EVALUATE statement, 327 in MOVE CORRESPONDING statement, 371 of data items, 243 CORRESPONDING phra
shared, 53, 803 size of, 195 synchronized, 217 that cannot have VALUE clauses, 219 Data items:classes of;Data items:categories of:description of;Levels of data;Categories of data:description of;Classes of data:description of, 77 Data items:initialization of:in Linkage Section;Linkage Section:initializing data items in, 180 Data items:initialization of:in Working-Storage Section, 177 Data items:qualifiers for, 90 DATA RECORDS clause, 168, 174 Data structures, 81 see also Files see also Records see also Table
propagation of, 594 DEFINEs for tape files description of, 847 DEFINEs:for tape files labeled, 849 DELETE DEFINE command, 825 DELETE statement, 310 Deleted records, 864 Delimited-scope statements, 232 Depending items, 216 Deploy command, 970 Descendants of processes, 939 Describing databases, 759 DEV subcommand of SPOOLCOM utility, 910 DEVICE attribute of DEFINE for labeled tape file, 852 for unlabeled tape file, 848 DEVICE-INFO message, 151 DEVICEINFO2-COMPLETION message, 151 Devices default input and outp
file processing and, 117 Dynamic calls, 797 Dynamic file assignments, 835, 839 Dynamic memory allocating with ALLOCATE statement, 289 Dynamic-link libraries (DLLs), 600 E EBCDIC code set, 172 EBCDIC tape files, 845 ECOBEX0 file, 801 ECOBEX1 file, 801 ECOBEXT File, 518 ECOBEXT file, 610, 801 ecobol utility (OSS), 711 EDIT editor, 748 EDIT files creating and using, 866 description of, 747 FILE-CONTROL paragraph and, 122 variable-length records in, 861 writing to, 490 Editing in PICTURE clause, 198, 199, 200,
EXCEPTION phrase, 296 Exclamation mark (, 745, 910 Exclusion modes, 84, 387, 859 EXCLUSIVE exclusion mode, 84, 387, 881 Executable files, 42 Execution of Declaratives Portion, 242 of loadfiles, 42 of paragraphs, 239 of Procedure Division, 238 of procedures, 242 of programs in Guardian environment, 581, 825 in OSS environment, 712 of programs:that use tape files, 853 of sections, 240 of sentences, 239 of statements, 239 EXECUTION-LOG parameter, 588 Execution:of programs description of, 853 EXIT statement, 33
system:for temporary disk files, 831 unqualified, 528, 756 File names:COBOL associating with system file names, 379 File numbers, 883 File position indicators description of, 84 OPEN statement and, 381 timed input-output and, 257 File Section, 154 FILE STATUS clause, 117 file type and, 116 for indexed file, 134 for line sequential file, 127, 718 for relative file, 130 for sequential file, 122 File system, 830 File system routines, 799 File Utility Program (FUP) DDL compiler and, 761 multiple-tape files and,
FIXERRS macro, 700, 776 Fixup operation, 816 Flags (OSS) cobol utility, 711 FLOAT directive, 537 Floating insertion editing, 201 Footing of page, 169 Form names for spooler jobs, 903 Formal parameters, adding, 801 Format reference:See ANSI reference format, 237 report, 912 source program, 43 standard COBOL, 237 Format:reference:See Tandem reference format, 237 FREE statement, 333 FROM phrase, 246 Functions C and C++, 322 GIVING phrase and, 321 intrinsic see Intrinsic functions X/Open CALL statement and, 293
in ANSI reference format, 703 in COBOL words, 63 in Tandem reference format, 45 I I-O-CONTROL paragraph, 138 I/O see Input-output IBM standard labels, 850 ICODE directive, 536 Identification Division description of, 96 summary of, 1019 Identification field, 704, 771 Identifiers, 93 IF directive, 553 IF sentences, 338 IF statement description of, 336 nested:conditional, 338 IF statement:nested:delimited-scope Statements:nested:delimited-scope IF, 336 IFNOT directive, 553 Imperative statements, 230 Implicit
Input:from tape Files see Tape files INSERTIONORDER parameter, 118, 122, 135 Inspect debugger native COBOL cross compiler, 968 symbol table for, 577 INSPECT directive, 556 INSPECT statement, 345 INSTALLATION paragraph, 97 Integer date format converting:to Julian date format, 665 converting:to standard date format, 665 obtaining from Julian date format, 668 obtaining from standard date format, 667 INTEGER function, 666 Integer functions description of, 656 FACTORIAL, 666 INTEGER, 666 INTEGER-PART, 669 LENGTH
K Key of reference OPEN statement and, 382 READ statement and, 421 KEY phrase, 212 Key-sequenced files See Indexed files, 82 Keys alternate record:for indexed files, 135 alternate record:for relative files, 130 alternate record:for sequential files, 122 in external files, 160 in START statement, 455 locking, 955 merge, 364 of reference, 869 record, 135 relative, 130 sort, 445 Status Key 1, 248 Status Key 2, 248 L LABEL RECORDS clause description of, 167 for labeled tape file, 851 for unlabeled tape file, 8
Local buffering for indexed files, 135 for relative files, 131 for sequential files, 124 Local names, 52 LOCK phrase for relative, indexed, or queue file, 307 for sequential or line sequential file, 305 Locked open mode, 83 LOCKFILE statement, 358 Locking files, 304, 835, 857 keys, 955 Locking files, 881 Locking records, 881 Locking:records, 955 LOG function Numeric functions, 671 LOG10 function, 671 Logging program activity to printer, 913 to terminal, 897 Logical operators in combined conditions, 273 in c
N N in PICTURE clause, 192 NAME option of RUN command, 827 Named processes, 562, 827 Names global, 52 local, 52 unqualified, 528 Names:qualified, 67 Names:user-defined, 65 National class and category, 77 National data items alignment of data in, 87 BLANK WHEN ZERO clause and, 219 CHARACTER-SET clause and, 105 comparisons of, 268 in INSPECT statements, 347 in PICTURE clause, 198 in STRING statement, 465 in UNSTRING statement, 481 MOVE statements and, 369 SIGN clause and, 211 SPECIAL-NAMES paragraph and, 106
Nonexecutable files See Linkfiles, 42 Nonnumeric comparisons, 266 Nonnumeric data items DISPLAY statement and, 313 initializing, 219 VALUE clause and, 219 Nonnumeric literals continuing in ANSI format, 703 hexadecimal, 73 in Tandem reference format, 45 punctuation characters in, 62 simple, 72 Nonprinting characters, 112 NONSTOP directive description of, 558 fault-tolerant facility and, 949 overriding, 822 NonStop SQL/MP See Embedded NonStop SQL/MP , 47 NonStop TS/MP See HP Nonstop TS/MP, 944 NOPORT directiv
Object files, 524 creating, 524 creating more space for, 524 default names for, 754 description of, 812 linking, 522 manipulating, 525 naming, 754 reducing size of, 541 OBJECT-COMPUTER paragraph, 102 OBJEXTENT directive description, 524 syntax, 559, 990 Obsolete elements, 574 OBSOLETE parameter, 575 OCCURS clause ALL subscript and, 658 in record description entry:for fixed-size table, 211 in redefined data item, 188 OCCURS clause:in record description entry:for variable-size table, 214 ODDUNSTR attribute, 1
file type and, 116 in external file, 160 in sequential file, 120 Page overflow condition, 489, 491 Pages, logical;Margins top and bottom, 169 Paragraph-names identical, 70 qualified, 69 Paragraphs execution of, 239 syntax of, 234 PARAM commands, 527 DEBUG, 587 description of, 586 EXECUTION-LOG, 587 INSPECT, 587 maximum number of, 824 NONSTOP, 587, 822 OSS environment and, 723 PRINTER-CONTROL, 823, 914 showing active, 825 SWAPVOL, 527 SWITCH-nn, 587, 823 SYMBOL-BLOCKS, 757 migrating to native mode and, 959 W
CALL statement and, 293, 798 unmatched items and, 181 POSITION phrase, 450, 873 Position-independent code (PIC) CALL statement and, 297 dynamic-link libraries and, 600 SHARED directive and, 568 Positioning file: to record with same alternate key, 873 Positioning, file approximate, 871 exact, 871 generic, 871 Power, raising to a See Exponentiation operator, 244 POWER-ON message, 151 Pre-execution preparation description of, 820 OBEY command files for, 823 Precedence of arithmetic operators, 261 of nested pro
PROGRAM-STATUS special register, 461, 950 PROGRAM-STATUS-1 special register, 461 PROGRAM-STATUS-2 special register, 461 Programs called, 513 calling see Calling programs and routines HP COBOL, 43 mixed-language see Mixed-language programs non-COBOL, 514, 798 PROMPT phrase, 409 Prompting an operator, 892 PROTECTED exclusion mode, 84, 881 PS TEXT EDIT (TEDIT) editor commands of, 750 customizing, 751 description of, 749 second window of, 750 Pseudo-text delimiter for, 62 REPLACE statement and, 767 Pseudo-text:
RECORD DELIMITER clause description of, 117 file type and, 116 for sequential file, 121 in external file, 160 RECORD KEY clause description of, 134 file type and, 116 Record keys alternate, 870 OCCURS clause and, 135 primary or prime, 864 Records description of, 79 blocking, 838, 877 deleted, 864 description entries for, 153, 182, 186 displaying, 314 elements of, 80 external, 190 fixed-length, 165 gaps between, 838 implicit FILLER bytes and, 88 in Extended-Storage Section, 53 in Linkage Section, 53 in Worki
substrings and, 764 REPLY CONTAINS phrase, 145 Reply table, 147, 923 REPORT clause, 149 description of, 173 message types of, 151 syntax of, 146 Reports names of, 902 printed:formatting of, 912 vertical spacing in, 911 Repositioning file to record with same alternate key, 873 Requesters reply table and, 147 screen transactions and TMF, 956 RERUN clause, 138 RESERVE clause buffered cache and for indexed file, 135 for relative file, 131 for sequential file, 123 file type and, 116 for indexed file, 133 for lin
of index-names, 51 of program-names, 49, 298 of statements, 233 of user-defined names, 49 Scope:of record-names, 50 Scratch file MERGE statement and, 366 SORT statement and, 444, 448 SCRATCH-BLOCK parameter, 624, 631 SCRATCH-CHECK parameter, 624, 632 SCRATCH-FILE parameter description of, 623 MERGE statement and, 366 Screen transactions, 956 SD entries see Sort-merge files, file description entries for SEARCH directive description of, 565 migrating TNS/R programs to TNS/E programs, 960 migrating to native m
description of, 210 for BINARY/COMPUTATIONAL data item, 206 for NATIVE-n data item, 209 in record description entry, 185 Sign conditions, 272 Simple conditions, 265 Simple insertion editing, 199 SIN function, 688 Sine function SIN function, 688 Single-tape files;Tape files closing, 306 Size error condition, 244, 263 SIZE ERROR phrase, 244 arithmetic precision and, 262 for NATIVE-n data item, 209 in ADD CORRESPONDING statement, 287 in ADD GIVING statement, 285 in ADD TO statement, 284 in COMPUTE statement, 3
Standard files sharing, 860 terminals as, 893 STANDARD-DEVIATION function, 690 START statement description of, 449 START LESS THAN, 457 STARTBACKUP statement description of, 460 fault-tolerant facility and, 944, 950 PROGRAM-STATUS data item and, 950 Starting points in disk files, 869 Startup message portions, 614 Statements description of, 229 arithmetic, 257 arithmetic:common features of, 257 compiler-directing see Compiler directives conditional, 231 delimited-scope, 232 execution of, 239 imperative, 230
System code space, 600 System data space, 600 System file names, 830 associating with COBOL file names, 379, 833 for devices, 832 for nondisk files, 832 for temporary disk files, 831 special, 833 System library, 600 System messages CRE and, 152 intercepting, 836 list of, 149 System numbers, 929 SYSTEM parameter, 624, 633 System-Name clause description of, 106 with STATUS phrase, 108 without STATUS phrase, 108 System-names, 65 T TABLE OCCURS phrase, 144 Tables elements of, 434 fixed-size, 211 implicit FILLE
current, 664 Time limit Break and, 893 expired, 256 for $RECEIVE, 257 for LOCKFILE statement, 359, 360 for READ statement, 407, 414, 421 for START statement, 453, 455 on disk file input-output, 860, 882 on input-output, 256 TIME LIMIT phrase in LOCKFILE statement, 359, 360 in READ statement, 407 in START statement, 453, 455 TIME LIMITS phrase, 376 TIME phrase, 283 Time, current ACCEPT statement and, 283 TIME-SIGNAL message, 152 Timestamp process names, 827 TMF see HP NonStop Transaction Management Facility
in EDIT files, 861 in entry-sequenced files, 863 in indexed files, 864 in key-sequenced files, 864 in relative files, 863 in tape files, 847 in terminal files, 890 preferred description of, 164 PROMPT phrase and, 409 READ statement and, 413 writing, 492, 496 Variable-length records:description of, 80 Variable-size data items operand identification and, 242 tables, 214 Variable-type intrinsic functions description of, 657 MAX, 673 MIN, 677 RANGE, 686 SUM, 691 Variables conditional see Conditional variables e