═══ 1. Version Notice ═══ Second Edition (September 1995) This edition applies to Version 3, Release 6, Modification Level 0, of IBM Application System/400 Integrated Language Environment COBOL/400 (Program 5716-CB1) and to all subsequent releases and modifications until otherwise indicated in new editions. Make sure you are using the correct edition for the level of the product. Order publications through your IBM representative or the IBM branch office serving your locality. Publications are not stocked at the address given below. A form for readers' comments is provided at the back of this publication. If the form has been removed, address your comments to: IBM Canada Ltd. Laboratory Information Development 2G/345/1150/TOR 1150 Eglinton Avenue East North York, Ontario, Canada. M3C 1H7 You can also send your comments by facsimile (attention: RCF Coordinator), or you can send your comments electronically to IBM. See "Communicating Your Comments to IBM" for a description of the methods. This page immediately precedes the Readers' Comment Form at the back of this publication. When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. ═══ ILE COBOL/400 Language Help - Main Panel ═══ For help on ILE COBOL/400 language clauses, statements, special registers, and figurative constants, select from the following topics.  Environment Division Clauses  Data Division Clauses  Procedure Division Statements  Special Registers  Figurative Constants  Compiler-Directing Statements For help on the structure of an ILE COBOL/400 program, select from the following topics.  ILE COBOL/400 Program-Overall Structure  Identification Division  Environment Division  Data Division  Procedure Division For help on the ILE COBOL/400 language concepts, select from the following topics.  Characters, character-strings, words, literals, comments, and separators  Sections and paragraphs  Reference format for a COBOL source line (Sequence Number Area, Indicator Area, Area A, Area B, and Comment Area)  Methods of referencing data and procedures  Types of COBOL names and their scope  Methods of transferring control of program flow from one statement to another statement. Note: To select a topic, click on the topic with the mouse, or move the cursor to the topic and press Enter. ═══ Environment Division Clauses ═══ For help with individual Environment Division clauses, select from the following list: Configuration Section: Input-Output Section: ALPHABET ACCESS MODE CLASS CONSOLE ASSIGN CRT STATUS COMMITMENT CONTROL CURRENCY SIGN CONTROL-AREA CURSOR FILE STATUS DECIMAL-POINT MULTIPLE FILE TAPE LINKAGE TYPE ORGANIZATION PADDING CHARACTER RECORD DELIMITER RECORD KEY RELATIVE KEY RERUN RESERVE SAME AREA SAME RECORD AREA SAME SORT AREA SAME SORT-MERGE AREA SELECT ═══ Data Division Clauses ═══ For help with individual Data Division clauses, select from the following list: FD and SD Entries: Data Description Entries: BLOCK CONTAINS BLANK WHEN ZERO CODE-SET EXTERNAL DATA RECORDS GLOBAL EXTERNAL JUSTIFIED GLOBAL LIKE LABEL RECORDS OCCURS LINAGE PICTURE RECORD CONTAINS REDEFINES VALUE OF RENAMES SIGN SYNCHRONIZED USAGE VALUE ═══ Procedure Division Statements ═══ For help with individual Procedure Division Statements, select from the following list: ACCEPT INITIALIZE ACQUIRE INSPECT ADD MERGE ALTER MOVE CALL MULTIPLY CANCEL OPEN CLOSE PERFORM COMMIT READ COMPUTE RELEASE CONTINUE RETURN DELETE REWRITE DISPLAY ROLLBACK DIVIDE SEARCH DROP SET ENTER SORT EVALUATE START EXIT STOP EXIT PROGRAM STRING GOBACK SUBTRACT GO TO UNSTRING IF WRITE ═══ Compiler-Directing Statements ═══ For help with individual Compiler-Directing Statements, select from the following list: *CONTROL(*CBL) COPY EJECT PROCESS REPLACE SKIP1/2/3 TITLE USE ═══ 2. Characters ═══ In COBOL, the indivisible unit of data is the character. The letters of the alphabet, digits, and special characters that form the COBOL character set are shown in COBOL Characters-Their Meanings and Uses. The Integrated Language Environment* (ILE*) COBOL/400* language is restricted to the defined character set. The contents of nonnumeric literals, comment lines, comment entries, and the values held in data items, can include any of the characters from the character set currently specified for the system (by the primary source file's code character set identifier (CCSID)). -----IBM Extension----- Characters from the Double-Byte Character Set (DBCS) are valid characters in certain COBOL character-strings. Double-byte characters occupy two adjacent bytes to represent one character. (See the DBCS information under Character-Strings for more information.) ---End of IBM Extension--- Individual characters are joined to form character strings, separators, and text words. A character-string is a character or sequence of contiguous characters that form a COBOL word, a literal, a PICTURE character-string, or a comment. A character-string is delimited by separators. A separator is a string of one or two contiguous punctuation characters used to delimit character-strings. Separators are described in detail under Separators. A text word is a character or sequence of contiguous characters between margin A (between column 7 and column 8) and margin R (column 72 and column 73) in a COBOL library, source program, or in pseudo-text. ═══ 2.1. COBOL Characters-Their Meanings and Uses ═══ ┌──────────────────────────────────────────────────────────────────────────────┐ │ COBOL Characters-Their Meanings and Uses │ ├───────────────┬───────────────────────────────┬──────────────────────────────┤ │ CHARACTER │ MEANING │ USE │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ A-Z │ Alphabet (uppercase) │ Alphabetic characters │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ a-z │ Alphabet (lowercase) │ Alphabetic characters │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ 0-9 │ Arabic numerals │ Numeric characters │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ │ Space │ Punctuation character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ . │ Decimal point or Period │ Editing character │ │ │ │ Punctuation character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ < │ Less than │ Relation character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ ( │ Left parenthesis │ Punctuation character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ + │ Plus sign │ Arithmetic operator │ │ │ │ Editing character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ $ │ Dollar sign │ Editing character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ * │ Asterisk │ Arithmetic operator │ │ │ │ Editing character │ │ │ │ Comment character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ ) │ Right parenthesis │ Punctuation character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ ; │ Semicolon │ Punctuation character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ : │ Colon │ Punctuation character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ - │ Minus sign or Hyphen │ Arithmetic operator │ │ │ │ Editing character │ │ │ │ Continuation character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ / │ Stroke or Slash │ Arithmetic operator │ │ │ │ Editing character │ │ │ │ Line control character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ , │ Comma │ Editing character │ │ │ │ Punctuation character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ > │ Greater than │ Relation character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ = │ Equal sign │ Punctuation character │ │ │ │ Relation character │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ " │ Quotation marks │ Punctuation characters │ ├───────────────┼───────────────────────────────┼──────────────────────────────┤ │ ' │ Apostrophe │ Punctuation character │ ├───────────────┴───────────────────────────────┴──────────────────────────────┤ │ NOTE: The Apostrophe (') character is an IBM Extension. │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 2.2. Character-Strings ═══ You can use character-strings containing single-byte characters to form:  COBOL words  Literals  PICTURE character-strings  Comment-entry text -----IBM Extension----- You can use character-strings containing double-byte characters to form:  Literals  Comment-entry text DBCS character-strings are constructed using characters from the Double-Byte Character Set. DBCS character-strings can be embedded into nonnumeric strings, including mixed literals. ---End of IBM Extension--- ═══ 2.2.1. COBOL Words ═══ COBOL words must be character-strings from the set of letters, digits, and the hyphen. (The hyphen cannot appear as the first or last character, however.) In the ILE COBOL/400 language, each lowercase letter is generally equivalent to the corresponding uppercase letter. The three types of COBOL words are:  User-defined words  System-names  Reserved words The following rules apply to all COBOL words that are not special character words within a source program:  The maximum length of a COBOL word is 30 characters.  A reserved word cannot be used as a user-defined word, or a system-name.  The same COBOL word however, may be used as both a system-name and as a user-defined word. The classification of a specific occurrence of such a COBOL word is determined by the context of the phrase in which it occurs. ═══ 2.2.2. User-Defined Words ═══ The types of user-defined words are listed below, with the rules that must be followed in forming them. ┌───────────────────────────────┬───────────────────────────────┐ │ TYPES OF USER-DEFINED WORDS │ GENERAL RULES │ ├───────────────────────────────┼───────────────────────────────┤ │ alphabet-name │ Each word must contain at │ │ class-name │ least one letter. │ │ condition-name │ │ │ data-name │ │ │ file-name │ │ │ index-name │ │ │ mnemonic-name │ │ │ program-name │ │ │ (for contained programs and│ │ │ outermost programs that are│ │ │ called using the PROCEDURE │ │ │ linkage convention) │ │ │ record-name │ │ │ routine-name │ │ ├───────────────────────────────┼───────────────────────────────┤ │ library-name │ Each word must contain at │ │ program-name │ least one letter. The first │ │ (for outermost programs tha│ 10 characters must be unique. │ │ are called using the PROGRA│ │ │ linkage convention) │ │ │ text-name │ │ ├───────────────────────────────┼───────────────────────────────┤ │ paragraph-name │ The word need NOT contain an │ │ section-name │ alphabetic character. │ ├───────────────────────────────┼───────────────────────────────┤ │ Level-numbers: │ Each word must be a 1- or │ │ 01-49,66,77,88 │ 2-digit integer; it does not │ │ Segment-numbers: 00-99 │ have to be unique. (Segmen- │ │ │ tation information is syntax │ │ │ checked only.) │ └───────────────────────────────┴───────────────────────────────┘ The function of each user-defined word is described in the clause or statement in which it appears. Related Information:  Constraints for Referencing User-Defined Words ═══ 2.2.3. Constraints for Referencing User-Defined Words ═══ Generally, a user-defined word must belong to only one of the types of user-defined words listed in the previous table and must be unique within each type. There are two exceptions; a COBOL word may be used as a:  condition-name, data-name, or record-name  Level-number or Segment-number For more information on the uniqueness of data reference, see Methods of Data Reference. The following types of user-defined words can be referenced by statements and entries in that program in which the user-defined word is declared:  paragraph-name  section-name The following types of user-defined words can be referenced by any COBOL program:  library-name  program-name  text-name The following types of names, when they are declared within a Configuration Section, can be referenced by statements and entries either in that program which contains a Configuration Section or in any program contained within that program:  alphabet-name  class-name  condition-name  mnemonic-name ═══ 2.2.4. System-Names ═══ A system-name is a character-string that is defined by IBM to have a specific meaning to the system. There are three types of system-names:  computer-name  language-name  implementer-name (which includes environment-name and assignment-name) ═══ 2.2.5. Reserved Words ═══ A reserved word is a character-string with a predefined meaning in a COBOL source program, and can be used only as specified in the language defined formats. There are five types of reserved words:  Keywords  Optional words  Special characters  Figurative constants  Special registers ═══ 2.2.5.1. Keywords ═══ Keywords are reserved words that are required within a given clause, entry, or statement. ═══ 2.2.5.2. Optional Words ═══ Optional words are reserved words that may be included in the format of a clause, entry, or statement in order to improve readability. They have no effect on the meaning or execution of the program. Optional words are shown in formats as uppercase, but appear below the main path. ═══ 2.2.5.3. Special Characters ═══ There are two types of special character reserved words:  Arithmetic operators: + - / * ** See Arithmetic Operators.  Relational operators: < > = <= >= See Relation Condition. ═══ 2.2.5.4. Figurative Constants ═══ Figurative constants are reserved words that name and refer to specific constant values. The reserved words for figurative constants are: ZERO/ZEROS/ZEROES SPACE/SPACES HIGH-VALUE/HIGH-VALUES LOW-VALUE/LOW-VALUES QUOTE/QUOTES ALL literal NULL/NULLS The singular and plural forms of ZERO, SPACE, HIGH-VALUE, LOW-VALUE, QUOTE, and NULL are equivalent, and may be used interchangeably. For example, if DATA-NAME-1 is a 5-character data item, each of the following statements will fill DATA-NAME-1 with five spaces: MOVE SPACE TO DATA-NAME-1 MOVE SPACES TO DATA-NAME-1 MOVE ALL SPACES TO DATA-NAME-1 A figurative constant may be used wherever 'literal' appears in a format, except where explicitly prohibited. When a numeric literal appears in a format, only the figurative constant ZERO may be used. -----IBM Extension----- The figurative constant ZERO can be used as a Boolean literal. ---End of IBM Extension--- The length of a figurative constant depends on the context of the program. The following rules apply:  When a figurative constant is associated with a data item (for example, when it is moved to or compared with another item), the length of the figurative constant character-string is equal to one (1) or to the number of character positions in the associated data item, whichever is greater.  When a figurative constant, other than the ALL literal, is not associated with another data item (for example, in a STOP, STRING, or UNSTRING statement), the length of the character-string is one (1) character. ═══ 2.2.5.5. Special Registers ═══ Special registers are reserved words that name storage areas generated by the compiler. Their primary use is to store information produced through specific COBOL features. Each such storage area has a fixed name, and must not be further defined within the program. In the general formats of this specification, a special register can be used, unless otherwise restricted, wherever a data-name or identifier is specified provided that the special register is the same category as the data-name or identifier. If qualification is allowed, special registers can be qualified as necessary to provide uniqueness. Each special register is discussed in the section indicated. The special registers are: ADDRESS OF DB-FORMAT-NAME DEBUG-ITEM LENGTH OF LINAGE-COUNTER RETURN-CODE SORT-RETURN WHEN-COMPILED ═══ 2.2.6. Literals ═══ A literal is a character-string whose value is specified either by the characters of which it is composed, or by the use of a figurative constant (See page Figurative Constants). There are three types of literals:  Boolean Literals  Nonnumeric Literals  Numeric Literals ═══ 2.2.6.1. Boolean Literals ═══ -----IBM Extension----- A Boolean literal is a character-string delimited on the left by the separator B" and on the right by the quotation mark separator. The character-string consists only of the character 0 or 1. The value of a Boolean literal is the character itself, excluding the delimiting separators. ---End of IBM Extension--- ═══ 2.2.6.2. Nonnumeric Literals ═══ A nonnumeric literal is a character-string enclosed in quotation marks ("), and can contain any allowable character from the EBCDIC character set. The maximum length of a nonnumeric literal is 256 characters. A nonnumeric literal must be enclosed in quotation marks ("). ---------- If the *APOST compiler option is in effect, the nonnumeric literal must be enclosed by apostrophes('). ---------- End of If the *APOST compiler option is in effect, the nonnumeric literal The enclosing quotation marks (or apostrophes) are excluded from the literal when the program is compiled. An embedded quotation mark must be represented by a pair of quotation marks (""). For example, "THIS ISN""T WRONG" ---------- In an apostrophe literal, a double apostrophe ('') is reduced to a single apostrophe when the double apostrophe is also a delimiter. For example, 'THIS ISN''T WRONG' represents THIS ISN'T WRONG ---------- End of Any punctuation characters included within a nonnumeric literal are part of the value of the literal. Every nonnumeric literal is in the alphanumeric data category. (Data categories are described in Classes and Categories of Data.) -----IBM Extension----- You can use hexadecimal notation to form a hexadecimal nonnumeric literal. ┌─── FORMAT ───────────────────────────────────────────────────────────────────┐ │ │ │ >──X"────hexadecimal-digits──"─────> │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The maximum length of a hexadecimal nonnumeric literal is 512 hexadecimal digits. The continuation rules are the same as those for nonnumeric literals. The compiler converts the hexadecimal literal into an ordinary nonnumeric literal. Hexadecimal nonnumeric literals can be used anywhere nonnumeric literals can appear. In nonnumeric literals, single-byte and double-byte characters can be combined within a character-string to form a mixed literal. COBOL statements process mixed literals without sensitivity to the machine representation. Those statements that operate on a byte-to-byte basis (for example, STRING and UNSTRING) may produce literals that are not valid mixtures of single-byte and double-byte characters. It is the user's responsibility to be certain that the statements are used correctly. ---End of IBM Extension--- ═══ 2.2.6.3. Numeric Literals ═══ A numeric literal is a character-string whose characters are selected from the digits 0 through 9, a sign character (+ or -), and the decimal point. If the literal contains no decimal point, it is an integer. (In this manual, the word integer appearing in a format represents a numeric literal of nonzero value that contains no sign and no decimal point; any other restrictions are included with the description of the format.) The following rules apply:  One through 18 digits are allowed.  Only one sign character is allowed. If included, it must be the leftmost character of the literal. If the literal is unsigned, it is positive in value.  Only one decimal point is allowed. If a decimal point is included, it is treated as an assumed decimal point (that is, as not taking up a character position in the literal). The decimal point may appear anywhere within the literal except as the rightmost character.  If enclosed in quotation marks, the compiler treats the literal as a nonnumeric literal. The value of a numeric literal is the algebraic quantity expressed by the characters in the literal. The size of a numeric literal in standard data format characters is equal to the number of digits specified by the user. Every numeric literal is in the numeric data category. (Data categories are described under Classes and Categories of Data.) ═══ 2.2.7. PICTURE Character-Strings ═══ A PICTURE character-string consists of symbols that are composed of the currency symbol and certain combinations of characters in the COBOL character set. Any punctuation character that appears as part of the specification of a PICTURE character-string is not considered as a punctuation character, but rather as a symbol used in the specification of that PICTURE character-string. ═══ 2.2.8. Comments ═══ A comment is a character-string that can contain any combination of characters from the EBCDIC character set. It has no effect on the execution of the program. There are two forms of comments: Comment entry Comment line ═══ 2.3. Separators ═══ A separator can be a single punctuation character or a string of punctuation characters. The following is a list of the COBOL separator characters and their meaning. Separator Meaning Space , Comma . Period ; Semicolon ( Left parenthesis ) Right parenthesis " Quotation mark == Pseudo-text delimiter : Colon -----IBM Extension----- ' Apostrophe B" Opening delimiter for Boolean literal X" Opening delimiter for hexadecimal nonnumeric literal ---End of IBM Extension--- Note: Any punctuation character included in a PICTURE character-string, a comment character-string, or a nonnumeric literal is not considered as a punctuation character, but rather as part of the character-string or literal. ═══ 3. Sections and Paragraphs ═══ Sections and paragraphs define a program. They are subdivided into clauses and statements. Unless the associated rules explicitly state otherwise, each required clause or statement must be written in the sequence shown in its format. If optional clauses or statements are used, they must be written in the sequence shown in their formats. These rules are true even for clauses and statements treated as comments. The grammatical hierarchy follows this form:  Identification Division Paragraphs Entries Clauses  Environment Division Sections Paragraphs Entries Clauses Phrases  Data Division Sections Entries Clauses Phrases  Procedure Division Sections Paragraphs Sentences Statements Phrases ═══ 4. Reference Format ═══ COBOL programs must be written in the COBOL reference format. Reference Format for COBOL Source Line shows the reference format for a COBOL 80-character source line. Reference Format for COBOL Source Line │ │ │ │ │ │ │ │ │ │ │ │ │ 1 │ 2 | 3 | 4 | 5 | 6 │ 7 │ 8 | 9 | 10 | 11 │ 12 | ... | 72 │ 73 | ... | 80 │ │ │ │ │ │ │ │ └──Sequence Number Area─┘ │ └─────Area A──────┴────Area B─────┴──Comment Area─┘  Indicator Area An 80-character COBOL source line is divided into the following reference format areas: Sequence Number Area Columns 1 through 6 Indicator Area Column 7 Area A Columns 8 through 11 Area B Columns 12 through 72 Comment Area Columns 73 through 80 ═══ 4.1. Sequence Number Area (Columns 1 through 6) ═══ A sequence number identifies each statement to be compiled by the COBOL compiler. The use of sequence numbers is optional, and may consist of any character in the character set of the computer. Sequence numbers may be in any order, and they need not be unique. -----IBM Extension----- You can use sequence checking at compilation time by specifying SEQUENCE. If the NUMBER option is specified, the sequence numbers from columns 1 through 6 are used; otherwise the source sequence numbers provided in the source file are used. ---End of IBM Extension--- ═══ 4.2. Indicator Area (Column 7) ═══ Use the indicator area to specify:  The continuation of lines from the previous line onto the current line  The treatment of text as documentation or comments  Debugging lines ═══ 4.3. Area A (Columns 8 through 11) ═══ The following items must begin in Area A:  Division header  Section header  Paragraph header or paragraph name  Level indicator (FD and SD) or level-number (01 and 77)  DECLARATIVES and END DECLARATIVES  END PROGRAM header The following items may begin in either Area A or Area B:  Comment lines  Debugging lines  Blank lines  Pseudo-text  Compiler-directing statements other than the USE statement ═══ 4.4. Division Header ═══ A division header is a combination of words, followed by a separator period, that indicates the beginning of a division: IDENTIFICATION DIVISION. ENVIRONMENT DIVISION. DATA DIVISION. PROCEDURE DIVISION. A division header (except when a USING phrase is specified with a Procedure Division header) must be immediately followed by a separator period. Except for the USING phrase, no text may appear on the same line. ═══ 4.5. Section Header ═══ A section header indicates either the beginning of a series of paragraphs (in the Environment and Procedure Divisions), or the beginning of an entry (in the Data Division). For example, FILE-CONTROL in the former case, and FILE SECTION in the latter. A section header must be immediately followed by a period except when Procedure Division segment numbers are specified. (Segmentation information is syntax checked only.) ═══ 4.6. Paragraph Header or Paragraph Name ═══ A paragraph header or paragraph name indicates the beginning of a paragraph. In the Environment Division, a paragraph consists of a paragraph header followed by one or more entries. In the Procedure Division, a paragraph consists of a paragraph-name followed by one or more sentences. ═══ 4.7. Level Indicator (FD and SD) or Level-Number (01 and 77) ═══ A level indicator can be either FD or SD. It must begin in Area A and be followed by a space. (See File Section.) A level-number that must begin in Area A is a 1- or 2-digit integer with a value of 01 or 77. ═══ 4.8. DECLARATIVES and END DECLARATIVES ═══ DECLARATIVES and END DECLARATIVES are keywords that begin and end the declaratives part of the source program. In the Procedure Division, each of these words must begin in Area A and be followed immediately by a separator period; no other text may appear on the same line. After END DECLARATIVES, no text may appear before the following section header. (See Declaratives.) ═══ 4.9. END PROGRAM Header ═══ The END PROGRAM header, followed by program-name and a separator period, indicates the end of a COBOL program. Program-name must be identical to that of the corresponding PROGRAM-ID paragraph. Every COBOL program (except an outermost program that contains no nested programs and is not followed by another COBOL program in a sequence of COBOL programs) must end with this header. ═══ 4.10. Area B (Columns 12 through 72) ═══ The following items must begin in Area B:  Entries  Sentences  Statements  Clauses  Continuation lines The following items may begin in either Area A or Area B:  Comment lines  Debugging lines  Blank lines  Pseudo-text  Compiler-directing statements other than the USE statement. ═══ 4.11. Entries, Sentences, Statements, Clauses ═══ The first entry, sentence, statement, or clause begins on either the same line as the header or paragraph-name it follows, or in Area B of the next nonblank line that is not a comment line. Successive sentences or entries either begin in Area B of the same line as the preceding sentence or entry or in Area B of the next nonblank line that is not a comment line. Within an entry or sentence, successive lines in Area B may have the same format, or may be indented to clarify program logic. The output listing is indented only if the input statements are indented. Indentation does not affect the meaning of the program, and the amount is limited to the width of Area B. See also Sections and Paragraphs. ═══ 4.12. Continuation Lines ═══ Any sentence, entry, clause, or phrase that requires more than one line can be continued in Area B of the next line that is neither a comment line nor a blank line. The line being continued is a continued line; the succeeding lines are continuation lines. Area A of a continuation line must be blank, though the indicator area must contain a hyphen. If there is no hyphen in the indicator area (column 7), the last character of the preceding line is assumed to be followed by a space. If there is a hyphen in the indicator area of a line, the first nonblank character of this continuation line immediately follows the last nonblank character of the continued line without an intervening space. If the continued line contains a nonnumeric literal without a closing quotation mark, all spaces at the end of the continued line (through column 72) are considered to be part of the literal. The continuation line must contain a hyphen in the indicator area, and the first nonblank character must be a quotation mark. The continuation of the literal begins with the character immediately following the quotation mark. If the last character of a continued line is a single quotation mark in column 72, the first two nonblank characters in the continuation line must be two quotes to denote a single quote as part of the nonnumeric literal. For the pseudo-text delimiter separator (==), the two characters that make up the separator must occupy the same line. ═══ 4.13. Comment Lines ═══ A comment line is any line with an asterisk (*) or slash (/) in the indicator area (column 7) of the line. The comment may be written anywhere in Area A and Area B of that line, and may consist of any combination of characters from the EBCDIC character set. A comment line may be placed anywhere in the program following the Identification Division header. Multiple comment lines are allowed. Each must begin with either an asterisk (*) or a slash (/) in the indicator area. An asterisk (*) comment line is printed in the output listing, immediately following the last preceding line. A slash (/) comment line is printed on the first line of the next page, and the current page of the output listing is ejected. The compiler treats a comment line as documentation, and does not check it syntactically. ═══ 4.14. Debugging Lines ═══ A debugging line is any line with a 'D' in the indicator area of the line. Debugging lines can be written in the Environment Division (after the OBJECT-COMPUTER paragraph), the Data Division, and the Procedure Division. If a debugging line contains only spaces in Area A and Area B, it is considered a blank line. ═══ 4.15. Blank Lines ═══ A blank line contains nothing but spaces from column 7 through column 72. A blank line may appear anywhere in a program. ═══ 4.16. Pseudo-Text ═══ The character-strings and separators comprising pseudo-text may start in either Area A or Area B. If, however, there is a hyphen in the indicator area (column 7) of a line which follows the opening pseudo-text delimiter, Area A of the line must be blank, and the rules for continuation lines apply to the formation of text words. ═══ 4.17. Compiler-Directing Statements ═══ The following compiler-directing statements may start in Area A or Area B: -----IBM Extension-----  *CBL  *CONTROL ---End of IBM Extension---  COPY -----IBM Extension-----  EJECT  SKIP/1/2/3  TITLE ---End of IBM Extension--- ═══ 4.18. Comment Area (Columns 73 through 80) ═══ The comment area is available for your own use; for example, to identify your program. ═══ 4.19. Methods of Data Reference ═══ References to data and procedures can be either explicit or implicit. Every user-defined name in a COBOL program names a resource for solving a data processing problem. To use a resource, a statement in a COBOL program must contain a reference that uniquely identifies that resource. To ensure uniqueness of reference, a user-defined name can be qualified, subscripted, or reference modified. Before looking at this, however, you need to understand the term identifier. There are three methods of data reference:  Qualification  Reference Modification  Subscripting. Related Information:  Resolution of Names ═══ 4.19.1. Identifier ═══ In the syntax diagrams, the term identifier refers to a user-defined name that, if not unique in a program, must be followed by a syntactically correct combination of qualifiers, subscripts, or reference modifiers necessary for uniqueness of reference. ┌─── FORMAT 1 - IDENTIFIER ────────────────────────────────────────────────────┐ │ │ │ ┌─────────────────────────┐ │ │  │ │ │ >>──data-name-1────┬─────────────────────┬─┴──┬─────────────────────┬──────> │ │ └─┬─IN─┬──data-name-2─┘ └─┬─IN─┬──file-name-1─┘ │ │ └─OF─┘ └─OF─┘ │ │ │ │ >──┬─────────────────────┬─────────────────────────────────────────────────> │ │ │ ┌───────────┐ │ │ │ │  │ │ │ │ └─(────subscript─┴──)─┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──>< │ │ └─(──leftmost-character-position:──┬────────┬──)─┘ │ │ └─length─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The following rules apply:  Duplication of data-names must not occur in those places where the data-name cannot be made unique by qualification.  In the same program, the data description entries for any two data items specified as the subject of the entry whose level-number is 01 must not include the EXTERNAL clause.  In the same Data Division, the data description entries for any two data items for which the same data-name is specified must not include the GLOBAL clause. There are two special cases for the identifier: LINAGE-COUNTER and condition-name. ═══ 4.19.1.1. LINAGE-COUNTER ═══ ┌─── FORMAT 2 - LINAGE-COUNTER ────────────────────────────────────────────────┐ │ │ │ >>──LINAGE-COUNTER──┬─────────────────────┬──>< │ │ └─┬─IN─┬──file-name-2─┘ │ │ └─OF─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 4.19.1.2. condition-name ═══ ┌─── FORMAT 3 - CONDITION-NAME ────────────────────────────────────────────────┐ │ │ │ ┌─────────────────────────┐ │ │  │ │ │ >>──condition-name-1────┬─────────────────────┬─┴──────────────────────────> │ │ └─┬─IN─┬──data-name-1─┘ │ │ └─OF─┘ │ │ │ │ >──┬─────────────────────┬──┬─────────────────────┬──>< │ │ └─┬─IN─┬──file-name-1─┘ │ ┌───────────┐ │ │ │ │ │ │  │ │ │ │ └─OF─┘ └─(────subscript─┴──)─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 4.19.2. Qualification ═══ A name can be made unique if it exists within a hierarchy of names, and the name can be identified by specifying one or more higher-level names in the hierarchy. The higher-level names are called qualifiers, and the process by which such names are made unique is called qualification. Qualification is specified by placing one or more phrases after a user-specified name, with each phrase made up of the word IN or OF followed by a qualifier. (IN and OF are logically equivalent.) ┌─── REFERENCES TO DATA DIVISION NAMES - FORMAT 1 ─────────────────────────────┐ │ │ │ ┌─────────────────────────┐ │ │  │ │ │ >>──┬─data-name-1────┬────┬─────────────────────┬─┴────────────────────────> │ │ └─condition-name─┘ └─┬─IN─┬──data-name-2─┘ │ │ └─OF─┘ │ │ │ │ >──┬─────────────────────┬──>< │ │ └─┬─IN─┬──file-name-1─┘ │ │ └─OF─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ┌─── REFERENCES TO DATA DIVISION NAMES - FORMAT 2 ─────────────────────────────┐ │ │ │ >>──LINAGE-COUNTER──┬─────────────────────┬──>< │ │ └─┬─IN─┬──file-name-2─┘ │ │ └─OF─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In any hierarchy, the data name associated with the highest level must be unique, and cannot be qualified. You must specify enough qualification to make the name unique; however, it may not be necessary to specify all the levels of the hierarchy. For example, if there is more than one file whose records contain the field EMPLOYEE-NO, but only one of the files has a record named MASTER-RECORD:  EMPLOYEE-NO OF MASTER-RECORD sufficiently qualifies EMPLOYEE-NO  EMPLOYEE-NO OF MASTER-RECORD OF MASTER-FILE is valid but unnecessary. Related Information:  References to Data Division Names  References to Procedure Division Names  References to COPY Libraries  Qualification Rules. ═══ 4.19.2.1. References to Data Division Names ═══ Data Division names that are explicitly referenced in a program must be either uniquely defined, or made unique through qualification. Unreferenced data-names need not be uniquely defined. A data-name associated with a level-number 01, or with an FD or SD level indicator in the File Section, is the highest level in a data hierarchy. If referenced, it must be uniquely defined, because it cannot be qualified. Data items with level-numbers 02 through 49 are successively lower levels in a data hierarchy, and if referenced, must be either uniquely defined, or made unique through qualification. Level-77 data-names, if referenced, must be uniquely defined, because they cannot be qualified. ═══ 4.19.2.2. References to Procedure Division Names ═══ If explicitly referenced, a paragraph-name must not be duplicated within a section. When a paragraph-name is qualified by a section-name, the word SECTION must not appear. A paragraph-name need not be qualified when referred to within the section in which it appears. A paragraph-name or section-name appearing in a program cannot be referenced from any other program. A section-name is the highest (and only) qualifier available for a paragraph-name and must be unique. ┌─── REFERENCES TO PROCEDURE DIVISION NAMES - FORMAT 1 ────────────────────────┐ │ │ │ >>──paragraph-name──┬──────────────────────┬──>< │ │ └─┬─IN─┬──section-name─┘ │ │ └─OF─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ┌─── REFERENCES TO PROCEDURE DIVISION NAMES - FORMAT 2 ────────────────────────┐ │ │ │ >>──section-name──>< │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 4.19.2.3. References to COPY Libraries ═══ If more than one COBOL library is available to the compiler during compilation, text-name can be qualified each time it is referenced. ┌─── REFERENCES TO COPY LIBRARIES - FORMAT 3 ──────────────────────────────────┐ │ │ │ >──text-name──┬──────────────────────────────────────┬──> │ │ │ (1) │ │ │ └─┬─IN─┬──library-name- ─────file-name─┘ │ │ └─OF─┘ │ │ │ │ NOTE: │ │ (1) Required hyphen between library-name-file-name to qualify │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ For rules on referencing COPY libraries, see COPY Statement. ═══ 4.19.2.4. Qualification Rules ═══ The rules for qualifying a name are:  A name can be qualified even though it does not need qualification.  Each qualifier must be of a higher level than the name it qualifies, and must be within the same hierarchy. For example: 01 FIELD-A 02 FIELD-B 05 SUB1 07 SUB2 02 FIELD-C 07 SUB1 A hierarchy includes all subordinate entries to the next equal or higher level-number. Therefore, in the above example all entries are in the hierarchy of FIELD-A. All entries from FIELD-B to, but not including, FIELD-C are in the hierarchy of FIELD-B. In the hierarchy of FIELD-A, SUB1 can be used twice; once as subordinate to FIELD-B and once as subordinate to FIELD-C. In references to SUB-1, it must be qualified as SUB-1 OF FIELD-B or SUB-1 OF FIELD-C. Within FIELD-B or FIELD-C, SUB1 cannot be subordinate to itself.  The complete list of qualifiers for one data-name must not be the same as a partial list of qualifiers for another.  If a data-name or a condition-name is assigned to more than one data item, it must be qualified each time it is referred to (for the one exception, see REDEFINES Clause).  If reference can be made unique by qualification, data-names may be defined in more than one place in a given program or compilation unit.  If there is more than one combination of qualifiers that ensures uniqueness, then any of these combinations can be used.  If referenced in the program, a section-name must be unique.  If referenced in the program, a paragraph-name must be unique within a section. When a paragraph-name is qualified by a section-name, the word SECTION must not appear. A paragraph-name need not be qualified when referred to within the section in which it appears.  LINAGE-COUNTER must be qualified each time it is referenced if more than one file description entry containing a LINAGE clause has been specified in the source program.  Library-name must be unique in the system. Therefore, the first 10 characters of library-name must be unique.  Text-name (member-name) can be qualified by the library-name and file-name in which it resides. (A hyphen is required between library-name and file-name, without any intervening spaces.) If no library is specified, the library list is searched. If no file-name is specified, QCBLLESRC is used. -----IBM Extension----- File-name is optional for the COPY statement, Format 1. If file-name is not specified, the default is QCBLLESRC. ---End of IBM Extension--- ═══ 4.19.3. Subscripting ═══ Subscripting is a method of providing table references through the use of positive integers. A subscript is a positive integer (or integer data item) whose value specifies the occurrence number of a table element. ┌─── SUBSCRIPTING - FORMAT ────────────────────────────────────────────────────┐ │ │ │ ┌───────────────────────┐ │ │  │ │ │ >>──┬─condition-name-1─┬───┬─────────────────────┬┴────────────────────────> │ │ └─data-name-1──────┘ └─┬─IN─┬──data-name-2─┘ │ │ └─OF─┘ │ │ │ │ >──┬─────────────────────┬─────────────────────────────────────────────────> │ │ └─┬─IN─┬──file-name-1─┘ │ │ └─OF─┘ │ │ │ │ ┌────────────────────────────────────────┐ │ │  │ │ │ >──(────┬─integer-1──────────────────────────┬─┴──)──>< │ │ ├─data-name-3──┬──────────────────┬──┤ │ │ │ └─┬─+─┬──integer-2─┘ │ │ │ │ └─┴─┘ │ │ │ └─index-name-1──┬──────────────────┬─┘ │ │ └─┬─+─┬──integer-3─┘ │ │ └─┴─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The subscripts, enclosed in parentheses, are written immediately following any qualification for the name of the table element. The number of subscripts in such a reference must equal the number of dimensions in the table whose element is being referenced. That is, there must be a subscript for each OCCURS clause in the hierarchy containing the data-name including the data-name itself. When more than one subscript is required, they are written in the order of successively less inclusive dimensions of the data organization. If a multi-dimensional table is thought of as a series of nested tables and the most inclusive or outermost table in the nest is considered to be the major table with the innermost or least inclusive table being the minor table, the subscripts are written from left to right in the order major, intermediate, and minor. For example, if TABLE-THREE is defined as: 01 TABLE-THREE. 05 ELEMENT-ONE OCCURS 3 TIMES. 10 ELEMENT-TWO OCCURS 3 TIMES. 15 ELEMENT-THREE OCCURS 2 TIMES PIC X(8). a valid subscripted reference to TABLE-THREE is: ELEMENT-THREE (2 2 1) A reference to an item must not be subscripted unless the item is a table element or an item or condition-name associated with a table element. Each table element reference must be subscripted except when such a reference appears:  In a USE FOR DEBUGGING statement  As the subject of a SEARCH statement  In a REDEFINES clause  In the KEY IS phrase of an OCCURS clause  In a LIKE clause The lowest permissible occurrence number represented by a subscript is 1. The highest permissible occurrence number in any particular case is the maximum number of occurrences of the item as specified in the OCCURS clause. Related Information:  Subscripting Using Integers or Data-Names  Subscripting Using Index-Names (Indexing)  Relative Subscripting ═══ 4.19.3.1. Subscripting Using Integers or Data-Names ═══ When an integer or data-name is used to represent a subscript, it can be used to reference items within different tables. These tables need not have elements of the same size. The same integer or data-name can appear as the only subscript with one item and as one of two or more subscripts with another item. A data-name subscript can be qualified; it cannot be subscripted or indexed. For example, valid subscripted references to TABLE-THREE-assuming that SUB1, SUB2, and SUB3 are all items subordinate to SUBSCRIPT-ITEM-include: ELEMENT-THREE (SUB1 SUB2 SUB3) ELEMENT-THREE IN TABLE-THREE (SUB1 OF SUBSCRIPT-ITEM, SUB2 OF SUBSCRIPT-ITEM, SUB3 OF SUBSCRIPT-ITEM) ═══ 4.19.3.2. Subscripting Using Index-Names (Indexing) ═══ Indexing allows such operations as table searching and manipulating specific items. To use indexing you associate one or more index-names with an item whose data description entry contains an OCCURS clause. An index associated with an index-name acts as a subscript, and its value corresponds to an occurrence number for the item to which the index-name is associated. The INDEXED BY phrase, which identifies the index-name associated with its table, is an optional part of the OCCURS clause. There is no separate entry to describe the index-name since its definition is completely system dependent. Index-names may be seen as compiler generated registers for the use of this program only. They are not data, or part of the data hierarchy, and must be unique in a COBOL program. Each index name must follow the rules for formation of a user-defined word. Each index-name refers to a compiler-generated register or storage area. The initial value of an index at object time is undefined, and the index must be initialized before it is used as a subscript. The initial value of an index is assigned with:  The PERFORM statement with the VARYING phrase, or  The SEARCH statement with the ALL phrase, or  The SET statement. An index-name can only be referenced by a PERFORM, SET, or SEARCH statement, as a parameter in the USING phrase in a CALL statement, or in a relational condition comparison. The use of an integer or data-name as a subscript referencing a table element or an item within a table element does not cause the alteration of any index associated with that table. An index-name can be used to reference only the table to which it is associated by the INDEXED BY phrase. Data that is arranged in the form of a table is often searched. The SEARCH statement provides facilities for producing serial and non-serial (for example, binary) searches. It is used to search for a table element that satisfies a specific condition and to adjust the value of the associated index to indicate that table element. To be valid during execution, an index value must correspond to a table element occurrence of neither less than one, nor greater than the highest permissible occurrence number. ═══ 4.19.3.3. Relative Subscripting ═══ In relative subscripting, the name of a table element is followed by a subscript of the form data-name or index-name followed by the operator + or -, and an unsigned integer literal. The operator + and - must be preceded and followed by a space. If the subscript contains a data-name, the value of the subscript is the same as if the data-name had been set up of down by the value of the integer. If the subscript contains an index-name, the integer is considered to be an occurence number, and is converted to an index value before being added to or subtracted from the index-name. The use of relative indexing does not cause the object program to alter the value of the index. The value of an index can be made accessible to an object program by storing the value in an index data-item. Index data-items are described in the program by a data description entry containing a USAGE IS INDEX clause. The index value is moved to the index data-item by the execution of a SET statement. A valid index value must correspond to a table element occurrence of not less than one, nor greater than the highest permissible occurrence number. ═══ 4.19.4. Reference Modification ═══ Reference modification resembles the use of substringing in other computer languages. Reference modification defines a data item by specifying a starting position and length for the item. ┌─── REFERENCE MODIFICATION - FORMAT ──────────────────────────────────────────┐ │ │ │ >──data-name-1──(──leftmost-character-position:──┬────────┬──)──> │ │ └─length─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Reference modification is generally allowed anywhere an identifier referencing an alphanumeric data item is allowed. Each character of a data item referenced by data-name-1 is assigned an ordinal number incrementing by one from the leftmost position to the rightmost position. The leftmost position is assigned the ordinal number of one. If the data description entry for data-name-1 contains a SIGN IS SEPARATE clause, the sign position is assigned an ordinal number within that data item. Reference modification creates a unique data item which is a subset of the data item referenced by data-name-1. This unique data item is considered an elementary item without the JUSTIFIED clause. When data-name-1 is reference-modified, the unique data item has the same class and category as that defined for the data item referenced by data-name-1; however, if the category of data-name-1 is numeric, numeric-edited, or alphanumeric-edited, the unique data item has the class and category alphanumeric. If length is not specified, the unique data item created extends from and includes the character identified by the leftmost-character position up to and including the rightmost character of the data item referenced by data-name-1. Related Information:  Evaluation of Operands  Range Errors  Restrictions on Reference Modification  Reference Modification Example. ═══ 4.19.4.1. Evaluation of Operands ═══ Reference modification for an operand is evaluated as follows:  If subscripting is specified for the operand, the reference modification is evaluated immediately after evaluation of the subscript.  If subscripting is not specified for the operand, the reference modification is evaluated at the time subscripting would be evaluated if subscripts had been specified. ═══ 4.19.4.2. Reference Modification Example ═══ This example transfers the first 25 characters in the variable whole-name to the variable last-name. MOVE whole-name(1:25) TO last-name ═══ 4.19.4.3. Range Errors ═══ An out-of-range reference modification component, such as a leftmost-character-position of zero, causes system message to be generated. This is the same message that signals errors in subscript ranges and character-string boundaries. (This message is generated only when the RANGE option is specified on the CRTCBLMOD or CRTBNDCBL command.) ═══ 4.19.4.4. Restrictions on Reference Modification ═══ -----IBM Extension----- The INDICATORS phrase does not support reference modification. ---End of IBM Extension--- The following restrictions apply to the statements listed: Statement Restriction STRING You cannot reference modify identifier-3. UNSTRING You cannot reference modify identifier-1. START You can reference modify last occurrence of data-name-1 only. ═══ 4.20. Scope of Names ═══ This section contains a brief description of the types of COBOL names, followed by the rules for name scoping. data-name A data-name names a data item. file-name A file-name names a file connector. record-name A record-name names a record. condition-name A condition-name associates a value with a conditional variable. program-name A program-name names a program, either external or internal (nested). See Conventions for Program-Names. section-name A section-name names a section in the Procedure Division. paragraph-name A paragraph-name names a paragraph in the Procedure Division. library-name A library-name names a COBOL library that is to be used by the compiler for a given source program compilation. text-name A text-name identifies library text. alphabet-name An alphabet-name assigns a name to a specific character set and/or collating sequence in the SPECIAL-NAMES paragraph of the Environment Division. class-name A class-name assigns a name to the preposition in the SPECIAL-NAMES paragraph of the Environment Division for which a truth value can be defined. mnemonic-name A mnemonic-name assigns a user-defined word to an implementer-name. symbolic-character A symbolic-character specifies a user-defined figurative constant. index-name An index-name names an index associated with a specific table. Related Information:  Nested Programs  Global and Local Names  External and Internal Objects  Resolution of Names. ═══ 4.20.1. Nested Programs ═══ A COBOL program may contain other COBOL programs. The contained (or nested) programs may themselves contain yet other programs. A contained program may be directly or indirectly contained within a program. Nested Program Structure with Directly and Indirectly Contained Programs describes a program structure with directly and indirectly contained programs. Nested Program Structure with Directly and Indirectly Contained Programs ┌─────────ID DIVISION. X is the outermost program and │ PROGRAM-ID. X. directly contains X1 and X2, ──│ PROCEDURE DIVISION. and indirectly contains │ DISPLAY "I'm in X" X11 and X12. │ CALL "X1" │ CALL "X2" │ STOP RUN. │ │ ┌──────ID DIVISION. X1 is directly contained │ │ PROGRAM-ID. X1. in X and directly contains────┼─│ PROCEDURE DIVISION. X11 and X12. │ │ DISPLAY "I'm in X1" │ │ CALL "X11" │ │ CALL "X12" │ │ EXIT PROGRAM. │ │ │ │ ID DIVISION. X11 is directly │ │ ┌───PROGRAM-ID. X11. contained in X1 ─────────┼──┼─│ PROCEDURE DIVISION. and indirectly │ │ │ DISPLAY "I'm in X11" contained in X. │ │ │ EXIT PROGRAM. │ │ └───END PROGRAM X11. │ │ │ │ ┌───ID DIVISION. X12 is directly │ │ │ PROGRAM-ID. X12. contained in X1 ─────────┼──┼─│ PROCEDURE DIVISION. and indirectly │ │ │ DISPLAY "I'm in X12" contained in X. │ │ │ EXIT PROGRAM. │ │ └───END PROGRAM X12. │ │ │ └──────END PROGRAM X1. │ │ ┌──────ID DIVISION. X2 is directly contained ─────┼─│ PROGRAM-ID. X2. in X. │ │ PROCEDURE DIVISION. │ │ DISPLAY "I'm in X2" │ │ EXIT PROGRAM. │ └──────END PROGRAM X2. │ └─────────END PROGRAM X. The same user-defined word may be used in different programs to define different objects. In a particular program, a reference to an object always refers to the object defined in that program. ═══ 4.20.2. Global and Local Names ═══ Names can have global or local attributes. Some names are always global; other names are always local; and some names are either local or global depending upon specifications in the program in which the names are declared. A program cannot reference any condition-name, data-name, file-name, index-name, paragraph-name, record-name, or section-name declared in any program it contains. A global name may be used to refer to the object with which it is associated either from within the program in which the global name is declared or from within any other program which is contained in the program which declares the global name. A local name, however, may be used only to refer to the object with which it is associated from within the program in which the local name is declared. If a data-name, a file-name, record-name, or a condition-name declared in a data description entry is not global, the name is local. Note: Specific rules sometimes prohibit specification of the GLOBAL clause for certain data description, file description, or record description entries. data-name A data-name is global if the GLOBAL clause is specified either in the data description entry by which the data-name is declared or in another entry to which that data description entry is subordinate. file-name A file-name is global if the GLOBAL clause is specified in the file description entry for that file-name. Two programs in a run unit can reference common file connectors in the following circumstances: 1. An external file connector can be referenced from any program that describes that file connector. 2. If a program is contained within another program, both programs can refer to a common file connector by referring to an associated global file-name declared either in the containing program or in any program that directly or indirectly contains the containing program. record-name A record-name is global if the GLOBAL clause is specified in the record description entry by which the record-name is declared or, in the case of record description entries in the File Section, if the GLOBAL clause is specified in the file description entry for the file-name associated with the record description entry. condition-name A condition-name, when declared in the data description entry, is global if that entry is subordinate to another entry in which the GLOBAL clause is specified. A condition-name, when declared within the Configuration Section, is always global. program-name A program-name is neither local nor global. See Conventions for Program-Names. section-name and paragraph-name These names are always local. library-name and text-name These names are external to the program and can be referenced by any COBOL program, provided that the compiler system supports the associated library and the entities referenced are known to that system. alphabet-name An alphabet-name is always global. class-name A class-name is always global. mnemonic-name A mnemonic-name is always global. index-name If a data item possessing the global attribute includes a table accessed with an index, that index also possesses the global attribute. Therefore, the scope of an index-name is identical to that of the data-name which names the table whose index is named by that index-name and the scope of name rules for data-names apply. Index-names cannot be qualified. ═══ 4.20.3. External and Internal Objects ═══ Accessible data items usually require that certain representations of data be stored. File connectors usually require that certain information concerning files be stored. The storage associated with a data item or a file connector may be external or internal to the program in which the object is declared. A data item or file connector is external if the storage associated with that object is associated with the run unit rather than with any particular program within the run unit. An external object may be referenced by any program in the run unit which describes the object. References to an external object from different programs using separate descriptions of the object with the same name are always to the same object. In a run unit, there is only one representative of an external object. An object is internal if the storage associated with that object is associated only with the program which describes the object. External and internal objects may have either global or local names. A data record described in the Working-Storage Section is given the external attribute by the presence of the EXTERNAL clause in its data description entry. Any data item described by a data description entry subordinate to an entry describing an external record also attains the external attribute. If a record or data item does not have the external attribute, it is part of the internal data of the program in which it is described. A file connector is given the external attribute by the presence of the EXTERNAL clause in the associated file description entry. If the file connector does not have the external attribute, it is internal to the program in which the associated file-name is described. The EXTERNAL clause cannot be specified for sort-merge files. The data records described subordinate to a file description entry which does not contain the EXTERNAL clause, or those subordinate to a sort-merge file description entry, as well as any data items described subordinate to the data description entries for such records, are always internal to the program describing the file-name. If the EXTERNAL clause is included in the file description entry, the data records and the data items attain the external attribute. Data records and subordinate data items described in the Linkage Section of a program are always considered to be internal to the program describing that data. Special considerations apply to data described in the Linkage Section whereby an association is made between the data records described and other data items accessible to other programs. ═══ 4.21. Data Attribute Specification ═══ Explicit data attributes are those you specify in actual COBOL coding. Implicit data attributes are default values. If you do not explicitly code a data attribute, the compiler assumes a default value. For example, you need not specify the USAGE of a data item. If it is omitted, the default is USAGE DISPLAY, which is the implicit data attribute. If, however, you specify USAGE DISPLAY in COBOL coding, it becomes an explicit data attribute. ═══ 4.22. Resolution of Names ═══ When a program, program B, is directly or indirectly contained within another program, program A, both programs may define objects using the same user-defined word. (Objects include, for example, a condition-name, a data-name, a file-name, or a record-name.) When such a duplicated name is referenced in program B, the following rules are used to determine the referenced object: 1. The referenced object is identified from the set of all names which are defined in program B and all global names defined in the directly containing program A and in any programs which directly or indirectly contain program A. Using this set of names, the normal rules for qualification and any other rules for uniqueness of reference are applied until one or more objects is identified. 2. If only one object is identified, it is the referenced object. 3. If more than one object is identified, no more than one of them can have a name local to program B unless each reference to them can be made unique with appropriate qualification. If zero or one of the objects has a name local to program B, the following rules apply:  If the name is declared in program B, the object in program B is the referenced object.  Otherwise, if program A is contained within another program, the referenced object is: - The object in program A if the name is declared in program A. - The object in the containing program if the name is not declared in program A and is declared in the program containing program A. This rule is applied to further containing programs until a single valid object has been found. Related Information:  Conventions for Program-Names ═══ 4.22.1. Conventions for Program-Names ═══ The program-name of a program is specified in the PROGRAM-ID paragraph of the program's Identification Division. A program-name can be referenced only by the:  CALL statement  CANCEL statement  END PROGRAM header -----IBM Extension-----  SET statement ---End of IBM Extension--- Names of programs constituting a run unit are not necessarily unique, but when two programs in a run unit are identically named, at least one of those two programs must be directly or indirectly contained within another separately compiled program which does not contain the other of those two programs. The following rules regulate the scope of a program-name.  If the program-name is that of a program which does not possess the COMMON attribute and which is directly contained within another program, that program-name can be referenced only by statements included in that containing program.  If the program-name is that of a program which possesses the COMMON attribute and that is directly contained within another program, that program-name can be referenced only by statements included in that containing program and any programs directly or indirectly contained within that containing program, except that program possessing the COMMON attribute and any programs contained within it.  If the program-name is that of an outermost COBOL program in a separately compiled module object, that program-name can be referenced by statements included in any other program in the run unit, except programs it directly or indirectly contains. Related Information:  Rules Regulating the Scope of Program Names ═══ 4.22.1.1. Rules Regulating the Scope of Program Names ═══ The following rules apply to referencing a program-name of a program that is contained within another program. For this discussion, we will say that Program-A directly contains Program-B and Program-C, Program-C directly contains Program-D and Program-F, and Program-D directly contains Program-E. ┌────────────────────────────────────────┐ │ Program-A │ │ ┌─────────────────────────────────┐ │ │ │ Program-B │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─────────────────────────────────┘ │ │ │ │ │ │ ┌─────────────────────────────────┐ │ │ │ Program-C │ │ │ │ ┌──────────────────────────┐ │ │ │ │ │ Program-D │ │ │ │ │ │ │ │ │ │ │ │ ┌─────────────────────┐ │ │ │ │ │ │ │ Program-E │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─────────────────────┘ │ │ │ │ │ └──────────────────────────┘ │ │ │ │ ┌──────────────────────────┐ │ │ │ │ │ Program-F │ │ │ │ │ │ │ │ │ │ │ └──────────────────────────┘ │ │ │ └─────────────────────────────────┘ │ └────────────────────────────────────────┘ If Program-D does not possess the COMMON attribute, then Program-D can only be referenced by the program that directly contains Program-D, that is, Program-C. If Program-D does possess the COMMON attribute, then Program-D can be referenced by Program-C since it contains Program-D, and by any programs contained in Program-C except for program D and programs contained in Program-D. In other words, if program-D possesses the COMMON attribute, Program-D can be referenced in Program-C and Program-F, but not by statements in Program-E, Program-A, Program-B, or Program-D. ═══ 5. Transfer of Control ═══ In the Procedure Division, unless there is an explicit control transfer or there is no next executable statement, program flow transfers control from statement to statement in the order in which the statements are written. This normal program flow is an implicit transfer of control. In addition to the implicit transfers of control between consecutive statements, implicit transfer of control also occurs when the normal flow is altered without the execution of a procedure branching statement. The following examples show implicit transfers of control, overriding statement-to-statement transfer of control:  After execution of the last statement of a COBOL procedure being executed under control of another COBOL statement, control implicitly transfers. (COBOL statements that control COBOL procedure execution are, for example: MERGE, PERFORM, SORT, and USE.)  During SORT or MERGE statement execution, when control is implicitly transferred to an INPUT or OUTPUT procedure.  During execution of any COBOL statement that causes execution of a declarative procedure, control is implicitly transferred to that procedure.  At the end of execution of any declarative procedure, control is implicitly transferred back to the control mechanism associated with the statement that caused its execution.  When a program that has no procedure division or any nondeclarative sections is called, the calling program issues an implicit EXIT PROGRAM. COBOL provides explicit control transfers through the execution of any procedure branching or conditional statement. ═══ 5.1. Next Executable Statement ═══ Note: The term "next executable statement" refers to the next COBOL statement to which control is transferred, according to the rules given above. There is no next executable statement under these circumstances:  When the program contains no Procedure Division.  Following the last statement in a declarative section when the paragraph in which it appears is not being executed under the control of some other COBOL statement.  Following the last statement in a program when the paragraph in which it appears is not being executed under the control of some other COBOL statement in that program.  Following the last statement in a declarative section when the statement is in the range of an active PERFORM statement executed in a different section and this last statement of the declarative section is not also the last statement of the procedure that is the exit of the active PERFORM statement.  Following a STOP RUN, EXIT PROGRAM, or GOBACK statement that transfers control outside the COBOL program.  Following the END PROGRAM header. When there is no next executable statement and control is not transferred outside the COBOL program, the program flow of control is undefined unless the program execution is in the nondeclarative procedures portion of a program under control of a CALL statement, in which case an implicit EXIT PROGRAM statement is executed. ═══ 6. General Structure ═══ A COBOL source program is a syntactically correct set of COBOL statements. A COBOL source program may contain other COBOL source programs. These contained programs may reference some of the resources of the programs within with they are contained. This concept of contained programs is known as nesting and the contained program is known as a nested program. A nested program may be directly or indirectly contained in another program. For example, if program B is contained in Program A, it is directly contained if there is no program in program A that also contains program B. Program B is indirectly contained in program A if there exists a program contained in Program A that also contains program B. With the exception of compiler-directing statements and the END PROGRAM header, the statements, enties, paragraphs, and sections of a COBOL source program are grouped into the following four divisions:  Identification Division  Environment Division  Data Division  Procedure Division The end of a COBOL source program is indicated by either the END PROGRAM header, if specified, or by the absence of additional source program lines. The following figure briefly illustrates the general structure of a COBOL program. ┌─── COBOL SOURCE PROGRAM-FORMAT ──────────────────────────────────────────────┐ │ │ │ >>──┬─IDENTIFICATION─┬──DIVISION.──PROGRAM-ID.──┬─program-name-1─┬─────────> │ │ │ (1) │ │ (1) │ │ │ └─ID─────────────┘ └─literal-1──────┘ │ │ │ │ >──┬──────────────────────────────┬──.─────────────────────────────────────> │ │ └─┬────┬──INITIAL──┬─────────┬─┘ │ │ └─IS─┘ └─PROGRAM─┘ │ │ │ │ >──┬─────────────────────────────────┬─────────────────────────────────────> │ │ └─identification-division-content─┘ │ │ │ │ >──┬─────────────────────────────────────────────────────┬─────────────────> │ │ └─ENVIRONMENT DIVISION.──environment-division-content─┘ │ │ │ │ >──┬───────────────────────────────────────┬───────────────────────────────> │ │ └─DATA DIVISION.──data-division-content─┘ │ │ │ │ >──┬─────────────────────────────────────────────────┬─────────────────────> │ │ └─PROCEDURE DIVISION.──procedure-division-content─┘ │ │ │ │ >──┬─────────────────────────────────────────────────────────────────┬──>< │ │ └─┬────────────────────────┬──END PROGRAM──┬─program-name-1─┬──.─┘ │ │ │ ┌────────────────────┐ │ │ (1) │ │ │ │  │ │ │ │ │ │ └───┤ nested program ├─┴─┘ └─literal-1──────┘ │ │ │ │ NESTED PROGRAM: │ │ ├──┬─IDENTIFICATION─┬──DIVISION.──PROGRAM-ID.──┬─program-name-2─┬──────────> │ │ │ (1) │ │ (1) │ │ │ └─ID─────────────┘ └─literal-2──────┘ │ │ │ │ >──┬──────────────────────────────────────────────┬──.─────────────────────> │ │ └─┬────┬──┬─COMMON──┬─────────┬─┬──┬─────────┬─┘ │ │ └─IS─┘ │ └─INITIAL─┘ │ └─PROGRAM─┘ │ │ └─INITIAL──┬────────┬─┘ │ │ └─COMMON─┘ │ │ │ │ >──┬─────────────────────────────────┬─────────────────────────────────────> │ │ └─identification-division-content─┘ │ │ │ │ >──┬─────────────────────────────────────────────────────┬─────────────────> │ │ └─ENVIRONMENT DIVISION.──environment-division-content─┘ │ │ │ │ >──┬───────────────────────────────────────┬───────────────────────────────> │ │ └─DATA DIVISION.──data-division-content─┘ │ │ │ │ >──┬─────────────────────────────────────────────────┬─────────────────────> │ │ └─PROCEDURE DIVISION.──procedure-division-content─┘ │ │ │ │ >──┬────────────────────────┬──END PROGRAM──┬─program-name-2─┬──.──┤ │ │ │ ┌────────────────────┐ │ │ (1) │ │ │ │  │ │ │ │ │ │ └───┤ nested program ├─┴─┘ └─literal-2──────┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 6.1. END PROGRAM Header ═══ The END PROGRAM header indicates the end of a named COBOL source program. It also separates each program in a sequence of source pograms. An END PROGRAM header is optional for the last program in a sequence of source programs only if that program does not contain any nested programs. ┌─── END PROGRAM HEADER - FORMAT ──────────────────────────────────────────────┐ │ │ │ >>──END PROGRAM──┬─program-name-1─┬──.──>< │ │ │ (1) │ │ │ └─literal-1──────┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 7. Identification Division ═══ The Identification Division must be the first division in every COBOL source program. It names the program and may include the date the program was written, the date of compilation, and other such documentary information about the program. ┌─── IDENTIFICATION DIVISION - FORMAT ─────────────────────────────────────────┐ │ │ │ >>──┬─IDENTIFICATION─┬──DIVISION.──PROGRAM-ID.──┬─program-name─┬───────────> │ │ │ (1) │ │ (1) │ │ │ └─ID─────────────┘ └─literal──────┘ │ │ │ │ >──┬─────────────────────────────────────────────────┬──.──────────────────> │ │ │ (2) │ │ │ └─┬────┬──┬─COMMON─────┬─────────┬─┬──┬─────────┬─┘ │ │ └─IS─┘ │ └─INITIAL─┘ │ └─PROGRAM─┘ │ │ └─INITIAL──┬────────┬────┘ │ │ └─COMMON─┘ │ │ │ │ >──┬────────────────────────────────┬──────────────────────────────────────> │ │ └─AUTHOR.──┬───────────────────┬─┘ │ │ │ ┌───────────────┐ │ │ │ │  │ │ │ │ └───comment-entry─┴─┘ │ │ │ │ >──┬──────────────────────────────────────┬────────────────────────────────> │ │ └─INSTALLATION.──┬───────────────────┬─┘ │ │ │ ┌───────────────┐ │ │ │ │  │ │ │ │ └───comment-entry─┴─┘ │ │ │ │ >──┬──────────────────────────────────────┬────────────────────────────────> │ │ └─DATE-WRITTEN.──┬───────────────────┬─┘ │ │ │ ┌───────────────┐ │ │ │ │  │ │ │ │ └───comment-entry─┴─┘ │ │ │ │ >──┬───────────────────────────────────────┬───────────────────────────────> │ │ └─DATE-COMPILED.──┬───────────────────┬─┘ │ │ │ ┌───────────────┐ │ │ │ │  │ │ │ │ └───comment-entry─┴─┘ │ │ │ │ >──┬──────────────────────────────────┬──>< │ │ └─SECURITY.──┬───────────────────┬─┘ │ │ │ ┌───────────────┐ │ │ │ │  │ │ │ │ └───comment-entry─┴─┘ │ │ │ │ NOTES: │ │ (1) IBM Extension │ │ │ │ (2) Allowed only for nested COBOL programs │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The first paragraph of the Identification Division must be the PROGRAM-ID paragraph. The other paragraphs are optional, but, when written, must appear in the order shown in the format. -----IBM Extension----- The abbreviation ID DIVISION may be substituted for the standard division header, and the optional paragraphs may be in any order. ---End of IBM Extension--- Related Information:  Identification Division Coding Example. ═══ 7.1. Coding Example ═══ IDENTIFICATION DIVISION. PROGRAM-ID. IDSAMPLE. AUTHOR. PROGRAMMER NAME. INSTALLATION. COBOL DEVELOPMENT CENTER. DATE-WRITTEN. 12/02/94. DATE-COMPILED. 12/09/94 12:57:53. SECURITY. NON-CONFIDENTIAL. ═══ 7.2. PROGRAM-ID Paragraph ═══ The PROGRAM-ID paragraph specifies the name of the COBOL program. For an outermost program, it can also specify the name of the program object (*PGM) or module object (*MODULE), or both. It is required and must be the first paragraph in the Identification Division. The name by which the program object is known to the system can be overridden by the PGM parameter of the CRTBNDCBL command. The name by which the module object is known can be overridden by the MODULE parameter of the CRTCBLMOD command. ═══ 7.2.1. program-name ═══ A user-defined word that identifies your program or module object to the system. For program and module objects, only the first 10 characters of program-name are used as the identifying name of the object. For an ILE procedure name, the first 250 characters of program-name are used. If the *MONOPRC option is specified on the CRTBNDCBL or CRTCBLMOD command, the first character of program-name is forced to be alphabetic; if it is numeric, it is converted as follows: 0 to J 1 through 9 to A through I If a hyphen is in positions 2 through 10, it is converted to zero (0). ═══ 7.2.2. literal ═══ Must be a nonnumeric literal. A nonnumeric literal without the enclosing delimiters becomes the program-name. The same rules apply for forming module, program, and procedure names as defined above under program-name. If the *MONOPRC option is specified, however, lowercase letters in the literal are converted to their uppercase equivalents. ═══ 7.2.3. COMMON clause ═══ The COMMON clause allows the program named by program-name to be called by its siblings and by programs contained within the siblings. The COMMON clause can be used only in nested programs. ═══ 7.2.4. INITIAL clause ═══ Specifies that when program-name is called, program-name and any programs contained within it are set to their initial state. (All working storage items are reset to their initial values and all INTERNAL files are closed.) A program is set to its initial state:  The first time the program is called in a run unit  Every time the program is called, if it possesses the INITIAL attribute  The first time the program is called after the execution of a CANCEL statement referencing the program or a CANCEL statement referencing a program that directly or indirectly contains the program  The first time the program is called after the execution of a CALL statement referencing a program that possesses the INITIAL attribute, and that directly or indirectly contains the program. For example, if program A calls program B, and program B has the INITIAL attribute and also contains program C, program C will be set to its initial state the first time that it is called after A called B. When a program is set to its initial state, the following occur:  The program's internal data contained in the Working-Storage Section are initialized. If a VALUE clause is used in the description of the data item, the data item is initialized to the defined value. If a VALUE clause is not associated with a data item, the initial value of the data item is set to the system default depending on whether the *STDINZ or *NOSTDINZ option is specified on the CRTCBLMOD or CRTBNDCBL command.  Files with internal file connectors associated with the program are not in the open mode.  The control mechanisms for all PERFORM statements contained in the program are set to their initial states.  The altered GO TO statements contained in the program are set to their initial state. ═══ 7.2.5. comment-entry ═══ The comment-entry in any of the optional paragraphs may be any combination of characters from the character set of the computer. Do not confuse the comment-entry with a comment line. (The latter is indicated by a slash or asterisk in the indicator area.) The comment-entry is written in Area B on one or more lines. Comment-entries serve only as documentation; they do not affect the meaning of the program. A hyphen in the indicator area (column 7) is not permitted in comment-entries. The paragraph name DATE-COMPILED and any comment-entry associated with it are replaced during compilation with a paragraph of the form: DATE-COMPILED. current date. The first eight lines of the comment-entry in the SECURITY paragraph will form the copyright information in the created module object. -----IBM Extension----- A comment-entry may contain the *CBL, *CONTROL, EJECT, SKIP1, SKIP2, SKIP3, or TITLE statements anywhere on the line. These statements will be acted on if they are alone on a line within the comment-entry, and they will not terminate the comment-entry. Comments may combine double-byte and single-byte character-strings. Multiple lines are allowed in a comment-entry containing double-byte strings. Note: Mixed strings are described under Character-Strings. ---End of IBM Extension--- ═══ 8. Environment Division ═══ The Environment Division has two sections:  The Configuration Section  The Input-Output Section. The Environment Division is optional in a COBOL source program. ┌─── ENVIRONMENT DIVISION - FORMAT ────────────────────────────────────────────┐ │ │ │ >>──ENVIRONMENT DIVISION.──────────────────────────────────────────────────> │ │ │ │ >──┬──────────────────────────────────────────────────────────────┬────────> │ │ └─CONFIGURATION SECTION.──┤ Configuration Section Paragraphs ├─┘ │ │ │ │ >──┬────────────────────────────────────────────────────────────┬──>< │ │ └─INPUT-OUTPUT SECTION.──┤ Input-Output Section Paragraphs ├─┘ │ │ │ │ CONFIGURATION SECTION PARAGRAPHS: │ │ ├──┬─────────────────────────────────────────────┬─────────────────────────> │ │ └─SOURCE-COMPUTER.──┬───────────────────────┬─┘ │ │ └─source-computer-entry─┘ │ │ │ │ >──┬─────────────────────────────────────────────┬─────────────────────────> │ │ └─OBJECT-COMPUTER.──┬───────────────────────┬─┘ │ │ └─object-computer-entry─┘ │ │ │ │ >──┬─────────────────────────────────────────┬──┤ │ │ └─SPECIAL-NAMES.──┬─────────────────────┬─┘ │ │ └─special-names-entry─┘ │ │ │ │ INPUT-OUTPUT SECTION PARAGRAPHS: │ │ ┌────────────────────┐ │ │  │ │ │ ├──FILE-CONTROL.────file-control-entry─┴───────────────────────────────────> │ │ │ │ >──┬─────────────────────────────────────────┬──┤ │ │ └─I-O-CONTROL.──┬───────────────────────┬─┘ │ │ │ ┌───────────────────┐ │ │ │ │  │ │ │ │ └───i-o-control-entry─┴─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Related Information:  Environment Division Coding Example. ═══ 8.1. Configuration Section ═══ The Configuration Section is optional. When specified, it can describe the computer on which the source program is compiled and the computer on which the object program is executed. However, the Configuration Section must not be specified in a nested program. The entries specified in the Configuration Section of a program apply to all programs contained within that program. In addition, the Configuration Section can:  Relate IBM-defined environment-names to user-defined mnemonic names  Specify the collating sequence  Specify a substitution for the currency sign  Interchange the functions of the comma and the period in PICTURE clauses and numeric literals  Relate alphabet-names to character sets or collating sequences  Relate class names to sets of characters  Specify the type of linkage to be made on a CALL, CANCEL, or SET...ENTRY statement. Each paragraph must contain one, and only one, separator period immediately after the last entry in the paragraph. The Configuration Section of the Environment Division contains three paragraphs:  SOURCE-COMPUTER paragraph  OBJECT-COMPUTER paragraph  SPECIAL-NAMES paragraph. ═══ 8.1.1. Coding Example ═══ ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. IBM-AS400. OBJECT-COMPUTER. IBM-AS400. SPECIAL-NAMES. C01 IS TOP-OF-PAGE. ═══ 8.2. SOURCE-COMPUTER Paragraph ═══ The SOURCE-COMPUTER paragraph describes the computer on which the source program is to be compiled. ┌─── SOURCE-COMPUTER PARAGRAPH - FORMAT ───────────────────────────────────────┐ │ │ │ >>──SOURCE-COMPUTER.──┬────────────────────────────────────────────────┬──>< │ │ └─computer-name──┬──────────────────────────┬──.─┘ │ │ └─┬──────┬──DEBUGGING MODE─┘ │ │ └─WITH─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Except for the WITH DEBUGGING MODE clause, the SOURCE-COMPUTER paragraph is syntax checked, and has no effect on the execution of the program. ═══ 8.2.1. WITH DEBUGGING MODE ═══ Activates a compile-time switch for debugging lines written in the source program. A debugging line is a statement that is compiled only when the compile-time switch is activated. Debugging lines allow you, for example, to check the value of a data-name at certain points in a procedure. The WITH DEBUGGING MODE clause causes any USE FOR DEBUGGING procedure to be compiled. Without this clause, these procedures are treated as comments and ignored. To specify a debugging line in your program, code a 'D' or 'd' in column 7 (indicator area). You may include successive debugging lines, but each must have a 'D' or 'd' in column 7 and you may not break character strings across lines. All your debugging lines must be written so that the program is syntactically correct, whether the debugging lines are compiled or treated as comments. The presence or absence of the DEBUGGING MODE clause is determined after all COPY statements are processed. See COPY Statement for details. You may code debugging lines in the Environment (after the OBJECT-COMPUTER paragraph), Data, or Procedure Divisions. If a debugging line contains only spaces in Area A and in Area B, it is treated the same as a blank line. If the WITH DEBUGGING MODE clause is omitted, debug lines are treated as comment lines. ═══ 8.3. OBJECT-COMPUTER Paragraph ═══ The OBJECT-COMPUTER paragraph specifies the system for which the object program is designated. ┌─── OBJECT-COMPUTER PARAGRAPH - FORMAT ───────────────────────────────────────┐ │ │ │ >>──OBJECT-COMPUTER.──┬─────────────────────────────┬──>< │ │ └─computer-name──┤ Entry ├──.─┘ │ │ │ │ ENTRY: │ │ ├──┬──────────────────────────────────────────────┬────────────────────────> │ │ │ (1) │ │ │ └─MEMORY─────┬──────┬──integer──┬─WORDS──────┬─┘ │ │ └─SIZE─┘ ├─CHARACTERS─┤ │ │ └─MODULES────┘ │ │ │ │ >──┬─────────────────────────────────────────────────────────────┬─────────> │ │ └─┬─────────┬──┬───────────┬──SEQUENCE──┬────┬──alphabet-name─┘ │ │ └─PROGRAM─┘ └─COLLATING─┘ └─IS─┘ │ │ │ │ >──┬──────────────────────────────────────────┬──┤ │ │ │ (1) │ │ │ └─SEGMENT-LIMIT─────┬────┬──segment-number─┘ │ │ └─IS─┘ │ │ │ │ NOTE: │ │ (1) Syntax-checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.3.1. MEMORY SIZE ═══ The amount of main storage needed to run the object program. The MEMORY SIZE clause is syntax checked only. ═══ 8.3.2. PROGRAM COLLATING SEQUENCE IS ═══ The collating sequence used in this program (and any programs it may contain) is the collating sequence associated with the specified alphabet-name. PROGRAM COLLATING SEQUENCE determines the truth value of the following nonnumeric comparisons:  Those explicitly specified in relation conditions  Those explicitly specified in condition-name conditions. The PROGRAM COLLATING SEQUENCE clause also applies to any nonnumeric merge or sort keys, unless the COLLATING SEQUENCE phrase is specified in the MERGE or SORT statement. When the PROGRAM COLLATING SEQUENCE clause is omitted, the EBCDIC collating sequence is used. ═══ 8.3.3. SEGMENT-LIMIT IS ═══ Determines which segments will be considered as permanent segments of the object program. This clause is syntax checked only. ═══ 8.4. SPECIAL-NAMES Paragraph ═══ The SPECIAL-NAMES paragraph:  Relates IBM-specified environment-names to user-defined mnemonic-names.  Relates alphabet-names to character sets or collating sequences.  Relates class names to sets of characters.  Specifies a substitute character for the currency sign.  Specifies that the functions of the comma and decimal point are to be interchanged in PICTURE clauses and numeric literals. -----IBM Extension-----  Specifies that ACCEPT or DISPLAY statements are treated as extended ACCEPT or DISPLAY statements, or as requests to the dynamic screen manager session services APIs.  Specifies additional functions associated with ACCEPT statements.  Specifies the type of linkage used for a CALL or CANCEL of a program, and for setting a procedure-pointer with the SET statement. ---End of IBM Extension--- ┌─── SPECIAL-NAMES PARAGRAPH - FORMAT ─────────────────────────────────────────┐ │ │ │ >>──SPECIAL-NAMES.─────────────────────────────────────────────────────────> │ │ │ │ ┌───────────────────────────────────────────────────────────────────┐ │ │  │ │ │ >────┬───────────────────────────────────────────────────────────────┬─┴───> │ │ ├─environment-name-1──┬────┬──mnemonic-name-1───────────────────┤ │ │ │ └─IS─┘ │ │ │ └─environment-name-2──┬─┬────┬──mnemonic-name-2──┬──────────┬─┬─┘ │ │ │ └─IS─┘ └─┤ cond ├─┘ │ │ │ └─┤ cond ├───────────────────┴──────┴───┘ │ │ │ │ ┌───────────────────┐ ┌────────────────┐ │ │  │  │ │ │ >───┬─────────────────┬┴───┬──────────────┬┴──┬───────────────────┬────────> │ │ └─ALPHABET Clause─┘ └─CLASS Clause─┘ │ (1)│ │ │ └─CONSOLE Clause────┘ │ │ │ │ >──┬───────────────────────┬──┬──────────────────────┬─────────────────────> │ │ │ (1)│ └─CURRENCY SIGN Clause─┘ │ │ └─CRT STATUS Clause────┘ │ │ │ │ >──┬──────────────────┬──┬──────────────────────┬──────────────────────────> │ │ │ (1)│ └─DECIMAL-POINT Clause─┘ │ │ └─CURSOR Clause────┘ │ │ │ │ ┌──────────────────────────┐ │ │  │ │ │ >───┬────────────────────────┬┴──┬──────┬──>< │ │ │ (1)│ │ (2)│ │ │ └─LINKAGE TYPE Clause────┘ └─.────┘ │ │ │ │ COND: │ │ ├──┬─ON────┬────────┬──┬────┬──condition-1──┬────────────────┬─┬──┤ │ │ │ └─STATUS─┘ └─IS─┘ └─┤ off phrase ├─┘ │ │ │ └─┤ off phrase ├──┬────────────────────────┴────────────┴─┬─┘ │ │ └─ON────┬────────┬──┬────┬──condition-1─┘ │ │ └─STATUS─┘ └─IS─┘ │ │ │ │ OFF PHRASE: │ │ ├──OFF───┬────────┬──┬────┬──condition-2──┤ │ │ └─STATUS─┘ └─IS─┘ │ │ │ │ NOTES: │ │ (1) IBM Extension │ │ │ │ (2) The separator period must be used if any of the optional clauses are │ │ selected. Clauses can be entered in any order. │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Related Information:  SPECIAL-NAMES Paragraph Coding Example. ═══ 8.4.1. environment-name-1 ═══ System devices or standard system actions taken by the compiler. Choices of Environment-Name-1 and Action Taken shows the actions that are associated with mnemonic-names for environment-name-1. ┌──────────────────────────────────────────────────────────────────────────────┐ │ Choices of Environment-Name-1 and Action Taken │ ├───────────────────┬───────────────────┬──────────────────────────────────────┤ │ ENVIRONMENT-NAME-1│ STATEMENT WHERE │ USAGE │ │ │ MNEMONIC-NAME │ │ │ │ ASSOCIATED WITH │ │ │ │ ENVIRONMENT-NAME │ │ │ │ IS USED │ │ ├───────────────────┼───────────────────┼──────────────────────────────────────┤ │ CSP │ WRITE │ Suppress spacing when printing a │ │ │ │ line. Use only when the device is │ │ │ │ PRINTER. │ ├───────────────────┼───────────────────┼──────────────────────────────────────┤ │ C01 │ WRITE │ Skip to the next page. Use only │ │ │ │ when the device is PRINTER. │ ├───────────────────┼───────────────────┼──────────────────────────────────────┤ │ ATTRIBUTE-DATA │ ACCEPT │ Retrieve attribute data about a │ │ │ │ program device acquired by a trans- │ │ │ │ action file, but only when the file │ │ │ │ is open. │ ├───────────────────┼───────────────────┼──────────────────────────────────────┤ │ I-O-FEEDBACK │ ACCEPT │ Give information about the last I-O │ │ │ │ operation on a file, but only when │ │ │ │ the file is open. │ ├───────────────────┼───────────────────┼──────────────────────────────────────┤ │ OPEN-FEEDBACK │ ACCEPT │ Give information about a file, but │ │ │ │ only when the file is open. │ ├───────────────────┼───────────────────┼──────────────────────────────────────┤ │ CONSOLE, │ ACCEPT, DISPLAY │ Communicate with the system opera- │ │ SYSTEM-CONSOLE │ │ tor's message queue (QSYSOPR). │ ├───────────────────┼───────────────────┼──────────────────────────────────────┤ │ LOCAL-DATA │ ACCEPT, DISPLAY │ Retrieve data from, or move data to │ │ │ │ the local data area created by the │ │ │ │ system for every job. │ ├───────────────────┼───────────────────┼──────────────────────────────────────┤ │ PIP-DATA │ ACCEPT │ Retrieve data from the Program │ │ │ │ Initialization Parameters (PIP) data │ │ │ │ area for programs running as part of │ │ │ │ a prestart job. For more informa- │ │ │ │ tion regarding prestart jobs, see │ │ │ │ the Work Management. │ ├───────────────────┼───────────────────┼──────────────────────────────────────┤ │ REQUESTOR │ ACCEPT, DISPLAY │ Communicate with the user work │ │ │ │ station (interactive jobs) or the │ │ │ │ batch input stream or job log (batch │ │ │ │ jobs). │ ├───────────────────┼───────────────────┼──────────────────────────────────────┤ │ SYSIN │ ACCEPT │ The equivalent of REQUESTOR (for the │ │ │ │ ACCEPT statement only). │ ├───────────────────┼───────────────────┼──────────────────────────────────────┤ │ SYSOUT │ DISPLAY │ The equivalent of REQUESTOR (for the │ │ │ │ DISPLAY statement only). │ └───────────────────┴───────────────────┴──────────────────────────────────────┘ ═══ 8.4.2. environment-name-2 ═══ Environment-name-2 can be defined as UPSI-0 through UPSI-7 or as SYSTEM-SHUTDOWN; UPSI stands for a one-byte User Programmable Status Indicator switch. UPSI-0 through UPSI-7 are COBOL names that identify program switches defined outside the COBOL program at object time. Their contents are considered to be alphanumeric. A value of zero is off; a value of one is on. Each switch represents one byte from the 8-character SWS parameter of the control language CHGJOB, SBMJOB, JOB, and JOBD commands as follows: UPSI-0 First byte (leftmost) UPSI-1 Second byte UPSI-2 Third byte . . . . . . UPSI-7 Eighth byte (rightmost) SYSTEM-SHUTDOWN is an internal switch that is set to ON status when the system operator causes the system to be in a shutdown-pending state or when the job is being canceled in a controlled manner. The associated ON or OFF condition-names can be referenced anywhere a condition-name is valid. Their status cannot be altered by the program. ═══ 8.4.3. mnemonic-name-1, mnemonic-name-2 ═══ Mnemonic-name-1 and mnemonic-name-2 follow the rules of formation for user-defined names. Mnemonic-name-1 can be used in ACCEPT, DISPLAY, and WRITE statements. Mnemonic-name-2 can be referenced only in the SET statement. Mnemonic-name-2 can qualify condition-1 or condition-2 names. Mnemonic-names and environment-names need not be unique. If you choose a mnemonic-name that is also an environment name, its definition as a mnemonic-name takes precedence over its definition as an environment-name for a given reference to such a name. ═══ 8.4.4. ON STATUS IS, OFF STATUS IS ═══ UPSI switches process special conditions within a program, such as year-beginning or year-ending processing. For example, at the beginning of the Procedure Division, an UPSI switch can be tested; if it is ON, the special branch is taken. (See Switch-Status Condition.) ═══ 8.4.5. condition-1, condition-2 ═══ If environment-name-2 references an external switch, the on/off status of that switch can be associated with condition-names, such as condition-1, condition-2. The status of the switch can be obtained through the condition-names. Condition-names follow the rules for user-defined names. At least one character must be alphabetic. The value associated with the condition-name is considered to be alphanumeric. In the Procedure Division, the UPSI switch status is tested through the associated condition-name. Each condition-name is the equivalent of a level-88 item; the associated mnemonic-name, if specified, is considered the conditional variable and can be used for qualification. Any names declared in a program's SPECIAL-NAMES paragraph can be referenced from any contained program. ═══ 8.4.6. Coding Example ═══ This coding example assigns mnemonic-names to some commonly used environment-names in the SPECIAL-NAMES paragraph. SPECIAL-NAMES. SYSTEM-CONSOLE IS SYSTM REQUESTOR IS WORK-STATION C01 IS NEXT-PAGE LOCAL-DATA IS LOCAL-DATA-AREA ATTRIBUTE-DATA IS ATTRB-DATA SYSTEM-SHUTDOWN IS SHUTDOWN-SWITCH ON STATUS IS SHUTDOWN-PENDING UPSI-0 IS UPSI-SWITCH-0 ON STATUS IS U0-ON OFF STATUS IS U0-OFF UPSI-1 IS UPSI-SWITCH-1 ON STATUS IS U1-ON OFF STATUS IS U1-OFF IBM-ASCII IS STANDARD-1 CURRENCY-SIGN IS "Y". ═══ 8.5. ALPHABET Clause ═══ The ALPHABET clause provides a means of relating an alphabet-name to a specified character code set or collating sequence. ┌─── ALPHABET CLAUSE - FORMAT ─────────────────────────────────────────────────┐ │ │ │ >>──ALPHABET──alphabet-name-1──┬────┬──────────────────────────────────────> │ │ └─IS─┘ │ │ │ │ >──┬─STANDARD-1────────────────────────────────┬──>< │ │ ├─STANDARD-2────────────────────────────────┤ │ │ ├─NATIVE────────────────────────────────────┤ │ │ ├─EBCDIC────────────────────────────────────┤ │ │ ├─NLSSORT───────────────────────────────────┤ │ │ │ ┌───────────────────────────────────────┐ │ │ │ │  │ │ │ │ └───literal-1──┬────────────────────────┬─┴─┘ │ │ ├─┬─THROUGH─┬──literal-2─┤ │ │ │ └─THRU────┘ │ │ │ │ ┌─────────────────┐ │ │ │ │  │ │ │ │ └───ALSO──literal-3─┴────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ It specifies a collating sequence when used in either:  The PROGRAM COLLATING SEQUENCE clause of the OBJECT-COMPUTER paragraph  The COLLATING SEQUENCE phrase of the SORT or MERGE statement. It specifies a character code set when specified in  The FD entry CODE-SET clause. Note: The EBCDIC collating sequence is used when the alphabet-name clause is omitted. Related Information:  ALPHABET Clause Coding Examples. ═══ 8.5.1. alphabet-name-1 ═══ Alphabet-name-1 follows the rules for user-defined names. At least one character must be alphabetic. Alphabet-name-1 identifies a specific character code set or collating sequence. ═══ 8.5.2. literal-1, literal-2, literal-3 ═══ Specifies that the collating sequence is to be determined by the program, according to the following rules:  The order in which literals appear specifies the ordinal number, in ascending sequence, of the character(s) in this collating sequence.  Each numeric literal specified must be an unsigned integer and must have a value from 1 through 256 (the maximum number of characters in the EBCDIC character set). The value of each literal specifies the relative position of a character within the EBCDIC character set. For example: literal 112 represents the EBCDIC character ? literal 234 represents the EBCDIC character Z literal 241 represents the EBCDIC numeric character 0.  Each character in a nonnumeric literal represents that actual character in the EBCDIC character set. (If the nonnumeric literal contains more than one character, each character, starting with the leftmost, is assigned a successively ascending position within this collating sequence.)  Any EBCDIC characters not explicitly specified assume positions in this collating sequence higher than any of the explicitly specified characters. The relative order of the unspecified characters remains unchanged from the EBCDIC collating sequence.  Within one alphabet-name clause, a given character must not be specified more than once.  Each nonnumeric literal associated with a THROUGH or ALSO phrase must be 1 character in length (if it is longer, only the first character is kept, and a warning is issued)  When the THROUGH phrase is specified, the contiguous EBCDIC characters beginning with the character specified by literal-1 and ending with the character specified by literal-2 are assigned successively ascending positions in this collating sequence. This sequence may be either ascending or descending within the original EBCDIC sequence. For example, if the characters Z through S are specified, then for this collating sequence the ascending values are: ZYXWVUTS.  When the ALSO phrase is specified, the EBCDIC characters specified as literal-1, literal-3, and so on, are assigned to the same position in this collating sequence. For example, if you specify: "D" ALSO "N" ALSO "%" the characters D, N, and % are all considered to be in the same position in the collating sequence.  If specified as literals in the SPECIAL-NAMES paragraph, the figurative constants HIGH-VALUE and LOW-VALUE are associated with hex FF and hex 00 respectively.  After all clauses in the SPECIAL-NAMES paragraph are processed, the character having the highest ordinal position in this collating sequence is associated with the figurative constant HIGH-VALUE. If more than one character has the highest position, because of specification of the ALSO phrase, the last character specified (or defaulted to when some characters in the native collating sequence are not explicitly specified) is considered to be the HIGH-VALUE character for procedural statements such as DISPLAY, or as the sending field in a MOVE statement. (If all characters within the native collating sequence were explicitly specified, and the ALSO phrase example from above were specified as the high-order characters of this collating sequence, the HIGH-VALUE character would be %.)  After all clauses in the SPECIAL-NAMES paragraph are processed, the character having the lowest ordinal position in this collating sequence is associated with the figurative constant LOW-VALUE. If more than one character has the lowest position, because of specification of the ALSO phrase, the first character specified is the LOW-VALUE character. (If the ALSO phrase example given above were specified as the low-order characters of the collating sequence, the LOW-VALUE character would be D.) When literal-1, literal-2, or literal-3 is specified, the alphabet-name must not be referred to in a CODE-SET clause (see CODE-SET Clause). ═══ 8.5.3. Coding Examples ═══ The following examples illustrate some uses for the ALPHABET clause. If PROGRAM COLLATING SEQUENCE IS USER-SEQUENCE; if the alphabet-name clause is specified as USER-SEQUENCE IS "D", "E", "F"; and if two Data Division items are defined as follows: 77 ITEM-1 PIC X(3) VALUE "ABC". 77 ITEM-2 PIC X(3) VALUE "DEF". then the following comparison is true: IF ITEM-1 > ITEM-2 Characters D, E, and F are in ordinal positions 1, 2, and 3 of this collating sequence. Characters A, B, and C are in ordinal positions 197, 198, and 199 of this collating sequence. If the alphabet-name clause is USER-SEQUENCE IS 1 THRU 247, 251 THRU 256, "7", ALSO "8", ALSO "9"; if all 256 EBCDIC characters have been specified; and if the two Data Division items are specified as follows: 77 ITEM-1 PIC X(3) VALUE HIGH-VALUE. 77 ITEM-2 PIC X(3) VALUE "789". then both of the following comparisons are true: IF ITEM-1 = ITEM-2 . . . IF ITEM-2 = HIGH-VALUE . . . They compare as true because the values "7", "8", and "9" all occupy the same position (HIGH-VALUE) in this USER-SEQUENCE collating sequence. If the alphabet-name clause is specified as USER-SEQUENCE IS "E", "D", "F" and a table in the Data Division is defined as follows: 05 TABLE A OCCURS 6 ASCENDING KEY IS KEY-A INDEXED BY INX-A. 10 FIELD-A ... 10 KEY-A ... and if the contents in ascending sequence of each occurrence of KEY-A are A, B, C, D, E, G, then the results of the execution of a SEARCH ALL statement for this table will be invalid because the contents of KEY-A are not in ascending order. The proper ascending order would be E, D, A, B, C, G. ═══ 8.6. CLASS Clause ═══ The CLASS clause relates a name to the specified set of characters listed in that clause. ┌─── CLASS CLAUSE - FORMAT ────────────────────────────────────────────────────┐ │ │ │ >>──CLASS──class-name-1──┬────┬────────────────────────────────────────────> │ │ └─IS─┘ │ │ │ │ ┌───────────────────────────────────────┐ │ │  │ │ │ >────literal-4──┬────────────────────────┬─┴──>< │ │ └─┬─THROUGH─┬──literal-5─┘ │ │ └─THRU────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.6.1. class-name-1 ═══ Class-name-1 is a user-defined word and must contain at least one alphabetic character. Class-name-1 can be referenced only in a class condition. See Class Condition for more information. The characters specified by the values of the literals in this clause define the exclusive set of characters of which class-name-1 consists. ═══ 8.6.2. literal-4, literal-5 ═══ If numeric, must be unsigned integers and must have a value from 1 through 256 (the maximum number of characters in the EBCDIC character set). The value of each literal specifies the relative position, or ordinal number, of a character within the EBCDIC character set. If nonnumeric, the literal is the actual character within the EBCDIC character set. If the value of the nonnumeric literal contains multiple characters, each character in the literal is included in the set of characters identified by class-name. If the nonnumeric literal is associated with a THROUGH phrase, it must be one character in length. ═══ 8.6.3. THROUGH, THRU ═══ If THROUGH is specified, class-name includes those characters beginning with the value of literal-4 and ending with the value of literal-5. In addition, the characters specified by a THROUGH phrase may specify characters in either ascending or descending order. ═══ 8.7. CONSOLE Clause ═══ -----IBM Extension----- If CONSOLE IS CRT is specified, any ACCEPT or DISPLAY statement that has no phrases specific to a particular format (such as LOCAL-DATA or PIP-DATA), is treated as an extended ACCEPT or DISPLAY statement. Similarly, if CONSOLE IS DISPLAY is specified, any ACCEPT or DISPLAY statement that has no phrases specific to a particular format is treated as a request to the dynamic screen manager session services APIs. For information on theses APIs, see the System API Reference. ┌─── CONSOLE CLAUSE - FORMAT ──────────────────────────────────────────────────┐ │ │ │ (1) │ │ >>──CONSOLE─────┬────┬──┬─CRT─────┬──>< │ │ └─IS─┘ └─DISPLAY─┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ If no CONSOLE IS clause is specified, any ACCEPT or DISPLAY statement that has no phrases specific to a particular format is treated as a standard ANSI COBOL ACCEPT or DISPLAY statement. ---End of IBM Extension--- ═══ 8.8. CRT STATUS Clause ═══ -----IBM Extension----- The CRT STATUS clause specifies a data item into which a status value is moved after an extended ACCEPT statement. ┌─── CRT STATUS CLAUSE - FORMAT ───────────────────────────────────────────────┐ │ │ │ (1) │ │ >>──CRT STATUS─────┬────┬──data-name-2──>< │ │ └─IS─┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Related Information:  CRT STATUS Clause Considerations ---End of IBM Extension--- ═══ 8.8.1. CRT STATUS Clause Considerations ═══ -----IBM Extension----- If the CRT STATUS clause is specified in the SPECIAL-NAMES paragraph, every extended ACCEPT statement places a value into data-name-2 to indicate the outcome of the ACCEPT operation. Data-name-2 consists of status keys which are set to indicate possible conditions resulting from the completion of the operation. There are three CRT status keys: CRT Status Key 1 The first two bytes of data-name-2. It indicates the condition that caused the termination of the ACCEPT operation. CRT Status Key 2 The next two bytes of data-name-2. It gives further details of the condition that caused the termination of the ACCEPT operation. CRT Status Key 3 The last two bytes of data-name-2. It contains the code for the keyboard key that terminated the ACCEPT operation. ---End of IBM Extension--- ═══ 8.8.1.1. CRT Status Key 1 ═══ -----IBM Extension----- The first two bytes of data-name-2 form CRT Status Key 1 and should be described as PIC 99. It indicates the condition that caused the termination of the ACCEPT operation. The possible values are: 0 Indicates a terminating key such as an enter key, or an auto skip from the final field 1 Indicates a function key 9 Indicates an error If the ACCEPT statement contains an ON EXCEPTION phrase, any value in CRT Status Key 1, except 0, will cause the execution of the imperative statement in the ON EXCEPTION phrase. ---End of IBM Extension--- ═══ 8.8.1.2. CRT Status Key 2 ═══ -----IBM Extension----- The next two bytes of data-name-2 form CRT Status Key 2, and contain a code giving further details of the condition that terminated the ACCEPT operation. Its format and possible values depend on the value in CRT Status Key 1, as shown in the following table. ┌──────────────────────────────────────────────────────────────────────────────┐ │ Valid Combinations of CRT STATUS Keys 1 and 2 │ ├────────┬──────────────────────────────────────────────┬──────────────────────┤ │ KEY 1 │ KEY 2 │ MEANING │ │ ├──────────────────────┬───────────────────────┤ │ │ │ FORMAT │ VALUE │ │ ├────────┼──────────────────────┼───────────────────────┼──────────────────────┤ │ 0 │ PIC 99 │ 0 │ The operator pressed │ │ │ │ │ a terminating key │ ├────────┼──────────────────────┼───────────────────────┼──────────────────────┤ │ 0 │ PIC 99 │ 1 │ Auto skip from the │ │ │ │ │ last field │ ├────────┼──────────────────────┼───────────────────────┼──────────────────────┤ │ 1 │ PIC 99 │ 1-24 │ The function key │ │ │ │ │ number │ ├────────┼──────────────────────┼───────────────────────┼──────────────────────┤ │ 9 │ PIC 99 │ 0 │ Error condition (no │ │ │ │ │ items fall within │ │ │ │ │ the screen) │ ├────────┴──────────────────────┴───────────────────────┴──────────────────────┤ │ NOTE: When auto skip from the last field takes place, the value of 1 for │ │ CRT STATUS KEY 2 is returned to supported controllers, and the value of 0 is │ │ returned to those controllers not supported. │ └──────────────────────────────────────────────────────────────────────────────┘ ┌──────────────────────────────────────────────────────────────────────────────┐ │ Auto Skip Value Returned by Controller Type │ ├───────────────────────────────────────┬──────────────────────────────────────┤ │ TYPE OF CONTROLLER │ AUTO SKIP VALUE OF 1 RETURNED │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ AS/400 controllers: │ │ │ Local workstation controllers │ Yes │ │ Remote 5251 model 12 │ Not applicable │ │ Remote 5294 │ No │ │ Remote 5394 │ Yes, if installed with new work- │ │ │ station │ │ Remote 3174 │ controller code │ │ Remote 3274 │ No, with *NOUNDSPCHR option │ │ │ No, with *NOUNDSPCHR option │ │ │ │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ PC attachments: │ │ │ DOS and Operating System/2* │ No │ │ (OS/2(*)) operating │ │ │ environments │ │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ System to system passthru: │ │ │ AS/400 system to AS/400 system │ Yes │ │ System/36* to AS/400 system │ No │ │ System/38 to AS/400 system │ No │ └───────────────────────────────────────┴──────────────────────────────────────┘ ---End of IBM Extension--- ═══ 8.8.1.3. CRT Status Key 3 ═══ -----IBM Extension----- The last two bytes of data-name-2 form CRT Status Key 3. If CRT Status Key 1 is 0, CRT Status Key 3 contains the code for the keyboard key that terminated the ACCEPT operation. Otherwise, if CRT Status Key 1 is 9, an error is signaled by the operating system, and CRT Status Key 3 will be set to 99. The codes for the keys are:  00 Enter key  90 Roll up key  91 Roll down key  93 Help key  94 Clear key Help and Clear keys accept data only on local AS/400 workstations. ---End of IBM Extension--- ═══ 8.9. CURRENCY SIGN Clause ═══ The CURRENCY SIGN clause defines the currency symbol used in the PICTURE clause. ┌─── CURRENCY SIGN CLAUSE - FORMAT ────────────────────────────────────────────┐ │ │ │ >>──CURRENCY──┬──────┬──┬────┬──literal-6──>< │ │ └─SIGN─┘ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ When the CURRENCY SIGN clause is omitted, only the dollar sign ($) may be used as the PICTURE symbol for the currency sign. ═══ 8.9.1. literal-6 ═══ Specifies the character that will be used as the currency symbol. It must be a one-character, nonnumeric literal, and must not be any of the following:  Digits zero (0) through nine (9)  Uppercase alphabetic characters A B C D P R S V X Z  Lowercase alphabetic characters a through z  The space  Special characters * + - / , . ; ( ) = ".  A figurative constant. ═══ 8.10. CURSOR Clause ═══ -----IBM Extension----- The CURSOR clause specifies the data item that will contain the cursor address used by the extended ACCEPT statement. ┌─── CURSOR CLAUSE - FORMAT ───────────────────────────────────────────────────┐ │ │ │ (1) │ │ >>──CURSOR─────┬────┬──data-name-1──>< │ │ └─IS─┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Related Information:  CURSOR Clause Considerations ---End of IBM Extension--- ═══ 8.10.1. data-name-1 ═══ -----IBM Extension----- Must be a 4- or 6-byte alphanumeric field or a 4- or 6-byte unsigned zoned integer field. If data-name-1 is 4 characters in length, the first two characters are interpreted as line number, and the second two as column number. If data-name-1 is 6 characters in length, the first three characters are interpreted as line number, and the second three as column number. The clause has no effect if data-name-1 contains an invalid position value (such as zeros, a nonnumeric value, or a value that is beyond the range of the screen). Data-name-1 must be described in the WORKING-STORAGE SECTION. If data-name-1 is referenced from a nested program, it must be defined as global in the outermost program. ---End of IBM Extension--- ═══ 8.10.2. CURSOR Clause Considerations ═══ -----IBM Extension----- At the start of an extended ACCEPT operation, if data-name-1 contains a value that is a valid character position on the screen, that position is used as the initial position for the cursor. A valid position is a coordinate that lies on the screen (that is, within the range from line 1, column 1, to line 24, column 80). After the ACCEPT operation, if the position in data-name-1 was valid, data-name-1 is updated to show the position of the cursor at the end of the operation. If the CURSOR IS identifier contains an invalid value (such as spaces, low-values, high-values or a value outside of the screen range), the cursor is positioned at the start of the first input field that is active on the screen. CURSOR IS has no effect on the positioning of fields on the screen. ---End of IBM Extension--- ═══ 8.11. DECIMAL-POINT IS COMMA Clause ═══ The DECIMAL-POINT IS COMMA clause exchanges the functions of the period and the comma in PICTURE character strings and in numeric literals. ┌─── DECIMAL-POINT IS COMMA CLAUSE - FORMAT ───────────────────────────────────┐ │ │ │ >>──DECIMAL-POINT──┬────┬──COMMA──>< │ │ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.12. LINKAGE TYPE Clause ═══ -----IBM Extension----- The LINKAGE TYPE clause specifies the type of linkage to be made on a CALL to or a CANCEL of the program specified by literal-7, and to the type of linkage to be made on the SET statement. ┌─── LINKAGE TYPE CLAUSE - FORMAT ─────────────────────────────────────────────┐ │ │ │ (1) │ │ >>──LINKAGE─────┬──────┬──┬────┬──┬─environment-name-3─┬──FOR──────────────> │ │ └─TYPE─┘ └─IS─┘ ├─PROGRAM────────────┤ │ │ └─PROCEDURE──────────┘ │ │ │ │ ┌─────────────────────────────────────────────┐ │ │  │ │ │ >────literal-7──┬──────────────────────────────┬─┴──>< │ │ └─USING──┤ linkage-arguments ├─┘ │ │ │ │ LINKAGE-ARGUMENTS: │ │ ┌───────────────────────────────────────────────────────────────────┐ │ │  │ │ │ ├────┬─ALL───────────────────────────────────────┬──┬─────┬──DESCRIBED─┴──┤ │ │ │ ┌───────────────────────────────────────┐ │ ├─IS──┤ │ │ │  │ │ │ │ │ │ └───literal-8──┬────────────────────────┬─┴─┘ └─ARE─┘ │ │ └─┬─THRU────┬──literal-9─┘ │ │ └─THROUGH─┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Related Information:  LINKAGE TYPE Clause Considerations ---End of IBM Extension--- ═══ 8.12.1. environment-name-3 ═══ -----IBM Extension----- Environment-name-3 can be defined as: PGM Linkage to a program object (*PGM) is generated. PRC Linkage to an ILE procedure is generated. SYS Linkage to a system-supplied procedure is generated. ---End of IBM Extension--- ═══ 8.12.2. USING ═══ -----IBM Extension----- Specifies which arguments are to have their operational descriptors made available to the called procedure. The USING clause is allowed for a linkage type of procedure and applies only to a CALL statement. literal-8, literal-9 Must be a positive non-zero integer. Specifies the ordinal position of any argument described using operational descriptors. Literal-9 must be greater than literal-8. DESCRIBED The arguments specified by literal-8 through literal-9 are passed along with corresponding operational descriptors. If ALL is specified, all arguments defined for the procedure are passed along with corresponding operational descriptors, where applicable. ---End of IBM Extension--- ═══ 8.12.3. LINKAGE TYPE Clause Considerations ═══ -----IBM Extension----- There are several ways to affect the type of linkage generated for a CALL, CANCEL, or SET. They are listed in order of precedence. The LINKAGE phrase of the CALL, CANCEL, or SET statement has the highest precedence. If no LINKAGE phrase is specified on the statement and there is no visible nested program, the LINKAGE TYPE clause is used if specified. The order of precedence is:  The LINKAGE phrase of the statement  CALL or CANCEL to a nested program  The LINKAGE TYPE clause of the SPECIAL-NAMES paragraph  The LINKLIT parameter of the CRTCBLMOD or CRTBNDCBL command ---End of IBM Extension--- ═══ 8.13. stitle='Part 2. COBOL Program Structure' subject='Environment Division-Input-Output Section'.Input-Output Section ═══ The Input-Output Section defines each file, identifies its external storage medium, assigns the file to one or more input/output devices, and specifies information needed for transmission of data between the external medium and the COBOL program. The Input-Output section of the Environment Division contains two paragraphs:  FILE-CONTROL paragraph  I-O-CONTROL paragraph. The AS/400 system has four categories of files:  Database Files  Device Files  DDM Files  Save Files. ═══ 8.13.1. Database Files ═══ Database files allow information to be permanently stored on the system. A database file is subdivided into groups of records called members. There are two types of database files: physical files and logical files. A physical file is a file that contains data records (similar to disk files on other systems). A logical file is a database file through which data from one or more physical files can be accessed. The format and organization of this data is different from that of the data in the physical file(s). Each logical file can define a different access path (index) for the data in the physical file(s), and can exclude and reorder the fields defined in the physical file(s). ═══ 8.13.2. Device Files ═══ A device file reads from or writes to a device or remote system. It controls the transfer of data between the physical device or remote system and the program. ═══ 8.13.3. DDM Files ═══ Distributed Data Management (DDM) allows you to access data that reside on remote systems that support DDM. You can retrieve, add, update, or delete data records in a file that resides on another system. ═══ 8.13.4. Save Files ═══ A save file is a file that is used to prepare data in a format that is correct for backup and recovery purposes or for transportation to another system. It contains the output that is produced from the Save Library (SAVLIB) or Save Object (SAVOBJ) CL commands. ═══ 8.14. FILE-CONTROL Paragraph ═══ The FILE-CONTROL paragraph associates each file in the COBOL program with an external medium, and specifies file organization, access mode, and other information. The FILE-CONTROL paragraph begins with the word "FILE-CONTROL", followed by a separator period. It must contain one and only one entry for each file described in an FD or SD entry in the Data Division. Within each entry, the SELECT clause must appear first. The other clauses may appear in any order. Each data-name must appear in a Data Division data description entry. Each data-name can be qualified but cannot be subscripted or indexed. The FILE-CONTROL paragraph has five formats:  Format 1 - Sequential Files  Format 2 - Relative Files  Format 3 - Indexed Files  Format 4 - Sort or Merge Files -----IBM Extension-----  Format 5 - Transaction Files. ---End of IBM Extension--- ═══ 8.14.1. FILE-CONTROL Paragraph - Format 1 - Sequential Files ═══ ┌─── FILE-CONTROL PARAGRAPH - FORMAT 1 - SEQUENTIAL ───────────────────────────┐ │ │ │ >>──FILE-CONTROL.──SELECT──┬──────────┬──file-name─────────────────────────> │ │ └─OPTIONAL─┘ │ │ │ │ ┌─────────────────────┐ (3) │ │  │ │ │ >──ASSIGN──┬────┬───┬─assignment-name-1─┬┴─────────────────────────────────> │ │ └─TO─┘ └─literal-1─────────┘ │ │ │ │ >──┬────────────────────────────────┬──────────────────────────────────────> │ │ │ (2) │ │ │ └─RESERVE─────integer──┬───────┬─┘ │ │ ├─AREA──┤ │ │ └─AREAS─┘ │ │ │ │ >──┬──────────────────────────────────────┬────────────────────────────────> │ │ └──┬──────────────────────┬─SEQUENTIAL─┘ │ │ └─ORGANIZATION─┬────┬──┘ │ │ └─IS─┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──────────────────> │ │ │ (2) │ │ │ └─PADDING─────┬───────────┬──┬────┬──┬─data-name-6─┬─┘ │ │ └─CHARACTER─┘ └─IS─┘ └─literal-2───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──────────────────> │ │ │ (2) │ │ │ └─RECORD DELIMITER─────┬────┬──┬─STANDARD-1────────┬─┘ │ │ └─IS─┘ └─assignment-name-2─┘ │ │ │ │ >──┬──────────────────────────────────────┬────────────────────────────────> │ │ └─ACCESS──┬──────┬──┬────┬──SEQUENTIAL─┘ │ │ └─MODE─┘ └─IS─┘ │ │ │ │ >──┬───────────────────────────────────────────────────────────┬──.──>< │ │ └─┬──────┬──STATUS──┬────┬──data-name-1──┬────────────────┬─┘ │ │ └─FILE─┘ └─IS─┘ │ (1)│ │ │ └─data-name-5────┘ │ │ │ │ NOTES: │ │ (1) IBM Extension │ │ │ │ (2) Syntax checked only │ │ │ │ (3) Subsequent repetitions syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.14.2. FILE-CONTROL Paragraph - Format 2 - Relative Files ═══ ┌─── FILE-CONTROL PARAGRAPH - FORMAT 2 - RELATIVE ─────────────────────────────┐ │ │ │ >>──FILE-CONTROL.──SELECT──┬──────────┬──file-name─────────────────────────> │ │ └─OPTIONAL─┘ │ │ │ │ ┌─────────────────────┐ (3) │ │  │ │ │ >──ASSIGN──┬────┬───┬─assignment-name-1─┬┴─────────────────────────────────> │ │ └─TO─┘ └─literal-1─────────┘ │ │ │ │ >──┬────────────────────────────────┬──────────────────────────────────────> │ │ │ (2) │ │ │ └─RESERVE─────integer──┬───────┬─┘ │ │ ├─AREA──┤ │ │ └─AREAS─┘ │ │ │ │ >──┬──────────────────────┬──RELATIVE──────────────────────────────────────> │ │ └─ORGANIZATION──┬────┬─┘ │ │ └─IS─┘ │ │ │ │ >──┬───────────────────────────────────────────────────────────┬───────────> │ │ └─ACCESS──┬──────┬──┬────┬──┬─SEQUENTIAL──┬─────────────┬─┬─┘ │ │ └─MODE─┘ └─IS─┘ │ └─┤ rel-key ├─┘ │ │ │ └─┬─RANDOM──┬──┤ rel-key ├┴───┘ │ │ └─DYNAMIC─┘ │ │ │ │ >──┬───────────────────────────────────────────────────────────┬──.──>< │ │ └─┬──────┬──STATUS──┬────┬──data-name-1──┬────────────────┬─┘ │ │ └─FILE─┘ └─IS─┘ │ (1)│ │ │ └─data-name-5────┘ │ │ │ │ REL-KEY: │ │ ├──RELATIVE──┬──────┬──┬────┬──data-name-4──┤ │ │ └─KEY──┘ └─IS─┘ │ │ │ │ NOTES: │ │ (1) IBM Extension │ │ │ │ (2) Syntax checked only │ │ │ │ (3) Subsequent repetitions syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.14.3. FILE-CONTROL Paragraph - Format 3 - Indexed Files ═══ ┌─── FILE-CONTROL PARAGRAPH - FORMAT 3 - INDEXED ──────────────────────────────┐ │ │ │ >>──FILE-CONTROL.──SELECT──file-name───────────────────────────────────────> │ │ │ │ ┌─────────────────────┐ (3) │ │  │ │ │ >──ASSIGN──┬────┬───┬─assignment-name-1─┬┴─────────────────────────────────> │ │ └─TO─┘ └─literal-1─────────┘ │ │ │ │ >──┬────────────────────────────────┬──────────────────────────────────────> │ │ │ (2) │ │ │ └─RESERVE─────integer──┬───────┬─┘ │ │ ├─AREA──┤ │ │ └─AREAS─┘ │ │ │ │ >──┬──────────────────────┬──INDEXED───────────────────────────────────────> │ │ └─ORGANIZATION──┬────┬─┘ │ │ └─IS─┘ │ │ │ │ >──┬──────────────────────────────────────────┬──RECORD──┬──────┬──────────> │ │ └─ACCESS──┬──────┬──┬────┬──┬─SEQUENTIAL─┬─┘ └─KEY──┘ │ │ └─MODE─┘ └─IS─┘ ├─RANDOM─────┤ │ │ └─DYNAMIC────┘ │ │ │ │ (1) │ │ >──┬────┬──┬─EXTERNALLY-DESCRIBED-KEY────┬──┬─────────────────────────┬────> │ │ └─IS─┘ └─data-name-2─────────────────┘ │ (1)│ │ │ └─┬──────┬──DUPLICATES────┘ │ │ └─WITH─┘ │ │ │ │ >──┬───────────────────────────────────────────────────────────┬──.──>< │ │ └─┬──────┬──STATUS──┬────┬──data-name-1──┬────────────────┬─┘ │ │ └─FILE─┘ └─IS─┘ │ (1)│ │ │ └─data-name-5────┘ │ │ │ │ NOTES: │ │ (1) IBM Extension │ │ │ │ (2) Syntax checked only │ │ │ │ (3) Subsequent repetitions syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.14.4. FILE-CONTROL Paragraph - Format 4 - Sort or Merge Files ═══ ┌─── FILE-CONTROL PARAGRAPH - FORMAT 4 - SORT OR MERGE ────────────────────────┐ │ │ │ (1) │ │ >>──FILE-CONTROL.──SELECT──file-name──ASSIGN─────┬────┬────────────────────> │ │ └─TO─┘ │ │ │ │ ┌───────────────────────┐ │ │  │ │ │ >────┬─assignment-name-1─┬─┴──.──>< │ │ └─literal-1─────────┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.14.5. FILE-CONTROL Paragraph - Format 5 - Transaction Files ═══ -----IBM Extension----- ┌─── FILE-CONTROL PARAGRAPH - FORMAT 5 - TRANSACTION ──────────────────────────┐ │ │ │ >>──FILE-CONTROL.──SELECT──file-name───────────────────────────────────────> │ │ │ │ ┌─────────────────────┐ (2) │ │  │ │ │ >──ASSIGN──┬────┬───┬─assignment-name-1─┬┴─────────────────────────────────> │ │ └─TO─┘ └─literal-1─────────┘ │ │ │ │ >──┬──────────────────────┬──TRANSACTION───────────────────────────────────> │ │ └─ORGANIZATION──┬────┬─┘ │ │ └─IS─┘ │ │ │ │ >──┬───────────────────────────────────────────────────────────┬───────────> │ │ └─ACCESS──┬──────┬──┬────┬──┬─SEQUENTIAL──┬─────────────┬─┬─┘ │ │ └─MODE─┘ └─IS─┘ │ └─┤ rel-key ├─┘ │ │ │ └─DYNAMIC──┤ rel┴key ├────┴───┘ │ │ │ │ >──┬────────────────────────────────────────────────────────┬──────────────> │ │ └─┬──────┬──STATUS──┬────┬──data-name-1──┬─────────────┬─┘ │ │ └─FILE─┘ └─IS─┘ └─data-name-5─┘ │ │ │ │ >──┬───────────────────────────────────┬──.──>< │ │ └─CONTROL-AREA──┬────┬──data-name-7─┘ │ │ └─IS─┘ │ │ │ │ REL-KEY: │ │ ├──RELATIVE──┬──────┬──┬────┬──data-name-3──┤ │ │ └─KEY──┘ └─IS─┘ │ │ │ │ NOTES: │ │ (1) Syntax checked only │ │ │ │ (2) Subsequent repetitions syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ---End of IBM Extension--- ═══ 8.15. SELECT Clause ═══ The SELECT clause chooses a file. ┌─── SELECT CLAUSE - FORMAT - SEQUENTIAL & RELATIVE FILES ─────────────────────┐ │ │ │ >>──SELECT──┬──────────┬──file-name──>< │ │ └─OPTIONAL─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ┌─── SELECT CLAUSE - INDEXED, SORT/MERGE, & TRANSACTION FILES ─────────────────┐ │ │ │ >>──SELECT──file-name──>< │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.16. ASSIGN Clause ═══ The ASSIGN clause associates a file with an external medium. ┌─── ASSIGN CLAUSE - FORMAT ───────────────────────────────────────────────────┐ │ │ │ ┌─────────────────────┐ (1) │ │  │ │ │ >>──ASSIGN──┬────┬───┬─assignment-name-1─┬┴──────>< │ │ └─TO─┘ └─literal-1─────────┘ │ │ │ │ NOTE: │ │ (1) Subsequent repetitions syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ For sort or merge files (associated with an SD entry), no external medium is used. The related ASSIGN clause is syntax checked only. It is not actually used for I-O. ═══ 8.16.1. assignment-name-1, literal-1 ═══ The assignment-name or literal makes the association between the file and the external medium. Any assignment-name or literal after the first is syntax checked, but has no effect on the execution of the program Assignment-name-1 or literal-1 consists of 3 parts:  Device  File name  Attribute It has the following general structure: ┌─── FORMAT ───────────────────────────────────────────────────────────────────┐ │ │ │ >──device──-file-name──┬────────────┬──> │ │ └─-attribute─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.16.2. Device ═══ This part specifies the type of device that the file will use. The compiler can then check whether the file is described and used in a consistent manner. Note: 1. The compiler does not check whether the device associated with the external file is of the type specified in the device portion of assignment-name-1 or literal-1. 2. The compiler provides no diagnostics unless the I-O verbs were used in an inconsistent manner. 3. When the program runs, the operating system could either issue an escape message or ignore the function if it was not applicable to the device. -----IBM Extension----- The device that the file will use can be changed at run time with the OVRxxxF CL command. To ensure consistent results, the device type associated with the file should correspond to that given in the assignment-name. ---End of IBM Extension--- Device can be any of the following: Device Associated file PRINTER PRINTER should be specified for program described printer files only. FORMATFILE FORMATFILE should be specified for externally described printer files only. See the OPEN Statement for information about Dynamic Files. TAPEFILE Tape file DISKETTE Diskette file DISK Any physical database file or single format logical database file. When DISK is the device, database extensions cannot be used. DATABASE Any database file (or DDM file). When DATABASE is the device, externally described data and database extensions can be used. However these file types are not supported for dynamically created files. See the OPEN Statement for information about Dynamic Files. See the OPEN Statement for information about Dynamic Files. WORKSTATION Display file or ICF file. See the OPEN Statement for information about Dynamic Files. ═══ 8.16.3. File Name ═══ This part of assignment-name must be a 1 through 10-character system name of the actual external file- physical or logical database, or device. This external file has to be created before compiling the program only when it is used by a COPY statement, DDS (data description specifications) or DD format, within this program. A quoted file name can be specified within literal-1. For example, if an AS/400 system file has a quoted name of "sysfile", the entry for literal-1 is coded as follows: "device-""sysfile""-SI" For database files, the member name cannot be specified in the program. If a member other than the first member is to be specified, the Override with Database File (OVRDBF) CL command must be used at execution time to specify the member name. This file name is the name of the AS/400 object that is displayed by the Display Program References (DSPPGMREF) command. Since no external medium is used for an SD file, the DSPPGMREF command does not list any files defined for an SD file. The file name can be changed at execution time with the TOFILE parameter of the OVRxxxF CL command. To ensure consistent results, the device type associated with the TOFILE parameter should be the same as that specified for assignment-name-1 or literal-1. ═══ 8.16.4. Attribute ═══ This part of assignment-name-1 or literal-1 can be SI. SI indicates that a separate indicator area has been specified in the DDS for a FORMATFILE or WORKSTATION file. The valid entries for each field of assignment-name-1 or literal-1 vary with the device. The valid combinations of fields are shown in Valid Entries for Assignment-Name-1 and Literal-1. ┌──────────────────────┬───────────┬───────────┬─────┐ │ │ FILE │ DEFAULT │ │ │ DEVICE │ NAME │ FILE NAME │ SI │ ├──────────────────────┼───────────┼───────────┼─────┤ │ PRINTER │ O │ QPRINT │ N │ ├──────────────────────┼───────────┼───────────┼─────┤ │ FORMATFILE │ R │ │ O │ ├──────────────────────┼───────────┼───────────┼─────┤ │ TAPEFILE │ O │ QTAPE │ N │ ├──────────────────────┼───────────┼───────────┼─────┤ │ DISKETTE │ O │ QDKT │ N │ ├──────────────────────┼───────────┼───────────┼─────┤ │ DISK │ R │ │ N │ ├──────────────────────┼───────────┼───────────┼─────┤ │ DATABASE │ R │ │ N │ ├──────────────────────┼───────────┼───────────┼─────┤ │ WORKSTATION │ R │ │ O │ └──────────────────────┴───────────┴───────────┴─────┘ R=Required O=Optional N=Not Allowed Valid Entries for Assignment-Name-1 and Literal-1 ═══ 8.17. RESERVE Clause ═══ The RESERVE clause reserves input-output areas. It is syntax checked, but treated as documentation. ┌─── RESERVE CLAUSE - FORMAT ──────────────────────────────────────────────────┐ │ │ │ (1) │ │ >>──RESERVE─────integer──┬───────┬──>< │ │ ├─AREA──┤ │ │ └─AREAS─┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.18. ORGANIZATION Clause ═══ The ORGANIZATION clause specifies the logical structure of the file. The file organization is established at the time the file is created and cannot subsequently be changed. COBOL allows for four distinct kinds of file organization:  ORGANIZATION IS SEQUENTIAL (Format 1)  ORGANIZATION IS RELATIVE (Format 2)  ORGANIZATION IS INDEXED (Format 3) -----IBM Extension-----  ORGANIZATION IS TRANSACTION (Format 5). ---End of IBM Extension--- -----IBM Extension----- For database files, the ORGANIZATION clause indicates the current program usage of the file in the program. Therefore, the same database file can use SEQUENTIAL, RELATIVE, or INDEXED (assuming a keyed sequence access path exists) in the ORGANIZATION clause. This is true regardless of what is specified in other programs that use this file. A keyed sequence access path is always created when a key is specified in the DDS that was used as input to the Create Physical File (CRTPF) or the Create Logical File (CRTLF) CL command. ---End of IBM Extension--- ═══ 8.18.1. ORGANIZATION IS SEQUENTIAL (Format 1) ═══ ┌─── ORGANIZATION CLAUSE - SEQUENTIAL FILES ───────────────────────────────────┐ │ │ │ >>──┬──────────────────────┬──SEQUENTIAL──>< │ │ └─ORGANIZATION──┬────┬─┘ │ │ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ A predecessor-successor relationship of the records in the files is established by the order in which records are placed in the file when it is created or extended (arrival sequence access path). ═══ 8.18.2. ORGANIZATION IS RELATIVE (Format 2) ═══ ┌─── ORGANIZATION CLAUSE - RELATIVE FILES ─────────────────────────────────────┐ │ │ │ >>──┬──────────────────────┬──RELATIVE──>< │ │ └─ORGANIZATION──┬────┬─┘ │ │ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The position of each record in the file is determined by its relative record number within the arrival sequence access path. ═══ 8.18.3. ORGANIZATION IS INDEXED (Format 3) ═══ ┌─── ORGANIZATION CLAUSE - INDEXED FILES ──────────────────────────────────────┐ │ │ │ >>──┬──────────────────────┬──INDEXED──>< │ │ └─ORGANIZATION──┬────┬─┘ │ │ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The position of each logical record in the file is determined by the key sequence access path created with the file and maintained by the system. The access path is based on an embedded key within the file's records. ═══ 8.18.4. ORGANIZATION IS TRANSACTION (Format 5) ═══ -----IBM Extension----- ┌─── ORGANIZATION CLAUSE - TRANSACTION FILES ──────────────────────────────────┐ │ │ │ (1) │ │ >>──┬──────────────────────┬──TRANSACTION─────>< │ │ └─ORGANIZATION──┬────┬─┘ │ │ └─IS─┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Signifies interaction between a COBOL program and either a workstation user or another system. ---End of IBM Extension--- ═══ 8.19. PADDING CHARACTER Clause ═══ The PADDING CHARACTER clause specifies the character which is to be used for block padding on sequential files. The PADDING CHARACTER clause is syntax checked, but no compile-time or run-time verification checking is done, and the clause has no effect on the execution of the program. ┌─── PADDING CHARACTER CLAUSE - FORMAT ────────────────────────────────────────┐ │ │ │ (1) │ │ >>──PADDING─────┬───────────┬──┬────┬──┬─data-name-6─┬──>< │ │ └─CHARACTER─┘ └─IS─┘ └─literal-2───┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ For EXTERNAL files, if data-name-6 is specified, it must reference an EXTERNAL data item. ═══ 8.20. RECORD DELIMITER Clause ═══ The RECORD DELIMITER clause indicates the method of determining the length of a variable-length record on an external medium. It can be specified only for variable-length records. The RECORD DELIMITER clause is syntax checked, but no compile-time or run-time verification checking is done, and the clause is treated as documentation ┌─── RECORD DELIMITER CLAUSE - FORMAT ─────────────────────────────────────────┐ │ │ │ (1) │ │ >>──RECORD──DELIMITER─────┬────┬──┬─STANDARD-1────────┬──>< │ │ └─IS─┘ └─assignment-name-2─┘ │ │ │ │ NOTE: │ │ (1) Syntax-checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.21. ACCESS MODE Clause ═══ The ACCESS MODE clause defines the manner in which the records of the file are made available for processing. If the ACCESS MODE clause is not specified, SEQUENTIAL access is assumed. The ACCESS MODE clause has four formats:  Format 1 - Sequential Files  Format 2 - Relative Files  Format 3 - Indexed Files -----IBM Extension-----  Format 5 - Transaction Files ---End of IBM Extension--- ═══ 8.21.1. ACCESS MODE Clause - Format 1 - Sequential Files ═══ ┌─── ACCESS MODE CLAUSE - FORMAT 1 - SEQUENTIAL FILES ─────────────────────────┐ │ │ │ >>──ACCESS──┬──────┬──┬────┬──SEQUENTIAL──>< │ │ └─MODE─┘ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.21.2. ACCESS MODE Clause - Format 2 - Relative Files ═══ ┌─── ACCESS MODE CLAUSE - FORMAT 3 - RELATIVE FILES ───────────────────────────┐ │ │ │ >>──ACCESS──┬──────┬──┬────┬──┬─SEQUENTIAL──┬─────────────┬─┬──>< │ │ └─MODE─┘ └─IS─┘ │ └─┤ Rel Key ├─┘ │ │ │ ├─RANDOM──┤ Rel Key ├─────┴───┤ │ │ └─DYNAMIC─┴┤ Rel Key ├────────┘ │ │ │ │ REL KEY: │ │ ├──RELATIVE──┬──────┬──┬────┬──data-name-4──┤ │ │ └─KEY──┘ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.21.3. ACCESS MODE Clause - Format 3 - Indexed Files ═══ ┌─── ACCESS MODE CLAUSE - FORMAT 2 - INDEXED FILES ────────────────────────────┐ │ │ │ >>──ACCESS──┬──────┬──┬────┬──┬─SEQUENTIAL─┬──>< │ │ └─MODE─┘ └─IS─┘ ├─RANDOM─────┤ │ │ └─DYNAMIC────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.21.4. ACCESS MODE Clause - Format 5 - Transaction Files ═══ -----IBM Extension----- ┌─── ACCESS MODE CLAUSE - FORMAT 5 - TRANSACTION FILES ────────────────────────┐ │ │ │ >>──ACCESS──┬──────┬──┬────┬──┬─SEQUENTIAL───────────┬──>< │ │ └─MODE─┘ └─IS─┘ └─DYNAMIC──┤ Rel Key ├─┘ │ │ │ │ REL KEY: │ │ ├──RELATIVE──┬──────┬──┬────┬──data-name-4──┤ │ │ └─KEY──┘ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ---End of IBM Extension--- ═══ 8.22. RECORD KEY Clause ═══ The RECORD KEY clause must be specified for an indexed file. The RECORD KEY clause specifies the data item within the record that is the record key for an indexed file. ┌─── RECORD KEY CLAUSE - FORMAT ───────────────────────────────────────────────┐ │ │ │ (1) │ │ >>──RECORD──┬─────┬──┬────┬──┬─EXTERNALLY-DESCRIBED-KEY────┬───────────────> │ │ └─KEY─┘ └─IS─┘ └─data-name-2─────────────────┘ │ │ │ │ >──┬─────────────────────────┬──>< │ │ │ (1) │ │ │ └──┬──────┬─DUPLICATES────┘ │ │ └─WITH─┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.22.1. DUPLICATES ═══ -----IBM Extension----- The DUPLICATES phrase can only be specified for files assigned duplicate record keys. This allows the file to have keys with the same values. If the file has multiple formats, two keys in different formats have the same values only when the key lengths and the contents of the keys are the same. For example, given a file with the following two formats: Format F1 with keys A, B, C Format F2 with keys A, B, D. If fields C and D are the same length, have the same data type, and have the same values, the file would contain two records with a duplicate key. The term duplicate key applies only to a complete record key for the format. A record key for the format consists of the key field(s) defined for a DDS format for records residing on the database. The term does not apply to the common key for the file (only fields A and B in the above example). Users can indicate DUPLICATES on the RECORD KEY clause. A file status of 95 is returned after a successful open when:  The DUPLICATES phrase is specified in the COBOL program and the file was created with UNIQUE specified in DDS.  The DUPLICATES phrase is not specified in the COBOL program and the file was created allowing nonunique keys. Processing files when either of these conditions exist can cause unpredictable results. In a file that allows duplicates and is processed randomly or dynamically, the duplicate record that is updated or deleted must be the proper one. To ensure this, the last input/output statement processed prior to the REWRITE or DELETE operation must be a successfully processed READ statement without the NO LOCK phrase. If the DDS file level keyword LIFO (last-in-first-out) is specified, the duplicate records within a physical file are retrieved in a last-in-first-out order. ---End of IBM Extension--- ═══ 8.22.2. data-name-2 ═══ Data-name-2 is the RECORD KEY data item. It must be described as a fixed-length alphanumeric item within a record description entry associated with the file. It must not reference a group item that contains a variable occurrence data item. Data-name-2 may be qualified, but it must not be subscripted. The length of the record key is restricted; the key length, in bytes, cannot exceed 2 000. If the indexed file contains variable-length records, data-name-2 must be contained within the first "x" positions of the record, where "x" equals the minimum record size specified for the file. For EXTERNAL files, all file description entries in the run unit that are associated with the EXTERNAL file must specify the same data description entry for data-name-2 with the same relative location within the associated record; otherwise the results are undefined. -----IBM Extension----- The RECORD KEY data item, data-name-2, can be a numeric item when the file is assigned to a DATABASE device type. The numeric item can have a usage of DISPLAY, COMP (COMP-3), COMP-4, PACKED-DECIMAL, or BINARY. ---End of IBM Extension--- The keys are ordered within the collating sequence used when the file was created. The data description of data-name-2 and its relative location within the record must be the same as the ones used when the file was defined in DDS. The record description that defines data-name-2 will always be used to access the record key field for the I-O operation. ═══ 8.22.3. EXTERNALLY-DESCRIBED-KEY ═══ -----IBM Extension----- The reserved word EXTERNALLY-DESCRIBED-KEY can specify that the keys for this file are those that are externally described in DDS. The keys are determined by the record formats that are copied by the COPY statement, DDS, DD, DDSR, or DDR format, under the FD for this file. The key can start at different offsets within the buffer for each format. In this situation, care must be used when changing from one record format to another, using a random READ or START statement. The key must be placed in the record format at the correct offset in the format that will be used in the random access of the file. Unpredictable results can occur if the key for the desired record is based on data that was part of the last record read. This is because the movement of the data to the key field can involve overlapping fields. The key within a format can be made up of multiple, noncontiguous (not adjacent) fields. Only those record formats copied in within the FD for the file should be referenced by the FORMAT phrase. If a format is referenced that is defined within the file, but that format has not been copied into the program, the key is built using the key fields defined for the first record format that was copied. This can cause unpredictable results. If a portion of the key is declared in the logical file only as an element of a concatenated item (rather than an independently-declared item), the result of the CONCAT operation must not be a variable-length item. ---End of IBM Extension--- ═══ 8.23. RELATIVE KEY Clause ═══ The RELATIVE KEY clause identifies a data-name that specifies the relative record number for a specific logical record within a relative file. ┌─── RELATIVE KEY CLAUSE - FORMAT ─────────────────────────────────────────────┐ │ │ │ >>──RELATIVE──┬─────┬──┬────┬──data-name-4──>< │ │ └─KEY─┘ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.23.1. data-name-4 ═══ Must be defined as an unsigned integer data item whose description does not contain the PICTURE symbol P. Data-name-4 must not be defined in a record description entry associated with this relative file. That is, the RELATIVE KEY is not part of the record. Data-name-4 can be qualified. For reads under sequential access, the RELATIVE KEY data item is updated with the relative record number of the record being made available. Data-name-4 is required for ACCESS IS SEQUENTIAL only when the START statement is to be used. It is always required for ACCESS IS RANDOM and ACCESS IS DYNAMIC. When the START statement is issued, the system uses the contents of the RELATIVE KEY data item to determine the record at which sequential processing is to begin. If a value is placed in data-name-4, and a START statement is not issued, the value is ignored and processing begins with the first record in the file. -----IBM Extension----- When the file is opened, the POSITION parameter on the OVRDBF CL command can be used to set the file position indicator. This causes processing to begin with a record other than the first record. ---End of IBM Extension--- If a relative file is to be referenced by a START statement, you must specify the RELATIVE KEY clause for that file. The ACCESS MODE IS RANDOM clause must not be specified for file-names specified in the USING or GIVING phrase of a SORT or MERGE statement. For EXTERNAL files, data-name-4 must reference an external data item, and the RELATIVE KEY phrase in each associated file control entry must reference that same external data item. (Relative keys are used with subfiles.) ═══ 8.24. FILE STATUS Clause ═══ The FILE STATUS clause monitors the execution of each input-output request for the file. ┌─── FILE STATUS CLAUSE - FORMAT ──────────────────────────────────────────────┐ │ │ │ >>──┬──────┬──STATUS──┬────┬──data-name-1──┬────────────────┬──>< │ │ └─FILE─┘ └─IS─┘ │ (1)│ │ │ └─data-name-5────┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ When the FILE STATUS clause is specified, the system moves a value into the status key data item after each input-output request that explicitly or implicitly refers to this file. The value indicates the status of execution of the statement. (See the "Status Key" description under Common Processing Facilities.) When the compiler generates code to block output records or unblock input records, file status values that are caused by OS/400 exceptions are set only when a block is processed. ═══ 8.24.1. data-name-1 ═══ The status key data item must be defined in the Data Division as a 2-character alphanumeric item. Data-name-1 must not be defined in the File Section. Data-name-1 can be qualified. ═══ 8.24.2. data-name-5 ═══ -----IBM Extension----- An optional status key data item may be specified for file processing. For transaction files, the data item must be a 4-character alphanumeric item. For non-transaction files, the data item must be a 6-byte group item. The item is treated as documentation for all non-transaction files except for those that are dynamically created. Extended file status is set to 0900 for files that are created dynamically when OPEN OUTPUT is specified. Data-name-5 can be qualified. ---End of IBM Extension--- ═══ 8.25. CONTROL-AREA Clause ═══ -----IBM Extension----- This clause specifies device-dependent and system-dependent information used to control input/output operations for TRANSACTION files. You could achieve the same result through the use of INDICATORS. ┌─── CONTROL-AREA CLAUSE - FORMAT ─────────────────────────────────────────────┐ │ │ │ (1) │ │ >>──CONTROL-AREA─────┬────┬──data-name-7──>< │ │ └─IS─┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ---End of IBM Extension--- ═══ 8.25.1. data-name-7 ═══ -----IBM Extension----- A data-item (2, 12, or 22 characters long) defined in the LINKAGE SECTION or the WORKING STORAGE SECTION, of the following format: 01 data-name-7 05 function-key PIC X(2) 05 device-name PIC X(10) 05 record-format PIC X(10) Where: function-key Is a 2-digit number inserted in the field by the workstation interface that identifies the function key the operator pressed to initiate the transaction. number meaning 00 Enter key 01-24 Function keys 1 through 24 90 Roll up / Page down key 91 Roll down / Page up key 92 Print key 93 Help key 94 Clear key 95 Home key 99 Undefined device-name The program device name record-format The DDS record format name that was referenced by the last input/output statement run. ---End of IBM Extension--- ═══ 8.26. I-O-CONTROL Paragraph ═══ The I-O-CONTROL paragraph of the INPUT-OUTPUT SECTION specifies the storage areas to be shared by different files. This paragraph is optional in a COBOL program. The keyword I-O-CONTROL may appear only once, at the beginning of the paragraph. The word I-O-CONTROL must begin in Area A, and must be followed by a separator period. Each clause within the paragraph may be separated from the next by a separator comma or a separator semicolon. The order in which I-O-CONTROL paragraph clauses are written is not significant. The I-O-CONTROL paragraph ends with a separator period. The I-O-CONTROL paragraph has three formats:  Format 1 - Sequential Files  Format 2 - Indexed and Relative Files  Format 3 - Sort or Merge Files ═══ 8.26.1. I-O-CONTROL Paragraph - Format 1 - Sequential Files ═══ ┌─── I-O-CONTROL PARAGRAPH - FORMAT 1 - SEQUENTIAL ────────────────────────────┐ │ │ │ >>──I-O-CONTROL.───────────────────────────────────────────────────────────> │ │ │ │ >──┬───────────────────────────────────────────────────────────────┬──>< │ │ │ ┌────────────────────────────────────────────────────────┐ │ │ │ │  │ │ │ │ │ (2) │ │ │ └──┬─RERUN─────┬───────────────────────────┬──┤ records ├─┬───.─┘ │ │ │ └─ON──┬─assignment-name-1─┬─┘ │ │ │ │ └─file-name-1───────┘ │ │ │ ├─SAME──┬────────┬──┬──────┬──┬─────┬──┤ files ├───────┤ │ │ │ └─RECORD─┘ └─AREA─┘ └─FOR─┘ │ │ │ ├─┤ multiple file tape ├───────────────────────────────┤ │ │ │ (1) ┌─────────────┐ │ │ │ │  │ │ │ │ └─COMMITMENT──CONTROL─────┬─────┬────file-name-6─┴─────┘ │ │ └─FOR─┘ │ │ │ │ RECORDS: │ │ ├──┬───────┬──┬─┬─integer-1──RECORDS────┬──┬────┬──file-name-2─┬──┤ │ │ └─EVERY─┘ │ └─END──┬────┬──┬─REEL─┬─┘ └─OF─┘ │ │ │ │ └─OF─┘ └─UNIT─┘ │ │ │ ├─integer-2──CLOCK-UNITS─────────────────────────┤ │ │ └─condition-name-1───────────────────────────────┘ │ │ │ │ FILES: │ │ ┌─────────────┐ │ │  │ │ │ ├──file-name-3────file-name-4─┴──┤ │ │ │ │ MULTIPLE FILE TAPE: │ │ (2) │ │ ├──MULTIPLE──FILE─────┬──────┬──┬──────────┬───────────────────────────────> │ │ └─TAPE─┘ └─CONTAINS─┘ │ │ │ │ ┌──────────────────────────────────────┐ │ │  │ │ │ >────file-name-5──┬─────────────────────┬─┴──┤ │ │ └─POSITION──integer-2─┘ │ │ │ │ NOTES: │ │ (1) IBM Extension │ │ │ │ (2) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.26.2. I-O-CONTROL Paragraph - Format 2 - Relative and Indexed Files ═══ ┌─── I-O-CONTROL PARAGRAPH - FORMAT 2 - RELATIVE/INDEXED ──────────────────────┐ │ │ │ >>──I-O-CONTROL.───────────────────────────────────────────────────────────> │ │ │ │ >──┬───────────────────────────────────────────────────────────────┬──>< │ │ │ ┌────────────────────────────────────────────────────────┐ │ │ │ │  │ │ │ │ │ (2) │ │ │ └──┬─RERUN─────┬───────────────────────────┬──┤ records ├─┬───.─┘ │ │ │ └─ON──┬─assignment-name-1─┬─┘ │ │ │ │ └─file-name-1───────┘ │ │ │ ├─SAME──┬────────┬──┬──────┬──┬─────┬──┤ files ├───────┤ │ │ │ └─RECORD─┘ └─AREA─┘ └─FOR─┘ │ │ │ │ (1) ┌─────────────┐ │ │ │ │  │ │ │ │ └─COMMITMENT──CONTROL─────┬─────┬────file-name-6─┴─────┘ │ │ └─FOR─┘ │ │ │ │ RECORDS: │ │ ├──┬───────┬──┬─integer-1──RECORDS──┬────┬──file-name-2─┬──┤ │ │ └─EVERY─┘ │ └─OF─┘ │ │ │ ├─integer-2──CLOCK-UNITS──────────────────┤ │ │ └─condition-name-1────────────────────────┘ │ │ │ │ FILES: │ │ ┌─────────────┐ │ │  │ │ │ ├──file-name-3────file-name-4─┴──┤ │ │ │ │ NOTES: │ │ (1) IBM Extension │ │ │ │ (2) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.26.3. I-O-CONTROL Paragraph - Format 3 - Sort or Merge Files ═══ ┌─── I-O-CONTROL ENTRIES - FORMAT 3 - SORT/MERGE ──────────────────────────────┐ │ │ │ >>──I-O-CONTROL.───────────────────────────────────────────────────────────> │ │ │ │ >──┬──────────────────────────────────────────────────────────────┬──>< │ │ │ ┌───────────────────────────────────────────────────────┐ │ │ │ │  │ │ │ │ └───SAME──┬─RECORD────────┬──┬──────┬──┬─────┬──┤ files ├─┴──.─┘ │ │ │ (1) │ └─AREA─┘ └─FOR─┘ │ │ ├─SORT──────────┤ │ │ │ (1)│ │ │ └─SORT-MERGE────┘ │ │ │ │ FILES: │ │ ┌─────────────┐ │ │  │ │ │ ├──file-name-3────file-name-4─┴──┤ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.27. RERUN Clause ═══ The RERUN clause specifies that checkpoint records are to be taken. The RERUN clause is syntax checked, but is treated as documentation. ┌─── RERUN CLAUSE - FORMAT ────────────────────────────────────────────────────┐ │ │ │ (1) │ │ >>──RERUN─────┬───────────────────────────┬──┬───────┬─────────────────────> │ │ └─ON──┬─file-name-1───────┬─┘ └─EVERY─┘ │ │ └─assignment-name-1─┘ │ │ │ │ >──┬─┬─integer-1──RECORDS─────┬──┬────┬──file-name-2─┬──>< │ │ │ └─END───┬────┬──┬─REEL─┬─┘ └─OF─┘ │ │ │ │ └─OF─┘ └─UNIT─┘ │ │ │ ├─integer-2──CLOCK-UNITS──────────────────────────┤ │ │ └─condition-name-1────────────────────────────────┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.28. SAME AREA Clause ═══ The SAME AREA clause specifies that two or more files, that do not represent sort or merge files, are to use the same main storage area during processing. The SAME AREA clause is syntax checked, but is treated as documentation. ┌─── SAME AREA CLAUSE - FORMAT ────────────────────────────────────────────────┐ │ │ │ (1) ┌─────────────┐ │ │  │ │ │ >>──SAME─────┬──────┬──┬─────┬──file-name-3────file-name-4─┴──>< │ │ └─AREA─┘ └─FOR─┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The files named in a SAME AREA clause need not have the same organization or access. ═══ 8.29. SAME RECORD AREA Clause ═══ The SAME RECORD AREA clause specifies that two or more files are to use the same main storage area for processing the current logical record. All of the files may be open at the same time. Note: The SAME RECORD AREA clause is intended to make efficient use of main storage. However, AS/400 virtual storage architecture eliminates the need for this clause, and the clause is supported for compatibility rather than for performance. Use of the SAME RECORD AREA clause actually degrades performance and increases program size. ┌─── SAME RECORD AREA CLAUSE - FORMAT ─────────────────────────────────────────┐ │ │ │ ┌─────────────┐ │ │  │ │ │ >>──SAME──RECORD──┬──────┬──┬─────┬──file-name-3────file-name-4─┴──>< │ │ └─AREA─┘ └─FOR─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ A logical record in the shared storage area is considered to be both of the following:  A logical record of each opened output file using the SAME RECORD AREA clause  A logical record of the most recently read input file using the SAME RECORD AREA clause. The SAME RECORD AREA clause allows transfer of data from one file to another with no explicit data manipulation because the input/output record areas of named files are identical, and all are available to the user. More than one SAME RECORD AREA clause may be included in a program. However:  A specific file-name must not appear in more than one SAME RECORD AREA clause.  If one or more file-names of a SAME AREA clause appear in a SAME RECORD AREA clause, all the file-names in that SAME AREA clause must appear in that SAME RECORD AREA clause. However, the SAME RECORD AREA clause may contain additional file-names that do not appear in the SAME AREA clause.  If the SAME RECORD AREA is specified for several files, the record description entries or the file description entries for these files must not include the GLOBAL clause.  The SAME RECORD AREA clause cannot be used with EXTERNAL files. ═══ 8.30. SAME SORT AREA Clause ═══ The SAME SORT AREA clause optimizes the storage area assignment to a given SORT statement. The SAME SORT AREA clause is syntax checked, but is treated as documentation. ┌─── SAME SORT AREA CLAUSE - FORMAT ───────────────────────────────────────────┐ │ │ │ (1) ┌─────────────┐ │ │  │ │ │ >>──SAME──SORT─────┬──────┬──┬─────┬──file-name-3────file-name-4─┴──>< │ │ └─AREA─┘ └─FOR─┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ When the SAME SORT AREA clause is specified, at least one file-name specified must be a sort file. Files that are not sort files may also be specified. The following rules apply:  More than one SAME SORT AREA clause may be specified. However, a given sort file must not be named in more than one such clause.  If a file that is not a sort file is named in both a SAME AREA clause and in one or more SAME SORT AREA clauses, all the files in the SAME AREA clause must also appear in that SAME SORT AREA clause.  Files named in a SAME SORT AREA clause need not have the same organization or access.  Files named in a SAME SORT AREA clause that are not sort files do not share storage with each other unless the user names them in a SAME RECORD AREA clause. ═══ 8.31. SAME SORT-MERGE AREA Clause ═══ The SAME SORT-MERGE AREA clause optimizes the storage area assignment to a given SORT or MERGE statement. The SAME SORT-MERGE AREA clause is syntax checked, but is treated as documentation. ┌─── SAME SORT-MERGE AREA CLAUSE - FORMAT ─────────────────────────────────────┐ │ │ │ (1) ┌─────────────┐ │ │  │ │ │ >>──SAME──SORT-MERGE─────┬──────┬──┬─────┬──file-name-3────file-name-4─┴──>< │ │ └─AREA─┘ └─FOR─┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ When the SAME SORT-MERGE AREA clause is specified, at least one file-name specified must be a sort or merge file. Files that are not sort or merge files may also be specified. The following rules apply:  More than one SAME SORT-MERGE AREA clause may be specified. However, a given sort or merge file must not be named in more than one such clause.  If a file that is not a sort or merge file is named in both a SAME AREA clause and in one or more SAME SORT-MERGE AREA clauses, all the files in the SAME AREA clause must also appear in that SAME SORT-MERGE AREA clause.  Files named in a SAME SORT-MERGE AREA clause need not have the same organization or access.  Files named in a SAME SORT-MERGE AREA clause that are not sort or merge files do not share storage with each other unless the user names them in a SAME RECORD AREA clause. ═══ 8.32. MULTIPLE FILE TAPE Clause ═══ This clause specifies that two or more files share the same reel of tape. The function is provided by the system through the use of command language. The MULTIPLE FILE TAPE clause is syntax checked, but is treated as documentation. ┌─── MULTIPLE FILE TAPE CLAUSE - FORMAT ───────────────────────────────────────┐ │ │ │ (1) │ │ >>──MULTIPLE──FILE─────┬──────┬──┬──────────┬──────────────────────────────> │ │ └─TAPE─┘ └─CONTAINS─┘ │ │ │ │ ┌──────────────────────────────────────┐ │ │  │ │ │ >────file-name-5──┬─────────────────────┬─┴──>< │ │ └─POSITION──integer-2─┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 8.33. COMMITMENT CONTROL Clause ═══ -----IBM Extension----- The COMMITMENT CONTROL clause specifies the files that will be placed under commitment control when they are opened. ┌─── COMMITMENT CONTROL CLAUSE - FORMAT ───────────────────────────────────────┐ │ │ │ (1) ┌─────────────┐ │ │  │ │ │ >>──COMMITMENT──CONTROL─────┬─────┬────file-name-6─┴──>< │ │ └─FOR─┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ File-name-6 must be specified in the FILE CONTROL paragraph of the same program as the I-O-CONTROL paragraph in which the COMMITMENT CONTROL clause appears. These files will then be affected by the COMMIT and ROLLBACK statements. The COMMIT statement allows the synchronization of changes to database records while preventing other jobs from modifying those records until the COMMIT is complete. The ROLLBACK statement provides a method of cancelling changes made to database files when those changes should not be made permanent. The COMMITMENT CONTROL clause can specify only files assigned to a device type of DATABASE. Files under commitment control may have an organization of sequential, relative or indexed, and may have any access mode valid for a particular organization. The system locks records contained in files under commitment control when these records are accessed. Records remain locked until released by a COMMIT or ROLLBACK statement. Note: Always try to use files in a consistent manner to avoid record locking problems, and to avoid reading records that have not yet been permanently committed to the database. Typically, a file should either always be accessed under commitment control or never be accessed under commitment control. ---End of IBM Extension--- ═══ 9. Data Division ═══ The Data Division of a COBOL source program describes, in a structured manner, all the data to be processed by the object program; also the relationship between physical and logical records. The Data Division is optional in a COBOL source program. This section outlines the structure of the Data Division and explains the types of data. The Data Division must begin with the words DATA DIVISION, followed by a period and a space. The Data Division is divided into three sections: File Section Describes externally stored data (including sort-merge files). Working-Storage Section Describes internal data. Linkage Section Describes data made available by another program. It appears in the called program and describes data items that are provided by the calling program and are referred to by the called program. The called program can be a nested program. Each section has a specific logical function within a COBOL source program, and each may be omitted from the source program when that logical function is not needed. If included, the sections must be written in the order shown. ┌─── DATA DIVISION - FORMAT ───────────────────────────────────────────────────┐ │ │ │ >>──DATA DIVISION.──┬─────────────────────────────────────────────────┬────> │ │ │ ┌──────────────────────────────┐ │ │ │ │  │ │ │ │ └─FILE SECTION.────┬──────────────────────────┬─┴─┘ │ │ └─┤ file-section-entries ├─┘ │ │ │ │ >──┬───────────────────────────────────────────────────────────────┬───────> │ │ │ ┌─────────────────────────────────┐ │ │ │ │  │ │ │ │ └─WORKING-STORAGE SECTION.────┬─────────────────────────────┬─┴─┘ │ │ ├─record-description-entry────┤ │ │ └─data-item-description-entry─┘ │ │ │ │ >──┬───────────────────────────────────────────────────────┬──>< │ │ │ ┌─────────────────────────────────┐ │ │ │ │  │ │ │ │ └─LINKAGE SECTION.────┬─────────────────────────────┬─┴─┘ │ │ ├─record-description-entry────┤ │ │ └─data-item-description-entry─┘ │ │ │ │ FILE-SECTION-ENTRIES: │ │ ┌──────────────────────────┐ │ │  │ │ │ ├──file-description-entry────record-description-entry─┴──┤ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Related Information:  File Description(FD) and Sort Description(SD) Entries  Data Description Entry  Data Types  Data Relationships ═══ 9.1. File Section ═══ The File Section describes:  All externally stored files  Each sort-merge file. Group items (including tables) are limited to a length of 16 711 568 bytes. The initial value of a data item in the File Section is undefined. -----IBM Extension----- The record description entry for a file can be specified using the Format 2 COPY statement (DD, DDR, DDS, or DDSR option). This allows the field descriptions for a record format to be exactly as defined in DDS. Also, programs are easier to write because the record format description is maintained in only one place. ---End of IBM Extension--- ═══ 9.2. Working-Storage Section ═══ The Working-Storage Section describes data records that are not part of external data files but are developed and processed internally by the program. Data entries in the Working-Storage Section that bear a definite hierarchic relationship to one another must be grouped into records structured by level number. The initial value of any data item in the Working-Storage Section, except an index data item, is specified by associating a VALUE clause with the item. The initial value of any index data item, or of any data item not associated with a VALUE clause, is undefined. Note: A maximum of 16 711 568 bytes is permitted for group items (including tables). ═══ 9.3. Linkage Section ═══ The Linkage Section describes data made available from another program through the CALL statement. It can also be used to describe the format of data accessed by using the ADDRESS OF special register. For example, you can set the ADDRESS OF special register for a Linkage Section item to data that is dynamically allocated using ILE bindable APIs. Record description entries and data item description entries in the Linkage Section provide names and descriptions of the data item, but not the storage. Storage is not reserved in the program because the data area exists elsewhere. Any data description clause may be used to describe items in the Linkage Section, with these exceptions:  The VALUE clause may not be specified for items other than level-88 items. -----IBM Extension----- If the VALUE clause is specified for items other than level-88 in the Linkage section, it is treated as a comment. ---End of IBM Extension---  The EXTERNAL clause cannot be specified in the Linkage section.  The GLOBAL clause cannot be specified in the Linkage section. -----IBM Extension-----  The GLOBAL clause can be specified for a data-name or condition-name in the LINKAGE section, with level number 01. When GLOBAL is specified in a LINKAGE section data item, a contained source program can refer directly to the item by the name of the data item. ---End of IBM Extension--- Note: A maximum of 16 711 568 bytes is permitted for group items (including tables). Related Information:  ADDRESS OF Statement  ADDRESS OF Special Register ═══ 9.4. ADDRESS OF ═══ -----IBM Extension----- ADDRESS OF refers to the calculated address of a data item. The data item can be reference modified or subscripted. You may take the ADDRESS OF any Data Division item except for level number 66 or 88. Such an address can be referenced, but not changed. The ADDRESS OF an item is implicitly defined as USAGE IS POINTER. ---End of IBM Extension--- ═══ 9.5. ADDRESS OF Special Register ═══ -----IBM Extension----- The ADDRESS OF special register is the starting address of the data structure from which all calculated addresses are determined. It exists for each record (level number 01 or 77) in the Linkage Section, except for those records that redefine each other. In such cases, the special register is similarly redefined. This special register is implicitly defined as USAGE IS POINTER, and you can change it. If you reference modify the ADDRESS OF identifier, it is no longer the starting address of a data structure. It is a calculated address. ---End of IBM Extension--- ═══ 9.6. Data Types ═══ Two types of data can be processed: file data and program data. File Data A file is a collection of data records existing on some input-output device. (See File Section.) A file can be considered to be a group of physical records; it can also be considered to be a group of logical records. A physical record is a unit of data that is treated as an entity when moved into or out of storage. The size of a physical record is determined by the particular input-output device on which it is stored. The size does not necessarily have a direct relationship to the size or content of the logical information contained in the file. A logical record is a unit of data whose subdivisions have a logical relationship. A logical record may itself be a physical record (that is, be contained completely within one physical unit of data); several logical records may be contained within one physical record, or one logical record may extend across several physical records. File description entries specify the physical aspects of the data (such as the size relationship between physical and logical records, the size and name(s) of the logical record(s).) Record description entries describe the logical records in the file, including the category and format of data within each field of the logical record, different values the data might be assigned. After the relationship between physical and logical records has been established, only logical records are made available to you. For this reason, a reference in this manual to "records" means logical records, unless the term "physical records" is used. Program Data Program data is created by the program itself, instead of being read from a file. The concept of logical records applies to program data as well as to file data. Program data can thus be grouped into logical records, and be defined by a series of record description entries. Items that need not be so grouped can be defined in independent data item description entries. ═══ 9.7. Data Relationships ═══ The relationships among all data to be used in a program are defined in the Data Division, through a system of level indicators and level-numbers. A level indicator, with its descriptive entry, identifies each file in a program. Level indicators represent the highest level of any data hierarchy with which they are associated; FD is the file description level indicator and SD is the sort-merge file description level indicator. A level-number, with its descriptive entry, indicates the properties of specific data. Level-numbers can be used to describe a data hierarchy; they can indicate that this data has a special purpose, and while they can be associated with (and subordinate to) level indicators, they can also be used independently to describe internal data or data common to two or more programs. Related Information:  Levels of Data  Classes and Categories of Data  Signed Data. ═══ 9.7.1. Levels of Data ═══ After a record has been defined, it can be subdivided to provide more detailed data references. For example, in a customer file for a department store, one complete record could contain all data pertaining to one customer. Subdivisions within that record could be: customer name, customer address, account number, department number of sale, unit amount of sale, dollar amount of sale, previous balance, plus other pertinent information. The basic subdivisions of a record (that is, those fields not further subdivided) are called elementary items. Thus, a record can be made up of a series of elementary items, or it may itself be an elementary item. It may be necessary to refer to a set of elementary items; thus, elementary items can be combined into group items. Groups themselves can be combined into a more inclusive group that contains one or more subgroups. Thus, within one hierarchy of data items, an elementary item can belong to more than one group item. A system of level-numbers specifies the organization of elementary and group items into records. Special level-numbers are also used; they identify data items used for special purposes. Related Information:  Levels of Data in a Record Description Entry  Special Level Numbers  Indentation. ═══ 9.7.1.1. Levels of Data in a Record Description Entry ═══ Each group and elementary item in a record requires a separate entry, and each must be assigned a level-number. A level-number is a 1- or 2-digit integer between 01 and 49, or one of three special level-numbers: 66, 77, or 88. The following level-numbers are used to structure records: 01 This level-number specifies the record itself, and is the most inclusive level-number possible. A level-01 entry may be either a group item or an elementary item. It must begin in Area A. 02-49 These level-numbers specify group and elementary items within a record. They may begin in Area A or Area B. Less inclusive data items are assigned higher (not necessarily consecutive) level-numbers in this series. A group item includes all group and elementary items following it, until a level-number less than or equal to the level-number of this group is encountered. All elementary or group items immediately subordinate to one group item must be assigned identical level-numbers higher than the level-number of this group item. Related Information:  Coding Example  Conceptual Example. ═══ 9.7.1.2. Coding Example ═══ -----IBM Extension----- The ILE COBOL/400 compiler accepts nonstandard level-numbers that are not identical to others at the same level. For example, the following two data description entries are equivalent: 01 EMPLOYEE-RECORD. 05 EMPLOYEE-NAME. 10 FIRST PICTURE X(10). 10 LAST PICTURE X(10). 05 EMPLOYEE-ADDRESS. 10 STREET PICTURE X(10). 10 CITY PICTURE X(10). 01 EMPLOYEE-RECORD. 05 EMPLOYEE-NAME. 10 FIRST PICTURE X(10). 10 LAST PICTURE X(10). 04 EMPLOYEE-ADDRESS. 08 STREET PICTURE X(10). 08 CITY PICTURE X(10). Because 04 is less than 05, it is not subordinate to EMPLOYEE-NAME, yet because it is greater than 01 it is subordinate to EMPLOYEE-RECORD. If 07 was used in place of 04, EMPLOYEE-ADDRESS would be subordinate to EMPLOYEE-NAME (which in this example would be undesirable). IBM does not recommend such coding practices, and this extension is provided only for compatibility. ---End of IBM Extension--- ═══ 9.7.1.3. Conceptual Example ═══ Note that all groups immediately subordinate to the level-01 entry have the same level-number. Note also that elementary items from different subgroups do not necessarily have the same level numbers, and that elementary items can be specified at any level within the hierarchy. Levels in a Record Description The COBOL record-description entry written as follows: is subdivided as indicated below: 01 RECORD─ENTRY. ──────This entry includes───────┐ │ 05 GROUP─1. ──────This entry includes─────┐ │ │ │ 10 SUBGROUP─1. ────────This entry includes───┐ │ │ │ │ │ 15 ELEM─1 PIC... . │ │ │ 15 ELEM─2 PIC... .  │ │ │ │ 10 SUBGROUP─2. ────────This entry includes───┐ │ │ │ │ │ 15 ELEM─3 PIC... . │ │ │ 15 ELEM─4 PIC... .   │ │ 05 GROUP─2. ────────This entry includes───┐ │ │ │ 15 SUBGROUP─3. ─────────This entry includes─────┐ │ │ │ │ │ 25 ELEM─5 PIC... . │ │ │ 25 ELEM─6 PIC... .  │ │ │ │ 15 SUBGROUP─4 PIC... . This entry includes itself.  │ │ 05 ELEM─7 PIC... . This entry includes itself.  The storage arrangement of the record-description entry is illustrated below: │──────────────────────────────RECORD─ENTRY─────────────────────────────────────│ │ │ │ │ │───────────GROUP─1────────────────│───────────────GROUP─2───────│ │ │ │ │ │ │───SUBGROUP─1──│───SUBGROUP─2───│─────SUBGROUP─3─│ │ │ ┌───────┬─────────┬─────────┬────────┬─────────┬────────┬────────────┬────────────┐ │ELEM─1 │ ELEM─2 │ ELEM─3 │ ELEM─4 │ ELEM─5 │ ELEM─6 │ SUBGROUP─4 │ ELEM─7 │ └───────┴─────────┴─────────┴────────┴─────────┴────────┴────────────┴────────────┘ ═══ 9.7.1.4. Special Level-Numbers ═══ Special level-numbers identify items that do not structure a record. The special level-numbers are: 66 Identifies items that must contain only a RENAMES clause; such items regroup previously defined data items. (For details, see RENAMES Clause.) 77 Identifies data item description entries - independent Working-Storage or Linkage Section items that are not subdivisions of other items, and are not subdivided themselves. Level-77 items must begin in Area A. 88 Identifies any condition-name entry that is associated with a particular value of a conditional variable. The condition-name entry must contain only a VALUE clause. (For details, see VALUE OF Clause.) Note: Level-77 and level-01 entries in the Working-Storage and Linkage Sections that are referenced in the program must be given unique data-names, because neither can be qualified. Subordinate data-names that are referenced in the program must be either uniquely defined, or made unique through qualification. Unreferenced data-names need not be uniquely defined. ═══ 9.7.1.5. Indentation ═══ Successive data description entries may begin in the same column as preceding entries, or may be indented. Indentation is useful for documentation, but does not affect the action of the compiler. ═══ 9.7.2. Classes and Categories of Data ═══ Most data used in a COBOL program can be divided into classes and categories, except pointers, procedure-pointers, and index data items. Every elementary item in a program belongs to one of the classes as well as one of the categories. Every group item belongs to the alphanumeric class even if the subordinate elementary items belong to another class and category. Classes and Categories of Data shows the relationship of data classes and categories. The data category of an item is determined by its PICTURE character-string, BLANK WHEN ZERO, and USAGE attribute. For details, see Data Categories and PICTURE Rules. -----IBM Extension----- Boolean data is an IBM extension that provides a means of modifying and passing the values of the indicators associated with the display screen formats and externally described printer files. A Boolean value of 0 is the off status of the indicator, and a Boolean value of 1 is the on status of the indicator. A Boolean literal contains a single 0 or 1, is enclosed in quotation marks, and is immediately preceded by an identifying B. A Boolean literal is defined as either B"0" or B"1". A Boolean character occupies one byte. When the figurative constant ZERO is associated with a Boolean data item or a Boolean literal, it represents the Boolean literal B"0". The reserved word ALL is valid with a Boolean literal. ---End of IBM Extension--- Related Information:  Alignment Rules  Standard Data Format  Character-String and Item Size. ═══ 9.7.2.1. Classes and Categories of Data ═══ ┌──────────────────────────────────────────────────────────────────────────────┐ │ Classes and Categories of Data │ ├───────────────────┬─────────────────────────────┬────────────────────────────┤ │ LEVEL OF ITEM │ CLASS │ CATEGORY │ ├───────────────────┼─────────────────────────────┼────────────────────────────┤ │ Elementary │ Alphabetic │ Alphabetic │ │ ├─────────────────────────────┼────────────────────────────┤ │ │ Numeric │ Numeric │ │ ├─────────────────────────────┼────────────────────────────┤ │ │ Alphanumeric │ Numeric Edited │ │ │ ├────────────────────────────┤ │ │ │ Alphanumeric Edited │ │ │ ├────────────────────────────┤ │ │ │ Alphanumeric │ │ │ ├────────────────────────────┤ │ │ ├────────────────────────────┤ │ │ │ ─────IBM EXTENSION───── │ │ │ │ Boolean │ │ │ │ ───END OF IBM EXTENSION─── │ ├───────────────────┼─────────────────────────────┼────────────────────────────┤ │ Group │ Alphanumeric │ Alphabetic │ │ │ ├────────────────────────────┤ │ │ │ Numeric │ │ │ ├────────────────────────────┤ │ │ │ Numeric Edited │ │ │ ├────────────────────────────┤ │ │ │ Alphanumeric Edited │ │ │ ├────────────────────────────┤ │ │ │ Alphanumeric │ │ │ ├────────────────────────────┤ │ │ │ ─────IBM EXTENSION───── │ │ │ │ Boolean │ │ │ │ ───END OF IBM EXTENSION─── │ └───────────────────┴─────────────────────────────┴────────────────────────────┘ ═══ 9.7.3. Alignment Rules ═══ The standard alignment rules for positioning data in an elementary item depend on the category of a receiving item (that is, an item into which the data is moved; see Elementary Moves). Numeric: 1. The data is aligned on the assumed decimal point and if necessary, truncated or padded with zeros. (An assumed decimal point - PICTURE character P or V - is one that has logical meaning but that does not exist as an actual character in the data.) 2. If an assumed decimal point is not explicitly specified, the receiving item is treated as though an assumed decimal point is specified immediately to the right of the field. The data is then treated according to the preceding rule. Numeric-edited: The data is aligned on the decimal point, and (if necessary) truncated or padded with zeros at either end, except when editing causes replacement of leading zeros. Alphanumeric, Alphanumeric-edited, Alphabetic: 1. The data is aligned at the leftmost character position, and (if necessary) truncated or padded with spaces at the right. 2. If the JUSTIFIED clause is specified for this receiving item, the above rule is modified, as described in JUSTIFIED Clause. ═══ 9.7.4. Standard Data Format ═══ For the ILE COBOL/400 language, the default data format is the EBCDIC character set. ═══ 9.7.5. Character-String and Item Size ═══ In your program, the size of an elementary item is determined through the number of character positions specified in its PICTURE character-string. In storage, however, the size is determined by the actual number of bytes the item occupies, as determined by the combination of its PICTURE character-string and its USAGE clause. Normally, when an arithmetic item is moved from a longer field into a shorter one, the compiler truncates the data to the number of characters represented in the shorter item's PICTURE character-string. For example, if a sending field with PICTURE S99999, and containing the value +12345, is moved to a BINARY receiving field with PICTURE S99, the data is truncated to +45. For additional information see USAGE Clause. ═══ 9.7.6. Signed Data ═══ There are two categories of algebraic signs used in COBOL: operational signs and editing signs. Operational signs (+, -) are associated with signed numeric items, and indicate their algebraic properties. The internal representation of an algebraic sign depends on the item's USAGE clause, and, optionally, upon its SIGN clause. Zero is considered a unique value, regardless of the operational sign. An unsigned field is always assumed to be either positive or zero. Editing signs are associated with numeric edited items; editing signs are PICTURE symbols (+, -, CR, DB) that identify the sign of the item in edited output. ═══ 10. Data Division-File and Sort Description Entries ═══ In a COBOL program, the File Description (FD) Entry (or Sort Description (SD) Entry for sort/merge files) represents the highest level of organization in the File Section. The File Description (FD) Entry (or Sort Description (SD) Entry) has six formats:  Format 1 - Sequential File  Format 2 - Diskette File  Format 3 - Tapefile  Format 4 - Printer File  Format 5 - Sort or Merge Files -----IBM Extension-----  Format 6 - Transaction File ---End of IBM Extension--- ═══ 10.1. File Description Entry - Format 1 - Sequential File ═══ ┌─── FILE DESCRIPTION ENTRY - FORMAT 1A - FORMATFILE, DATABASE ────────────────┐ │ │ │ >>──FD────file-name──┬──────────────────┬──┬────────────────┬──────────────> │ │ └─┬────┬──EXTERNAL─┘ └─┬────┬──GLOBAL─┘ │ │ └─IS─┘ └─IS─┘ │ │ │ │ >──┬─────────────────────────────────────────────────────────────────┬─────> │ │ └─BLOCK──┬──────────┬──┬──────────────┬──integer2──┬────────────┬─┘ │ │ └─CONTAINS─┘ └─integer1──TO─┘ ├─CHARACTERS─┤ │ │ └─RECORDS────┘ │ │ │ │ >──┬──────────────────────────────────────────────────────────────────┬────> │ │ └─RECORD──┬──────────┬──┬─integer3───────────────┬──┬────────────┬─┘ │ │ └─CONTAINS─┘ └─integer6──TO──integer7─┘ └─CHARACTERS─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ │ (1) │ │ │ └─LABEL─────┬─RECORD──┬────┬───┬──┬─STANDARD─┬─┘ │ │ │ └─IS─┘ │ └─OMITTED──┘ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ >──┬────────────────────────────────────────────────────────────┬──────────> │ │ │ (1) ┌────────────────────────────────────────┐ │ │ │ │  │ │ │ │ └─VALUE──OF─────────system-name-1──┬────┬──┬─data-name-1─┬─┴─┘ │ │ └─IS─┘ └─literal-1───┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──.──>< │ │ │ (1) ┌─────────────┐ │ │ │ │  │ │ │ │ └─DATA─────┬─RECORD──┬────┬───┬────data-name-2─┴─┘ │ │ │ └─IS─┘ │ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ┌─── FILE DESCRIPTION ENTRY - FORMAT 1B - DISK ────────────────────────────────┐ │ │ │ >>──FD────file-name──┬──────────────────┬──┬────────────────┬──────────────> │ │ └─┬────┬──EXTERNAL─┘ └─┬────┬──GLOBAL─┘ │ │ └─IS─┘ └─IS─┘ │ │ │ │ >──┬─────────────────────────────────────────────────────────────────┬─────> │ │ └─BLOCK──┬──────────┬──┬──────────────┬──integer2──┬────────────┬─┘ │ │ └─CONTAINS─┘ └─integer1──TO─┘ ├─CHARACTERS─┤ │ │ └─RECORDS────┘ │ │ │ │ >──┬──────────────────────────────────────────────────────────────────┬────> │ │ └─RECORD──┬─┬──────────┬──integer3──┬────────────┬───────────────┬─┘ │ │ │ └─CONTAINS─┘ └─CHARACTERS─┘ │ │ │ ├─┬──────────┬──integer6──TO──integer7──┬────────────┬─┤ │ │ │ └─CONTAINS─┘ └─CHARACTERS─┘ │ │ │ └─┤ varying ├──┬────────────────────────────────┬──────┘ │ │ └─DEPENDING──┬────┬──data-name-1─┘ │ │ └─ON─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ │ (1) │ │ │ └─LABEL─────┬─RECORD──┬────┬───┬──┬─STANDARD─┬─┘ │ │ │ └─IS─┘ │ └─OMITTED──┘ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ >──┬────────────────────────────────────────────────────────────┬──────────> │ │ │ (1) ┌────────────────────────────────────────┐ │ │ │ │  │ │ │ │ └─VALUE──OF─────────system-name-1──┬────┬──┬─data-name-1─┬─┴─┘ │ │ └─IS─┘ └─literal-1───┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──.──>< │ │ │ (1) ┌─────────────┐ │ │ │ │  │ │ │ │ └─DATA─────┬─RECORD──┬────┬───┬────data-name-2─┴─┘ │ │ │ └─IS─┘ │ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ VARYING: │ │ ├──┬────┬──VARYING──┬────┬──┬──────┬──┬─────────────────────┬──────────────> │ │ └─IS─┘ └─IN─┘ └─SIZE─┘ └─┬──────┬──integer-4─┘ │ │ └─FROM─┘ │ │ │ │ >──┬───────────────┬──┬────────────┬──┤ │ │ └─TO──integer-5─┘ └─CHARACTERS─┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 10.2. File Description Entry - Format 2 - Diskette File ═══ ┌─── FILE DESCRIPTION ENTRY - FORMAT 2 - DISKETTE ─────────────────────────────┐ │ │ │ >>──FD────file-name──┬──────────────────┬──┬────────────────┬──────────────> │ │ └─┬────┬──EXTERNAL─┘ └─┬────┬──GLOBAL─┘ │ │ └─IS─┘ └─IS─┘ │ │ │ │ >──┬────────────────────────────────────────────────────────────────────┬──> │ │ │ (1) │ │ │ └─BLOCK─────┬──────────┬──┬──────────────┬──integer2──┬────────────┬─┘ │ │ └─CONTAINS─┘ └─integer1──TO─┘ ├─CHARACTERS─┤ │ │ └─RECORDS────┘ │ │ │ │ >──┬──────────────────────────────────────────────────────────────────┬────> │ │ └─RECORD──┬──────────┬──┬─integer3───────────────┬──┬────────────┬─┘ │ │ └─CONTAINS─┘ └─integer6──TO──integer7─┘ └─CHARACTERS─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ │ (1) │ │ │ └─LABEL─────┬─RECORD──┬────┬───┬──┬─STANDARD─┬─┘ │ │ │ └─IS─┘ │ └─OMITTED──┘ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ >──┬────────────────────────────────────────────────────────────┬──────────> │ │ │ (1) ┌────────────────────────────────────────┐ │ │ │ │  │ │ │ │ └─VALUE──OF─────────system-name-1──┬────┬──┬─data-name-1─┬─┴─┘ │ │ └─IS─┘ └─literal-1───┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──────────────────────> │ │ │ (1) ┌─────────────┐ │ │ │ │  │ │ │ │ └─DATA─────┬─RECORD──┬────┬───┬────data-name-2─┴─┘ │ │ │ └─IS─┘ │ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ >──┬───────────────────────────────────┬──.──>< │ │ └─CODE-SET──┬────┬──alphabet-name-1─┘ │ │ └─IS─┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 10.3. File Description Entry - Format 3 - Tapefile ═══ ┌─── FILE DESCRIPTION ENTRY - FORMAT 3 - TAPEFILE ─────────────────────────────┐ │ │ │ >>──FD────file-name──┬──────────────────┬──┬────────────────┬──────────────> │ │ └─┬────┬──EXTERNAL─┘ └─┬────┬──GLOBAL─┘ │ │ └─IS─┘ └─IS─┘ │ │ │ │ >──┬─────────────────────────────────────────────────────────────────┬─────> │ │ └─BLOCK──┬──────────┬──┬──────────────┬──integer2──┬────────────┬─┘ │ │ └─CONTAINS─┘ └─integer1──TO─┘ ├─CHARACTERS─┤ │ │ └─RECORDS────┘ │ │ │ │ >──┬──────────────────────────────────────────────────────────────────┬────> │ │ └─RECORD──┬─┬──────────┬──integer3──┬────────────┬───────────────┬─┘ │ │ │ └─CONTAINS─┘ └─CHARACTERS─┘ │ │ │ ├─┬──────────┬──integer6──TO──integer7──┬────────────┬─┤ │ │ │ └─CONTAINS─┘ └─CHARACTERS─┘ │ │ │ └─┤ varying ├──┬────────────────────────────────┬──────┘ │ │ └─DEPENDING──┬────┬──data-name-1─┘ │ │ └─ON─┘ │ │ │ │ >──┬───────────────────────────────────────────┬───────────────────────────> │ │ └─LABEL──┬─RECORD──┬────┬───┬──┬─STANDARD─┬─┘ │ │ │ └─IS─┘ │ └─OMITTED──┘ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ >──┬────────────────────────────────────────────────────────────┬──────────> │ │ │ (1) ┌────────────────────────────────────────┐ │ │ │ │  │ │ │ │ └─VALUE──OF─────────system-name-1──┬────┬──┬─data-name-1─┬─┴─┘ │ │ └─IS─┘ └─literal-1───┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──────────────────────> │ │ │ (1) ┌─────────────┐ │ │ │ │  │ │ │ │ └─DATA─────┬─RECORD──┬────┬───┬────data-name-2─┴─┘ │ │ │ └─IS─┘ │ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ >──┬───────────────────────────────────┬──.──>< │ │ └─CODE-SET──┬────┬──alphabet-name-1─┘ │ │ └─IS─┘ │ │ │ │ VARYING: │ │ ├──┬────┬──VARYING──┬────┬──┬──────┬──┬─────────────────────┬──────────────> │ │ └─IS─┘ └─IN─┘ └─SIZE─┘ └─┬──────┬──integer-4─┘ │ │ └─FROM─┘ │ │ │ │ >──┬───────────────┬──┬────────────┬──┤ │ │ └─TO──integer-5─┘ └─CHARACTERS─┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 10.4. File Description Entry - Format 4 - Printer File ═══ ┌─── FILE DESCRIPTION ENTRY - FORMAT 4 - PRINTER ──────────────────────────────┐ │ │ │ >>──FD────file-name──┬──────────────────┬──┬────────────────┬──────────────> │ │ └─┬────┬──EXTERNAL─┘ └─┬────┬──GLOBAL─┘ │ │ └─IS─┘ └─IS─┘ │ │ │ │ >──┬─────────────────────────────────────────────────────────────────┬─────> │ │ └─BLOCK──┬──────────┬──┬──────────────┬──integer2──┬────────────┬─┘ │ │ └─CONTAINS─┘ └─integer1──TO─┘ ├─CHARACTERS─┤ │ │ └─RECORDS────┘ │ │ │ │ >──┬──────────────────────────────────────────────────────────────────┬────> │ │ └─RECORD──┬──────────┬──┬─integer3───────────────┬──┬────────────┬─┘ │ │ └─CONTAINS─┘ └─integer6──TO──integer7─┘ └─CHARACTERS─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ │ (1) │ │ │ └─LABEL─────┬─RECORD──┬────┬───┬──┬─STANDARD─┬─┘ │ │ │ └─IS─┘ │ └─OMITTED──┘ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ >──┬────────────────────────────────────────────────────────────┬──────────> │ │ │ (1) ┌────────────────────────────────────────┐ │ │ │ │  │ │ │ │ └─VALUE──OF─────────system-name-1──┬────┬──┬─data-name-1─┬─┴─┘ │ │ └─IS─┘ └─literal-1───┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──────────────────────> │ │ │ (1) ┌─────────────┐ │ │ │ │  │ │ │ │ └─DATA─────┬─RECORD──┬────┬───┬────data-name-2─┴─┘ │ │ │ └─IS─┘ │ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ >──┬───────────────────┬──┬───────────────────────────────────┬──.──>< │ │ └─┤ linage clause ├─┘ └─CODE-SET──┬────┬──alphabet-name-1─┘ │ │ └─IS─┘ │ │ │ │ LINAGE CLAUSE: │ │ ├──LINAGE──┬────┬──┬─data-name-3─┬──┬───────┬──────────────────────────────> │ │ └─IS─┘ └─integer-8───┘ └─LINES─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──FOOTING──┬──────┬──┬─data-name-4─┬─┘ │ │ └─WITH─┘ └─AT───┘ └─integer-9───┘ │ │ │ │ >──┬────────────────────────────────────────────┬──────────────────────────> │ │ └─┬───────┬──┬──────┬──TOP───┬─data-name-5─┬─┘ │ │ └─LINES─┘ └─AT───┘ └─integer-10──┘ │ │ │ │ >──┬──────────────────────────────────────────────┬──┤ │ │ └─┬───────┬──┬──────┬──BOTTOM──┬─data-name-6─┬─┘ │ │ └─LINES─┘ └─AT───┘ └─integer-11──┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 10.5. Sort Description Entry - Format 5 - Sort or Merge Files ═══ ┌─── FILE DESCRIPTION ENTRY - FORMAT 5 - SORT/MERGE ───────────────────────────┐ │ │ │ >>──SD────file-name────────────────────────────────────────────────────────> │ │ │ │ >──┬──────────────────────────────────────────────────────────────────┬────> │ │ └─RECORD──┬─┬──────────┬──integer3──┬────────────┬───────────────┬─┘ │ │ │ └─CONTAINS─┘ └─CHARACTERS─┘ │ │ │ ├─┬──────────┬──integer6──TO──integer7──┬────────────┬─┤ │ │ │ └─CONTAINS─┘ └─CHARACTERS─┘ │ │ │ └─┤ varying ├──┬────────────────────────────────┬──────┘ │ │ └─DEPENDING──┬────┬──data-name-1─┘ │ │ └─ON─┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──.──>< │ │ │ (1) ┌─────────────┐ │ │ │ │  │ │ │ │ └─DATA─────┬─RECORD──┬────┬───┬────data-name-2─┴─┘ │ │ │ └─IS─┘ │ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ VARYING: │ │ ├──┬────┬──VARYING──┬──────┬──┬──────┬──┬─────────────────────┬────────────> │ │ └─IS─┘ └─IN───┘ └─SIZE─┘ └─┬──────┬──integer-4─┘ │ │ └─FROM─┘ │ │ │ │ >──┬───────────────┬──┬────────────┬──┤ │ │ └─TO──integer-5─┘ └─CHARACTERS─┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 10.6. File Description Entry - Format 6 - Transaction Files ═══ -----IBM Extension----- ┌─── FILE DESCRIPTION ENTRY - FORMAT 6 - TRANSACTION ──────────────────────────┐ │ │ │ >>──FD────file-name──┬──────────────────┬──┬────────────────┬──────────────> │ │ └─┬────┬──EXTERNAL─┘ └─┬────┬──GLOBAL─┘ │ │ └─IS─┘ └─IS─┘ │ │ │ │ >──┬──────────────────────────────────────────────────────────────────┬────> │ │ └─RECORD──┬──────────┬──┬─integer3───────────────┬──┬────────────┬─┘ │ │ └─CONTAINS─┘ └─integer6──TO──integer7─┘ └─CHARACTERS─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ │ (1) │ │ │ └─LABEL─────┬─RECORD──┬────┬───┬──┬─STANDARD─┬─┘ │ │ │ └─IS─┘ │ └─OMITTED──┘ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──.──>< │ │ │ (1) ┌─────────────┐ │ │ │ │  │ │ │ │ └─DATA─────┬─RECORD──┬────┬───┬────data-name-2─┴─┘ │ │ │ └─IS─┘ │ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ---End of IBM Extension--- ═══ 10.7. File Section ═══ The File Section must contain a level indicator for each input and output file.  For all files except sort/merge, the File Section must contain an FD entry. The last clause of an FD entry must be immediately followed by a separator period.  For each sort or merge file, the File Section must contain an SD entry. The last clause of an SD entry must be immediately followed by a separator period. ═══ 10.7.1. file-name ═══ Must follow the level indicator (FD or SD), and must be the same as that specified in the associated SELECT clause. The file-name must adhere to the rules of formation for a user-defined word: at least one character must be alphabetic. The file-name must be unique within this program. One or more record description entries must follow the file-name. When more than one record description entry is specified, each entry implies a redefinition of the same storage area. The clauses that follow file-name are optional; they may appear in any order. ═══ 10.8. EXTERNAL Clause ═══ The EXTERNAL clause specifies that a file connector is external. ┌─── EXTERNAL CLAUSE - FORMAT ─────────────────────────────────────────────────┐ │ │ │ >>──┬────┬──EXTERNAL──>< │ │ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In a run unit, there is only one representation of an external file; an external file can be referenced by any program in the run unit that describes the file. In the File Section, the EXTERNAL clause can be specified only in file description entries. The records appearing in the file description entry need not have the same name in corresponding external file description entries. In addition, the number of such records need not be the same in corresponding file description entries. However, the maximum record length for corresponding external file description entries must be the same. For EXTERNAL files, the value of all BLOCK CONTAINS clauses of corresponding EXTERNAL files must match within the run unit. This conformance is in terms of character positions only - not upon whether the value was specified as CHARACTERS or as RECORDS. All file description entries in the run unit that are associated with an external file connector must have:  A LINAGE clause, if any file description entry has a LINAGE clause.  The same corresponding values for integer-8, integer-9, integer-10, and integer-11, if specified.  The same corresponding external data items referenced by data-name-3, data-name-4, data-name-5, and data-name-6. Use of the EXTERNAL clause does not imply that the associated file-name is a global name. ═══ 10.8.1. Considerations for External Files ═══ In general, all definitions of an external file should be identical. If there is a mismatch, the program will fail at start up when the definitions are compared. The following attributes of external files are compared:  If any of the definitions corresponding to the file are externally described (for example, by using Format 2 of the COPY statement), all other definitions must also be externally described. The level check information associated with all definitions must match.  The name specified on the ASSIGN TO clause must be the same for all definitions. This includes the device type.  The ORGANIZATION and ACCESS modes must be the same for all definitions of the file.  The OPTIONAL phrase, if specified, must be specified for all definitions of the file.  The external data item specified for the RELATIVE KEY phrase must be in the same physical location and occupy the same number of bytes for all definitions of the file.  The location of the record key within the associated record must be the same for all definitions of the file.  The blocking information associated with the file must be the same for all file definitions. This includes whether blocking is to be performed and the size of the block.  The values for the maximum or minimum number of characters on the RECORD clause must be the same for all definitions of the file.  The character set specified on the CODE-SET clause must be the same for all definitions of the file.  The value specified for the DUPLICATES phrase must be the same for all definitions of the file.  All of the values specified for the LINAGE clause must be the same for each definition of the file.  The specification of the attribute for the ASSIGN clause (separate indicators) must be the same for all definitions of the file.  The specification for the COMMITMENT CONTROL clause must be the same for all definitions of the file.  The specification for the *DUPKEYCHK or the *INZDLT compile-time option must be the same for all modules containing definitions of the file. ═══ 10.9. GLOBAL Clause ═══ The GLOBAL clause specifies that the file connector named by a file-name is a global name. ┌─── GLOBAL CLAUSE - FORMAT ───────────────────────────────────────────────────┐ │ │ │ >>──┬────┬──GLOBAL──>< │ │ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ A global file-name is available to the program that declares it and to every program that is contained directly or indirectly in that program. A file-name is global if the GLOBAL clause is specified in the file description entry for that file-name. A record-name is global if the GLOBAL clause is specified in the record description entry by which the record-name is declared or, in the case of record description entries in the File Section, if the GLOBAL clause is specified in the file description entry for the file-name associated with the record description entry. ═══ 10.10. BLOCK CONTAINS Clause ═══ The BLOCK CONTAINS clause specifies the size of the physical records. ┌─── BLOCK CONTAINS CLAUSE - FORMAT ───────────────────────────────────────────┐ │ │ │ >>──BLOCK──┬──────────┬──┬────────────────┬──integer-2──┬────────────┬──>< │ │ └─CONTAINS─┘ └─integer-1── TO─┘ ├─CHARACTERS─┤ │ │ └─RECORDS────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ This clause can be omitted when each physical record contains only one complete logical record. This clause is syntax checked for FORMATFILE and printer files. To activate this clause for other types of files, use OPTION parameter value *BLK, or PROCESS option BLK. ═══ 10.10.1. CHARACTERS ═══ Specifies the number of character positions required to store the physical record, no matter what USAGE the characters have within the data record. If only integer-2 is specified, it specifies the exact character size of the physical record. When integer-1 and integer-2 are both specified, they represent, respectively, the minimum and maximum character sizes of the physical record. Integer-1 and integer-2 must include any control bytes and padding contained in the physical record. (Logical records do not include padding.) For non-tape files, only integer-2 controls the blocking factor. If integer-2 is zero, the system default blocking factor applies. The CHARACTERS phrase is the default. CHARACTERS must be specified when the physical record contains padding. In general, the length of a variable length record on a RELEASE, REWRITE, or WRITE statement is determined by data-name-1, if specified. If data-name-1 is not specified and the record description does not contain a table, the length is the number of characters in the record description. If data-name-1 is not specified and the record contains a table, the length is the sum of the fixed part of the record and the current length of the table. When variable length records are used for disk files, the BLOCK CONTAINS clause specifies the size of the block. The size of the actual record is contained in data-name-1 after a READ operation. To WRITE a variable length record, data-name-1 must be set to the length of the record. For tape files, each variable record contains a four-byte header and each block contains a four-byte header when the data is transferred to tape. However, these four-byte headers are provided by the system and are of no concern to the COBOL user except that the maximum size of a variable record is restricted to 32 764. When variable records are used for tape files, the BLOCK CONTAINS clause specifies the maximum physical record length, while the logical record length for each record is inferred by the compiler from the record name used in a WRITE statement. If an explicit length is required after a READ statement, the user can obtain it through the I-O-FEEDBACK mnemonic-name. ═══ 10.10.2. RECORDS ═══ Specifies the number of logical records contained in each physical record. Maximum record size is 32 767; maximum block size is 32 767. These maximums include any control bytes required for variable blocked records; thus, the maximum size data record for a variable-blocked record is 32 759. ═══ 10.11. RECORD Clause ═══ The RECORD clause specifies the number of character positions for fixed-length or variable-length records. The RECORD clause has three formats:  Format 1 - for fixed-length records  Format 2 - for variable-length records  Format 3 - for fixed-length records or variable-length records Related Information:  General considerations for all three formats. ═══ 10.11.1. RECORD clause - Format 1 ═══ Format 1 specifies the number of character positions for fixed length records. ┌─── RECORD CLAUSE - FORMAT 1 ─────────────────────────────────────────────────┐ │ │ │ >>──RECORD──┬──────────┬──integer-3──┬────────────┬──>< │ │ └─CONTAINS─┘ └─CHARACTERS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ When the maximum record length determined from the record description entries does not match the length specified in the RECORD clause, the maximum will be used. ═══ 10.11.2. RECORD clause - Format 2 ═══ Format 2 is the recommended format when dealing with variable records. ┌─── RECORD CLAUSE - FORMAT 2 ─────────────────────────────────────────────────┐ │ │ │ >>──RECORD──┬────┬──VARYING──┬────┬──┬──────┬──┬─────────────────────┬─────> │ │ └─IS─┘ └─IN─┘ └─SIZE─┘ └─┬──────┬──integer-4─┘ │ │ └─FROM─┘ │ │ │ │ >──┬───────────────┬──┬────────────┬───────────────────────────────────────> │ │ └─TO──integer-5─┘ └─CHARACTERS─┘ │ │ │ │ >──┬────────────────────────────────┬──>< │ │ └─DEPENDING──┬────┬──data-name-1─┘ │ │ └─ON─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The number of character positions associated with a record description is determined by the sum of the number of character positions in all elementary data items (excluding redefinitions and renamings), plus any implicit FILLER due to synchronization. If a table is specified, the minimum and maximum number of table elements described in the record are used in the summation above, to determine the minimum and maximum number of character positions associated with the record description. If the number of character positions in the logical record to be written is less than integer-4 or greater than integer-5, the output statement is unsuccessful and, except during execution of a RELEASE statement, the associated I-O status key is set to a value indicating the cause of the condition. During the execution of a RELEASE, REWRITE, or WRITE statement, the number of character positions in the record is determined by the following conditions:  If data-name-1 is specified, by the content of the data item referenced by data-name-1.  If data-name-1 is not specified and the record does not contain a variable occurrence data item, by the number of character positions in the record.  If data-name-1 is not specified and the record contains a variable occurrence data item, by the sum of the fixed portion and that portion of the table described by the number of occurrences at the time of execution of the output statement. During the execution of a READ ... INTO or RETURN ... INTO statement, the number of character positions in the current record that participate as the sending data items in the implicit MOVE statement is determined by the following conditions:  If data-name-1 is specified, by the content of the data item referenced by data-name-1.  If data-name-1 is not specified, by the value that would have been moved into the data item referenced by data-name-1 had data-name-1 been specified. ═══ 10.11.3. RECORD clause - Format 3 ═══ Format 3 specifies the number of character positions for either fixed or variable length records. (The latter is only applicable to tape files.) ┌─── RECORD CLAUSE - FORMAT 3 ─────────────────────────────────────────────────┐ │ │ │ >>──RECORD──┬──────────┬──integer-6──TO ──integer-7──┬────────────┬──>< │ │ └─CONTAINS─┘ └─CHARACTERS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ For Tape Files In this case, the records are variable, and the following descriptions apply. For All Other Files If Format 3 is used for non-tape files, the records are treated as fixed length records the size of the largest data record. The logical records are truncated or padded to the length of the record as defined in the CRTxxxF CL command. User length in the following table is defined as the largest record associated with the given file, as specified by its record description. ┌──────────────┬──────────────────┬────────────────────────────────┐ │ │ USER LENGTH LESS │ USER LENGTH │ │ INPUT/OUTPUT │ THAN FILE RECORD │ GREATER THAN │ │ TYPE │ LENGTH │ FILE RECORD LENGTH │ ├──────────────┼──────────────────┼────────────────────────────────┤ │ Input │ Truncation │ Pad with blanks. │ ├──────────────┼──────────────────┼────────────────────────────────┤ │ Output │ Pad with blanks │ Truncation if old file (non- │ │ │ │ empty); for new (empty files) │ │ │ │ the larger record length is │ │ │ │ used. │ └──────────────┴──────────────────┴────────────────────────────────┘ Note: The maximum record length for a file is 32 767. ═══ 10.11.4. General Considerations for all Formats ═══ When the RECORD clause is used, the record size must be specified as the number of character positions needed to store the record internally. That is, it must specify the number of bytes occupied internally by the characters of the record, not the number of characters used to represent the data item within the record. The size of a record is determined according to the rules for obtaining the size of a group item. When the RECORD clause is omitted, the compiler determines the record lengths from the record descriptions. When one of the entries within a record description contains an OCCURS DEPENDING ON clause, the compiler uses the maximum value of the variable-length item to calculate the number of character positions needed to store the record internally. If the associated file connector is an external file connector, all file description entries in the run unit that are associated with that file connector must specify the same maximum number of character positions. ═══ 10.12. LABEL RECORDS Clause ═══ The LABEL RECORDS clause indicates the presence or absence of labels. FD -Format 3 (TAPEFILE) is the only format in which this clause is not syntax checked. For all other FD formats, this clause is syntax checked only, then treated as documentation. ┌─── LABEL RECORDS CLAUSE - FORMAT ────────────────────────────────────────────┐ │ │ │ (1) │ │ >>──LABEL─────┬─RECORD──┬────┬───┬──┬─STANDARD─┬──>< │ │ │ └─IS─┘ │ └─OMITTED──┘ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ If it is not specified for a file, label records for that file must conform to the system label specifications. ═══ 10.13. VALUE OF Clause ═══ The VALUE OF clause describes an item in the label records associated with this file. The clause is syntax checked, then treated as documentation. ┌─── VALUE OF CLAUSE - FORMAT ─────────────────────────────────────────────────┐ │ │ │ (1) ┌────────────────────────────────────────┐ │ │  │ │ │ >>──VALUE OF───────system-name-1──┬────┬──┬─data-name-1─┬─┴──>< │ │ └─IS─┘ └─literal-1───┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 10.14. DATA RECORDS Clause ═══ The DATA RECORDS clause is syntax checked and it serves only as documentation for the names of data records associated with this file. ┌─── DATA RECORDS CLAUSE - FORMAT ─────────────────────────────────────────────┐ │ │ │ (1) ┌─────────────┐ │ │  │ │ │ >>──DATA─────┬─RECORD──┬────┬───┬────data-name-2─┴──>< │ │ │ └─IS─┘ │ │ │ └─RECORDS──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The specification of more than one data-name indicates that this file contains more than one type of data record. Two or more record descriptions for this file occupy the same storage area. These records need not have the same description or length. The order in which the data-names are listed is not significant. ═══ 10.15. LINAGE Clause ═══ The LINAGE clause specifies the depth of a logical page in terms of number of lines. Optionally, it also specifies the line number at which the footing area begins, as well as the top and bottom margins of the logical page. (The logical page and the physical page don't necessarily have to be of the same size.) The LINAGE clause can be specified only for files assigned to the device PRINTER. See ASSIGN Clause. AS/400 printer files offer a number of powerful features through DDS that can be used to advantage. Such files are declared in COBOL/400 programs as FORMATFILE. For more information on printer files, see the DDS Reference. ┌─── LINAGE CLAUSE - FORMAT ───────────────────────────────────────────────────┐ │ │ │ >>──LINAGE──┬────┬──┬─data-name-3─┬──┬───────┬─────────────────────────────> │ │ └─IS─┘ └─integer-8───┘ └─LINES─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └──┬──────┬─FOOTING─┬──────┬──┬─data-name-4─┬──┘ │ │ └─WITH─┘ └─AT───┘ └─integer-9───┘ │ │ │ │ >──┬────────────────────────────────────────────┬──────────────────────────> │ │ └─┬───────┬──┬──────┬──TOP───┬─data-name-5─┬─┘ │ │ └─LINES─┘ └─AT───┘ └─integer-10──┘ │ │ │ │ >──┬──────────────────────────────────────────────┬──>< │ │ └─┬───────┬──┬──────┬──BOTTOM──┬─data-name-6─┬─┘ │ │ └─LINES─┘ └─AT───┘ └─integer-11──┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The LINAGE clause does not affect the number of lines in the selected device file; it only affects the logical page mechanism within the COBOL program. At execution time, the printer file being used determines the physical page size. This information is used to issue appropriate space and eject commands to produce the logical page as defined in the LINAGE clause. Thus, the logical page can contain multiple physical pages, or one physical page can contain multiple logical pages. All integers must be unsigned. All data-names must be described as unsigned integer data items. Related Information:  Illustration of LINAGE clause phrases  LINAGE-COUNTER Special Register ═══ 10.15.1. Illustration of LINAGE clause phrases ═══ LINAGE Clause Phrases ┌───────────────────────────────────────────────────────────────────┐ │)   │ │) LINES AT TOP integer─10 (top margin) │ │ │)  │ │ ├───────────────────────────────────────────────────────────┼───────┤ │  │ │ │ │ │ │ │ │ logical │ │ page body page depth │ │ │ │ │ │ │ │ │ │ │ │ │ │ WITH FOOTING integer─9 ────────────────────┼─────────────┼───────┤ │  │ │ │ │ footing area │ │ │ │   │ │ │ LINAGE integer─8 ────────────────────────────────────────┼───────│ │)  │ │ │) LINES AT BOTTOM integer─11 (bottom│margin) │ │ │)   │ └───────────────────────────────────────────────────────────────────┘ The logical page size specified in the LINAGE clause is the sum of all values specified in each phrase except the FOOTING phrase. If the LINES AT TOP and/or the LINES AT BOTTOM phrase is omitted, the assumed value for top and bottom margins is zero. Each logical page immediately follows the preceding logical page, with no additional spacing provided. If the FOOTING phrase is specified and the value of data-name-4 or integer-9 is equal to the LINAGE value of data-name-3 or integer-8, one line (the last line of the logical page) is available for footing information. If the FOOTING phrase is omitted, its assumed value is equal to that of the page body (integer-8 or data-name-3). At the time an OPEN OUTPUT statement is executed, the values of integer-8, integer-9, integer-10, and integer-11, if specified, are used to determine the page body, first footing line, top margin, and bottom margin of the logical page for this file. See LINAGE Clause Phrases. These values are then used for all logical pages printed for this file during a given execution of the program. At the time an OPEN statement with the OUTPUT phrase is executed for the file, data-name-3, data-name-4, data-name-5, and data-name-6 determine the page body, first footing line, top margin, and bottom margin for the first logical page only. At the time a WRITE statement with the ADVANCING PAGE phrase is executed or a page overflow condition occurs, the values of data-name-3, data-name-4, data-name-5, and data-name-6, if specified, are used to determine the page body, first footing line, top margin, and bottom margin for the next logical page. ═══ 10.15.2. LINAGE-COUNTER Special Register ═══ A separate LINAGE-COUNTER special register is generated for each FD entry containing a LINAGE clause (when more than one is generated, you must qualify each LINAGE-COUNTER with its related file-name). The implicit description of LINAGE-COUNTER is one of the following:  If the LINAGE clause specifies data-name-3, LINAGE-COUNTER has the same PICTURE and USAGE as data-name-3.  If the LINAGE clause specifies integer-8, LINAGE-COUNTER is a binary item large enough to hold the binary representation of integer-8. The value in LINAGE-COUNTER at any given time is the line number at which the device is positioned within the current page. LINAGE-COUNTER may be referred to in Procedure Division statements; it cannot be modified by them. LINAGE-COUNTER is initialized to 1 when an OPEN statement for this file is executed. LINAGE-COUNTER is automatically modified by any WRITE statement for this file. (See WRITE Statement.) If the file description for a sequential file contains the LINAGE clause and the EXTERNAL clause, the LINAGE-COUNTER data item is an external data item. Similarly, if it contains the LINAGE and GLOBAL clauses, the LINAGE-COUNTER data item is a global data item. ═══ 10.16. CODE-SET Clause ═══ The CODE-SET clause specifies the character code used to represent data on DISKETTE and TAPEFILE. ┌─── CODE-SET CLAUSE - FORMAT ─────────────────────────────────────────────────┐ │ │ │ >>──CODE-SET──┬────┬──alphabet-name-1──>< │ │ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ When the CODE-SET clause is specified, an alphabet-name identifies the character code convention used to represent data on the input-output device. The CODE-SET clause also specifies the algorithm for converting the character codes on the input-output medium from/to the internal EBCDIC character set. Alphabet-name-1 must be defined in the SPECIAL-NAMES paragraph as STANDARD-1 (for ASCII-encoded files), STANDARD-2 (for ISO 7-bit encoded files), NATIVE (for EBCDIC-encoded files), or EBCDIC (for EBCDIC-encoded files). When NATIVE is specified, the CODE-SET clause is syntax checked, but it has no effect on the execution of the program. When the CODE-SET clause is specified for a file, all data in this file must have USAGE DISPLAY, and, if signed numeric data is present, it must be described with the SIGN IS SEPARATE clause. When the CODE-SET clause is omitted, the EBCDIC character set is assumed. Note: The AS/400 system only supports ASCII and ISO for tape and diskette files. Therefore, if the CODE-SET clause specifies a character code set of STANDARD-1 (ASCII), or STANDARD-2 (ISO) for a file that is not a tape or diskette file, a warning message is issued and the EBCDIC character set will be used. -----IBM Extension----- If the CODE-SET clause is omitted, the CODE parameter of the Create Diskette File (CRTDKTF) or the Create Tape File (CRTTAPF) CL command is used. The CODE-SET clause can be changed at execution time by specifying the CODE parameter on the Override with Diskette File (OVRDKTF) or the Override with Tape File (OVRTAPF) CL command. ---End of IBM Extension--- ═══ 11. Data Division-Data Description Entry ═══ A data description entry specifies the characteristics of a data item. Data items have attributes, which may be either implicit (default values), or explicit. This section describes the coding of data description entries and record description entries (which are sets of data description entries). The single term data description entry is used in this section to refer to data and record description entries. Data description entries that define independent data items do not make up a record. These are known as data item description entries. The data description entry has four general formats.  Format 1 is used for data description entries in all Data Division sections.  Format 2 regroups previously defined items.  Format 3 describes condition names. -----IBM Extension-----  Format 4 describes boolean data items. ---End of IBM Extension--- ═══ 11.1. Format 1 ═══ Format 1 is used for data description entries in all Data Division sections. Level-number in this format can be any number from 01-49, as well as 77. ┌─── DATA DESCRIPTION ENTRY - GENERAL FORMAT 1 ────────────────────────────────┐ │ │ │ >>──level-number──┬─────────────┬──────────────────────────────────────────> │ │ ├─data-name-1─┤ │ │ └─FILLER──────┘ │ │ │ │ >──┬─────────────────────────────────────┬──┬──────────────────┬───────────> │ │ ├─REDEFINES──data-name-2──────────────┤ └─┬────┬──EXTERNAL─┘ │ │ │ (1) │ └─IS─┘ │ │ └─LIKE─────data-name-3──┬───────────┬─┘ │ │ └─(integer)─┘ │ │ │ │ >──┬───────────────────────┬──┬────────────────┬───────────────────────────> │ │ └─BLANK──┬──────┬──ZERO─┘ └─┬────┬──GLOBAL─┘ │ │ └─WHEN─┘ └─IS─┘ │ │ │ │ >──┬─────────────────────────────┬──┬──────────────────────────────┬───────> │ │ └─┬─JUST──────┬──┬──────────┬─┘ ├─┤ OCCURS clause - Format 1 ├─┤ │ │ └─JUSTIFIED─┘ │ (2)│ └─┤ OCCURS clause - Format 2 ├─┘ │ │ └─RIGHT────┘ │ │ │ │ >──┬───────────────────────────────────────┬───────────────────────────────> │ │ └─┬─PICTURE─┬──┬────┬──character-string─┘ │ │ └─PIC─────┘ └─IS─┘ │ │ │ │ >──┬─────────────────────────────────────────────────────────────┬─────────> │ │ └─┬──────────────┬──┬─LEADING──┬──┬─────────────────────────┬─┘ │ │ └─SIGN──┬────┬─┘ └─TRAILING─┘ └─SEPARATE──┬───────────┬─┘ │ │ └─IS─┘ └─CHARACTER─┘ │ │ │ │ >──┬────────────────────────┬──┬────────────────────────────────┬──────────> │ │ └─VALUE──┬────┬──literal─┘ └─┬─SYNCHRONIZED─┬──┬──────────┬─┘ │ │ └─IS─┘ └─SYNC─────────┘ │ (2) │ │ │ ├─LEFT─────┤ │ │ │ (2)│ │ │ └─RIGHT────┘ │ │ │ │ >──┬─────────────────────────────────────────────┬──>< │ │ └─┬───────────────┬──┬─BINARY───────────────┬─┘ │ │ └─USAGE──┬────┬─┘ ├─COMPUTATIONAL────────┤ │ │ └─IS─┘ ├─COMP─────────────────┤ │ │ │ (1) │ │ │ ├─COMPUTATIONAL-3──────┤ │ │ │ (1) │ │ │ ├─COMP-3───────────────┤ │ │ │ (1) │ │ │ ├─COMPUTATIONAL-4──────┤ │ │ │ (1) │ │ │ ├─COMP-4───────────────┤ │ │ ├─DISPLAY──────────────┤ │ │ ├─INDEX────────────────┤ │ │ ├─PACKED-DECIMAL───────┤ │ │ │ (1) │ │ │ ├─POINTER──────────────┤ │ │ │ (1)│ │ │ └─PROCEDURE-POINTER────┘ │ │ │ │ OCCURS CLAUSE - FORMAT 1: │ │ ├──OCCURS──integer-2──┬───────┬──┤ key-indexed-by phrase ├──┤ │ │ └─TIMES─┘ │ │ │ │ OCCURS CLAUSE - FORMAT 2: │ │ ├──OCCURS──integer-1──TO──integer-2──┬───────┬──DEPENDING──┬────┬──────────> │ │ └─TIMES─┘ └─ON─┘ │ │ │ │ >──data-name-1──┤ key-indexed-by phrase ├──┤ │ │ │ │ KEY-INDEXED-BY PHRASE: │ │ ┌──────────────────────────────────────────────────────────┐ │ │  │ │ │ ├────┬──────────────────────────────────────────────────────┬─┴────────────> │ │ │ (3) ┌─────────────┐ │ │ │ │  │ │ │ │ └─┬─ASCENDING─────┬──┬──────┬──┬────┬────data-name-2─┴─┘ │ │ │ (3)│ └─KEY──┘ └─IS─┘ │ │ └─DESCENDING────┘ │ │ │ │ >──┬─────────────────────────────────────┬──┤ │ │ │ ┌──────────────┐ │ │ │ │  │ │ │ │ └─INDEXED──┬──────┬────index-name-1─┴─┘ │ │ └─BY───┘ │ │ │ │ NOTES: │ │ (1) IBM Extension │ │ │ │ (2) Syntax-checked only │ │ │ │ (3) Cannot be used with Boolean data │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The clauses may be written in any order with two exceptions:  If data-name or FILLER is specified, it must immediately follow the level-number.  When specified, the REDEFINES clause must be the first entry following data-name-1 or FILLER. If data-name-1 or FILLER is not specified, the REDEFINES clause must be the first entry following the level-number. The data item being described is treated as though FILLER has been specified. Not all clauses are compatible with each other. For details, see the descriptions of the individual clauses. Clauses must be separated by a space, a separator comma, or a separator semicolon. ═══ 11.2. Format 2 ═══ Format 2 regroups previously defined items. ┌─── DATA DESCRIPTION ENTRY - GENERAL FORMAT 2 ────────────────────────────────┐ │ │ │ >>──66──data-name-1──RENAMES──data-name-2──┬──────────────────────────┬────> │ │ └─┬─THROUGH─┬──data-name-3─┘ │ │ └─THRU────┘ │ │ │ │ >──.──>< │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ A level-66 entry cannot rename another level-66 entry, nor can it rename a level-01, level-77, or level-88 entry. All level-66 entries associated with one record must immediately follow the last data description entry in that record. Details are contained in RENAMES Clause. ═══ 11.3. Format 3 ═══ Format 3 describes condition-names. ┌─── DATA DESCRIPTION ENTRY - GENERAL FORMAT 3 ────────────────────────────────┐ │ │ │ >>──88──condition-name──┬─VALUE──┬────┬───┬────────────────────────────────> │ │ │ └─IS─┘ │ │ │ └─VALUES──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ ┌───────────────────────────────────────┐ │ │  │ │ │ >────literal-1──┬────────────────────────┬─┴──.──>< │ │ └─┬─THROUGH─┬──literal-2─┘ │ │ └─THRU────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ condition-name A user-specified name that associates a value, a set of values, or a range of values with a conditional variable. A conditional variable is a data item that can assume one or more values, that can, in turn, be associated with a condition-name. Format 3 can be used to describe both elementary and group items. Further information on condition-name entries can be found under VALUE OF Clause. ═══ 11.4. Format 4 ═══ -----IBM Extension----- This format describes Boolean data. Boolean data items are items that are limited to a value of 1 or 0. Note: When you use indicators in a COBOL program, you must describe them as Boolean data items using the data description entry for Boolean data. ┌─── DATA DESCRIPTION ENTRY - FORMAT 4 - BOOLEAN DATA ─────────────────────────┐ │ │ │ >>──level-number──┬─────────────┬──┬────────────────────────┬──────────────> │ │ ├─data-name-1─┤ ├─REDEFINES──data-name-2─┤ │ │ └─FILLER──────┘ └─LIKE──data-name-3──────┘ │ │ │ │ >──┬──────────────────┬──┬────────────────┬────────────────────────────────> │ │ └─┬────┬──EXTERNAL─┘ └─┬────┬──GLOBAL─┘ │ │ └─IS─┘ └─IS─┘ │ │ │ │ >──┬──────────────────────────────┬──┬──────────────────────────────┬──────> │ │ │ (1) │ ├─┤ OCCURS clause - Format 1 ├─┤ │ │ └─┬─JUST──────┬──────┬───────┬─┘ └─┤ OCCURS clause - Format 2 ├─┘ │ │ └─JUSTIFIED─┘ └─RIGHT─┘ │ │ │ │ >──┬───────────────────────────┬──┬────────────────────────┬───────────────> │ │ └─┬─INDICATOR──┬──integer-3─┘ └─┬─PICTURE─┬──┬────┬──1─┘ │ │ ├─INDICATORS─┤ └─PIC─────┘ └─IS─┘ │ │ └─INDIC──────┘ │ │ │ │ >──┬────────────────────────────────┬──────────────────────────────────────> │ │ └─VALUE──┬────┬──boolean-literal─┘ │ │ └─IS─┘ │ │ │ │ >──┬─────────────────────────────────┬──┬────────────────────────────┬─────> │ │ │ (1) │ └─┬───────────────┬──DISPLAY─┘ │ │ └─┬─SYNCHRONIZED─┬──────┬───────┬─┘ └─USAGE──┬────┬─┘ │ │ └─SYNC─────────┘ ├─LEFT──┤ └─IS─┘ │ │ └─RIGHT─┘ │ │ │ │ >──.──>< │ │ │ │ OCCURS CLAUSE - FORMAT 1: │ │ ├──OCCURS──integer-2──┬───────┬────────────────────────────────────────────> │ │ └─TIMES─┘ │ │ │ │ ┌───────────────────────────────────────┐ │ │  │ │ │ >───┬─────────────────────────────────────┬┴──┤ │ │ │ ┌──────────────┐ │ │ │ │  │ │ │ │ └─INDEXED──┬──────┬────index-name-1─┴─┘ │ │ └─BY───┘ │ │ │ │ OCCURS CLAUSE - FORMAT 2: │ │ ├──OCCURS──integer-1──TO──integer-2──┬───────┬─────────────────────────────> │ │ └─TIMES─┘ │ │ │ │ >──DEPENDING──┬────┬──data-name-4──────────────────────────────────────────> │ │ └─ON─┘ │ │ │ │ ┌───────────────────────────────────────┐ │ │  │ │ │ >───┬─────────────────────────────────────┬┴──┤ │ │ │ ┌──────────────┐ │ │ │ │  │ │ │ │ └─INDEXED──┬──────┬────index-name-1─┴─┘ │ │ └─BY───┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ---End of IBM Extension--- ═══ 11.5. LIKE Clause ═══ -----IBM Extension----- The length of the data item cannot be changed using this clause. ---End of IBM Extension--- ═══ 11.6. OCCURS Clause ═══ -----IBM Extension----- When the OCCURS clause and the INDICATOR clause are both specified at an elementary level, a table of Boolean data items is defined with each element in the table corresponding to an external indicator. The first element in the table corresponds to the indicator number specified in the INDICATOR clause; the second element corresponds to the indicator that sequentially follows the indicator specified by the INDICATOR clause. For example, if the following is coded: 07 SWITCHES PIC 1 OCCURS 10 TIMES INDICATOR 16. then SWITCHES (1) corresponds to indicator 16, SWITCHES (2) corresponds to indicator 17,..., and SWITCHES (10) corresponds to indicator 25. ---End of IBM Extension--- ═══ 11.7. INDICATOR Clause ═══ -----IBM Extension----- If indicator fields are in a separate indicator area, the INDICATOR clause associates an indicator defined in DDS with a Boolean data item. If indicator fields are in the record area, the INDICATOR clause is syntax checked, but is treated as documentation. Integer-3 must be a value of 1 through 99. The INDICATOR clause must be specified at an elementary level only. ---End of IBM Extension--- ═══ 11.8. VALUE Clause ═══ -----IBM Extension----- The VALUE clause specifies the initial content of a Boolean data item. The allowable values for Boolean literals are B"0", B"1", and ZERO. ---End of IBM Extension--- ═══ 11.9. level-number ═══ Level-numbers must be followed either by a separator period; or by a space followed by its associated data-name-1, FILLER, or appropriate data description clause. Level number 01 and 77 must begin in Area A. Level-number 77 must be followed by a space followed by its associated data-name-1. Level numbers 02 through 49, 66, and 88 may begin in Area A or B. Single-digit level-numbers 1 through 9 may be substituted for level-numbers 01 through 09. Successive data description entries may start in the same column as the first or they may be indented according to the level-number. Indentation does not affect the magnitude of a level-number. When level-numbers are indented, each new level-number may begin any number of spaces to the right of Area A. The extent of indentation to the right is limited only by the width of Area B. For more information, see Levels of Data and Standard Data Format. -----IBM Extension----- Elementary items or group items that are immediately subordinate to one group item can have unequal level-numbers. ---End of IBM Extension--- ═══ 11.10. data-name ═══ Explicitly identifies the data being described. If specified, data-name-1 identifies a data item used in the program. The data item must be the first word following the level-number. The data item can be changed during program execution. Data-name-1 must be specified for  Level-66, level-77, and level-88 items  Entries containing a GLOBAL or EXTERNAL clause  Record description entries associated with file description entries having GLOBAL or EXTERNAL clauses. ═══ 11.11. FILLER ═══ Is a data item that is not explicitly referred to in a program. The keyword FILLER is optional. If specified, FILLER must be the first word following the level-number. The keyword FILLER may be used with a conditional variable, if explicit reference is never made to the conditional variable but only to values it may assume. FILLER may not be used with a condition-name. In a MOVE CORRESPONDING statement, or in an ADD CORRESPONDING or SUBTRACT CORRESPONDING statement, FILLER items are ignored. In an INITIALIZE statement, elementary FILLER items are ignored. If data-name-1 or FILLER clause is omitted, the data item being described is treated as though FILLER had been specified. ═══ 11.12. BLANK WHEN ZERO Clause ═══ The BLANK WHEN ZERO clause specifies that an item contains nothing but spaces when its value is zero. ┌─── BLANK WHEN ZERO CLAUSE - FORMAT ──────────────────────────────────────────┐ │ │ │ >>──BLANK──┬──────┬──ZERO──>< │ │ └─WHEN─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The BLANK WHEN ZERO clause may be specified only for elementary numeric or numeric-edited items. These items must be described, either implicitly or explicitly, as USAGE IS DISPLAY. When the BLANK WHEN ZERO clause is specified for a numeric item, the item is considered a numeric-edited item. The BLANK WHEN ZERO clause must not be specified for level-66 or level-88 items. The BLANK WHEN ZERO clause must not be specified for the same entry as the PICTURE symbols S or *. The BLANK WHEN ZERO clause is not allowed for items described with the:  USAGE IS INDEX clause -----IBM Extension-----  USAGE IS POINTER clause  USAGE IS PROCEDURE-POINTER clause ---End of IBM Extension--- ═══ 11.13. EXTERNAL Clause ═══ The EXTERNAL clause specifies that the storage associated with a data item is associated with the run unit rather than with any particular program within the run unit. ┌─── EXTERNAL CLAUSE - FORMAT ─────────────────────────────────────────────────┐ │ │ │ >>──┬────┬──EXTERNAL──>< │ │ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ An external data item can be referenced by any program in the run unit that describes the data item. References to an external data item from different programs using separate descriptions of the data item are always to the same data item. In a run unit, there is only one representation of an external data item. The EXTERNAL clause can be specified in either 01 level entries in the Working-Storage Section or in file description entries. If there are two data description entries with the same data name in the same Data Division, only one entry can contain the EXTERNAL clause. Index-names and condition-names in an external data record do not possess the EXTERNAL attribute. The data contained in the record named by the data-name clause is external and can be accessed and processed by any program in the run unit that describes and, optionally, redefines it. This data is subject to the following rules:  If two or more programs within a run unit describe the same external data record, each record-name of the associated record description entries must be the same and the records must define the same number of standard data format characters. However, a program that describes an external record can contain a data description entry including the REDEFINES clause that redefines the complete external record, and this complete redefinition need not occur identically in other programs in the run unit.  Use of the EXTERNAL clause does not imply that the associated data-name is a global name.  The VALUE clause must not be used in any data description entry which includes, or is subordinate to an entry which includes, the EXTERNAL clause. The VALUE clause can be specified for condition-name entries associated with such data description entries. ═══ 11.14. GLOBAL Clause ═══ The GLOBAL clause specifies that a data-name is available to the program that declares it and to every program contained within the program that declares it, as long as the contained program does not itself have a declaration for that name. All data-names subordinate to, or condition-names or index-names associated with a global name, are global names. ┌─── GLOBAL CLAUSE - FORMAT ───────────────────────────────────────────────────┐ │ │ │ >>──┬────┬──GLOBAL──>< │ │ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ A data-name is global if the GLOBAL clause is specified either in the data description entry by which the data-name is declared or in another entry to which that data description entry is subordinate. -----IBM Extension----- The GLOBAL clause can be specified in the Linkage Section, but only in data description entries whose level-number is 01. ---End of IBM Extension--- In the same Data Division, the data description entries for any two data items for which the same data-name is specified must not include the GLOBAL clause. A statement in a program contained directly or indirectly within a program which describes a global name can reference that name without describing it again. Sharing Data Two programs in a run unit can reference common data in the following circumstances: 1. The data content of an external data record can be referenced from any program provided that program has described that data record. 2. If a program is contained within another program, both programs can refer to data possessing the global attribute either in the containing program or in any program that directly or indirectly contains the containing program. 3. A parameter passed by reference can be shared between the calling program and the called program. ═══ 11.15. JUSTIFIED Clause ═══ The JUSTIFIED clause overrides standard positioning rules for a receiving item of the alphabetic or alphanumeric categories. ┌─── JUSTIFIED CLAUSE - FORMAT ────────────────────────────────────────────────┐ │ │ │ >>──┬─JUSTIFIED─┬──┬──────────┬──>< │ │ └─JUST──────┘ │ (1)│ │ │ └─RIGHT────┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The JUSTIFIED clause may be specified only at the elementary level. RIGHT is an optional word that is syntax checked only and has no effect on the execution of the program. The JUSTIFIED clause cannot be specified for numeric, numeric-edited, or alphanumeric-edited items. The JUSTIFIED clause is not allowed for items described with:  Level-66 (RENAMES) entries  Level-88 (condition-name) entries  The USAGE IS INDEX clause -----IBM Extension-----  The USAGE IS POINTER clause  The USAGE IS PROCEDURE-POINTER clause The JUSTIFIED clause can be specified for an alphanumeric edited item. ---End of IBM Extension--- When the JUSTIFIED clause is omitted, the rules for standard alignment are followed (see Alignment Rules). When the JUSTIFIED clause is specified for a receiving item, the data is aligned at the rightmost character position in the receiving item. Also:  If the sending item is larger than the receiving item, the leftmost characters are truncated.  If the sending item is smaller than the receiving item, the unused character positions at the left are filled with spaces. The JUSTIFIED clause does not affect initial values, as determined by the VALUE clause. ═══ 11.16. LIKE Clause ═══ -----IBM Extension----- The LIKE clause allows you to define the PICTURE, USAGE, and SIGN characteristics of a data item by copying them from a previously defined data item. It also allows you to make the length of the data item you define different from the length of the original item. ┌─── LIKE CLAUSE - FORMAT ─────────────────────────────────────────────────────┐ │ │ │ (1) │ │ >>──LIKE─────data-name──┬───────────┬──>< │ │ └─(integer)─┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The LIKE clause causes the new data item to inherit specific characteristics from the existing data item. These characteristics are the PICTURE, USAGE, SIGN, and BLANK WHEN ZERO attributes of the existing item. The compiler generates comments to identify the characteristics of the new item. These comments appear after the statement containing the LIKE clause. Note that the default USAGE IS DISPLAY and SIGN IS TRAILING characteristics do not print as comments. Related Information:  Comments Generated Based on Inherited USAGE Characteristics  Rules and Restrictions for Like Clause  Coding Examples ---End of IBM Extension--- ═══ 11.16.1. Comments Generated Based on Inherited USAGE Characteristics ═══ -----IBM Extension----- The different USAGE clauses that you can specify for the original item result in a limited number of comments. Comments Generated based on Inherited USAGE Characteristics illustrates this. ┌──────────────────────────────────────────────────────────────────────────────┐ │ Comments Generated based on Inherited USAGE Characteristics │ ├───────────────────────────────────────┬──────────────────────────────────────┤ │ INHERITED USAGE CLAUSE │ GENERATED COMMENT │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ PACKED-DECIMAL │ * USAGE IS PACKED-DECIMAL │ │ COMPUTATIONAL │ │ │ COMPUTATIONAL-3 │ │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ BINARY │ * USAGE IS BINARY │ │ COMPUTATIONAL-4 │ │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ INDEX │ * USAGE IS INDEX │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ DISPLAY │ This is the default usage, so a │ │ │ comment is not generated. │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ POINTER │ * USAGE IS POINTER │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ PROCEDURE-POINTER │ * USAGE IS PROCEDURE-POINTER │ └───────────────────────────────────────┴──────────────────────────────────────┘ The characteristics of the data item that you define using the LIKE clause are shown in the listing of your compiled program. ---End of IBM Extension--- ═══ 11.16.2. Rules and Restrictions ═══ -----IBM Extension----- You can use the LIKE clause at level-numbers 01 through 49, and at level-number 77. If you specify data-name or FILLER entries, you can put the LIKE clause in any position after them. Otherwise, you can put it in any position after the level-number. You can specify one or more other clauses before or after the LIKE clause: JUSTIFIED SYNCHRONIZED BLANK WHEN ZERO VALUE OCCURS. Note that you can specify BLANK WHEN ZERO only if it has not previously been inherited. You cannot use the LIKE clause with the following clauses: REDEFINES SIGN USAGE PICTURE. If you specify any inherited clauses in the LIKE clause, a duplication error will result. For numeric items, the total number of numeric characters in the new item cannot be zero. But if the item contains decimals, the number of characters in the integer portion can be zero. If a PICTURE clause specifies a mixture of alphabetic, numeric, or alphanumeric characters, and the LIKE clause has length modification, the new PICTURE clause specifies alphanumeric characters. You cannot use the LIKE clause to define an item that is subordinate to the item that you name in the clause. ---End of IBM Extension--- ═══ 11.16.3. Coding Examples ═══ -----IBM Extension----- To create data item DEPTH with the same attributes as data item HEIGHT, you simply write: DEPTH LIKE HEIGHT To create data item PROVINCE with the same attributes as data item STATE, except one byte longer, you write: PROVINCE LIKE STATE (+1) ---End of IBM Extension--- ═══ 11.17. OCCURS Clause ═══ The Data Division clauses that are used for table handling are the OCCURS clause and USAGE IS INDEX clause (For the USAGE IS INDEX description, see USAGE Clause.) The OCCURS Clause has two formats:  Format 1 - Fixed Length Tables  Format 2 - Variable Length Tables Related Information:  Table Handling Concepts  Table Limitations  Defining Tables  Referencing Table Elements  Subscripting ═══ 11.17.1. Table Handling Concepts ═══ A table is a set of logically consecutive items, each of which has the same data description as the other items in the set. COBOL provides a method of data reference is used which makes it possible to refer to all or to part of one table as an entity. In COBOL, a table is defined with an OCCURS clause in its data description. The OCCURS clause specifies that the named item is to be repeated as many times as stated. The item so named is considered a table element, and its name and description apply to each repetition (or occurrence) of the item. Because the occurrences are not given unique data-names, reference to a particular occurrence can be made only by specifying the data-name of the table element, together with the occurrence number of the desired item within the element. The occurrence number is known as a subscript and the technique of supplying the occurrence number of individual table elements is called subscripting. Subscripting is described in a subsequent section. The data-name of the data item containing the OCCURS clause is known as the subject of the OCCURS clause. When the subject of an OCCURS clause (or any data-item subordinate to it) is referenced, it must be subscripted or indexed unless:  The subject of the OCCURS clause is used as the subject of the SEARCH statement.  The subject (or subordinate data item) is the object of the ASCENDING/DESCENDING KEY clause.  The subordinate data item is the object of the REDEFINES clause. When the subject of an OCCURS clause is subscripted or indexed, it represents one occurrence within the table. Otherwise, the subject represents the entire table. -----IBM Extension----- An item whose usage is POINTER or PROCEDURE-POINTER can contain an OCCURS clause, or be subordinate to an item declared with an OCCURS clause. Tables containing pointer or procedure-pointer data items are subject to pointer alignment as defined under Pointer Alignment. Where necessary, the compiler adds FILLER items to align the pointers in the first element of the table, plus a FILLER item at the end of the element to align the next pointer. This continues until all pointers in the table have been aligned. The OCCURS clause can be specified for a boolean item. ---End of IBM Extension--- ═══ 11.17.1.1. Limitations ═══ You should be aware of the following limitations when you work with tables:  The number of occurrences of an item in the OCCURS clause can be up to a maximum of 16 711 568.  Table elements, including subordinate elements, have a size limit of 16 711568 bytes.  The OCCURS clause cannot appear in a data description entry that: - Has a level-number of 01, 66, 77, or 88. - Describes a redefined data item. However, a redefined item can be subordinate to an item containing an OCCURS clause. ═══ 11.17.1.2. Defining Tables ═══ The ILE COBOL/400 compiler allows tables in one to seven dimensions. To define a one-dimensional table, set up a group item that includes one OCCURS clause. Remember that the OCCURS clause cannot appear in a data description entry whose level-number is 01, 66, 77, or 88. For example: 01 TABLE-ONE. 05 ELEMENT-ONE OCCURS 3 TIMES. 10 ELEMENT-A PIC X(4). 10 ELEMENT-B PIC 9(4). TABLE-ONE is the group item that contains the table. ELEMENT-ONE is an element of a one-dimensional table that occurs three times. ELEMENT-A and ELEMENT-B are elementary items subordinate to ELEMENT-ONE. To define a three-dimensional table, a one-dimensional table is defined within each occurrence of another one-dimensional table, which is itself contained within each occurrence of another one-dimensional table. For example: 01 TABLE-THREE. 05 ELEMENT-ONE OCCURS 3 TIMES. 10 ELEMENT-TWO OCCURS 3 TIMES. 15 ELEMENT-THREE OCCURS 2 TIMES PICTURE X(8). TABLE-THREE is the group item that contains the table. ELEMENT-ONE is an element of a one-dimensional table that occurs three times. ELEMENT-TWO is an element of a two-dimensional table that occurs three times within each occurrence of ELEMENT-ONE. ELEMENT-THREE is an element of a three-dimensional table that occurs two times within each occurrence of ELEMENT-TWO. Storage Layout for TABLE-THREE shows the storage layout for TABLE-THREE. ELEMENT─ONE ELEMENT─TWO ELEMENT─THREE Byte Dis─ Occurs Three Times Occurs Three Times Occurs Two Times placement ┌──────────────────┬────────────────────────┬───────────────────────────┬── 0 │ │ │ ELEMENT─THREE (1, 1, 1) │ │ │ ELEMENT─TWO (1, 1) ├───────────────────────────┼── 8 │ │ │ ELEMENT─THREE (1, 1, 2) │ │ ├────────────────────────┼───────────────────────────┼── 16 │ │ │ ELEMENT─THREE (1, 2, 1) │ │ ELEMENT─ONE (1) │ ELEMENT─TWO (1, 2) ├───────────────────────────┼── 24 │ │ │ ELEMENT─THREE (1, 2, 2) │ │ ├────────────────────────┼───────────────────────────┼── 32 │ │ │ ELEMENT─THREE (1, 3, 1) │ │ │ ELEMENT─TWO (1, 3) ├───────────────────────────┼── 40 │ │ │ ELEMENT─THREE (1, 3, 2) │ ├──────────────────┼────────────────────────┼───────────────────────────┼── 48 │ │ │ ELEMENT─THREE (2, 1, 1) │ │ │ ELEMENT─TWO (2, 1) ├───────────────────────────┼── 56 │ │ │ ELEMENT─THREE (2, 1, 2) │ │ ├────────────────────────┼───────────────────────────┼── 64 │ │ │ ELEMENT─THREE (2, 2, 1) │ │ ELEMENT─ONE (2) │ ELEMENT─TWO (2, 2) ├───────────────────────────┼── 72 │ │ │ ELEMENT─THREE (2, 2, 2) │ │ ├────────────────────────┼───────────────────────────┼── 80 │ │ │ ELEMENT─THREE (2, 3, 1) │ │ │ ELEMENT─TWO (2, 3) ├───────────────────────────┼── 88 │ │ │ ELEMENT─THREE (2, 3, 2) │ ├──────────────────┼────────────────────────┼───────────────────────────┼── 96 │ │ │ ELEMENT─THREE (3, 1, 1) │ │ │ ELEMENT─TWO (3, 1) ├───────────────────────────┼── 104 │ │ │ ELEMENT─THREE (3, 1, 2) │ │ ├────────────────────────┼───────────────────────────┼── 112 │ │ │ ELEMENT─THREE (3, 2, 1) │ │ ELEMENT─ONE (3) │ ELEMENT─TWO (3, 2) ├───────────────────────────┼── 120 │ │ │ ELEMENT─THREE (3, 2, 2) │ │ ├────────────────────────┼───────────────────────────┼── 128 │ │ │ ELEMENT─THREE (3, 3, 1) │ │ │ ELEMENT─TWO (3, 3) ├───────────────────────────┼── 136 │ │ │ ELEMENT─THREE (3, 3, 2) │ └──────────────────┴────────────────────────┴───────────────────────────┴── 144 Storage Layout for TABLE-THREE ═══ 11.17.2. Referencing Table Elements ═══ Whenever the user refers to a table element, or to any item associated with a table element, the reference must indicate which occurrence is intended. For a one-dimensional table, the occurrence number of the desired element gives the complete information. For tables of more than one dimension, an occurrence number for each dimension must be supplied. In the three-dimensional table defined in the previous discussion, for example, a reference to ELEMENT-THREE must supply the occurrence number for ELEMENT-ONE, ELEMENT-TWO, and ELEMENT-THREE. ═══ 11.17.3. Fixed-Length Tables ═══ Fixed-length tables are specified using the OCCURS clause. Because seven subscripts or indexes are allowed, six nested levels and one outermost level of the Format 1 OCCURS clause are allowed. The Format 1 OCCURS clause may be specified as subordinate to the OCCURS DEPENDING ON clause. In this way, a table of up to seven dimensions may be specified. ┌─── OCCURS CLAUSE - FORMAT 1 - FIXED-LENGTH TABLES ───────────────────────────┐ │ │ │ >>──OCCURS──integer-2──┬───────┬───────────────────────────────────────────> │ │ └─TIMES─┘ │ │ │ │ ┌───────────────────────────────────────────────────────┐ │ │  │ │ │ >────┬───────────────────────────────────────────────────┬─┴───────────────> │ │ │ ┌─────────────┐ │ │ │ │  │ │ │ │ └─┬─ASCENDING──┬──┬──────┬──┬────┬────data-name-2─┴─┘ │ │ └─DESCENDING─┘ └─KEY──┘ └─IS─┘ │ │ │ │ >──┬─────────────────────────────────────┬──>< │ │ │ ┌──────────────┐ │ │ │ │  │ │ │ │ └─INDEXED──┬──────┬────index-name-1─┴─┘ │ │ └─BY───┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 11.17.3.1. ASCENDING/DESCENDING KEY Phrase ═══ Data is arranged in ascending or descending order (depending on the keyword specified) according to the values contained in data-name-2. The data-names are listed in their descending order of significance. The order is determined by the rules for comparison of operands (see Relation Condition). The ASCENDING and DESCENDING KEY data items are used in OCCURS clauses and the SEARCH ALL statement for a binary search of the table element. Related Information:  ASCENDING/DESCENDING KEY Phrase Rules  ASCENDING/DESCENDING KEY Coding Example ═══ 11.17.3.2. ASCENDING/DESCENDING KEY Phrase Rules ═══ When the ASCENDING/DESCENDING KEY phrase is specified, the following rules apply:  Keys must be listed in decreasing order of significance.  You must arrange the data in the table in ASCENDING or DESCENDING sequence according to the collating sequence in use.  A key may have DISPLAY, BINARY, PACKED-DECIMAL, or COMPUTATIONAL usage. -----IBM Extension-----  A key can have COMPUTATIONAL-3 or COMPUTATIONAL-4 usage. ---End of IBM Extension--- ═══ 11.17.3.3. ASCENDING/DESCENDING KEY Phrase Coding Example ═══ The following example illustrates the specification of ASCENDING KEY data items: WORKING-STORAGE SECTION. 01 TABLE-RECORD. 05 EMPLOYEE-TABLE OCCURS 100 TIMES ASCENDING KEY IS WAGE-RATE EMPLOYEE-NO INDEXED BY A, B. 10 EMPLOYEE-NAME PIC X(20). 10 EMPLOYEE-NO PIC 9(6). 10 WAGE-RATE PIC 9999V99. 10 WEEK-RECORD OCCURS 52 TIMES ASCENDING KEY IS WEEK-NO INDEXED BY C. 15 WEEK-NO PIC 99. 15 AUTHORIZED-ABSENCES PIC 9. 15 UNAUTHORIZED-ABSENCES PIC 9. 15 LATE-ARRIVALS PIC 9. The keys for EMPLOYEE-TABLE are subordinate to that entry, while the key for WEEK-RECORD is subordinate to that subordinate entry. In the preceding example, records in EMPLOYEE-TABLE must be arranged in ascending order of WAGE-RATE, and in ascending order of EMPLOYEE-NO within WAGE-RATE. Records in WEEK-RECORD must be arranged in ascending order of WEEK-NO. If they are not, results of any SEARCH ALL statement will be unpredictable. ═══ 11.17.3.4. INDEXED BY Phrase ═══ The INDEXED BY phrase specifies the indexes that can be used with this table. The INDEXED BY phrase is required if indexing is used to refer to this table element. See Subscripting Using Index-Names (Indexing). The value of an index is made accessible to a program by storing the value in an index data-item. Index data-items are described in the program by a data description entry containing the USAGE IS INDEX clause. The index value is moved to the index data-item through the SET statement. ═══ 11.17.4. Variable-Length Tables ═══ Variable-length tables are specified using Format 2 of the OCCURS clause. ┌─── OCCURS CLAUSE - FORMAT 2 - VARIABLE-LENGTH TABLES ────────────────────────┐ │ │ │ >>──OCCURS──integer-1──TO──integer-2──┬───────┬──DEPENDING──┬────┬─────────> │ │ └─TIMES─┘ └─ON─┘ │ │ │ │ >──data-name-1─────────────────────────────────────────────────────────────> │ │ │ │ ┌───────────────────────────────────────────────────────┐ │ │  │ │ │ >────┬───────────────────────────────────────────────────┬─┴───────────────> │ │ │ ┌─────────────┐ │ │ │ │  │ │ │ │ └─┬─ASCENDING──┬──┬──────┬──┬────┬────data-name-2─┴─┘ │ │ └─DESCENDING─┘ └─KEY──┘ └─IS─┘ │ │ │ │ >──┬─────────────────────────────────────┬──>< │ │ │ ┌──────────────┐ │ │ │ │  │ │ │ │ └─INDEXED──┬──────┬────index-name-1─┴─┘ │ │ └─BY───┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The length of the subject item is fixed; it is only the number of repetitions of the subject item that is variable. The object of the OCCURS DEPENDING ON clause must not occupy any storage position within the range of any table (that is, any storage position from the first character position in the table through the last character position in the table). At the time that the group item or any data item that contains a subordinate OCCURS DEPENDING ON item is referenced, the value of the object of the OCCURS DEPENDING ON clause must fall within the range integer-1 through integer-2. This rule does not apply to a receiving item that contains its own OCCURS DEPENDING ON object or when the group being referenced is used in a CALL BY REFERENCE statement. If the OCCURS clause is specified in a data description entry included in a record description entry containing the EXTERNAL clause, data-name-1 must reference a data item possessing the EXTERNAL attribute which is described in the same Data Division. If the data description entry is subordinate to one containing the GLOBAL clause, data-name-1 must be a global name and must reference a data item which is described in the same Data Division. When a group item containing a subordinate OCCURS DEPENDING ON item is referred to, the part of the table area used in the operation is determined as follows:  If the object is outside the group, only that part of the table area that is specified by the object at the start of the operation will be used.  If the object is included in the same group and the group data item is referenced as a sending item, only that part of the table area that is specified by the value of the object at the start of the operation will be used in the operation.  If the object is included in the same group and the group data item is referenced as a receiving item, the maximum length of the group item will be used in the operation. When reference modification is applied to a group item containing a variable-length table, reference modification creates a unique data item from the referenced data item. The length of this referenced data item is determined by first applying the previous rules. Subsequently, the rules for reference modification are applied to determine the length of the unique data item. If a group item containing a variable-length table is used as an argument in the CALL statement USING phrase, the size of the storage for that parameter from the called program's point of view depends on how the argument is passed. If it is passed BY REFERENCE, the maximum size is described by the data description of the argument in the calling program. If it is passed BY CONTENT, the group item is considered as a sending item. The subject of an OCCURS clause is the data-name of the data item containing the OCCURS clause. Except for the OCCURS clause itself, data description clauses used with the subject apply to each occurrence of the item described. Subscripting or indexing is required whenever the subject is used in a statement other than SEARCH or USE FOR DEBUGGING, unless it is the object of a REDEFINES clause. In this case, the subject refers to one occurrence within a table element. Subscripting and indexing are not allowed when the subject is used in a SEARCH or USE FOR DEBUGGING statement, or when it is the object of a REDEFINES clause. In this case, the subject represents an entire table element. Note that the previous two restrictions do not apply to the LENGTH OF special register. In one record description entry, any entry that contains an OCCURS DEPENDING ON clause may be followed only by items subordinate to it. The OCCURS DEPENDING ON clause may not be specified as subordinate to another OCCURS clause. All data-names used in the OCCURS clause may be qualified; they may not be subscripted or indexed. The OCCURS or OCCURS DEPENDING ON clause cannot be specified in a data description entry that:  Has a level number of 01, 66, 77, or 88.  Describes an item of variable size (an item is of variable size if any subordinate entry contains an OCCURS DEPENDING ON clause).  Describes a redefined data item. (However, a redefined item can be subordinate to an item containing an OCCURS clause.) See REDEFINES Clause. The ASCENDING/DESCENDING KEY and INDEXED BY clauses are described under Fixed-Length Tables. Note: If you use the OCCURS DEPENDING ON clause, the table must contain no more than 16 711 568 occurrences, the length of a table element must be no more than 16 711 568 bytes, and the length of the whole table must be no more than 16 711 568 bytes. ═══ 11.17.5. Subscripting ═══ Subscripting is a method of providing table references through the use of subscripts. A subscript is a positive integer whose value specifies the occurrence number of a table element. Subscripting is related to the OCCURS clause through the number of dimensions in a table. For example, a 4-dimensional table will require four subscripts. You may think of subscripting as the COBOL way of identifying elements in a multidimensional array, which was defined through the OCCURS clause. If the RANGE option is specified or implied, the system ensures that the subscript value is valid. If the RANGE option is not active, it is your responsibility to ensure that the subscript value is valid. The RANGE option does not cause the system to verify that index entries are valid; it is your responsibility to ensure valid index values. Related Information:  More Detailed Information on Subscripting  Restrictions on Subscripting ═══ 11.17.5.1. Restrictions on Subscripting ═══ 1. A data-name must not be subscripted or indexed when it is being used as a subscript or qualifier. 2. An index may be modified only by a PERFORM, SEARCH, or SET statement. 3. When a literal is used in a subscript, it must be a positive or unsigned integer. 4. When a literal is used in relative subscripting and indexing, it must be an unsigned integer. ═══ 11.18. PICTURE Clause ═══ The PICTURE clause specifies the general characteristics and editing requirements of an elementary item. ┌─── PICTURE CLAUSE - FORMAT ──────────────────────────────────────────────────┐ │ │ │ >>──┬─PICTURE─┬──┬────┬──character-string──>< │ │ └─PIC─────┘ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The PICTURE clause must be specified for every elementary item except an index data item or the subject of the RENAMES clause. The PICTURE clause is not allowed in descriptions of items described with USAGE IS INDEX, USAGE IS POINTER, or USAGE IS PROCEDURE-POINTER. The PICTURE character-string may contain a maximum of 30 characters. It consists of certain COBOL characters used as symbols. The allowable combinations determine the category of the elementary data item. DECIMAL-POINT IS COMMA, when specified in the SPECIAL-NAMES paragraph, exchanges the functions of the period and the comma in PICTURE character strings and in numeric literals. Related Information:  Symbols Used in the PICTURE Clause  Character String Representation  Data Categories and PICTURE Rules  PICTURE Clause Editing. ═══ 11.18.1. Symbols Used in the PICTURE Clause ═══ Any punctuation character appearing within the PICTURE character-string is not considered a punctuation character, but rather a PICTURE character-string symbol. The lowercase letters corresponding to the uppercase letters representing the PICTURE symbols A, B, P, S, V, X, Z, CR, and DB are equivalent to their uppercase representations in a PICTURE character-string. The meaning of each PICTURE clause symbol is defined in the following list. Symbol Meaning A Alphabetic character or space B Space insertion character P Decimal scaling position (not counted in size of data item) S Operational sign (not counted in size of data item unless a SIGN clause with optional SEPARATE CHARACTER phrase is specified) V Assumed decimal point (not counted in size of data item) X Alphanumeric character (any from the EBCDIC set) Z Zero suppression character 9 Numeric character -----IBM Extension----- 1 Boolean character ---End of IBM Extension--- 0 Zero insertion character / Slash insertion character , Comma insertion character . Decimal point or period editing control character + Plus sign insertion editing control character - Minus sign editing control character CR Credit editing control character DB Debit editing control character * Check protect insertion character $ Currency symbol insertion character ($ is default). ═══ 11.18.2. Character-String Representation ═══ The following symbols may appear more than once in one PICTURE character-string: A B P X Z 9 0 / , + - * $ An integer enclosed in parentheses immediately following any of these symbols specifies the number of consecutive occurrences of that symbol. The number of consecutive occurrences cannot exceed 16 711 568. For example, the following two PICTURE clause specifications are equivalent: PICTURE IS $99999.99CR PICTURE IS $9(5).9(2)CR The following symbols may appear only once in one PICTURE character-string: S V . CR DB or -----IBM Extension----- 1 (A character position that contains a Boolean value). ---End of IBM Extension--- Each time any of the above symbols appears in the character-string, it represents an occurrence of that character or set of allowable characters in the data item. ═══ 11.18.3. Data Categories and PICTURE Rules ═══ The allowable combinations of PICTURE symbols determine the data category of the item.  Alphabetic items  Numeric Items  Numeric-edited items  Alphanumeric items  Alphanumeric-edited items -----IBM Extension-----  Boolean items ---End of IBM Extension--- ═══ 11.18.3.1. Alphabetic Items: ═══  The PICTURE character-string can contain only the symbol A.  The contents of the item in standard data format must consist of any of the letters of the English alphabet and the space character.  USAGE DISPLAY must be specified or implied.  Any associated VALUE clause must specify a nonnumeric literal containing only alphabetic characters or the figurative constant SPACE. ═══ 11.18.3.2. Numeric Items: ═══  Types of numeric items are: - Binary - Packed decimal (internal decimal) - Zoned decimal (external decimal).  The PICTURE character-string can contain only the symbols 9, P, S, and V.  The number of digit positions must range from 1 through 18, inclusive.  If unsigned, the contents of the item in standard data format must contain a combination of the Arabic numerals 0-9. If signed, it may also contain a +, -, or other representation of the operational sign.  The USAGE of the item can be DISPLAY, BINARY, COMPUTATIONAL, or PACKED-DECIMAL. -----IBM Extension-----  The USAGE of the item can be COMPUTATIONAL-3 or COMPUTATIONAL-4. ---End of IBM Extension---  A VALUE clause associated with an elementary numeric item must specify a numeric literal or the figurative constant ZERO. A VALUE clause associated with a group item consisting of elementary numeric items must specify a nonnumericliteral or a figurative constant, because the group is considered alphanumeric. In both cases, the literal is treated exactly as specified; no editing is performed. Examples of numeric items: PICTURE Valid Range of Values 9999 0 through 9999 S99 -99 through +99 S999V9 -999.9 through +999.9 PPP999 0 through .000999 S999PPP -1000 through -999000 and +1000 through +999000 or zero ═══ 11.18.3.3. Numeric-edited Items: ═══  The PICTURE character-string can contain the following symbols: B P V Z 9 0 / , . + - CR DB * $ The combinations of symbols allowed are determined from the PICTURE clause symbol order allowed and the editing rules (see PICTURE Clause Editing). The following additional rules also apply: - Either the BLANK WHEN ZERO clause must be specified for the item, or the string must contain at least one of the following symbols: B / Z 0 , . * + - CR DB $ - The number of digit positions represented in the character-string must be in the range 1 through 18, inclusive. - The total length of the resultant character positions must be 127 or less.  The contents of those character positions representing digits in standard data format must be one of the 10 Arabic numerals.  USAGE DISPLAY must be specified or implied.  Any associated VALUE clause must specify a nonnumeric literal or a figurative constant. The literal is treated exactly as specified; no editing is done. ═══ 11.18.3.4. Alphanumeric Items: ═══  The PICTURE character-string must consist of either of the following: - The symbol X - Combinations of the symbols A, X, and 9. (A character-string containing all As or all 9s does not define an alphanumeric item.)  The item is treated as if the character-string contained only the symbol X. - The contents of the item in standard data format may be any allowable characters from the EBCDIC character set. - USAGE DISPLAY must be specified or implied. - Any associated VALUE clause must specify a nonnumeric literal or a figurative constant. ═══ 11.18.3.5. Alphanumeric-edited Items: ═══  The PICTURE character-string can contain the following symbols: A X 9 B 0 /  The string must contain at least one A or X, and at least one B or 0 (zero) or /.  The contents of the item in standard data format may be any allowable character from the EBCDIC character set.  The total length of the resultant character positions must be 127 or less.  USAGE DISPLAY must be specified or implied.  Any associated VALUE clause must specify a nonnumeric literal or a figurative constant. The literal is treated exactly as specified; no editing is done. ═══ 11.18.3.6. Boolean items ═══ -----IBM Extension----- The following rules apply: 1. The PICTURE character-string can contain only the symbol 1. 2. Only one character 1 can be specified. 3. The USAGE of an item can only be DISPLAY. 4. An associated VALUE clause must specify a Boolean literal (B"1" or B"0") or zero. 5. The following clauses cannot be specified for a Boolean item:  SIGN clause  BLANK WHEN ZERO clause  ASCENDING/DESCENDING KEY clause. 6. The INDICATOR clause can be specified. ---End of IBM Extension--- ═══ 11.18.4. PICTURE Clause Editing ═══ There are two general methods of editing in a PICTURE clause:  Insertion editing - Simple insertion - Special insertion - Fixed insertion - Floating insertion.  Suppression and replacement editing - Zero suppression and replacement with asterisks - Zero suppression and replacement with spaces. The type of editing allowed for an item depends on its data category. The type of editing that is valid for each category is shown below: ┌────────────────────────────────────────────────────────────┐ │ Valid Editing for Each Data Category │ ├──────────────────────────────┬─────────────────────────────┤ │ CATEGORY │ TYPE OF EDITING │ ├──────────────────────────────┼─────────────────────────────┤ │ Alphabetic │ None │ ├──────────────────────────────┼─────────────────────────────┤ │ ─────IBM EXTENSION───── │ None │ │ Boolean │ │ │ ───END OF IBM EXTENSION─── │ │ ├──────────────────────────────┼─────────────────────────────┤ │ Numeric │ None │ ├──────────────────────────────┼─────────────────────────────┤ │ Alphanumeric │ None │ ├──────────────────────────────┼─────────────────────────────┤ │ Alphanumeric edited │ Simple insertion │ ├──────────────────────────────┼─────────────────────────────┤ │ Numeric edited │ All │ └──────────────────────────────┴─────────────────────────────┘ ═══ 11.18.4.1. Simple Insertion Editing ═══ This type of editing is valid for numeric-edited and alphanumeric-edited items. Each insertion symbol is counted in the size of the item, and represents the position within the item where the equivalent characters will be inserted. ┌────────────────────────────────────────────────────────────┐ │ Simple Insertion Editing - Valid Insertion │ │ Symbols for Each Data Category │ ├──────────────────────────────┬─────────────────────────────┤ │ CATEGORY │ VALID INSERTION SYMBOLS │ ├──────────────────────────────┼─────────────────────────────┤ │ Alphabetic │ None │ ├──────────────────────────────┼─────────────────────────────┤ │ ─────IBM EXTENSION───── │ None │ │ Boolean │ │ │ ───END OF IBM EXTENSION─── │ │ ├──────────────────────────────┼─────────────────────────────┤ │ Numeric │ None │ ├──────────────────────────────┼─────────────────────────────┤ │ Alphanumeric │ None │ ├──────────────────────────────┼─────────────────────────────┤ │ Alphanumeric edited │ B 0 / │ ├──────────────────────────────┼─────────────────────────────┤ │ Numeric edited │ B 0 / , │ └──────────────────────────────┴─────────────────────────────┘ Examples of simple insertion editing: PICTURE Value of Data Edited Results X(10)/XX ALPHANUMER01 ALPHANUMER/01 X(5)BX(7) ALPHANUMERIC ALPHA NUMERIC 99,B999,B000 1234 01, 234, 000 99,999 12345 12,345 GGBBGG D1D2D3D4 D1D2 D3D4 ═══ 11.18.4.2. Special Insertion Editing ═══ This type of editing is valid only for numeric-edited items. The period (.) is the special insertion symbol; it also represents the actual decimal point for alignment purposes. The period insertion symbol is counted in the size of the item, and represents the position within the item where the actual decimal point is inserted. Either the actual decimal point or the symbol V as the assumed decimal point, but not both, must be specified in one PICTURE character-string. Examples of special insertion editing: PICTURE Value of Data Edited Results 999.99 1.234 001.23 999.99 12.34 012.34 999.99 123.45 123.45 999.99 1234.5 234.50 ═══ 11.18.4.3. Fixed Insertion Editing ═══ This type of editing is valid only for numeric-edited items. The following insertion symbols are used: $ (currency symbol) + - CR DB (editing-sign control symbols) In fixed insertion editing, only one currency symbol and one editing sign control symbol can be specified in one PICTURE character-string. Unless it is preceded by a + or - symbol, the currency symbol must be the first character in the character-string. When either + or - is used as a symbol, it must be the first or last character in the character-string. When CR or DB is used as a symbol, it must occupy the rightmost two character positions in the character-string. If these two character positions contain the symbols CR or DB, the uppercase letters are the insertion characters. Editing sign control symbols produce results that depend on the value of the data item, as shown below: Editing Symbol Result: Result: in PICTURE Data Item Data Item Character-String Positive or Zero Negative + + - - space - CR 2 spaces CR DB 2 spaces DB Examples of fixed insertion editing: PICTURE Value of Data Edited Result 999.99+ +6555.556 555.55+ +9999.99 -6555.555 -6555.55 9999.99 +1234.56 1234.56 $999.99 -123.45 $123.45 -$999.99 -123.456 -$123.45 -$999.99 +123.456 $123.45 $9999.99CR +123.45 $0123.45 $9999.99DB -123.45 $0123.45DB Note: Beware of situations where sign truncation would lead to negative amounts being shown as credits. ═══ 11.18.4.4. Floating Insertion Editing ═══ This type of editing is valid only for numeric-edited items. The following symbols are used: $ + - Within one PICTURE character-string, these symbols are mutually exclusive as floating insertion characters. Floating insertion editing is specified by using a string of at least two of the allowable floating insertion symbols to represent leftmost character positions into which these actual characters can be inserted. The leftmost floating insertion symbol in the character-string represents the leftmost limit at which this actual character can appear in the data item. The rightmost floating insertion symbol represents the rightmost limit at which this actual character can appear. The second leftmost floating insertion symbol in the character-string represents the leftmost limit at which numeric data can appear within the data item. Nonzero numeric data may replace all characters at or to the right of this limit. Any simple-insertion symbols (B 0 / ,) within or to the immediate right of the string of floating insertion symbols are considered part of the floating character-string. If the period (.) special-insertion symbol is included within the floating string, it is considered to be part of the character-string. In a PICTURE character-string, there are two ways to represent floating insertion editing and thus, two ways in which editing is performed: 1. Any or all leading numeric character positions to the left of the decimal point are represented by the floating insertion symbol. When editing is performed, a single floating insertion character is placed to the immediate left of the first nonzero digit in the data, or of the decimal point, whichever is farther to the left. The character positions to the left of the inserted character are filled with spaces. 2. All the numeric character positions are represented by the floating insertion symbol. When editing is performed, then:  If the value of the data is zero, the entire data item will contain spaces.  If the value of the data is nonzero, the result is the same as in rule 1. To avoid truncation, the minimum size of the PICTURE character-string must be:  The number of character positions in the sending item, plus  The number of nonfloating insertion symbols in the receiving item, plus  One character for the floating insertion symbol. Examples of floating insertion editing: PICTURE Value of Data Edited Result $$$$.99 .123 $.12 $$$9.99 .12 $0.12 $,$$$,999.99 -1234.56 $1,234.56 +,+++,999.99 -123456.789 -123,456.78 $$,$$$,$$$.99CR -1234567 $1,234,567.00CR ++,+++,+++.+++ 0000.00 Note: Beware of situations where sign truncation would lead to negative amounts being shown as credits. ═══ 11.18.4.5. Zero Suppression and Replacement Editing ═══ This type of editing is valid only for numeric-edited items. In zero suppression editing, the symbols Z and * are used. These symbols are mutually exclusive in one PICTURE character-string. The following symbols are mutually exclusive as floating replacement symbols in one PICTURE character-string: Z * + - $ Specify zero suppression and replacement editing with a string of one or more of the allowable symbols to represent leftmost character positions in which zero suppression and replacement editing can be performed. Any simple insertion symbols (B 0 / ,) within or to the immediate right of the string of floating editing symbols are considered part of the string. If the period (.) special insertion symbol is included within the floating editing string, it is considered to be part of the character-string. In a PICTURE character-string, there are two ways to represent zero suppression, and two ways in which editing is performed:  Any or all of the leading numeric character positions to the left of the decimal point are represented by suppression symbols. When editing is performed, any leading zero in the data that appears in the same character position as a suppression symbol is replaced by the replacement character. Suppression stops at the leftmost character: - That does not correspond to a suppression symbol - That contains nonzero data - That is the decimal point.  All the numeric character positions in the PICTURE character-string are represented by the suppression symbols. When editing is performed, and the value of the data is nonzero, the result is the same as in the preceding rule. If the value of the data is zero, then: - If Z has been specified, the entire data item will contain spaces. - If * has been specified, the entire data item, except the actual decimal point, will contain asterisks. Note: Do not specify both the asterisk (*) as a suppression symbol and the BLANK WHEN ZERO clause for the same entry. Examples of zero suppression and replacement editing: PICTURE Value of Data Edited Result ****.** 0000.00 ****.** ZZZZ.ZZ 0000.00 ZZZZ.99 0000.00 .00 ****.99 0000.00 ****.00 ZZ99.99 0000.00 00.00 Z,ZZZ.ZZ+ +123.456 123.45+ *,***.**+ -123.45 **123.45- **,***,***.**+ +12345678.9 12,345,678.90+ $Z,ZZZ,ZZZ.ZZCR +12345.67 $ 12,345.67 $B*,***,***.**BBDB -12345.67 $ ***12,345.67 DB ═══ 11.19. REDEFINES Clause ═══ The REDEFINES clause allows you to use different data description entries to describe the same computer storage area. ┌─── REDEFINES CLAUSE - FORMAT ────────────────────────────────────────────────┐ │ │ │ >>──level-number──┬─────────────┬──REDEFINES──data-name-2──>< │ │ ├─data-name-1─┤ │ │ └─FILLER──────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ When specified, the REDEFINES clause must be the first entry following data-name-1 or FILLER. If data-name-1 or FILLER is not specified, the REDEFINES clause must be the first entry following the level-number. The data item being described is treated as though FILLER has been specified. The level-numbers of data-name-1 and data-name-2 must be identical, and must not be level 66 or level 88. The following rules apply when coding the REDEFINES clause. When more than one level-01 entry is written subordinate to an FD entry, a condition known as implicit redefinition occurs. That is, the second level-01 entry implicitly redefines the storage allotted for the first entry. In such level-01 entries, the REDEFINES clause must not be specified. Related Information:  Redefinition Process  REDEFINE Clause Considerations  Coding Examples  Undefined Results. ═══ 11.19.1. Redefinition Process ═══ Redefinition begins at data-name-1 and ends when a level-number less than or equal to that of data-name-1 is encountered. No entry having a level-number numerically lower than those of data-name-1 and data-name-2 may occur between these entries. For example: 05 A PICTURE X(6). 05 B REDEFINES A. 10 B-1 PICTURE X(2). 10 B-2 PICTURE 9(4). 05 C PICTURE 99V99. In this example, A is the redefined item, and B is the redefining item. Redefinition begins with B and includes the two subordinate items B-1 and B-2. Redefinition ends when the level-05 item C is encountered. The data description entry for the redefined item cannot contain an OCCURS clause. However, the redefined item may be subordinate to an item whose data description entry contains an OCCURS clause. In this case, the reference to the redefined item in the REDEFINES clause may not be subscripted. Neither the original definition nor the redefinition can include a variable occurrence data item (in other words, they cannot contain an OCCURS DEPENDING ON clause). If the GLOBAL clause is used in the data description entry which contains the REDEFINES clause, only the subject of the clause possesses the global attribute. The EXTERNAL clause must not be specified on the same data description entry as a REDEFINES clause. If the object is GLOBAL or EXTERNAL, the subject does not inherit the attribute. Data-name-1, the redefining item, may be smaller than data-name-2, the redefined item. However, if the redefined item is specified with a level-number other than 01, it is declared to be part of an external record, and the number of character positions it contains must be greater than or equal to the number of character positions in the redefining item. One or more redefinitions of the same storage area are permitted. The entries giving the new descriptions of the storage area must be in the same section, and must immediately follow the description of the redefined area without intervening entries that define new character positions. Multiple redefinitions must all use the data-name of the original entry that defined this storage area. For example: 05 A PICTURE 9999. 05 B REDEFINES A PICTURE 9V999. 05 C REDEFINES A PICTURE 99V99. The redefining entry (identified by data-name-1), and any subordinate entries, must not contain any VALUE clauses. ═══ 11.19.2. REDEFINES Clause Considerations ═══ Data items within an area can be redefined without changing their lengths. For example: 05 NAME-2. 10 SALARY PICTURE XXX. 10 SO-SEC-NO PICTURE X(9). 10 MONTH PICTURE XX. 05 NAME-1 REDEFINES NAME-2. 10 WAGE PICTURE XXX. 10 EMP-NO PICTURE X(9). 10 YEAR PICTURE XX. Data item lengths and types can also be respecified within an area. For example: 05 NAME-2. 10 SALARY PICTURE XXX. 10 SO-SEC-NO PICTURE X(9). 10 MONTH PICTURE XX. 05 NAME-1 REDEFINES NAME-2. 10 WAGE PICTURE 999V999. 10 EMP-NO PICTURE X(6). 10 YEAR PICTURE XX. When an area is redefined, all descriptions of the area are always in effect; that is, redefinition does not cause any data to be erased and never supersedes a previous description. Thus, if B REDEFINES C has been specified, either of the two procedural statements, MOVE X TO B and MOVE Y TO C, could be executed at any point in the program. In the first case, the area described as B would assume the value and format of X. In the second case, the same physical area (described now as C) would assume the value and format of Y. Note that, if the second statement is executed immediately after the first, the value of Y replaces the value of X in the one storage area. The usage of a redefining data item need not be the same as that of a redefined item. This does not, however, cause any change in existing data. For example: 05 B PICTURE 99 USAGE DISPLAY VALUE 8. 05 C REDEFINES B PICTURE S99 USAGE COMPUTATIONAL-4. 05 A PICTURE S99 USAGE COMPUTATIONAL-4. The bit configuration of the DISPLAY value 8 is 1111 0000 1111 1000. Redefining B does not change the bit configuration of the data in the storage area. Therefore, the following two statements produce different results: ADD B TO A ADD C TO A In the first case, the value 8 is added to A (because B has USAGE DISPLAY). In the second statement, the value -48 is added to A (because C has USAGE COMPUTATIONAL-4) because the bit configuration (truncated to 2 decimal digits) in the storage area has the binary value -48. The above example demonstrates how the improper use of redefinition may give unexpected or incorrect results. ═══ 11.19.3. Coding Examples ═══ The REDEFINES clause may be specified for an item within the scope of an area being redefined (that is, an item subordinate to a redefined item). For example: 05 REGULAR-EMPLOYEE. 10 LOCATION PICTURE A(8). 10 GRADE PICTURE X(4). 10 SEMI-MONTHLY-PAY PICTURE 9999V99. 10 WEEKLY-PAY REDEFINES SEMI-MONTHLY-PAY PICTURE 999V999. 05 TEMPORARY-EMPLOYEE REDEFINES REGULAR-EMPLOYEE. 10 LOCATION PICTURE A(8). 10 FILLER PICTURE X(6). 10 HOURLY-PAY PICTURE 99V99. The REDEFINES clause may also be specified for an item subordinate to a redefining item. For example: 05 REGULAR-EMPLOYEE. 10 LOCATION PICTURE A(8). 10 GRADE PICTURE X(4). 10 SEMI-MONTHLY-PAY PICTURE 999V999. 05 TEMPORARY-EMPLOYEE REDEFINES REGULAR-EMPLOYEE. 10 LOCATION PICTURE A(8). 10 FILLER PICTURE X(6). 10 HOURLY-PAY PICTURE 99V99. 10 CODE-H REDEFINES HOURLY-PAY PICTURE 9999. ═══ 11.19.4. Undefined Results ═══ Undefined results may occur when:  A redefining item is moved to a redefined item (that is, if B REDEFINES C and the statement MOVE B TO C is executed).  A redefined item is moved to a redefining item (that is, if B REDEFINES C and if the statement MOVE C TO B is executed). ═══ 11.20. RENAMES Clause ═══ The RENAMES clause specifies alternative, possibly overlapping, groupings of elementary data items. ┌─── RENAMES CLAUSE - FORMAT ──────────────────────────────────────────────────┐ │ │ │ >>──66──data-name-1──RENAMES──data-name-2──────────────────────────────────> │ │ │ │ >──┬──────────────────────────┬──.──>< │ │ └─┬─THROUGH─┬──data-name-3─┘ │ │ └─THRU────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ One or more RENAMES entries can be written for a logical record. All RENAMES entries associated with one logical record must immediately follow that record's last data description entry. ═══ 11.20.1. data-name-1 ═══ Identifies an alternative grouping of data items. A level-66 entry cannot rename a level-01, level-77, level-88, or another level-66 entry. Data-name-1 cannot be used as a qualifier; it can be qualified only by the names of level indicator entries or level-01 entries. ═══ 11.20.2. data-name-2, data-name-3 ═══ Identify the original grouping of elementary data items; that is, they must be elementary or group items within the associated level-01 entry, and must not be the same data-name. Both data-names may be qualified. The OCCURS clause must not be specified in the data entries for data-name-2 and data-name-3, or for any group entry to which they are subordinate. In addition, the OCCURS DEPENDING ON clause must not be specified for any item defined between data-name-2 and data-name-3. When data-name-3 is specified, data-name-1 is treated as a group item that includes all elementary items:  Starting with data-name-2 (if it is an elementary item) or the first elementary item within data-name-2 (if it is a group item)  Ending with data-name-3 (if it is an elementary item) or the last elementary item within data-name-3 (if it is a group item) The leftmost character in data-name-3 must not precede that in data-name-2; the rightmost character in data-name-3 must follow that in data-name-2. This means that data-name-3 cannot be subordinate to data-name-2. When data-name-3 is not specified, all of the data attributes of data-name-2 become the data attributes for data-name-1. That is:  When data-name-2 is a group item, data-name-1 is treated as a group item.  When data-name-2 is an elementary item, data-name-1 is treated as an elementary item. Related Information:  Illustrations of Valid and Invalid RENAMES Clause Specifications ═══ 11.20.3. Illustrations of Valid and Invalid RENAMES Clause Specifications ═══ RENAMES Clause-Valid and Invalid Specifications COBOL Specifications Storage Layouts Example 1 (Valid) 01 RECORD─I. 05 DN─1... . │───────────────RECORD─I───────────────│ 05 DN─2... . ┌──────┬──────────┬───────────┬──────────┐ 05 DN─3... . │ DN─1 │ DN─2 │ DN─3 │ DN─4 │ 05 DN─4... . └──────┴──────────┴───────────┴──────────┘ 66 DN─6 RENAMES DN─1 THROUGH DN─3. │───────────DN─6────────────│ Example 2 (Valid) 01 RECORD─II. │───────────────RECORD─II──────────────│ 05 DN─1. │───────────DN─1─────────────│ │ 10 DN─2... . ┌──────────┬───────────────────┬─────────┐ 10 DN─2A... . │ DN─2 │ DN─2A │ DN─5 │ 05 DN─1A REDEFINES DN─1. └──────────┴───────────────────┴─────────┘ 10 DN─3A... . │───────────DN─1A────────────│ 10 DN─3... . ┌───────┬────────┬─────────────┐ 10 DN─3B... . │ DN─3A │ DN─3 │ DN─3B │ 05 DN─5... . └───────┴────────┴─────────────┘ 66 DN─6 RENAMES DN─2 THROUGH DN─3. │─────DN─6─────│ Example 3 (Invalid) 01 RECORD─III. │──────────────RECORD─III──────────────│ 05 DN─2. │────────DN─2─────────│ │ 10 DN─3... . ┌──────────┬────────────┬────────────────┐ 10 DN─4... . │ DN─3 │ DN─4 │ DN─5 │ 05 DN─5... . └──────────┴────────────┴────────────────┘ 66 DN─6 RENAMES DN─2 THROUGH DN─3. DN─6 is indeterminate Example 4 (Invalid) 01 RECORD─IV. │──────────────RECORD─IV───────────────│ 05 DN─1. │─────────DN─1───────────│ │ 10 DN─2A... . ┌──────────┬───────────────┬─────────────┐ 10 DN─2B... . │ DN─2A │ DN─2B │ DN─3 │ 10 DN─2C REDEFINES DN─2B. └──────────┴───────────────┴─────────────┘ 15 DN─2... . ┌───────┬───────┐ 15 DN─2D... . │ DN─2 │ DN─2D │ 05 DN─3... . └───────┴───────┘ 66 DN─4 RENAMES DN─1 THROUGH DN─2. DN─4 is indeterminate ═══ 11.21. SIGN Clause ═══ The SIGN clause specifies the position and mode of representation of the operational sign for a numeric entry. ┌─── SIGN CLAUSE - FORMAT ─────────────────────────────────────────────────────┐ │ │ │ >>──┬──────────────┬──┬─LEADING──┬──┬─────────────────────────┬──>< │ │ └─SIGN──┬────┬─┘ └─TRAILING─┘ └─SEPARATE──┬───────────┬─┘ │ │ └─IS─┘ └─CHARACTER─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The SIGN clause may be specified only for a signed numeric data description entry (that is, one whose PICTURE character-string contains an S), or for a group item that contains at least one such elementary entry. USAGE IS DISPLAY must be specified, explicitly or implicitly. The SIGN clause is required only when an explicit description of the properties and/or position of the operational sign is necessary. When specified, the SIGN clause defines the position and mode of representation of the operational sign for the numeric data description entry to which it applies, or for each signed numeric data description entry subordinate to the group to which it applies. If a SIGN clause is specified in either an elementary or group entry subordinate to a group item for which a SIGN clause is specified, the SIGN clause for the subordinate entry takes precedence for the subordinate entry. If you specify the CODE-SET clause in an FD entry, any signed numeric data description entries associated with that file description entry must be described with the SIGN IS SEPARATE clause. Every numeric data description entry whose PICTURE contains the symbol S is a signed numeric data description entry. If the SIGN clause is also specified for such an entry, and conversion is necessary for computations or comparisons, the conversion takes place automatically. ═══ 11.21.1. SEPARATE CHARACTER ═══ If the SEPARATE CHARACTER phrase is not specified, then:  The operational sign is presumed to be associated with the LEADING or TRAILING digit position, whichever is specified, of the elementary numeric data item. (In this instance, specification of SIGN IS TRAILING is the equivalent of the standard action of the compiler.)  The character S in the PICTURE character string is not counted in determining the size of the item (in terms of standard data format characters). If the SEPARATE CHARACTER phrase is specified, then:  The operational sign is presumed to be the LEADING or TRAILING character position, whichever is specified, of the elementary numeric data item. This character position is not a digit position.  The character S in the PICTURE character string is counted in determining the size of the data item (in terms of standard data format characters).  + is the character used for the positive operational sign.  - is the character used for the negative operational sign. ═══ 11.22. SYNCHRONIZED Clause ═══ The SYNCHRONIZED clause specifies the alignment of an elementary item in storage. To use the SYNCHRONIZED clause, specify the *SYNC compiler option on the CRTCBLMOD or CRTBNDCBL command. ┌─── SYNCHRONIZED CLAUSE - FORMAT ─────────────────────────────────────────────┐ │ │ │ >>──┬─SYNCHRONIZED─┬──┬──────────┬──>< │ │ └─SYNC─────────┘ │ (1) │ │ │ ├─LEFT─────┤ │ │ │ (1)│ │ │ └─RIGHT────┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ When specified, the LEFT and the RIGHT phrases are syntax checked, but they have no effect on the execution of the program. If synchronization is not specified, data is placed contiguously without filler space. If synchronization is specified, data is aligned along addresses which may be wholly divisible by 1, 2, 4, 8, or 16 bytes (where allowed - see Data item USAGE and the SYNCHRONIZATION clause). This may require the (implicit) use of filler space, should the preceding data item not use all the bytes between boundaries. Related Information:  Benefits of Synchronized Data  Synchronization and Offsets  Specifying the SYNCHRONIZED Clause with the OCCURS Clause  Specifying the SYNCHRONIZED Clause with the REDEFINES Clause  FILLER Items  Example of Implicit FILLER. ═══ 11.22.1. Benefits of Synchronized Data ═══ What is the benefit of synchronizing data? Improved performance in terms of its accessibility. The penalty is some wasted storage, due to increased record size (filler spaces become part of the record). Level 01 items and pointers are aligned on 16-byte boundaries always, whether synchronization is specified or not. You are allowed to specify synchronization only for elementary items. It is not permitted for group items. Data storage representation without and with synchronization illustrates the concept: Data storage representation without and with synchronization 01 A 05 A2 PIC X(3) 05 A3 PIC 9(5) BINARY 01 B 05 B2 PIC X(16) WITHOUT SYNCHRONIZATION ┌──────────────────┐ ┌─────────────────────────┐ │ item A │ │ item B │ Data │ │ │ │ Storage ├─────────┬────────┼──────┼─────────────────────────┤ Representation │ │ │ fil- │ item B2 │ │ item A2 │item A3 │ ler │ │ │ │ │ │ │ └─────────┴────────┴──────┴─────────────────────────┘ Bytes 0 3 7 16 WITH SYNCHRONIZATION ┌─────────────────────┐ ┌─────────────────────────┐ │ item A │ │ item B │ Data │ │ │ │ Storage ├─────────┬──┬────────┼───┼─────────────────────────┤ Representation │ │fi│ │fil│ item B2 │ │ item A2 │ll│item A3 │ler│ │ │ │er│ │ │ │ └─────────┴──┴────────┴───┴─────────────────────────┘ Bytes 0 3 4 8 16 Data storage representation without and with synchronization shows that A and B are always aligned on 16 byte boundaries. Without synchronization, A2 and A3 are stored contiguously regardless of size. With synchronization, a 4 byte boundary is chosen (due to A3's type), and A3 is aligned accordingly. There is a one byte filler between A2 and A3. However, A3 should be accessed faster. ═══ 11.22.2. Synchronization and Offsets: ═══ In the preceding figure, note that A and B do not have to be following each other in actual storage. In other words, you cannot know if B starts 16 bytes after A's start, or 48 bytes (16 x 3), or 16 x N bytes. You must not attempt to retrieve synchronized data by specifying offsets. -----IBM Extension----- The SYNCHRONIZED clause is implicit for pointer data and procedure-pointer data items. Pointer data and procedure-pointer data items declared in the Linkage Section are not synchronized. ---End of IBM Extension--- Depending on the USAGE that is specified for an item, the SYNCHRONIZED clause has a particular effect. Data item USAGE and the SYNCHRONIZATION clause shows how the USAGE of an item determines the effect of the SYNCHRONIZED clause upon it. ┌──────────────────────────────────────────────────────────────────────────────┐ │ Data item USAGE and the SYNCHRONIZATION clause │ ├───────────────────────────────┬──────────────────────────────────────────────┤ │ IF THE USAGE IS... │ THE SYNCHRONIZED CLAUSE... │ ├───────────────────────────────┼──────────────────────────────────────────────┤ │ DISPLAY │ is syntax checked but does not affect exe- │ │ │ cution │ ├───────────────────────────────┼──────────────────────────────────────────────┤ │ PACKED-DECIMAL │ is syntax checked but does not affect exe- │ │ │ cution │ ├───────────────────────────────┼──────────────────────────────────────────────┤ │ COMPUTATIONAL-3 │ is syntax checked but does not affect exe- │ │ │ cution │ ├───────────────────────────────┼──────────────────────────────────────────────┤ │ BINARY: │ aligns data item at a multiple of 2 relative │ │ PIC S9(1) through PIC S9(4) │ to the beginning of the record │ ├───────────────────────────────┼──────────────────────────────────────────────┤ │ BINARY: │ aligns data item at a multiple of 4 relative │ │ PIC S9(5) through PIC S9(9) │ to the beginning of the record │ ├───────────────────────────────┼──────────────────────────────────────────────┤ │ BINARY: │ aligns data item at a multiple of 8 relative │ │ PIC S9(10) through PIC │ to the beginning of the record │ │ S9(18) │ │ ├───────────────────────────────┼──────────────────────────────────────────────┤ │ COMPUTATIONAL-4 │ functions the same as for USAGE BINARY │ ├───────────────────────────────┼──────────────────────────────────────────────┤ │ COMPUTATIONAL │ is syntax checked but does not affect exe- │ │ │ cution │ ├───────────────────────────────┼──────────────────────────────────────────────┤ │ INDEX │ is not permitted │ ├───────────────────────────────┼──────────────────────────────────────────────┤ │ POINTER │ aligns data item at a multiple of 16 rela- │ │ │ tive to the beginning of the record │ ├───────────────────────────────┼──────────────────────────────────────────────┤ │ PROCEDURE-POINTER │ functions the same as for USAGE POINTER │ └───────────────────────────────┴──────────────────────────────────────────────┘ The length of an elementary item is not affected by the SYNCHRONIZED clause. ═══ 11.22.3. Specifying the SYNCHRONIZED Clause with the OCCURS Clause ═══ When the SYNCHRONIZED clause is specified for an item within the scope of the OCCURS clause, each occurrence of the item is synchronized. ═══ 11.22.4. Specifying the SYNCHRONIZED Clause with the REDEFINES Clause ═══ When the SYNCHRONIZED clause is specified for an item that also contains a REDEFINES clause, the data item that is redefined must have the proper boundary alignment for the data item that redefines it. No padding characters are added for items containing the REDEFINES clause. For example, if you write the following, be sure that data item A begins at a multiple of 4 bytes relative to the beginning of the record: 02 A PICTURE X(4). 02 B REDEFINES A PICTURE S9(9) BINARY SYNC. When the SYNCHRONIZED clause is specified for a binary item that is the first elementary item subordinate to an item that contains a REDEFINES clause, the item must not require the addition of unused character positions. ═══ 11.22.5. FILLER Items ═══ The FILLER item is treated as if it were an item with a level number equal to that of the preceding item. The size of this implicit FILLER item is calculated as follows:  The total number of characters occupied by all elementary data items preceding the aligned item are added together, including any implicit FILLER items previously added.  This sum is divided by the factor m used as a multiplier in the above calculation of alignment (2, 4, 8, or 16).  If the remainder r of this division is equal to zero, no implicit FILLER item is required. If the remainder is not equal to zero, the size of the implicit FILLER item is equal to m - r. The size of the implicit FILLER item is not included in the size of any group item that contains it. Group items are naturally defined as alphanumeric. Any FILLER items are initialized with spaces. Implicit FILLER items generated through the SYNCHRONIZED clause, then, are also initialized with spaces under the (default) *STDINZ compiler option. Under the *NOSTDINZ option, these implicit FILLER items will contain hexadecimal zeroes. An implicit FILLER item may also be added by the compiler when a group item is defined with an OCCURS clause and contains data items that are subject to alignment. To determine whether an implicit FILLER is to be added, the following action is taken:  The compiler calculates the size of the group item, including all necessary implicit FILLER items.  This sum is divided by the largest m required by any elementary item within the group.  If r is equal to zero, no implicit FILLER item is required. If r is not equal to zero, an implicit FILLER item of size m - r must be added. An implicit FILLER item may be inserted at the end of each occurrence of the group item containing the OCCURS clause. This is done to synchronize subsequent occurrences. Items at level 01 or 77 are aligned according to the following rules: ┌──────────────────┬──────────┬────────────────────────────────────────────────┐ │ AREA │ LEVEL │ BOUNDARY ALIGNMENT │ │ │ NUMBER │ │ ├──────────────────┼──────────┼────────────────────────────────────────────────┤ │ Working-Storage │ 01 │ 16 bytes │ │ Section │ 77 │ 16 bytes │ ├──────────────────┼──────────┼────────────────────────────────────────────────┤ │ File Section │ 01 │ Compiler assumes a 16-byte boundary for syn- │ │ │ │ chronizing items. │ ├──────────────────┼──────────┼────────────────────────────────────────────────┤ │ Linkage Section │ 01 │ Compiler assumes a 16-byte boundary for syn- │ │ │ 77 │ chronizing items. Pointer data and procedure- │ │ │ │ pointer data items are not synchronized. │ └──────────────────┴──────────┴────────────────────────────────────────────────┘ ═══ 11.22.5.1. Example of Implicit FILLER ═══ The following COBOL data description will produce the computer storage allocation shown in Computer Storage Allocation. 01 UNSYNCHRONIZED-RECORD 02 UNSYNCHRONIZED-DATA-1 PIC 9(3) DISPLAY. 02 UNSYNCHRONIZED-DATA-2 PIC X(2). 01 COMPOUND-REPEATED-RECORD. 02 ELEMENTARY-ITEM-1 PIC X (2). 02 GROUP-ITEM OCCURS 3 TIMES. 03 ELEMENTARY-ITEM-2 PIC X. 03 ELEMENTARY-ITEM-3 PIC S9(2) BINARY SYNC. 03 ELEMENTARY-ITEM-4 PIC S9(4) V9(2) BINARY SYNC. 03 ELEMENTARY-ITEM-5 PIC X (5). Computer Storage Allocation │ │ │Unsynchronized-│ Compound-Repeated-Record │ Record │ │ │ │ │ │ │ │ │ │ Group-Item (1) │ │ Group-Item (2) and so │ │ │ │ │ forth │ U │ │E│ │E │ │ │ │ │E│ │E │ │ │ │ UD1 │D │ │EI1│I│ │I │ │ EI4 │ EI5 │ │I│ │I │ │ EI4 │ EI5 │ │2 │ │ │2│ │3 │ │ │ │ │2│ │3 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │9 9 9│x x│@ @ @│x x│x│#│* C│# #│* C C C│x x x x x│$│x│#│* C│# #│* C C C│x x x x x ├─┬─┬─┼─┬─┼─┬─┬─┼─┬─┼─┼─┼─┬─┼─┬─┼─┬─┬─┬─┼─┬─┬─┬─┬─┼─┼─┼─┼─┬─┼─┬─┼─┬─┬─┬─┼─┬─┬─┬─┬─┐ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 2 │ 2 │ 2 │ 2 │ 2 │ 2 │ 2 │ 2 │ 2 │ 2 │ │ │ │ │ │ │ │ │ │ │ │ │ 4 │ 4 │ 4 │ 4 │ 4 │ │ │ │ │ │ │ 16 16 16 16 16 16 @ Indicates implicit FILLER bytes allocated because of automatic synchronization or a record (01-level) description # Indicates implicit FILLER bytes allocated when the following data item is explicitly synchronized * The first byte of a BINARY item that has been synchronized $ Indicates implicit FILLER bytes allocated when a non-elementary item is subject to an OCCURS clause. 9 Indicates bytes allocated for a numeric DISPLAY character X Indicates bytes allocated for an alphanumeric DISPLAY character C Indicates bytes allocated for a BINARY data storage ═══ 11.23. USAGE Clause ═══ The USAGE clause specifies the format in which data is represented in storage. The format may be restricted if certain Procedure Division statements are used. ┌─── USAGE CLAUSE - FORMAT ────────────────────────────────────────────────────┐ │ │ │ >>──┬───────────────┬──┬─BINARY───────────────┬──>< │ │ └─USAGE──┬────┬─┘ ├─COMPUTATIONAL────────┤ │ │ └─IS─┘ ├─COMP─────────────────┤ │ │ │ (1) │ │ │ ├─COMPUTATIONAL-3──────┤ │ │ │ (1) │ │ │ ├─COMP-3───────────────┤ │ │ │ (1) │ │ │ ├─COMPUTATIONAL-4──────┤ │ │ │ (1) │ │ │ ├─COMP-4───────────────┤ │ │ ├─DISPLAY──────────────┤ │ │ ├─INDEX────────────────┤ │ │ ├─PACKED-DECIMAL───────┤ │ │ │ (1) │ │ │ ├─POINTER──────────────┤ │ │ │ (1)│ │ │ └─PROCEDURE-POINTER────┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The USAGE clause can be specified for an entry at any level (other than 66 or 88). However, if it is specified at the group level, it applies to each elementary item in the group rather than to the group itself. The usage of an elementary item must not contradict the usage specified on the owning group item. When the USAGE clause is not specified at either the group or elementary level, it is assumed that the usage is DISPLAY. Related Information:  Computational Items ═══ 11.23.1. Computational Items ═══ A computational item is a value used in arithmetic operations. It must be numeric. If the USAGE of a group item is described with any of these items, the elementary items within the group have this usage. The group itself is considered nonnumeric and cannot be used in numeric operations, except for those using the CORRESPONDING phrase (see CORRESPONDING Phrase). The maximum length of a computational item is 18 decimal digits. The PICTURE of a computational item may contain only: 9 One or more numeric character positions S One operational sign V One implied decimal point P One or more decimal scaling positions. ═══ 11.23.1.1. BINARY ═══ Specified for binary data items. Such items have a decimal equivalent consisting of the decimal digits 0 through 9, plus a sign. The amount of storage occupied by a binary item depends on the number of decimal digits defined in its PICTURE clause: Digits in PICTURE Clause Storage Occupied 1 through 4 2 bytes 5 through 9 4 bytes 10 through 18 8 bytes The leftmost bit of the storage area is the operational sign. For better performance, avoid using 8-byte binary items. You can specify these items for convenience, but the compiler must make conversions in order to use them. ═══ 11.23.1.2. PACKED-DECIMAL ═══ Specified for internal decimal items. Such an item appears in storage in packed decimal format. There are 2 digits for each character position, except for the trailing character position, which is occupied by the low-order digit and the sign. Such an item may contain any of the digits 0 through 9, plus a sign, representing a value not exceeding 18 decimal digits. ═══ 11.23.1.3. COMPUTATIONAL or COMP ═══ Specified for internal decimal items. Such an item appears in storage as 2 digits per byte, with the sign contained in the 4 rightmost bits of the rightmost byte. An internal decimal item can contain any of the digits 0 through 9 plus a sign. If the PICTURE of an internal decimal item does not contain an S, the sign position is occupied by a bit configuration that is interpreted as positive. Internal representation of USAGE COMP items is normally assigned to the most efficient of all the USAGEs. For the ILE COBOL/400 compiler, the COMPUTATIONAL phrase is synonymous with PACKED-DECIMAL. ═══ 11.23.1.4. COMPUTATIONAL-3 or COMP-3 (internal decimal) ═══ -----IBM Extension----- This is the equivalent of PACKED-DECIMAL. ---End of IBM Extension--- ═══ 11.23.1.5. COMPUTATIONAL-4 or COMP-4 (binary) ═══ -----IBM Extension----- This is the equivalent of BINARY. ---End of IBM Extension--- ═══ 11.23.2. DISPLAY Phrase ═══ The data item is stored in character form, 1 character for each 8-bit byte. This corresponds to the format used for printed output. DISPLAY can be explicit or implicit. USAGE IS DISPLAY is valid for the following types of items:  Alphabetic  Alphanumeric  Alphanumeric-edited  Numeric-edited -----IBM Extension-----  Boolean ---End of IBM Extension---  External decimal (numeric). The PICTURE character-string of a zoned item can contain only 9s, the operational sign symbol S, the assumed decimal point V, and one or more Ps. ═══ 11.23.2.1. External decimal (numeric) ═══ External Decimal Items are sometimes referred to as zoned decimal items. Each digit of a number is represented by a single byte. The 4 high-order bits of each byte are zone bits; the 4 high-order bits of the low-order byte represent the sign of the item. If the number is positive, these four bits contain a hexadecimal F. If the number is negative, these four bits contain a hexadecimal D. The 4 low-order bits of each byte contain the value of the digit. The maximum length of an external decimal item is 18 digits. The PICTURE character-string of an external decimal item may contain only 9s; the operational-sign, S; the assumed decimal point, V; and one or more Ps. ═══ 11.23.3. INDEX Phrase ═══ A data item defined with the INDEX phrase is an index data item. An index data item is a 4-byte elementary item (not necessarily connected with any table) that can be used to save index-name values for future reference. Through a SET statement, an index data item can be assigned an index-name value. The index-name value is the displacement, which corresponds to an occurrence number in the table. The index-name value equals: (occurrence-number - 1) * entry length Any attempt to set an index-name to a value greater than 999 999 999 will leave the index-name value undefined. Direct references to an index data item can be made only in a SEARCH statement, a SET statement, a relation condition, the USING phrase of the Procedure Division header, or the USING phrase of the CALL statement. An index data item can be part of a group item referred to in a MOVE statement or an input/output statement. An index data item saves values that represent table occurrences, yet is not necessarily defined as part of any table. Thus, when it is referred to directly in a SEARCH or SET statement, or indirectly in a MOVE or input/output statement, there is no conversion of values when the statement is executed. The USAGE IS INDEX clause may be written at any level. If a group item is described with the USAGE IS INDEX clause, the elementary items within the group are index data items; the group itself is not an index data item, and the group name may not be used in SEARCH and SET statements or in relation conditions. The USAGE clause of an elementary item cannot contradict the USAGE clause of a group to which the item belongs. An index data item cannot be a conditional variable. The JUSTIFIED, PICTURE, BLANK WHEN ZERO, SYNCHRONIZED, or VALUE clauses cannot be used to describe group or elementary items described with the USAGE IS INDEX clause. If a source program is to be portable to other systems, it must not depend on the content of the index data item when stored in external records (since the content is system specific). ═══ 11.23.4. POINTER Phrase ═══ -----IBM Extension----- A data item defined with the USAGE IS POINTER clause is a pointer data item. A pointer data item is a 16-byte elementary item that can be used to accomplish base addressing. Pointer data items can be compared for equality, or moved to other pointer items. A pointer data item may only be used in:  A SET statement (Format 5 only)  A relation condition  The USING phrase of a CALL statement or Procedure Division header  Expressions involving ADDRESS OF or LENGTH OF. The USAGE IS POINTER clause may be written at any level except 66 or 88. If a group item is described with the USAGE IS POINTER clause, the elementary items within the group are pointer data items. The group itself, however, is not a pointer data item and cannot be used in the syntax where a pointer data item is allowed. Pointer data items can be part of a group that is referred to in a MOVE statement or an I/O statement. If, however, a pointer data item is part of a group, there is no conversion of pointer values to another internal representation when the statement runs. A pointer data item can be the subject or object of a REDEFINES clause. A VALUE clause for a pointer data item can contain NULL or NULLS only. A pointer data item does not belong to a class or category, and it cannot be used as a conditional variable. The JUSTIFIED, PICTURE, SIGN, and BLANK WHEN ZERO clauses cannot be used to describe group or elementary items defined with the USAGE IS POINTER clause. Pointer data items are ignored in CORRESPONDING operations. A pointer data item can be written to a file, but if you later read the record containing the pointer data item, the item will no longer represent a valid address. USAGE IS POINTER is implicitly specified for the ADDRESS OF special register. You cannot treat ILE COBOL/400 pointer data items as ordinary numbers. Related Information:  Pointer Alignment ---End of IBM Extension--- ═══ 11.23.4.1. Pointer Alignment ═══ -----IBM Extension----- For the purposes of this section on pointer alignment, the term pointer refers to both pointer data items and procedure-pointer data items. When a pointer is referenced, or is the subject of a REDEFINES clause, the object item must be in alignment. In other words, it must be located at an offset that is a multiple of 16 bytes from the beginning of the record. A data item described as a pointer in the Working-storage or File section is aligned. If the pointer is part of a structure that begins at level-number 01, the compiler aligns the beginning of the structure. After that, the compiler puts FILLER items in front of the pointer to make sure that it is also in alignment. The compiler issues a warning when it adds these FILLER items. In the Linkage section, the compiler does not add FILLER items to the structure, but it issues warnings regarding its assumption that you have aligned the 01-level items. If a pointer is the subject of a REDEFINES clause in the Linkage section, and the object of the clause is not a pointer, you will receive a warning that you need to maintain pointer alignment. For the same situation in the Working-storage or File section, an error will result if you do not align the object of the clause. You can specify the SYNCHRONIZED clause along with USAGE IS POINTER or USAGE IS PROCEDURE-POINTER clause, but this clause is already implicit for pointers. If the pointer is part of a table, the first item in the table is aligned, and to make sure that all occurrences of the pointer are also aligned, a filler item might be added to the end of the table. To avoid adding FILLER items to data structures, place pointers at the beginning of the structures. ---End of IBM Extension--- ═══ 11.23.5. PROCEDURE-POINTER Phrase ═══ -----IBM Extension----- A data item defined with the PROCEDURE-POINTER phrase is a procedure-pointer data item. It is a 16-byte elementary item containing the address of an entry point to an ILE procedure or program object (*PGM), such as:  The entry point of the outermost ILE COBOL/400 program (an ILE procedure) in the compilation unit defined by the PROGRAM-ID statement  An entry point of a non-COBOL program, such as an ILE C/400 function (an ILE procedure)  An entry point of a program (*PGM). A procedure-pointer data item may only be used in:  The SET statement  A relation condition  The USING phrase of a CALL statement, or the Procedure Division header  Expressions involving ADDRESS OF and LENGTH OF  The CALL statement as a target Like pointer data items, procedure-pointer data items must be in alignment. ---End of IBM Extension--- Related Information:  PROCEDURE-POINTER Usage Rules ═══ 11.23.5.1. Usage Rules ═══ -----IBM Extension-----  The USAGE IS PROCEDURE-POINTER clause cannot be written at level-88  In a group item described with the USAGE IS PROCEDURE-POINTER clause, the elementary items within the group are procedure-pointer data items (the group itself is not a procedure-pointer)  The USAGE clause of an elementary item cannot contradict the USAGE clause of a group to which the item belongs  Procedure-pointer data items can be part of a group that is referred to in a MOVE statement, or an input/output statement. However, there is no conversion of values when the statement is executed  A procedure-pointer data item can be written to a file, but if you later read the same record containing the procedure-pointer, the item will no longer represent a valid address.  GLOBAL, EXTERNAL, OCCURS, SYNCHRONIZED, and LIKE clauses may be used with USAGE IS PROCEDURE-POINTER  A procedure-pointer may be the subject or object of a REDEFINES clause  A VALUE clause for a procedure-pointer data item can contain only NULL or NULLS  JUSTIFIED, PICTURE, and BLANK WHEN ZERO clauses cannot describe group or elementary items defined with the USAGE IS PROCEDURE-POINTER clause  A procedure-pointer data item cannot be a conditional variable, does not belong to any class or category, and is ignored in CORRESPONDING operations. ---End of IBM Extension--- ═══ 11.24. VALUE Clause ═══ The VALUE clause specifies the initial contents of a data item or the value(s) associated with a condition-name. The VALUE clause has three formats:  Format 1 - Literal Value  Format 2 - Condition-Name Value -----IBM Extension-----  Format 3 - NULL Value ---End of IBM Extension--- The use of the VALUE clause differs depending on the Data Division section in which it is specified. -----IBM Extension----- In the Linkage section, a VALUE clause used in entries other than condition-names is treated as a comment. ---End of IBM Extension--- In the File and Linkage sections, the VALUE clause must be used only in condition-name entries. In the Working-Storage Section, the VALUE clause may be used in condition-name entries, or in specifying the initial value of any data item. The data item assumes the specified value at the beginning of program execution. If the initial value is not explicitly specified, it is unpredictable. ═══ 11.24.1. VALUE Clause - Format 1 - Literal Value ═══ ┌─── VALUE CLAUSE - FORMAT 1 - LITERAL VALUE ──────────────────────────────────┐ │ │ │ >>──VALUE──┬────┬──literal──>< │ │ └─IS─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Format 1 specifies the initial value of a data item. Initialization is independent of any BLANK WHEN ZERO or JUSTIFIED clause specified. A Format 1 VALUE clause specified in a data description entry that contains, or is subordinate to an OCCURS clause, causes every occurrence of the associated data item to be assigned the specified value. Each structure that contains the DEPENDING ON phrase of the OCCURS clause is assumed to contain the maximum number of occurrences for the purposes of VALUE initialization. The VALUE clause must not be specified for a data description entry that contains, or is subordinate to, an entry containing an EXTERNAL clause or a REDEFINES clause. This rule does not apply to condition-name entries. If the VALUE clause is specified at the group level, the literal must be a nonnumeric literal or a figurative constant other than NULL or NULLS. The group area is initialized without consideration for the subordinate entries within this group. In addition, the VALUE clause must not be specified for subordinate entries within this group. For group entries, the VALUE clause must not be specified if the entry also contains a USAGE (other than USAGE DISPLAY) clause. The VALUE clause must not conflict with other clauses in the data description entry, or in the data description of this entry's hierarchy. Related Information:  Rules for Literal Values ═══ 11.24.2. Rules for Literal Values: ═══  Wherever a literal is specified, a figurative constant may be substituted.  If the item is numeric, all VALUE clause literals must be numeric. If the literal defines the value of a Working-Storage item, the literal is aligned according to the rules for numeric moves, with one additional restriction: The literal must not have a value that requires truncation of nonzero digits. If the literal is signed, the associated PICTURE character-string must contain a sign symbol (S).  All numeric literals in a VALUE clause of an item must have a value that is within the range of values indicated by the PICTURE clause for that item. For example, for a PICTURE of 99PPP, the literal must fall within the range of 1 000 through 99 000, or it must be zero. For a PICTURE of PPP99, the literal must fall within the range of 0.000 00 through 0.000 99.  If the item is a group item, or an elementary alphabetic, alphanumeric, alphanumeric-edited, or numeric-edited item, all VALUE clause literals must be nonnumeric literals. The literal is aligned according to the alignment rules, with one additional restriction: the number of characters in the literal must not exceed the size of the item. -----IBM Extension----- If the item is Boolean, the VALUE clause must be a Boolean literal. ---End of IBM Extension---  The functions of the editing characters in a PICTURE clause are ignored in determining the initial appearance of the item described. However, editing characters are included in determining the size of the item. Therefore, any editing characters must be included in the literal. For example, if the item is defined as PICTURE +999.99 and the value is to be +12.34, then the VALUE clause should be specified as VALUE '+012.34'.  A maximum of 32 767 bytes can be initialized by means of a single VALUE clause. A maximum of 65 472 bytes can be initialized by all of the VALUE clauses contained within a single program. ═══ 11.24.3. VALUE Clause - Format 2 - Condition-Name Value ═══ ┌─── VALUE CLAUSE - FORMAT 2 - CONDITION-NAME VALUE ───────────────────────────┐ │ │ │ >>──88──condition-name──┬─VALUE──┬────┬───┬────────────────────────────────> │ │ │ └─IS─┘ │ │ │ └─VALUES──┬─────┬─┘ │ │ └─ARE─┘ │ │ │ │ ┌───────────────────────────────────────┐ │ │  │ │ │ >────literal-1──┬────────────────────────┬─┴──.──>< │ │ └─┬─THROUGH─┬──literal-2─┘ │ │ └─THRU────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ This format associates a value, values, and/or range(s) of values with a condition-name. Each such condition-name requires a separate level-88 entry. Level-number 88 and condition-name are not part of the Format 2 VALUE clause itself. They are included in the format only for clarity. Related Information:  Rules for Condition-Name Values ═══ 11.24.4. Rules for Condition-Name Values: ═══  The VALUE clause is required in a condition-name entry, and must be the only clause in the entry. Each condition-name entry is associated with a preceding conditional variable. Thus, every level-88 entry must always be preceded either by the entry for the conditional variable, or by another level-88 entry when several condition-names apply to one conditional variable. Each such level-88 entry implicitly has the PICTURE characteristics of the conditional variable.  The condition-name entries associated with a particular conditional variable must immediately follow the conditional variable entry. The conditional variable can be any data description entry except: - A level-66 item (RENAMES clause) - A data item whose USAGE IS INDEX - An item whose USAGE IS POINTER or PROCEDURE-POINTER.  A condition-name can be associated with a group item data description entry. In this case: - The condition-name value must be specified as a nonnumeric literal or figurative constant. - The size of the condition-name value must not exceed the sum of the sizes of all the elementary items within the group. - No element within the group may contain a JUSTIFIED or SYNCHRONIZED clause. - No USAGE other than DISPLAY may be specified within the group.  Condition-names can be specified both at the group level and at subordinate levels within the group.  The relation test implied by the definition of a condition-name at the group level is performed in accordance with the rules for comparison of nonnumeric operands, regardless of the nature of elementary items within the group.  A space, a separator comma, or a separator semicolon, must separate successive operands.  Each entry must end with a separator period.  The type of literal in a condition-name entry must be consistent with the data type of its conditional variable. ═══ 11.24.5. VALUE Clause - Format 3 - NULL Value ═══ -----IBM Extension----- ┌─── VALUE CLAUSE - FORMAT 3 - NULL VALUE ─────────────────────────────────────┐ │ │ │ (1) │ │ >>──VALUE─────┬────┬──┬─NULL──┬──>< │ │ └─IS─┘ └─NULLS─┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ This format assigns an address that is not valid to a pointer data item or a procedure-pointer data item. A value of NULL is an undefined value. VALUE IS NULL can only be specified for elementary items described implicitly or explicitly as USAGE IS POINTER or USAGE IS PROCEDURE-POINTER. ---End of IBM Extension--- ═══ 12. Procedure Division ═══ The Procedure Division is optional in a COBOL source program. The Procedure Division consists of optional declaratives, and procedures that contain sections and/or paragraphs, sentences, and statements. The Procedure Division has two formats:  Format 1 - with Sections and Paragraphs  Format 2 - with Paragraphs Only. Execution begins with the first statement in the Procedure Division, excluding declaratives. Statements are executed in the order in which they are presented for compilation, unless the statement rules dictate some other order of execution. The Procedure Division ends at the physical end of the program; that is, the physical position in a source program after which no further statements appear. Related Information:  Sample Procedure Division Statements  Arithmetic Expressions  Conditional Expressions  Statement Categories  Statement Operations ═══ 12.1. Format 1 - with Sections and Paragraphs ═══ ┌─── PROCEDURE DIVISION - FORMAT 1 ────────────────────────────────────────────┐ │ │ │ >>──PROCEDURE DIVISION──┬────────────────────────┬──.──────────────────────> │ │ │ ┌─────────────┐ │ │ │ │  │ │ │ │ └─USING────data-name-1─┴─┘ │ │ │ │ >──┬───────────────────────────────────────────────────────┬───────────────> │ │ │ ┌────────────────┐ │ │ │ │  │ │ │ │ └─DECLARATIVES.────┤ Sections-2 ├─┴──END DECLARATIVES.─┘ │ │ │ │ ┌────────────────┐ │ │  │ │ │ >────┤ Sections-1 ├─┴──>< │ │ │ │ SECTIONS-1: │ │ ├──section-name──SECTION──┬────────────────┬───────────────────────────────> │ │ └─segment-number─┘ │ │ │ │ >──┬───────────────────────────────────────┬──┤ │ │ │ ┌───────────────────────────────────┐ │ │ │ │  │ │ │ │ └───paragraph-name.──┬──────────────┬─┴─┘ │ │ │ ┌──────────┐ │ │ │ │  │ │ │ │ └───sentence─┴─┘ │ │ │ │ SECTIONS-2: │ │ ├──section-name──SECTION──┬────────────────┬──.──USE statement.────────────> │ │ └─segment-number─┘ │ │ │ │ >──┬───────────────────────────────────────┬──┤ │ │ │ ┌───────────────────────────────────┐ │ │ │ │  │ │ │ │ └───paragraph-name.──┬──────────────┬─┴─┘ │ │ │ ┌──────────┐ │ │ │ │  │ │ │ │ └───sentence─┴─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.2. Format 2 - with Paragraphs Only ═══ ┌─── PROCEDURE DIVISION - FORMAT 2 ────────────────────────────────────────────┐ │ │ │ >>──PROCEDURE DIVISION──┬────────────────────────┬──.──────────────────────> │ │ │ ┌─────────────┐ │ │ │ │  │ │ │ │ └─USING────data-name-1─┴─┘ │ │ │ │ ┌───────────────────────────────────┐ │ │  │ │ │ >────paragraph-name.──┬──────────────┬─┴──>< │ │ │ ┌──────────┐ │ │ │ │  │ │ │ │ └───sentence─┴─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.3. The USING Phrase ═══ The USING phrase makes data items defined in a calling program available to a called subprogram. The following rules for the USING phrase assume that the calling and called programs are written in COBOL.  The USING phrase is specified in the Procedure Division header if, and only if, this program is a subprogram invoked by a CALL statement that itself contains a USING phrase. For each CALL USING statement in a calling program, there must be a corresponding USING phrase specified in a called subprogram  The USING phrase is valid in the Procedure Division header of a called subprogram entered at the beginning of the nondeclaratives portion  Each USING identifier must be defined as a level-01 or level-77 item in the Linkage Section of the called subprogram  A USING identifier must not contain a REDEFINES clause  A particular user-defined word may not appear more than once as data-name-1  In a calling program, the USING phrase is valid for the CALL statement; each USING identifier must be defined as a level-01, level-77, or an elementary item in the Data Division  The maximum number of data-names that can be specified is 255 when a program is called with a LINKAGE TYPE of program. For programs called with LINKAGE TYPE of procedure, the predefined maximum number of data-names is 400.  The order of appearance of USING identifiers in both calling and called subprograms determines the correspondence of single sets of data available to both programs. The correspondence is positional and not by name. Corresponding identifiers must contain the same number of characters, although their data descriptions need not be the same. For index-names, no correspondence is established; index-names in calling and called programs always refer to separate indexes.  The identifiers specified in a CALL USING statement name data items available to the calling program that may be referred to in the called program; a given identifier may appear more than once. These items are defined in any Data Division section. -----IBM Extension-----  An identifier may appear more than once in a Procedure Division USING phrase. In that case, the last value assigned to the identifier by a CALL USING statement is used. ---End of IBM Extension---  Data items defined in the Linkage Section of the called program may be referenced within the Procedure Division of that program if, and only if, they satisfy one of the following conditions: - They are operands of the USING phrase of the Procedure Division header - They are defined with a REDEFINES or RENAMES clause, the object of which satisfies the above condition -----IBM Extension----- - They are used as arguments of the ADDRESS OF special register ---End of IBM Extension--- - They are items subordinate to any item which satisfies the condition in the rules above - They are condition-names or index-names associated with data items that satisfy any of the above conditions. ═══ 12.4. Declaratives ═══ Declaratives provide one or more special-purpose sections that are executed when an exception-condition occurs. When Declarative Sections are specified, they must be grouped at the beginning of the Procedure Division, and the entire Procedure Division must be divided into sections. Each Declarative Section starts with a USE sentence that identifies the section's function; the series of procedures that follow specify what actions are to be taken when the exception condition occurs. Each Declarative Section ends with another section-name followed by a USE sentence, or with the keywords END DECLARATIVES. See USE Statement for more information on the USE statement. See Precedence Rules for Nested Programs on using the GLOBAL phrase. The entire group of Declarative Sections is preceded by the key word DECLARATIVES, written on the line after the Procedure Division header; the group is followed by the keywords END DECLARATIVES. The keywords DECLARATIVES and END DECLARATIVES must each begin in Area A and be followed by a separator period. No other text may appear on the same line. In the declaratives part of the Procedure Division, each section header (with an optional segment number) must be followed by a separator period, a USE sentence, and a separator period. No other text may appear on the same line. The USE sentence itself is never executed; instead, the USE sentence defines the conditions that execute the succeeding procedural paragraphs, which specify the actions to be taken. After the procedure is executed, control is returned to the routine that caused the execution of it. Within a declarative procedure, there must be no reference to any nondeclarative procedure. A procedure-name associated with a USE statement can be referenced in a different declarative section or in a nondeclarative procedure only with a PERFORM statement. A declarative is run as a separate invocation from any other declaratives or from the nondeclarative part of the COBOL program. Within a declarative procedure, no statement should be included that would cause the execution of a USE procedure that had been previously invoked and had not yet returned control to the invoking routine. The declarative procedure is exited when the last statement in the procedure is executed. ═══ 12.4.1. Section ═══ A section consists of a section header optionally followed by one or more paragraphs. A section-header is a section-name followed by: the keyword SECTION, an optional segment-number, and a separator period. The section-header must begin in Area A. A section-name is a user-defined word that identifies a section. If referenced, a section-name must be unique within the program in which it is defined, because it cannot be qualified. A section ends immediately before the next section header, or at the end of the Procedure Division, or, in the declaratives portion, at the keywords END DECLARATIVES. ═══ 12.4.2. Paragraph ═══ A paragraph consists of a paragraph-name followed by a separator period, optionally followed by one or more sentences. A paragraph-name is a user-defined word that identifies a paragraph. A paragraph-name, because it can be qualified, need not be unique. The paragraph-name must begin in Area A. A paragraph ends immediately before the next paragraph-name or section header, or at the end of the Procedure Division. In the declaratives portion, a paragraph ends immediately before the next paragraph, the next USE statement, or at the keywords END DECLARATIVES. If one paragraph in a program is contained within a section, all paragraphs of the program must be contained in sections. ═══ 12.4.3. Sentence ═══ A sentence consists of one or more statements terminated by a separator period. A statement is a syntactically valid combination of identifiers and symbols (literals, relational-operators, and so forth) beginning with a COBOL verb. An identifier is a syntactically correct combination of a data-name, with its qualifiers, subscripts, and reference modifiers as required for uniqueness of reference, that names a data item. In any Procedure Division reference (except the class test), the contents of an identifier must be compatible with the class specified through its PICTURE clause, or results are unpredictable. ═══ 12.4.4. Sample Procedure Division Statements ═══ . 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7 PROCEDURE DIVISION. DECLARATIVES. ERROR-IT SECTION. USE AFTER STANDARD ERROR PROCEDURE ON INPUT-DATA. ERROR-ROUTINE. IF CHECK-IT = "30" ADD 1 TO DECLARATIVE-ERRORS. END DECLARATIVES. BEGIN-NON-DECLARATIVES SECTION. 100-BEGIN-IT. OPEN INPUT INPUT-DATA OUTPUT REPORT-OUT. 110-READ-IT. READ INPUT-DATA RECORD AT END MOVE "Y" TO EOF-SW. IF EOF-SW NOT = "Y" ADD 1 TO RECORDS-IN. 200-MAIN-ROUTINE. PERFORM PROCESS-DATA UNTIL EOF-SW = "Y". PERFORM FINAL-REPORT THRU FINAL-REPORT-EXIT. DISPLAY "TOTAL RECORDS IN = " RECORDS-IN UPON WORK-STATION. DISPLAY "DECLARATIVE ERRORS = " DECLARATIVE-ERRORS UPON WORK-STATION. STOP RUN. PROCESS-DATA. IF RECORD-ID = "G" PERFORM PROCESS-GEN-INFO ELSE IF RECORD-CODE = "C" PERFORM PROCESS-SALES-DATA ELSE PERFORM UNKNOWN-RECORD-TYPE. ═══ 12.5. Arithmetic Expressions ═══ Expressions calculate values which can then be used as operands in conditional and arithmetic statements. Arithmetic expressions are built up from operands and operators under a strict hierarchy and precedence. In general, any arithmetic expression can be: 1. An elementary numeric item such as:  A numeric literal (integer or decimal)  An identifier describing an elementary numeric item  The figurative constant ZERO (ZEROS, ZEROES) 2. An arithmetic expression surrounded by parentheses 3. An arithmetic expression preceded by a unary operator (+, -) 4. Two arithmetic expressions separated by a binary arithmetic operator (+, -, *, /, **) Identifiers and literals appearing in arithmetic expressions must represent either numeric elementary items or numeric literals on which arithmetic may be performed. If an exponential expression is evaluated as both a positive and a negative number, the result will always be the positive number. The square root of 4, for example, always results in +2. If the value of an expression to be raised to a power is zero, the exponent must have a value greater than zero. Otherwise, the size error condition exists. In any case where no real number exists as the result of the evaluation, the size error condition exists. Unless the exponent is a literal integer with a value of 2, the results of exponentiation are truncated after the thirteenth fractional digit. The results of exponentiation when the exponent is noninteger are accurate to seven digits. ═══ 12.5.1. Arithmetic Operators ═══ Five binary and two unary arithmetic operators can be used in arithmetic expressions. They are represented by specific characters that must be preceded and followed by a space. Binary Operator Meaning + Addition - Subtraction * Multiplication / Division ** Exponentiation Unary Operator Meaning + Multiplication by +1 - Multiplication by -1 Parentheses are used to highlight or modify the order of evaluation of complex expressions. This improves both readability and maintainability. Left and right parentheses must be paired in an arithmetic expression with the left parenthesis appearing before its corresponding right parenthesis. Expressions within parentheses are evaluated first and parenthetical pairs can be nested within other pairs. Evaluation proceeds from the least inclusive pairing outward. When the order of evaluation is not made explicit by parentheses, expressions are evaluated left-to-right following the hierarchy listed below: 1. Unary operator 2. Exponentiation 3. Multiplication and division 4. Addition and subtraction. An arithmetic expression may begin only with a left parenthesis, a unary operator, or an operand (that is, an identifier or a literal). It may end only with a right parenthesis or an operand. An arithmetic expression must contain at least one reference to an identifier or a literal. If the first operator in an arithmetic expression is a unary operator, it must be immediately preceded by a left parenthesis if that arithmetic expression immediately follows an identifier or another arithmetic expression. Valid Arithmetic Symbol Pairs shows permissible arithmetic symbol pairs. An arithmetic symbol pair is the combination of two such symbols in sequence. In the figure: Yes indicates a permissible pairing. No indicates that the pairing is not permitted. ┌──────────────────────────────────────────────────────────────────────────────┐ │ Valid Arithmetic Symbol Pairs │ ├─────────────────────┬────────────────────────────────────────────────────────┤ │ │ SECOND SYMBOL │ ├─────────────────────┼───────────┬──────────┬───────────┬──────────┬──────────┤ │ │ IDENTI- │ │ UNARY + │ │ │ │ FIRST SYMBOL │ FIER │ * / ** + │ OR UNARY │ ( │ ) │ │ │ OR │ - │ - │ │ │ │ │ LITERAL │ │ │ │ │ ├─────────────────────┼───────────┼──────────┼───────────┼──────────┼──────────┤ │ IDENTIFIER OR │ No │ Yes │ No │ No │ Yes │ │ LITERAL │ │ │ │ │ │ ├─────────────────────┼───────────┼──────────┼───────────┼──────────┼──────────┤ │ * / ** + - │ Yes │ No │ Yes │ Yes │ No │ ├─────────────────────┼───────────┼──────────┼───────────┼──────────┼──────────┤ │ UNARY + OR UNARY - │ Yes │ No │ No │ Yes │ No │ ├─────────────────────┼───────────┼──────────┼───────────┼──────────┼──────────┤ │ ( │ Yes │ No │ Yes │ Yes │ No │ ├─────────────────────┼───────────┼──────────┼───────────┼──────────┼──────────┤ │ ) │ No │ Yes │ No │ No │ Yes │ └─────────────────────┴───────────┴──────────┴───────────┴──────────┴──────────┘ ═══ 12.6. Conditional Expressions ═══ A conditional expression causes the object program to select alternative paths of control, depending on the truth value of a test. Conditional expressions are specified in EVALUATE, IF, PERFORM, and SEARCH statements. A conditional expression can be specified in either  simple conditions  complex conditions Both simple and complex conditions can be enclosed within any number of paired parentheses; the parentheses do not change whether the condition is simple or complex. ═══ 12.6.1. Simple Conditions ═══ There are five simple conditions:  Class condition  Condition-name condition  Relation condition  Sign condition  Switch-status condition A simple condition has a truth value of either true or false. ═══ 12.6.1.1. Class Condition ═══ The class condition determines whether the content of a data item is alphabetic, alphabetic-lower, alphabetic-upper, numeric, or contains only the characters in the set of characters specified by the CLASS clause as defined in the SPECIAL-NAMES paragraph of the Environment Division. ┌─── CLASS CONDITION - FORMAT ─────────────────────────────────────────────────┐ │ │ │ >──identifier──┬────┬──┬──────┬──┬─NUMERIC──────────┬──> │ │ └─IS─┘ └─NOT──┘ ├─ALPHABETIC───────┤ │ │ ├─ALPHABETIC-LOWER─┤ │ │ ├─ALPHABETIC-UPPER─┤ │ │ └─class-name───────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.6.1.2. NUMERIC ═══ The data item consists entirely of the characters 0 through 9, with or without an operational sign. If its PICTURE does not contain an operational sign, the item being tested is determined to be numeric only if the contents are numeric and an operational sign is not present. If its PICTURE does contain an operational sign, the item being tested is determined to be numeric only if the item is an elementary item, the contents are numeric, and a valid operational sign is present. In the EBCDIC character set, valid embedded operational positive signs are hexadecimal F, C, E, and A. Negative signs are hexadecimal D and B. The preferred positive sign is hexadecimal F, and the preferred negative sign is hexadecimal D. For items described with the SIGN IS SEPARATE clause, valid operational signs are + (hex 4E) and - (hex 60). -----IBM Extension----- For numeric data items, the identifier being tested can be described implicitly or explicitly as USAGE DISPLAY, USAGE PACKED-DECIMAL, USAGE COMP, or USAGE COMP-3. ---End of IBM Extension--- ═══ 12.6.1.3. Condition-Name Condition ═══ A condition-name condition tests a conditional variable to determine whether its value is equal to any value(s) associated with the condition-name. ┌─── CONDITION-NAME CONDITION - FORMAT ────────────────────────────────────────┐ │ │ │ >──condition-name──> │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ A condition-name is used in conditions as an abbreviation for the relation condition. The rules for comparing a conditional variable with a condition-name value are the same as those specified for relation conditions. If the condition-name has been associated with a range of values (or with several ranges of values), the conditional variable is tested to determine whether or not its value falls within the range(s), including the end values. The result of the test is true if one of the values corresponding to the condition-name equals the value of its associated conditional variable. The following example illustrates the use of conditional variables and condition-names: 01 NUMBER PIC 99. 88 FIVE VALUE 5. 88 ONE-DIGIT-EVEN VALUE 0, 2, 4, 6, 8 88 TWO-DIGIT-NUMBER VALUE 10 THRU 99 NUMBER is the conditional variable; FIVE, ONE-DIGIT-EVEN, TWO-DIGIT-NUMBER are condition-names. The following IF statements can be added to the above example to determine the age group of a specific record: IF FIVE... (Tests for value 5) IF ONE-DIGIT-EVEN (Tests for values 0, 2, 4, 6, 8) IF TWO-DIGIT-NUMBER (Tests for values 10 thru 99) Depending on the evaluation of the condition-name condition, alternative paths of execution are taken by the object program. ═══ 12.6.1.4. Relation Condition ═══ A relation condition compares two operands, either of which may be an identifier, a literal, an arithmetic expression, or an index-name. The relation condition must contain at least one reference to an identifier. ┌─── RELATION CONDITION - FORMAT ──────────────────────────────────────────────┐ │ │ │ >──operand-1──┬────┬──┬────────┬───────────────────────────────────────────> │ │ └─IS─┘ │ (1)│ │ │ └─NOT────┘ │ │ │ │ >──┬─┬─GREATER──┬──────┬─┬───────────────┬──operand-2──> │ │ │ │ └─THAN─┘ │ │ │ │ │ ├─>─────────────────┤ │ │ │ │ ├─LESS──┬──────┬────┤ │ │ │ │ │ └─THAN─┘ │ │ │ │ │ ├─┐─────────────────┤ │ │ │ │ ├─EQUAL──┬────┬─────┤ │ │ │ │ │ └─TO─┘ │ │ │ │ │ └─=─────────────────┘ │ │ │ ├─GREATER──┬──────┬──OR EQUAL──┬────┬─┤ │ │ │ └─THAN─┘ └─TO─┘ │ │ │ ├─>=──────────────────────────────────┤ │ │ ├─LESS──┬──────┬──OR EQUAL──┬────┬────┤ │ │ │ └─THAN─┘ └─TO─┘ │ │ │ └─┐=──────────────────────────────────┘ │ │ │ │ NOTE: │ │ (1) NOT GREATER THAN OR EQUAL TO, NOT >=, NOT LESS THAN OR EQUAL TO, and │ │ NOT <=, are IBM Extensions. │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The relational operator specifies the type of comparison to be made. Each relational operator must be preceded and followed by a space. Relational Operator Can Be Written IS GREATER THAN IS > IS NOT GREATER THAN IS NOT > IS LESS THAN IS < IS NOT LESS THAN IS NOT < IS EQUAL TO IS = IS NOT EQUAL TO IS NOT = IS GREATER THAN OR EQUAL TO IS >= IS LESS THAN OR EQUAL TO IS <= -----IBM Extension----- IS NOT GREATER THAN OR EQUAL TO IS NOT >= IS NOT LESS THAN OR EQUAL TO IS NOT <= ---End of IBM Extension--- Related Information:  Pointer Data Items  Procedure-Pointer Data Items  Comparing Numeric Operands  Comparing Nonnumeric Operands  Comparing Numeric and Nonnumeric Operands  Comparing Boolean Operands  Comparing Index-Names and Index Data Items ═══ 12.6.1.4.1. Pointer Data Items ═══ -----IBM Extension----- Pointer data items are items defined explicitly as USAGE IS POINTER. Otherwise, they are ADDRESS OF data items or ADDRESS OF special registers, which are implicitly defined as USAGE IS POINTER. Only EQUAL and NOT EQUAL are allowed as relational operators when you specify pointer data items. The operands are equal if the two addresses used in the comparison would both result in the same storage location. This relation condition is allowed in IF, PERFORM, EVALUATE, and SEARCH Format 1 statements. It is not allowed in SEARCH Format 2 (SEARCH ALL) statements, because there is not a meaningful ordering that can be applied to pointer data items. ┌─── ADDRESS COMPARISON - FORMAT ──────────────────────────────────────────────┐ │ │ │ >──┬─ADDRESS OF──identifier-1─┬──┬────┬──┬─────┬──┬─EQUAL──┬────┬─┬────────> │ │ ├─identifier-2─────────────┤ └─IS─┘ └─NOT─┘ │ └─TO─┘ │ │ │ ├─NULL─────────────────────┤ └─=─────────────┘ │ │ └─NULLS────────────────────┘ │ │ │ │ >──┬─ADDRESS OF──identifier-3─┬──> │ │ ├─identifier-4─────────────┤ │ │ ├─NULL─────────────────────┤ │ │ └─NULLS────────────────────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ---End of IBM Extension--- ═══ 12.6.1.4.2. Procedure-pointer Data Items ═══ -----IBM Extension----- Procedure-pointer data items are items defined explicitly as USAGE IS PROCEDURE-POINTER. Only EQUAL and NOT EQUAL are allowed as relational operators when you specify procedure-pointer data items. The operands are equal if the two addresses used in the comparison would both result in the same storage location. This relation condition is allowed in IF, PERFORM, EVALUATE, and SEARCH Format 1 statements. It is not allowed in SEARCH Format 2 (SEARCH ALL) statements, because there is not a meaningful ordering that can be applied to procedure-pointer data items. ┌─── PROCEDURE-POINTER COMPARISON - FORMAT ────────────────────────────────────┐ │ │ │ >──┬─identifier-1─┬──┬────┬──┬─────┬──┬─EQUAL──┬────┬─┬────────────────────> │ │ ├─NULL─────────┤ └─IS─┘ └─NOT─┘ │ └─TO─┘ │ │ │ └─NULLS────────┘ └─=─────────────┘ │ │ │ │ >──┬─identifier-2─┬──> │ │ ├─NULL─────────┤ │ │ └─NULLS────────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ---End of IBM Extension--- ═══ 12.6.1.4.3. Comparing Numeric Operands ═══ The algebraic values of numeric operands are compared.  The length (number of digits) of the operands is not significant.  Unsigned numeric operands are considered positive.  Zero is considered to be a unique value, regardless of sign.  Comparison of numeric operands is permitted, regardless of the type of USAGE specified for each. ═══ 12.6.1.4.4. Comparing Nonnumeric Operands ═══ Comparisons of nonnumeric operands are made with respect to the collating sequence of the character set in use. When the PROGRAM COLLATING SEQUENCE clause is specified in the OBJECT-COMPUTER paragraph, the collating sequence associated with the alphabet-name clause in the SPECIAL-NAMES paragraph is used. Otherwise, the native EBCDIC character set is used. The size of each operand is the total number of characters in that operand. There are two cases to consider: Operands of Equal Size Characters in corresponding positions of the two operands are compared, beginning with the leftmost character and continuing through the rightmost character. If all pairs of characters through the last pair test as equal, the operands are considered equal. If a pair of unequal characters is encountered, the characters are tested to determine their relative positions in the collating sequence. The operand containing the character higher in the sequence is considered the greater operand. Operands of Unequal Size If the operands are of unequal size, the comparison is made as though the shorter operand were extended to the right with enough spaces to make the operands equal in size. ═══ 12.6.1.4.5. Comparing Numeric and Nonnumeric Operands ═══ The nonnumeric comparison rules, discussed above, apply. In addition, when numeric and nonnumeric operands are being compared, their USAGE must be the same. In such comparisons:  The numeric operand must be described as an integer literal or data item.  Noninteger literals and data items must not be compared with nonnumeric operands. If either of the operands is a group item, the nonnumeric comparison rules, discussed above, apply. In addition to those rules:  If the nonnumeric operand is a literal or an elementary data item, the numeric operand is treated as though it were moved to an alphanumeric elementary data item of the same size, and the contents of this alphanumeric data item were then compared with the nonnumeric operand.  If the nonnumeric operand is a group item, the numeric operand is treated as though it were moved to a group item of the same size, and the contents of this group item were compared then with the nonnumeric operand. (See MOVE Statement.) ═══ 12.6.1.4.6. Comparing of Boolean Operands ═══ -----IBM Extension----- Boolean operands are used only in the [NOT] EQUAL TO relation condition. Boolean operands cannot be compared to non-Boolean operands. Boolean data items and literals must be one position in length. Two Boolean operands are equal if they both have a value of Boolean 1 or Boolean 0. ---End of IBM Extension--- ═══ 12.6.1.4.7. Comparing Index-Names and Index Data Items ═══ Comparisons involving index-names and/or index data items conform to the following rules:  The comparison of two index-names is a comparison of the corresponding occurrence numbers.  In the comparison of an index-name with a data item (other than an index data item), or in the comparison of an index-name with a literal, the occurrence number of the index-name is compared with the data item or literal.  In the comparison of an index data item with an index-name or another index data item, the actual values are compared without conversion. Results of any other comparison involving an index data item are undefined. Comparisons Involving Index Names and Index Data Items shows valid comparisons involving index-names and index data items. ┌──────────────────────────────────────────────────────────────────────────────┐ │ Comparisons Involving Index Names and Index Data Items │ ├───────────────┬───────────────┬───────────────┬───────────────┬──────────────┤ │ OPERANDS COM- │ INDEX-NAME │ INDEX DATA │ DATA-NAME │ LITERAL │ │ PARED │ │ ITEM │ │ │ ├───────────────┼───────────────┼───────────────┼───────────────┼──────────────┤ │ INDEX-NAME │ Compare │ Compare │ Compare │ Compare │ │ │ occurrence │ without con- │ occurrence │ occurrence │ │ │ number │ version │ number with │ number with │ │ │ │ │ data-name │ literal │ ├───────────────┼───────────────┼───────────────┼───────────────┼──────────────┤ │ INDEX DATA │ Compare │ Compare │ Not permitted │ Not per- │ │ ITEM │ without con- │ without con- │ │ mitted │ │ │ version │ version │ │ │ └───────────────┴───────────────┴───────────────┴───────────────┴──────────────┘ ═══ 12.6.1.5. Sign Condition ═══ The sign condition determines whether or not the algebraic value of a numeric operand is greater than, less than, or equal to zero. ┌─── SIGN CONDITION - FORMAT ──────────────────────────────────────────────────┐ │ │ │ >──operand-1──┬────┬──┬──────┬──┬─POSITIVE─┬──> │ │ └─IS─┘ └─NOT──┘ ├─NEGATIVE─┤ │ │ └─ZERO─────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.6.1.6. Switch-Status Condition ═══ The switch-status condition determines the on or off status of an UPSI switch, by testing the value associated with the condition-name. (The value associated with the condition-name is considered to be alphanumeric.) The result of the test is true if the UPSI switch is set to the value (0 or 1) corresponding to condition-name. ┌─── SWITCH-STATUS CONDITION - FORMAT ─────────────────────────────────────────┐ │ │ │ >──condition-name──> │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.6.2. Complex Conditions ═══ A complex condition is formed by combining simple conditions, combined conditions, and/or complex conditions with logical operators, or negating these conditions with logical negation. Each logical operator must be preceded and followed by a space. The following chart shows the logical operators and their meanings. ┌──────────────────────────────────────────────────────────────────────────────┐ │ Logical Operators and Their Meanings │ ├────────────┬──────────────┬──────────────────────────────────────────────────┤ │ LOGICAL │ │ │ │ OPERATOR │ NAME │ MEANING │ ├────────────┼──────────────┼──────────────────────────────────────────────────┤ │ AND │ Logical con- │ The truth value is TRUE when both conditions are │ │ │ junction │ true. │ ├────────────┼──────────────┼──────────────────────────────────────────────────┤ │ OR │ Logical │ The truth value is TRUE when either or both con- │ │ │ inclusive OR │ ditions are true. │ ├────────────┼──────────────┼──────────────────────────────────────────────────┤ │ NOT │ Logical │ Reversal of truth value (the truth value is TRUE │ │ │ negation │ if the condition is false). │ └────────────┴──────────────┴──────────────────────────────────────────────────┘ Unless modified by parentheses, the following precedence rules (from highest to lowest) apply: 1. Arithmetic operations 2. Simple conditions 3. NOT 4. AND 5. OR The truth value of a complex condition (whether parenthesized or not) is the truth value that results from the interaction of all the stated logical operators on either of the following:  The individual truth values of simple conditions  The intermediate truth values of conditions logically combined or logically negated. A complex condition can be either of the following:  A negated simple condition  A combined condition (which can be negated). ═══ 12.6.2.1. Negated Simple Conditions ═══ A simple condition is negated through the use of the logical operator NOT. The negated simple condition gives the opposite truth value of the simple condition. ┌─── NEGATED SIMPLE CONDITION - FORMAT ────────────────────────────────────────┐ │ │ │ >──NOT──simple-condition──> │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.6.2.2. Combined Conditions ═══ Two or more conditions can be logically connected to form a combined condition. ┌─── COMBINED CONDITIONS - FORMAT ─────────────────────────────────────────────┐ │ │ │ ┌──────────────────────┐ │ │  │ │ │ >──condition-1────┬─AND─┬──condition-2─┴──> │ │ └─OR──┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The condition to be combined may be any of the following:  A simple-condition  A negated simple-condition  A combined condition  A negated combined condition (that is, the NOT logical operator followed by a combined condition enclosed in parentheses)  Combinations of the preceding conditions, specified according to the rules in the following table. ┌──────────────────────────────────────────────────────────────────────────────┐ │ Combined Conditions-Permissible Element Sequences │ ├────────────┬──────────┬─────────────────────┬──────────┬─────────────────────┤ │ COMBINED │ LEFTMOST │ WHEN NOT LEFTMOST, │ RIGHT- │ WHEN NOT RIGHTMOST, │ │ CONDITION │ │ CAN BE IMMEDIATELY │ MOST │ CAN BE IMMEDIATELY │ │ ELEMENT │ │ PRECEDED BY: │ │ FOLLOWED BY: │ ├────────────┼──────────┼─────────────────────┼──────────┼─────────────────────┤ │ simple- │ Yes │ OR │ Yes │ OR │ │ condition │ │ NOT │ │ AND │ │ │ │ AND │ │ ) │ │ │ │ ( │ │ │ ├────────────┼──────────┼─────────────────────┼──────────┼─────────────────────┤ │ OR │ No │ simple-condition │ No │ simple-condition │ │ AND │ │ ) │ │ NOT │ │ │ │ │ │ ( │ ├────────────┼──────────┼─────────────────────┼──────────┼─────────────────────┤ │ NOT │ Yes │ OR │ No │ simple-condition │ │ │ │ AND │ │ ( │ │ │ │ ( │ │ │ ├────────────┼──────────┼─────────────────────┼──────────┼─────────────────────┤ │ ( │ Yes │ OR │ No │ simple-condition │ │ │ │ NOT │ │ NOT │ │ │ │ AND │ │ ( │ │ │ │ ( │ │ │ ├────────────┼──────────┼─────────────────────┼──────────┼─────────────────────┤ │ ) │ No │ simple-condition │ Yes │ OR │ │ │ │ ) │ │ AND │ │ │ │ │ │ ) │ └────────────┴──────────┴─────────────────────┴──────────┴─────────────────────┘ Parentheses are never needed when either ANDs or ORs (but not both) are used exclusively in one combined condition. However, parentheses may be needed to modify the implicit precedence rules to maintain the correct logical relation of operators and operands. There must be a one-to-one correspondence between left and right parentheses, with each left parenthesis to the left of its corresponding right parenthesis. The following table illustrates the relationships between logical operators and conditions C1 and C2. ┌──────────────────────────────────────────────────────────────────────────────┐ │ Logical Operators and Evaluation Results of Combined Conditions │ ├────────┬────────┬────┬─────────┬────────┬────────┬─────────┬────────┬────────┤ │ │ │ │ │ │ NOT │ │ │ │ │ │ │ │ │ │ (C1 │ │ NOT │ │ │ VALUE │ VALUE │ │ C1 AND │ C1 OR │ AND │ NOT C1 │ (C1 OR │ NOT C1 │ │ FOR C1 │ FOR C2 │ │ C2 │ C2 │ C2) │ AND C2 │ C2) │ OR C2 │ ├────────┼────────┼────┼─────────┼────────┼────────┼─────────┼────────┼────────┤ │ True │ True │ │ True │ True │ False │ False │ False │ True │ ├────────┼────────┼────┼─────────┼────────┼────────┼─────────┼────────┼────────┤ │ False │ True │ │ False │ True │ True │ True │ False │ True │ ├────────┼────────┼────┼─────────┼────────┼────────┼─────────┼────────┼────────┤ │ True │ False │ │ False │ True │ True │ False │ False │ False │ ├────────┼────────┼────┼─────────┼────────┼────────┼─────────┼────────┼────────┤ │ False │ False │ │ False │ False │ True │ False │ True │ True │ └────────┴────────┴────┴─────────┴────────┴────────┴─────────┴────────┴────────┘ Related Information:  Evaluating Conditional Expressions  Abbreviated Combined Relation Conditions ═══ 12.6.2.2.1. Evaluating Conditional Expressions ═══ If parentheses are used, logical evaluation of combined conditions proceeds in the following order: 1. Conditions within parentheses are evaluated first. 2. Within nested parentheses, evaluation proceeds from the least inclusive condition to the most inclusive condition. If parentheses are not used (or are not at the same level of inclusiveness), the combined condition is evaluated in the following order: 1. Arithmetic expressions. 2. Simple-conditions in the following order: a) Relation b) Class c) Condition-name d) Switch-status e) Sign. 3. Negated simple-conditions in the same order as item 2. 4. Combined conditions, in the following order: a) AND b) OR. 5. Negated combined conditions in the following order: a) AND b) OR. 6. Consecutive operands at the same evaluation-order level are evaluated from left to right. However, the truth value of a combined condition can sometimes be determined without evaluating the truth value of all the component conditions. The component conditions of a combined condition are evaluated from left to right. If the truth value of one condition is not affected by the evaluation of further elements of the combined condition, these elements are not evaluated. However, the truth value of the condition will always be the same (as if the condition had been evaluated in full), as described earlier in this paragraph. For example: NOT A IS GREATER THAN B OR A + B IS EQUAL TO C AND D IS POSITIVE is evaluated as if parenthesized as follows: (NOT (A IS GREATER THAN B)) OR (((A+B) IS EQUAL TO C) AND (D IS POSITIVE)) The order of evaluation in this example is as follows: 1. (NOT (A IS GREATER THAN B)) is evaluated. If true, the rest of the condition is not evaluated, as the expression is true. 2. (A+B) is evaluated, giving some intermediate result, x. 3. (x IS EQUAL TO C) is evaluated. If false, the rest of the condition is not evaluated, as the expression is false. 4. (D IS POSITIVE) is evaluated, giving the final truth value of the expression. ═══ 12.6.2.3. Abbreviated Combined Relation Conditions ═══ When relation-conditions are written consecutively without intervening parentheses, any relation-condition after the first can be abbreviated in one of two ways:  Omission of the subject  Omission of the subject and relational operator. ┌─── ABBREVIATED COMBINED RELATION CONDITIONS - FORMAT ────────────────────────┐ │ │ │ >──relation-condition──────────────────────────────────────────────────────> │ │ │ │ ┌─────────────────────────────────────────────────────────────┐ │ │  │ │ │ >────┬─AND─┬──┬────┬──┬────────┬──┬──────────────────────┬─object┴──> │ │ └─OR──┘ └─IS─┘ │ (1)│ ├─GREATER─┬──────┬─────┤ │ │ └─NOT────┘ │ └─THAN─┘ │ │ │ ├─>────────────────────┤ │ │ ├─LESS──┬──────┬───────┤ │ │ │ └─THAN─┘ │ │ │ ├─┐────────────────────┤ │ │ ├─EQUAL──┬────┬────────┤ │ │ │ └─TO─┘ │ │ │ ├─=────────────────────┤ │ │ ├─┤ greater or equal ├─┤ │ │ ├─>=─────────────────┴─┤ │ │ ├─┤ less or equal ├────┤ │ │ └─┐=──────────────┴────┘ │ │ │ │ GREATER OR EQUAL: │ │ ├──GREATER──┬──────┬──OR EQUAL──┬────┬──┤ │ │ └─THAN─┘ └─TO─┘ │ │ │ │ LESS OR EQUAL: │ │ ├──LESS──┬──────┬──OR EQUAL──┬────┬──┤ │ │ └─THAN─┘ └─TO─┘ │ │ │ │ NOTE: │ │ (1) NOT GREATER THAN OR EQUAL TO, NOT >=, NOT LESS THAN OR EQUAL TO, and │ │ NOT <=, are IBM Extensions. │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ An object is any data item or expression that can be compared to the subject of the preceding relation condition. In any consecutive sequence of relation-conditions, both forms of abbreviation can be specified. The abbreviated condition is evaluated as if: 1. The last stated subject is the missing subject. 2. The last stated relational operator is the missing relational operator. The resulting combined condition must comply with the rules for element sequence in combined conditions, as shown in Abbreviated Combined Relation Conditions. The word NOT is considered part of the relational operator in the forms NOT GREATER THAN, NOT >, NOT LESS THAN, NOT <, NOT EQUAL TO, and NOT =. NOT in any other position is considered a logical operator (and thus results in a negated relation-condition). The following examples illustrate abbreviated combined relation conditions, with and without parentheses, and their unabbreviated equivalents. ┌──────────────────────────────────────────────────────────────────────────────┐ │ Abbreviated Combined Relation Conditions │ ├───────────────────────────────────────┬──────────────────────────────────────┤ │ ABBREVIATED COMBINED RELATION CONDI- │ EQUIVALENT │ │ TION │ │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ A = B AND NOT < C OR D │ ((A = B) AND (A NOT < C)) OR (A NOT │ │ │ < D) │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ A NOT > B OR C │ (A NOT > B) OR (A NOT > C) │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ NOT A = B OR C │ (NOT (A = B)) OR (A = C) │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ NOT (A = B OR < C) │ NOT ((A = 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)))) │ └───────────────────────────────────────┴──────────────────────────────────────┘ ═══ 12.7. Statement Categories ═══ There are four categories of COBOL statements:  Imperative  Conditional  Delimited scope  Compiler directing. ═══ 12.7.1. Imperative Statements ═══ An imperative statement either specifies an unconditional action to be taken by the program, or is a conditional statement terminated by its explicit scope terminator (see Delimited Scope Statements). A series of imperative statements can be specified whenever an imperative statement is allowed. ═══ 12.7.2. Conditional Statements ═══ A conditional statement specifies that the truth value of a condition is to be determined, and that the subsequent action of the object program is dependent on this truth value. (See Conditional Expressions.) ═══ 12.7.3. Delimited Scope Statements ═══ A delimited scope statement uses an explicit scope terminator to turn a conditional statement into an imperative statement; the resulting imperative statement can then be nested. Explicit scope terminators may also be used to terminate the scope of an imperative statement. Explicit scope terminators are provided for all COBOL verbs that may have conditional phrases. Unless explicitly specified otherwise, a delimited scope statement may be specified wherever an imperative statement is allowed by the rules of the language. Related Information:  Explicit Scope Terminators  Implicit Scope Terminators. ═══ 12.7.3.1. Explicit Scope Terminators ═══ An explicit scope terminator marks the end of certain Procedure Division statements. A conditional statement that is delimited by its explicit scope terminator is considered an imperative statement and must follow the rules for imperative statements. ═══ 12.7.3.2. Implicit Scope Terminators ═══ The separator period at the end of any sentence is an implicit scope terminator that terminates the scope of any previous statement that is not yet terminated. When a statement is contained within another statement, the next phrase of the containing statement following the contained statement is an implicit scope terminator that ends the scope of the contained statement. A conditional statement not terminated by its scope terminator cannot be contained within another statement. Except for nesting conditional statements within IF statements, nested statements must be imperative statements, and must follow the rules for imperative statements. You should not nest conditional statements. ═══ 12.8. Statement Operations ═══ COBOL statements perform the following types of operations:  Arithmetic  Data manipulation  Input/output  Ordering  Subprogram linkage  Table handling  Procedure branching ═══ 12.8.1. CORRESPONDING Phrase ═══ The CORRESPONDING phrase (CORR) allows ADD, SUBTRACT, and MOVE operations to be performed on elementary data items of the same name if the group items to which they belong are specified. Both identifiers following the keyword CORRESPONDING must be group items. In this discussion, these identifiers are referred to as identifier-1 and identifier-2. A pair of data items (subordinate items), one from identifier-1 and one from identifier-2, correspond if the following conditions are true:  In an ADD or SUBTRACT statement, both of the data items are elementary numeric data items. Other data items are ignored.  In a MOVE statement, at least one of the data items is an elementary item, and the move is permitted by the move rules.  The two subordinate items have the same name and the same qualifiers up to but not including identifier-1 and identifier-2.  The subordinate items are not identified by the keyword FILLER.  Neither identifier-1 nor identifier-2 is described as a level 66, 77, or 88 item, nor is the usage of either item INDEX, POINTER, or PROCEDURE-POINTER. Neither identifier-1 nor identifier-2 can be reference modified. The name of the data item must be unique after application of the implied qualifiers.  The subordinate items do not include a REDEFINES, RENAMES, OCCURS, USAGE IS INDEX, USAGE IS POINTER, or USAGE IS PROCEDURE-POINTER clause in their descriptions; if such a subordinate item is a group, the items subordinate to it are also ignored. However, identifier-1 and identifier-2 themselves may contain or be subordinate to items containing a REDEFINES or OCCURS clause in their descriptions.  Identifier-1 and identifier-2 can be subordinate to a FILLER item. For example, if two data hierarchies are defined as follows: 05 ITEM-1 OCCURS 6 INDEXED BY X. 10 ITEM-A PIC S9(3). 10 ITEM-B PIC 99V9. 10 ITEM-C PIC X(4). 10 ITEM-D REDEFINES ITEM-C PIC 9(4). 10 ITEM-E PIC 9(4) USAGE COMP. 10 ITEM-F USAGE INDEX. 10 ITEM-G PIC X(4). 05 ITEM-2. 10 ITEM-A PIC 99. 10 ITEM-B PIC 9V9. 10 ITEM-C PIC A(4). 10 ITEM-D PIC 9(4). 10 ITEM-E PIC 9(9) USAGE COMP. 10 ITEM-F USAGE INDEX. 10 ITEM-G PIC X(4). Then, if ADD CORR ITEM-2 TO ITEM-1(X) is specified, - ITEM-A and ITEM-A(X); ITEM-B and ITEM-B(X); ITEM-E and ITEM-E(X) are considered to be corresponding and are added together - ITEM-C and ITEM-C(X); ITEM-G and ITEM-G(X) are not included, because they are not numeric - ITEM-D and ITEM-D(X) are not included, because ITEM-D(X) includes a REDEFINES clause in its data description. - ITEM-F and ITEM-F(X) are not included, because they are defined as USAGE IS INDEX ═══ 12.8.2. GIVING Phrase ═══ The data item referenced by the identifier that follows the word GIVING is set to the calculated result of the arithmetic operation. Because this identifier is not involved in the computation, it may be a numeric edited item. ═══ 12.8.3. ROUNDED Phrase ═══ After decimal point alignment, the number of places in the fraction of the result of an arithmetic operation is compared with the number of places provided for the fraction of the resultant identifier. When the size of the fractional result exceeds the number of places provided for its storage, truncation occurs unless ROUNDED is specified. When ROUNDED is specified, the least significant digit of the resultant identifier is increased by 1 whenever the most significant digit of the excess is greater than or equal to 5. When the resultant identifier is described by a PICTURE clause containing rightmost Ps, and when the number of places in the calculated result exceeds the number of integer positions specified, rounding or truncation occurs, relative to the rightmost integer position for which storage is allocated. ═══ 12.8.4. SIZE ERROR Phrases ═══ ┌─── SIZE ERROR PHRASE - FORMAT ───────────────────────────────────────────────┐ │ │ │ >>──┬────┬──SIZE ERROR──imperative-statement-1──>< │ │ └─ON─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ A size error condition can occur in three different ways:  When the absolute value of the result of an arithmetic evaluation, after decimal point alignment, exceeds the largest value that can be contained in the result field  When division by zero occurs  In an exponential expression, when - Zero is raised to the exponent zero - Zero is raised to a negative exponent - A negative number is raised to a fractional exponent The size error condition applies only to final results, not to any intermediate results. If the resultant identifier is defined with USAGE IS BINARY, the largest value that can be contained in it is the maximum value implied by its associated decimal PICTURE character-string. If the ROUNDED phrase is specified, rounding takes place before size error checking. When a size error occurs, the subsequent action of the program depends on whether or not the ON SIZE ERROR phrase is specified. If the ON SIZE ERROR phrase is specified and a size error condition occurs, the value of the resultant identifier affected by the size error is not altered-that is, the error results are not placed in the receiving identifier. Values of other resultant identifiers are not affected, as long as no size error occurred for them. After completion of the execution of the arithmetic operation, the imperative statement in the ON SIZE ERROR phrase is executed. If no explicit transfer of control is executed upon completion of the imperative statement specified in the ON SIZE ERROR phrase, control is transferred to the end of the arithmetic statement and the NOT ON SIZE ERROR phrase, if specified, is ignored. If the ON SIZE ERROR phrase is not specified and a size error condition exists after the execution of the arithmetic operations specified by an arithmetic statement, the value of the affected resultant identifier is undefined. Values of other resultant identifiers are not affected, as long as no size error occurred for them. After completion of the arithmetic operations, control is transferred to the end of the arithmetic statement and the NOT ON SIZE ERROR phrase, if specified, is ignored. For ADD CORRESPONDING and SUBTRACT CORRESPONDING statements, if an individual arithmetic operation causes a size error condition, the ON SIZE ERROR imperative statement is not executed until all the individual additions or subtractions have been completed. When both ON SIZE ERROR and NOT ON SIZE ERROR phrases are specified, and the statement in the phrase that is executed does not contain any explicit transfer of control, then, if necessary, an implicit transfer of control is made after execution of the phrase to the end of the arithmetic statement. ═══ 12.8.5. NOT ON SIZE ERROR ═══ If the NOT ON SIZE ERROR phrase has been specified and, after execution of an arithmetic operation, a size error condition does not exist, the NOT ON SIZE ERROR phrase is executed. When both ON SIZE ERROR and NOT ON SIZE ERROR phrases are specified, and the statement in the phrase that is executed does not contain any explicit transfer of control, then, if necessary, an implicit transfer of control is made after execution of the phrase to the end of the arithmetic statement. ═══ 12.8.6. Overlapping Operands ═══ When a sending and a receiving item in any statement share a part or all of their storage areas, yet are not defined by the same data description entry, the result of the execution of such a statement is undefined. In addition, the results are undefined for some statements in which sending and receiving items are defined by the same data description entry. These cases are addressed in the general rules associated with those statements. The result of the execution of such a statement is unpredictable. ═══ 12.8.7. Arithmetic Statements ═══ The arithmetic statements are used for computations. Individual operations are specified by the ADD, SUBTRACT, MULTIPLY, and DIVIDE statements. These operations can be combined symbolically in a formula, using the COMPUTE statement. The data description of operands in an arithmetic statement need not be the same. Throughout the calculation, the compiler performs any necessary data conversion and decimal point alignment. Related Information:  Size of Operands  Overlapping Operands  Multiple Results ═══ 12.8.7.1. Size of Operands ═══ The maximum size of each operand is 18 decimal digits. The composite of operands is a hypothetical data item resulting from aligning the operands at the decimal point and then superimposing them on one another. -----IBM Extension----- The composite of operands must not contain more than 30 decimal digits. ---End of IBM Extension--- For example, assume that each item is defined as follows in the Data Division: A PICTURE 9(7)V9(5). B PICTURE 9(11)V99. C PICTURE 9(12)V9(3). If the following statement is executed, the composite of operands consists of 17 decimal digits: ADD A B TO C It has the following implicit description: Composite-of-Operands PICTURE 9(12)V9(5). In the ADD and SUBTRACT statements, if the composite of operands is 18 digits or less, the compiler ensures that enough places are carried so that no significant digits are lost during execution. The following list shows how the composite of operands is determined for arithmetic statements: Statement Determination of the Composite of Operands ADD Superimposing all operands in a given statement (except those following the word GIVING) COMPUTE Restriction does not apply DIVIDE Superimposing all receiving data items, except the REMAINDER data item MULTIPLY Superimposing all receiving data items SUBTRACT Superimposing all operands in a given statement (except those following the word GIVING) In all arithmetic statements, it is important to define data with enough digits and decimal places to ensure the desired accuracy in the final result. ═══ 12.8.7.2. Multiple Results ═══ When an arithmetic statement has multiple results, execution conceptually proceeds as follows:  The statement performs all arithmetic operations to find the result to be placed in the receiving items, and stores that result in a temporary location.  A sequence of statements transfers or combines the value of this temporary result with each single receiving field. The statements are considered to be written in the same left-to-right order as the multiple results are listed. For example, executing the following statement: ADD A, B, C, TO C, D(C), E. is equivalent to executing the following series of statements: ADD A, B, C GIVING TEMP. ADD TEMP TO C. ADD TEMP TO D(C). ADD TEMP TO E. In the above example, TEMP is a compiler-supplied temporary result field. When the addition operation for D(C) is performed, the subscript C contains the new value of C. Note: Intermediate results generated during the execution of arithmetic statements are system-specific and can affect program portability. Use of the individual arithmetic statements ADD, SUBTRACT, MULTIPLY, and DIVIDE, rather than COMPUTE, reduces the risk of getting inconsistent results. ═══ 12.8.8. Data Manipulation Statements ═══ The following COBOL statements move and inspect data: ACCEPT, INITIALIZE, INSPECT, MOVE, READ, RELEASE, RETURN, REWRITE, SET, STRING, UNSTRING, and WRITE. Overlapping Operands When the sending and receiving fields of a data manipulation statement share a part of their storage (that is, when the operands overlap), the result of the execution of such a statement is unpredictable. ═══ 12.8.9. Input-Output Statements ═══ COBOL input-output statements transfer data to and from files stored on external media, and also control low-volume data that is obtained from or sent to an input/output device. In COBOL, the unit of file data made available to the program is a record, and you need only be concerned with such records. Provision is automatically made for such operations as the movement of data into buffers and/or internal storage, validity checking, error correction (where feasible), blocking and deblocking, and volume switching procedures. The description of the file in the Environment Division and Data Division governs which input-output statements are allowed in the Procedure Division. Related Information  Common Processing Facilities ═══ 12.8.9.1. Common Processing Facilities ═══ There are several common processing facilities that apply to more than one input-output statement. The common processing facilities provided are:  Status key  INVALID KEY condition  INTO/FROM identifier phrase  File position indicator. ═══ 12.8.9.1.1. Status Key ═══ If the FILE STATUS clause is specified in the FILE-CONTROL entry, a value is placed in the specified status key (the 2-character data item named in the FILE STATUS clause) during execution of any request on that file; the value indicates the status of that request. The value is placed in the status key before execution of any EXCEPTION/ERROR declarative or INVALID KEY/AT END phrase associated with the request. The first character of the status key is known as status key 1 (high order digit); the second character is known as status key 2 (low order digit). ═══ 12.8.9.1.2. INVALID KEY Condition ═══ The invalid key condition can occur during execution of a START, READ, WRITE, REWRITE, or DELETE statement. When an invalid key condition occurs, the input-output statement that caused the condition is unsuccessful. When the invalid key condition exists after an input-output operation, the following actions are taken: 1. If there is an applicable file status clause (but not an applicable USE procedure), the file status is updated, and control returns to the program. 2. Control will be transferred to the imperative statement of an INVALID KEY phrase, if specified. 3. If an explicit or implicit EXCEPTION/ERROR procedure is specified for the file, the procedure runs; if no such procedure is specified, the results are unpredictable. 4. In the absence of a file status clause, USE procedure, or INVALID KEY phrase to handle the error, a run-time message is issued, giving you the option to end or return to the program. When the invalid key condition does not exist after an input-output operation, the INVALID KEY phrase is ignored, if specified, and the following actions are taken: 1. If an exception condition that is not an invalid key condition exists, control is transferred according to the rules of the USE statement following the running of any USE AFTER EXCEPTION procedure. 2. If no exception condition exists, control is transferred to the end of the input-output statement or the imperative statement specified in the NOT INVALID KEY phrase, if it is specified. ═══ 12.8.9.1.3. INTO/FROM Identifier Phrase ═══ This phrase is valid for READ, RETURN, RELEASE, REWRITE, and WRITE statements. The identifier specified must be the name of an entry in the Working-Storage Section or the Linkage Section, or of a record description for another previously opened file. Record-name, identifier must not refer to the same storage area. ┌─── INTO/FROM IDENTIFIER PHRASE - FORMAT ─────────────────────────────────────┐ │ │ │ >>──┬─┬─READ───┬──file-name-1──┬────────┬──┬────────────────────┬─┬──>< │ │ │ └─RETURN─┘ └─RECORD─┘ └─INTO──identifier-1─┘ │ │ │ └─┬─RELEASE─┬──record-name-1──┬────────────────────┬──────────┘ │ │ ├─REWRITE─┤ └─FROM──identifier-1─┘ │ │ └─WRITE───┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The result of the execution of a READ or RETURN statement with the INTO phrase is equivalent to the application of the following rules in the order specified: 1. The execution of the same READ or RETURN statement without the INTO phrase. 2. The current record is moved from the record area to identifier-1 according to the rules for the MOVE statement without the CORRESPONDING phrase. The size of the current record is determined by rules specified in the RECORD clause. If the file description entry contains a RECORD IS VARYING clause, the implied move is a group move. The implied MOVE statement does not occur if the execution of the READ or RETURN statement was unsuccessful. Any subscripting or reference modification associated with identifier-1 is evaluated after the record has been read or returned and immediately before it is moved to the data item. The record is available both in the record area and in identifier-1. The result of the execution of a RELEASE, REWRITE, or WRITE statement with the FROM phrase is equivalent to the execution of the following statements in the order specified: 1. The statement MOVE identifier-1 TO record-name-1 according to the rules specified for the MOVE statement. 2. The same RELEASE, REWRITE, or WRITE statement without the FROM phrase. After the execution of the RELEASE, REWRITE or WRITE statement is complete, the information in identifier-1 is available, but the information in record-name-1 is not available, except as specified by the SAME RECORD AREA clause. ═══ 12.8.9.1.4. File Position Indicator ═══ The file position indicator is a conceptual entity used in this document to facilitate exact specification of the next record to be accessed within a given file during certain sequences of input-output operations. The concept of a file position indicator has no meaning for a file opened in the output or extend mode. The setting of the file position indicator is affected only by the OPEN, READ, RETURN, ROLLBACK and START statements as follows:  The OPEN statement positions the file position indicator to the first record in the file. -----IBM Extension----- The file position indicator can be positioned to any record in the file by using the POSITION parameter of the Override with database file (OVRDBF) command. ---End of IBM Extension---  For a sequential access READ statement, or a dynamic access READ NEXT statement, the following considerations apply: - If an OPEN or START statement positioned the file position indicator, the record identified by the file position indicator is made available. If this record no longer exists, the next existing record is made available. - If a previous READ statement positioned the file position indicator, the file position indicator is updated to point to the next existing record in the file; that record is then made available. -----IBM Extension-----  For a dynamic access READ FIRST statement, the file position indicator is positioned to point to the first record in the file; that record is then made available.  For a dynamic access READ LAST statement, the file position indicator is positioned to point to the last record in the file; that record is then made available.  For a dynamic access READ PRIOR statement, the file position indicator is positioned to point to the previous existing record in the file; that record is then made available. ---End of IBM Extension---  For the RETURN statement, the following considerations apply: - The first RETURN statement positions the file position indicator to the first record in the file, and that record is then made available. - If a previous RETURN statement positioned the file position indicator, the file position indicator is updated to point to the next existing record in the file, and the record is then made available. -----IBM Extension-----  For the ROLLBACK statement, the following considerations apply to any file under commitment control: - The ROLLBACK statement sets the file position indicator to the pointer's position at the previous commitment boundary. This is important to remember if you are doing sequential processing. - The file position indicator is set to the pointer's position at the OPEN if no COMMIT statement has been issued since the file was opened. - The file position indicator is undefined for any file under commitment control that is not open. ---End of IBM Extension---  The START statement positions the file position indicator to the first record in the file that satisfies the implicit or explicit comparison specified in the START statement. The concept of the file position indicator has no meaning for files with an access mode of random or for TRANSACTION files. ═══ 12.8.9.2. DB-FORMAT-NAME Special Register ═══ -----IBM Extension----- After the execution of an input/output statement, for a FORMATFILE or DATABASE file, the DB-FORMAT-NAME special register is modified according to the following rules:  After completion of a successful READ, WRITE, REWRITE, START, or DELETE operation, the record format name used in the I-O operation is implicitly moved to the special register.  After an unsuccessful input/output operation, DB-FORMAT-NAME contains the record format name used in the last successful input/output operation.  DB-FORMAT-NAME is implicitly defined as PICTURE X(10) and GLOBAL in the outermost program. ---End of IBM Extension--- ═══ 12.8.10. Procedure Branching Statements ═══ Statements, sentences, and paragraphs in the Procedure Division are executed sequentially, except when a procedure-branching statement (listed below) is used.  ALTER  EXIT  GO TO  PERFORM ═══ 12.9. ACCEPT Statement ═══ The ACCEPT statement transfers data into the specified identifier. There is no editing or error checking of the incoming data. The ACCEPT statement has seven formats:  Format 1 - Data Transfer  Format 2 - System Information Transfer -----IBM Extension-----  Format 3 - Feedback  Format 4 - Local Data Area  Format 5 - PIP Data Area  Format 6 - Attribute Data Area  Format 7 - Workstation I/O  Format 8 - Session I/O ---End of IBM Extension--- ═══ 12.9.1. Data Transfer ═══ ┌─── ACCEPT STATEMENT - FORMAT 1 - DATA TRANSFER ──────────────────────────────┐ │ │ │ >>──ACCEPT──identifier-1──┬───────────────────────────────┬──>< │ │ └─FROM──┬─mnemonic-name───────┬─┘ │ │ │ (1)│ │ │ └─environment-name────┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Format 1 transfers data from an input/output device into identifier-1. No conversion is made to this data. The incoming data is received in USAGE IS DISPLAY format. Format 1 is useful for exception situations in a program when operator intervention (to supply a given message, code, or exception indicator) is required. The operator must, of course, be supplied with the appropriate messages with which to reply. When the FROM phrase is omitted, the ACCEPT statement obtains input from the job input stream for batch jobs, and from the workstation for interactive jobs. The job input stream consists of data that accompanies a CL command. If there is no data in the input stream, an exception occurs. Related Information:  Coding Example ═══ 12.9.2. Coding Example ═══ The following is an example of a batch job file member that contains a job input stream: //BCHJOB JOB(ADD021) JOBD(QUSER/ACCTEST) CALL PGM(QSYS/ACCPT1X) 123456789012345 //ENDBCHJOB The following is an example of a COBOL program that uses a Format 1 ACCEPT statement to read the job input stream: IDENTIFICATION DIVISION. PROGRAM-ID. ACCPT1X. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. IBM-AS400. OBJECT-COMPUTER. IBM-AS400. DATA DIVISION. WORKING-STORAGE SECTION. 77 TRANS-DATA PIC X(15). PROCEDURE DIVISION. BEGIN. ACCEPT TRANS-DATA. DISPLAY TRANS-DATA. STOP RUN. When the batch job file member is used to call ACCPT1X, the ACCEPT statement reads the batch job file member from the line that immediately follows the CALL command. This causes "123456789012345" to be accepted into TRANS-DATA. ═══ 12.9.3. mnemonic-name ═══ Must be associated with an input/output device that is specified in the SPECIAL-NAMES paragraph. The input/output device can be the workstation (REQUESTOR) or the system operator's message queue (CONSOLE or SYSTEM-CONSOLE). If mnemonic-name is associated with REQUESTOR and the job is a batch job, the job input stream is used. ═══ 12.9.4. Job Input Stream ═══ When the input is from the job input stream, the following rules apply:  An input record size of 80 characters is assumed.  If identifier-1 is up to 80 characters in length, the input data must appear as the first character within the input record. Any characters beyond the length of identifier-1 are truncated.  If identifier-1 is longer than 80 characters, succeeding input records are read until the storage area of identifier-1 is filled. If the length of identifier-1 is not an exact multiple of 80 characters, the last input record is truncated. ═══ 12.9.5. Work Station or System Operator's Message Queue ═══ When the device is the workstation, the input record size is 62. When the device is the system operator's message queue, the input record size is 58. The following steps occur: 1. A system-generated inquiry message containing the program-name, the text "AWAITING REPLY FOR POSITION(S)", and the beginning and ending positions is automatically sent to the system operator's message queue or workstation operator. Previous DISPLAYs can also appear on the ACCEPT screen. 2. Processing is suspended. 3. The reply is moved into identifier-1, and processing is resumed after a reply is made by the operator to the inquiry in step 1. The reply value is made available to the program as it was typed, in uppercase or lowercase. 4. If identifier-1 is longer than the input record size, succeeding input records are read (steps 1-3) until identifier-1 is filled. ═══ 12.9.6. System Information Transfer ═══ System information contained in the specified conceptual data items DATE, DAY, DAY-OF-WEEK, or TIME can be transferred into the identifier. DATE, DAY, DAY-OF-WEEK, and TIME are conceptual data items and, therefore, are not described in the COBOL program. The transfer must follow the rules for the MOVE statement without the CORRESPONDING phrase. See MOVE Statement. ┌─── ACCEPT STATEMENT - FORMAT 2 - SYSTEM INFO TRANSFER ───────────────────────┐ │ │ │ >>──ACCEPT──identifier-1──FROM──┬─DATE────────┬──>< │ │ ├─DAY─────────┤ │ │ ├─DAY-OF-WEEK─┤ │ │ └─TIME────────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Format 2 accesses the current date and time of day, as carried by the system. This can be useful in identifying when a particular run of an object program was executed. It can also be used to supply the date in headings and footings. ═══ 12.9.7. Feedback ═══ -----IBM Extension----- This format is used to transfer feedback information from an active file to the identifier. ┌─── ACCEPT STATEMENT - FORMAT 3 - FEEDBACK ───────────────────────────────────┐ │ │ │ >>──ACCEPT──identifier-1──FROM──mnemonic-name──┬───────────────────┬──>< │ │ └─FOR───file-name-1─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ---End of IBM Extension--- ═══ 12.9.8. Local Data Area ═══ -----IBM Extension----- This format is used to transfer data to identifier-1 from the system-defined local data area created for a job. ┌─── ACCEPT STATEMENT - FORMAT 4 - LOCAL DATA AREA ────────────────────────────┐ │ │ │ >>──ACCEPT──identifier-1──FROM──mnemonic-name──────────────────────────────> │ │ │ │ >──┬───────────────────────────┬──>< │ │ │ (1) │ │ │ └─FOR──────┬─identifier-2─┬─┘ │ │ └─literal-1────┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The move into identifier-1 takes place according to the rules for the MOVE statement for a group move without the CORRESPONDING phrase. ---End of IBM Extension--- ═══ 12.9.9. Program Initialization Parameters ═══ -----IBM Extension----- You use this format to transfer data from the PIP (Program Initialization Parameters) data area into the identifier. ┌─── ACCEPT STATEMENT - FORMAT 5 - PIP DATA AREA ──────────────────────────────┐ │ │ │ >>──ACCEPT──identifier-1──FROM──mnemonic-name──────────────────────────────> │ │ │ │ >──┬─────────────────────────────────────────────┬─────────────────────────> │ │ └─┬──────┬──EXCEPTION──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬───────────────────────────────────────────────────┬───────────────────> │ │ └─NOT───┬──────┬──EXCEPTION──imperative-statement-2─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────┬──>< │ │ └─END-ACCEPT─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Note that you cannot update the PIP data area using COBOL. ---End of IBM Extension--- ═══ 12.9.10. Attribute Data ═══ -----IBM Extension----- The ACCEPT statement retrieves information (attribute data) about a particular program device associated with a TRANSACTION file. ┌─── ACCEPT STATEMENT - FORMAT 6 - ATTRIBUTE DATA ─────────────────────────────┐ │ │ │ >>──ACCEPT──identifier-1──FROM──mnemonic-name──────────────────────────────> │ │ │ │ >──┬─────────────────────────────────────────────┬──>< │ │ └─FOR──┬─identifier-2─┬──┬──────────────────┬─┘ │ │ └─literal-1────┘ └─FOR──file-name-1─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ This format of the ACCEPT statement may only be used for files with an organization of TRANSACTION. If file-name-1 is not open at the time the ACCEPT is executed, message LNR7205 is issued. Program device attributes are moved into identifier-1 from the appropriate attribute data format, according to the rules for a group MOVE without the CORRESPONDING phrase. ---End of IBM Extension--- ═══ 12.9.11. Workstation I/O ═══ -----IBM Extension----- An ACCEPT statement is considered an extended ACCEPT statement if it:  has an AT phrase, or  has a FROM phrase with the CRT option, or  has a MODE IS BLOCK phrase, or  has a WITH phrase, or  has an ON EXCEPTION phrase or a NOT ON EXCEPTION phrase, (and PIP-DATA is not specified for mnemonic-name), or  does not have a FROM phrase, but CONSOLE IS CRT is specified in the SPECIAL-NAMES paragraph. An ACCEPT statement is considered a standard ACCEPT statement if it:  has a FROM phrase (other than FROM CRT) and CONSOLE IS CRT is specified in the SPECIAL-NAMES paragraph, or  does not have a FROM phrase and CONSOLE IS CRT is not specified. ┌─── ACCEPT STATEMENT - FORMAT 7 - WORKSTATION I/O ────────────────────────────┐ │ │ │ ┌──────────────────────────┐ │ │  │ │ │ >>──ACCEPT──identifier-1───┬────────────────────────┬┴─────────────────────> │ │ ├─┤ line-column-phrase ├─┤ │ │ ├─FROM CRT─────────────┴─┤ │ │ ├─MODE─┬──────┬─BLOCK────┤ │ │ │ └─IS───┘ │ │ │ └─┤ with-phrase ├────────┘ │ │ │ │ >──┬─────────────────────────────────────────────┬─────────────────────────> │ │ └─┬──────┬──EXCEPTION──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬───────────────────────────────────────────────────┬───────────────────> │ │ └─NOT───┬──────┬──EXCEPTION──imperative-statement-2─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────┬──>< │ │ └─END-ACCEPT─┘ │ │ │ │ LINE-COLUMN-PHRASE: │ │ ┌──────────────────────────────────────────┐ │ │  │ │ │ ├──┬──┬──────┬────┬─LINE───┬──┬────────┬──┬─identifier-2─┬─┴──┬──┤ │ │ │ └─AT───┘ ├─COLUMN─┤ └─NUMBER─┘ └─integer-1────┘ │ │ │ │ └─COL────┘ │ │ │ └─AT───┬─identifier-3─┬────────────────────────────────────┘ │ │ └─integer-2────┘ │ │ │ │ WITH-PHRASE: │ │ ┌───────────────────────────────────────────────────┐ │ │  │ │ │ ├──WITH───┬─┬─AUTO──────┬───────────────────────────────────┬┴──┤ │ │ │ └─AUTO-SKIP─┘ │ │ │ ├─┬─BELL─┬────────────────────────────────────────┤ │ │ │ └─BEEP─┘ │ │ │ ├─BLINK───────────────────────────────────────────┤ │ │ ├─┬─FULL─────────┬────────────────────────────────┤ │ │ │ └─LENGTH-CHECK─┘ │ │ │ ├─HIGHLIGHT───────────────────────────────────────┤ │ │ ├─┬─REQUIRED────┬─────────────────────────────────┤ │ │ │ └─EMPTY-CHECK─┘ │ │ │ ├─REVERSE-VIDEO───────────────────────────────────┤ │ │ ├─┬─SECURE──┬─────────────────────────────────────┤ │ │ │ └─NO-ECHO─┘ │ │ │ ├─UNDERLINE───────────────────────────────────────┤ │ │ ├─RIGHT-JUSTIFY───────────────────────────────────┤ │ │ ├─SPACE-FILL──────────────────────────────────────┤ │ │ ├─TRAILING-SIGN───────────────────────────────────┤ │ │ ├─UPDATE──────────────────────────────────────────┤ │ │ ├─ZERO-FILL───────────────────────────────────────┤ │ │ ├─SIZE─┬────┬──┬─identifier-4─┬───────────────────┤ │ │ │ └─IS─┘ └─integer-3────┘ │ │ │ │ (1) │ │ │ ├─PROMPT────┬────────────────┬──┬─identifier-5─┬──┤ │ │ │ └─CHARACTER IS───┘ └─literal-1────┘ │ │ │ │ (1) │ │ │ ├──┬─FOREGROUND-COLOR──┬──────┬────┬─integer-4────┤ │ │ │ └─FOREGROUND-COLOUR─┘ └─IS─┘ │ │ │ │ (1) │ │ │ ├──┬─BACKGROUND-COLOR──┬──────┬────┬─integer-5────┤ │ │ │ └─BACKGROUND-COLOUR─┘ └─IS─┘ │ │ │ │ (1) │ │ │ └─LEFT-JUSTIFY────────────────────────────────────┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ---End of IBM Extension--- ═══ 12.9.12. AT Phrase ═══ -----IBM Extension----- The AT phrase indicates the absolute address on the screen at which the ACCEPT operation is to start. If the AT phrase is not specified, the ACCEPT operation starts at line 1, column 2. It does not indicate the starting position of the leading attribute. Related Information:  Line and Column Combinations ---End of IBM Extension--- ═══ 12.9.13. Line and Column Combinations ═══ -----IBM Extension----- Certain combinations of line and column numbers have special meaning:  Until the column comes within range, out of range column values are reduced by the line length and the line value is incremented. A column number may cause the line number to be incremented several times.  Out of range line values cause the screen to scroll up one line. The effect is the same as if the line number of the bottom line had been specified. The screen is never scrolled more than one line up regardless of the line specified.  If column and line numbers are both out of range, out of range columns are handled first followed by out of range lines (according to rules above).  If the line and column numbers given are both zero, the ACCEPT starts at the position following that where the preceding ACCEPT operation finished. Column 1 of each line is considered to follow the last column of the previous line.  If the line number is zero, but a non-zero column number is specified, the ACCEPT starts at the specified column, on the line following that where the preceding display operation finished.  If the column number is zero, but a non-zero line number is specified, the ACCEPT starts on the specified line, at the column following that where the preceding display operation finished. ---End of IBM Extension--- ═══ 12.9.14. Session I/O ═══ -----IBM Extension----- The ACCEPT statement retrieves information from the ILE common session manager. ┌─── ACCEPT STATEMENT - FORMAT 8 - SESSION I/O ────────────────────────────────┐ │ │ │ >>──ACCEPT──identifier──┬───────────────────┬──>< │ │ └─FROM────DISPLAY───┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ For this format of the ACCEPT statement the FROM phrase is optional if the CONSOLE IS DISPLAY clause is specified in the SPECIAL-NAMES paragraph. Format 8 transfers data from the ILE common session manager into identifier-1. No conversion is made to this data. The incoming data is received in USAGE IS DISPLAY format. The ILE common session manager is used to manage the ACCEPT statement. For further information on the screen I/O session services, refer to the "Dynamic Screen Manager" section in the System API Reference. ---End of IBM Extension--- ═══ 12.10. ACQUIRE Statement ═══ -----IBM Extension----- The ACQUIRE statement acquires a program device for a TRANSACTION file. ┌─── ACQUIRE STATEMENT - FORMAT - TRANSACTION ─────────────────────────────────┐ │ │ │ >>──ACQUIRE──┬─identifier─┬──FOR──file-name──>< │ │ └─literal────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Successful completion of the ACQUIRE operation makes the program device available for input and output operations. If the ACQUIRE is unsuccessful, the file status value is set to 9H and any applicable USE AFTER EXCEPTION/ERROR procedure is invoked. Only one program device may be implicitly acquired when a file is opened. If a file is an ICF file, the single implicitly acquired program device is determined by the ACQPGMDEV parameter of the CRTICFF CL command. If the file is a display file, the single implicitly acquired program device is determined by the first entry in the DEV parameter of the CRTDSPF CL command. Additional program devices must be explicitly acquired. A program device is explicitly acquired by using the ACQUIRE statement. For an ICF file, the program device must have been defined to the file with the ADDICFDEVE or OVRICFDEVE command before the file is opened. For a display file, if the program device name is not the name of the display device, then the device must have been specified in the DEV parameter when the file was created, changed, or overridden, and before the OPEN is issued for the file. ---End of IBM Extension--- ═══ 12.11. ADD Statement ═══ The ADD statement adds two or more numeric operands and stores the result. The ADD statement has three formats:  Format 1 - ADD  Format 2 - ADD GIVING  Format 3 - ADD CORRESPONDING ═══ 12.11.1. ADD Statement - Format 1 ═══ ┌─── ADD STATEMENT - FORMAT 1 ─────────────────────────────────────────────────┐ │ │ │ ┌──────────────────┐ ┌───────────────────────────┐ │ │  │  │ │ │ >>──ADD────┬─identifier-1─┬─┴──TO────identifier-2──┬─────────┬─┴───────────> │ │ └─literal-1────┘ └─ROUNDED─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──SIZE ERROR──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──┬─────────┬──>< │ │ └─NOT───┬──────┬──SIZE ERROR──imperative-statement-2─┘ └─END-ADD─┘ │ │ └─ON───┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 1, identifiers and literals preceding the keyword TO are added together, and this initial sum is added to and stored in identifier-2. The initial sum is also added to each successive occurrence of identifier-2, in the left-to-right order in which identifier-2 is specified. If the composite of operands is 18 digits or less, enough places are carried so that no significant digits are lost during execution. In Format 1, the composite of operands is determined by using all of the operands in a given statement. -----IBM Extension----- The composite of all operands in an arithmetic statement can have a maximum length of 30 digits. ---End of IBM Extension--- ═══ 12.11.2. ADD Statement - Format 2 ═══ ┌─── ADD STATEMENT - FORMAT 2 ─────────────────────────────────────────────────┐ │ │ │ ┌──────────────────┐ │ │  │ │ │ >>──ADD────┬─identifier-1─┬─┴──┬────┬──┬─identifier-2─┬────────────────────> │ │ └─literal-1────┘ └─TO─┘ └─literal-2────┘ │ │ │ │ ┌───────────────────────────┐ │ │  │ │ │ >──GIVING────identifier-3──┬─────────┬─┴───────────────────────────────────> │ │ └─ROUNDED─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──SIZE ERROR──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──┬─────────┬──>< │ │ └─NOT───┬──────┬──SIZE ERROR──imperative-statement-2─┘ └─END-ADD─┘ │ │ └─ON───┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 2, the values of the operands preceding the word GIVING are added together, and the sum is stored as the new value of each data item referenced by identifier-3. If the composite of operands is 18 digits or less, enough places are carried so that no significant digits are lost during execution. In Format 2, the composite of operands is determined by using all of the operands in a given statement excluding the data items that follow the word GIVING. -----IBM Extension----- The composite of all operands in an arithmetic statement can have a maximum length of 30 digits. ---End of IBM Extension--- ═══ 12.11.3. ADD Statement - Format 3 ═══ ┌─── ADD STATEMENT - FORMAT 3 ─────────────────────────────────────────────────┐ │ │ │ >>──ADD──┬─CORRESPONDING─┬──identifier-4──TO──identifier-5──┬─────────┬────> │ │ └─CORR──────────┘ └─ROUNDED─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──SIZE ERROR──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──┬─────────┬──>< │ │ └─NOT───┬──────┬──SIZE ERROR──imperative-statement-2─┘ └─END-ADD─┘ │ │ └─ON───┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 3, elementary data items within identifier-4 are added to and stored in the corresponding elementary items within identifier-5. If the composite of operands is 18 digits or less, enough places are carried so that no significant digits are lost during execution. In Format 3, the composite of operands is determined separately for each pair of corresponding data items. -----IBM Extension----- The composite of all operands in an arithmetic statement can have a maximum length of 30 digits. ---End of IBM Extension--- ═══ 12.12. ALTER Statement ═══ The ALTER statement changes the transfer point specified in a GO TO statement. Note: The ALTER statement encourages the use of unstructured programming practices. The EVALUATE statement provides the same function as the ALTER statement and helps to ensure that your program will be well-structured. ┌─── ALTER STATEMENT - FORMAT ─────────────────────────────────────────────────┐ │ │ │ ┌────────────────────────────────────────────────────────┐ │ │  │ │ │ >>──ALTER────procedure-name-1──TO──┬────────────┬──procedure-name-2─┴──>< │ │ └─PROCEED TO─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The ALTER statement modifies the GO TO statement in the paragraph named by procedure-name-1. Subsequent executions of the modified GO TO statement(s) transfer control to procedure-name-2. If procedure-name-1 or procedure-name-2 are within a declarative procedure, neither can reference any nondeclarative procedure. In the nondeclarative portion of the program, there must be no reference to procedure-names that appear in an EXCEPTION/ERROR declarative procedure, except that PERFORM statements may refer to an EXCEPTION/ERROR procedure or procedures associated with it. Before the ALTER statement is executed, when control reaches the paragraph specified in procedure-name-1, the GO TO statement transfers control to the paragraph specified in the GO TO statement. After execution of the ALTER statement, however, the next time control reaches the paragraph specified in procedure-name-1, the GO TO statement transfers control to the paragraph specified in procedure-name-2. Related Information:  Coding Example ═══ 12.12.1. Coding Example ═══ The ALTER statement acts as a program switch, allowing, for example, one sequence of execution during initialization and another sequence during the bulk of file processing. Because altered GO TO statements are difficult to debug, it is preferable to test a switch, and based on the value of the switch, execute a particular code sequence. For example: PARAGRAPH-1. GO TO BYPASS-PARAGRAPH. PARAGRAPH-1A. . . BYPASS-PARAGRAPH. . . ALTER PARAGRAPH-1 TO PROCEED TO PARAGRAPH-2. . . PARAGRAPH-2. . . Before the ALTER statement is executed, when control reaches PARAGRAPH-1, the GO TO statement transfers control to BYPASS-PARAGRAPH. After execution of the ALTER statement, however, the next time control reaches PARAGRAPH-1, the GO TO statement transfers control to PARAGRAPH-2. Altered GO TO statements in programs with the INITIAL attribute are returned to their initial state each time the program is entered. ═══ 12.13. CALL Statement ═══ The CALL statement transfers control from one program to another within the run unit. The CALL statement has two formats:  Format 1 - CALL ON OVERFLOW  Format 2 - CALL ON EXCEPTION The program containing the CALL statement is the calling program; the program identified in the CALL statement is the called subprogram. The calling program must contain a CALL statement at the point where another program is to be called. Processing of the CALL statement passes control to the first nondeclarative instruction of the called subprogram. Control returns to the calling program at the instruction following the CALL statement. If the called subprogram has no procedure division or nondeclarative section in the Procedure Division, the called subprogram issues an implicit EXIT PROGRAM. A called program must not directly or indirectly execute its caller. This is called a recursive call. ILE COBOL/400 does not allow recursion in both main programs and subprograms. If recursion is attempted, a run-time error message is generated. The RETURN-CODE special register can be used to pass return code information from a program to its caller. See RETURN-CODE Special Register for further information. CALL statement processing passes control to the called subprogram, which becomes part of the run unit. If a CALL statement has a linkage of program object and the CALL statement names a program that does not exist in the job's library list (*LIBL) at run time, an error message is issued. A called subprogram is in its initial state the first time it is called within a run unit. It is also in its initial state the first time it is called after a CANCEL statement. A program is in its initial state each time it is called if it is an initial program (if its PROGRAM-ID paragraph contains the INITIAL clause). On all other entries into the called subprogram, it is in its last-used state, and the reinitialization of any items is your responsibility. The user return code is set to 0 at the start of the processing of any COBOL program, and before a call is made to another program. Related Information:  OS/400 Graphics Support ═══ 12.13.1. CALL Statement - Format 1 ═══ ┌─── CALL STATEMENT - FORMAT 1 ────────────────────────────────────────────────┐ │ │ │ >>──CALL───────────────────────────────────────────────────────────────────> │ │ │ │ >──┬─identifier-1──────────────────────────────────────────────────────────>─┤ │ └─┬────────────────────────────────────────────────────────┬──literal-1─' │ │ │ (1) │ │ │ ├─LINKAGE─────┬──────┬──┬──────┬──┬─environment-name-1─┬─┤ │ │ │ └─TYPE─┘ └─IS───┘ ├─PROGRAM────────────┤ │ │ │ │ └─PROCEDURE──────────┘ │ │ │ │ (1) │ │ │ ├─PROGRAM────────────────────────────────────────────────┤ │ │ │ (1) │ │ │ └─PROCEDURE──────────────────────────────────────────────┘ │ │ │ │ >──┬──────────────────────────┬────────────────────────────────────────────> │ │ │ ┌───────────────┐ │ │ │ │  │ │ │ │ └─USING────┤ BY Phrase ├─┴─┘ │ │ │ │ >──┬────────────────────────────────────────────┬──┬──────────┬──>< │ │ └─┬──────┬──OVERFLOW──imperative-statement-1─┘ └─END-CALL─┘ │ │ └─ON───┘ │ │ │ │ BY PHRASE: │ │ ┌───────────────────────────────────────┐ │ │  │ │ │ ├──┬─┬─────────────────────┬────┬─┬─────────────────┬──identifier-2─┬─┴─┬──┤ │ │ │ └─┬──────┬──REFERENCE─┘ │ │ (1)│ │ │ │ │ │ └─BY───┘ │ └─ADDRESS OF──────┘ │ │ │ │ │ │ (1) │ │ │ │ │ └─┬─file-name-1────┬────────────────┘ │ │ │ │ │ (1) │ │ │ │ │ └─OMITTED────────┘ │ │ │ │ ┌───────────────────────────────────────┐ │ │ │ │  │ │ │ │ └─┬──────┬──CONTENT────┬─┬─────────────────┬──identifier-2─┬─┴───────┘ │ │ └─BY───┘ │ │ (1)│ │ │ │ │ ├─ADDRESS OF──────┤ │ │ │ │ │ (1) │ │ │ │ │ └─LENGTH OF───────┘ │ │ │ │ (1) │ │ │ └─┬─literal-2──────┬────────────────┘ │ │ │ (1)│ │ │ ├─file-name-1────┤ │ │ │ (1) │ │ │ └─OMITTED────────┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.13.2. CALL Statement - Format 2 ═══ ┌─── CALL STATEMENT - FORMAT 2 ────────────────────────────────────────────────┐ │ │ │ >>── CALL──────────────────────────────────────────────────────────────────> │ │ │ │ >──┬─identifier-1──────────────────────────────────────────────────────────>─┤ │ └─┬────────────────────────────────────────────────────────┬──literal-1─' │ │ │ (1) │ │ │ ├─LINKAGE─────┬──────┬──┬──────┬──┬─environment-name-1─┬─┤ │ │ │ └─TYPE─┘ └─IS───┘ ├─PROGRAM────────────┤ │ │ │ │ └─PROCEDURE──────────┘ │ │ │ │ (1) │ │ │ ├─PROGRAM────────────────────────────────────────────────┤ │ │ │ (1) │ │ │ └─PROCEDURE──────────────────────────────────────────────┘ │ │ │ │ >──┬──────────────────────────┬────────────────────────────────────────────> │ │ │ ┌───────────────┐ │ │ │ │  │ │ │ │ └─USING────┤ BY Phrase ├─┴─┘ │ │ │ │ >──┬─────────────────────────────────────────────┬─────────────────────────> │ │ └─┬──────┬──EXCEPTION──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬───────────────────────────────────────────────────┬──┬──────────┬──>< │ │ └─NOT───┬──────┬──EXCEPTION──imperative-statement-2─┘ └─END-CALL─┘ │ │ └─ON───┘ │ │ │ │ BY PHRASE: │ │ ┌───────────────────────────────────────┐ │ │  │ │ │ ├──┬─┬─────────────────────┬────┬─┬─────────────────┬──identifier-2─┬─┴─┬──┤ │ │ │ └─┬──────┬──REFERENCE─┘ │ │ (1)│ │ │ │ │ │ └─BY───┘ │ └─ADDRESS OF──────┘ │ │ │ │ │ │ (1) │ │ │ │ │ └─┬─file-name-1────┬────────────────┘ │ │ │ │ │ (1) │ │ │ │ │ └─OMITTED────────┘ │ │ │ │ ┌───────────────────────────────────────┐ │ │ │ │  │ │ │ │ └─┬──────┬──CONTENT────┬─┬─────────────────┬──identifier-2─┬─┴───────┘ │ │ └─BY───┘ │ │ (1)│ │ │ │ │ ├─ADDRESS OF──────┤ │ │ │ │ │ (1) │ │ │ │ │ └─LENGTH OF───────┘ │ │ │ │ (1) │ │ │ └─┬─literal-2──────┬────────────────┘ │ │ │ (1)│ │ │ ├─file-name-1────┤ │ │ │ (1) │ │ │ └─OMITTED────────┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.13.3. USING ═══ Included in the CALL statement only if there is a USING phrase in the Procedure Division header of the called subprogram. The number of operands in both USING phrases must be identical. For CALL statements with a LINKAGE TYPE of program the maximum number of operands is 255, and for LINKAGE TYPE of procedure the maximum number of operands is 400. For more information about the USING phrase, see The USING Phrase. ILE COBOL/400 programs can pass arguments to other AS/400 programs. The attributes of the data passed depend on the requirements of the called subprogram. If a called program requires several parameters, you must specify the identity of each parameter, rather than a group item that consists of the parameters. The sequence of identifiers in the USING phrase of the CALL statement and in the corresponding USING phrase in the called subprogram's Procedure Division header determines the correspondence between the identifiers used by the calling and called programs. This correspondence is by position, rather than by name. The values of the parameters referenced in the USING phrase of the CALL statement are made available to the called subprogram at the time the CALL statement is executed. USING Phrase Example ┌───────────────────────────────────┬───────────────────────────────────┐ │ CALLING PROGRAM DESCRIPTION │ CALLED PROGRAM DESCRIPTION (PGMB) │ │ (PGMA) │ │ ├───────────────────────────────────┼───────────────────────────────────┤ │ WORKING-STORAGE SECTION. │ LINKAGE SECTION. │ │ 01 ARG-LIST. │ 01 PARAM-LIST. │ │ 05 PARTCODE PIC A. │ 10 PART-ID PIC X(5). │ │ 05 PARTNO PIC X(4). │ 10 SALES PIC 9(5). │ │ 05 U-SALES PIC 9(5). │ . │ │ . │ . │ │ . │ . │ │ . │ PROCEDURE DIVISION USING │ │ PROCEDURE DIVISION. │ PARAM-LIST. │ │ . │ │ │ . │ │ │ . │ │ │ CALL PGMB │ │ │ USING ARG-LIST. │ │ └───────────────────────────────────┴───────────────────────────────────┘ Note: In the calling program, the code for parts (PARTCODE) and the part number (PARTNO) are referred to separately. In the called subprogram, the code for parts and the part number are combined into one data item (PART-ID); therefore in the called subprogram, a reference to PART-ID is the only valid reference to them. ═══ 12.13.4. LINKAGE TYPE Phrase ═══ -----IBM Extension----- The LINKAGE TYPE phrase is used to specify the type of linkage to be made on the CALL to literal-1. If the LINKAGE TYPE phrase is not specified on the CALL statement, the linkage generated for the CALL can be changed by specifying one of: the LINKAGE TYPE clause of the SPECIAL-NAMES paragraph, or the LINKLIT parameter of the CRTCBLMOD or CRTBNDCBL command. ---End of IBM Extension--- ═══ 12.13.5. BY REFERENCE Phrase ═══ The value of a parameter passed through the BY REFERENCE phrase is evaluated when the CALL statement runs. This value is assigned to the corresponding parameter of the called program. The number of characters in each parameter must be equal; however, the data descriptions need not be the same. When an ILE COBOL/400 parameter is passed BY REFERENCE, a pointer to the original data item passes to the called program. Because of this, a change to a parameter in a called program will result in a change to a data item in a calling program. ═══ 12.13.6. BY CONTENT Phrase ═══ The value of a parameter passed through the BY CONTENT phrase is evaluated when the CALL statement runs. This value is assigned to the corresponding parameter of the called program. For each ILE COBOL/400 item passed BY CONTENT, a copy of the item is made in the calling program, and a pointer to this copy passes to the called program. Changes made to the parameter in the called program do not affect the data item of the calling program. The number of characters in each parameter must be equal; however, the data descriptions need not be the same. ═══ 12.13.7. LENGTH OF Special Register ═══ -----IBM Extension----- The LENGTH OF phrase creates an implicit special register whose contents equal the current length, in bytes, of the data item referenced by the identifier. The LENGTH OF special register has the implicit definition: USAGE IS BINARY, PICTURE 9(9) You can use it anywhere in the Procedure Division where you can use a numeric data item having the same definition as the implied definition of the LENGTH OF special register. It can appear in the starting position or length expression of a reference modifier. However, the LENGTH OF special register cannot be applied to any operand that is reference modified. It cannot be either of the following:  A receiving data item  A subscript You can use LENGTH OF in the BY CONTENT phrase of the CALL statement. For a table element, the LENGTH OF special register contains the length, in bytes, of one occurrence. To refer to a table element in this case, you do not need to use a subscript. For a variable-length element, the LENGTH OF special register contains the length based on the current contents of the occurs depending on (ODO) variable. The register returns a value for any identifier whose length can be determined, even if the area referenced by the identifier is currently not available to the program. For example, an identifier that is part of a 01-level record in a File Definition is not available until the corresponding file is open; however, the LENGTH OF such an identifier can be determined before the file is open. If, for a variable-length item, the contents of the ODO variable are not available, the LENGTH OF special register is undefined. For example, if an ODO variable is defined in the 01-level record of a file that is not open, no LENGTH OF value exists, and an error results. A separate LENGTH OF special register exists for each identifier referenced with the LENGTH OF phrase. For example: MOVE LENGTH OF A TO B DISPLAY LENGTH OF A, A ADD LENGTH OF A TO B CALL "PROGX" USING BY REFERENCE A BY CONTENT LENGTH OF A ---End of IBM Extension--- ═══ 12.13.7.1. ON EXCEPTION Phrase ═══ This phrase handles the exceptions that result from program existence, authority, and storage if the original receiver of the exception is the caller. At that time, one of the following occurs: 1. If the ON EXCEPTION phrase appears in the CALL statement, control transfers to imperative-statement-1. Processing then continues according to the rules for each statement specified in imperative-statement-1. If a procedure-branching or conditional statement causing explicit transfer of control runs, control transfers according to the rules for that statement. Otherwise, once imperative-statement-1 has run, control transfers to the end of the CALL statement, and the NOT ON EXCEPTION phrase, if specified, is ignored. 2. If the ON EXCEPTION phrase does not appear in the CALL statement, the NOT ON EXCEPTION phrase, if specified, is ignored. ═══ 12.13.7.2. NOT ON EXCEPTION Phrase ═══ If an exception condition does not occur (in other words, the called subprogram can be made available), control transfers to the called program. After control returns from the called program, the ON EXCEPTION phrase, if specified, is ignored, and control transfers to the end of the CALL statement (or to imperative-statement-2, if the NOT ON EXCEPTION phrase is specified). If control transfers to imperative-statement-2, processing continues according to the rules for each statement specified in imperative-statement-2. If a procedure-branching or conditional statement causing explicit transfer of control runs, control transfers according to the rules for that statement. Otherwise, once imperative-statement-2 has run, control transfers to the end of the CALL statement. If you specify this phrase in conjunction with the ON OVERFLOW phrase, an error will result. ═══ 12.13.8. OS/400 Graphics Support ═══ You can use the CALL statement to access the following OS/400 graphics routines:  Graphical Data Display Manager* (GDDM*), a set of graphics primitives for drawing pictures  Presentation Graphics Routines (PGR), a set of business charting routines. You access all these graphics routines with the same format of the CALL statement: ┌─── CALL GDDM STATEMENT - FORMAT ─────────────────────────────────────────────┐ │ │ │ (1) ┌───────────────┐ │ │  │ │ │ >>──CALL──"GDDM"──USING─────routine-name───┬─────────────┬┴──>< │ │ └─data-name-1─┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Routine-name is the name of the graphics routine you want to use. The data-names that follow routine-name are the parameters necessary to use certain graphics routines. The number of parameters that you must specify varies, depending on which routine you select. When you select a graphics routine, make sure each parameter is the correct size and data type as required by that routine. The following are examples of calling graphics routines. Remember, you must use the CALL literal format and define each parameter as required by the graphics routine you use. MOVE "FSINIT" TO OS-400-GRAPHICS-ROUTINE-NAME. CALL "GDDM" USING OS-400-GRAPHICS-ROUTINE-NAME. . . MOVE "GSFLD" TO OS-400-GRAPHICS-ROUTINE-NAME. CALL "GDDM" USING OS-400-GRAPHICS-ROUTINE-NAME, PIC-ROW, PIC-COL, PIC-DEPTH, PIC-WIDTH. ═══ 12.14. CANCEL Statement ═══ The CANCEL statement ensures that the next time the referenced subprogram is called it will be entered in its initial state. ┌─── CANCEL STATEMENT - FORMAT ────────────────────────────────────────────────┐ │ │ │ ┌───────────────────────────────────────┐ │ │  │ │ │ >>──CANCEL────┬─identifier-1──────────────────────┬─┴──>< │ │ └─┬────────────────────┬──literal-1─┘ │ │ └─┤ Linkage Phrase ├─┘ │ │ │ │ LINKAGE PHRASE: │ │ ├──┬────────────────────────────────────────────────────────┬──┤ │ │ │ (1) │ │ │ ├─LINKAGE─────┬──────┬──┬──────┬──┬─environment-name-1─┬─┤ │ │ │ └─TYPE─┘ └─IS───┘ ├─PROGRAM────────────┤ │ │ │ │ └─PROCEDURE──────────┘ │ │ │ │ (1) │ │ │ ├─PROGRAM────────────────────────────────────────────────┤ │ │ │ (1) │ │ │ └─PROCEDURE──────────────────────────────────────────────┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ If the LINKAGE TYPE phrase is not specified on the CANCEL statement, the type of program canceled can be changed by specifying one of: the LINKAGE TYPE clause of the SPECIAL-NAMES paragraph, or the LINKLIT parameter of the CRTCBLMOD or CRTBNDCBL command. After a CANCEL statement for a called subprogram has been executed, that subprogram no longer has a logical connection to the program. The contents of data items in external data records described by the subprogram are not changed when a subprogram is canceled. If a CALL statement is executed later by any program in the run unit naming the same subprogram, that subprogram will be entered in its initial state. A CANCEL statement closes all open INTERNAL files. You can cancel a called subprogram in any of the following ways:  By referencing it as the operand of a CANCEL statement  By terminating the run unit of which the subprogram is a member (This can be done by a STOP RUN in the same run unit or by a GOBACK from the main program of the run unit.)  By executing an EXIT PROGRAM statement in the called subprogram if that subprogram possesses the INITIAL attribute -----IBM Extension-----  By executing the GOBACK statement in the called subprogram if that subprogram possesses the INITIAL attribute. ---End of IBM Extension--- A CANCEL statement operates only on the program specified, and not on any program that may have been called by the canceled program. Called subprograms may contain CANCEL statements. A called subprogram must not contain a CANCEL statement that directly or indirectly cancels its calling program or any other program higher than itself in the calling hierarchy. If a called subprogram attempts to cancel its calling program, the CANCEL statement in the subprogram is ignored. A program named in a CANCEL statement must not refer to any program that has been called and has not yet returned control to the calling program. For example: A calls B and B calls C (When A receives control, it can cancel C.) A calls B and A calls C (When C receives control, it can cancel B.) No action is taken when a CANCEL statement is executed naming a program that has not been called in the run unit, or that names a program that was called and subsequently canceled. In both cases, control passes to the next statement. ═══ 12.15. CLOSE Statement ═══ The CLOSE statement terminates the processing of volumes and files, with optional rewind and/or lock or removal, where applicable. The CLOSE statement has three formats:  Format 1  Format 2 - Tape Files Related Information:  CLOSE Statement Considerations  Special Considerations for Device Type TAPEFILE Only ═══ 12.15.1. CLOSE Statement - Format 1 ═══ ┌─── CLOSE STATEMENT - FORMAT 1 ───────────────────────────────────────────────┐ │ │ │ ┌─────────────────────────────────┐ │ │  │ │ │ >>──CLOSE────file-name-1──┬────────────────┬─┴──>< │ │ └─┬──────┬──LOCK─┘ │ │ └─WITH─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.15.2. CLOSE Statement - Format 2 - Tape Files ═══ ┌─── CLOSE STATEMENT - FORMAT 2 - TAPE FILES ──────────────────────────────────┐ │ │ │ ┌──────────────────────────────────────────────────┐ │ │  │ │ │ >>──CLOSE────file-name-1──┬─────────────────────────────────┬─┴──>< │ │ ├─┬─REEL─┬──┬───────────────────┬─┤ │ │ │ └─UNIT─┘ └──┬──────┬─REMOVAL─┘ │ │ │ │ └─FOR──┘ │ │ │ └─┬──────┬──┬─NO REWIND─┬───────┘ │ │ └─WITH─┘ └─LOCK────────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.15.3. CLOSE Statement Considerations ═══ A CLOSE statement may be executed only for a file in an open mode. After successful execution of a CLOSE statement without the REEL/UNIT phrase:  The record area associated with the file-name-1 is no longer available. Unsuccessful execution of a CLOSE statement leaves availability of the record data undefined.  An OPEN statement for the file must be executed before any other input/output statement. If the FILE STATUS clause is specified in the FILE-CONTROL entry, the associated status key is updated when the CLOSE statement is executed. For more information about the status key, see Common Processing Facilities. If the file is in an open status and the execution of a CLOSE statement is unsuccessful, the EXCEPTION/ERROR procedure (if specified) for this file is executed. If a CLOSE statement for an open file is not processed before a STOP RUN for this run unit, the file is implicitly closed. If the SELECT OPTIONAL clause is specified in the file-control entry for this file, and the file is not present at run time, standard end-of-file processing is not performed. The following considerations apply to the use of the CLOSE statement:  May be processed only for an open file.  For Relative Files Only: To extend a relative file boundary beyond the current number of records and within the file size, use the INZPFM command to add deleted records before processing the file. You will need to do this when more records need to be added to the file, and file status 0Q has been received. Any attempt to extend a relative file beyond its current size results in a boundary violation. ═══ 12.15.4. WITH LOCK Phrase ═══ COBOL ensures that this file cannot be reopened by this COBOL program during this processing of the program. External files closed WITH LOCK cannot be opened again within the run unit. This includes any other programs that have defined the external file. ═══ 12.15.5. Special Considerations for Device Type TAPEFILE Only ═══  A device type TAPEFILE can be divided into the following two categories: Sequential Single Volume: A sequential file contained entirely on one volume. More than one file may be contained on this volume. Sequential Multivolume: A sequential file contained on more than one volume.  If the ENDOPT keyword has been specified in the Create Tape File (CRTTAPF) or the Override with Tape File (OVRTAPF) CL command, the positioning of the tape volume when the file is closed follows the value specified in that keyword (a value of LEAVE, REWIND, or UNLOAD). If the ENDOPT keyword has not been specified, the positioning of the tape volume when the file is closed corresponds to the following ENDOPT values: CLOSE NO REWIND statement . . . . LEAVE All other forms of CLOSE . . . . REWIND  The CLOSE statement causes the current volume to be positioned at its beginning, except when the NO REWIND phrase is specified, or if the REEL, UNIT, REEL FOR REMOVAL, or UNIT FOR REMOVAL phrases are specified for a sequential single volume tape file. For sequential multivolume tape files, CLOSE, CLOSE WITH LOCK, and CLOSE NO REWIND have no effect on any previous volumes. Any additional volumes are not processed. The following phrases apply only to device type TAPEFILE: NO REWIND phrase REEL or UNIT phrase REEL FOR REMOVAL or UNIT FOR REMOVAL phrase ═══ 12.15.5.1. NO REWIND Phrase ═══ The current volume is left in its present position. The reel is not rewound. -----IBM Extension----- The system always rewinds and unloads the tape when the REEL or UNIT phrase is specified on the CLOSE statement. ---End of IBM Extension--- ═══ 12.15.5.2. REEL or UNIT Phrase ═══ For sequential single volume tape files, the REEL or UNIT phrase is optional; it is syntax checked only and performs no function at run time. For sequential multivolume tape files, the following CLOSE statement procedures apply:  For tape files opened for input, the current volume is positioned to read the labels. If this is the last volume for the file, the next processed READ statement receives the AT END condition. If this is not the last volume: 1. The current volume is unloaded 2. The beginning standard labels on the next volume are read 3. The next processed READ statement gets the first record on the newly mounted volume.  For tape files opened for output, the standard end-of-volume labels are written. The next volume is mounted. The standard beginning labels are written on the new volume. The next processed WRITE statement places the next logical record on the newly mounted volume. ═══ 12.15.5.3. FOR REMOVAL Phrase ═══ For sequential single volume tape files, the REEL FOR REMOVAL or UNIT FOR REMOVAL phrase is optional; it is syntax checked only and performs no function at run time. For sequential multivolume tape files, the addition of the FOR REMOVAL phrase to the REEL or UNIT phrase causes the current volume to be rewound and unloaded. The system is then notified that the volume is logically removed from this run unit. However, the volume can be accessed again, after processing of a CLOSE statement without the REEL or UNIT phrase and an OPEN statement for this file. ═══ 12.16. COMMIT Statement ═══ -----IBM Extension----- The COMMIT statement provides a way of synchronizing changes to data base records while preventing other jobs from modifying those records until the COMMIT is performed. The format of the COMMIT statement is: ┌─── COMMIT STATEMENT - FORMAT ────────────────────────────────────────────────┐ │ │ │ >>──COMMIT──>< │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ When the COMMIT statement is executed, all changes made to files under commitment control, for the current commitment definition since the previous commitment boundary, are made permanent. A commitment boundary is established by the successful execution of a ROLLBACK or COMMIT statement. If no COMMIT or ROLLBACK has been issued in the current job, a commitment boundary is established by the first OPEN of any file under commitment control in the job. Changes are made to all files under commitment control, not just to files under commitment control in the COBOL program that issues the COMMIT statement. When a COMMIT is executed, all record locks held by the current commitment definition since the last commitment boundary for files under commitment control are released and the records become available. Commitment control can be scoped at the job level or the activation group level. Commitment control scopes to the activation group by default. This is important when your application involves non-ILE COBOL programs that run in a different activation group, such as a CL program. The COMMIT statement only affects files under commitment control. If a COMMIT is executed and there are no files opened under commitment control, the COMMIT statement has no effect and no commitment boundary is established. The COMMIT statement does not:  Modify the I-O-FEEDBACK area for any file  Change the file position indicator for any file  Set a file status value for any file. ---End of IBM Extension--- ═══ 12.17. COMPUTE Statement ═══ The COMPUTE statement assigns the value of an arithmetic expression to one or more data items. With the COMPUTE statement, arithmetic operations can be combined without the restrictions on receiving data items imposed by the rules for the ADD, SUBTRACT, MULTIPLY, and DIVIDE statements. ┌─── COMPUTE STATEMENT - FORMAT ───────────────────────────────────────────────┐ │ │ │ ┌───────────────────────────┐ │ │  │ │ │ >>──COMPUTE────identifier-1──┬─────────┬─┴──┬─=─────┬──────────────────────> │ │ └─ROUNDED─┘ └─EQUAL─┘ │ │ │ │ >──arithmetic-expression───────────────────────────────────────────────────> │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──SIZE ERROR──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──────────────────> │ │ └─NOT───┬──────┬──SIZE ERROR──imperative-statement-2─┘ │ │ └─ON───┘ │ │ │ │ >──┬─────────────┬──>< │ │ └─END-COMPUTE─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ If portability is desired, however, you should use ADD, SUBTRACT, MULTIPLY, and DIVIDE rather than COMPUTE. This is because of potentially different system-specific intermediate results. When arithmetic operations are combined, the COMPUTE statement may be more efficient than the separate arithmetic statements written in series. ═══ 12.18. CONTINUE Statement ═══ The CONTINUE statement allows you to specify a no operation statement. CONTINUE indicates that no executable instruction is present. ┌─── CONTINUE STATEMENT - FORMAT ──────────────────────────────────────────────┐ │ │ │ >>──CONTINUE──>< │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The CONTINUE statement may be used anywhere a conditional statement or an imperative statement may be used. It has no effect on the execution of the program. ═══ 12.19. DELETE Statement ═══ The DELETE statement removes a record from an indexed or relative file. For indexed files, the key may then be reused for record addition. For relative files, the space is then available for a new record with the same RELATIVE KEY value. When the DELETE statement is executed, the associated file must be open in I-O mode. ┌─── DELETE STATEMENT - FORMAT ────────────────────────────────────────────────┐ │ │ │ >>──DELETE──file-name──┬────────┬──────────────────────────────────────────> │ │ └─RECORD─┘ │ │ │ │ >──┬─────────────────────────────────────┬─────────────────────────────────> │ │ │ (1) │ │ │ └─FORMAT────┬────┬──┬─identifier-1─┬──┘ │ │ └─IS─┘ └─literal-1────┘ │ │ │ │ >──┬───────────────────────────────────────────┬───────────────────────────> │ │ └─INVALID──┬──────┬──imperative-statement-1─┘ │ │ └─KEY──┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──┬────────────┬──>< │ │ └─NOT INVALID──┬──────┬──imperative-statement-2─┘ └─END-DELETE─┘ │ │ └─KEY──┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ After successful execution of a DELETE statement, the record is logically removed from the file and can no longer be accessed. Execution of the DELETE statement does not affect the contents of the record area associated with the file-name (or the content of the data item referenced by the data-name specified in the DEPENDING ON phrase of the RECORD clause associated with file-name). If the FILE STATUS clause is specified in the File-Control entry, the associated status key is updated when the DELETE statement is executed. The file position indicator is not affected by the processing of the DELETE statement. Related Information:  DELETE Statement Considerations  Special Considerations for Sequential Access Mode  Special Considerations for Random or Dynamic Access Mode ═══ 12.19.1. DELETE Statement Considerations ═══ -----IBM Extension----- The action of this statement can be inhibited at program run time by the inhibit write (INHWRT) parameter of the Override with Database File (OVRDBF) CL command. When this parameter is specified, non-zero file status codes are not set for data dependent errors. Duplicate key and data conversion errors are examples of data dependent errors. ---End of IBM Extension--- ═══ 12.19.2. Sequential Access Mode ═══ For an indexed or relative file in sequential access mode,  When the DELETE statement is processed, the system logically removes the record retrieved and locked by the READ statement. The last input/output statement must have been a successfully processed READ statement without the NO LOCK phrase. -----IBM Extension----- If the last input/output statement was a successfully processed READ statement with the NO LOCK phrase: - The file status key, if defined, is set to 9S. - The EXCEPTION/ERROR procedure, if any, is run. - The DELETE statement is not processed. ---End of IBM Extension--- If the last input/output statement was not a successfully processed READ statement, the file status key (if defined) is set to 43.  For a file in sequential access mode, the INVALID KEY and NOT INVALID KEY phrases must not be specified; however, an EXCEPTION/ERROR procedure may be specified. For information about error handling, see Common Processing Facilities. ═══ 12.19.3. Random or Dynamic Access Mode ═══ In random and dynamic access modes, the results of using the DELETE statement depend on the file organization. When it is a relative file, the system logically removes the record identified by the contents of the RELATIVE KEY data item. The space is then available for a new record with the same RELATIVE KEY value. If the file does not contain such a record, an INVALID KEY condition exists. On an indexed file, the system logically removes the record identified by the contents of the RECORD KEY data item. If the file does not contain such a record, an INVALID KEY condition exists. -----IBM Extension----- When EXTERNALLY-DESCRIBED-KEY is specified for the file, the key fields in the record area for the format specified by the FORMAT phrase are used to find the record to be deleted. If the FORMAT phrase is not specified, the first format defined in the program for the file is used to find the record to be deleted. DUPLICATES Phrase If this phrase was specified for the file, the last input/output statement processed for this file before the processing of the DELETE statement must have been a successfully processed READ statement without the NO LOCK phrase. The record read by that statement is the record that is deleted. In this case, the FORMAT phrase is not used to find the record to be deleted. The READ statement is required to ensure that the proper record is deleted when there are duplicates. If a successful READ operation did not occur before the delete operation:  The file status key, if defined, is set to 94.  The EXCEPTION/ERROR procedure, if any, is run.  The DELETE statement is not processed. If the last input/output statement was a successfully processed READ statement with the NO LOCK phrase:  The file status key, if defined, is set to 9S.  The EXCEPTION/ERROR procedure, if any, is run.  The DELETE statement is not processed. The value of the RECORD KEY data item should not have changed since the record was read. By default, if it has changed:  The file status key, if defined, is set to 21.  An INVALID KEY condition exists.  The DELETE statement is not processed. ---End of IBM Extension--- ═══ 12.20. DISPLAY Statement ═══ The DISPLAY statement transfers the contents of each operand to the output device. The contents are displayed on the output device in the order, left to right, in which the operands are listed. The DISPLAY statement has four formats:  Format 1 - Data Transfer -----IBM Extension-----  Format 2 - Local Data Area  Format 3 - Workstation I/O  Format 4 - Session I/O ---End of IBM Extension--- ═══ 12.20.1. Data Transfer ═══ ┌─── DISPLAY STATEMENT - FORMAT 1 - DATA TRANSFER ─────────────────────────────┐ │ │ │ ┌──────────────────┐ │ │  │ │ │ >>──DISPLAY────┬─identifier-1─┬─┴──┬───────────────────────────────────┬───> │ │ └─literal-1────┘ └─┬──────┬──┬─mnemonic-name───────┬─┘ │ │ └─UPON─┘ │ (1)│ │ │ └─environment-name────┘ │ │ │ │ >──┬────────────────────────────┬──>< │ │ │ (2)│ │ │ └─┬──────┬──NO──ADVANCING────┘ │ │ └─WITH─┘ │ │ │ │ NOTES: │ │ (1) IBM Extension │ │ │ │ (2) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The DISPLAY statement transfers the data in the sending field to the output device. The size of the sending field is the total character count of all operands listed. If the hardware device is capable of receiving data of the same size as the data item being transferred, then the data item is transferred. If the hardware device is not capable of receiving data of the same size as the data item being transferred, then one of the following applies:  If the total character count is less than the device maximum logical record size, the remaining rightmost characters are padded with spaces.  If the total character count exceeds the maximum, as many records are written as are needed to display all operands. Any operand being printed or displayed when the end of a record is reached is continued in the next record. After the last operand has been transferred to the output device, the device is reset to the leftmost position of the next line of the device. The logical record length depends on the device as follows: ┌────────────────────────────────┬───────────────────┐ │ │ MAXIMUM LOGICAL │ │ OUTPUT │ RECORD SIZE │ │ │ │ ├────────────────────────────────┼───────────────────┤ │ Job log │ 120 characters │ ├────────────────────────────────┼───────────────────┤ │ Workstation │ 58 characters │ ├────────────────────────────────┼───────────────────┤ │ System operator's │ 58 characters │ │ message queue │ │ └────────────────────────────────┴───────────────────┘ When a program in a batch job processes a DISPLAY statement without the UPON phrase, or with an UPON phrase associated with the REQUESTOR, the output is sent to the job log in an informational message of severity 99. You can change the severity of this message using the Change Message Description (CHGMSGD) CL command. For an interactive job that uses display device files, DISPLAY statements are not normally used. If you do use them, the following considerations apply. When an interactive job processes a DISPLAY statement, the logical record appears on the screen in the Program Messages display. ═══ 12.20.2. Format 2 - Local Data Area ═══ -----IBM Extension----- This format is used to transfer data to the system-defined local data area created for a job. ┌─── DISPLAY STATEMENT - FORMAT 2 - LOCAL DATA AREA ───────────────────────────┐ │ │ │ ┌──────────────────┐ │ │  │ │ │ >>──DISPLAY────┬─identifier-1─┬─┴──UPON──mnemonic-name─────────────────────> │ │ └─literal-1────┘ │ │ │ │ >──┬──────────────────────────────────┬──>< │ │ │ (1) │ │ │ └──┬──────┬──┬─identifier-2─┬──────┘ │ │ └─FOR──┘ └─literal-2────┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The DISPLAY statement's literal operands, or the contents of the DISPLAY statement's identifier operands, are written to the system-defined local data area of the job containing the program that issues the DISPLAY. The data is written to the local data area according to the rules of the MOVE statement for a group move, without the CORRESPONDING phrase, and without padding on the right with spaces. ---End of IBM Extension--- ═══ 12.20.3. Format 3 - Extended DISPLAY Statement ═══ -----IBM Extension----- A DISPLAY statement is considered an extended DISPLAY statement if it has one of the following:  An AT phrase  An UPON CRT or UPON CRT-UNDER phrase  A MODE IS BLOCK phrase  A WITH phrase  No UPON phrase and a CONSOLE IS CRT specified in the SPECIAL-NAMES paragraph A DISPLAY statement is considered a standard DISPLAY statement if it has one of the following:  An UPON phrase (other than UPON CRT or UPON CRT-UNDER)  No UPON phrase and no CONSOLE IS CRT specified in the SPECIAL-NAMES paragraph ┌─── DISPLAY STATEMENT - FORMAT 3 - WORKSTATION I/O ───────────────────────────┐ │ │ │ ┌──────────────────────────┐ │ │  │ │ │ >>──DISPLAY───┬─┬─identifier-1─┬───────┬┴──>< │ │ │ └─literal-1────┘ │ │ │ ├─┤ line-column-phrase ├─┤ │ │ ├─UPON─┬─CRT───────┬───┴─┤ │ │ │ └─CRT-UNDER─┘ │ │ │ ├─MODE─┬──────┬─BLOCK────┤ │ │ │ └─IS───┘ │ │ │ └─┤ with-phrase ├────────┘ │ │ │ │ LINE-COLUMN-PHRASE: │ │ ┌──────────────────────────────────────────┐ │ │  │ │ │ ├──┬──┬──────┬────┬─LINE───┬──┬────────┬──┬─identifier-2─┬─┴──┬──┤ │ │ │ └─AT───┘ ├─COLUMN─┤ └─NUMBER─┘ └─integer-1────┘ │ │ │ │ └─COL────┘ │ │ │ └─AT───┬─identifier-3─┬────────────────────────────────────┘ │ │ └─integer-2────┘ │ │ │ │ WITH-PHRASE: │ │ ┌───────────────────────────────────────────────┐ │ │  │ │ │ ├──WITH───┬─┬─BELL─┬────────────────────────────────────┬┴──┤ │ │ │ └─BEEP─┘ │ │ │ ├─BLINK───────────────────────────────────────┤ │ │ ├─HIGHLIGHT───────────────────────────────────┤ │ │ ├─REVERSE-VIDEO───────────────────────────────┤ │ │ ├─UNDERLINE───────────────────────────────────┤ │ │ ├─BLANK─┬─SCREEN─┬────────────────────────────┤ │ │ │ └─LINE───┘ │ │ │ ├─SIZE─┬──────┬──┬─identifier-4─┬─────────────┤ │ │ │ └─IS───┘ └─integer-3────┘ │ │ │ │ (1) │ │ │ ├──┬─FOREGROUND-COLOR─────┬──┬────┬─integer-4─┤ │ │ │ │ (1)│ └─IS─┘ │ │ │ │ └─FOREGROUND-COLOUR────┘ │ │ │ │ (1) │ │ │ └──┬─BACKGROUND-COLOR─────┬──┬────┬─integer-5─┘ │ │ │ (1)│ └─IS─┘ │ │ └─BACKGROUND-COLOUR────┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Part of this statement can be repeated to allow the display of several data items. If the first identifier has no AT, LINE, or COLUMN phrase, it begins in line 1, column 2. Each subsequent data item begins at the currently available screen position following the previous data item. If identifier-1 or literal-1 is not specified, neither the MODE IS BLOCK phrase nor the WITH phrase is allowed. When identifier-1 does not fit within the screen, then alphanumeric data is truncated and numeric data is not put on the screen. If identifier-1 is a group item and there is no MODE IS BLOCK phrase, those elementary subordinate items that have names other than FILLER are displayed. They are displayed simultaneously, and positioned on the screen in the order that their descriptions appear in the DATA DIVISION, separated by the lengths of the FILLER items in the group. For this purpose, the first position on a line is regarded as immediately following the last position on the previous line. When items are separated by FILLERs, the attribute bytes are included in the FILLER length. Thus a FILLER of one or two bytes would contain both the trailing and leading attributes of separate items. In the case of a one-byte FILLER, the trailing and leading attributes would occupy the same byte. Since data items are normally separated by one attribute byte, one-byte FILLERs are not necessary. If no identifier or literal is present, the DISPLAY operation changes the screen position without actually displaying any data. The phrases following the identifier or literal can be in any order. All phrases specified apply to the previous identifier or literal, if one was specified. The WITH and MODE phrases cannot be specified if an identifier or literal was not previously specified. Identifiers or literals in a DISPLAY statement follow one after another, separated by one attribute byte, unless an AT, LINE, or COLUMN phrase is specified. If no AT, LINE, or COLUMN phrase appears in the statement, the first identifier or literal begins at line 1, column 2, followed immediately by all other identifiers or literals. ---End of IBM Extension--- Related Information:  Special Considerations for Format 3 DISPLAY. ═══ 12.20.4. AT Phrase ═══ -----IBM Extension----- The AT phrase indicates the absolute address on the screen at which the DISPLAY operation is to start. It does not indicate the starting position of the leading attribute. Related Information:  Line and Column Combinations ---End of IBM Extension--- ═══ 12.20.5. Line and Column Combinations ═══ -----IBM Extension----- Certain combinations of line and column numbers have special meaning:  Until the column comes within range, out-of-range column values are reduced by the line length, and the line value is incremented. A column number, then, can cause the line number to be incremented several times.  Out-of-range line values cause the screen to scroll up one line. The effect is the same as if the line number of the bottom line were specified. The screen is never scrolled up by more than one line, regardless of the line specified.  If column and line numbers are both out of range, out-of-range columns are handled first, followed by out-of-range lines (according to the preceding rules).  If the line and column numbers given are both zero, the DISPLAY operation starts at the position following the one at which the preceding DISPLAY operation finished. Column 1 of each line is considered to follow the last column of the previous line.  If the line number is zero, but the column number is not, the DISPLAY operation starts at the specified column on the line following the one at which the preceding DISPLAY operation finished.  If the column number is zero, but the line number is not, the DISPLAY operation starts on the specified line at the column following the one at which the preceding DISPLAY operation finished. ---End of IBM Extension--- ═══ 12.20.6. SIZE Phrase ═══ -----IBM Extension----- Specifies the current size of the data item on the screen. You can use this phrase with elementary data items only. The SIZE phrase has no effect if the size you specify is zero. In this case, the length of the field is used to display the data item. If you specify a size that is less than the size implied by the associated PICTURE clause, only the leftmost portion of the data item appears on the workstation display. When the size specified for a numeric or a numeric-edited data item is less than that implied by the PICTURE clause, truncation of the rightmost positions occurs when the value is displayed, or predisplayed in the ACCEPT operation. The data item is then updated following the rules for the MOVE operation. If you specify a SIZE literal whose value causes the field length to exceed the screen size, alphanumeric data will be truncated and numeric data will be ignored and not displayed. For justified items, only the rightmost portion appears when you specify a size that is smaller than the length of the item. If the size you specify is greater than the size implied by the PICTURE clause, the displayed version of the item is padded with spaces. The padding occurs on the right. ALL figurative constants are displayed as many times as necessary to reach the length you specify. If the display wraps around to a new line, the new line starts at the beginning of the constant. Related Information:  SIZE Phrase Example ---End of IBM Extension--- ═══ 12.20.7. SIZE Phrase Example ═══ -----IBM Extension----- The following is an example of displaying a figurative constant where the size specified is greater than the figurative constant and wraps around to a new line: DISPLAY ALL 'ABCD' AT 0270 WITH SIZE 15. This constant will be displayed on the screen starting with line 2, column 70: 0000000001 677777777778 1234567890................901234567890 Line 1 Line 2 ABCDABCDABC Line 3 ABCD Notice the differences between the following examples: Statement 1 DISPLAY 'WORKSTATION' AT 0275 WITH SIZE 10 Statement 2 DISPLAY ALL 'WORKSTATION' AT 0275 WITH SIZE 10 0000000001 677777777778 1234567890................901234567890 Statement 1 WORKST ATIO Statement 2 WORKST WORK ---End of IBM Extension--- ═══ 12.20.8. Format 3 Considerations ═══ -----IBM Extension----- A data item can contain a table whether or not MODE IS BLOCK has been specified. Fixed-length and variable-length tables are treated as group items (MODE IS BLOCK is not specified) that are repeated from the first occurrence to the last occurrence of the table. Some extended DISPLAY statement considerations also apply to the extended ACCEPT statement. The ILE COBOL/400 extended DISPLAY statement is similar to the IBM COBOL/2 DISPLAY statement (Format 2). ---End of IBM Extension--- ═══ 12.20.9. Format 4 - Session I/O ═══ -----IBM Extension----- This format is used to transfer data to the ILE common session manager. ┌─── DISPLAY STATEMENT - FORMAT 4 - SESSION I/O ───────────────────────────────┐ │ │ │ ┌──────────────────┐ │ │  │ │ │ >>──DISPLAY────┬─identifier-1─┬─┴──┬───────────────┬───────────────────────> │ │ └─literal-1────┘ └─UPON──DISPLAY─┘ │ │ │ │ >──┬─────────────────────────┬──>< │ │ └─┬──────┬──NO──ADVANCING─┘ │ │ └─WITH─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ This format is only applicable when the UPON DISPLAY phrase is specified or the CONSOLE IS DISPLAY clause is specified in the SPECIAL-NAMES paragraph. The DISPLAY statement's literal operands or the contents of the DISPLAY statement's identifier operands, are written to the ILE common session manager. The data is written to the session manager according to the rules outlined in format1 - Data Transfer (refer to the description of identifier-1 and literal-1 under Data Transfer). If the contents of identifier-1 or literal-1 span more than one line, writing of data continues at the first position of the next line of the ILE common session manager. If the WITH NO ADVANCING phrase is not specified a new line character is written to the session manager; if it is specified, the session manager will be positioned immediately following the last character of the last operand displayed. ---End of IBM Extension--- ═══ 12.21. DIVIDE Statement ═══ The DIVIDE statement divides one numeric data item into or by one or more others, and stores the result in the quotient and remainder. The DIVIDE statement has five formats:  Format 1 - DIVIDE INTO  Format 2 - DIVIDE INTO GIVING  Format 3 - DIVIDE BY GIVING  Format 4 - DIVIDE INTO GIVING REMAINDER  Format 5 - DIVIDE BY GIVING REMAINDER ═══ 12.21.1. DIVIDE Statement - Format 1 ═══ ┌─── DIVIDE STATEMENT - FORMAT 1 ──────────────────────────────────────────────┐ │ │ │ ┌───────────────────────────┐ │ │  │ │ │ >>──DIVIDE──┬─identifier-1─┬──INTO────identifier-2──┬─────────┬─┴──────────> │ │ └─literal-1────┘ └─ROUNDED─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──SIZE ERROR──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──────────────────> │ │ └─NOT───┬──────┬──SIZE ERROR──imperative-statement-2─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────┬──>< │ │ └─END-DIVIDE─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 1, the value of identifier-1 or literal-1 is divided into the value of identifier-2; the quotient is then placed in identifier-2. This process is repeated for each successive occurrence of identifier-2. ═══ 12.21.2. DIVIDE Statement - Format 2 ═══ ┌─── DIVIDE STATEMENT - FORMAT 2 ──────────────────────────────────────────────┐ │ │ │ >>──DIVIDE──┬─identifier-1─┬──INTO──┬─identifier-2─┬───────────────────────> │ │ └─literal-1────┘ └─literal-2────┘ │ │ │ │ ┌───────────────────────────┐ │ │  │ │ │ >──GIVING────identifier-3──┬─────────┬─┴───────────────────────────────────> │ │ └─ROUNDED─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──SIZE ERROR──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──────────────────> │ │ └─NOT───┬──────┬──SIZE ERROR──imperative-statement-2─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────┬──>< │ │ └─END-DIVIDE─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 2, the value of identifier-1 or literal-1 is divided into the value of identifier-2 or literal-2. The value of the quotient is stored in each data item referenced by identifier-3. ═══ 12.21.3. DIVIDE Statement - Format 3 ═══ ┌─── DIVIDE STATEMENT - FORMAT 3 ──────────────────────────────────────────────┐ │ │ │ >>──DIVIDE──┬─identifier-1─┬──BY──┬─identifier-2─┬─────────────────────────> │ │ └─literal-1────┘ └─literal-2────┘ │ │ │ │ ┌───────────────────────────┐ │ │  │ │ │ >──GIVING────identifier-3──┬─────────┬─┴───────────────────────────────────> │ │ └─ROUNDED─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──SIZE ERROR──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──────────────────> │ │ └─NOT───┬──────┬──SIZE ERROR──imperative-statement-2─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────┬──>< │ │ └─END-DIVIDE─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 3, the value of identifier-1 or literal-1 is divided by the value of identifier-2 or literal-2. This quotient is stored in each data item referenced by identifier-3. ═══ 12.21.4. DIVIDE Statement - Format 4 ═══ ┌─── DIVIDE STATEMENT - FORMAT 4 ──────────────────────────────────────────────┐ │ │ │ >>──DIVIDE──┬─identifier-1─┬──INTO──┬─identifier-2─┬───────────────────────> │ │ └─literal-1────┘ └─literal-2────┘ │ │ │ │ >──GIVING──identifier-3──┬─────────┬──REMAINDER──identifier-4──────────────> │ │ └─ROUNDED─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──SIZE ERROR──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──────────────────> │ │ └─NOT───┬──────┬──SIZE ERROR──imperative-statement-2─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────┬──>< │ │ └─END-DIVIDE─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 4, the value of identifier-1 or literal-1 is divided into identifier-2 or literal-2. This quotient is stored in identifier-3, and the value of the remainder is stored in identifier-4. ═══ 12.21.5. DIVIDE Statement - Format 5 ═══ ┌─── DIVIDE STATEMENT - FORMAT 5 ──────────────────────────────────────────────┐ │ │ │ >>──DIVIDE──┬─identifier-1─┬──BY──┬─identifier-2─┬─────────────────────────> │ │ └─literal-1────┘ └─literal-2────┘ │ │ │ │ >──GIVING──identifier-3──┬─────────┬──REMAINDER──identifier-4──────────────> │ │ └─ROUNDED─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──SIZE ERROR──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──────────────────> │ │ └─NOT───┬──────┬──SIZE ERROR──imperative-statement-2─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────┬──>< │ │ └─END-DIVIDE─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 5, the value of identifier-1 or literal-1 is divided by identifier-2 or literal-2. This quotient is stored in identifier-3, and the value of the remainder is stored in identifier-4. ═══ 12.22. DROP Statement ═══ -----IBM Extension----- The DROP statement releases a program device that has been acquired by a TRANSACTION file. ┌─── DROP STATEMENT - FORMAT ──────────────────────────────────────────────────┐ │ │ │ >>──DROP──┬─identifier─┬──FROM──file-name──>< │ │ └─literal────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Program devices specified in a DROP statement must have been acquired by the TRANSACTION file, either through an explicit ACQUIRE or through an implicit ACQUIRE at OPEN time. After successful execution of the DROP statement, the program device is no longer available for input or output operations through the TRANSACTION file. The device may be reacquired if necessary. The contents of the record area associated with a released program device are no longer available, even if the device is reacquired. If the DROP statement is unsuccessful, any applicable USE AFTER EXCEPTION/ERROR procedures are executed. The DROP statement can also be used as an aid in recovering from I-O errors. ---End of IBM Extension--- ═══ 12.23. ENTER Statement ═══ The ENTER statement allows the use of more than one source language in the same source program. It is syntax checked only. ┌─── ENTER STATEMENT - FORMAT ─────────────────────────────────────────────────┐ │ │ │ (1) │ │ >>──ENTER─────language-name──┬──────────────┬──.──>< │ │ └─routine-name─┘ │ │ │ │ NOTE: │ │ (1) Syntax-checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.24. EVALUATE Statement ═══ The EVALUATE statement provides a shorthand notation for a series of nested IF statements. It can evaluate multiple conditions. That is, the IF statements can be made up of compound conditions. The subsequent action of the object program depends on the results of these evaluations. ┌─── EVALUATE STATEMENT - FORMAT ──────────────────────────────────────────────┐ │ │ │ >>──EVALUATE──┬─identifier-1─┬──┬────────────────────────────┬─────────────> │ │ ├─literal-1────┤ │ ┌────────────────────────┐ │ │ │ │ │ │  │ │ │ │ ├─expression-1─┤ └───ALSO──┬─identifier-2─┬─┴─┘ │ │ ├─TRUE─────────┤ ├─literal-2────┤ │ │ └─FALSE────────┘ ├─expression-2─┤ │ │ ├─TRUE─────────┤ │ │ └─FALSE────────┘ │ │ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │ ┌──────────────────────────────────────────┐ │ │ │   │ │ │ │ >──────┤ WHEN phrase ├──┬─────────────────────┬─┴──imperative-stmt-1─┴─────> │ │ │ ┌─────────────────┐ │ │ │ │  │ │ │ │ └───┤ ALSO phrase ├─┴─┘ │ │ │ │ >──┬───────────────────────────────┬──┬──────────────┬──>< │ │ └─WHEN OTHER──imperative-stmt-2─┘ └─END-EVALUATE─┘ │ │ │ │ WHEN PHRASE: │ │ ├──WHEN────────────────────────────────────────────────────────────────────> │ │ │ │ >──┬─ANY───────────────────────────────────────────────────────────┬──┤ │ │ ├─condition-1───────────────────────────────────────────────────┤ │ │ ├─TRUE──────────────────────────────────────────────────────────┤ │ │ ├─FALSE─────────────────────────────────────────────────────────┤ │ │ └─┬──────┬──┬─identifier-3─┬──┬───────────────────────────────┬─┘ │ │ └─NOT──┘ ├─literal-3────┤ └─┬─THROUGH─┬──┬─identifier-4─┬─┘ │ │ └─arith-expr-1─┘ └─THRU────┘ ├─literal-4────┤ │ │ └─arith-expr-2─┘ │ │ │ │ ALSO PHRASE: │ │ ├──ALSO────────────────────────────────────────────────────────────────────> │ │ │ │ >──┬─ANY───────────────────────────────────────────────────────────┬──┤ │ │ ├─condition-2───────────────────────────────────────────────────┤ │ │ ├─TRUE──────────────────────────────────────────────────────────┤ │ │ ├─FALSE─────────────────────────────────────────────────────────┤ │ │ └─┬──────┬──┬─identifier-5─┬──┬───────────────────────────────┬─┘ │ │ └─NOT──┘ ├─literal-5────┤ └─┬─THROUGH─┬──┬─identifier-6─┬─┘ │ │ └─arith-expr-3─┘ └─THRU────┘ ├─literal-6────┤ │ │ └─arith-expr-4─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Related Information:  Simple Coding Example  Complex Coding Example  Interpreting Selection Subject (operands before the WHEN statement) and Selection Objects (operands in the WHEN statement)  Comparing Selection Subjects and Selection Objects  Executing the EVALUATE Statement ═══ 12.24.1. Simple Example of the EVALUATE Statement: ═══ EVALUATE MENU-INPUT WHEN "0" PERFORM INIT-PROC WHEN "1" THRU "9" PERFORM PROCESS-PROC WHEN "R" PERFORM READ-PARMS WHEN "X" PERFORM CLEANUP-PROC WHEN OTHER PERFORM ERROR-PROC END-EVALUATE. The Equivalent IF Statement: IF (MENU-INPUT = "0") THEN PERFORM INIT-PROC ELSE IF (MENU-INPUT >= "1") AND (MENU-INPUT =< "9") THEN PERFORM PROCESS-PROC ELSE IF (MENU-INPUT = "R") THEN PERFORM READ-PARMS ELSE IF (MENU-INPUT = "X") THEN PERFORM CLEANUP-PROC ELSE PERFORM ERROR-PROC END-IF END-IF END-IF END-IF. ═══ 12.24.2. Complex Example of the EVALUATE Statement: ═══ EVALUATE A = B ALSO C > D ALSO TRUE WHEN TRUE ALSO TRUE ALSO E = F + 15 imp-stat-1 WHEN TRUE ALSO TRUE ALSO E > 12 imp-stat-2 WHEN TRUE ALSO FALSE ALSO ANY imp-stat-3 WHEN FALSE ALSO TRUE ALSO ANY imp-stat-4 WHEN FALSE ALSO FALSE ALSO ANY imp-stat-5 END-EVALUATE. The Equivalent IF Statement: IF A = B THEN IF C > D THEN IF E = F + 15 THEN imp-stat-1 ELSE IF E > 12 THEN imp-stat-2 END-IF END-IF ELSE imp-stat-3 END-IF ELSE IF C > D THEN imp-stat-4 ELSE imp-stat-5 END-IF END-IF. ═══ 12.24.3. Interpreting Selection Subjects and Selection Objects ═══ Operands before the WHEN phrase  Individually, they are called selection subjects.  Collectively, they are called a set of selection subjects. Operands in the WHEN phrase  Individually, they are called selection objects.  Collectively, they are called a set of selection objects. The number of selection objects within each set of selection objects must be equal to the number of selection subjects. Each selection object within a set of selection objects must correspond to the selection subject having the same ordinal position within the set of selection subjects, according to the following rules:  Identifiers, literals, or arithmetic expressions appearing within a selection object must be valid operands for comparison to the corresponding operand in the set of selection subjects.  Condition-1, condition-2, or the word TRUE or FALSE appearing as a selection object must correspond to a conditional expression or the word TRUE or FALSE in the set of selection subjects.  Condition-1, and condition-2 may be any form of a conditional expression.  The word ANY may correspond to a selection subject of any type.  Conditional expressions may be simple or complex conditions. -----IBM Extension-----  Identifiers can reference items whose usage is implicitly or explicitly defined as POINTER or PROCEDURE-POINTER. ---End of IBM Extension--- ═══ 12.24.4. Comparing Selection Subjects and Objects ═══ The execution of the EVALUATE statement then proceeds as if the values assigned to the selection subjects and selection objects were compared to determine whether any WHEN phrase satisfies the set of selection subjects. This comparison proceeds as follows: 1. Each selection object within the set of selection objects for the first WHEN phrase is compared to the selection subject having the same ordinal position within the set of selection subjects. One of the following conditions must be satisfied if the comparison is to be satisfied: a) If the items being compared are assigned numeric or nonnumeric values, or a range of numeric or nonnumeric values, the comparison is satisfied if the value, or one value in the range of values, assigned to the selection object is equal to the value assigned to the selection subject, according to the rules for comparison. b) If the items being compared are assigned truth values, the comparison is satisfied if the items are assigned identical truth values. c) If the selection object being compared is specified by the word ANY, the comparison is always satisfied, regardless of the value of the selection subject. 2. If the above comparison is satisfied for every selection object within the set of selection objects being compared, the WHEN phrase containing that set of selection objects is selected as the one satisfying the set of selection subjects. 3. If the above comparison is not satisfied for every selection object within the set of selection objects being compared, that set of selection objects does not satisfy the set of selection subjects. 4. This procedure is repeated for subsequent sets of selection objects in the order of their appearance in the source program, until either a WHEN phrase satisfying the set of selection subjects is selected or until all sets of selection objects are exhausted. ═══ 12.24.5. Executing the EVALUATE Statement ═══ After the comparison operation is completed, execution of the EVALUATE statement proceeds as follows:  If a WHEN phrase is selected, execution continues with the first imperative-statement-1 following the selected WHEN phrase. Note that multiple WHEN statements are allowed for a single imperative-statement-1.  If no WHEN phrase is selected and a WHEN OTHER phrase is specified, execution continues with imperative-statement-2.  If no WHEN phrase is selected and no WHEN OTHER phrase is specified, execution continues with the next executable statement following the scope delimiter.  The scope of execution of the EVALUATE statement is terminated when execution reaches the end of the scope of the selected WHEN phrase or WHEN OTHER phrase, or when no WHEN phrase is selected and no WHEN OTHER phrase is specified. ═══ 12.25. EXIT Statement ═══ The EXIT statement provides a common end point for a series of paragraphs. ┌─── EXIT STATEMENT - FORMAT ──────────────────────────────────────────────────┐ │ │ │ >>──EXIT──>< │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The EXIT statement assigns a name to a given point in a program. The EXIT statement has no other effect on the compilation or execution of the program. The EXIT statement must be preceded by a paragraph-name and must appear in a sentence by itself. This sentence must be the only sentence in the paragraph. The EXIT statement is useful for documenting the end point in a series of paragraphs. If an EXIT paragraph is written as the last paragraph in a declarative procedure or a series of performed procedures, it identifies the point to which control is transferred:  When control reaches an EXIT paragraph that is the end of a range of procedures governed by an active PERFORM or USE statement, control is transferred in accordance with the rules for that PERFORM or USE statement.  When control reaches an EXIT paragraph that is not the end of a range of procedures governed by an active PERFORM or USE statement, control passes through the EXIT statement to the first statement of the next paragraph. Without an EXIT statement, the end of the sequence is difficult to determine, unless you know the logic of the program. ═══ 12.26. EXIT PROGRAM Statement ═══ The EXIT PROGRAM statement specifies the end of a called program and returns control to the calling program. It must not be used in the range of a global declarative unless it is in a different program called by the statement in the range of the global declarative. ┌─── EXIT PROGRAM STATEMENT - FORMAT ──────────────────────────────────────────┐ │ │ │ >>──EXIT PROGRAM──>< │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ If control reaches an EXIT PROGRAM statement in a program that does not possess the INITIAL attribute while operating under the control of a calling program, control returns to the CALL statement of the calling program. The program state of the calling program is identical to that which existed at the time it executed the CALL statement except that the contents of data items and the contents of the data files shared between the two programs may have been changed. The program state of the called program is not altered except that the ends of the ranges of all PERFORM statements executed by that called program are considered to have been reached. The execution of an EXIT PROGRAM statement in a called program that possesses the INITIAL attribute performs an implicit CANCEL of the referenced program. If control reaches an EXIT PROGRAM statement in the main program, control passes through the exit point to the next executable statement. The EXIT PROGRAM statement should appear as the last statement in a series of imperative statements within a sentence. When there is no next executable statement in a called program, an implicit EXIT PROGRAM statement is assumed, and executed. The RETURN-CODE special register can be used to pass return code information from a program to its caller. See RETURN-CODE Special Register for further information. ═══ 12.27. GOBACK Statement ═══ -----IBM Extension----- The GOBACK statement functions like the EXIT PROGRAM statement when it is coded as part of a program that is a subprogram in a COBOL run unit, and like the STOP RUN statement when coded in a program that is a main program in a COBOL run unit. The GOBACK statement specifies the logical end of a called program. ┌─── GOBACK STATEMENT - FORMAT ────────────────────────────────────────────────┐ │ │ │ >>──GOBACK──>< │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ A GOBACK statement should appear as the only statement, or as the last of a series of imperative statements, in a sentence because statements following the GOBACK statement are not executed. If control reaches a GOBACK statement while a CALL statement is active, control returns to the point in the calling program immediately following the CALL statement, as in the EXIT PROGRAM statement. The RETURN-CODE special register can be used to pass return code information before executing a GOBACK statement. See RETURN-CODE Special Register. ---End of IBM Extension--- ═══ 12.28. GO TO Statement ═══ The GO TO statement transfers control from one part of the Procedure Division to another. The GOTO statement has three formats:  Format 1 - Unconditional  Format 2 - Conditional  Format 3 - Altered If procedure-name or procedure-name-1 are within a declarative procedure, neither can reference another declarative procedure or any nondeclarative procedure. In the nondeclarative portion of the program, there must be no reference to procedure-names that appear in an EXCEPTION/ERROR declarative procedure, except that PERFORM statements may refer to an EXCEPTION/ERROR procedure or procedures associated with it. ═══ 12.28.1. Unconditional GO TO ═══ An unconditional GO TO statement transfers control to the first statement in the paragraph or section named in procedure-name, unless the GO TO statement has been modified by an ALTER statement. (See ALTER Statement.) ┌─── GO TO STATEMENT - FORMAT 1 - UNCONDITIONAL ───────────────────────────────┐ │ │ │ >>──GO──┬────┬──procedure-name──>< │ │ └─TO─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ An unconditional GO TO statement, when it appears in a sequence of imperative statements, must be the last statement in the sequence. When a paragraph is referred to by an ALTER statement, the paragraph must consist of a paragraph-name followed by an unconditional or altered GO TO statement. ═══ 12.28.2. Conditional GO TO ═══ The conditional GO TO statement transfers control to one of a series of procedures, depending on the value of the data item referenced by the identifier. ┌─── GO TO STATEMENT - FORMAT 2 - CONDITIONAL ─────────────────────────────────┐ │ │ │ ┌──────────────────┐ │ │  │ │ │ >>──GO──┬────┬────procedure-name-1─┴──DEPENDING──┬────┬──identifier──>< │ │ └─TO─┘ └─ON─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.28.3. Altered GO TO ═══ The altered GO TO statement transfers control to the first statement of the paragraph named in the ALTER statement. An ALTER statement referring to the paragraph containing this GO TO statement must have been executed before this GO TO statement is executed. ┌─── GO TO STATEMENT - FORMAT 3 - ALTERED ─────────────────────────────────────┐ │ │ │ >>──GO──┬────┬──.──>< │ │ └─TO─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ When an ALTER statement refers to a paragraph, the paragraph may consist only of the paragraph-name followed by an unconditional or altered GO TO statement. ═══ 12.29. IF Statement ═══ The IF statement evaluates a condition and provides for alternative actions in the object program, depending on the evaluation. ┌─── IF STATEMENT - FORMAT ────────────────────────────────────────────────────┐ │ │ │ >>──IF──condition──┬──────┬────────────────────────────────────────────────> │ │ └─THEN─┘ │ │ │ │ ┌───────────────┐ │ │  │ │ │ >──┬─┬────statement-1──┴─┬──┬─────────────────────────────┬─────┬──>< │ │ │ └─NEXT SENTENCE─────┘ │ ┌───────────────┐ │ │ │ │ │ │  │ │ │ │ │ │ └─ELSE──┬────statement-2──┴─┬─┘ │ │ │ │ └─NEXT SENTENCE─────┘ │ │ │ │ ┌───────────────┐ ┌───────────────┐ │ │ │ │  │  │ │ │ │ └────statement-1──┴──┬─ELSE─────statement-2──┴──┬────────┬─┬─┘ │ │ │ └─END-IF─┘ │ │ │ └─END-IF──────────────────────────────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The scope of an IF statement can be terminated by any of the following:  An END-IF phrase at the same level of nesting  A separator period  If nested, by an ELSE phrase associated with an IF statement at a higher level of nesting Related Information:  Transferring Control  Nested IF Statements ═══ 12.29.1. Transferring Control ═══ If the condition tested is true, one of the following actions takes place:  Statement-1, if specified, is executed. If statement-1 contains a procedure branching statement, control is transferred, according to the rules for that statement. If statement-1 does not contain a procedure-branching statement, the ELSE phrase, if specified, is ignored, and control passes to the next executable statement after the corresponding (implicit or explicit) END-IF or separator period.  NEXT SENTENCE, if specified, is executed; that is, the ELSE phrase, if specified, is ignored, and control passes to the statement following the closest separator period. If the condition tested is false, one of the following actions takes place:  ELSE statement-2, if specified, is executed. If statement-2 contains a procedure-branching statement, control is transferred, according to the rules for that statement. If statement-2 does not contain a procedure-branching statement, control is passed to the next executable statement after the corresponding END-IF or separator period.  ELSE NEXT SENTENCE, if specified, is executed and control passes to the statement following the closest separator period.  If ELSE NEXT SENTENCE is omitted, control passes to the next executable statement after the corresponding END-IF or separator period. Note: When ELSE or ELSE NEXT SENTENCE are omitted, all statements following the condition and preceding the corresponding END-IF or the separator period for the sentence are considered to be part of statement-1. ═══ 12.29.2. Nested IF Statements ═══ The presence of one or more IF statements within the initial IF statement constitutes a "nested IF statement". Nesting statements is much like specifying subordinate arithmetic expressions enclosed in parentheses and combined in larger arithmetic expressions. IF statements contained within IF statements are considered as paired IF, ELSE, and END-IF combinations, proceeding from left to right. Thus, any ELSE or END-IF encountered is considered to apply to the immediately preceding IF that has not been already paired with an ELSE or END-IF. ═══ 12.30. INITIALIZE Statement ═══ The INITIALIZE statement sets selected categories of data fields to predetermined values. It is functionally equivalent to one or more MOVE statements. ┌─── INITIALIZE STATEMENT - FORMAT ────────────────────────────────────────────┐ │ │ │ ┌──────────────┐ │ │  │ │ │ >>──INITIALIZE────identifier-1─┴───────────────────────────────────────────> │ │ │ │ >──┬───────────────────────────────────────────────────────┬──>< │ │ │ ┌────────────────────────────────────────┐ │ │ │ │  │ │ │ │ └─REPLACING────┬─ALPHABETIC──────────┬──┤ BY Phrase ├─┴─┘ │ │ ├─ALPHANUMERIC────────┤ │ │ ├─NUMERIC─────────────┤ │ │ ├─ALPHANUMERIC-EDITED─┤ │ │ └─NUMERIC-EDITED──────┘ │ │ │ │ BY PHRASE: │ │ ├──┬──────┬──BY──┬─identifier-2─┬──┤ │ │ └─DATA─┘ └─literal-1────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Identifier-1 can be a subscripted or reference-modified item. A complete table can be initialized if identifier-1 is a group item that contains the complete table. Neither identifier-1 nor any item subordinate to it may contain the DEPENDING ON phrase of the OCCURS clause. The data description entry for identifier-1 must not contain a RENAMES clause. An index data item may not be an operand of INITIALIZE. Related Information:  INITIALIZE Statement Rules ═══ 12.30.1. REPLACING Phrase ═══ When the REPLACING phrase is used:  The category of identifier-2 or literal-1 must be compatible with the category indicated in the corresponding REPLACING phrase, according to the rules for MOVE.  The same category cannot be repeated in a REPLACING phrase.  The keyword following the word REPLACING corresponds to a category of data shown in Classes and Categories of Data. When the REPLACING phrase is not used:  SPACE is the implied sending field for alphabetic, alphanumeric, and alphanumeric-edited items.  ZERO is the implied sending field for numeric, and numeric-edited items. ═══ 12.30.2. INITIALIZE Statement Rules ═══ 1. Whether identifier-1 references an elementary or group item, all operations are performed as if a series of MOVE statements had been written, each of which had an elementary item as a receiving field. If the REPLACING phrase is specified:  If identifier-1 references a group item, any elementary item within the data item referenced by identifier-1 is initialized only if it belongs to the category specified in the REPLACING phrase.  If identifier-1 references an elementary item, that item is initialized only if it belongs to the category specified in the REPLACING phrase. This initialization takes place as if the data item referenced by identifier-2 or literal-1 acts as the sending operand in an implicit MOVE statement to the identified item. All such elementary receiving fields, including all occurrences of table items within the group, are affected, with the following exceptions:  Index, pointer, and procedure-pointer data items  Elementary FILLER data items  Items that are subordinate to identifier-1 and contain a REDEFINES clause, or any items subordinate to such an item. (However, identifier-1 may contain a REDEFINES clause or be subordinate to a redefining item.)  BOOLEAN data items. 2. The areas referenced by identifier-1 are initialized in the order (left to right) of the appearance of identifier-1 in the statement. Within a group receiving field, affected elementary items are initialized in the order of their definition within the group. 3. If identifier-1 occupies the same storage area as identifier-2, the result of the execution of this statement is undefined, even if these operands are defined by the same data description entry. 4. If identifier-1 is a group item, then all of the items within that group item are considered as being referenced in the program. ═══ 12.31. INSPECT Statement ═══ The INSPECT statement specifies that characters in a data item are to be counted (tallied), or replaced (or both).  It will count the occurrence of a specific character (alphabetic, numeric, or special character) in a data item.  It will fill all or portions of a data item with spaces or zeros.  It will translate characters from one collating sequence to another. The INSPECT statement has four formats:  Format 1 - INSPECT TALLYING  Format 2 - INSPECT REPLACING  Format 3 - INSPECT TALLYING REPLACING  Format 4 - INSPECT CONVERTING Related Information:  INSPECT Statement Considerations  Comparison Rules  Examples ═══ 12.31.1. INSPECT Statement - Format 1 ═══ ┌─── INSPECT STATEMENT - FORMAT 1 ─────────────────────────────────────────────┐ │ │ │ >>──INSPECT──identifier-1──TALLYING────────────────────────────────────────> │ │ │ │ ┌─────────────────────────────────────────────────────────────┐ │ │ │ ┌──────────────────────────────────────┐ │ │ │ │ │ ┌──────────────────┐ │ │ │ │    │ │ │ │ │ >────identifier-2──FOR────┬─CHARACTERS────┬──────────────┬─┴─┬─┴─┴──>< │ │ │ └─┤ phrase 1 ├─┘ │ │ │ │ ┌──┴──────────┴┐ │ │ │ │  │ │ │ │ └─┬─ALL─────┬────┤ phrase 2 ├─┴────┘ │ │ └─LEADING─┘ │ │ │ │ PHRASE 1: │ │ ├──┬─BEFORE─┬──┬─────────┬──┬─identifier-4─┬──┤ │ │ └─AFTER──┘ └─INITIAL─┘ └─literal-2────┘ │ │ │ │ PHRASE 2: │ │ ┌───────────────────────────────────────────────┐ │ │  │ │ │ ├──┬─identifier-3─┬────┬───────────────────────────────────────────┬─┴──┤ │ │ └─literal-1────┘ └─┬─BEFORE─┬──┬─────────┬──┬─identifier-4─┬─┘ │ │ └─AFTER──┘ └─INITIAL─┘ └─literal-2────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.31.2. INSPECT Statement - Format 2 ═══ ┌─── INSPECT STATEMENT - FORMAT 2 ─────────────────────────────────────────────┐ │ │ │ >>──INSPECT──identifier-1──REPLACING───────────────────────────────────────> │ │ │ │ ┌───────────────────────────────────────────────────────────┐ │ │ │ ┌──────────────────┐ │ │ │   │ │ │ │ >────┬─CHARACTERS BY──┬─identifier-5─┬────┬──────────────┬─┴─┬─┴──>< │ │ │ └─literal-3────┘ └─┤ phrase 1 ├─┘ │ │ │ │ ┌──────────────┐ │ │ │ │  │ │ │ │ └─┬─ALL─────┬────┤ phrase 2 ├─┴─────────────────────────┘ │ │ ├─LEADING─┤ │ │ └─FIRST───┘ │ │ │ │ PHRASE 1: │ │ ├──┬─BEFORE─┬──┬─────────┬──┬─identifier-4─┬──┤ │ │ └─AFTER──┘ └─INITIAL─┘ └─literal-2────┘ │ │ │ │ PHRASE 2: │ │ ├──┬─identifier-3─┬──BY──┬─identifier-5─┬──────────────────────────────────> │ │ └─literal-1────┘ └─literal-3────┘ │ │ │ │ ┌───────────────────────────────────────────────┐ │ │  │ │ │ >────┬───────────────────────────────────────────┬─┴──┤ │ │ └─┬─BEFORE─┬──┬─────────┬──┬─identifier-4─┬─┘ │ │ └─AFTER──┘ └─INITIAL─┘ └─literal-2────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.31.3. INSPECT Statement - Format 3 ═══ ┌─── INSPECT STATEMENT - FORMAT 3 ─────────────────────────────────────────────┐ │ │ │ >>──INSPECT──identifier-1──TALLYING────────────────────────────────────────> │ │ │ │ ┌─────────────────────────────────────────────────────────────┐ │ │ │ ┌──────────────────────────────────────┐ │ │ │ │ │ ┌──────────────────┐ │ │ │ │    │ │ │ │ │ >────identifier-2──FOR────┬─CHARACTERS────┬──────────────┬─┴─┬─┴─┴─────────> │ │ │ └─┤ phrase 1 ├─┘ │ │ │ │ ┌──┴──────────┴┐ │ │ │ │  │ │ │ │ └─┬─ALL─────┬────┤ phrase 2 ├─┴────┘ │ │ └─LEADING─┘ │ │ │ │ >──REPLACING───────────────────────────────────────────────────────────────> │ │ │ │ ┌───────────────────────────────────────────────────────────┐ │ │ │ ┌──────────────────┐ │ │ │   │ │ │ │ >────┬─CHARACTERS BY──┬─identifier-5─┬────┬──────────────┬─┴─┬─┴──>< │ │ │ └─literal-3────┘ └─┤ phrase 1 ├─┘ │ │ │ │ ┌──────────────┐ │ │ │ │  │ │ │ │ └─┬─ALL─────┬────┤ phrase 3 ├─┴─────────────────────────┘ │ │ ├─LEADING─┤ │ │ └─FIRST───┘ │ │ │ │ PHRASE 1: │ │ ├──┬─BEFORE─┬──┬─────────┬──┬─identifier-4─┬──┤ │ │ └─AFTER──┘ └─INITIAL─┘ └─literal-2────┘ │ │ │ │ PHRASE 2: │ │ ┌───────────────────────────────────────────────┐ │ │  │ │ │ ├──┬─identifier-3─┬────┬───────────────────────────────────────────┬─┴──┤ │ │ └─literal-1────┘ └─┬─BEFORE─┬──┬─────────┬──┬─identifier-4─┬─┘ │ │ └─AFTER──┘ └─INITIAL─┘ └─literal-2────┘ │ │ │ │ PHRASE 3: │ │ ├──┬─identifier-3─┬──BY──┬─identifier-5─┬──────────────────────────────────> │ │ └─literal-1────┘ └─literal-3────┘ │ │ │ │ ┌───────────────────────────────────────────────┐ │ │  │ │ │ >────┬───────────────────────────────────────────┬─┴──┤ │ │ └─┬─BEFORE─┬──┬─────────┬──┬─identifier-4─┬─┘ │ │ └─AFTER──┘ └─INITIAL─┘ └─literal-2────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.31.4. INSPECT Statement - Format 4 ═══ ┌─── INSPECT STATEMENT - FORMAT 4 ─────────────────────────────────────────────┐ │ │ │ >>──INSPECT──identifier-1──CONVERTING──┬─identifier-6─┬──TO────────────────> │ │ └─literal-4────┘ │ │ │ │ ┌───────────────────────────────────────────────┐ │ │  │ │ │ >──┬─identifier-7─┬────┬───────────────────────────────────────────┬─┴──>< │ │ └─literal-5────┘ └─┬─BEFORE─┬──┬─────────┬──┬─identifier-4─┬─┘ │ │ └─AFTER──┘ └─INITIAL─┘ └─literal-2────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.31.5. INSPECT Statement Considerations ═══ Except when the BEFORE or AFTER phrase is specified, inspection begins at the leftmost character position of the inspected item (identifier-1) and proceeds character-by-character to the rightmost position. The operands of the following phrases are compared in the left-to-right order in which they are specified in the INSPECT statement:  TALLYING (literal-1 or identifier-3, . . . )  REPLACING (literal-3 or identifier-5, . . . ) If any identifier is subscripted or reference modified, the subscript or reference modifier is evaluated only once as the first operation in the execution of the INSPECT statement. ═══ 12.31.6. Comparison Rules ═══ 1. When both the TALLYING and REPLACING phrases are specified, the INSPECT statement is executed as if an INSPECT TALLYING statement were specified, immediately followed by an INSPECT REPLACING statement. 2. The first comparand is compared with an equal number of leftmost contiguous characters in the inspected item. The comparand matches the inspected characters only if both are equal, character-for-character. 3. If no match occurs for the first comparand, the comparison is repeated for each successive comparand until either a match is found or all comparands have been acted upon. 4. If a match is found, tallying or replacing takes place, as described in the following TALLYING/REPLACING phrase descriptions. In the inspected item, the first character following the rightmost matching character is now considered to be in the leftmost character position. The process described in rules 2 and 3 is then repeated. 5. If no match is found, then, in the inspected item, the first character following the leftmost inspected character is now considered to be in the leftmost character position. The process described in rules 2 and 3 is then repeated. 6. If the CHARACTERS phrase is specified, an implied one-character item is used in the process described in rules 2 and 3. The implied character is always considered to match the inspected character in the inspected item. 7. The actions taken in rules 1 through 6 (defined as the comparison cycle) are repeated until the rightmost character in the inspected item has either been matched or has been considered as being in the leftmost character position. Inspection is then terminated. When the BEFORE or AFTER phrase is specified, the preceding rules are modified as described in BEFORE and AFTER Phrases (All Formats). ═══ 12.31.7. TALLYING Phrase (Formats 1 and 3) ═══ When neither the BEFORE nor AFTER phrase is specified, the following actions take place when the INSPECT TALLYING statement is executed:  If ALL is specified, the count field is increased by 1 for each non-overlapping occurrence in the inspected item of this tallying operand, beginning at the leftmost character position and continuing to the rightmost.  If LEADING is specified, the count field is increased by 1 for each contiguous non-overlapping occurrence of this tallying operand in the inspected item, provided that the leftmost such occurrence is at the point where comparison began in the first comparison cycle for which this tallying operand is eligible to participate.  If CHARACTERS is specified, the count field is increased by 1 for each character (including the space character) in the inspected item. Thus, execution of the INSPECT TALLYING statement increases the value in the count field by the number of characters in the inspected item. ═══ 12.31.8. REPLACING Phrase (Formats 2 and 3) ═══ The subject field and the substitution field must have the same length. The following replacement rules apply:  If the subject field is a figurative constant, it is considered to be a 1-character nonnumeric literal. Each character in the inspected item equivalent to the figurative constant is replaced by the single-character substitution field, which must be 1 character in length.  If the substitution field is a figurative constant, the substitution field is considered to be the same length as the subject field. Each non-overlapping occurrence of the subject field in the inspected item is replaced by the substitution field.  When the subject and substitution fields are character-strings, each non-overlapping occurrence of the subject field in the inspected item is replaced by the character-string specified in the substitution field.  Once replacement has occurred in a given character position in the inspected item, no further replacement for that character position is made in this execution of the INSPECT statement. When the CHARACTERS phrase is used, literal-3 or identifier-5 must be 1 character in length, and literal-2 or identifier-4 must be 1 character in length. When neither the BEFORE nor AFTER phrase is specified, the following actions take place when the INSPECT REPLACING statement is executed:  If CHARACTERS is specified, the substitution field must be 1 character in length. Each character in the inspected field is replaced by the substitution field, beginning at the leftmost character and continuing to the rightmost.  If ALL is specified, each non-overlapping occurrence of the subject field in the inspected item is replaced by the substitution field, beginning at the leftmost character and continuing to the rightmost.  If LEADING is specified, each contiguous non-overlapping occurrence of the subject field in the inspected item is replaced by the substitution field, provided that the leftmost such occurrence is at the point where comparison began in the first comparison cycle for which this substitution field is eligible to participate.  If FIRST is specified, the leftmost occurrence of the subject field in the inspected item is replaced by the substitution field. ═══ 12.31.9. BEFORE and AFTER Phrases (All Formats) ═══ No more than one BEFORE phrase and one AFTER phrase can be specified for any one ALL, LEADING, CHARACTERS, FIRST or CONVERTING phrase. When these phrases are specified, the preceding rules for counting and replacing are modified. When BEFORE is specified, counting and/or replacing of the inspected item begins at the leftmost character and continues until the first occurrence of the delimiter is encountered. If no delimiter is present in the inspected item, counting and/or replacing continues toward the rightmost character. When AFTER is specified, counting and/or replacing of the inspected item begins with the first character to the right of the delimiter and continues toward the rightmost character in the inspected item. If no delimiter is present in the inspected item, no counting or replacement takes place. ═══ 12.31.10. CONVERTING Phrase (Format 4) ═══ A string of replacement values may be expressed by this phrase. The size of the receiving location (identifier-7 or literal-5) must be the same size as the sending location (identifier-6 or literal-4). When a figurative constant is used as literal-5, the size of the figurative constant is equal to the size of literal-4 or identifier-6. The same character must not appear more than once either in literal-4 or identifier-6. A Format 4 INSPECT statement is interpreted and executed as if a Format 2 INSPECT statement had been written with a series of ALL phrases (one for each character of literal-4), specifying the same identifier-1. The effect is as if each single character of literal-4 were referenced as literal-1, and the corresponding single character of literal-5 referenced as literal-3. Correspondence between the characters of literal-4 and the characters of literal-5 is by ordinal position within the data item. If identifier-4, identifier-6, or identifier-7 occupies the same storage area as identifier-1, the result of the execution of this statement is undefined, even if they are defined by the same data description entry. ═══ 12.31.11. INSPECT Statement Examples ═══ The following examples illustrate some uses of the INSPECT statement. In all instances, the programmer has initialized the COUNTR field to zero before the INSPECT statement is executed. INSPECT ID-1 REPLACING CHARACTERS BY ZERO. ┌────────────────────┬────────────────────┬────────────────────┐ │ ID-1 BEFORE │ COUNTR AFTER │ ID-1 AFTER │ ├────────────────────┼────────────────────┼────────────────────┤ │ 1234567 │ 0 │ 0000000 │ ├────────────────────┼────────────────────┼────────────────────┤ │ HIJKLMN │ 0 │ 0000000 │ └────────────────────┴────────────────────┴────────────────────┘ INSPECT ID-1 TALLYING COUNTR FOR CHARACTERS REPLACING CHARACTERS BY SPACES. ┌────────────────────┬────────────────────┬────────────────────┐ │ ID-1 BEFORE │ COUNTR AFTER │ ID-1 AFTER │ ├────────────────────┼────────────────────┼────────────────────┤ │ 1234567 │ 7 │ │ ├────────────────────┼────────────────────┼────────────────────┤ │ HIJKLMN │ 7 │ │ └────────────────────┴────────────────────┴────────────────────┘ INSPECT ID-1 REPLACING CHARACTERS BY ZEROS BEFORE INITIAL QUOTE. ┌────────────────────┬────────────────────┬────────────────────┐ │ ID-1 BEFORE │ COUNTR AFTER │ ID-1 AFTER │ ├────────────────────┼────────────────────┼────────────────────┤ │ 456"ABEL │ 0 │ 000"ABEL │ ├────────────────────┼────────────────────┼────────────────────┤ │ ANDES"12 │ 0 │ 00000"12 │ ├────────────────────┼────────────────────┼────────────────────┤ │ "TWAS BR │ 0 │ "TWAS BR │ └────────────────────┴────────────────────┴────────────────────┘ INSPECT ID-1 TALLYING COUNTR FOR CHARACTERS AFTER INITIAL "S" REPLACING ALL "A" BY "O". ┌────────────────────┬────────────────────┬────────────────────┐ │ ID-1 BEFORE │ COUNTR AFTER │ ID-1 AFTER │ ├────────────────────┼────────────────────┼────────────────────┤ │ ANSELM │ 3 │ ONSELM │ ├────────────────────┼────────────────────┼────────────────────┤ │ SACKET │ 5 │ SOCKET │ ├────────────────────┼────────────────────┼────────────────────┤ │ PASSED │ 3 │ POSSED │ └────────────────────┴────────────────────┴────────────────────┘ INSPECT ID-1 TALLYING COUNTR FOR LEADING "0" REPLACING FIRST "A" BY "2" AFTER INITIAL "C". ┌────────────────────┬────────────────────┬────────────────────┐ │ ID-1 BEFORE │ COUNTR AFTER │ ID-1 AFTER │ ├────────────────────┼────────────────────┼────────────────────┤ │ 00ACADEMY00 │ 2 │ 00AC2DEMY00 │ ├────────────────────┼────────────────────┼────────────────────┤ │ 0000ALABAMA │ 4 │ 0000ALABAMA │ ├────────────────────┼────────────────────┼────────────────────┤ │ CHATAM0000 │ 0 │ CH2THAM0000 │ └────────────────────┴────────────────────┴────────────────────┘ INSPECT ID-1 CONVERTING "ABCD" TO "XYZX" AFTER QUOTE BEFORE "#". ┌─────────────────────────────┬─────────────────────────────┐ │ ID-1 BEFORE │ ID-1 AFTER │ ├─────────────────────────────┼─────────────────────────────┤ │ AC"AEBDFBCD#AB"D │ AC"XEYXFYZX#AB"D │ └─────────────────────────────┴─────────────────────────────┘ ═══ 12.32. MERGE Statement ═══ The MERGE statement combines two or more identically sequenced files (that is, files that have already been sorted according to an identical set of ascending/descending keys) on one or more keys and makes records available in merged order to an output procedure or output file. A MERGE statement may appear anywhere in the Procedure Division except in a Declarative Section. The maximum number of USING or GIVING files is 32. -----IBM Extension----- It is not necessary to sequence input files prior to a merge operation. ---End of IBM Extension--- ┌─── MERGE STATEMENT - FORMAT ─────────────────────────────────────────────────┐ │ │ │ >>──MERGE──file-name-1─────────────────────────────────────────────────────> │ │ │ │ ┌───────────────────────────────────────────────────┐ │ │ │ ┌─────────────┐ │ │ │   │ │ │ │ >────┬────┬──┬─ASCENDING──┬──┬──────┬────data-name-1─┴─┴───────────────────> │ │ └─ON─┘ └─DESCENDING─┘ └─KEY──┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──────────────────────> │ │ └─┬───────────┬──SEQUENCE──┬────┬──alphabet-name─┘ │ │ └─COLLATING─┘ └─IS─┘ │ │ │ │ ┌─────────────┐ │ │  │ │ │ >──USING──file-name-2────file-name-3─┴──┬─┤ OUTPUT PROCEDURE Phrase ├─┬──>< │ │ │ ┌─────────────┐ │ │ │ │  │ │ │ │ └─GIVING────file-name-4─┴─────┘ │ │ │ │ OUTPUT PROCEDURE PHRASE: │ │ ├──OUTPUT PROCEDURE──┬────┬──procedure-name-1──────────────────────────────> │ │ └─IS─┘ │ │ │ │ >──┬───────────────────────────────┬──┤ │ │ └─┬─THROUGH─┬──procedure-name-2─┘ │ │ └─THRU────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ When the MERGE statement is executed, all records contained in file-name-2, file-name-3, . . . are accepted by the merge program and then merged according to the key(s) specified. Null-capable fields are supported, but null values are not. Null values result in a file status of 90. Related Information:  SORT-RETURN Special Register ═══ 12.32.1. ASCENDING/DESCENDING KEY Phrase ═══ This phrase specifies that records are to be processed in an ascending or descending sequence (depending on the phrase specified), based on the specified merge keys. Data-name-1 specifies the KEY data item on which the merge is based. Each such data-name identifies a data item in a record associated with file-name-1. The data-names following the word KEY are listed from left to right in the MERGE statement in order of decreasing significance without regard to how they are divided into KEY phrases. The left-most data-name is the major key, the next data-name is the next most significant key, and so forth. The following rules apply:  A specific KEY data item must be physically located in the same position and have the same data format in each input file; however, it need not have the same data-name.  If file-name-1 has more than one record description, the KEY data items need be described in only one of the record descriptions.  If file-name-1 contains variable-length records, all of the KEY data-items must be contained within the first n character positions of the record, where n equals the minimum record size specified for file-name-1.  KEY data items must not contain an OCCURS clause or be subordinate to an item that contains an OCCURS clause.  KEY data items can be qualified, but they cannot be subscripted or indexed. -----IBM Extension-----  KEY data items can be reference modified, but they cannot be subscripted or indexed. ---End of IBM Extension---  The total length (in bytes) of the KEY data items must not exceed 2 000  Variable length fields can not be used in a MERGE key as a variable length field. Variable length fields are converted into group items by ILE COBOL/400. Since variable length fields are converted into group items, they are compared as alphanumeric data items when used in a MERGE key.  Date, time, and timestamp fields can not be used as part of a MERGE key as date, time, and timestamp fields. In ILE COBOL/400, date, time, and timestamp fields are converted to alphanumeric data items. They are compared as alphanumeric data items when used in a MERGE key. The direction of the merge operation depends on the specification of the ASCENDING or DESCENDING keywords as follows:  When ASCENDING is specified, the sequence is from the lowest key value to the highest key value.  When DESCENDING is specified, the sequence is from the highest key value to the lowest.  If the KEY data item is alphabetic, alphanumeric, alphanumeric-edited, or numeric-edited, the sequence of key values depends on the collating sequence used (see COLLATING SEQUENCE Phrase below). The key comparisons are performed according to the rules for comparison of operands in a relation condition (see Relation Condition). ═══ 12.32.2. COLLATING SEQUENCE Phrase ═══ This phrase specifies the collating sequence to be used in nonnumeric comparisons for the KEY data items in this merge operation. When the COLLATING SEQUENCE phrase is omitted, the PROGRAM COLLATING SEQUENCE clause (if specified) in the OBJECT-COMPUTER paragraph specifies the collating sequence to be used. When both the COLLATING SEQUENCE phrase and the PROGRAM COLLATING SEQUENCE clause are omitted, the EBCDIC collating sequence is used. ═══ 12.32.3. USING Phrase ═══ file-name-2, file-name-3, ... Specifies input files. When the USING phrase is specified, all the records on file-name-2, file-name-3,... (that is, the input files) are transferred automatically to file-name-1. At the time the MERGE statement is executed, these files must not be open; the compiler generates code that opens, reads and closes the input files automatically. If EXCEPTION/ERROR procedures are specified for these files, the COBOL compiler makes the necessary linkage to these procedures. All input files must be described in an FD entry in the Data Division, and their record descriptions must describe records of the same size as the record described for the merge file. If the elementary items that make up these records are not identical, input records must have an equal number of character positions as the merge record. The input files must have sequential, relative or indexed organization. If file-name-1 contains variable length records, the size of the records contained in the input files must be no less than the smallest record nor greater than the largest record described for file-name-1. If file-name-1 contains fixed-length records, the size of the records contained in the input files must be no greater than the largest record described for file-name-1. ═══ 12.32.4. GIVING Phrase ═══ file-name-4, ... Specifies input files. When the GIVING phrase is specified, all the merged records in file-name-1 are automatically transferred to the output file (file-name-4). At the start of execution of the MERGE statement, the file referenced by file-name-4 must not be open. For each of the files referenced by file-name-4, the execution of the MERGE statement causes the following actions to be taken: 1. The processing of the file is initiated. The initiation is performed as if an OPEN statement with the OUTPUT phrase had been executed. 2. The merged logical records are returned and written onto the file. Each record is written as if a WRITE statement without any optional phrases had been executed. The records overwrite the previous contents, if any, of the file. -----IBM Extension----- If file-name-1 is a logical database file, the records are added to the end of the file. ---End of IBM Extension--- If the file referenced by file-name-4 is an INDEXED file then the associated key data-name for that file must have an ASCENDING KEY phrase in the merge statement. This same data-name must occupy the identical character positions in its record as the data item associated with the prime record key for the file. For a relative file, the relative key data item for the first record returned contains the value '1'; for the second record returned, the value '2', and so on. After execution of the MERGE statement, the content of the relative key data item indicates the last record returned to the file. 3. The processing of the file is terminated, as if a CLOSE statement without optional phrases had been executed. Note: When duplicate keys are found when writing to an indexed file, the MERGE will terminate and the merged data in all GIVING files will be incomplete. These implicit functions are performed such that any associated USE AFTER EXCEPTION/ERROR procedures are executed; however, the execution of such a USE procedure must not cause the execution of any statement manipulating the file referenced by, or accessing the record area associated with, file-name-4. On the first attempt to write beyond the externally defined boundaries of the file, any USE AFTER STANDARD EXCEPTION/ERROR procedure specified for the file is executed. If control is returned from that USE procedure or if no such USE procedure is specified, the processing of the file is terminated. The output file must be described in an FD entry in the Data Division, and its record description(s) must describe records of the same size as the record described for the merge file. If the elementary items that make up these records are not identical, the output record must have an equal number of character positions as the merge record. The output file must have a sequential, relative or indexed organization. The output file should be created without a keyed sequence access path. Otherwise, the MERGE statement cannot override the collating sequence defined in the data description specifications (DDS). If the output files (file-name-4) contain variable-length records, the size of the records contained in file-name-1 must be no less than the largest record described in the output files. If the output files contain fixed-length records, the size of the records contained in file-name-1 must be no greater than the largest record described for the output files. ═══ 12.32.5. OUTPUT PROCEDURE Phrase ═══ This phrase specifies the name of a procedure that is to select or modify output records from the merge operation. The OUTPUT PROCEDURE can consist of any procedure needed to select, modify, or copy the records that are made available one at a time by the RETURN statement in merged order from the file referenced by file-name-1. The range includes all statements that are executed as the result of a transfer of control by CALL, EXIT, GO TO, and PERFORM statements in the range of the output procedure. The range also includes all statements in declarative procedures that are executed as a result of the execution of statements in the range of the output procedure. The range of the output procedure must not cause the execution of any MERGE, RELEASE, or SORT statement. If an output procedure is specified, control passes to it after the file referenced by file-name-1 has been sequenced by the MERGE statement. Note: The OUTPUT PROCEDURE phrase is similar to a basic PERFORM statement. For example, if you name a procedure in an OUTPUT PROCEDURE, that procedure is executed during the merging operation just as if it were named in a PERFORM statement. As with the PERFORM statement, execution of the procedure is terminated after the last statement completes execution. The last statement in an OUTPUT PROCEDURE can be the EXIT statement (see EXIT Statement). ═══ 12.32.6. SORT-RETURN Special Register ═══ -----IBM Extension----- The SORT-RETURN special register is the name of a binary data item and is available to both sort and merge programs. The SORT-RETURN special register has the implicit definition: 01 SORT-RETURN GLOBAL PICTURE S9(4) USAGE BINARY VALUE ZERO. When used in nested programs, the SORT-RETURN special register is implicitly defined as GLOBAL in the outermost COBOL program. The SORT-RETURN special register contains a return code of 0 (successful) or 16 (unsuccessful) at the completion of a sort/merge operation. You can set the SORT-RETURN special register to 16 in an error declarative or input/output procedure to terminate a sort/merge operation before all records are processed. The operation is terminated before a record is RETURNed or RELEASEd. ---End of IBM Extension--- ═══ 12.33. MOVE Statement ═══ The MOVE statement transfers data between areas of storage. The MOVE statement has two formats:  Format 1 - MOVE  Format 2 - MOVE CORRESPONDING Related Information:  MOVE Statement Rules  Elementary Moves  Group Moves  WHEN-COMPILED Special Register ═══ 12.33.1. MOVE Statement - Format 1 ═══ ┌─── MOVE STATEMENT - FORMAT 1 ────────────────────────────────────────────────┐ │ │ │ ┌──────────────┐ │ │  │ │ │ >>──MOVE──┬─identifier-1─┬──TO────identifier-2─┴──>< │ │ └─literal-1────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 1, all identifiers may be either group or elementary items. The data in the sending item is moved into the data item referenced by each identifier-2 in the order in which identifier-2 is specified. See Elementary Moves and Group Moves. ═══ 12.33.2. MOVE Statement - Format 2 ═══ ┌─── MOVE STATEMENT - FORMAT 2 ────────────────────────────────────────────────┐ │ │ │ >>──MOVE──┬─CORRESPONDING─┬──identifier-1──TO──identifier-2──>< │ │ └─CORR──────────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 2, identifier-1 and identifier-2 must be group items. Selected items in identifier-1 are moved to identifier-2, according to the rules for the CORRESPONDING Phrase. ═══ 12.33.3. MOVE Statement Rules ═══ An index data item cannot be specified in a MOVE statement. -----IBM Extension----- A pointer data item (USAGE POINTER) or a procedure-pointer data item (USAGE PROCEDURE-POINTER) cannot be specified in a MOVE statement. To move an address into a pointer or procedure-pointer data item, use the SET statement. ---End of IBM Extension--- The evaluation of the length of the sending or receiving item may be affected by the DEPENDING ON phrase of the OCCURS clause (see OCCURS Clause). Any length evaluation, subscripting, or reference modification associated with the sending item (identifier-1 or literal-1) is evaluated only once, immediately before the data is moved to the first of the receiving items. Any length evaluation, subscripting, or reference modification associated with a receiving item (identifier-2) is evaluated immediately before the data is moved into it. For example, the result of the statement: MOVE A(B) TO B, C(B). is equivalent to: MOVE A(B) TO TEMP. MOVE TEMP TO B. MOVE TEMP TO C(B). where TEMP is an intermediate result item. The subscript B has changed in value between the time that the first move took place and the time that the final move to C(B) is executed. ═══ 12.33.4. Elementary Moves ═══ An elementary move is one in which the receiving item is an elementary item, and the sending item is an elementary item or a literal. Any necessary conversion of data from one form of internal representation to another takes place during the move, along with any specified editing in, or de-editing implied by, the receiving item. De-editing is the logical removal of all editing characters from a numeric-edited data item in order to determine that item's unedited numeric value. The following rules outline the execution of valid elementary moves. When the receiving item is: Alphabetic:  Alignment and any necessary space filling occur as described under Alignment Rules.  If the size of the sending item is greater than the size of the receiving item, excess characters on the right are truncated after the receiving item is filled. Alphanumeric or Alphanumeric-edited:  Alignment and any necessary space filling take place, as described under Alignment Rules.  If the size of the sending item is greater than the size of the receiving item, excess characters on the right are truncated after the receiving item is filled.  If the sending item has an operational sign, the absolute value is used. If the operational sign occupies a separate character, that character is not moved, and the size of the sending item is considered to be one less character than the actual size. -----IBM Extension-----  If the sending item is Boolean, the data is moved as if the sending item were described as an alphanumeric item of length 1. ---End of IBM Extension--- Numeric or Numeric-edited:  Except where zeros are replaced because of editing requirements, alignment by decimal point and any necessary zero filling take place, as described under Alignment Rules.  If the receiving item is signed, the sign of the sending item is placed in the receiving item, with any necessary sign conversion. If the sending item is unsigned, a positive operational sign is generated for the receiving item.  If the receiving item is unsigned, the absolute value of the sending item is moved, and no operational sign is generated for the receiving item.  When the sending item is alphanumeric, the data is moved as if the sending item were described as an unsigned integer.  De-editing allows the moving of a numeric-edited data item into a numeric or numeric-edited receiver. The compiler accomplishes this by first establishing the unedited value of the numeric-edited item (this value can be signed), then moving the unedited numeric value to the receiving numeric or numeric-edited data item. -----IBM Extension----- Boolean:  For a Boolean receiving item, only the first byte of the sending item is moved.  If the sending item is alphanumeric, the first character of the sending item is moved. The characters "0" and "1" are equivalent to the Boolean values B"0" and B"1", respectively.  If the sending item is ZERO, it is treated as the Boolean literal B"0". ---End of IBM Extension--- Note: 1. If the receiving item is alphanumeric or numeric-edited, and the sending item is a scaled integer (that is, has a P as the rightmost character in its PICTURE character-string), the scaling positions are treated as trailing zeros when the MOVE statement is executed. 2. If the receiving item is numeric and the sending item is alphanumeric literal or ALL literal, then all characters of the literal must be numeric characters. ═══ 12.33.5. Group Moves ═══ A group move is one in which one or both of the sending and receiving items are group items. A group move is treated exactly as though it were an alphanumeric elementary move, except that there is no conversion of data from one form of internal representation to another. In a group move, the receiving item is filled without consideration for the individual elementary items contained within either the sending item or the receiving item. All group moves are valid. -----IBM Extension----- In the following discussion, on the MOVE statement and pointers, pointers refers to both the pointer data item (USAGE POINTER) and the procedure-pointer data item (USAGE PROCEDURE-POINTER). A pointer can be part of a group that is referred to in a MOVE statement. A pointer move occurs when all of the following conditions are met:  The sending or receiving item of a MOVE statement contains a pointer  Both items are at least 16 bytes long and properly aligned  Both are alphanumeric or group items If the items being moved are 01-level items, or part of a 01-level structure, they must be at the same offset relative to a 16-byte boundary. All 01-level items in Working-storage are aligned on 16-byte boundaries. For more information about pointer alignment, see Pointer Alignment. A pointer can be part of a group that is referred to in a MOVE CORRESPONDING statement; however, movement of the pointer will not take place. ---End of IBM Extension--- ═══ 12.33.6. WHEN-COMPILED Special Register ═══ -----IBM Extension----- This special register contains the date at the start of compilation. It consists of an alphanumeric data item with the implicit definition: 01 WHEN-COMPILED GLOBAL PICTURE X(16) USAGE DISPLAY and format: MM/DD/YYhh.mm.ss (MONTH/DAY/YEARhour.minute.second) For example, if compilation began at 2:04 PM on 15 December 1994, WHEN-COMPILED would contain the value 12/15/9414.04.00. The DATSEP or TIMSEP parameter of job-related commands (such as CHGJOB) specifies the date-separation or time-separation character used in the WHEN-COMPILED special register. The DATFMT parameter specifies the date format used in the WHEN-COMPILED special register. It is valid only as the sending item in a MOVE statement. The special register data can be reference-modified only when it is used as a sender data item. In nested programs, this special register is implicitly defined in the outermost program. ---End of IBM Extension--- ═══ 12.34. MULTIPLY Statement ═══ The MULTIPLY statement multiplies numeric items and stores the result. The MULTIPLY statement has two formats:  Format 1 - MULTIPLY  Format 2 - MULTIPLY GIVING Related Information:  MULTIPLY Statement Considerations ═══ 12.34.1. MULTIPLY Statement - Format 1 ═══ ┌─── MULTIPLY STATEMENT - FORMAT 1 ────────────────────────────────────────────┐ │ │ │ ┌───────────────────────────┐ │ │  │ │ │ >>──MULTIPLY──┬─identifier-1─┬──BY────identifier-2──┬─────────┬─┴──────────> │ │ └─literal-1────┘ └─ROUNDED─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──SIZE ERROR──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──────────────────> │ │ └─NOT───┬──────┬──SIZE ERROR──imperative-statement-2─┘ │ │ └─ON───┘ │ │ │ │ >──┬──────────────┬──>< │ │ └─END-MULTIPLY─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 1, the value of identifier-1 or literal-1 is saved. This value is multiplied by and stored in each identifier-2, in the left-to-right order in which identifier-2 is specified. ═══ 12.34.2. MULTIPLY Statement - Format 2 ═══ ┌─── MULTIPLY STATEMENT - FORMAT 2 ────────────────────────────────────────────┐ │ │ │ >>──MULTIPLY──┬─identifier-1─┬──BY──┬─identifier-2─┬───────────────────────> │ │ └─literal-1────┘ └─literal-2────┘ │ │ │ │ ┌───────────────────────────┐ │ │  │ │ │ >──GIVING────identifier-3──┬─────────┬─┴───────────────────────────────────> │ │ └─ROUNDED─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──SIZE ERROR──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──────────────────> │ │ └─NOT───┬──────┬──SIZE ERROR──imperative-statement-2─┘ │ │ └─ON───┘ │ │ │ │ >──┬──────────────┬──>< │ │ └─END-MULTIPLY─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 2, the value of identifier-1 or literal-1 is multiplied by the value of identifier-2 or literal-2. The product is then stored in each data item referenced by identifier-3. ═══ 12.34.3. MULTIPLY Statement Considerations ═══ The composite of operands must not contain more than 18 digits. -----IBM Extension----- The composite of all operands in an arithmetic statement can have a maximum length of 30 digits. ---End of IBM Extension--- Note: Intermediate results generated during the execution of a MULTIPLY statement are system-specific and can affect program portability. ═══ 12.35. OPEN Statement ═══ The OPEN statement initiates the processing of files and checks or writes labels. The OPEN statement varies depending on the type of file. The OPEN statement has three formats:  Format 1 - Sequential Files  Format 2 - Indexed and Relative Files -----IBM Extension-----  Format 3 - TRANSACTION Files ---End of IBM Extension--- Related Information:  OPEN Statement Considerations  OPEN Statement Programming Notes ═══ 12.35.1. OPEN Statement - Format 1 - Sequential ═══ ┌─── OPEN STATEMENT - FORMAT 1 - SEQUENTIAL ───────────────────────────────────┐ │ │ │ ┌────────────────────────────────────────────────────────┐ │ │ │ ┌────────────────────────────────────────┐ │ │ │   │ │ │ │ >>──OPEN────┬─INPUT────file-name-1──┬───────────────────────┬─┴──┬─┴──>< │ │ │ ├─REVERSED──────────────┤ │ │ │ │ └─┬──────┬──NO REWIND─┘ │ │ │ │ └─WITH─┘ │ │ │ │ ┌────────────────────────────────────────┐ │ │ │ │  │ │ │ │ ├─OUTPUT────file-name-2──┬───────────────────────┬─┴─┤ │ │ │ └─┬──────┬──NO REWIND─┘ │ │ │ │ └─WITH─┘ │ │ │ │ ┌─────────────┐ │ │ │ │  │ │ │ │ ├─I-O─────file-name-3─┴──────────────────────────────┤ │ │ │ ┌─────────────┐ │ │ │ │  │ │ │ │ └─EXTEND────file-name-4─┴────────────────────────────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.35.2. OPEN Statement - Format 2 - Indexed and Relative ═══ ┌─── OPEN STATEMENT - FORMAT 2 - INDEXED AND RELATIVE ─────────────────────────┐ │ │ │ ┌─────────────────────────────┐ │ │ │ ┌─────────────┐ │ │ │   │ │ │ │ >>──OPEN────┬─INPUT────file-name-1─┴──┬─┴──>< │ │ │ ┌─────────────┐ │ │ │ │  │ │ │ │ ├─OUTPUT────file-name-2─┴─┤ │ │ │ ┌─────────────┐ │ │ │ │  │ │ │ │ └─I-O─────file-name-3─┴───┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ For relative files only, the OPEN statement is not allowed for logical file members:  That are based on more than one physical file  That contain select or omit logic ═══ 12.35.3. OPEN Statement - Format 3 - TRANSACTION ═══ -----IBM Extension----- ┌─── OPEN STATEMENT - FORMAT 3 - TRANSACTION ──────────────────────────────────┐ │ │ │ ┌─────────────┐ │ │  │ │ │ >>──OPEN──I-O─────file-name-3─┴──>< │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The OPEN statement can cause a program device to be implicitly acquired for a TRANSACTION file. For a further discussion about the acquiring of program devices, see the ACQUIRE Statement. ---End of IBM Extension--- ═══ 12.35.4. OPEN Statement Considerations ═══ The successful execution of an OPEN statement determines the availability of the file and results in that file being in an open mode. The file is unavailable if the OPEN operation fails. A file is available if it is physically present and is recognized by the input-output control system. OPEN Statement Programming Notes shows the results of opening available and unavailable files. Related Information:  Special Considerations for Device Type DATABASE ═══ 12.35.4.1. Special Considerations for Device Type DATABASE ═══ -----IBM Extension----- The file may be placed under commitment control. ---End of IBM Extension--- If the file contains null-capable fields, a file status of 0P is set. COBOL I-O statements do not support records that contain null fields. However, records in a null-capable file that do not contain null fields may be processed. ═══ 12.35.5. INPUT Phrase (Sequential Files) ═══ The file is opened for input operations. The file position indicator is set to the first record in the file. If no records exist in the file, the file position indicator is set so that processing of the first sequential READ statement results in an AT END condition. If SELECT OPTIONAL is specified in the file-control entry, OPEN statement processing causes the program to check for the presence or absence of this file at run time. If the file is absent, the first READ statement for this file causes the AT END condition to occur. Under the OPTION(*NOBLK) option, the compiler generates code to block output records and unblock input records if the following conditions are satisfied:  The file access is sequential.  The organization of the file is sequential and the file is open only for input or output.  The file is assigned to DISK, DATABASE, DISKETTE, or TAPEFILE. The BLOCK CONTAINS clause does not control the blocking factor for any files except tape files. The BLOCK CONTAINS clause controls the blocking factor for all files. Related Information:  Special Considerations for Device Types DATABASE, TAPEFILE, and DISKETTE  Special Considerations for Device Types DISK and DATABASE ═══ 12.35.5.1. Special Considerations for Device Types DATABASE, TAPEFILE, and DISKETTE ═══ If SELECT OPTIONAL is specified in the file-control entry and OPTION(*CRTF) is specified in the CRTCBLMOD or CRTBNDCBL command, this combination is not valid. ═══ 12.35.5.2. Special Considerations for Device Types DISK and DATABASE ═══ -----IBM Extension----- The first record to be made available to the program can be specified at run time by using the POSITION parameter on the OVRDBF CL command. ---End of IBM Extension--- ═══ 12.35.6. OUTPUT Phrase (Sequential Files) ═══ The file is opened to allow only output operations. When the file is successfully opened, it contains no records. Under OPTION(*NOBLK), the compiler generates code to block output records and unblock input records if the following conditions are satisfied:  The file access is sequential.  The organization of the file is sequential and the file is open only for input or output.  The file is assigned to DISK, DATABASE, DISKETTE, or TAPEFILE. The BLOCK CONTAINS clause does not control the blocking factor for any files except tape files. Device type FORMATFILE and PRINTER can only be opened for output. Related Information:  Special Considerations for Device Type DISK  Special Considerations for Device Types DISK, DATABASE, and FORMATFILE ═══ 12.35.6.1. Special Considerations for Device Type DISK ═══ The default in the CRTCBLMOD or CRTBNDCBL command is OPTION(*NOCRTF). If the file is unavailable, it will not be created by the OPEN operation. For dynamic file creation, specify OPTION(*CRTF) in the CRTCBLMOD or CRTBNDCBL command. Note: The maximum record length for a file that can be created dynamically is 32 766. ═══ 12.35.6.2. Special Considerations for Device Types DISK, DATABASE, and FORMATFILE ═══ -----IBM Extension----- Only a physical file is cleared when opened for OUTPUT. When the file is successfully opened, it contains no records. If an attempt is made to open a logical file for OUTPUT, the file is opened but no records are deleted. The file is treated as though the EXTEND phrase had been specified. To clear a logical file, all the members on which the logical file is based should be cleared. ---End of IBM Extension--- ═══ 12.35.7. I-O Phrase (Sequential Files) ═══ Only device types DISK and DATABASE can be opened for I-O. The file is opened for both input and output operations. The file position indicator is set to the first record in the file. If no records exist in the file, the file position indicator is set so that processing of the first sequential READ statement results in an AT END condition. -----IBM Extension----- The first record to be made available to the program can be specified at run time by using the POSITION parameter on the OVRDBF CL command. ---End of IBM Extension--- Related Information:  Special Considerations for Device Type DISK ═══ 12.35.7.1. Special Considerations for Device Type DISK ═══ If the OPTIONAL phrase is used in the SELECT clause for the file, and OPTION(*NOCRTF) is specified in the CRTCBLMOD or CRTBNDCBL command, a compile-time error will occur. If the OPTIONAL phrase is used, and if OPTION(*CRTF) is specified in the CRTCBLMOD or CRTBNDCBL command, the file will be created by the OPEN operation if it is unavailable. For dynamic file creation, specify OPTION(*CRTF) on the CRTCBLMOD or CRTBNDCBL command. If the OPTIONAL phrase is not specified, file status 90 will be returned. Note: The maximum record length for a file that can be created dynamically is 32 766. ═══ 12.35.8. NO REWIND Phrase (Sequential Files) ═══ This phrase applies only to device type TAPEFILE. The OPEN statement does not reposition the file. The tape must be positioned at the beginning of the desired file before processing of the OPEN statement. If the concept of reels has no meaning for the storage medium (for example, a direct access device), the REVERSED and NO REWIND phrases do not apply. When the phrases are used in this situation, a file status of 07 is set. -----IBM Extension----- The system keeps track of the current position on the tape and automatically positions the tape to the proper place. When processing a multifile tape volume, all CLOSE statements should specify the NO REWIND phrase. When the next file on the volume is opened, the system determines which direction the tape should be moved to most efficiently get to the desired file. ---End of IBM Extension--- ═══ 12.35.9. REVERSED Phrase (Sequential Files) ═══ This phrase applies only to device type TAPEFILE. OPEN statement processing positions the file at its end. Subsequent READ statements make the data records available in reverse order, starting with the last record. REVERSED can only be specified for input files. If the concept of reels has no meaning for the storage medium (for example, a direct access device), the REVERSED and NO REWIND phrases do not apply. When the phrases are used in this situation, a file status of 07 is set. ═══ 12.35.10. EXTEND Phrase (Sequential Files) ═══ Device types TAPEFILE, DISK, and DATABASE may be opened as EXTEND. The EXTEND phrase permits opening the file for output operations. OPEN EXTEND statement processing prepares the file for the addition of records. These additional records immediately follow the last record in the file. Subsequent WRITE statements add records as if the file had been opened for OUTPUT. The EXTEND phrase can be specified when a file is being created. Related Information:  Special Considerations for Device Type DISK ═══ 12.35.10.1. Special Considerations for Device Type DISK ═══ If the OPTIONAL phrase is used in the SELECT clause for the file, and OPTION(*NOCRTF) is specified in the CRTCBLMOD or CRTBNDCBL command, a compile-time error will occur. If the OPTIONAL phrase is used, and if OPTION(*CRTF) is specified in the CRTCBLMOD or CRTBNDCBL command, the file is created by the OPEN operation if it is unavailable (and the authority of the file is inherited from the job profile). For dynamic file creation, specify OPTION(*CRTF) on the CRTCBLMOD or CRTBNDCBL command. If the OPTIONAL phrase is not specified, file status 90 will be returned. Note: The maximum record length for a file that can be created dynamically is 32 766. ═══ 12.35.11. INPUT Phrase (Indexed and Relative Files) ═══ The file is opened for input operations. The file position indicator is set to the first record in the file. If no records exist in the file, the file position indicator is set so that processing of the first sequential READ statement results in an AT END condition. Related Information:  Special Considerations for Sequential Access Mode  Special Considerations for Dynamic Access Mode ═══ 12.35.11.1. Special Considerations for Sequential Access Mode ═══ -----IBM Extension----- The first record to be made available to the program can be specified at run time by using the POSITION parameter on the OVRDBF CL command. ---End of IBM Extension--- Under OPTION(*NOBLK), the compiler generates code to block output records and unblock input records if the following conditions are satisfied:  The file access is sequential.  The organization of the file is indexed and the file is open only for input or output; or the organization of the file is relative, and the file is open only for input.  The file is assigned to DISK or DATABASE  No START statements are specified for the file. The BLOCK CONTAINS clause does not control the blocking factor. START statements are allowed if you specify both OPTION(*BLK) and the BLOCK CONTAINS clause. The BLOCK CONTAINS clause controls the blocking factor for all files. ═══ 12.35.11.2. Special Considerations for Dynamic Access Mode ═══ -----IBM Extension----- The first record to be made available to the program can be specified at run time by using the POSITION parameter on the OVRDBF CL command. ---End of IBM Extension--- Also, under OPTION(*BLK), the BLOCK CONTAINS clause causes the compiler to generate code that blocks output records and unblocks input records if the following conditions are satisfied:  The file access is dynamic.  The organization of the file is indexed and the file is open only for input or output; or the organization of the file is relative, and the file is open only for input.  The file is assigned to DISK or DATABASE. If the BLOCK CONTAINS clause specifies a record size of zero, the system default blocking factor applies. ═══ 12.35.12. OUTPUT Phrase (Indexed and Relative Files) ═══ -----IBM Extension----- Only a physical file is cleared when opened for OUTPUT. When the file is successfully opened, it contains no records. If an attempt is made to open a logical file for OUTPUT, the file is opened but no records are deleted. To clear a logical file, all the members on which the logical file is based should be cleared. ---End of IBM Extension--- Related Information:  Special Considerations for Device Type DISK  Special Considerations for Indexed Files - Sequential Access  Special Considerations for Indexed Files - Dynamic Access ═══ 12.35.12.1. Special Considerations for Device Type DISK ═══ If the file is unavailable, it will not be created by the OPEN operation if OPTION(*NOCRTF) is specified in the CRTCBLMOD or CRTBNDCBL command. For dynamic file creation, specify OPTION(*CRTF) in the CRTCBLMOD or CRTBNDCBL command. (*NOCRTF is the default unless otherwise specified.) Note: The maximum record length for a file that can be created dynamically is 32 766. ═══ 12.35.12.2. Special Considerations for Indexed Files - Sequential Access ═══ Under OPTION(*NOBLK), the compiler generates code to block output records and unblock input records if the following conditions are satisfied:  The file access is sequential.  The organization of the file is indexed and the file is open only for input or output.  The file is assigned to DISK or DATABASE  No START statements are specified for the file. The BLOCK CONTAINS clause does not control the blocking factor. If you specify both OPTION(*BLK) and the BLOCK CONTAINS clause, the blocking factor applies. ═══ 12.35.12.3. Special Considerations for Indexed Files - Dynamic Access ═══ Under OPTION(*BLK), the BLOCK CONTAINS clause causes the compiler to generate code that blocks output records and unblocks input records if the following conditions are satisfied:  The file access is dynamic.  The organization of the file is indexed and the file is open only for input or output.  The file is assigned to DISK or DATABASE. If the BLOCK CONTAINS clause specifies a record size of zero, the system default blocking factor applies. ═══ 12.35.13. I-O Phrase (Indexed and Relative Files) ═══ The file is opened for both input and output operations. The file position indicator is set to the first record in the file. If no records exist in the file, the file position indicator is set so that processing of the first sequential READ statement results in an AT END condition. Related Information:  Special Considerations for Sequential or Dynamic Access Modes ═══ 12.35.13.1. Special Considerations for Sequential or Dynamic Access Modes ═══ -----IBM Extension----- The first record to be made available to the program can be specified at run time by using the POSITION parameter on the OVRDBF CL command. ---End of IBM Extension--- ═══ 12.35.14. OPEN Statement Programming Notes ═══ The successful execution of an OPEN statement determines the availability of the files and results in that file being in open mode. 1. The successful execution of the OPEN statement makes the associated record area available to the program; it does not obtain or release the first data record. 2. An OPEN statement must be successfully executed prior to the execution of any of the permissible input-output statements, except a SORT or MERGE statement with the USING or GIVING phrase. 3. The READ statement is executed on a file which is open for INPUT or I-O. 4. The WRITE statement is executed on a file which is open for OUTPUT or EXTEND (sequential files only). The WRITE statement is also executed on an indexed or relative file which is open for I-O in random or dynamic access mode, and on a TRANSACTION file open for I-O. 5. The REWRITE statement is executed on a file which is open for I-O. 6. The START statement is executed on an indexed or relative file which is open for INPUT or I-O. 7. The DELETE statement is executed on an indexed or relative file which is open for I-O. 8. A file may be opened for INPUT, OUTPUT, I-O, or EXTEND (sequential files only) in the same program. After the first OPEN statement execution for a given file, each subsequent OPEN statement execution must be preceded by a successful CLOSE file statement execution without the REEL or UNIT phrase (for sequential files only), or the LOCK phrase. 9. If the FILE STATUS clause is specified in the FILE-CONTROL entry, the associated status key is updated when the OPEN statement is executed. For more information about the status key, refer to Common Processing Facilities. 10. If an OPEN statement is issued for a file already in the open status, the EXCEPTION/ERROR procedure (if specified) for this file is executed and file status 41 is returned. ═══ 12.36. PERFORM Statement ═══ The PERFORM statement transfers control explicitly to one or more procedures and implicitly returns control to the next executable statement after execution of the specified procedure(s) or imperative statements is completed. The PERFORM statement can be: An out-of-line PERFORM statement Procedure-name-1 is specified. An in-line PERFORM statement Procedure-name-1 is omitted. An in-line PERFORM must be delimited by the END-PERFORM phrase. The in-line and out-of-line formats cannot be combined. For example, if procedure-name-1 is specified, the imperative-statement and the END-PERFORM phrase must not be specified. There are four PERFORM statement formats:  Format 1 - Basic PERFORM  Format 2 - PERFORM with TIMES Phrase  Format 3 - PERFORM with UNTIL Phrase  Format 4 - PERFORM with VARYING Phrase Related Information:  Nested PERFORM Statements ═══ 12.36.1. Basic PERFORM Statement ═══ The procedure(s) referenced in the basic PERFORM statement are executed once, and control then passes to the next executable statement following the PERFORM statement. ┌─── PERFORM STATEMENT - FORMAT 1 ─────────────────────────────────────────────┐ │ │ │ >>──PERFORM──┬─procedure-name-1──┬───────────────────────────────┬─┬──>< │ │ │ └─┬─THROUGH─┬──procedure-name-2─┘ │ │ │ │ └─THRU────┘ │ │ │ └─imperative-statement──END-PERFORM───────────────────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.36.1.1. In-line PERFORM Statement ═══ An in-line PERFORM statement functions according to the same general rules as an otherwise identical out-of-line PERFORM statement, except that statements contained within the in-line PERFORM are executed in place of the statements contained within the range of procedure-name-1 (through procedure-name-2, if specified). Unless specifically qualified by the word in-line or out-of-line, all the rules that apply to the out-of-line PERFORM statement also apply to the in-line PERFORM. ═══ 12.36.1.2. Out-of-line PERFORM Statement ═══ Whenever an out-of-line PERFORM statement is executed, control is transferred to the first statement of the procedure named procedure-name-1. Control is always returned to the statement following the PERFORM statement. The point from which this control is returned is determined as follows:  If procedure-name-1 is a paragraph name and procedure-name-2 is not specified, the return is made after the execution of the last statement of the procedure-name-1 paragraph.  If procedure-name-1 is a section name and procedure-name-2 is not specified, the return is made after the execution of the last statement of the last paragraph in the procedure-name-1 section.  If procedure-name-2 is specified and it is a paragraph name, the return is made after the execution of the last statement of the procedure-name-2 paragraph.  If procedure-name-2 is specified and it is a section name, the return is made after the execution of the last statement of the last paragraph in the procedure-name-2 section. The only necessary relationship between procedure-name-1 and procedure-name-2 is that a consecutive sequence of operations is executed, beginning at the procedure named by procedure-name-1 and ending with the execution of the procedure named by procedure-name-2. ═══ 12.36.1.3. Nested PERFORM Statements ═══ PERFORM statements may be specified within the performed procedure. If there are two or more logical paths to the return point, then procedure-name-2 may name a paragraph that consists only of an EXIT statement; all the paths to the return point must then lead to this paragraph. When both procedure-name-1 and procedure-name-2 are specified, GO TO and PERFORM statements can appear within the sequence of statements contained in these paragraphs or sections. A GO TO statement should not refer to a procedure-name outside the range of procedure-name-1 through procedure-name-2. If this is done, results are unpredictable and are not diagnosed. When only procedure-name-1 is specified, PERFORM and GO TO statements can appear within the procedure. A GO TO statement should not refer to a procedure-name outside the range of procedure-name-1. If this is done, results are unpredictable and are not diagnosed. When the performed procedures include another PERFORM statement, the sequence of procedures associated with the embedded PERFORM statement must be totally included in or totally excluded from the performed procedures of the first PERFORM statement. That is, an active PERFORM statement whose execution point begins within the range of performed procedures of another active PERFORM statement must not allow control to pass through the exit point of the other active PERFORM statement. In addition, two or more such active PERFORM statements must not have a common exit. -----IBM Extension----- Two or more active PERFORM statements can have a common exit point. ---End of IBM Extension--- When control passes to the sequence of procedures by means other than a PERFORM statement, control passes through the exit point to the next executable statement, as if no PERFORM statement referred to these procedures. ═══ 12.36.2. PERFORM with TIMES Phrase ═══ The procedure(s) referred to in the TIMES phrase PERFORM statement are executed the number of times specified by the value in identifier-1 or integer-1. Control then passes to the next executable statement following the PERFORM statement. ┌─── PERFORM STATEMENT - FORMAT 2 ─────────────────────────────────────────────┐ │ │ │ >>──PERFORM────────────────────────────────────────────────────────────────> │ │ │ │ >──┬─procedure-name-1──┬───────────────────────────────┬──┤ phrase 1 ├─┬──>< │ │ │ └─┬─THROUGH─┬──procedure-name-2─┘ │ │ │ │ └─THRU────┘ │ │ │ └─┤ phrase 1 ├──imperative-statement──END-PERFORM───────────────────┘ │ │ │ │ PHRASE-1: │ │ ├──┬─identifier-1─┬──TIMES──┤ │ │ └─integer-1────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.36.3. PERFORM with UNTIL Phrase ═══ In the UNTIL phrase format, the procedure(s) referred to are performed until the condition specified by the UNTIL phrase is true. Control is then passed to the next executable statement following the PERFORM statement. ┌─── PERFORM STATEMENT - FORMAT 3 ─────────────────────────────────────────────┐ │ │ │ >>──PERFORM────────────────────────────────────────────────────────────────> │ │ │ │ >──┬─procedure-name-1──┬───────────────────────────────┬──┤ phrase 2 ├─┬──>< │ │ │ └─┬─THROUGH─┬──procedure-name-2─┘ │ │ │ │ └─THRU────┘ │ │ │ └─┤ phrase 2 ├──imperative-statement──END-PERFORM───────────────────┘ │ │ │ │ PHRASE 2: │ │ ├──┬────────────────────────────┬──UNTIL──condition-1──┤ │ │ └─┬──────┬──TEST──┬─BEFORE─┬─┘ │ │ └─WITH─┘ └─AFTER──┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.36.4. PERFORM with VARYING Phrase ═══ The VARYING phrase increases or decreases the value of one or more identifiers or index-names, according to certain rules. (See Varying Phrase Rules.) The Format 4 VARYING phrase PERFORM statement can serially search an entire 7-dimensional table. ┌─── PERFORM STATEMENT - FORMAT 4 ─────────────────────────────────────────────┐ │ │ │ >>──PERFORM────────────────────────────────────────────────────────────────> │ │ │ │ >──┬─procedure-name-1──┬───────────────────────────────┬──┤ phrase 3 ├─┬──>< │ │ │ └─┬─THROUGH─┬──procedure-name-2─┘ │ │ │ │ └─THRU────┘ │ │ │ └─┤ phrase 3 ├──imperative-statement-1──END-PERFORM─────────────────┘ │ │ │ │ PHRASE 3: │ │ ├──┬────────────────────────────┬──VARYING──┬─identifier-2─┬──FROM─────────> │ │ └─┬──────┬──TEST──┬─BEFORE─┬─┘ └─index-name-1─┘ │ │ └─WITH─┘ └─AFTER──┘ │ │ │ │ >──┬─identifier-3─┬──BY──┬─identifier-4─┬──UNTIL──condition-1──────────────> │ │ ├─index-name-2─┤ └─literal-2────┘ │ │ └─literal-1────┘ │ │ │ │ >──┬──────────────────┬──┤ │ │ │ ┌──────────────┐ │ │ │ │  │ │ │ │ └───┤ phrase 4 ├─┴─┘ │ │ │ │ PHRASE 4: │ │ ├──AFTER──┬─identifier-5─┬──FROM──┬─identifier-6─┬──BY─────────────────────> │ │ └─index-name-3─┘ ├─index-name-4─┤ │ │ └─literal-3────┘ │ │ │ │ >──┬─identifier-7─┬──UNTIL──condition-2──┤ │ │ └─literal-4────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Related Information:  VARYING Phrase Rules  Varying One Identifier Example  Varying Two Identifiers Example  Varying Three Identifiers Example  Varying More Than Three Identifiers Example ═══ 12.36.4.1. Varying Identifiers ═══ The way in which operands are increased or decreased depends on the number of variables specified. In the following discussion, every reference to identifier-n refers equally to index-name-n (except when identifier-n is the object of the BY phrase). If identifier-2 or identifier-5 is subscripted, the subscripts are evaluated each time the content of the data item referenced by the identifier is set or augmented. If identifier-3, identifier-4, identifier-6, or identifier-7 is subscripted, the subscripts are evaluated each time the content of the data item referenced by the identifier is used in a setting or an augmenting operation. ═══ 12.36.4.2. Varying One Identifier ═══ Example: PERFORM procedure-name-1 THROUGH procedure-name-2 VARYING identifier-2 FROM identifier-3 BY identifier-4 UNTIL condition-1 1. Identifier-2 is set equal to its starting value, identifier-3 (or literal-1). 2. Condition-1 is evaluated as follows: a) If it is false, steps 3 through 5 are executed. b) If it is true, control passes directly to the statement following the PERFORM statement. 3. Procedure-1 and everything up to and including procedure-2 (if specified) is executed once. 4. Identifier-2 is augmented by identifier-4 (or literal-2), and condition-1 is evaluated again. 5. Steps 2 through 4 are repeated until condition-1 is true. At the end of PERFORM statement execution identifier-2 has a value that exceeds the last-used setting by the increment/decrement value (unless condition-1 was true at the beginning of PERFORM statement execution, in which case, identifier-2 contains the current value of identifier-3). ═══ 12.36.4.3. Varying Two Identifiers ═══ Example: PERFORM procedure-name-1 THROUGH procedure-name-2 VARYING identifier-2 FROM identifier-3 BY identifier-4 UNTIL condition-1 AFTER identifier-5 FROM identifier-6 BY identifier-7 UNTIL condition-2 1. identifier-2 and identifier-5 are set to their initial values, identifier-3 and identifier-6, respectively. 2. condition-1 is evaluated as follows: a) If it is false, steps 3 through 7 are executed. b) If it is true, control passes directly to the statement following the PERFORM statement. 3. condition-2 is evaluated as follows: a) If it is false, steps 4 through 6 are executed. b) If it is true, identifier-2 is augmented by identifier-4, identifier-5 is set to the current value of identifier-6, and step 2 is repeated. 4. procedure-name-1 and everything up to and including procedure-name-2 (if specified) are executed once. 5. identifier-5 is augmented by identifier-7. 6. Steps 3 through 5 are repeated until condition-2 is true. 7. Steps 2 through 6 are repeated until condition-1 is true. At the end of PERFORM statement execution:  identifier-5 contains the current value of identifier-6.  identifier-2 has a value that exceeds the last-used setting by the increment/decrement value (unless condition-1 was true at the beginning of PERFORM statement execution, in which case, identifier-2 contains the current value of identifier-3). ═══ 12.36.4.4. Varying Three Identifiers ═══ Example: PERFORM procedure-name-1 THROUGH procedure-name-2 VARYING identifier-2 FROM identifier-3 BY identifier-4 UNTIL condition-1 AFTER identifier-5 FROM identifier-6 BY identifier-7 UNTIL condition-2 AFTER identifier-8 FROM identifier-9 BY identifier-10 UNTIL condition-3 The actions are the same as those for two identifiers, except that identifier-8 goes through the complete cycle each time identifier-5 is augmented by identifier-7, which, in turn, goes through a complete cycle each time identifier-2 is varied. At the end of PERFORM statement execution:  identifier-5 and identifier-8 contain the current values of identifier-6 and identifier-9, respectively.  identifier-2 has a value exceeding its last-used setting by one increment/decrement value (unless condition-1 was true at the beginning of PERFORM statement execution, in which case, identifier-2 contains the current value of identifier-3). ═══ 12.36.4.5. Varying More Than Three Identifiers ═══ In the VARYING phrase, you may extend the examples above by adding up to four more AFTER phrases, for a total of six AFTER phrases. . ═══ 12.36.4.6. Varying Phrase Rules ═══ No matter how many variables are specified, the following rules apply: 1. In the VARYING/AFTER phrases, when an index-name is specified: a) The index-name is initialized and incremented or decremented according to the rules under INDEXED BY Phrase. (See also SET Statement.) b) In the associated FROM phrase, an identifier must be described as an integer and have a positive value; a literal must be a positive integer. c) In the associated BY phrase, an identifier must be described as an integer; a literal must be a nonzero integer. 2. In the FROM phrase, when an index-name is specified: a) In the associated VARYING/AFTER phrase, an identifier must be described as an integer. It is initialized, as described in the SET statement. b) In the associated BY phrase, an identifier must be described as an integer and have a nonzero value; a literal must be a nonzero integer. 3. In the BY phrase, identifiers and literals must have nonzero values. 4. Changing the values of identifiers and/or index-names in the VARYING, FROM, and BY phrases during execution changes the number of times the procedures are executed. 5. The way in which operands are incremented or decremented depends on the number of variables specified. ═══ 12.37. READ Statement ═══ The READ statement makes a record available to the program:  For sequential access, the READ statement makes the next record from a file available to the object program.  For random access, the READ statement makes a specified record from a direct-access file available to the object program. When the READ statement is executed, the associated file must be open in INPUT or I-O mode. Execution of the READ statement depends on the file organization. File organization can be:  Sequential  Relative  Indexed The READ statement has five formats:  Format 1 - Sequential Retrieval/Sequential Access  Format 2 - Sequential Retrieval/Dynamic Access  Format 3 - Random Retrieval -----IBM Extension-----  Format 4 - Transaction (Nonsubfile)  Format 5 - Transaction (Subfile) ---End of IBM Extension--- If the FILE STATUS clause is specified in the file-control entry, the associated status key is updated when the READ statement is processed. Following the unsuccessful processing of any READ statement, the contents of the associated record area and the position of the file position indicator are undefined. Related Information:  Sequential Access Mode  Dynamic Access Mode  Random Access Mode  Special Considerations for Device Types DISK and DATABASE  Multiple Record Processing  Multivolume Files ═══ 12.37.1. Special Considerations for Device Types DISK and DATABASE ═══ Null-capable fields are supported when the READ statement is performed on a file which is found on a DISK or DATABASE device. However, null values are not supported. If any of these fields contain the null value, the READ operation fails and returns a file status of 90. ═══ 12.37.2. Sequential Access Mode ═══ Format 1 must be used for all files in sequential access mode. Execution of a Format 1 READ statement retrieves the next record from the file. The next record accessed is determined by the file organization. ═══ 12.37.3. Dynamic Access Mode ═══ For files with indexed or relative organization, dynamic access mode may be specified in the FILE-CONTROL entry. In dynamic access mode, either sequential or random record retrieval can be used, depending on the format used. Format 2 with the NEXT phrase must be specified for sequential retrieval. All other rules for sequential access apply. Format 3 must be specified for random retrieval. All other rules for random access apply. ═══ 12.37.4. Random Access Mode ═══ Format 3 must be specified for indexed and relative files in random access mode, and also for files in the dynamic access mode when record retrieval is random. Execution of the READ statement depends on the file organization, as explained in following sections. ═══ 12.37.5. READ Statement - Format 1 - Sequential Retrieval/Sequential Access ═══ ┌─── READ STATEMENT - FORMAT 1 - SEQUENTIAL RETRIEVAL/ACCESS ──────────────────┐ │ │ │ >>──READ──file-name──┬──────┬──┬────────┬──┬────────────────────┬──────────> │ │ └─NEXT─┘ └─RECORD─┘ └─INTO──identifier-1─┘ │ │ │ │ >──┬──────────────────────┬──┬───────────────────────────────────────┬─────> │ │ │ (1) │ │ (1) │ │ │ └──┬──────┬─NO LOCK────┘ └─FORMAT────┬──────┬──┬─identifier-2─┬──┘ │ │ └─WITH─┘ └─IS───┘ └─literal-1────┘ │ │ │ │ >──┬────────────────────────────────────────┬──────────────────────────────> │ │ └─┬──────┬──END───imperative-statement-1─┘ │ │ └─AT───┘ │ │ │ │ >──┬──────────────────────────────────────────────┬──┬──────────┬──>< │ │ └─NOT───┬──────┬──END───imperative-statement-2─┘ └─END-READ─┘ │ │ └─AT───┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.37.6. READ Statement - Format 2 - Sequential Retrieval/Dynamic Access ═══ ┌─── READ - FORMAT 2 - SEQUENTIAL RET./DYNAMIC ACCESS ─────────────────────────┐ │ │ │ >>──READ──file-name──┬─NEXT─────┬──┬────────┬──┬────────────────────┬──────> │ │ │ (1)│ └─RECORD─┘ └─INTO──identifier-1─┘ │ │ ├─FIRST────┤ │ │ │ (1) │ │ │ ├─LAST─────┤ │ │ │ (1)│ │ │ └─PRIOR────┘ │ │ │ │ >──┬──────────────────────┬──┬───────────────────────────────────────┬─────> │ │ │ (1) │ │ (1) │ │ │ └──┬──────┬─NO LOCK────┘ └─FORMAT────┬──────┬──┬─identifier-2─┬──┘ │ │ └─WITH─┘ └─IS───┘ └─literal-1────┘ │ │ │ │ >──┬────────────────────────────────────────┬──────────────────────────────> │ │ └─┬──────┬──END───imperative-statement-1─┘ │ │ └─AT───┘ │ │ │ │ >──┬──────────────────────────────────────────────┬──┬──────────┬──>< │ │ └─NOT───┬──────┬──END───imperative-statement-2─┘ └─END-READ─┘ │ │ └─AT───┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.37.7. READ Statement - Format 3 - Random Retrieval ═══ ┌─── READ STATEMENT - FORMAT 3 - RANDOM RETRIEVAL ─────────────────────────────┐ │ │ │ >>──READ──file-name──┬────────┬──┬────────────────────┬────────────────────> │ │ └─RECORD─┘ └─INTO──identifier-1─┘ │ │ │ │ >──┬──────────────────────┬──┬──────────────────────────────┬──────────────> │ │ │ (1) │ │ (2) │ │ │ └──┬──────┬─NO LOCK────┘ └─KEY─────┬──────┬─data-name-1─┘ │ │ └─WITH─┘ └─IS───┘ │ │ │ │ >──┬───────────────────────────────────────┬───────────────────────────────> │ │ │ (1) │ │ │ └─FORMAT────┬──────┬──┬─identifier-2─┬──┘ │ │ └─IS───┘ └─literal-1────┘ │ │ │ │ >──┬─────────────────────────────────────────┬─────────────────────────────> │ │ └─INVALID─┬──────┬─imperative-statement-1─┘ │ │ └─KEY──┘ │ │ │ │ >──┬──────────────────────────────────────────────┬──┬──────────┬──>< │ │ └─NOT INVALID─┬──────┬─imperative-statement-2─┘ └─END-READ─┘ │ │ └─KEY──┘ │ │ │ │ NOTES: │ │ (1) IBM Extension │ │ │ │ (2) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.37.8. INTO Phrase ═══ The INTO identifier phrase makes a READ statement equivalent to:  READ file-name RECORD  MOVE record-name TO identifier After successful processing of the READ statement, the current record becomes available both in the record-name and identifier. When the INTO identifier phrase is specified, the current record is moved from the input area to the identifier area according to the rules for the MOVE statement without the CORRESPONDING phrase. Any subscripting, indexing, or reference modification associated with the identifier is evaluated after the record has been read and immediately before it is transferred to the identifier. (See also INTO/FROM Identifier Phrase.) The INTO phrase may be specified in a READ statement if:  Only one record description is subordinate to the file description entry, or,  All record-names associated with file-name, and the data item referenced by identifier-1, describe a group item or an elementary alphanumeric item. When using the INTO identifier phrase with variable length records, the amount of data moved to the receiver is equal to the length of the variable length record being read. ═══ 12.37.9. identifier-1 ═══ Identifier-1 is the receiving field. The current record is moved from the record area to that specified by identifier-1 according to the rules of the MOVE statement without the CORRESPONDING phrase. The following usage notes apply:  The size of the current record depends on the rules specified in the RECORD clause  If the file description entry contains a RECORD IS VARYING clause, the move is a group move  The implied MOVE statement occurs only if the execution of the READ statement is successful  Subscripting or reference modification associated with identifier-1 applies after reading the record and immediately before it is moved to the data item  The record is available in both the record area and the data item referenced by identifier-1  The INTO phrase is allowed in a READ statement only if - Only one record description is subordinate to the file description entry, or - All record names associated with file-name-1, and the item referenced by identifier-1, describe a group item or an elementary alphanumeric item.  The record areas associated with file-name-1 and identifier-1 must not be the same storage area ═══ 12.37.10. NO LOCK Phrase ═══ -----IBM Extension----- The NO LOCK phrase prevents the READ operation from obtaining record locks on files that you open in I-O (update) mode. A READ statement bearing this phrase also releases records that have been locked by a previous READ operation. If you use this phrase for a file that is not open in I-O mode, you will receive an error message at compilation time. ---End of IBM Extension--- ═══ 12.37.11. FORMAT Phrase ═══ -----IBM Extension----- The FORMAT phrase applies only when the READ statement is performed against an indexed file for which the ASSIGN specified DATABASE as the file device type. The value specified in the FORMAT phrase contains the name of the record format to use for this I-O operation. The system uses this to specify or select which record format to operate on. Identifier-2, if specified, must be an alphanumeric data item of 10 characters or less. Literal-1, if specified, must be an uppercase character-string of 10 characters or less. If the FORMAT phrase is not specified, the first format defined is used when accessing indexed files in random access mode. A value of all blanks is treated as though the FORMAT phrase were not specified. If the value is not valid for the file, a FILE STATUS of 9K is returned and a USE procedure is invoked, if applicable for the file. When the file is read in sequential access mode, the next record in the keyed sequence access path that has the requested format is made available. If omitted, the next record in the keyed sequence access path is made available. When the file is read in random access mode, the key as defined for the specified format is used to get a record of that format. If a record of that format is not found, an INVALID KEY condition is raised. This occurs even when there are records that have the defined key, but that have a different record format. If the format is omitted, the common key for the file is used to get the first record of any format that has that common key value. The common key for a file consists of the key fields common to all formats of a file for records residing on the database. The common key for a file is the leftmost key fields that are common across all record formats in the file. The common key is built from the data in the record description area using the first record format defined in the program for the file. When the file is read in dynamic access mode, the next record made available is determined as follows: ┌─────────────────────────┬────────────────────────────────────────────────────┐ │ │ FORMAT Phrase │ │ ├──────────────────────────┬─────────────────────────┤ │ │ Specified │ Omitted │ ├─────────────────────────┼──────────────────────────┼─────────────────────────┤ │ NEXT │ The next record in the │ The next record in the │ │ │ keyed sequence access │ keyed sequence access │ │ │ path having the speci- │ path is made available │ │ │ fied format is made │ regardless of its │ │ │ available. │ format. │ ├─────────────────────────┼──────────────────────────┼─────────────────────────┤ │ PRIOR │ The record in the keyed │ The record in the keyed │ │ │ sequence access path │ sequence access path │ │ │ preceding the record │ preceding the record │ │ │ identified by the file │ identified by the file │ │ │ position indicator │ position indicator is │ │ │ having the specified │ made available regard- │ │ │ format is made avail- │ less of its format. │ │ │ able. │ │ ├─────────────────────────┼──────────────────────────┼─────────────────────────┤ │ FIRST │ The first record in the │ The first record in the │ │ │ keyed sequence access │ keyed sequence access │ │ │ path having the speci- │ path is made available │ │ │ fied format is made │ regardless of its │ │ │ available. │ format. │ ├─────────────────────────┼──────────────────────────┼─────────────────────────┤ │ LAST │ The last record in the │ The last record in the │ │ │ keyed sequence access │ keyed sequence access │ │ │ path having the speci- │ path is made available │ │ │ fied format is made │ regardless of its │ │ │ available. │ format. │ ├─────────────────────────┼──────────────────────────┼─────────────────────────┤ │ None of the above │ The key as defined for │ The common key for the │ │ │ the specified format is │ file is used to get the │ │ │ used to get a record of │ first record of any │ │ │ that format. If a │ format that has that │ │ │ record of that format is │ common key value. The │ │ │ not found, an INVALID │ common key for a file │ │ │ KEY condition is raised. │ consists of the key │ │ │ This occurs even when │ fields common to all │ │ │ there are records that │ formats of a file for │ │ │ have the defined key, │ records residing on the │ │ │ but that have a dif- │ database. The common │ │ │ ferent record format. │ key for a file consists │ │ │ │ of the leftmost key │ │ │ │ fields that are common │ │ │ │ across all record │ │ │ │ formats in the file. │ │ │ │ The common key is built │ │ │ │ from the data in the │ │ │ │ record description area │ │ │ │ using the first record │ │ │ │ format defined in the │ │ │ │ program for the file. │ └─────────────────────────┴──────────────────────────┴─────────────────────────┘ ---End of IBM Extension--- ═══ 12.37.12. AT END Phrase ═══ The AT END phrase applies only when a file is read in sequential access mode or dynamic access mode. If a next record does not exist in the file when a sequential read is processed, an AT END condition occurs (the high order digit of the file status is 1), and READ statement processing is unsuccessful. The following actions take place: 1. If the FILE STATUS clause is specified, the status key is updated to indicate an AT END condition. 2. If the AT END phrase is specified, control is transferred to the AT END imperative statement. Any EXCEPTION/ERROR procedure for this file is not run. 3. If the AT END phrase is not specified, any EXCEPTION/ERROR procedure for this file is run. Return from that procedure is to the next executable statement following the end of the READ statement. Note: A sequential read can be a read on a file with sequential access, or, a read NEXT, FIRST, LAST, or PRIOR, on a file with dynamic access. READ FIRST and READ LAST will only result in an AT END condition if there are no records in the file. When the AT END condition occurs, execution of the READ statement is unsuccessful. The contents of the associated record area are undefined and the file position indicator is set to indicate that no valid next record has been established. If a sequential READ operation is attempted after an AT END condition has been raised without an intervening successful START or random READ, it will produce a file status of 46 and the AT END phrase will not be executed. A READ FIRST or READ LAST operation will always result in an AT END condition if the file remains empty. A READ PRIOR after an AT END condition will also result in a file status of 46. Neither the AT END phrase nor the NOT AT END phrase will be executed. If an AT END condition does not occur during the execution of a READ statement, the AT END phrase is ignored, if specified, and the following actions occur: 1. The file position indicator is set and the I-O status associated with file-name-1 is updated. 2. If an exception condition which is not an AT END condition exists, control is transferred according to rules of the USE statement following the execution of any USE AFTER EXCEPTION procedure applicable to file-name-1. 3. If no exception condition exists, the record is made available in the record area and any implicit move resulting from the presence of an INTO phrase is executed. Control is transferred to the end of the READ statement or to imperative-statement-2, if specified. In the latter case, execution continues according to the rules for each statement specified in imperative-statement-2. If a procedure branching or conditional statement which causes explicit transfer of control is executed, control is transferred in accordance with the rules for that statement; otherwise, upon completion of the execution of imperative-statement-2, control is transferred to the end of the READ statement. Following the unsuccessful execution of a READ statement, the contents of the associated record area are undefined and the file position indicator is set to indicate that no valid next record has been established. The AT END phrase must be specified if no explicit or implicit EXCEPTION/ERROR procedure is specified for the file. When a sequential file is being read and the AT END condition is recognized, a successful CLOSE statement, followed by a successful OPEN statement must be processed for this file before processing a READ statement. When a relative or indexed file is being read and the AT END condition is recognized, a sequential access READ statement for this file, other than a READ FIRST or READ LAST statement where permitted, must not be processed without first processing one of the following:  A successful CLOSE statement followed by a successful OPEN statement.  A successful START statement for this file.  A successful random access READ statement for this file.  A successful READ file-name FIRST or READ file-name LAST where permitted. ═══ 12.37.13. Sequential Files ═══ Sequential files can be read from the following device types:  TAPEFILE  DISKETTE  DISK  DATABASE Sequential files can only be read in sequential access mode. The record that is made available by the READ statement is determined as follows:  If the file position indicator was set by the processing of an OPEN statement, the record pointed to is made available.  If the file position indicator was set by the processing of a previous READ statement, the pointer is updated to point to the next existing record in the file. That record is then made available. If SELECT OPTIONAL is specified in the file-control entry for this file and the file is not available when this program runs, processing of the first READ statement causes an AT END condition. Since the file is not available, the standard system end-of-file processing is not done when the file is closed. Related Information:  Special Considerations for Device Types TAPEFILE and DISKETTE ═══ 12.37.14. Special Considerations for Device Types TAPEFILE and DISKETTE ═══ If end of volume is recognized during processing of a READ statement and logical end of file has not been reached, the following actions are taken in the order listed: 1. The standard ending volume label procedure is processed. 2. A volume switch occurs. 3. The standard beginning volume label procedure is run. 4. The first data record of the next volume is made available. The program receives no indication that the above actions occurred during the read operation. ═══ 12.37.15. Relative Files ═══ Relative files can be read from the following device types:  DISK  DATABASE Relative files can be read in sequential, random, or dynamic access modes. When a relative file is read in sequential access mode, the record that is made available by the READ statement is determined as follows:  If the file position indicator was set by the processing of a START or OPEN statement, the record pointed to is made available if it is still accessible through the path indicated by the file position indicator. If the record is no longer accessible (due, for example, to deletion of the record), the current record pointer is updated to indicate the next existing record in the file. That record is then made available.  If the file position indicator was set by the processing of a previous READ statement, the file position indicator is updated to point to the next existing record in the file. That record is then made available. If the RELATIVE KEY phrase is specified for this file, READ statement processing updates the RELATIVE KEY data item to indicate the relative record number of the record being made available. When a relative file is read in random access mode, the record with the relative record number contained in the RELATIVE KEY data item is made available. If the file does not contain such a record, the INVALID KEY condition exists, and READ statement processing is unsuccessful. ═══ 12.37.16. Indexed Files ═══ Indexed files can be read from the following device types:  DISK  DATABASE Indexed files can be read in sequential, random, or dynamic access modes. When an indexed file is read in sequential access mode, the record made available by the READ statement is determined as follows:  If the file position indicator was set by the processing of a START or OPEN statement, the record pointed to is made available if it is still accessible through the path indicated by the current record pointer. If the record is no longer accessible (due, for example, to deletion of the record), the file position indicator is updated to indicate the next existing record in the file. That record is then made available.  If the file position indicator was set by the processing of a previous READ statement, the file position indicator is updated to point to the next existing record in the file. That record is then made available. -----IBM Extension----- For a file that allows duplicate keys (the DUPLICATES phrase is specified in the file-control entry), the records with duplicate key values are made available in the order specified when the file was created. The system options are first-in first-out (FIFO), last-in first-out (LIFO), and no specific sequence (if neither LIFO not FIFO is specified). ---End of IBM Extension--- When an indexed file is read in random access mode, the record in the file with a key value equal to that of the RECORD KEY data item is then made available. If the file does not contain such a record, the INVALID KEY condition exists, and READ statement processing is unsuccessful. If the FORMAT phrase is not specified on the I-O statement when indexed files are read in random access mode, the first format defined in the file is used. Note that if externally described keys are being used and no format is specified, the first format included in the program is the one used to build the key. This format may not necessarily be the first format in the file. -----IBM Extension----- For a file that allows duplicate keys (the DUPLICATES phrase is specified in the file-control entry), the first record with the specified key value is made available. The first record is determined by the order specified when the file was created. The system options are first-in first-out (FIFO), last-in first-out (LIFO), and no specific sequence (if neither LIFO not FIFO is specified). ---End of IBM Extension--- To enable file status 02 for DUPLICATE KEY checking, you need:  The WITH DUPLICATES phrase in the SELECT clause  OPEN I-O or OPEN INPUT  The *DUPKEYCHK option of the OPTION parameter, or the DUPKEYCHK option of the PROCESS statement. ═══ 12.37.17. Multiple Record Processing ═══ If more than one record description entry is associated with file-name-1, these records automatically share the same storage area; that is, they are implicitly redefined. After a READ statement is executed, only those data items within the range of the current record are replaced; data items stored beyond that range are undefined. READ Statement with Multiple Record Description illustrates this concept. If the range of the current record exceeds the record description entries for file-name, the record is truncated on the right to the maximum size. In either of these cases, the READ statement is successful and an I-O status is set indicating a record length conflict has occurred. The FD entry is: FD INPUT-FILE LABEL RECORDS OMITTED. 01 RECORD-1 PICTURE X(30). 01 RECORD-2 PICTURE X(20). Contents of input area when READ statement is executed: ─────────────────────────────── ABCDEFGHIJKLMNOPQRSTUVWXYZ1234 ─────────────────────────────── Contents of record being read in (RECORD-2): ──────────────────── 01234567890123456789 ──────────────────── Contents of input area after READ is executed: 01234567890123456789?????????? │ │ │ │ └────────┘ (these characters in input area undefined) READ Statement with Multiple Record Description ═══ 12.37.18. Multivolume Files ═══ If end-of-volume is recognized during execution of a READ statement, and logical end-of-file has not been reached, the following actions are taken:  The system-defined ending volume label procedure  A volume switch  The system-defined beginning volume label procedure  The first data record of the next volume is made available. ═══ 12.37.19. READ Statement - Format 4 - Transaction (Nonsubfile) ═══ -----IBM Extension----- ┌─── READ STATEMENT - FORMAT 4 - TRANSACTION (NONSUBFILE) ─────────────────────┐ │ │ │ >>──READ──file-name──┬────────┬──┬────────────────────┬────────────────────> │ │ └─RECORD─┘ └─INTO──identifier-1─┘ │ │ │ │ >──┬────────────────────────────────────┬──────────────────────────────────> │ │ └─FORMAT─┬──────┬──┬─identifier-2─┬──┘ │ │ └─IS───┘ └─literal-1────┘ │ │ │ │ >──┬──────────────────────────────────────┬────────────────────────────────> │ │ └─TERMINAL─┬──────┬──┬─identifier-3─┬──┘ │ │ └─IS───┘ └─literal-2────┘ │ │ │ │ >──┬────────────────────────────────────────┬──────────────────────────────> │ │ └──┬─INDICATOR──┬──┬──────┬─identifier-4─┘ │ │ ├─INDICATORS─┤ ├─IS───┤ │ │ └─INDIC──────┘ └─ARE──┘ │ │ │ │ >──┬─────────────────────────────────┬─────────────────────────────────────> │ │ └─NO DATA──imperative-statement-1─┘ │ │ │ │ >──┬────────────────────────────────────────┬──────────────────────────────> │ │ └─┬──────┬──END───imperative-statement-2─┘ │ │ └─AT───┘ │ │ │ │ >──┬──────────────────────────────────────────────┬──┬──────────┬──>< │ │ └─NOT───┬──────┬──END───imperative-statement-3─┘ └─END-READ─┘ │ │ └─AT───┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Format 4 is used only to read a format that is not a subfile record. The RELATIVEKEY data item, if specified in the FILE-CONTROL entry, is not used. The Format 4 READ statement is not valid for a subfile record; however, a Format 4 READ statement for the subfile control record format must be used to put those subfile records that were updated on a display into the subfile. If the data is available, it is returned in the record area. The names of the record format and the program device are returned in the I-O-FEEDBACK area and in the CONTROL-AREA. The READ statement is valid only when there are acquired devices for the file. If a READ is executed and there are no acquired devices, the file status is set to 92 (logic error). The manner in which the Format 4 READ statement functions depends on whether:  The READ is for a single device file or a multiple device file  A specific program device has been requested through the TERMINAL phrase  A specific record format has been requested through the FORMAT phrase  The NO DATA phrase has been specified ---End of IBM Extension--- ═══ 12.37.20. READ Statement - Format 5 - Transaction (Subfile) ═══ -----IBM Extension----- ┌─── READ - FORMAT 5A - TRANSACTION (SUBFILE SEQUENTIAL) ──────────────────────┐ │ │ │ >>──READ SUBFILE──file-name──┬──────┬──MODIFIED──┬────────┬────────────────> │ │ └─NEXT─┘ └─RECORD─┘ │ │ │ │ >──┬────────────────────┬──┬────────────────────────────────────┬──────────> │ │ └─INTO──identifier-1─┘ └─FORMAT─┬──────┬──┬─identifier-2─┬──┘ │ │ └─IS───┘ └─literal-1────┘ │ │ │ │ >──┬──────────────────────────────────────┬────────────────────────────────> │ │ └─TERMINAL─┬──────┬──┬─identifier-3─┬──┘ │ │ └─IS───┘ └─literal-2────┘ │ │ │ │ >──┬────────────────────────────────────────┬──────────────────────────────> │ │ └──┬─INDICATOR──┬──┬──────┬─identifier-4─┘ │ │ ├─INDICATORS─┤ ├─IS───┤ │ │ └─INDIC──────┘ └─ARE──┘ │ │ │ │ >──┬────────────────────────────────────────┬──────────────────────────────> │ │ └─┬──────┬──END───imperative-statement-3─┘ │ │ └─AT───┘ │ │ │ │ >──┬──────────────────────────────────────────────┬──┬──────────┬──>< │ │ └─NOT───┬──────┬──END───imperative-statement-4─┘ └─END-READ─┘ │ │ └─AT───┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Format 5a is used to read a format that is a subfile record, in sequential access mode. The NEXT MODIFIED phrase must be specified to access subfile records sequentially. The AT END phrase can only be specified with the NEXT MODIFIED phrase. ┌─── READ - FORMAT 5B - TRANSACTION (SUBFILE RANDOM) ──────────────────────────┐ │ │ │ >>──READ SUBFILE──file-name──┬────────┬──┬────────────────────┬────────────> │ │ └─RECORD─┘ └─INTO──identifier-1─┘ │ │ │ │ >──┬────────────────────────────────────┬──────────────────────────────────> │ │ └─FORMAT─┬──────┬──┬─identifier-2─┬──┘ │ │ └─IS───┘ └─literal-1────┘ │ │ │ │ >──┬──────────────────────────────────────┬────────────────────────────────> │ │ └─TERMINAL─┬──────┬──┬─identifier-3─┬──┘ │ │ └─IS───┘ └─literal-2────┘ │ │ │ │ >──┬────────────────────────────────────────┬──────────────────────────────> │ │ └──┬─INDICATOR──┬──┬──────┬─identifier-4─┘ │ │ ├─INDICATORS─┤ ├─IS───┤ │ │ └─INDIC──────┘ └─ARE──┘ │ │ │ │ >──┬─────────────────────────────────────────┬─────────────────────────────> │ │ └─INVALID─┬──────┬─imperative-statement-1─┘ │ │ └─KEY──┘ │ │ │ │ >──┬──────────────────────────────────────────────┬──┬──────────┬──>< │ │ └─NOT INVALID─┬──────┬─imperative-statement-2─┘ └─END-READ─┘ │ │ └─KEY──┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Format 5b is used to read a format that is a subfile record, in random access mode. The INVALID KEY phrase can only be used for random access of subfile records. The NEXT MODIFIED phrase must not be used to randomly access subfile records. Format 5a or 5b cannot be used for communications devices. If the subfile format of the READ statement is used for a communications device, the READ fails and a file status of 90 is set. ---End of IBM Extension--- ═══ 12.37.21. NEXT MODIFIED Phrase ═══ -----IBM Extension----- When NEXT MODIFIED is not specified, the data record made available is the record in the subfile with a relative record number that corresponds to the value of the RELATIVE KEY data item. When the NEXT MODIFIED phrase is not specified, and if the RELATIVE KEY data item contains a value other than the relative record number of a record in the subfile, the INVALID KEY condition exists and the execution of the READ statement is unsuccessful. When the NEXT MODIFIED phrase is specified, the record made available is the first record in the subfile that has been modified (has the Modified Data Tag on). The search for the next modified record begins:  At the beginning of the subfile if: - An I-O operation has been performed for the subfile control record. - The I-O operation cleared, initialized, or displayed the subfile.  For all other cases, with the record following the record that was read by a previous read operation. The value of the RELATIVE KEY data item is updated to reflect the relative record number of the record made available to the program. If NEXT MODIFIED is specified and there is no user-modified record in the subfile with a relative record number greater than the relative record number contained in the RELATIVE KEY data item, the AT END condition exists, the file status is set to 12, and the value of the RELATIVE KEY data item is set to the key of the last record in the subfile. Imperative-statement-2, or any applicable USE AFTER ERROR/EXCEPTION procedure, if any, is then executed. ---End of IBM Extension--- ═══ 12.37.22. FORMAT Phrase ═══ -----IBM Extension----- When a format-name is not specified, the format used is the last record format written to the display device that contains input fields, input/output fields, or hidden fields. If no such format exists for the display file, the format used is the record format of the last WRITE operation to the display device. If the FORMAT phrase is specified, literal-1 or the contents of identifier-2 must specify a format which is active for the appropriate program device. The READ statement reads a data record of the specified format. The FORMAT phrase must always be specified for multiple format files to ensure correct results. ---End of IBM Extension--- ═══ 12.38. RELEASE Statement ═══ The RELEASE statement transfers records from an input/output area to the initial phase of a sorting operation. The RELEASE statement can only be used within the range of an input procedure associated with a SORT statement. ┌─── RELEASE STATEMENT - FORMAT ───────────────────────────────────────────────┐ │ │ │ >>──RELEASE──record-name-1──┬────────────────────┬──>< │ │ └─FROM──identifier-1─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Within an INPUT PROCEDURE, at least one RELEASE statement must be specified. When the RELEASE statement is executed, the current contents of record-name-1 are placed in the sort file; that is, made available to the initial phase of the sorting operation. Record-name-1 and identifier-1 must not refer to the same storage area. If the RELEASE statement is executed without specifying the SD entry for file-name-1 in a SAME RECORD AREA clause, the information in record-name-1 is no longer available. If the SD entry is specified in a SAME RECORD AREA clause, record-name-1 is still available as a record of the other files named in that clause. When FROM identifier-1 is specified, the information is still available in identifier-1. When control passes from the INPUT PROCEDURE, the sort file consists of all those records placed in it by execution of RELEASE statements. ═══ 12.39. RETURN Statement ═══ The RETURN statement transfers records from the final phase of a sort or merge operation to an OUTPUT PROCEDURE. The RETURN statement can be used only within the range of an output procedure associated with a SORT or MERGE statement. ┌─── RETURN STATEMENT - FORMAT ────────────────────────────────────────────────┐ │ │ │ >>──RETURN──file-name-1──┬────────┬──┬────────────────────┬────────────────> │ │ └─RECORD─┘ └─INTO──identifier-1─┘ │ │ │ │ >──┬──────┬──END───imperative-statement-1──────────────────────────────────> │ │ └─AT───┘ │ │ │ │ >──┬──────────────────────────────────────────────┬──┬────────────┬──>< │ │ └─NOT───┬──────┬──END───imperative-statement-2─┘ └─END-RETURN─┘ │ │ └─AT───┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Within an OUTPUT PROCEDURE, at least one RETURN statement must be specified. When the RETURN statement is executed, the next record from file-name-1 is made available for processing by the OUTPUT PROCEDURE. The record areas associated with file-name-1 and identifier-1 must not be the same storage area. The record is available in both the record area and the data-item referenced by identifier-1. ═══ 12.39.1. file-name-1 ═══ Must be described in a Data Division SD entry. If more than one record description is associated with file-name-1, these records automatically share the same storage; that is, the area is implicitly redefined. After RETURN statement execution, only the contents of the current record are available; if any data items lie beyond the length of the current record, their contents are undefined. ═══ 12.39.2. INTO identifier-1 ═══ The RETURN INTO statement is equivalent to the statements: RETURN file-name-1 MOVE record-name TO identifier-1 Moving takes place according to the rules for the MOVE statement without the CORRESPONDING phrase. The size of the current record is determined by rules specified for the RECORD clause. If the file description entry contains a RECORD IS VARYING clause, the implied MOVE is a group move. However, the implied MOVE does not occur when the RETURN statement is unsuccessful. Any subscripting, indexing, or reference modification associated with identifier-1 is evaluated after the record has been returned and immediately before it is moved to identifier-1. The INTO phrase may be specified in a RETURN statement if one or both of the following are true:  If only one record description is subordinate to the sort-merge file description entry, and/or  If all record-names associated with file-name-1 and the data item referenced by identifier-1 describe a group item, a numeric-edited item, or an elementary alphanumeric item. ═══ 12.39.3. AT END Phrases ═══ The imperative-statement specified on the AT END phrase executes after all records have been returned from file-name-1. No more RETURN statements may be executed as part of the current output procedure. If an at end condition does not occur during the execution of a RETURN statement, then after the record is made available and after executing any implicit move resulting from the presence of an INTO phrase, control is transferred to the imperative statement specified by the NOT AT END phrase, otherwise control is passed to the end of the RETURN statement. ═══ 12.39.4. END-RETURN Phrase ═══ This explicit scope terminator serves to delimit the scope of the RETURN statement. END-RETURN permits a conditional RETURN statement to be nested in another conditional statement. END-RETURN may also be used with an imperative RETURN statement. For more information, see Delimited Scope Statements. ═══ 12.40. REWRITE Statement ═══ The REWRITE statement logically replaces an existing record in a direct-access file. When the REWRITE statement is executed, the associated direct-access file must be open in I-O mode. The REWRITE statement has two formats:  Format 1 - REWRITE -----IBM Extension-----  Format 2 - REWRITE (Transaction - Subfile) ---End of IBM Extension--- -----IBM Extension----- The action of this statement can be inhibited at program run time by the inhibit write (INHWRT) parameter of the Override with database file (OVRDBF) CL command. When this parameter is specified, nonzero file status codes are not set for data dependent errors. Duplicate key and data conversion errors are examples of data dependent errors. ---End of IBM Extension--- Related Information:  REWRITE Statement Considerations  Reusing a Logical Record  Sequential Files  Indexed Files  Relative Files ═══ 12.40.1. REWRITE Statement ═══ ┌─── REWRITE STATEMENT - FORMAT 1 ─────────────────────────────────────────────┐ │ │ │ >>──REWRITE──record-name-1──┬────────────────────┬─────────────────────────> │ │ └─FROM──identifier-1─┘ │ │ │ │ >──┬───────────────────────────────────────┬───────────────────────────────> │ │ │ (1) │ │ │ └─FORMAT────┬──────┬──┬─identifier-2─┬──┘ │ │ └─IS───┘ └─literal-1────┘ │ │ │ │ >──┬───────────────────────────────────────────┬───────────────────────────> │ │ └─INVALID──┬──────┬──imperative-statement-1─┘ │ │ └─KEY──┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──┬─────────────┬──>< │ │ └─NOT INVALID──┬──────┬──imperative-statement-2─┘ └─END-REWRITE─┘ │ │ └─KEY──┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.40.2. FROM Phrase ═══ This phrase has the following effect: MOVE identifier-1 TO record-name-1. REWRITE record-name-1. After successful processing of the REWRITE statement, the current record is no longer available in record-name-1, but is still available in identifier-1. Both record-name-1 and identifier-1 cannot refer to the same storage area. ═══ 12.40.3. INVALID KEY Phrase ═══ This phrase is valid in indexed organization files, and relative organization files with random or dynamic access. It is processed when the record specified by the key field in the record area is not found. When an INVALID KEY condition exists, the updating operation does not take place. The data in record-name is unaffected. This phrase transfers control to the corresponding imperative-statement, as appropriate. The INVALID KEY phrase must be specified if no applicable EXCEPTION/ERROR procedure is specified for record-name-1. An INVALID KEY condition exists when:  The access mode is sequential, and the value contained in the prime RECORD KEY of the record to be replaced does not equal the value of the prime RECORD KEY data item of the last-retrieved record from the file, or  The value contained in the prime RECORD KEY does not equal that of any record in the file. The INVALID KEY phrase must be specified for files in which an applicable USE procedure is not specified. See "Invalid Key Condition" under Common Processing Facilities for more information. For sequentially accessed indexed files on device type DISK, this phrase is processed when the value contained in the RECORD KEY of the record to be replaced does not equal the RECORD KEY data item of the last retrieved record from the file. ═══ 12.40.4. NOT INVALID KEY Phrase ═══ This phrase is valid for indexed organization files, and relative organization files with random or dynamic access. After the successful completion of a REWRITE statement with the NOT INVALID KEY phrase, control transfers to the imperative statement associated with the phrase. ═══ 12.40.5. FORMAT Phrase ═══ This phrase applies when the REWRITE statement is performed against an indexed file for which the ASSIGN specified DATABASE as the file device type. It is optional when processing a file that has one record format. -----IBM Extension----- The value specified in the FORMAT phrase contains the name of the record format to use for this I-O operation. The system uses this to specify or select which record format to operate on. Identifier-2, if specified, must be an alphanumeric data item of 10 characters or less. Literal-1, if specified, must be an uppercase character-string of 10 characters or less. If the FORMAT phrase is not specified, the first format defined is used when accessing indexed files in Random Access Mode. A value of all blanks is treated as though the FORMAT phrase were not specified. If the value is not valid for the file, a FILE STATUS of 9K is returned and a USE procedure is invoked, if applicable for the file. ---End of IBM Extension--- ═══ 12.40.6. REWRITE Statement Considerations ═══ For relative organization files, random or dynamic access modes, the record to be replaced is specified by the value in the RELATIVE KEY data item. If the file does not contain such a record, an INVALID KEY condition exists. For indexed organization files, sequential access mode, the value of the RECORD KEY data-item must not have been changed since the record was last read. For indexed organization files, random or dynamic access modes, the record to be replaced is specified by the value in the RECORD KEY data item. If the file does not contain such a record, an INVALID KEY condition exists. -----IBM Extension----- When EXTERNALLY-DESCRIBED-KEY is specified for the file, the key field in the record area for the format specified by the FORMAT phrase (or, if not specified, the first format defined in the program for the file), is used to find the record to be replaced. If the DUPLICATES phrase was specified for the file, the last input/output statement processed for this file before the REWRITE statement must have been a successfully processed READ statement without the NO LOCK phrase. The record read by that statement is the one that is replaced. In this case, the FORMAT phrase is not used in determining the record to be replaced. The READ statement is required to ensure that the proper record is replaced when there are duplicates. If a successful READ operation did not occur before the REWRITE operation:  The file status key, if defined, is set to 94.  The EXCEPTION/ERROR procedure, if any, is run.  The REWRITE statement is not processed. If the last input/output statement was a successfully processed READ statement with the NO LOCK phrase:  The file status key, if defined, is set to 9S.  The EXCEPTION/ERROR procedure, if any, is run.  The REWRITE statement is not processed. The value of the RECORD KEY data item should not have changed since the record was read. By default, if it has changed:  The file status key, if defined, is set to 21.  An INVALID KEY condition exists.  The REWRITE operation does not occur. Note: The only way to rewrite one of a sequence of records with duplicate keys is to sequentially read each of the duplicate records and rewrite the desired one. ---End of IBM Extension--- ═══ 12.40.6.1. Reusing a Record ═══ After successful execution of a REWRITE statement, the record is no longer available in record-name-1 unless the associated file is named in a SAME RECORD AREA clause (in which case, the record is also available as a record of the other files named in the SAME RECORD AREA clause). The file position indicator is not affected by execution of the REWRITE statement. If the FILE STATUS clause is specified in the FILE-CONTROL entry, the associated status key is updated when the REWRITE statement is executed. ═══ 12.40.6.2. Sequential Files ═══ For files in the sequential access mode, the last prior input/output statement executed for this file must be a successfully executed READ statement. When the REWRITE statement is executed, the record retrieved by that READ statement is logically replaced. The number of character positions in record-name-1 must equal the number of character positions in the record being replaced. The INVALID KEY and NOT INVALID KEY phrases must not be specified for a file with sequential organization. An EXCEPTION/ERROR procedure may be specified. ═══ 12.40.6.3. Indexed Files ═══ The number of character positions in record-name-1 can be different from the number of character positions in the record being replaced. When the access mode is sequential, the record to be replaced is specified by the value contained in the prime RECORD KEY. When the REWRITE statement is executed, this value must equal the value of the prime record key data item in the last record read from this file. The INVALID KEY phrase must be specified if an applicable USE AFTER STANDARD EXCEPTION procedure is not specified for the associated file-name. When the access mode is random or dynamic, the record to be replaced is specified by the value contained in the prime RECORD KEY. If the FORMAT phrase is not specified on the I-O statement when indexed files are read in random access mode, the first format defined is used. If an invalid key condition exists, the execution of the REWRITE statement is unsuccessful, the updating operation does not take place, and the data in record-name-1 is unaffected. (See INVALID KEY Condition.) ═══ 12.40.6.4. Relative Files ═══ The number of character positions in record-name-1 can be different from the number of character positions in the record being replaced. For relative files in sequential access mode, the INVALID KEY and NOT INVALID KEY phrases must not be specified. An EXCEPTION/ERROR procedure may be specified. The INVALID KEY phrase must be specified in the REWRITE statement for relative files in the random or dynamic access mode, and for which an appropriate USE AFTER STANDARD EXCEPTION procedure is not specified. When the access mode is random or dynamic, the record to be replaced is specified in the RELATIVE KEY data item. If the file does not contain the record specified, an invalid key condition exists, and, if specified, the INVALID KEY imperative-statement is executed. (See INVALID KEY Condition.) The updating operation does not take place, and the data in record-name is unaffected. ═══ 12.40.7. Transaction (Subfile) Format ═══ -----IBM Extension----- The REWRITE statement is used to replace a subfile record that already exists in the subfile. ┌─── REWRITE STATEMENT - FORMAT 2 - TRANSACTION (SUBFILE) ─────────────────────┐ │ │ │ >>──REWRITE SUBFILE──record-name-1──┬────────────────────┬─────────────────> │ │ └─FROM──identifier-1─┘ │ │ │ │ >──┬────────────────────────────────────┬──────────────────────────────────> │ │ └─FORMAT─┬──────┬──┬─identifier-2─┬──┘ │ │ └─IS───┘ └─literal-1────┘ │ │ │ │ >──┬──────────────────────────────────────┬────────────────────────────────> │ │ └─TERMINAL─┬──────┬──┬─identifier-3─┬──┘ │ │ └─IS───┘ └─literal-2────┘ │ │ │ │ >──┬────────────────────────────────────────┬──────────────────────────────> │ │ └──┬─INDICATOR──┬──┬──────┬─identifier-4─┘ │ │ ├─INDICATORS─┤ ├─IS───┤ │ │ └─INDIC──────┘ └─ARE──┘ │ │ │ │ >──┬───────────────────────────────────────────┬───────────────────────────> │ │ └─INVALID──┬──────┬──imperative-statement-1─┘ │ │ └─KEY──┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──┬─────────────┬──>< │ │ └─NOT INVALID──┬──────┬──imperative-statement-2─┘ └─END-REWRITE─┘ │ │ └─KEY──┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The number of character positions in the record referenced by record-name-1 must be equal to the number of character positions in the record being replaced. A successful read operation on the record must be done prior to the rewrite operation. The record replaced in the subfile is that record accessed by the previous read operation. ---End of IBM Extension--- ═══ 12.41. ROLLBACK Statement ═══ -----IBM Extension----- The ROLLBACK statement provides a way to cancel one or more changes to database records when the changes should not remain permanent. ┌─── ROLLBACK STATEMENT - FORMAT ──────────────────────────────────────────────┐ │ │ │ >>──ROLLBACK──>< │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ When the ROLLBACK statement is executed, any changes made to files under commitment control since the last commitment boundary are removed from the database. Note that when a file is cleared while being opened for OUTPUT, execution of a ROLLBACK statement does not restore cleared records to the file. A commitment boundary is the previous occurrence of a ROLLBACK or COMMIT statement. If no COMMIT or ROLLBACK has been issued, the commitment boundary is the first OPEN of a file under commitment control. Removal of changes takes place for all files under commitment control and not just for files under commitment control in the COBOL program that issues the ROLLBACK. Once the ROLLBACK is successfully executed, all record locks held for files under commitment control are released and the records become available to other jobs. Commitment control can be scoped at the job level or the activation group level. (Commitment control is scoped at the activation group level by default.) The ROLLBACK has no effect on files not under commitment control. If a ROLLBACK is executed and there are no files under commitment control, the ROLLBACK is ignored. A file under commitment control can be opened or closed without affecting the status of changes made since the last commitment boundary. A COMMIT must still be issued to make the changes permanent. A ROLLBACK, when executed, leaves files in the same open or closed state as before execution. The ROLLBACK statement does not:  modify the I-O-FEEDBACK area for any file  set a file status value for any file. For the ROLLBACK statement, the following considerations apply:  The ROLLBACK statement sets the file position indicator to its position at the previous commitment boundary. This is important to remember if you are doing sequential processing.  If no COMMIT statement has been issued since the file was opened, the ROLLBACK statement sets the file position indicator to its position at the OPEN.  The file position indicator is undefined after a ROLLBACK if the file is closed with uncommitted changes. If commitment control is scoped at the job level, an implicit ROLLBACK of uncommitted records is automatically done for all files under commitment control at the end of every job. Any uncommitted changes to the database are cancelled. If commitment control is scoped at the activation group level, an implicit commit occurs when the activation group ends normally. If the activation group ends abnormally, an implicit ROLLBACK occurs. ---End of IBM Extension--- ═══ 12.42. SEARCH Statement ═══ The SEARCH statement searches a table for an element that satisfies the specified condition, and adjusts the associated index to indicate that element. The SEARCH statement has two formats:  Format 1 - Serial Search  Format 2 - Binary Search Related Information:  SEARCH Statement Considerations  Coding Example ═══ 12.42.1. SEARCH Statement - Format 1 - Serial Search ═══ ┌─── SEARCH STATEMENT - FORMAT 1 - SERIAL SEARCH ──────────────────────────────┐ │ │ │ >>──SEARCH──identifier-1──┬───────────────────────────┬────────────────────> │ │ └─VARYING──┬─identifier-2─┬─┘ │ │ └─index-name-1─┘ │ │ │ │ >──┬────────────────────────────────────────┬──────────────────────────────> │ │ └─┬──────┬──END───imperative-statement-1─┘ │ │ └─AT───┘ │ │ │ │ ┌───────────────────────────────────────────────┐ │ │  │ │ │ >──┬───WHEN──condition-1──┬─imperative-statement-2─┬─┴─────────────┬──>< │ │ │ └─NEXT SENTENCE──────────┘ │ │ │ │ ┌───────────────────────────────────────────┐ │ │ │ │  │ │ │ │ └───WHEN──condition-1──imperative-statement-2─┴──┬────────────┬─┘ │ │ └─END-SEARCH─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Related Information:  Execution of a Serial Search ═══ 12.42.2. SEARCH Statement - Format 2 - Binary Search ═══ ┌─── SEARCH STATEMENT - FORMAT 2 - BINARY SEARCH ──────────────────────────────┐ │ │ │ >>──SEARCH ALL──identifier-1──┬────────────────────────────────────────┬───> │ │ └─┬──────┬──END───imperative-statement-1─┘ │ │ └─AT───┘ │ │ │ │ ┌─────────────────────────────────┐ │ │  │ │ │ >──WHEN──┬─┤ equal phrase 1 ├─┬────┬─────────────────────────────┬─┴───────> │ │ └─condition-name-1─┴─┘ └─AND──┬─┤ equal phrase 2 ├─┬─┘ │ │ └─condition-name-2─┴─┘ │ │ │ │ >──┬─imperative-statement-2──┬────────────┬─┬──>< │ │ │ └─END-SEARCH─┘ │ │ │ └─NEXT SENTENCE──────────────────────────┘ │ │ │ │ EQUAL PHRASE 1: │ │ ├──data-name-1──┬────┬──┬─EQUAL──┬────┬─┬──┬─identifier-3────────────┬──┤ │ │ └─IS─┘ │ └─TO─┘ │ ├─literal-1───────────────┤ │ │ └─=─────────────┘ └─arithmetic-expression-1─┘ │ │ │ │ EQUAL PHRASE 2: │ │ ├──data-name-2──┬────┬──┬─EQUAL──┬────┬─┬──┬─identifier-4────────────┬──┤ │ │ └─IS─┘ │ └─TO─┘ │ ├─literal-2───────────────┤ │ │ └─=─────────────┘ └─arithmetic-expression-2─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Related Information:  Execution of a Binary Search ═══ 12.42.3. identifier-1 ═══ Can be a data item subordinate to a data item that contains an OCCURS clause; that is, it can be a part of a multi-dimensional table. In this case, the data description entry must specify an INDEXED BY phrase for each dimension of the table. Identifier-1 can be an index data item. Identifier-1 must refer to all occurrences within the table element; that is, it must not be subscripted or reference modified. The Data Division description of identifier-1 must contain an OCCURS clause with the INDEXED BY phrase. SEARCH statement execution modifies only the value in the index-name associated with identifier-1 and, if present, of index-name-1 or identifier-2 Therefore, to search an entire two- to seven-dimensional table, it is necessary to execute a SEARCH statement for each dimension. Before each execution, SET statements must be executed to reinitialize the associated index-names. ═══ 12.42.4. AT END/WHEN Phrases ═══ After imperative-statement-1 or imperative-statement-2 is executed, control passes to the end of the SEARCH statement, unless imperative-statement-1 or imperative-statement-2 ends with a GO TO statement. Condition-1, condition-2 may be any condition described under Conditional Expressions. ═══ 12.42.5. NEXT SENTENCE Phrase ═══ This phrase causes the transfer of control to an implicit CONTINUE statement immediately preceding the next separator period. If the NEXT SENTENCE phrase is specified, the END-SEARCH phrase must not be specified. ═══ 12.42.6. END-SEARCH Phrase ═══ This explicit scope terminator serves to delimit the scope of the SEARCH statement. END-SEARCH permits a conditional SEARCH statement to be nested in another conditional statement. If the END-SEARCH phrase is specified, the NEXT SENTENCE phrase must not be specified. For more information, see Delimited Scope Statements. ═══ 12.42.7. Serial Search ═══ The Format 1 SEARCH statement executes a serial search beginning at the current index setting. When the search begins, if the value of the index-name associated with identifier-1 is not greater than the highest possible occurrence number, the following actions take place:  The condition(s) in the WHEN phrase are evaluated in the order in which they are written.  If none of the conditions is satisfied, the index-name for identifier-1 is increased to correspond to the next table element, and step 1 is repeated.  If upon evaluation, one of the WHEN conditions is satisfied, the search is terminated immediately, and the imperative-statement associated with that condition is executed. The index-name points to the table element that satisfied the condition. If NEXT SENTENCE is specified, control passes to the statement following the closest period.  If the end of the table is reached (that is, the incremented index-name value is greater than the highest possible occurrence number) without the WHEN condition being satisfied, the search is terminated, as described in the next paragraph. If, when the search begins, the value of the index-name associated with identifier-1 is greater than the highest possible occurrence number, the search immediately ends, and, if specified, the AT END imperative-statement is executed. If the AT END phrase is omitted, control passes to the next statement after the SEARCH statement. ═══ 12.42.7.1. index-name-1 ═══ One of the following actions applies:  If index-name-1 is an index for identifier-1, this index is used for the search. Otherwise, the first (or only) index-name is used.  If index-name-1 is an index for another table element, then the first (or only) index-name for identifier-1 is used for the search; the occurrence number represented by index-name-1 is increased by the same amount as the search index-name and at the same time. When the VARYING index-name-1 phrase is omitted, the first (or only) index-name for identifier-1 is used for the search. ═══ 12.42.7.2. identifier-2 ═══ Must be either an index data item or an elementary integer item. During the search, one of the following actions applies:  If identifier-2 is an index data item, then, whenever the search index is increased, the specified index data item is simultaneously increased by the same amount.  If identifier-2 is an integer data item, then, whenever the search index is increased, the specified data item is simultaneously increased by 1. ═══ 12.42.8. Binary Search ═══ The Format 2 SEARCH ALL statement executes a binary search. The search index need not be initialized by SET statements, because its setting is varied during the search operation so that its value is at no time less than the value of the first table element, nor ever greater than the value of the last table element. The index used is always that associated with the first index-name specified in the OCCURS clause. ═══ 12.42.8.1. identifier-1 ═══ Can be a data item subordinate to a data item that contains an OCCURS clause; that is, it can be a part of a two- to seven-dimensional table. In this case, the data description entry must specify an INDEXED BY phrase for each dimension of the table. Before the search takes place, the values of all indexes should be set for higher dimensions of the table to define a specific table of identifier-1 elements. Identifier-1 must refer to all occurrences within the table element; that is, it must not be subscripted or indexed. Identifier-1 cannot be a pointer data item or a procedure-pointer data item. The Data Division description of identifier-1 must contain an OCCURS clause with the INDEXED BY option. For Format-2, the Data Division description must also contain the KEY IS phrase in its OCCURS clause. ═══ 12.42.8.2. WHEN Phrase ═══ If the WHEN phrase cannot be satisfied for any setting of the index within this range, the search is unsuccessful. If the WHEN option can be satisfied, control passes to imperative-statement-2, and the index contains the value indicating the occurrence that allowed the WHEN condition(s) to be satisfied. The results of a SEARCH ALL operation are predictable only when:  The data in the table is ordered according to the ASCENDING/DESCENDING KEY phrase  The contents of the ASCENDING/DESCENDING keys specified in the WHEN clause provide a unique table reference. ═══ 12.42.8.3. Search Statement Considerations ═══ Index data items cannot be used as subscripts, because of the restrictions on direct reference to them. The use of a direct indexing reference together with a relative indexing reference for the same index-name allows reference to two different occurrences of a table element for comparison purposes. When the object of the VARYING option is an index-name for another table element, one Format 1 SEARCH statement steps through two table elements at once. To ensure correct execution of a SEARCH statement for a variable-length table, make sure the object of the OCCURS DEPENDING ON clause (data-name-1) contains a value that specifies the current length of the table. The scope of a SEARCH statement may be terminated by any of the following:  An END-SEARCH phrase at the same level of nesting  A separator period  An ELSE or END-IF phrase associated with a previous IF statement. ═══ 12.42.8.4. SEARCH Example ═══ The following example searches an inventory table for items that match those from input data. The key is ITEM-NUMBER. .. 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7 DATA DIVISION. FILE SECTION. FD SALES-DATA BLOCK CONTAINS 1 RECORDS RECORD CONTAINS 80 CHARACTERS LABEL RECORDS STANDARD DATA RECORD IS SALES-REPORTS. 01 SALES-REPORTS PIC X(80). FD PRINTED-REPORT BLOCK CONTAINS 1 RECORDS RECORD CONTAINS 132 CHARACTERS LABEL RECORDS OMITTED DATA RECORD IS PRINTER-OUTPUT. 01 PRINTER-OUTPUT PIC X(132). FD INVENTORY-DATA BLOCK CONTAINS 1 RECORDS RECORD CONTAINS 40 CHARACTERS LABEL RECORDS STANDARD DATA RECORD IS INVENTORY-RECORD. 01 INVENTORY-RECORD. 03 I-NUMBER PIC 9(4). 03 INV-ID PIC X(26). 03 I-COST PIC 9(8)V99. WORKING-STORAGE SECTION. 01 EOF-SW PIC X VALUE "N". 01 EOF-SW2 PIC X VALUE "N". 01 SUB1 PIC 99. 01 RECORDS-NOT-FOUND PIC 9(5) VALUE ZEROS. 01 TOTAL-COSTS PIC 9(10) VALUE ZEROS. 01 HOLD-INPUT-DATA. 03 INVENTORY-NUMBER PIC 9999. 03 PURCHASE-COST PIC 9(4)V99. 03 PURCHASE-DATE PIC 9(6). 03 FILLER PIC X(64). 01 PRINTER-SPECS. 03 PRINT-LINE. 05 OUTPUT-ITEM-NUMBER PIC ZZZ9. 05 FILLER PIC X(48) VALUE SPACES. 05 TOTAL-COSTS-0 PIC $(8).99. 01 PRODUCT-TABLE. 05 INVENTORY-NUMBERS OCCURS 50 TIMES ASCENDING KEY ITEM-NUMBER INDEXED BY INDEX-1. 07 ITEM-NUMBER PIC 9(4). 07 ITEM-DESCRIPTION PIC X(26). 07 ITEM-COST PIC 9(8)V99. .. 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ...7 PROCEDURE DIVISION. 100-START-IT. OPEN INPUT SALES-DATA INVENTORY-DATA OUTPUT PRINTED-REPORT. MOVE HIGH-VALUES TO PRODUCT-TABLE. PERFORM READ-INVENTORY-DATA. LOAD-TABLE-ROUTINE. PERFORM LOAD-IT VARYING SUB1 FROM 1 BY 1 UNTIL SUB1 > 50 OR EOF-SW2 = "Y". PERFORM 110-READ-IT. 200-MAIN-ROUTINE. PERFORM PROCESS-DATA UNTIL EOF-SW = "Y". MOVE TOTAL-COSTS TO TOTAL-COSTS-0. PERFORM WRITE-REPORT THRU WRITE-REPORT-EXIT. DISPLAY "RECORDS NOT FOUND - " RECORDS-NOT-FOUND UPON MYTUBE. STOP RUN. PROCESS-DATA. SEARCH ALL INVENTORY-NUMBERS AT END PERFORM KEY-NOT-FOUND THRU NOT-FOUND-EXIT WHEN ITEM-NUMBER (INDEX-1) = INVENTORY-NUMBER MOVE ITEM-NUMBER (INDEX-1) TO OUTPUT-ITEM-NUMBER MOVE ITEM-COST (INDEX-1) TO TOTAL-COSTS-0 ADD ITEM-COST (INDEX-1) TO TOTAL-COSTS PERFORM WRITE-REPORT THRU WRITE-REPORT-EXIT. PERFORM 110-READ-IT. KEY-NOT-FOUND. ADD 1 TO RECORDS-NOT-FOUND. NOT-FOUND-EXIT. EXIT. LOAD-IT. MOVE INVENTORY-RECORD TO INVENTORY-NUMBERS (SUB1). PERFORM READ-INVENTORY-DATA. WRITE-REPORT. WRITE PRINTER-OUTPUT FROM PRINTER-SPECS. WRITE-REPORT-EXIT. EXIT. READ-INVENTORY-DATA. READ INVENTORY-DATA AT END MOVE "Y" TO EOF-SW2. 110-READ-IT. READ SALES-DATA INTO HOLD-INPUT-DATA AT END MOVE "Y" TO EOF-SW. ═══ 12.43. SET Statement ═══ The SET statement can be used to:  Initialize the values of index-names or identifiers used to reference table elements  Increment or decrement an index-name  Set the status of an external switch to ON or OFF  Move data to make conditional variable conditions true -----IBM Extension-----  Set pointer and procedure-pointer data items and the ADDRESS OF special register ---End of IBM Extension--- When the sending and receiving fields in a SET statement share part of their storage (that is, the operands overlap), the result of the execution of such a SET statement is undefined. The SET statement has six formats:  Format 1 - TO Phrase  Format 2 - UP BY/DOWN BY Phrase  Format 3 - ON/OFF Phrase  Format 4 - TRUE Phrase -----IBM Extension-----  Format 5 - Pointer Data Item  Format 6 - Procedure-pointer Data Item ---End of IBM Extension--- ═══ 12.43.1. Format 1 - Initializing Index-names, Identifiers ═══ When Format 1 of the SET statement is executed, the current value of the receiving field is replaced by the value of the sending field (with conversion). ┌─── SET STATEMENT - FORMAT 1 ─────────────────────────────────────────────────┐ │ │ │ ┌──────────────────┐ │ │  │ │ │ >>──SET────┬─index-name-1─┬─┴──TO──┬─index-name-2─┬──>< │ │ └─identifier-1─┘ ├─identifier-2─┤ │ │ └─integer-1────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Execution of the Format 1 SET statement depends upon the type of receiving field, as follows:  Index-name receiving fields (index-name-1, and so on) are usually converted to a displacement value representing the occurrence number indicated by the sending field. To be valid, the resulting index-name value must correspond to an occurrence number in its associated table element. For the one exception, when the sending field is an index data item, the value in the index data item is placed in the index-name without change.  Index data item receiving fields (identifier-1, and so on) are set equal to the contents of the sending field (which must be either an index-name or an index data item); no conversion takes place. A numeric integer or literal sending field must not be specified.  Integer data item receiving fields (identifier-1, and so on) are are set to the occurrence number associated with the sending field, which must be an index-name. An integer data item, an index data item, or a literal sending field must not be specified. Sending and Receiving Fields for Format 1 SET Statement shows valid combinations of sending and receiving fields in a Format 1 SET statement. ┌──────────────────────────────────────────────────────────────────────────────┐ │ Sending and Receiving Fields for Format 1 SET Statement │ ├───────────────────────────────┬──────────────────────────────────────────────┤ │ │ RECEIVING FIELD │ │ SENDING FIELD ├───────────────┬───────────────┬──────────────┤ │ │ INDEX-NAME │ INDEX DATA │ INTEGER DATA │ │ │ │ ITEM │ ITEM │ ├───────────────────────────────┼───────────────┼───────────────┼──────────────┤ │ Index-name │ Valid │ Valid(*) │ Valid │ ├───────────────────────────────┼───────────────┼───────────────┼──────────────┤ │ Index Data Item │ Valid(*) │ Valid(*) │ - │ ├───────────────────────────────┼───────────────┼───────────────┼──────────────┤ │ Integer Data Item │ Valid │ - │ - │ ├───────────────────────────────┼───────────────┼───────────────┼──────────────┤ │ Integer Literal │ Valid │ - │ - │ ├───────────────────────────────┴───────────────┴───────────────┴──────────────┤ │ (*)No conversion takes place │ └──────────────────────────────────────────────────────────────────────────────┘ Receiving fields are acted upon in the left-to-right order in which they are specified. Any subscripting or indexing associated with an identifier's receiving field is evaluated immediately before the field is acted upon. The value used for the sending field is the value at the beginning of SET statement execution. The value for an index-name after execution of a SEARCH or PERFORM statement may be undefined; therefore, a Format 1 SET statement should reinitialize such index-names before other table-handling operations are attempted. ═══ 12.43.2. Format 2 - Adjusting Index Values ═══ When Format 2 of the SET statement is executed, the value of the receiving field is increased (UP BY) or decreased (DOWN BY) by a value that corresponds to the value in the sending field. ┌─── SET STATEMENT - FORMAT 2 ─────────────────────────────────────────────────┐ │ │ │ ┌──────────────┐ │ │  │ │ │ >>──SET────index-name-3─┴──┬─UP BY───┬──┬─identifier-3─┬──>< │ │ └─DOWN BY─┘ └─integer-2────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ When Format 2 of the SET statement is executed, the contents of the receiving field are increased (UP BY) or decreased (DOWN BY) by a value that corresponds to the number of occurrences represented by the value of identifier-3 or integer-2. Receiving fields are acted upon in the left-to-right order in which they are specified. The value of the incrementing or decrementing field at the beginning of SET statement execution is used for all receiving fields. ═══ 12.43.3. Format 3 - Setting External Switches ═══ When Format 3 of the SET statement is executed, the status of each external switch associated with the specified mnemonic-name is turned ON or OFF. ┌─── SET STATEMENT - FORMAT 3 ─────────────────────────────────────────────────┐ │ │ │ ┌──────────────────────────────────┐ │ │ │ ┌─────────────────┐ │ │ │   │ │ │ │ >>──SET──────mnemonic-name-1─┴──TO──┬─ON──┬─┴──>< │ │ └─OFF─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.43.4. Format 4 - Condition-names ═══ When Format 4 of the SET statement is executed, the value associated with a condition-name is placed in its conditional variable. ┌─── SET STATEMENT - FORMAT 4 ─────────────────────────────────────────────────┐ │ │ │ ┌──────────────────┐ │ │  │ │ │ >>──SET────condition-name-1─┴──TO TRUE──>< │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ If more than one literal is specified in the VALUE clause of condition-name-1, its associated conditional variable is set to the first literal. If multiple condition-names are specified, the results are the same as if a separate SET statement had been written for each condition-name in the same order in which the condition-names are specified. ═══ 12.43.5. Format 5 - Pointer Data Item ═══ -----IBM Extension----- When Format 5 of the SET statement is executed, the current value of the receiving field is replaced by the address value contained in the sending field. ┌─── SET STATEMENT - FORMAT 5 ─────────────────────────────────────────────────┐ │ │ │ ┌────────────────────────────────┐ │ │  │ │ │ >>──SET────┬─identifier-4───────────────┬─┴────────────────────────────────> │ │ └─ADDRESS OF────identifier-5─┘ │ │ │ │ >──TO──┬─identifier-6───────────────┬──>< │ │ ├─ADDRESS OF────identifier-7─┤ │ │ ├─NULL───────────────────────┤ │ │ └─NULLS──────────────────────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ---End of IBM Extension--- ═══ 12.43.6. Format 6 - Procedure-Pointer Data Item ═══ -----IBM Extension----- When Format 6 of the SET statement is executed, the current value of the receiving field is replaced by the address value contained in the sending field. ┌─── SET STATEMENT - FORMAT 6 ─────────────────────────────────────────────────┐ │ │ │ ┌───────────────────────────────┐ │ │  │ │ │ >>──SET────procedure-pointer-data-item-1─┴─────────────────────────────────> │ │ │ │ >──TO──┬─procedure-pointer-data-item-2────────────────┬──>< │ │ ├─ENTRY──┬─identifier-1──────────────────────┬─┤ │ │ │ └─┬────────────────────┬──literal-1─┘ │ │ │ │ └─┤ Linkage Phrase ├─┘ │ │ │ ├─NULL───────┴────────────────┴────────────────┤ │ │ └─NULLS────────────────────────────────────────┘ │ │ │ │ LINKAGE PHRASE: │ │ ├──┬─────────────────────────────────────────────────────┬──┤ │ │ ├─LINKAGE──┬──────┬──┬──────┬──┬─environment-name-1─┬─┤ │ │ │ └─TYPE─┘ └─IS───┘ ├─PROGRAM────────────┤ │ │ │ │ └─PROCEDURE──────────┘ │ │ │ ├─PROGRAM─────────────────────────────────────────────┤ │ │ └─PROCEDURE───────────────────────────────────────────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ---End of IBM Extension--- ═══ 12.44. SORT Statement ═══ The SORT statement accepts records from one or more files, sorts them according to the specified key(s), and makes the sorted records available either through an OUTPUT PROCEDURE or in an output file. A SORT statement may appear anywhere in the Procedure Division except in a Declarative Section. The maximum number of USING or GIVING files is 32. ┌─── SORT STATEMENT - FORMAT ──────────────────────────────────────────────────┐ │ │ │ >>──SORT──file-name-1──────────────────────────────────────────────────────> │ │ │ │ ┌─────────────────────────────────────────────────────┐ │ │ │ ┌─────────────┐ │ │ │   │ │ │ │ >────┬──────┬──┬─ASCENDING──┬──┬──────┬────data-name-1─┴─┴─────────────────> │ │ └─ON───┘ └─DESCENDING─┘ └─KEY──┘ │ │ │ │ >──┬────────────────────────────────────┬──────────────────────────────────> │ │ └─┬──────┬──DUPLICATES──┬──────────┬─┘ │ │ └─WITH─┘ └─IN ORDER─┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──────────────────────> │ │ └─┬───────────┬──SEQUENCE──┬────┬──alphabet-name─┘ │ │ └─COLLATING─┘ └─IS─┘ │ │ │ │ ┌─────────────┐ ┌─────────────┐ │ │  │  │ │ │ >──┬─USING────file-name-2─┴─────┬──┬─GIVING────file-name-3─┴─────┬──>< │ │ └─┤ input procedure phrase ├─┘ └─┤ output procedure phrase ├─┘ │ │ │ │ INPUT PROCEDURE PHRASE: │ │ ├──INPUT PROCEDURE──┬────┬──procedure-name-1───────────────────────────────> │ │ └─IS─┘ │ │ │ │ >──┬───────────────────────────────┬──┤ │ │ └─┬─THROUGH─┬──procedure-name-2─┘ │ │ └─THRU────┘ │ │ │ │ OUTPUT PROCEDURE PHRASE: │ │ ├──OUTPUT PROCEDURE──┬────┬──procedure-name-3──────────────────────────────> │ │ └─IS─┘ │ │ │ │ >──┬───────────────────────────────┬──┤ │ │ └─┬─THROUGH─┬──procedure-name-4─┘ │ │ └─THRU────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Null-capable fields are supported, but null values are not. Null values result in a file status of 90. ═══ 12.44.1. ASCENDING/DESCENDING KEY Phrase ═══ This phrase specifies that records are to be processed in ascending or descending sequence (depending on the phrase specified), based on the specified sort keys. The direction of the sorting operation depends on the specification of the ASCENDING or DESCENDING keywords as follows:  When ASCENDING is specified, the sequence is from the lowest key value to the highest key value.  When DESCENDING is specified, the sequence is from the highest key value to the lowest.  If the KEY data item is alphabetic, alphanumeric, alphanumeric-edited, or numeric-edited, the sequence of key values depends on the collating sequence used (see COLLATING SEQUENCE Phrase).  The key comparisons are performed according to the rules for comparison of operands in a relation condition (see "Relation Condition" under Conditional Expressions). ═══ 12.44.2. DUPLICATES Phrase ═══ If the DUPLICATES phrase is specified, and the contents of all the key elements associated with one record are equal to the corresponding key elements in one or more other records, the order of these records is as follows:  The order of the associated input files as specified in the SORT statement. Within a given file the order is that in which the records are accessed from that file.  The order in which these records are released by an input procedure, when an input procedure is specified. If the DUPLICATES phrase is not specified, the order of these records is undefined. ═══ 12.44.3. COLLATING SEQUENCE Phrase ═══ This phrase specifies the collating sequence to be used in nonnumeric comparisons for the KEY data items in this sorting operation. When the COLLATING SEQUENCE phrase is omitted, the PROGRAM COLLATING SEQUENCE clause (if specified) in the OBJECT-COMPUTER paragraph specifies the collating sequence to be used. When both the COLLATING SEQUENCE phrase and the PROGRAM COLLATING SEQUENCE clause are omitted, the EBCDIC collating sequence is used. ═══ 12.44.4. USING Phrase ═══ When the USING phrase is specified, all the records in file-name-2, . . . (that is, the input files) are transferred automatically to file-name-1. At the time the SORT statement is executed, these files must not be open; the compiler opens, reads, makes records available, and closes these files automatically. If EXCEPTION/ERROR procedures are specified for these files, the compiler makes the necessary linkage to these procedures. The input files must be sequential, relative or indexed files. All input files must specify sequential or dynamic access mode, and must be described in FD entries in the Data Division. ═══ 12.44.5. INPUT PROCEDURE Phrase ═══ This phrase specifies the name of a procedure that is to select or modify input records before the sorting operation begins. The input procedure may consist of any procedure needed to select, modify, or copy the records that are made available one at a time by the RELEASE statement to the file referenced by file-name-1. The range includes all statements that are executed as the result of a transfer of control by CALL, EXIT, GO TO, and PERFORM statements in the range of the input procedure, as well as all statements in declarative procedures that are executed as a result of the execution of statements in the range of the input procedure. The range of the input procedure must not cause the execution of any MERGE, RETURN, or SORT statement. If an input procedure is specified, control is passed to the input procedure before file-name-1 is sequenced by the SORT statement. The compiler inserts a return mechanism at the end of the last statement in the input procedure. When control passes the last statement in the input procedure, the records that have been released to file-name-1 are sorted. ═══ 12.44.6. GIVING Phrase ═══ When the GIVING phrase is specified, all the sorted records in file-name-1 are automatically transferred to the output files (file-name-3, . . . ). At the time the SORT statement is executed, this file must not be open. If the output files contain variable length records, the size of the records contained in file-name-1 must not be less than the smallest record nor greater than the largest described for the output files. If the output files contain fixed length records, the size of the records contained in file-name-1 must not be greater than the largest record described for the output files. For each of the files referenced by file-name-3, the execution of the SORT statement causes the following actions to be taken:  The processing of the file is initiated. The initiation is performed as if an OPEN statement with the OUTPUT phrase has been executed.  The sorted logical records are returned and written onto the file. Each record is written as if a WRITE statement without any optional phrases had been executed. The records overwrite the previous contents, if any, of the file. -----IBM Extension----- If file-name-3 is a logical database file, the records are added to the end of the file. ---End of IBM Extension--- If the file referenced by file-name-3 is an INDEXED file then the associated key data-name for that file must have an ASCENDING KEY phrase in the SORT statement. This same data-name must occupy the identical character positions in its record as the data item associated with the prime record key for the file. For a relative file, the relative key data item for the first record returned contains the value '1'; for the second record returned, the value '2', and so on. After execution of the SORT statement, the content of the relative key data item indicates the last record returned to the file.  The processing of the file is terminated. The termination is performed as if a CLOSE statement without optional phrases had been executed. Note: When duplicate keys are found when writing to an indexed file, the SORT will terminate and the sorted data in all GIVING files will be incomplete. These implicit functions are performed such that any associated USE AFTER EXCEPTION/ERROR procedures are executed; however, the execution of such a USE procedure must not cause the execution of any statement manipulating the file referenced by, or accessing the record area associated with, file-name-3. On the first attempt to write beyond the externally defined boundaries of the file, any USE AFTER STANDARD EXCEPTION/ERROR procedure specified for the file is executed. If control is returned from that USE procedure or if no such USE procedure is specified, the processing of the file is terminated. All output files must specify sequential or dynamic access mode, and must be described in FD entries in the Data Division. The output file must be an indexed, relative or sequential file. The output file should also be created without a keyed sequence access path. When the output file has such a path, the SORT statement cannot override the collating sequence defined in the data description specifications (DDS). ═══ 12.44.7. OUTPUT PROCEDURE Phrase ═══ This phrase specifies the name of a procedure that is to select or modify output records from the sorting operation. The output procedure may consist of any procedure needed to select, modify, or copy the records that are made available one at a time by the RETURN statement in sorted order from file-name-1. The range of the output procedure includes all statements that are executed as the result of a transfer of control by CALL, EXIT, GO TO, and PERFORM statements within the output procedure. The range also includes all statements in declarative procedures that are executed as a result of the execution of statements in the range of the output procedure. The range of the output procedure must not include any MERGE, RELEASE, or SORT statement. If an output procedure is specified, control passes to it after file-name-1 has been sequenced by the SORT statement. The compiler inserts a return mechanism after the last statement in the output procedure, and when control passes that statement, the return mechanism terminates the sort and passes control to the next executable statement after the SORT statement. Before entering the output procedure, the sort procedure reaches a point at which it can select the next record in sorted order when requested. The RETURN statements in the output procedure are the requests for the next record. Note: The INPUT and OUTPUT PROCEDURE phrases are similar to those for a basic PERFORM statement. For example, if you name a procedure in an OUTPUT PROCEDURE phrase, that procedure is executed during the sorting operation just as if it were named in a PERFORM statement. As with the PERFORM statement, execution of the procedure ends after the last statement executes. The last statement in an input or output procedure can be the EXIT statement (see EXIT Statement). -----IBM Extension----- The SORT-RETURN special register contains a return code indicating the success (or lack of) of a SORT operation. See SORT-RETURN Special Register for more information. ---End of IBM Extension--- ═══ 12.45. START Statement ═══ The START statement provides a means of positioning within an indexed or relative file for subsequent sequential record retrieval. This positioning is achieved by comparing the key values of records in the file with the value you place in the RECORD KEY portion of a file's record area (for an indexed file), or in the RELATIVE KEY data item (for a relative file) prior to execution of the START statement. Note: When the START statement is executed, the associated indexed or relative file must be open in INPUT or I-O mode. ┌─── START STATEMENT - FORMAT ─────────────────────────────────────────────────┐ │ │ │ >>──START──file-name-1──┬───────────────────┬──────────────────────────────> │ │ └─┬──────┬──NO LOCK─┘ │ │ └─WITH─┘ │ │ │ │ >──┬─────────────────────────────────────────────────────────────────┬─────> │ │ └─KEY───┬────┬──┬─EQUAL──┬────┬───────────────────────┬──┤ data ├─┘ │ │ └─IS─┘ │ └─TO─┘ │ │ │ ├─=───────────────────────────────────┤ │ │ ├─GREATER──┬──────┬───────────────────┤ │ │ │ └─THAN─┘ │ │ │ ├─>───────────────────────────────────┤ │ │ ├─NOT LESS──┬──────┬──────────────────┤ │ │ │ └─THAN─┘ │ │ │ ├─NOT ┌───────────────────────────────┤ │ │ │  │ │ │ ├─GREATER──┬──────┬──OR EQUAL──┬────┬─┤ │ │ │ └─THAN─┘ └─TO─┘ │ │ │ └─>=──────────────────────────────────┘ │ │ │ │ >──┬───────────────────────────────────────┬───────────────────────────────> │ │ │ (1,2) │ │ │ └─FORMAT───────┬────┬──┬─identifier-1─┬─┘ │ │ └─IS─┘ └─literal-1────┘ │ │ │ │ >──┬───────────────────────────────────────────┬───────────────────────────> │ │ └─INVALID──┬──────┬──imperative-statement-1─┘ │ │ └─KEY──┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──┬───────────┬──>< │ │ └─NOT INVALID──┬──────┬──imperative-statement-2─┘ └─END-START─┘ │ │ └─KEY──┘ │ │ │ │ DATA: │ │ (1) │ │ ├──┬─EXTERNALLY-DESCRIBED-KEY────┬──┤ │ │ │ ┌─────────────┐ │ │ │ │  │ │ │ │ └───data-name-1─┴─────────────┘ │ │ │ │ NOTES: │ │ (1) IBM Extension │ │ │ │ (2) Applies only to indexed files on DATABASE devices │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ═══ 12.45.1. NO LOCK Phrase ═══ -----IBM Extension----- The NO LOCK phrase prevents the START operation from obtaining record locks on files that are opened in I-O (update) mode. A START statement bearing this phrase also releases records that have been locked by a previous START operation. If this phrase is used for a file that is not open in I-O mode, an error message is issued. ---End of IBM Extension--- Related Information:  Indexed Files  Relative Files ═══ 12.45.2. KEY Phrase ═══ When the KEY phrase is specified, the file position indicator is positioned at the logical record in the file whose key field satisfies the comparison. When the KEY phrase is not specified, KEY IS EQUAL (to the prime record key) is implied. When the START statement is executed, a comparison is made between the current value in the key data-name and the corresponding key field in the file's index. If the FILE STATUS clause is specified in the FILE-CONTROL entry, the associated status key is updated when the START statement is executed. (See Status Key.) ═══ 12.45.3. INVALID KEY Phrase ═══ If the comparison is not satisfied by any record in the file, an invalid key condition exists; the value of the file position indicator is undefined, and (if specified) the INVALID KEY imperative statement runs. (See INVALID KEY Condition.) The INVALID KEY phrase must be specified if no EXCEPTION/ERROR procedure is explicitly or implicitly specified for this file. ═══ 12.45.4. NOT INVALID KEY Phrase ═══ After successful completion of a START statement with the NOT INVALID KEY phrase, control transfers to the imperative statement associated with the phrase. ═══ 12.45.5. END-START Phrase ═══ This explicit scope terminator serves to delimit the scope of the START statement. END-START permits a conditional START statement to be nested in another conditional statement. END-START may also be used with an imperative START statement. For more information, see Delimited Scope Statements. ═══ 12.45.6. FORMAT Phrase ═══ -----IBM Extension----- The value specified in the FORMAT phrase contains the name of the record format to use for this I-O operation. The system uses this to specify or select which record format to operate on. Identifier-1, if specified, must be an alphanumeric data item of 10 characters or less. Literal-1, if specified, must be an uppercase character-string of 10 characters or less. A value of all blanks is treated as though the FORMAT phrase were not specified. If the value is not valid for the file, a FILE STATUS of 9K is returned and a USE procedure is invoked, if applicable for the file. ---End of IBM Extension--- If specified, the file position indicator is set to the first record of the specified record format that satisfies the comparison. If omitted, the current record pointer is set to the first record of any format that satisfies the comparison. See Relationship between KEY IS and FORMAT Phrases for a description of how the FORMAT phrase interacts with the EXTERNALLY-DESCRIBED-KEY and KEY IS phrases. ═══ 12.45.7. Indexed Files ═══ When the KEY phrase is specified, the key data item used for the comparison is data-name. When the KEY phrase is not specified, the file position indicator is set to the record with a key equal to the value contained in the RECORD KEY data item. When the KEY phrase is specified, the search argument used for the comparison is data-name-1, which can be:  The RECORD KEY itself.  An alphanumeric data item within a record description for the file with a leftmost character position that corresponds to the leftmost character position of the key field in the record area. This data item must be less than or equal to the length of the record key for the file. This data item can be qualified or reference modified. If the key itself is not used, the leftmost character position plus the reference modification starting position must correspond to the leftmost character position of the key field. Note: If the RECORD KEY is defined as COMP, COMP-3, or COMP-4, the key data item must be the RECORD KEY itself. A partial key field in the record area cannot be used. The file position indicator is positioned to the first record in the file with a record key for a format that satisfies the comparison. If the operands in the comparison are of unequal length, the comparison proceeds as if the longer field were truncated on the right to the length of the shorter field. All other numeric and nonnumeric comparison rules apply, except that the PROGRAM COLLATING SEQUENCE, if specified, has no effect. -----IBM Extension----- For a file that specified RECORD KEY IS EXTERNALLY-DESCRIBED-KEY, the following additional considerations apply:  The reserved word EXTERNALLY-DESCRIBED-KEY can be specified. This indicates that the complete key in the record area should be used in the comparison.  A series of data names can be specified. This allows a partial key field in the record area to be used (generic START). These data names must follow the following rules: - All except the last of the data names specified must be a record key for a single format that was copied in for the file. The record format in which they are contained does not have to be the one that can be specified by the FORMAT phrase. - The order of these data names (key fields) must match the order of the keys as defined in DDS; that is, they must be specified from most significant field to least significant. - The total number of data names cannot exceed the number of key fields defined for that record format. - If the last data name specified in the series is not a key field in the record area, it must have its left byte occupy the same space as the key field that is defined at that relative position. If the key field in the record area at this position is a COMP, COMP-3, or COMP-4 field, only the key field itself can be used as the data name. - Only the last key can be reference modified, and the reference modification starting position must equal 1.  Relationship between KEY IS and FORMAT Phrases shows the action between the KEY IS phrase and the FORMAT phrase: ┌──────────────────────────────────────────────────────────────────────────────┐ │ Relationship between KEY IS and FORMAT Phrases │ ├─────────────┬────────────────────────────────────────────────────────────────┤ │ FORMAT │ KEY Phrase │ │ Phrase ├────────────┬──────────┬────────────────────────────────────────┤ │ specified │ Data-Name │ Omitted │ EXTERNALLY-DESCRIBED-KEY │ │ │ Series │ │ │ ├─────────────┼────────────┼──────────┼────────────────────────────────────────┤ │ Yes │ A, B │ C, D │ C, B │ ├─────────────┼────────────┼──────────┼────────────────────────────────────────┤ │ No │ A, E │ F, G │ F, E │ └─────────────┴────────────┴──────────┴────────────────────────────────────────┘ A The search argument is built using the specified data items. B The file position indicator is set to the first record in the file of the format specified with a record key that satisfies the comparison specified in the key phrase. C The search argument is built using the key fields in the record area for the format specified in the FORMAT phrase. D The file position indicator is set to the first record in the file of the specified format with a record key equal to the search argument. E The file position indicator is set to the first record in the file with a common key for the file that satisfies the comparison specified in the KEY phrase. If there is no common key, the file position indicator is set to the first record in the file. F The search argument is built using the key fields in the record area for the first record format for the file as defined in the program. G The file position indicator is set to the first record in the file with a common key for the file that is equal to the search argument. If there is no common key, the file position indicator is set to the first record in the file. ---End of IBM Extension--- When the KEY phrase is not specified, the key data item used for the EQUAL TO comparison is the prime RECORD KEY. data-name-1 Can be any of the following:  The prime RECORD KEY.  An alphanumeric data item within a record description for a file whose leftmost character position corresponds to the leftmost character position of that record key; it may be qualified. The data item must be less than or equal to the length of the record key for the file. The file position indicator points to the first record in the file whose key field satisfies the comparison. If the operands in the comparison are of unequal lengths, the comparison proceeds as if the longer field were truncated on the right to the length of the shorter field. All other numeric and nonnumeric comparison rules apply, except that the PROGRAM COLLATING SEQUENCE clause, if specified, has no effect. When START statement execution is successful, the RECORD KEY with which data-name-1 is associated becomes the key of reference for subsequent READ statements. When START statement execution is unsuccessful, the key of reference is undefined. -----IBM Extension----- For indexed files of device type DATABASE, the meaning of the comparison can be affected by the type of key fields in the record area defined for the file. Key fields on this system can be defined as multiple fields, each of which can be in ascending or descending sequence. The system establishes a sequence (keyed sequence access path) for the records based on the values contained in the record key for the format and the sequencing specified in DDS. When a START statement is processed, the request is interpreted as follows: ┌───────────────────────────────────────┬──────────────────────────────────────┐ │ COBOL COMPARISON │ SYSTEM RESULT │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ GREATER THAN │ AFTER │ ├───────────────────────────────────────┼──────────────────────────────────────┤ │ NOT LESS THAN │ EQUAL TO or AFTER │ └───────────────────────────────────────┴──────────────────────────────────────┘ For example, when a statement is processed using the comparison of GREATER THAN, a search is made of these sequenced records for the first record after the search argument specified by the START statement. If the file was sequenced using descending keys, the file position indicator would point to a record with a key less than the one specified and not greater than that specified in the START statement. ---End of IBM Extension--- ═══ 12.45.8. Relative Files ═══ When the KEY phrase is not specified, the file position indicator is set to the record in the file with a key (relative record number) equal to the RELATIVE KEY data item. When the KEY phrase is specified, data-name-1 must specify the RELATIVE KEY. The file position indicator is positioned to the first logical record currently existing in the file with a key (relative record number) that satisfies the comparison with the RELATIVE KEY data item. When the KEY phrase is not specified, KEY IS EQUAL (to the prime record key) is implied. Data-name-1 may be qualified; it may not be subscripted. When the START statement is executed, a comparison is made between the current value in the relative key and the relative record numbers of existing records in the file. If the FILE STATUS clause is specified in the FILE-CONTROL entry, the associated status key is updated when the START statement is executed. (See "Status Key" under Common Processing Facilities.) Whether or not the KEY phrase is specified, the key data item used in the comparison is the RELATIVE KEY data item. When START statement execution is successful, the file position indicator points to the logical record in the file whose key satisfies the comparison, and this key becomes the reference for subsequent READ statements. When START statement execution is unsuccessful, the key of reference and the file position indicator are undefined. ═══ 12.46. STOP Statement ═══ The STOP statement halts execution of the object program either permanently or temporarily. ┌─── STOP STATEMENT - FORMAT ──────────────────────────────────────────────────┐ │ │ │ >>──STOP──┬─RUN─────┬──>< │ │ └─literal─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ When STOP literal is specified, the literal is communicated to the system operator for batch jobs and to the work station for interactive jobs. Program execution is suspended. Execution is resumed only after operator intervention. The operator response determines determines the action to be taken. Operator Response Action G (default) Continue at next instruction. C Terminate the execution of all programs up to and including the program at the nearest control boundary. If the nearest control boundary is a hard control boundary then escape message CEE9901 is issued to the caller of the COBOL run unit. For batch jobs, the job is canceled if the ENDSEV parameter (see CRTJOBD CL command) for the job contains a value that is less than or equal to the severity of the message. D Dump COBOL identifiers and then perform the same action as C. F Dump COBOL identifiers and file information and then perform the same action as C. The output of the STOP literal contains the program-name. The literal is contained in the second level text, and is displayed when the Help key is used. The STOP literal statement is useful for special situations (a special tape or disk must be mounted, a specific daily code must be entered, and so forth) when operator intervention is needed during program execution. However, the ACCEPT and DISPLAY statements are preferred when operator intervention is needed. When STOP RUN is specified, execution of all programs up to and including the program at the nearest control boundary is ended, and control is returned to the program prior to the control boundary. If the nearest control boundary is a hard control boundary, then STOP RUN causes the activation group (run unit) to end, which in turn causes all files scoped to the activation group to be closed. If a STOP RUN statement appears in a sequence of imperative statements, it must be the last or only statement in the sequence. In each case above, the calling program could be the system. If it is, execution of the run unit ceases, and control transfers to the operating system. Also, if the main program is called by a program written in a language that does not follow COBOL linkage conventions, return will be to this calling program. For details on the behavior of the STOP RUN statement under various conditions, see "Returning from an ILE COBOL/400 Program" in ILE COBOL/400 PROGRAM-ID. Related Information:  RETURN-CODE Special Register ═══ 12.46.1. RETURN-CODE Special Register ═══ -----IBM Extension----- The RETURN-CODE special register can be used to pass return code information (that is, a numeric value) from a program to its caller (either a calling program or the system). You can set the RETURN-CODE special register before executing an EXIT PROGRAM, GOBACK, or STOP RUN statement. RETURN-CODE has the implicit definition: 01 RETURN-CODE GLOBAL PICTURE S9999 USAGE BINARY VALUE 0 This special register may be used anywhere in a program where a data-item with a data definition of PICTURE S9999 USAGE BINARY is allowed. When used in nested programs, the RETURN-CODE special register is implicitly defined as GLOBAL in the outermost program. When a COBOL subprogram terminates, the contents of the RETURN-CODE special register of the subprogram are transferred into the RETURN-CODE special register of the calling program. When the main COBOL program terminates, and control returns to the operating system, the special register content is returned to the operating system as a user return code. For the first call to a program, the RETURN-CODE special register is initialized to zero, which is the normal return code for successful completion. The field will be re-set to zero on subsequent calls to a program that has been cancelled or which possesses the INITIAL attribute. Otherwise, the RETURN-CODE special register will not be re-set, it will be unchanged from the value it contained after the previous call. ---End of IBM Extension--- ═══ 12.47. STRING Statement ═══ The STRING statement strings together the partial or complete contents of two or more data items or literals into one single data item. One STRING statement can be written instead of a series of MOVE statements. ┌─── STRING STATEMENT - FORMAT ────────────────────────────────────────────────┐ │ │ │ >>──STRING─────────────────────────────────────────────────────────────────> │ │ │ │ ┌─────────────────────────────────────────────────────────────┐ │ │ │ ┌──────────────────┐ │ │ │   │ │ │ │ >──────┬─identifier-1─┬─┴──DELIMITED──┬──────┬──┬─identifier-2─┬─┴─────────> │ │ └─literal-1────┘ └─BY───┘ ├─literal-2────┤ │ │ └─SIZE─────────┘ │ │ │ │ >──INTO──identifier-3──┬─────────────────────────────────┬─────────────────> │ │ └─┬──────┬──POINTER──identifier-4─┘ │ │ └─WITH─┘ │ │ │ │ >──┬────────────────────────────────────────────┬──────────────────────────> │ │ └─┬──────┬──OVERFLOW──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬──────────────────────────────────────────────────┬──┬────────────┬──>< │ │ └─NOT───┬──────┬──OVERFLOW──imperative-statement-2─┘ └─END-STRING─┘ │ │ └─ON───┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Note: All identifiers (except identifier-4, the POINTER item) must have USAGE DISPLAY, explicitly or implicitly. Related Information:  Data Flow  Coding Example ═══ 12.47.1. ON OVERFLOW Phrases ═══ Control is transferred to imperative-statement-1 when the pointer value (explicit or implicit):  Is zero or less than 1  Exceeds a value equal to the length of the receiving field When any of the above conditions occur, an overflow condition exists, and no more data is transferred. The STRING operation is terminated and, if the ON OVERFLOW phrase is specified, control is transferred to imperative-statement-1. Otherwise, control is transferred to the end of the STRING statement. The NOT ON OVERFLOW statement, if specified, is ignored. If control is transferred to imperative-statement-1, execution continues according to the rules for each statement specified in imperative-statement-1. If a procedure branching or conditional statement that causes explicit transfer of control is executed, control is transferred according to the rules for that statement; otherwise, upon completion of the execution of imperative-statement-1, control is transferred to the end of the STRING statement. If an overflow condition does not occur during the execution of a STRING statement, then control is transferred to the end of the STRING statement. If an overflow condition does not occur and the NOT ON OVERFLOW phrase is specified, control is transferred to imperative-statement-2. The ON OVERFLOW phrase, if specified, is ignored. If control is transferred to imperative-statement-2, execution continues according to the rules for each statement specified in imperative statement-2. If a procedure branching or conditional statement that causes explicit transfer of control is executed, control is transferred according to the rules for that statement. Otherwise, upon completion of the execution of imperative-statement-2, control is transferred to the end of the STRING statement. The ON OVERFLOW statement is not executed unless there was an attempt to move in one or more characters beyond the end of identifier-3, or the initial value of POINTER is less than 1. ═══ 12.47.2. END-STRING Phrase ═══ This explicit scope terminator serves to delimit the scope of the STRING statement. END-STRING permits a conditional STRING statement to be nested in another conditional statement. END-STRING may also be used with an imperative STRING statement. For more information, see Delimited Scope Statements. ═══ 12.47.3. Data Flow ═══ When the STRING statement is executed, data is transferred from the sending fields to the receiving field. The order in which sending fields are processed is the order in which they are specified. The following rules apply:  Characters from the sending fields are transferred to the receiving field, according to the rules for alphanumeric to alphanumeric elementary moves, except that no space filling is provided (see MOVE Statement).  When DELIMITED BY identifier/literal is specified, the contents of each sending item are transferred, character-by-character, beginning with the leftmost character and continuing until either: - A delimiter for this sending field is reached (the delimiter itself is not transferred), or - The rightmost character of this sending field has been transferred.  When DELIMITED BY SIZE identifier is specified, each entire sending field is transferred to the receiving field.  When the receiving field is filled, or when all the sending fields have been processed, the operation is ended.  When the POINTER phrase is specified, an explicit pointer field is available to the COBOL user to control placement of data in the receiving field. The user must set the explicit pointer's initial value, which must not be less than 1 and not more than the character count of the receiving field. (Note that the pointer field must be defined as a field large enough to contain a value equal to the length of the receiving field plus 1; this precludes arithmetic overflow when the system updates the pointer at the end of the transfer.)  When the POINTER phrase is not specified, no pointer is available to the user. However, a conceptual implicit pointer with an initial value of 1 is used by the system.  Conceptually, when the STRING statement is executed, the initial pointer value (explicit or implicit) is the first character position within the receiving field into which data is to be transferred. Beginning at that position, data is then positioned, character-by-character, from left to right. After each character is positioned, the explicit or implicit pointer is increased by 1. The value in the pointer field is changed only in this manner. At the end of processing, the pointer value always indicates a value equal to one character beyond the last character transferred into the receiving field. Subscripting, reference modification, or variable-length calculations are performed only once, at the beginning of the processing of the STRING statement. So if identifier-3 or identifier-4 is used as a subscript or reference modifier in the STRING statement, or affects the length of any identifiers of the STRING statement, these values are determined at the beginning of the STRING statement, and are not affected by any results of the STRING statement. If identifier-1 or identifier-2 occupy the same storage area as identifier-3 or identifier-4, or if identifier-3 and identifier-4 occupy the same storage area, the result of the execution of the STRING statement is undefined. After STRING statement execution is completed, only that part of the receiving field into which data was transferred is changed. The rest of the receiving field contains the data that was present before this execution of the STRING statement. When the following STRING statement is executed, the results obtained will be like those illustrated in Results of STRING Statement Execution. STRING ID-1 ID-2 DELIMITED BY ID-3 ID-4 ID-5 DELIMITED BY SIZE INTO ID-7 WITH POINTER ID-8 END-STRING Results of STRING Statement Execution ID─1 at execution ID─2 at execution ID─4 at execution ID─5 at execution ┌──┬──┬──┬──┬──┬──┐ ┌──┬──┬──┬──┐ ┌──┬──┬──┬──┬──┬──┐ ┌──┬──┬──┬──┬──┐ │ 1│ 2│ 3│ *│ 4│ 5│ │ A│ *│ B│ C│ │ 6│ 7│ 8│ 9│ *│ 0│ │ D│ E│ *│ F│ G│ └──┴──┴──┴──┴──┴──┘ └──┴──┴──┴──┘ └──┴──┴──┴──┴──┴──┘ └──┴──┴──┴──┴──┘ └───┬────┘ └─┬┘ └────────┬────────┘ └───────┬──────┘ First group of Second group of Third group of Fourth group of characters moved characters moved characters moved characters moved │ │ │ │ └─────────────┐ └┐ ┌────────────────┘ │ │ │ │ ┌──────────────────┘ ID─3 │ │ │ │ (delimiter)     at execution ┌────────┬──┬─────────────────┬──────────────┐ ┌──┐ ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐ │ *│ │ 1│ 2│ 3│ A│ 6│ 7│ 8│ 9│ *│ 0│ D│ E│ *│ F│ G│ Z│ Z│ Z│ Z│ Z│ Z│ └──┘ └──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘ ID─7 after execution (initialized to ALL Z before execution) ID─8 (pointer) after execution ┌──┬──┐ │ 1│ 6│ └──┴──┘ (initialized to 01 before execution) ═══ 12.47.4. STRING Statement Example ═══ The following example illustrates some of the considerations that apply to the STRING statement. In the Data Division, the programmer has defined the following fields: 01 RPT-LINE PICTURE X(120). 01 LINE-POS PICTURE 99. 01 LINE-NO PICTURE 9(5) VALUE 1. 01 DEC-POINT PICTURE X VALUE ".". In the File Section, he or she has defined the following input record: 01 RCD-01. 05 CUST-INFO. 10 CUST-NAME PICTURE X(15). 10 CUST-ADDR PICTURE X(34). 05 BILL-INFO. 10 INV-NO PICTURE X(6). 10 INV-AMT PICTURE $$,$$$.99. 10 AMT-PAID PICTURE $$,$$$.99. 10 DATE-PAID PICTURE X(8). 10 BAL-DUE PICTURE $$,$$$.99. 10 DATE-DUE PICTURE X(8). The programmer wants to construct an output line consisting of portions of the information from RCD-01. The line is to consist of a line number, customer name and address, invoice number, date due, and balance due, truncated to the dollar figure shown. The record as read in contains the following information: J.B.bSMITHbbbbb 444bSPRINGbST.,bCHICAGO,bILL.bbbbb (where b is a blank space) A14275 $4,736.85 $2,400.00 09/22/76 $2,336.85 09/09/94 In the Procedure Division, the programmer initializes RPT-LINE to SPACES and sets LINE-POS (which is to be used as the pointer field) to 4. Then he issues this STRING statement: STRING LINE-NO SPACE CUST-INFO SPACE INV-NO SPACE DATE-DUE SPACE DELIMITED BY SIZE, BAL-DUE DELIMITED BY DEC-POINT INTO RPT-LINE WITH POINTER LINE-POS. When the statement is executed, the following actions take place: 1. The field LINE-NO is moved into positions 4 through 8 of RPT-LINE. 2. A space is moved into position 9. 3. The group item CUST-INFO is moved into positions 10 through 58. 4. A space is moved into position 59. 5. INV-NO is moved into positions 60 through 65. 6. A space is moved into position 66. 7. DATE-DUE is moved into positions 67 through 74. 8. A space is moved into position 75. 9. The portion of BAL-DUE that precedes the decimal point is moved into positions 76 through 81. After the STRING statement has been executed:  RPT-LINE appears as shown in STRING Statement Example Output Data.  LINE-POS contains the value 82. Note: One STRING statement can be written instead of a series of MOVE statements. ┌────────────────────────────────────────────────────────────────────────────────────┐ │ │ │ Column │ │ 4 10 25 60 67 76 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │       │ │ 00001 J.B. SMITH 444 SPRING ST., CHICAGO, ILL. A14725 09/09/94 $2,336 │ │ │ └────────────────────────────────────────────────────────────────────────────────────┘ STRING Statement Example Output Data ═══ 12.48. SUBTRACT Statement ═══ The SUBTRACT statement subtracts one numeric item, or the sum of two or more numeric items, from one or more numeric items, and stores the results. The SUBTRACT statement has three formats:  Format 1 - SUBTRACT  Format 2 - SUBTRACT with GIVING phrase  Format 3 - SUBTRACT with CORRESPONDING phrase ═══ 12.48.1. SUBTRACT Statement - Format 1 ═══ ┌─── SUBTRACT STATEMENT - FORMAT 1 ────────────────────────────────────────────┐ │ │ │ ┌──────────────────┐ ┌───────────────────────────┐ │ │  │  │ │ │ >>──SUBTRACT────┬─identifier-1─┬─┴──FROM────identifier-2──┬─────────┬─┴────> │ │ └─literal-1────┘ └─ROUNDED─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──SIZE ERROR──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──────────────────> │ │ └─NOT───┬──────┬──SIZE ERROR──imperative-statement-2─┘ │ │ └─ON───┘ │ │ │ │ >──┬──────────────┬──>< │ │ └─END-SUBTRACT─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 1, identifiers or literals preceding the keyword FROM are added together, and this initial sum is subtracted from and stored in identifier-2. The initial sum is then subtracted from and stored in each successive occurrence of identifier-2, in the left-to-right order in which identifier-2 is specified. ═══ 12.48.2. SUBTRACT Statement - Format 2 - GIVING phrase ═══ ┌─── SUBTRACT STATEMENT - FORMAT 2 ────────────────────────────────────────────┐ │ │ │ ┌──────────────────┐ │ │  │ │ │ >>──SUBTRACT────┬─identifier-1─┬─┴──FROM──┬─identifier-2─┬─────────────────> │ │ └─literal-1────┘ └─literal-2────┘ │ │ │ │ ┌───────────────────────────┐ │ │  │ │ │ >──GIVING────identifier-3──┬─────────┬─┴───────────────────────────────────> │ │ └─ROUNDED─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──SIZE ERROR──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──────────────────> │ │ └─NOT───┬──────┬──SIZE ERROR──imperative-statement-2─┘ │ │ └─ON───┘ │ │ │ │ >──┬──────────────┬──>< │ │ └─END-SUBTRACT─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 2, all identifiers or literals preceding the keyword FROM are added together and this sum is subtracted from identifier-2 or literal-2. The result of the subtraction is stored in the data item referenced by identifier-3. Identifier-2 or literal-2 remains unchanged. ═══ 12.48.3. SUBTRACT Statement - Format 3 - CORRESPONDING phrase ═══ ┌─── SUBTRACT STATEMENT - FORMAT 3 ────────────────────────────────────────────┐ │ │ │ >>──SUBTRACT──┬─CORRESPONDING─┬──identifier-1──FROM────────────────────────> │ │ └─CORR──────────┘ │ │ │ │ >──identifier-2──┬─────────┬───────────────────────────────────────────────> │ │ └─ROUNDED─┘ │ │ │ │ >──┬──────────────────────────────────────────────┬────────────────────────> │ │ └─┬──────┬──SIZE ERROR──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬────────────────────────────────────────────────────┬──────────────────> │ │ └─NOT───┬──────┬──SIZE ERROR──imperative-statement-2─┘ │ │ └─ON───┘ │ │ │ │ >──┬──────────────┬──>< │ │ └─END-SUBTRACT─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ In Format 3, elementary data items within identifier-1 are subtracted from, and the results are stored in, the corresponding elementary data items within identifier-2. If the composite of operands is 18 digits or less, enough places are carried so that no significant digits are lost during execution. -----IBM Extension----- The composite of all operands in an arithmetic statement can have a maximum length of 30 digits. ---End of IBM Extension--- ═══ 12.49. UNSTRING Statement ═══ The UNSTRING statement causes contiguous data in a sending field to be separated and placed into multiple receiving fields. One UNSTRING statement can be written instead of a series of MOVE statements. ┌─── UNSTRING STATEMENT - FORMAT ──────────────────────────────────────────────┐ │ │ │ >>──UNSTRING──identifier-1─────────────────────────────────────────────────> │ │ │ │ >──┬────────────────────────────────────────────────────────────────┬──────> │ │ └─DELIMITED──┬──────┬──┬──────┬──┬─identifier-2─┬──┤ OR Phrase ├─┘ │ │ └─BY───┘ └─ALL──┘ └─literal-1────┘ │ │ │ │ ┌──────────────────────────────────────────────────────┐ │ │  │ │ │ >──INTO────identifier-4──┤ DELIMITER Phrase ├──┤ COUNT Phrase ├─┴──────────> │ │ │ │ >──┬─────────────────────────────────┬─────────────────────────────────────> │ │ └─┬──────┬──POINTER──identifier-7─┘ │ │ └─WITH─┘ │ │ │ │ >──┬──────────────────────────────────┬────────────────────────────────────> │ │ └─TALLYING──┬──────┬──identifier-8─┘ │ │ └─IN───┘ │ │ │ │ >──┬────────────────────────────────────────────┬──────────────────────────> │ │ └─┬──────┬──OVERFLOW──imperative-statement-1─┘ │ │ └─ON───┘ │ │ │ │ >──┬──────────────────────────────────────────────────┬────────────────────> │ │ └─NOT───┬──────┬──OVERFLOW──imperative-statement-2─┘ │ │ └─ON───┘ │ │ │ │ >──┬──────────────┬──>< │ │ └─END-UNSTRING─┘ │ │ │ │ OR PHRASE: │ │ ├──┬────────────────────────────────────┬──┤ │ │ │ ┌────────────────────────────────┐ │ │ │ │  │ │ │ │ └───OR──┬──────┬──┬─identifier-3─┬─┴─┘ │ │ └─ALL──┘ └─literal-2────┘ │ │ │ │ DELIMITER PHRASE: │ │ ├──┬───────────────────────────────────┬──┤ │ │ └─DELIMITER──┬──────┬──identifier-5─┘ │ │ └─IN───┘ │ │ │ │ COUNT PHRASE: │ │ ├──┬───────────────────────────────┬──┤ │ │ └─COUNT──┬──────┬──identifier-6─┘ │ │ └─IN───┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Related Information:  Data Flow  Coding Example ═══ 12.49.1. DELIMITED BY Phrase ═══ This phrase specifies delimiters within the data that control the data transfer. The delimiters are identifier-2, identifier-3, or their corresponding literals. Each identifier or literal specified represents one delimiter. Each must be an alphanumeric data item. Unless the DELIMITED BY phrase is specified, the DELIMITER IN and COUNT IN phrases must not be specified. If a delimiter contains two or more characters, it is recognized as a delimiter only if the delimiting characters are contiguous, and in the sequence specified in the sending field. When two or more delimiters are specified, an OR condition exists, and each nonoverlapping occurrence of any one of the delimiters is recognized in the sending field in the sequence specified. For example, if DELIMITED BY "AB" or "BC" is specified, then an occurrence of either AB or BC in the sending field is considered a delimiter; an occurrence of ABC is considered an occurrence of AB. The data-count fields, the pointer field, and the field-count field must each be an integer item without the symbol P in the PICTURE character-string. ═══ 12.49.2. ON OVERFLOW Phrases ═══ Imperative-statement-1 is executed when:  The pointer value (explicit or implicit) is less than 1  The pointer value (explicit or implicit) exceeds a value equal to the length of the sending field  All data receiving fields have been acted upon, and the sending field still contains unexamined characters. When any of the above conditions occurs: 1. An overflow condition exists, and no more data is transferred 2. The UNSTRING operation is terminated 3. The NOT ON OVERFLOW phrase, if specified, is ignored 4. Control is transferred to the end of the UNSTRING statement or, if the ON OVERFLOW phrase is specified, to imperative-statement-1. If control is transferred to imperative-statement-1, execution continues according to the rules for each statement specified in imperative-statement-1. If a procedure branching or conditional statement that causes explicit transfer of control is executed, control is transferred according to the rules for that statement; otherwise, upon completion of the execution of imperative-statement-1, control is transferred to the end of the UNSTRING statement. If conditions that would cause an overflow condition are not encountered, the ON OVERFLOW phrase, if specified, is ignored. If the NOT ON OVERFLOW phrase is specified, control is transferred to imperative-statement-2; otherwise, control is transferred to the end of the UNSTRING statement. If control is transferred to imperative-statement-2, execution continues according to the rules for each statement specified in imperative-statement-2. If a procedure branching or conditional statement that causes explicit transfer of control is executed, control is transferred according to the rules for that statement. Otherwise, upon completion of the execution of imperative-statement-2, control is transferred to the end of the UNSTRING statement. ═══ 12.49.3. Data Flow ═══ When the UNSTRING statement is initiated, data is transferred from the sending field to the current data receiving field, according to the following rules (the current data receiving field is identifier-4): 1. If the POINTER phrase is not specified, the sending field character-string is examined, beginning with the leftmost character. If the POINTER phrase is specified, the field is examined, beginning at the relative character position specified by the value in the pointer field. 2. If the DELIMITED BY phrase is specified, the examination proceeds from left to right, character-by-character, until a delimiter is encountered. If the end of the sending field is reached before a delimiter is found, the examination ends with the last character in the sending field. If there are more receiving fields, the next one is selected, otherwise, an overflow condition occurs. 3. If the DELIMITED BY phrase is not specified, the number of characters examined is equal to the size of the current data receiving field, which depends on its data category: a) If the receiving field is alphanumeric or alphabetic, the number of characters examined is equal to the number of characters in the current receiving field. b) If the receiving field is numeric, the number of characters examined is equal to the number of characters in the integer portion of the current receiving field. c) If the receiving field is described with the SIGN IS SEPARATE clause, the number of characters examined is one less than the size of the current receiving field. d) If the receiving field is described as a variable-length data item, the number of characters examined is determined by the size of the current receiving field at the beginning of the UNSTRING operation. 4. The examined characters (excluding any delimiter characters) are treated as an alphanumeric elementary item, and are moved into the current data receiving field, according to the rules for the MOVE statement (see MOVE Statement). 5. If the DELIMITER IN phrase is specified, the delimiting characters in the sending field are treated as an elementary alphanumeric item and are moved to the current delimiter receiving field, according to the rules for the MOVE statement. If the delimiting condition is the end of the sending field, the current delimiter receiving field is filled with spaces. 6. If the COUNT IN phrase is specified, a value equal to the number of examined characters (excluding any delimiters) is moved into the data count field, according to the rules for an elementary move. 7. If the DELIMITED BY phrase is specified, the sending field is further examined, beginning with the first character to the right of the delimiter. 8. If the DELIMITED BY phrase is not specified, the sending field is further examined, beginning with the first character to the right of the last character examined. 9. For each succeeding data receiving field, the preceding procedure is repeated either until all the characters in the sending field have been transferred, or until there are no more unfilled data receiving fields. 10. When the POINTER phrase is specified, the value of the pointer field behaves as if it were increased by 1 for each examined character in the sending field. When this execution of the UNSTRING statement is completed, the pointer field contains a value equal to its initial value, plus the number of characters examined in the sending field. 11. When the TALLYING phrase is specified, then, when this execution of the UNSTRING statement is completed, the field-count field contains a value equal to the initial value, plus the number of data receiving areas acted upon. Note: All subscripting and reference modification is performed only once, at the beginning of the execution of the UNSTRING statement. If any of the UNSTRING statement identifiers are subscripted or indexed, the subscripts and indexes are evaluated as follows:  Any subscripting or indexing associated with the sending field, the pointer field, or the field-count field is evaluated only once, immediately before any data is transferred to any of the receivers.  Any subscripting or indexing associated with the delimiters, the data and delimiter receiving fields, or the data-count fields, is evaluated immediately before the transfer of data into the affected data item. ═══ 12.49.3.1. UNSTRING Statement Example ═══ The following example illustrates some of the considerations that apply to the UNSTRING statement. In the Data Division, the user has defined the following input record to be acted upon by the UNSTRING statement: 01 INV-RCD. 05 CONTROL-CHARS PIC XX. 05 ITEM-INDENT PIC X(20). 05 FILLER PIC X. 05 INV-CODE PIC X(10). 05 FILLER PIC X. 05 NO-UNITS PIC 9(6). 05 FILLER PIC X. 05 PRICE-PER-M PIC 99999. 05 FILLER PIC X. 05 RTL-AMT PIC 9(6).99. The next two records are defined as receiving fields for the UNSTRING statement. DISPLAY-REC is to be used for printed output. WORK-REC is to be used for further internal processing. 01 DISPLAY-REC 05 INV-NO PIC X(6). 05 FILLER PIC X VALUE SPACE 05 ITEM-NAME PIC X(20). 05 FILLER PIC X VALUE SPACE 05 DISPLAY-DOLS PIC 9(6). 01 WORK-REC 05 M-UNITS PIC 9(6). 05 FIELD-A PIC 9(6). 05 WK-PRICE REDEFINES FIELD-A PIC 9999V99. 05 INV-CLASS PIC X(3). The user has also defined the following fields for use as control fields in the UNSTRING statement. 01 DBY-1 PIC X, VALUE IS ".". 01 CTR-1 PIC 99, VALUE IS ZERO. 01 CTR-2 PIC 99, VALUE IS ZERO. 01 CTR-3 PIC 99, VALUE IS ZERO. 01 CTR-4 PIC 99, VALUE IS ZERO. 01 DLTR-1 PIC X. 01 DLTR-2 PIC X. 01 CHAR-CT PIC 99, VALUE IS 3. 01 FLDS-FILLED PIC 99, VALUE IS ZERO. In the Procedure Division, the user writes the following UNSTRING statement to move subfields of INV-RCD to the subfields of DISPLAY-REC and WORK-REC: UNSTRING INV-RCD DELIMITED BY ALL SPACES OR "/" OR DBY-1 INTO ITEM-NAME COUNT IN CTR-1, INV-NO DELIMITER IN DLTR-1 COUNT IN CTR-2, INV-CLASS, M-UNITS COUNT IN CTR-3, FIELD-A, DISPLAY-DOLS DELIMITER IN DLTR-2 COUNT IN CTR-4 WITH POINTER CHAR-CT TALLYING IN FLDS-FILLED ON OVERFLOW GO TO UNSTRING-COMPLETE. Before the UNSTRING statement is issued, the user places the value 3 in the CHAR-CT (the pointer item), so as not to work with the two control characters at the beginning of INV-RCD. In DBY-1, a period is placed for use as a delimiter, and in FLDS-FILLED (the tallying item) the value 0 is placed. The following data is then read into INV-RCD as shown in UNSTRING Statement Example-Input Data. Column 1 10 20 30 40 50 60 │ │ │ │ │ │ │ │ │ │ │ │ │ │        ZYFOUR─PENNY─NAILS 707890/BBA 475120 00122 000379.50 UNSTRING Statement Example-Input Data When the UNSTRING statement is executed, the following actions take place: 1. Positions 3 through 18 (FOUR-PENNY-NAILS) of INV-RCD are placed in ITEM-NAME, left-justified within the area, and the unused character positions are padded with spaces. The value 16 is placed in CTR-1. 2. Because ALL SPACES is specified as a delimiter, the five contiguous SPACE characters are considered to be one occurrence of the delimiter. 3. Positions 24 through 29 (707890) are placed in INV-NO. The delimiter character / is placed in DLTR-1, and the value 6 is placed in CTR-2. 4. Positions 31 through 33 are placed in INV-CLASS. The delimiter is a SPACE, but because no field has been defined as a receiving area for delimiters, the SPACE is merely bypassed. 5. Positions 35 through 40 (475120) are examined and are placed in M-UNITS. The delimiter is a SPACE, but because no receiving field has been defined as a receiving area for delimiters, the SPACE is bypassed. The value 6 is placed in CTR-3. 6. Positions 42 through 46 (00122) are placed in FIELD-A and right-justified within the area. The high-order digit position is filled with a 0 (zero). The delimiter is a SPACE, but because no field has been defined as a receiving area for delimiters, the SPACE is bypassed. 7. Positions 48 through 53 (000379) are placed in DISPLAY-DOLS. The period delimiter character is placed in DLTR-2, and the value 6 is placed in CTR-4. 8. Because all receiving fields have been acted upon and two characters of data in INV-RCD have not been examined, the ON OVERFLOW exit is taken, and execution of the UNSTRING statement is completed. At the end of execution of the UNSTRING statement, DISPLAY-REC contains the following data: 707890 FOUR-PENNY-NAILS 000379 WORK-REC contains the following data: 475120000122BBA CHAR-CT (the pointer field) contains the value 55, and FLD-FILLED (the tallying field) contains the value 6. Note: One UNSTRING statement can be written instead of a series of MOVE statements. ═══ 12.50. WRITE Statement ═══ The WRITE statement releases a record for an output or input/output file. When the WRITE statement is executed, the associated indexed or relative file must be open in OUTPUT, I-O, or EXTEND mode. The associated sequential file must be open in OUTPUT or EXTEND (device types TAPEFILE, DISK, or DATABASE) mode. The WRITE statement has five formats:  Format 1 - Sequential Files  Format 2 - Indexed and Relative Files -----IBM Extension-----  Format 3 - FORMATFILE  Format 4 - TRANSACTION (Nonsubfile)  Format 5 - TRANSACTION (Subfile) ---End of IBM Extension--- -----IBM Extension----- The action of this statement can be inhibited at program run time by the INHWRT parameter of the OVRDBF CL command. When this parameter is specified, non-zero file status codes are not set for data dependent errors. Duplicate key and data conversion errors are examples of data dependent errors. ---End of IBM Extension--- ═══ 12.50.1. Sequential Files ═══ The ADVANCING and END-OF-PAGE phrases control the vertical positioning of each line on a printed page. If the printed page is held on an intermediate device (a disk, for example), the format may appear different than the expected output when it is edited or browsed. Note: The ADVANCING PAGE and END-OF-PAGE phrases must not both be specified in a single WRITE statement. When an attempt is made to write beyond the externally defined boundaries of the file, the processing of the WRITE statement is unsuccessful and an EXCEPTION/ERROR condition exists. The contents of record-name are unaffected. Processing then follows the rules for error handling as described under USE Statement Programming Notes. For sequential files on device type TAPEFILE or DISKETTE, when end-of-volume is recognized for a multivolume OUTPUT file, the WRITE statement processes the following operations in order: 1. The standard ending volume label procedure is run. 2. A volume switch occurs. 3. The standard beginning volume label procedure is run. No indication that an end-of-volume has occurred is returned to the program. ┌─── WRITE STATEMENT - FORMAT 1 - SEQUENTIAL FILES ────────────────────────────┐ │ │ │ >>──WRITE──record-name-1──┬────────────────────┬───────────────────────────> │ │ └─FROM──identifier-1─┘ │ │ │ │ >──┬────────────────────────────────────────────────────────────┬──────────> │ │ └─┬─BEFORE─┬──┬───────────┬──┬─┬─identifier-2─┬──┬───────┬─┬─┘ │ │ └─AFTER──┘ └─ADVANCING─┘ │ └─integer-1────┘ ├─LINE──┤ │ │ │ │ └─LINES─┘ │ │ │ ├─mnemonic-name-1─────────────┤ │ │ └─PAGE────────────────────────┘ │ │ │ │ >──┬───────────────────────────────────────────────────┬───────────────────> │ │ └──┬──────┬──┬─END-OF-PAGE─┬─imperative-statement-1─┘ │ │ └─AT───┘ └─EOP─────────┘ │ │ │ │ >──┬─────────────────────────────────────────────────────────┬─────────────> │ │ └─NOT───┬──────┬──┬─END-OF-PAGE─┬──imperative-statement-2─┘ │ │ └─AT───┘ └─EOP─────────┘ │ │ │ │ >──┬───────────┬──>< │ │ └─END-WRITE─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The maximum record size for the file is established at the time the file is created, and cannot subsequently be changed. Record-name-1 and identifier-1 must not refer to the same storage area. After the WRITE statement is executed, the record is no longer available in record-name-1, unless:  The associated file is named in a SAME RECORD AREA clause (in which case, the record is also available as a record of the other files named in the SAME RECORD AREA clause), or  The WRITE statement is unsuccessful because of a boundary violation. In either of these two cases, the record is still available in record-name-1. The file position indicator is not affected by execution of the WRITE statement. The number of character positions required to store the record in a file may or may not be the same as the number of character positions defined by the logical description of that record in the COBOL program. (See PICTURE Clause Editing andUSAGE Clause.) If the FILE STATUS clause is specified in the File-Control entry, the associated status key is updated when the WRITE statement is executed, whether or not execution is successful. The WRITE statement cannot be executed for a sequential file opened in I-O mode. Related Information:  Multivolume Files ═══ 12.50.1.1. ADVANCING Phrase ═══ The ADVANCING phrase controls positioning of the output record on the page. It only applies to device type PRINTER. The following rules apply: 1. When BEFORE ADVANCING is specified, the line is printed before the page is advanced. 2. When AFTER ADVANCING is specified, the page is advanced before the line is printed. 3. When identifier-2 is specified, the page is advanced the number of lines equal to the current value in identifier-2. Identifier-2 must be an integer data item. 4. When integer-1 is specified, the page is advanced the number of lines equal to the value of integer-1. 5. Integer-1 or the value in identifier-2 may be zero. 6. When mnemonic-name is specified, a system-specific action takes place. Mnemonic-name must be equated with environment-name-1 in the SPECIAL-NAMES paragraph (valid environment-names are listed in Choices of Environment-Name-1 and Action Taken). For more information on acceptable values for mnemonic-name, see SPECIAL-NAMES Paragraph. 7. When PAGE is specified, the record is printed on the logical page BEFORE or AFTER (depending on the phrase used) the device is positioned to the next logical page. If PAGE has no meaning for the device used, then BEFORE or AFTER (depending on the phrase specified) ADVANCING 1 LINE is provided. If the FD entry contains a LINAGE clause, the repositioning is to the first printable line of the next page, as specified in that clause. If the LINAGE clause is omitted, the repositioning is to line 1 of the next succeeding page. LINAGE-COUNTER Rules: If the LINAGE clause is specified for this file, the associated LINAGE-COUNTER special register is modified during the execution of the WRITE statement, according to the following rules: a) If ADVANCING PAGE is specified, LINAGE-COUNTER is reset to 1. b) If ADVANCING identifier-2 or integer-1 is specified, LINAGE-COUNTER is increased by the value in identifier-2 or integer-1. c) If the ADVANCING phrase is omitted, LINAGE-COUNTER is increased by 1. d) When the device is repositioned to the first available line of a new page, LINAGE-COUNTER is reset to 1. When this phrase is omitted, automatic line advancing is provided, as if the user had written AFTER ADVANCING 1 LINE. ═══ 12.50.1.2. END-OF-PAGE Phrase ═══ When this phrase is specified (and the FD entry for this file contains a LINAGE clause), and the logical end of the printed page is reached during execution of the WRITE statement, the imperative-statement is executed. If an END-OF-PAGE condition does not exist after the processing of a WRITE statement with the NOT AT END-OF-PAGE phrase, control transfers to the imperative statement associated with that phrase. Related Information:  Special Considerations for Printer Files  Special Considerations for FORMATFILEs ═══ 12.50.1.2.1. Special Considerations for Printer Files ═══ The keywords END-OF-PAGE and EOP are equivalent. When the END-OF-PAGE phrase is specified, the FD entry for this file must contain a LINAGE clause. When END-OF-PAGE is specified, and an END-OF-PAGE condition exists after the processing of the WRITE statement, the END-OF-PAGE imperative-statement is processed. The logical end of the printed page is specified in the LINAGE clause associated with record-name. An END-OF-PAGE condition for a printer file is reached when the processing of a WRITE statement for that file causes printing or spacing within the footing area of a page body. This occurs when the processing of such a WRITE statement causes the value in the LINAGE-COUNTER to equal or exceed the value specified in the WITH FOOTING phrase of the LINAGE clause. The WRITE statement is processed, and then the END-OF-PAGE imperative statement is processed, if coded. An automatic page overflow condition is reached whenever the processing of any WRITE statement with or without the END-OF-PAGE phrase cannot be completely processed within the current page body. This occurs when a processed WRITE statement would cause the value in the LINAGE-COUNTER to exceed the number of lines for the page body specified in the LINAGE clause. In this case, the line is printed before or after (depending on the option specified) the device is repositioned to the first printable line on the next logical page, as specified in the LINAGE clause. If the END-OF-PAGE phrase is specified, the END-OF-PAGE imperative-statement is then processed. The END-OF-PAGE condition and automatic page overflow condition occur simultaneously in the following cases:  When the WITH FOOTING phrase of the LINAGE clause is not specified. This results in no distinction between the END-OF-PAGE condition and the page overflow condition. No footing information can be printed at the bottom of a logical page when the FOOTING phrase is not specified.  When the WITH FOOTING phrase is specified, but the processing of a WRITE statement would cause the LINAGE-COUNTER to exceed both the footing value and the page body value specified in the LINAGE clause. The keywords END-OF-PAGE and EOP are equivalent. Note: The phrases ADVANCING PAGE and END-OF-PAGE must not both be specified in a single WRITE statement. ═══ 12.50.1.2.2. Special Considerations for FORMATFILEs ═══ The keywords END-OF-PAGE and EOP are equivalent. When the END-OF-PAGE phrase is specified, and an EOP condition exists after the processing of the WRITE statement for the FORMATFILE file, the END-OF-PAGE imperative statement is processed. An EOP condition for a FORMATFILE file occurs when the logical end of page is reached during the processing of a WRITE statement for that file. The logical end of the printed page is specified in the overflow line number parameter of the CRTPRTF command or the OVRPRTF command. ═══ 12.50.1.3. Multivolume Files ═══ When end-of-volume is recognized for a multivolume OUTPUT file (tape or sequential direct-access file), the WRITE statement performs the following operations:  The standard ending volume label procedure  A volume switch  The standard beginning volume label procedure. ═══ 12.50.2. Indexed and Relative Files ═══ ┌─── WRITE STATEMENT - FORMAT 2 - INDEXED AND RELATIVE FILES ──────────────────┐ │ │ │ >>──WRITE──record-name-1──┬────────────────────┬───────────────────────────> │ │ └─FROM──identifier-1─┘ │ │ │ │ >──┬───────────────────────────────────────┬───────────────────────────────> │ │ │ (1) │ │ │ └─FORMAT────┬──────┬──┬─identifier-2─┬──┘ │ │ └─IS───┘ └─literal-1────┘ │ │ │ │ >──┬───────────────────────────────────────────┬───────────────────────────> │ │ └─INVALID──┬──────┬──imperative-statement-1─┘ │ │ └─KEY──┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──┬───────────┬──>< │ │ └─NOT INVALID──┬──────┬──imperative-statement-2─┘ └─END-WRITE─┘ │ │ └─KEY──┘ │ │ │ │ NOTE: │ │ (1) IBM Extension │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Related Information:  Considerations for Writing Indexed Files  Considerations for Writing Relative Files ═══ 12.50.2.1. Considerations When Writing Indexed Files ═══ Before the WRITE statement is executed, you must set the prime record key (the RECORD KEY data item, as defined in the File-Control entry) to the desired value. When the WRITE statement is processed, the system releases the record. -----IBM Extension----- If the DUPLICATES phrase is specified, record key values for a format need not be unique (see RECORD KEY Clause). In this case, the system stores the records so that later sequential access to the records allows retrieval in the order specified in DDS. ---End of IBM Extension--- If records are written to an indexed file of fixed size when it has SEQUENTIAL access, is open for OUTPUT, and blocking is in effect (BLOCK CONTAINS clause is specified), the blocking factor will change to 1 at the point at which a block of records would cause the end-of-file to be reached. The number of remaining records in the file at this moment is less than the number of records in a block. When ACCESS IS SEQUENTIAL is specified in the File-Control entry, records must be released in ascending order of RECORD KEY values. When ACCESS is RANDOM or ACCESS IS DYNAMIC is specified in the File-Control entry, records may be released in any programmer-specified order. If the FORMAT phrase is not specified on the I-O statement when indexed files are accessed in random access mode, the first format defined is used. When writing to a multiformat logical file, the format must be specified on the WRITE statement. ═══ 12.50.2.2. Considerations When Writing Relative Files ═══ For OUTPUT files, the WRITE statement causes the following actions:  If ACCESS IS SEQUENTIAL is specified: The first record released has relative record number 1, the second record released has relative record number 2, the third number 3, and so on. If the RELATIVE KEY is specified in the File-Control entry, the relative record number of the record just released is placed in the RELATIVE KEY during execution of the WRITE statement.  If ACCESS IS RANDOM or ACCESS IS DYNAMIC is specified, the RELATIVE KEY must contain the desired relative record number for this record before the WRITE statement is issued. When the WRITE statement is executed, this record is placed at the specified relative record number position in the file. For files opened in I-O mode, either ACCESS IS RANDOM or ACCESS IS DYNAMIC must be specified; the WRITE statement inserts new records into the file. The RELATIVE KEY must contain the desired relative record number for this record before the WRITE statement is issued. When the WRITE statement is executed, this record is placed at the specified relative record number position in the file. For a physical file that does not allow the DELETE operation on records (for example, using the CRTPF with the ALWDLT(*NO) parameter), the update operation on records must be allowed (that is, CRTPF with the ALWUPD(*YES) parameter). ═══ 12.50.2.3. FORMAT Phrase ═══ Required if there is more than one record format for the file. The value specified in the FORMAT phrase contains the name of the record format to use for this I-O operation. The system uses this to specify or select which record format to operate on. Identifier-2, if specified, must be a an alphanumeric data item of 10 characters or less. Literal-1, if specified, must be an uppercase character-string of 10 characters or less. If the FORMAT phrase is not specified on the I-O statement when indexed files are accessed in random access mode, the first format defined is used. ═══ 12.50.2.4. INVALID KEY Phrase ═══ The INVALID KEY phrase must be specified if an explicit or implicit EXCEPTION/ERROR procedure is not specified for this file. When an attempt is made to write beyond the externally defined boundaries of the file, WRITE statement execution is unsuccessful and an EXCEPTION/ERROR condition exists. For Relative files in Random or Dynamic access mode, an INVALID KEY condition exists when RELATIVE KEY specifies a record that already contains data. For Indexed files in Random or Dynamic access mode, an INVALID KEY condition exists when the value of the key field in the record area equals that of an already existing record and DUPLICATES are not allowed. For Indexed files in Sequential access mode, an INVALID KEY condition exists when the values of the primary record keys of successive records are not in ascending order. -----IBM Extension----- For a file that allows duplicate keys, the INVALID KEY condition exists only if the value of the record key is less than that for the previous record. ---End of IBM Extension--- When the invalid key condition is recognized, WRITE statement execution is unsuccessful, and the contents of the record are unaffected. Program execution proceeds according to the rules described under INVALID KEY Condition. ═══ 12.50.2.5. FORMATFILE ═══ -----IBM Extension----- ┌─── WRITE STATEMENT - FORMAT 3 - FORMATFILE ──────────────────────────────────┐ │ │ │ >>──WRITE──record-name-1──┬────────────────────┬───────────────────────────> │ │ └─FROM──identifier-1─┘ │ │ │ │ >──┬────────────────────────────────────┬──────────────────────────────────> │ │ └─FORMAT─┬──────┬──┬─identifier-2─┬──┘ │ │ └─IS───┘ └─literal-1────┘ │ │ │ │ >──┬───────────────────────────────────────┬───────────────────────────────> │ │ └──┬─INDICATOR──┬──┬─────┬─identifier-3─┘ │ │ ├─INDICATORS─┤ ├─IS──┤ │ │ └─INDIC──────┘ └─ARE─┘ │ │ │ │ >──┬───────────────────────────────────────────────────┬───────────────────> │ │ └──┬──────┬──┬─END-OF-PAGE─┬─imperative-statement-1─┘ │ │ └─AT───┘ └─EOP─────────┘ │ │ │ │ >──┬───────────────────────────────────────────────────────┬───────────────> │ │ └─NOT──┬──────┬──┬─END-OF-PAGE─┬─imperative-statement-2─┘ │ │ └─AT───┘ └─EOP─────────┘ │ │ │ │ >──┬───────────┬──>< │ │ └─END-WRITE─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ---End of IBM Extension--- ═══ 12.50.2.6. FORMAT Phrase ═══ Required if there is more than one record format for the file. -----IBM Extension----- The value specified in the FORMAT phrase contains the name of the record format to use for this I-O operation. The system uses this to specify or select which record format to operate on. Identifier-2, if specified, must be an alphanumeric data item of 10 characters or less. Literal-1, if specified, must be an uppercase character-string of 10 characters or less. A value of all blanks is treated as though the FORMAT phrase were not specified. If the value is not valid for the file, a FILE STATUS of 9K is returned and a USE procedure is invoked, if applicable for the file. ---End of IBM Extension--- ═══ 12.50.2.7. INDICATORS Phrase ═══ Specifies which indicators are to be written when a data record is read. Indicators can be used to pass information about the data record and how it was entered into the program. Identifier-3 must be either an elementary Boolean data item specified without the OCCURS clause or a group item that has elementary Boolean data items subordinate to it. ═══ 12.50.2.8. TRANSACTION (Nonsubfile) ═══ -----IBM Extension----- ┌─── WRITE - FORMAT 4 - TRANSACTION (NONSUBFILE) ──────────────────────────────┐ │ │ │ >>──WRITE──record-name-1──┬────────────────────┬───────────────────────────> │ │ └─FROM──identifier-1─┘ │ │ │ │ >──FORMAT─┬──────┬──┬─identifier-2─┬───────────────────────────────────────> │ │ └─IS───┘ └─literal-1────┘ │ │ │ │ >──┬──────────────────────────────────────┬────────────────────────────────> │ │ └─TERMINAL──┬──────┬──┬─identifier-3─┬─┘ │ │ └─IS───┘ └─literal-2────┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──────────────────────> │ │ └─STARTING──┬──────┬──┬──────┬──┬─identifier-4─┬─┘ │ │ └─AT───┘ └─LINE─┘ └─literal-3────┘ │ │ │ │ >──┬────────────────────┬──┬────────────────────────────────────────┬──────> │ │ └─┤ Rolling Phrase ├─┘ └──┬─INDICATOR──┬──┬──────┬─identifier-8─┘ │ │ ├─INDICATORS─┤ ├─IS───┤ │ │ └─INDIC──────┘ └─ARE──┘ │ │ │ │ >──┬───────────┬──>< │ │ └─END-WRITE─┘ │ │ │ │ ROLLING PHRASE: │ │ ├──┬─BEFORE─┬──ROLLING──┬───────┬──┬─identifier-5─┬──┬─────────┬───────────> │ │ └─AFTER──┘ ├─LINES─┤ └─literal-4────┘ ├─THROUGH─┤ │ │ └─LINE──┘ └─THRU────┘ │ │ │ │ >──┬─identifier-6─┬──┬─UP───┬──┬─identifier-7─┬──┬───────┬──┤ │ │ └─literal-5────┘ └─DOWN─┘ └─literal-6────┘ ├─LINES─┤ │ │ └─LINE──┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ---End of IBM Extension--- ═══ 12.50.2.9. FORMAT Phrase ═══ -----IBM Extension----- Literal-1 or identifier-2 specifies the name of the record format to be written. Literal-1, if specified, must be nonnumeric, uppercase, and 10 characters or less in length. Identifier-2, if specified, must refer to an alphanumeric data item, 10 characters or less in length. If identifier-2 contains blanks, the WRITE statement is executed as if the FORMAT phrase were omitted. ═══ 12.50.2.10. TERMINAL Phrase ═══ The TERMINAL phrase specifies the program devices to which the output record is to be sent. The contents of literal-2 or identifier-3 must be the name of a program device previously acquired, either implicitly or explicitly, by the file. Literal-2, if specified, must be nonnumeric and 10 characters or less in length. Identifier-3, if specified, must refer to an alphanumeric data item, 10 characters or less in length. A value of blanks is treated as if the TERMINAL phrase was omitted. If only a single program device was acquired by the TRANSACTION file, the TERMINAL phrase can be omitted. That program device is always used for the WRITE. If the TERMINAL phrase is omitted for a WRITE operation to a TRANSACTION file that has acquired multiple program devices, the default program device is used. ---End of IBM Extension--- ═══ 12.50.2.11. STARTING Phrase ═══ -----IBM Extension----- The STARTING phrase specifies the starting line number for the record formats that use the variable starting line keyword. This phrase is only valid for display devices. The actual line number on which a field begins can be determined from the following equation: Actual-line = Start-line + DDS Start-line - 1 Where: Actual-line is the actual line number Start-line is the starting line number specified in the program DDS Start-line is the line number specified in positions 39 through 41 of the Data Description Specifications form. The write is successful if:  The result of the above equation is positive and less than or equal to the number of lines on the workstation screen.  The value specified for the STARTING phrase is 0. In this case, a value of 1 is assumed. The write is unsuccessful and the program terminates if:  The result of the above equation is greater than the number of lines on the workstation screen.  The value specified for the STARTING phrase is negative. If the value specified for the STARTING phrase is within the screen area, any fields outside of the screen area are ignored. Literal-3 of the STARTING phrase must be a numeric literal. Identifier-4 must be an elementary numeric item. To use the STARTING phrase, the DDS record level keyword SLNO(*VAR) must be specified for the format being written. If the record format does not specify this keyword, the STARTING phrase is ignored at execution time. The DDS keyword CLRL also affects the STARTING phrase. CLRL controls how much of the screen is cleared when the WRITE statement is executed. ---End of IBM Extension--- ═══ 12.50.2.12. ROLLING Phrase ═══ -----IBM Extension----- The ROLLING phrase allows you to move lines displayed on the workstation screen. All or some of the lines on the screen can be rolled up or down. The lines vacated by the rolled lines are cleared, and can have another screen format written into them. This phrase is only valid for display devices. ROLLING is specified in the WRITE statement that is writing a new format to the workstation screen. You must specify whether the write is before or after the roll, the range of lines you want to roll, how many lines you want to roll these lines, and whether the roll operation is up or down. After lines are rolled, the fields on these lines retain their DDS display attributes, for example, underlining, but lose their DDS usage attributes, for example, input-capability. Fields on lines that are written and then rolled (BEFORE ROLLING phrase) also lose their usage attributes. If any part of a format is rolled, the entire format loses its usage attributes. If more than one format exists, only the rolled formats lose their usage attributes. When you specify the ROLLING phrase, the following general rules apply.  The DDS record level keyword ALWROL must be specified for every record format written in a WRITE statement containing the ROLLING phrase.  Other DDS keywords mutually exclusive with the ALWROL keyword must not be used.  Either of the DDS keywords, CLRL or OVERLAY, must be specified for a record format that is to be written and rolled to prevent the display screen from being cleared when that record format is written.  All the identifiers and literals must represent positive integer values.  The roll starting line number (identifier-5 or literal-4) must not exceed the ending line number (identifier-6 or literal-5).  The contents of lines that are rolled outside of the window specified by the starting and ending line numbers disappear. ---End of IBM Extension--- ═══ 12.50.2.13. INDICATORS Phrase ═══ Specifies which indicators are to be used when a data record is written. Indicators can be used to pass information about the data record and how it was entered into the program. For detailed information on the INDICATORS phrase, refer to Using Indicators with Transaction Files in the ILE COBOL/400 PROGRAM-ID. Identifier-8 must be either an elementary Boolean data item specified without the OCCURS clause or a group item that has elementary Boolean data items subordinate to it. ---End of IBM Extension--- ═══ 12.50.2.14. TRANSACTION (Subfile) ═══ -----IBM Extension----- ┌─── WRITE STATEMENT - FORMAT 5 - TRANSACTION (SUBFILE) ───────────────────────┐ │ │ │ >>──WRITE SUBFILE──record-name-1──┬────────────────────┬───────────────────> │ │ └─FROM──identifier-1─┘ │ │ │ │ >──FORMAT─┬──────┬──┬─identifier-2─┬───────────────────────────────────────> │ │ └─IS───┘ └─literal-1────┘ │ │ │ │ >──┬──────────────────────────────────────┬────────────────────────────────> │ │ └─TERMINAL──┬──────┬──┬─identifier-3─┬─┘ │ │ └─IS───┘ └─literal-2────┘ │ │ │ │ >──┬────────────────────────────────────────┬──────────────────────────────> │ │ └──┬─INDICATOR──┬──┬──────┬─identifier-4─┘ │ │ ├─INDICATORS─┤ ├─IS───┤ │ │ └─INDIC──────┘ └─ARE──┘ │ │ │ │ >──┬───────────────────────────────────────────┬───────────────────────────> │ │ └─INVALID──┬──────┬──imperative-statement-1─┘ │ │ └─KEY──┘ │ │ │ │ >──┬────────────────────────────────────────────────┬──┬───────────┬──>< │ │ └─NOT INVALID──┬──────┬──imperative-statement-2─┘ └─END-WRITE─┘ │ │ └─KEY──┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Format 5 can only be used for display devices. If the subfile form of the WRITE statement is used for any other type of device, the WRITE operation fails and a file status of 90 is set. If the format is a subfile record and SUBFILE is specified, the RELATIVE KEY clause must be specified on the SELECT clause for the file being written. The record written to the subfile is the record in the subfile identified by the format name that has a relative record number equal to the value of the RELATIVE KEY data item. ═══ 12.50.2.15. INDICATORS Phrase ═══ Specifies which indicators are to be used when a data record is written. Indicators can be used to pass information about the data record and how it was entered into the program. For detailed information on the INDICATORS phrase, refer to Using Indicators with Transaction Files in the ILE COBOL/400 PROGRAM-ID. Identifier-4 must be either an elementary Boolean data item specified without the OCCURS clause or a group item that has elementary Boolean data items subordinate to it. ═══ 12.51. *CONTROL (*CBL) Statement ═══ -----IBM Extension----- With the *CONTROL (or *CBL) statement, you can selectively display or suppress the listing of source code throughout the source program. ┌─── CONTROL (*CBL) STATEMENT - FORMAT ────────────────────────────────────────┐ │ │ │ ┌───────────────┐ │ │  │ │ │ >>──┬─*CONTROL─┬────┬─SOURCE────┬─┴──┬───┬──>< │ │ └─*CBL─────┘ ├─NOSOURCE──┤ └─.─┘ │ │ │ (1) │ │ │ ├─LIST──────┤ │ │ │ (1)│ │ │ ├─NOLIST────┤ │ │ │ (1) │ │ │ ├─MAP───────┤ │ │ │ (1) │ │ │ └─NOMAP─────┘ │ │ │ │ NOTE: │ │ (1) Syntax checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The *CONTROL and *CBL statements are synonymous. The characters *CONTROL or *CBL can start in any column beginning with column 8, followed by at least one space or comma and one or more option keywords. Separate the option keywords with one or more spaces or commas. This statement must be the only statement on the line, and continuation is not allowed. The statement can end with a period. The options you request are handled in the following manner: 1. If SOURCE or NOSOURCE appears more than once in a *CONTROL statement, the last occurrence of either option is used. 2. If a *CONTROL NOSOURCE statement is encountered and SOURCE has been requested as a compiler option, printing of the source listing is suppressed from this point on. An informational message is issued stating that printing of the source has been suppressed. Afterwards, you can specify *CONTROL SOURCE to resume the printing of the source listing. 3. If *NOSOURCE is requested as a compiler option, output is always inhibited. 4. The *CONTROL statement is in effect only for the source program in which it is written. It does not remain in effect across batch compilation of a sequence of source programs. ---End of IBM Extension--- Related Information:  *CONTROL (*CBL) and the COPY statement ═══ 12.51.1. *CONTROL (*CBL) and the COPY Statement ═══ -----IBM Extension----- A COPY statement bearing the SUPPRESS phrase overrides any *CONTROL or *CBL options contained in the copied member, but the compiler remembers *CONTROL and *CBL statements that appear in a suppressed COPY member. Once the COPY member has been processed, the last NOSOURCE or SOURCE option in it runs. If a COPY statement does not bear the SUPPRESS phrase, *CONTROL and *CBL statements within the copied member run immediately. ---End of IBM Extension--- ═══ 12.52. COPY Statement ═══ The COPY statement is a library statement that places prewritten text in a COBOL program. The COPY statement has two formats:  Format 1 - Basic  Format 2 - DDS Translate Prewritten source program entries can be included in a source program at compilation time. Thus, an installation can use standard file descriptions, record descriptions, or procedures without recoding them. These entries and procedures can then be saved in user-created libraries; they can then be included in the source program by means of the COPY statement. Compilation of the source program containing COPY statements is logically equivalent to processing all COPY statements before processing the resulting source program. The effect of processing a COPY statement is that the library text associated with text-name is copied into the source program, logically replacing the entire COPY statement, beginning with the word COPY and ending with the period, inclusive. When the REPLACING phrase is not specified, the library text is copied unchanged. Related Information:  Coding Examples ═══ 12.52.1. COPY Statement - Format 1 - Basic ═══ ┌─── COPY STATEMENT - FORMAT 1 ────────────────────────────────────────────────┐ │ │ │ >>──COPY──text-name──┬──────────────────────────────────────────────┬──────> │ │ └─┬─OF─┬──┬───────────────────────┬──file-name─┘ │ │ └─IN─┘ │ (2)│ │ │ └─library-name- ────┘ │ │ │ │ >──┬─────────────┬──┬──────────────────┬──.──>< │ │ │ (1)│ └─REPLACING Phrase─┘ │ │ └─SUPPRESS────┘ │ │ │ │ NOTES: │ │ (1) IBM Extension │ │ │ │ (2) Required hyphen between library-name-file-name to qualify │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Each COPY statement must be preceded by a space and ended with a separator period. A COPY statement may appear in the source program anywhere a character string or a separator may appear; however, a COPY statement must not be specified within a COPY statement. The resulting copied text must not contain a COPY statement. -----IBM Extension----- COPY statements can be nested. However, nested COPY statements cannot contain the REPLACING phrase, and a COPY statement with the REPLACING phrase cannot contain nested COPY statements. A COPY statement may not cause recursion. That is, a COPY member may be named only once in a set of nested COPY statements until the end-of-file for that COPY member is reached. ---End of IBM Extension--- Debugging lines are permitted within library text and pseudo-text. Text words within a debugging line participate in the matching rules as if the D did not appear in the indicator area. A debugging line is specified within pseudo-text if the debugging line begins in the source program after the opening pseudo-text-delimiter but before the matching closing pseudo-text-delimiter. When a COPY statement is specified on a debugging line, the copied text is treated as though it appeared on a debugging line, except that comment lines in the text appear as comment lines in the resulting source program. If the word COPY appears in a comment-entry, or in the place where a comment-entry may appear, it is considered part of the comment-entry. After all COPY and REPLACE statements have been processed, a debugging line will be considered to have all the characteristics of a comment line, if the WITH DEBUGGING MODE clause is not specified in the SOURCE-COMPUTER paragraph. Comment lines or blank lines may occur in library text. Comment lines or blank lines appearing in library text are copied into the resultant source program unchanged with the following exception: a comment line or blank line in library text is not copied if that comment line or blank line appears within the sequence of text words that match pseudo-text-1 (refer to Replacement and Comparison Rules). The syntactic correctness of the entire COBOL source program cannot be determined until all COPY statements have been completely processed, because the syntactic correctness of the library text cannot be independently determined. Library text copied from the library is placed into the same area of the resultant program as it is in the library. Library text must conform to the rules for standard COBOL format. ═══ 12.52.2. REPLACING Phrase ═══ In the discussion that follows, each operand may consist of one of the following:  Pseudo-text  An identifier  A literal  A COBOL word (except COPY) When the REPLACING phrase is specified, the library text is copied, and each properly matched occurrence of operand-1 within the library text is replaced by the associated operand-2. ┌─── REPLACING PHRASE - FORMAT ────────────────────────────────────────────────┐ │ │ │ ┌──────────────────────────────────────────────────┐ │ │  │ │ │ >>──REPLACING────┬─==pseudo-text-1==─┬──BY──┬─==pseudo-text-2==─┬─┴──>< │ │ ├─identifier-1──────┤ ├─identifier-2──────┤ │ │ ├─literal-1─────────┤ ├─literal-2─────────┤ │ │ └─word-1────────────┘ └─word-2────────────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Related Information:  Replacement and Comparison Rules ═══ 12.52.3. Replacement and Comparison Rules ═══ 1. Arithmetic and logical operators that do not occur as part of an identifier are considered text words and may be replaced only through the pseudo-text option. 2. When a figurative constant is operand-1, it will match only if it appears exactly as it is specified. For example, if ALL "AB" is specified in the library text, then "ABAB" is not considered a match; only ALL "AB" is considered a match. 3. Operand-2 is copied in the place of operand-1 unless pseudo-text-2 positioning rules cause the replacement to be inserted in a different area. 4. Any separator comma, semicolon, and/or space preceding the leftmost word in the library text is copied into the source program. Beginning with the leftmost library text word and the first operand-1 specified in the REPLACING option, the entire REPLACING operand that precedes the keyword BY is compared to an equivalent number of contiguous library text words. 5. Operand-1 matches the library text if, and only if, the ordered sequence of text words in operand-1 is equal, character for character, to the ordered sequence of library words. For matching purposes, each occurrence of a comma or semicolon separator and each sequence of one or more space separators is considered to be a single space. 6. If no match occurs, the comparison is repeated with each successive operand-1, if specified, until either a match is found or there are no further REPLACING operands. 7. Whenever a match occurs between operand-1 and the library text, the associated operand-2 is copied into the source program. 8. When all operands have been compared and no match is found, the leftmost library text word is copied into the source program. 9. The next successive uncopied library text word is then considered to be the leftmost text word, and the comparison process is repeated, beginning with the first operand-1. The process continues until the rightmost library text word has been compared. 10. Comment lines or blank lines occurring in the library text and in pseudo-text-1 are ignored for purposes of matching; and the sequence of text words in the library text and in pseudo-text-1 is determined by the rules for reference format. Comment lines or blank lines appearing in pseudo-text-2 are copied into the resultant program unchanged whenever pseudo-text-2 is placed into the source program as a result of text replacement. Comment lines or blank lines appearing in library text are copied into the resultant source program unchanged with the following exception: a comment line or blank line in library text is not copied if that comment line or blank line appears within the sequence of text words that match pseudo-text-1. 11. Text words, after replacement, are placed in the source program according to standard COBOL format rules. -----IBM Extension----- 12. COPY REPLACING does not affect the EJECT, SKIP1/2/3, or TITLE compiler-directing statements. ---End of IBM Extension--- ═══ 12.52.4. Coding Examples ═══ Sequences of code (such as file and data descriptions, error and exception routines, etc.) that are common to a number of programs can be saved in a library, and then used in conjunction with the COPY statement. If naming conventions are established for such common code, then the REPLACING phrase need not be specified. If the names will change from one program to another, then the REPLACING phrase can be used to supply meaningful names for this program. Example 1: In this example, the library text PAYLIB consists of the following Data Division entries: 01 A. 02 B PIC S99. 02 C PIC S9(5)V99. 02 D PIC S9999 OCCURS 1 TO 52 TIMES DEPENDING ON B OF A. The programmer can use the COPY statement in the Data Division of a program as follows: COPY PAYLIB. In this program, the library text is copied; the resulting text is treated as if it had been written as follows: 01 A. 02 B PIC S99. 02 C PIC S9(5)V99. 02 D PIC S9999 OCCURS 1 TO 52 TIMES DEPENDING ON B OF A. Example 2: To change some (or all) of the names within the library text, the programmer can use the REPLACING phrase: COPY PAYLIB REPLACING A BY PAYROLL B BY PAY-CODE C BY GROSS-PAY D BY HOURS. In this program, the library text is copied; the resulting text is treated as if it had been written as follows: 01 PAYROLL. 02 PAY-CODE PIC S99. 02 GROSS-PAY PIC S9(5)V99. 02 HOURS PIC S9999 OCCURS 1 TO 52 TIMES DEPENDING ON PAY-CODE OF PAYROLL. The changes shown are made only for this program. The text, as it appears in the library, remains unchanged. ═══ 12.52.5. COPY Statement - Format 2 - DDS Translate ═══ -----IBM Extension----- ┌─── COPY STATEMENT - FORMAT 2 - DDS TRANSLATE ────────────────────────────────┐ │ │ │ >>──COPY──┬─DD-─format-name──┬──┬──────┬──┬─────────────┬──┬─OF─┬──────────> │ │ ├─DD-─ALL-FORMATS──┤ ├─-I───┤ ├─-INDICATOR──┤ └─IN─┘ │ │ ├─DDR-format-name──┤ ├─-O───┤ ├─-INDICATORS─┤ │ │ ├─DDR-ALL-FORMATS──┤ └─-I-O─┘ └─-INDIC──────┘ │ │ ├─DDS-format-name──┤ │ │ ├─DDS-ALL-FORMATS──┤ │ │ ├─DDSR-format-name─┤ │ │ └─DDSR-ALL-FORMATS─┘ │ │ │ │ >──┬───────────────────────┬──file-name──┬──────┬──────────────────────────> │ │ │ (1)│ └─WITH─┘ │ │ └─library-name- ────┘ │ │ │ │ ┌───────────────────────────┐ │ │  │ │ │ >────┬───────────────────────┬─┴──┬──────────┬──┬──────────────────┬──.──>< │ │ ├─┬─I-FIELDS───┬────────┤ └─SUPPRESS─┘ └─REPLACING Phrase─┘ │ │ │ ├─O-FIELDS───┤ │ │ │ │ └─I-O-FIELDS─┘ │ │ │ ├─┬─INDICATOR──┬────────┤ │ │ │ ├─INDICATORS─┤ │ │ │ │ └─INDIC──────┘ │ │ │ ├─PREFIX──BY────literal─┤ │ │ ├─ALIAS─────────────────┤ │ │ ├─SUBSTITUTE────────────┤ │ │ └─VLR───────────────────┘ │ │ │ │ NOTE: │ │ (1) Required hyphen between library-name-file-name to qualify │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The Format 2 COPY statement (DD, DDR, DDS, or DDSR option) can be used to create COBOL Data Division statements to describe a file that exists on the system. These descriptions are based on the version of the file in existence at compilation time. They do not make use of the DDS source statements for the file. The Format 2 COPY statement can be used only in the Data Division, and it is the user's responsibility to precede the statement with a group level item that has a level-number less than 05. ---End of IBM Extension--- ═══ 12.52.6. I-O ═══ -----IBM Extension----- If neither -I or I-FIELDS, nor -O or O-FIELDS is specified, then -I-O or I-O-FIELDS is assumed. If -I and O-FIELDS, or -O and I-FIELDS is specified, then -I-O or I-O-FIELDS is assumed. If a format-name is specified without the indicator attribute, and both -I and -O formats are to be generated, each record format is generated as a redefinition of a 05 elementary item defined as the size of the largest record format that will be generated. If the file is a database file, a single I-O format is generated. For all other file types the description generated varies as follows:  If -I is specified, the generated data description entries contain either: - The input and input/output fields for a nonsubfile format - The input, output, and input/output fields for a subfile format.  If -O is specified, the generated data description entries contain the output and input/output fields. The use of the Indicator attribute is discussed under INDICATOR Attribute of the Format 2 COPY Statement. ---End of IBM Extension--- ═══ 12.52.7. INDICATOR Attribute of the Format 2 COPY Statement ═══ -----IBM Extension----- The INDICATOR attribute specifies whether or not data description entries are generated for indicators. If the INDICATOR attribute is specified, data description entries are generated for indicators, but not for data fields. An 05 group level entry is generated as follows:  If the COPY is for a single structure COPY DDS-format-name-INDIC will generate 05 format-name-I. (or -0 as appropriate).  If the COPY is for multiple structures COPY DDS-ALL-FORMATS-INDIC will generate 05 file-name-RECORD. The data description entries that are generated are determined by which one of the usage attributes (I, O, or I-O) is specified or assumed in the COPY statement.  If ...I-INDICATOR... is specified, data description entries for input (response) indicators are generated for indicators used in the input record area.  If ...O-INDICATOR... is specified, data description entries for output (option) indicators are generated for indicators used in the output record area.  If ...I-O-INDICATOR... is specified or assumed, separate data description entries for both input and output (response and option) indicators are generated for indicators used in the input and output record areas. If the INDICATOR attribute is not specified, whether data description entries are generated for indicators depends on whether the file had the keyword INDARA specified in the DDS at the time it was created.  If INDARA was not specified, data description entries are generated for both data fields and indicators.  If INDARA was specified, data description entries are generated for data fields only, not for indicators. ---End of IBM Extension--- ═══ 12.53. EJECT Statement ═══ -----IBM Extension----- The EJECT statement specifies that the next source statement is to be printed at the top of the next page. ┌─── EJECT STATEMENT - FORMAT ─────────────────────────────────────────────────┐ │ │ │ >>──EJECT──┬───┬──>< │ │ └─.─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The EJECT statement must be the only statement on the line. It may be written in either Area A or Area B, and may be terminated with a separator period. The EJECT statement has no effect on the compilation of the source program itself. ---End of IBM Extension--- ═══ 12.54. REPLACE Statement ═══ The REPLACE statement is used to replace source program text. The REPLACE statement can occur anywhere in the source program where a character-string can occur. It must be preceded by a separator period except when it is the first statement in a separately compiled program. It must be terminated by a separator period. The REPLACE statement resembles the REPLACING phrase of the COPY statement, except that it acts on the entire source program, not just the text in COPY libraries. ┌─── REPLACE STATEMENT - FORMAT 1 ─────────────────────────────────────────────┐ │ │ │ ┌──────────────────────────────────────────┐ │ │  │ │ │ >>──REPLACE────==pseudo-text-1==──BY──==pseudo-text-2==─┴──.──>< │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Each matched occurrence of pseudo-text-1 is replaced by its corresponding pseudo-text-2. This process continues until any of the following are met:  The next occurrence of the REPLACE statement  End of the program  REPLACE OFF (see Format 2 below) ┌─── REPLACE STATEMENT - FORMAT 2 ─────────────────────────────────────────────┐ │ │ │ >>──REPLACE──OFF──.──>< │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Format 2 ends current text replacement specified by Format 1. REPLACE statements are processed after all COPY statements have been processed. Pseudo-text must not include REPLACE statements. The character-strings and separators comprising pseudo-text can start in either Area A or Area B. However, when there is a hyphen in the indicator area of a line which follows the opening pseudo-text delimiter, Area A of that line must be blank. Related Information:  Replacing Algorithm  Programming Notes ═══ 12.54.1. Replacing Algorithm ═══ For example, assuming three matched pairs of pseudo-text in a REPLACE statement: 1. The comparison starts with the leftmost source program text word following the REPLACE statement, and with the first pseudo-text-1. 2. Pseudo-text-1 is compared to an equivalent number of contiguous source program text words according to the following rules:  The comparison is character for character  Uppercase and lowercase characters are equivalent (except within literals)  Each occurrence of a separator comma, semicolon, and sequence of one or more spaces is treated as a single space  Comment lines and blank lines are ignored for purposes of matching. -----IBM Extension-----  Lines containing EJECT, SKIP 1/2/3, or TITLE statements are ignored for purposes of matching (they are treated as comment lines) ---End of IBM Extension---  Debugging lines are processed for matches, but the D in the indicator area is ignored 3. If no match occurs, the comparison is repeated with each successive occurrence of pseudo-text-1 (in our example, there are three occurrences), until a match is found (go to Step 5) 4. If no match is found after all, the next source program text word is treated as the leftmost program text word, and the cycle begins again at Step 1 5. When a match is found, the corresponding pseudo-text-2 replaces the matched text in the source program 6. The source program text word immediately following the rightmost text word that participated in the match becomes the leftmost source program text word. The cycle starts again (Step 1) with the first occurrence of pseudo-text-1. ═══ 12.54.2. Programming Notes ═══ After all COPY and REPLACE statements are processed, and if the WITH DEBUGGING MODE clause is not specified in the SOURCE-COMPUTER paragraph, a debugging line is considered to have all the characteristics of a comment line When additional lines are introduced in the source program as a result of processing the REPLACE statement, the indicator area of the new lines contains the same character as the line of the text being replaced (unless the line contains a hyphen, in which case the new lines contain a space) If a literal within pseudo-text-2 does not fit in the line containing pseudo-text-1, and the literal is not being placed in a debugging line, additional continuation lines are introduced that contain the remainder of the literal. If pseudo-text-1 is on a debugging line, the program is in error. ═══ 12.55. SKIP1/2/3 Statements ═══ -----IBM Extension----- The SKIP1/2/3 statements specify blank lines that the compiler should add when printing the source listing. SKIP statements have no effect on the compilation of the source program itself. ┌─── SKIP1/2/3 STATEMENTS - FORMAT ────────────────────────────────────────────┐ │ │ │ >>──┬─SKIP1─┬──┬───┬──>< │ │ ├─SKIP2─┤ └─.─┘ │ │ └─SKIP3─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ SKIP1 Specifies a single blank line (double spacing). SKIP2 Specifies two blank lines (triple spacing). SKIP3 Specifies three blank lines (quadruple spacing). SKIP1, SKIP2, or SKIP3 causes one occurrence of double, triple, or quadruple spacing. SKIP1, SKIP2, or SKIP3 may be written anywhere in either Area A or Area B, and may be terminated with a separator period. It must be the only statement on the line. ---End of IBM Extension--- ═══ 12.56. TITLE Statement ═══ -----IBM Extension----- The TITLE statement specifies a title to be printed at the top of each page of the source listing produced during compilation. The title line is printed below the line containing the identification of the compiler and the current release level. The title is left-justified on the title line. ┌─── TITLE STATEMENT - FORMAT ─────────────────────────────────────────────────┐ │ │ │ >>──TITLE──literal──┬───┬──>< │ │ └─.─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The TITLE statement:  Forces a new page immediately  Is not printed on the source listing  Has no other effect on compilation  Has no effect on program execution. A title line is produced for each page in the listing produced by the LIST option. This title line uses the last TITLE statement found in the source statements or the default. The word TITLE may begin in either Area A or Area B. The TITLE statement may not be continued on another line. The TITLE statement may appear anywhere in any of the divisions. No other statement may appear on the same line as the TITLE statement. ---End of IBM Extension--- ═══ 12.57. USE Statement ═══ The USE statement specifies procedures for input/output exception or error handling that are to be executed in addition to the system-defined procedures. Although the USE statement is a compiler-directing statement, it can appear only in the Procedure Division, and it can begin only in Area B. (See Precedence Rules for Nested Programs for information on using the GLOBAL phrase.) The USE statement has two formats:  Format 1 - USE AFTER EXCEPTION/ERROR  Format 2 - USE FOR DEBUGGING ═══ 12.57.1. USE Statement - Format 1 - EXCEPTION/ERROR ═══ The words EXCEPTION and ERROR are synonymous and may be used interchangeably. ┌─── USE STATEMENT - FORMAT ───────────────────────────────────────────────────┐ │ │ │ >>──USE──┬────────┬──AFTER──┬──────────┬──┬─EXCEPTION─┬──PROCEDURE─────────> │ │ └─GLOBAL─┘ └─STANDARD─┘ └─ERROR─────┘ │ │ │ │ ┌─────────────┐ │ │  │ │ │ >──┬────┬──┬───file-name-1─┴─┬──>< │ │ └─ON─┘ ├─INPUT───────────┤ │ │ ├─OUTPUT──────────┤ │ │ ├─I-O─────────────┤ │ │ └─EXTEND──────────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ The EXCEPTION/ERROR procedure is executed:  Either after completing the system-defined input/output error routine, or  Upon recognition of an INVALID KEY or AT END condition when an INVALID KEY or AT END phrase has not been specified in the input/output statement, or  Upon recognition of an IBM-defined condition that causes status key 1 to be set to 9. (See Status Key.) The EXCEPTION/ERROR procedures are activated when an input/output error occurs during execution of a ACQUIRE, DROP, READ, WRITE, REWRITE, START, OPEN, CLOSE, or DELETE statement. To determine what conditions are errors, see Common Processing Facilities. After execution of the EXCEPTION/ERROR Declarative procedure, control is returned to the statement immediately following the input/output statement which caused the error. Within a declarative procedure, there must be no reference to any nondeclarative procedures. In the nondeclarative portion of the program, there must be no reference to procedure-names that appear in an EXCEPTION/ERROR declarative procedure, except that PERFORM statements may refer to an EXCEPTION/ERROR procedure or to procedures associated with it. Within an EXCEPTION/ERROR declarative procedure, no statement should be included that would cause execution of a USE procedure that had been previously invoked and had not yet returned control to the invoking routine. Related Information:  USE Statement Programming Notes ═══ 12.57.2. USE Statement Programming Notes ═══ EXCEPTION/ERROR Declarative procedures can be used to check the status key values whenever an input/output error occurs. Additional information about the file causing the error can be obtained by using data from the mnemonic-names OPEN-FEEDBACK and I-O-FEEDBACK. Care should be used in specifying EXCEPTION/ERROR Declarative procedures for any file. Prior to successful completion of an initial OPEN for any file, the current Declarative has not yet been established by the object program. Therefore, if any other I-O statement is executed for a file that has never been opened, no Declarative can receive control. However, if this file has been previously opened, the last previously established Declarative procedure receives control. For example, an OPEN OUTPUT statement establishes a Declarative procedure for this file, and the file is then closed without error. During later processing, if a logic error occurs, control will go to the Declarative procedure established when the file was opened OUTPUT. Error Handling: If there is an applicable file status clause (but not an applicable USE procedure) when an I-O error occurs, the file status is updated, and control returns to the program. In the absence of a file status clause, USE procedure (implicit or explicit), AT END phrase, or INVALID KEY phrase to handle the error, a run-time message is issued, giving you the option to end or return to the program. ═══ 12.57.3. Precedence Rules for Nested Programs ═══ Special precedence rules are followed when programs are contained within other programs. In applying these rules, only the first qualifying declarative will be selected for execution. The declarative that is selected must satisfy the rules for execution of that declarative. The order of precedence for selecting a declarative is: 1. A file-specific declarative (one of the form USE AFTER ERROR ON file-name-1) within the program that contains the statement that caused the qualifying condition 2. A mode-specific declarative (one of the form USE AFTER ERROR ON INPUT) within the program that contains the statement that caused the qualifying condition 3. A file-specific declarative that specifies the GLOBAL phrase, and is within the program directly containing the program that was last examined for a qualifying condition 4. A mode-specific declarative that specifies the GLOBAL phrase, and is within the program directly containing the program that was last examined for a qualifying condition. 5. Rules 3 and 4 apply recursively back through the parents in the nest of programs. Note: Each declarative procedure runs as a separate invocation from that of other declarative procedures and the nondeclarative part of the same ILE COBOL/400 program. ═══ 12.57.4. USE FOR DEBUGGING ═══ The USE FOR DEBUGGING declarative identifies the items in the source program that are to be monitored by the associated debugging procedure. It establishes a procedure to run when certain errors occur, or when certain items or files change. The USE FOR DEBUGGING declarative is syntax checked and treated as documentation. ┌─── USE FOR DEBUGGING DECLARATIVE - FORMAT ───────────────────────────────────┐ │ │ │ (1) │ │ >>──USE─────┬─────┬──DEBUGGING──┬────┬─────────────────────────────────────> │ │ └─FOR─┘ └─ON─┘ │ │ │ │ ┌────────────────────────────────────────────┐ │ │  │ │ │ >───┬──┬────────────────────────┬─identifier-1─┬┴──>< │ │ │ └─ALL─┬───────────────┬──┘ │ │ │ │ └─REFERENCES OF─┘ │ │ │ ├─file-name-1──────────────────────────────┤ │ │ ├─procedure-name-1─────────────────────────┤ │ │ └─ALL PROCEDURES───────────────────────────┘ │ │ │ │ NOTE: │ │ (1) Syntax-checked only │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Identifier-1 cannot be reference modified. This statement is compiled only when you are in debugging mode. The compiler treats all statements that follow this one as comments until the next valid USE AFTER EXCEPTION/ERROR statement or END DECLARATIVES delimiter is reached. ═══ 12.58. PROCESS Statement ═══ The PROCESS statement is an optional part of the COBOL source program. It lets you specify options that you would normally specify at compilation time. Options specified in the PROCESS statement override the corresponding options specified in the CRTCBLMOD or CRTBNDCBL CL command. The format of the PROCESS statement is as follows: ┌─── PROCESS STATEMENT - FORMAT ───────────────────────────────────────────────┐ │ │ │ ┌──────────┐ │ │  │ │ │ >>──PROCESS────option-1─┴──┬───┬──>< │ │ └─.─┘ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ Related Information:  List of Valid PROCESS Statement Options  PROCESS Statement Rules ═══ 12.58.1. option-1 ═══ Option-1 represents the options available with the PROCESS statement. The list of valid PROCESS statement options are: OUTPUT NODUPKEYCHK NOOUTPUT DUPKEYCHK GENLVL(nn) NOINZDLT SOURCE INZDLT SRC NOBLK NOSOURCE BLK NOSRC STDINZ NOSEQUENCE NOSTDINZ SEQUENCE NODDSFILLER NOVBSUM DSSFILLER VBSUM STDTRUNC NONUMBER NOSTDTRUNC NUMBER CHGPOSSGN LINENUMBER NOCHGPOSSGN NOMAP NOVARCHAR MAP VARCHAR NOOPTIONS NODATETIME OPTIONS DATETIME QUOTE CVTPICXGRAPHIC APOST NOCVTPICXGRAPHIC NOSECLVL NOOPTIMIZE SECLVL BASICOPT PRTCORR FULLOPT NOPRTCORR NOFIPS MONOPRC MINIMUM NOMONOPRC INTERMEDIATE RANGE HIGH NORANGE NOOBSOLETE NOUNREF OBSOLETE UNREF EXTDSPOPT(a b c) NOSYNC FLAG(nn) SYNC LINKPGM NOCRTF LINKPRC CRTF SRTSEQ(a) LANGID(a) NOGRAPHIC GRAPHIC ═══ 12.58.1.1. PROCESS Statement Rules ═══ The following rules apply to the PROCESS statement:  The statement must be placed before the first source statement in the program immediately preceding the IDENTIFICATION DIVISION header.  The statement begins with the word PROCESS. Options can appear on more than one line; however, only the first line can contain the word PROCESS.  The word PROCESS and all options must appear within positions 8 through 72. Position 7 must be left blank. The remaining positions can be used as in COBOL source statements: positions 1 through 6 for sequence numbers, positions 73 through 80 for identification purposes.  The options must be separated by blanks and/or commas.  The options can appear in any order. If conflicting options are specified, for example, LIST and NOLIST, the last option encountered takes precedenc  For any options with suboptions, if the option keyword is correct and the suboption is in error, the default suboption is assumed. ═══ 12.58.1.2. OUTPUT / NOOUTPUT ═══  OUTPUT indicates that a compiler listing is generated. OUTPUT is the default value.  NOOUTPUT indicates that no compiler listing is generated. ═══ 12.58.1.3. GENLVL(nn) ═══ GENLEVL(nn) specifies the severity level that determines if a module or program object is created. The severity level, nn, corresponds to the severity level of the messages produced during compilation. You can specify a one or two-digit number, 0 through 30, which is the severity level you want to use to determine if a module or program object is to be created. No module or program object is created if errors occur with a severity level equal to or greater than this severity level. The default value for GENLVL is 30. GENLVL(0) cancels compile. ═══ 12.58.1.4. GEN / NOGEN ═══  GEN indicates that the compiler creates a module or program object after the COBOL source is compiled. GEN is the default value.  NOGEN indicates that the compiler does not create a module or program object after the COBOL source program is compiled. You might specify this option if you want only error messages and/or listings. ═══ 12.58.1.5. NOMAP / MAP ═══  NOMAP indicates that the compiler does not list the Data Division map. NOMAP is the default value.  MAP indicates that the compiler lists the Data Division map. ═══ 12.58.1.6. NONUMBER / NUMBER / LINENUMBER ═══  NONUMBER indicates that the source-file sequence numbers are used for reference numbers. NONUMBER is the default value.  NUMBER indicates that the user-supplied sequence numbers (columns 1 through 6) are used for reference numbers.  LINENUMBER indicates that the sequence numbers created by the compiler are used for reference numbers. This option combines COBOL program source code and source code introduced by COPY statements into one consecutively numbered sequence. Use this option if you specify FIPS (Federal Information Processing Standards) flagging or SAA flagging. ═══ 12.58.1.7. NOSECLVL / SECLVL ═══  NOSECLVL indicates that second level message text is not listed for this compilation. NOSECLVL is the default value.  SECLVL indicates that second level message text is listed for this compilation, along with the first-level error text. ═══ 12.58.1.8. NOOPTIONS / OPTIONS ═══  NOOPTIONS indicates that options in effect are not listed for this compilation. NOOPTIONS is the default value.  OPTIONS indicates that options in effect are listed for this compilation. ═══ 12.58.1.9. QUOTE / APOST ═══  QUOTE specifies that the delimiter quotation mark (") is used for nonnumeric literals and Boolean literals. This option also specifies that the value of the figurative constant QUOTE has the EBCDIC value of a quotation mark. QUOTE is the default value.  APOST specifies that the delimiter apostrophe (') is used for nonnumeric literals and Boolean literals. This option also specifies that the value of the figurative constant QUOTE has the EBCDIC value of an apostrophe. ═══ 12.58.1.10. NOSEQUENCE / SEQUENCE ═══  NOSEQUENCE indicates that the reference numbers are not checked for sequence errors. NOSEQUENCE is the default value.  SEQUENCE indicates that the reference numbers are checked for sequence errors. Sequence errors do not occur if the LINENUMBER option is specified. ═══ 12.58.1.11. NOVBSUM / VBSUM ═══  NOVBSUM indicates that verb usage counts are not printed. NOVBSUM is the default value.  VBSUM indicates that verb usage counts are printed. ═══ 12.58.1.12. NOXREF / XREF ═══  NOXREF indicates that the compiler does not produce a cross-reference listing for the COBOL source program. NOXREF is the default value.  XREF indicates that the compiler produces a cross-reference listing for the COBOL source program. ═══ 12.58.1.13. PRTCORR / NOPRTCORR ═══  PRTCORR indicates that the compiler inserts comment lines in the compiler listing indicating which elementary items were included as a result of the use of the CORRESPONDING phrase. PRTCORR is the default value.  NOPRTCORR indicates that the compiler does not insert comment lines in the compiler listing when the CORRESPONDING phrase is used. ═══ 12.58.1.14. NOINZDLT / INZDLT ═══  NOINZDLT indicates that relative files with sequential access are not initialized with deleted records during the CLOSE operation if the files have been opened for OUTPUT. The record boundary is determined by the number of records written at OPEN OUTPUT time. Subsequent OPEN operations allow access only up to the record boundary. NOINZDLT is the default value.  INZDLT indicates that relative files with sequential access are initialized with deleted records during the CLOSE operation if the files were opened for OUTPUT. Active records in the files are not affected. The record boundary is defined as the file size for subsequent OPEN operations. ═══ 12.58.1.15. NODDSFILLER / DDSFILLER ═══  NODDSFILLER indicates that if no matching fields are found by a COPY DDS statement, no field descriptions are generated. NODDSFILLER is the default value.  DDSFILLER indicates that if no matching fields are found by a COPY DDS statement, a single character FILLER field description, "07 FILLER PIC X", is always created. ═══ 12.58.1.16. NOSYNC / SYNC ═══  NOSYNC indicates that the SYNCHRONIZED clause is syntax checked only. NOSYNC is the default value.  SYNC indicates that the SYNCHRONIZED clause is compiled by the compiler. The SYNCHRONIZED clause causes the position of a data item to be aligned such that the right-hand (least-significant) end is on the natural storage boundary. Extra storage is reserved adjacent to the synchronized item to achieve this alignment. Each elementary data item that is described as SYNCHRONIZED is aligned to the natural storage boundary that corresponds to its data storage assignment. ═══ 12.58.1.17. NOCRTF / CRTF ═══  NOCRTF indicates that files that are unavailable at the time of an OPEN operation are not created dynamically. NOCRTF is the default value.  CRTF indicates that files that are unavailable at the time of an OPEN operation are created dynamically. Note: The maximum record length for a file that will be created dynamically is 32 766. ═══ 12.58.1.18. NODUPKEYCHK / DUPKEYCHK ═══  NODUPKEYCHK does not check for duplicate primary keys for INDEXED files. NODUPKEYCHK is the default value.  DUPKEYCHK checks for duplicate primary keys for INDEXED files. ═══ 12.58.1.19. NOBLK / BLK ═══  NOBLK indicates that the compiler allows blocking only of SEQUENTIAL access files with no START statement. The BLOCK CONTAINS clause, if specified, is ignored, except for tape files. NOBLK is the default value.  When BLK is used and a BLOCK CONTAINS clause is specified, the compiler allows blocking for DYNAMIC access files and SEQUENTIAL access files with a START statement. Blocking is not allowed for RELATIVE files opened for output operations. The BLOCK CONTAINS clause controls the number of records to be blocked. When BLK is used and no BLOCK CONTAINS clause is specified, the compiler allows blocking only of SEQUENTIAL access files with no START statement. The operating system determines the number of records to be blocked. ═══ 12.58.1.20. STDINZ / NOSTDINZ ═══  STDINZ indicates that for those items with no VALUE clause, the compiler initializes data items to system defaults. STDINZ is the default value.  NOSTDINZ indicates that for those items with no VALUE clause, the compiler does not initialize data items to system defaults. ═══ 12.58.1.21. RANGE / NORANGE ═══  RANGE indicates that at run-time, subscripts are verified that they are within the correct ranges, but index ranges are not verified. Reference modification and compiler-generated substring operations are also checked. RANGE is the default value.  NORANGE indicates that ranges are not verified at run time. Note: The RANGE option generates code for checking subscript ranges. For example, it ensures that you are not attempting to access the 21st element of a 20-element array. The NORANGE option does not generate code to check subscript ranges. ═══ 12.58.1.22. NOUNREF / UNREF ═══  NOUNREF indicates that unreferenced data items are not included in the compiled program. This reduces the amount storage used, allowing a larger program to be compiled. The unreferenced data items still appear in the cross-reference listings produced by specifying the XREF option. NOUNREF is the default value.  UNREF indicates that unreferenced data items are included in the compiled program. ═══ 12.58.1.23. MONOPRC / NOMONOPRC ═══  MONOPRC indicates monocasing of PROGRAM-ID and CALL/CANCEL target. MONOPRC is the default value.  NOMONOPRC indicates no monocasing of PROGRAM-ID and CALL/CANCEL target. This option is most useful when dealing with external calls to case sensitive procedure names (for example: C functions). ═══ 12.58.1.24. NOVARCHAR / VARCHAR ═══  NOVARCHAR indicates that variable-length fields are ignored, and are declared as FILLER fields. NOVARCHAR is the default value.  VARCHAR indicates that variable-length fields are declared as fixed-length group items, and are accessible to the COBOL source program. ═══ 12.58.1.25. NODATETIME / DATETIME ═══  NODATETIME indicates that date, time, and timestamp data types are ignored, and are declared as FILLER fields. NODATETIME is the default value.  DATETIME indicates that date, time, and timestamp data types are declared as fixed-length character fields, and are accessible to the COBOL source program. ═══ 12.58.1.26. NOCVTPICXGRAPHIC / CVTPICXGRAPHIC ═══  NOCVTPICXGRAPHIC indicates that DBCS-graphic data types are ignored, and are declared as FILLER fields. NOCVTPICXGRAPHIC is the default value.  CVTGRAPHIC indicates that fixed-length DBCS-graphic data types are declared as fixed-length alphanumeric fields, and are accessible to the ILE COBOL/400 source program. When the VARCHAR option is also in use, variable-length DBCS-graphic data types are declared as fixed-length group items, and are accessible to the ILE COBOL/400 source program. ═══ 12.58.1.27. NOOPTIMIZE / BASICOPT / FULLOPT ═══  NOOPTIMIZE indicates that no optimization is performed on the compiled module. Compilation time is minimized when this option is used. This option allows variables to be displayed and modified during debugging. NOOPTIMIZE is the default value.  BASICOPT indicates that some optimization (only at the local block level) is performed on the compiled module. This option allows user variables to be displayed but not modified during debugging.  FULLOPT indicates that full optimization (at the global level) is performed on the compiled module. This optimization increases compilation time but also generates the most efficient code. This option allows user variables to be displayed but not modified during debugging. The displayed values of the variables my not be their current values. ═══ 12.58.1.28. NOFIPS / MINIMUM / INTERMEDIATE / HIGH ═══  NOFIPS indicates that the COBOL source program is not FIPS flagged. NOFIPS is the default value.  MINIMUM indicates FIPS flag for minimum subset and higher.  INTERMEDIATE indicates FIPS flag for intermediate subset and higher.  HIGH indicates FIPS flag for high subset. ═══ 12.58.1.29. NOOBSOLETE / OBSOLETE ═══  NOOBSOLETE indicates that obsolete language elements are not flagged. NOOBSOLETE is the default value.  OBSOLETE indicates that obsolete language elements are flagged. ═══ 12.58.1.30. EXTDSPOPT(a b c) ═══ EXTDSPOPT specifies the options to use for extended ACCEPT and extended DISPLAY statements for workstation I/O, and takes the form: EXTDSPOPT(a b c) Where a is DFRWRT or NODFRWRT, b is UNDSPCHR or NOUNDSPCHR, and c is ACCUPDALL or ACCUPDNE.  DFRWRT indicates that extended DISPLAY statements are held in a buffer until an extended ACCEPT statement is encountered, or until the buffer is filled. The contents of the buffer are written to the display when the extended ACCEPT statement is encountered or the buffer is full. DFRWRT is the default value.  NODFRWRT indicates that each extended DISPLAY statement is performed as it is encountered.  UNDSPCHR indicates that displayable and undisplayable characters are handled by extended ACCEPT and extended DISPLAY statements. UNDSPCHR is the default value.  NOUNDSPCHR indicates that only displayable characters are handled by extended ACCEPT and extended DISPLAY statements. Although you must use this option for display stations attached to remote 3174 and 3274 controllers, you can also use it for local work stations. If you do use this option, your data must contain displayable characters. If the data contains values less than hexadecimal 20, the results are not predictable, ranging from unexpected display formats to severe errors.  ACCUPDALL indicates that all types of data are predisplayed in the extended ACCEPT statements regardless of the existence of the UPDATE phrase. ACCUPDALL is the default value.  ACCUPDNE indicates that only numeric edited data are predisplayed in the extended ACCEPT statements that do not contain the UPDATE phrase. ═══ 12.58.1.31. FLAG(nn) ═══ FLAG specifies the minimum severity level of messages that will appear in the compiler listing. You can specify a one or two-digit number, nn, that specifies the minimum severity level of messages that you want to appear in the compiler listing. Messages that have severity levels of this specified value or higher will appear in the compiler listing. The default value for FLAG is 0. FLAG(0) indicates that all messages will appear in the compiler listing. ═══ 12.58.1.32. LINKPGM / LINKPRC ═══  LINKPGM indicates that the linkage type for external CALL/CANCEL 'literal' form target is a program object. LINKPGM is the default value.  LINKPRC indicates that the linkage type for external CALL/CANCEL 'literal' form target is an ILE procedure. Note: You may override this option for specific external CALL/CANCEL 'literal' target lists by specifying the following sentence in the SPECIAL-NAMES paragraph: LINKAGE TYPE IS implementer-name FOR target-list. ═══ 12.58.1.33. SRTSEQ(a) ═══ SRTSEQ specifies the sort sequence used when NLSSORT is associated with an alphabet-name in the ALPHABET clause. The SRTSEQ option is used in conjunction with the LANGID option to determine which system-defined or user-defined sort sequence table the module will use. SRTSEQ takes the form: SRTSEQ(a) Where a is HEX, JOB, JOBRUN, LANGIDUNQ, LANGIDSHR, "table-name", or "library-name/table-name".  HEX indicates that no sort sequence table will be used, and the hexadecimal values of the characters will be used to determine the sort sequence. HEX is the default value.  JOB indicates that the sort sequence of the module will be resolved and associated with the module at compile time. The sort sequence table must exist in the system at compile time.  JOBRUN indicates that the sort sequence of the program will be resolved and associated with the module at run time. At compile time, the compiler will associate the sort sequence of the compile job with the module. At run time, this sort sequence will be replaced by the sort sequence associated with the job at run time. This value allows a module to be compiled once and used with different sort sequences at run time.  LANGIDUNQ indicates that the sort sequence table being used must contain a unique weight for each character in the code page. The sort sequence table used will be the unique weighted table associated with the language specified in the LANGID option.  LANGIDSHR indicates that the sort sequence table being used can contain the same weight for multiple characters in the code page. The sort sequence table used will be the shared weighted table associated with the language specified in the LANGID option.  "table-name" or "library-name/table-name" indicates the name of the sort sequence table to be used. The table contains weights for all characters in a given code page. A weight is associated with the character that is defined at the code point. The library is specified as LIBL, CURLIB, or library-name. - LIBL indicates that the library list is searched to find the library where the source file is located. LIBL is the default value. - CURLIB indicates that the current library is used. If you have not assigned a library as the current library, QTEMP is used. - library-name indicates the name of the library where the sort sequence table is found. ═══ 12.58.1.34. LANGID(a) ═══ LANGID specifies the language identifier which is used in conjunction with the sort sequence. The LANGID option is used only when the SRTSEQ value in effect is LANGIDUNQ or LANGIDSHR. LANGID takes the form: LANGID(a) Where a is JOBRUN, JOB or "language-identifer-name".  JOBRUN indicates that the language identifier of the program will be resolved at run time. When the compiled program is run, the language identifier of the job is used. This value allows a module to be compiled once and used with different language identifiers at run time.  JOB indicates that the language identifier of the module will be resolved at compile time.  "language-identifier-name" is a valid 3 character language identifier. ═══ 12.58.1.35. SOURCE / SRC / NOSOURCE / NOSRC ═══  SOURCE or SRC indicates that the compiler produces a source listing, consisting of the ILE COBOL/400 source program and all compiler-time error messages. SOURCE or SRC is the default value.  NOSOURCE or NOSRC indicates that the compiler does not produce the source part of the listing. If you do not require a source listing, you should use this option because compilation may take less time. ═══ 12.58.1.36. STDTRUNC / NOSTDTRUNC ═══  STDTRUNC applies only to USAGE BINARY data. When STDTRUNC is selected, USAGE BINARY data is truncated to the number of digits in the PICTURE clause of the BINARY receiving field. STDTRUNC is the default value.  NOSTDTRUNC applies only to USAGE BINARY data. When NOSTDTRUNC is selected, BINARY receiving fields are truncated only at half-word, full-word, or double-word boundaries. BINARY sending fields are also handled as half-words, full-words, or double-words. Thus, the full binary content of the field is significant. Also, the DISPLAY statement will convert the entire content of a BINARY field, with no truncation. ═══ 12.58.1.37. NOCHGPOSSGN / CHGPOSSGN ═══  NOCHGPOSSGN indicates that hexadecimal F is used as the default positive sign for zoned and packed numeric data. Hexadecimal F is the system default for the OS/400 operating system. NOCHGPOSSGN is the default value.  CHGPOSSGN indicates that hexadecimal C is used as the default positive sign for zoned and packed numeric data. This applies to all results of the MOVE, ADD, SUBTRACT, MULTIPLY, DIVIDE, COMPUTE, and INITIALIZE statements, as well as the results of the VALUE clause. ═══ 12.58.1.38. NOGRAPHIC / GRAPHIC ═══  NOGRAPHIC indicates that mixed literals will be handled with the assumption that hex 0E and hex 0F are shift-in and shift-out characters respectively, and they enclose the DBCS characters in the mixed literal.  GRAPHIC indicates that non-numeric literals containing hex 0E and hex 0F will be treated as of they only contain SBCS characters. ═══ ADVANCING Menu ═══ Select which occurence of ADVANCING you want to display:  DISPLAY Statement - Format 1 - Data Transfer  DISPLAY Statement - Format 4 - Session I/O  WRITE Statement - Format 1 - Sequential Files ═══ AFTER Menu ═══ Select which occurence of AFTER you want to display:  INSPECT Statement - Format 1 - TALLYING  INSPECT Statement - Format 2 - REPLACING  INSPECT Statement - Format 3 - TALLYING REPLACING  INSPECT Statement - Format 4 - CONVERTING  PERFORM Statement - Format 3 - UNTIL  PERFORM Statement - Format 4 - VARYING  WRITE Statement - Format 1 - Sequential Files  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile) ═══ ALL Menu ═══ Select which occurence of ALL you want to display:  INSPECT Statement - Format 1 - TALLYING  INSPECT Statement - Format 2 - REPLACING  INSPECT Statement - Format 3 - TALLYING REPLACING  Figurative Constant - ALL literal  SEARCH Statement - Format 2 - Binary Search  UNSTRING Statement ═══ ALPHABETIC Menu ═══ Select which occurence of ALPHABETIC you want to display:  Class Condition (identifer IS/IS NOT ALPHABETIC)  INITIALIZE Statement ═══ ALSO Menu ═══ Select which occurence of ALSO you want to display:  ALPHABET Clause  EVALUATE Statement ═══ ARE Menu ═══ Select which occurence of ARE you want to display:  LABEL RECORDS Clause  DATA RECORDS Clause  READ Statement - Format 4 - TRANSACTION (Nonsubfile)  READ Statement - Format 5 - TRANSACTION (Subfile)  WRITE Statement - Format 3 - FORMATEFILE  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile)  WRITE Statement - Format 5 - TRANSACTION (Subfile) ═══ AREA Menu ═══ Select which occurence of AREA you want to display:  RESERVE Clause  SAME AREA Clause  SAME RECORD AREA Clause  SAME SORT AREA Clause  SAME SORT-MERGE AREA Clause ═══ ASCENDING Menu ═══ Select which occurence of ASCENDING you want to display:  OCCURS Clause - Format 1 - Fixed-Length Tables  OCCURS Clause - Format 2 - Variable-Length Tables  MERGE Statement  SORT Statement ═══ AT Menu ═══ Select which occurence of AT you want to display:  LINAGE Clause  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O  READ Statement - Format 1 - Sequential Retrieval/Sequential Access  READ Statement - Format 2 - Sequential Retrieval/Dynamic Access  READ Statement - Format 4 - TRANSACTION (Nonsubfile)  READ Statement - Format 5 - TRANSACTION (Subfile)  SEARCH Statement - Format 1 - Serial Search  SEARCH Statement - Format 2 - Binary Search  WRITE Statement - Format 1 - Sequential Files  WRITE Statement - Format 3 - FORMATEFILE  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile) ═══ BEFORE Menu ═══ Select which occurence of BEFORE you want to display:  INSPECT Statement - Format 1 - TALLYING  INSPECT Statement - Format 2 - REPLACING  INSPECT Statement - Format 3 - TALLYING REPLACING  INSPECT Statement - Format 4 - CONVERTING  PERFORM Statement - Format 3 - UNTIL  PERFORM Statement - Format 4 - VARYING  WRITE Statement - Format 1 - Sequential Files  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile) ═══ BLOCK Menu ═══ Select which occurence of BLOCK you want to display:  BLOCK CONTAINS Clause  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O ═══ BY Menu ═══ Select which occurence of BY you want to display:  OCCURS Clause - Format 1 - Fixed-Length Tables  OCCURS Clause - Format 2 - Variable-Length Tables  CALL Statement - Format 1 - ON OVERFLOW  CALL Statement - Format 2 - ON EXCEPTION  INITIALIZE Statement  INSPECT Statement - Format 2 - REPLACING  INSPECT Statement - Format 3 - TALLYING REPLACING  MULTIPLY Statement - Format 1 - MULTIPY  MULTIPLY Statement - Format 2 - MULTIPLY GIVING  PERFORM Statement - Format 4 - VARYING  SET Statement - Format 2 - UP BY / DOWN BY  STRING Statement  UNSTRING Statement ═══ CHARACTER Menu ═══ Select which occurence of CHARACTER you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  SIGN Clause ═══ CHARACTERS Menu ═══ Select which occurence of CHARACTERS you want to display:  MEMORY SIZE Phrase (OBJECT-COMPUTER Paragraph)  BLOCK CONTAINS Clause  RECORD CONTAINS Clause - Format 1 - Fixed Length Records  RECORD CONTAINS Clause - Format 2 - Fixed or Variable Length Records  RECORD CONTAINS Clause - Format 3 - Variable Length Records  INSPECT Statement - Format 1 - TALLYING  INSPECT Statement - Format 2 - REPLACING  INSPECT Statement - Format 3 - TALLYING REPLACING ═══ COLLATING Menu ═══ Select which occurence of COLLATING you want to display:  PROGRAM COLLATING SEQUENCE Phrase (OBJECT-COMPUTER Paragraph)  MERGE Statement  SORT Statement ═══ COLUMN Menu ═══ Select which occurence of COLUMN you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O ═══ CONTAINS Menu ═══ Select which occurence of CONTAINS you want to display:  MULTIPLE FILE TAPE Clause  BLOCK CONTAINS Clause  RECORD CONTAINS Clause - Format 1 - Fixed Length Records  RECORD CONTAINS Clause - Format 2 - Fixed or Variable Length Records  RECORD CONTAINS Clause - Format 3 - Variable Length Records ═══ DATA Menu ═══ Select which occurence of DATA you want to display:  DATA DIVISION  DATA RECORDS Clause  INITIALIZE Statement  READ Statement - Format 4 - TRANSACTION (Nonsubfile) ═══ DELIMITED Menu ═══ Select which occurence of DELIMITED you want to display:  STRING Statement  UNSTRING Statement ═══ DEPENDING Menu ═══ Select which occurence of DEPENDING you want to display:  RECORD CONTAINS Clause - Format 3 - Variable Length Records  OCCURS Clause - Format 2 - Variable-Length Tables  GO TO Statement - Format 2 - Conditional ═══ DESCENDING Menu ═══ Select which occurence of DESCENDING you want to display:  OCCURS Clause - Format 1 - Fixed-Length Tables  OCCURS Clause - Format 2 - Variable-Length Tables  MERGE Statement  SORT Statement ═══ DISPLAY Menu ═══ Select which occurence of DISPLAY you want to display:  CONSOLE Clause  USAGE Clause  ACCEPT Statement - Format 8 - Session I/O  DISPLAY Statement - Format 1 to Format 4 ═══ DOWN Menu ═══ Select which occurence of DOWN you want to display:  SET Statement - Format 2 - UP BY / DOWN BY  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile) ═══ DUPLICATES Menu ═══ Select which occurence of DUPLICATES you want to display:  RECORD KEY Clause  SORT Statement ═══ END Menu ═══ Select which occurence of END you want to display:  END DECLARATIVES key words (PROCEDURE DIVISION)  READ Statement - Format 1 - Sequential Retrieval/Sequential Access  READ Statement - Format 2 - Sequential Retrieval/Dynamic Access  READ Statement - Format 4 - TRANSACTION (Nonsubfile)  READ Statement - Format 5 - TRANSACTION (Subfile)  RETURN Statement  SEARCH Statement - Format 1 - Serial Search  SEARCH Statement - Format 2 - Binary Search ═══ EQUAL Menu ═══ Select which occurence of EQUAL you want to display:  EQUAL TO Relational Condition Operator  COMPUTE Statement  SEARCH Statement - Format 2 - Binary Search  START Statement ═══ EXCEPTION Menu ═══ Select which occurence of EXCEPTION you want to display:  ACCEPT Statement - Format 5 - PIP Data Area  ACCEPT Statement - Format 7 - Workstation I/O  CALL Statement - Format 2 - ON EXCEPTION ═══ EXIT Menu ═══ Select which occurence of EXIT you want to display:  EXIT Statement  EXIT PROGRAM Statement ═══ EXTERNAL Menu ═══ Select which occurence of EXTERNAL you want to display:  EXTERNAL Clause (File Description Entry)  EXTERNAL Clause (Data Description Entry) ═══ FILE Menu ═══ Select which occurence of FILE you want to display:  FILE STATUS Clause  MULTIPLE FILE TAPE Clause  FILE SECTION ═══ FIRST Menu ═══ Select which occurence of FIRST you want to display:  INSPECT Statement - Format 2 - REPLACING  INSPECT Statement - Format 3 - TALLYING REPLACING  READ Statement - Format 2 - Sequential Retrieval/Dynamic Access ═══ FOR Menu ═══ Select which occurence of FOR you want to display:  LINKAGE TYPE Clause  SAME AREA Clause  SAME RECORD AREA Clause  SAME SORT AREA Clause  SAME SORT-MERGE AREA Clause  COMMITMENT CONTROL Clause  ACCEPT Statement - Format 3 - Feedback  ACCEPT Statement - Format 4 - Local Data Area  ACCEPT Statement - Format 6 - Attribute Data  ACQUIRE Statement  CLOSE Statement - Format 1 - Sequential Files  DISPLAY Statement - Format 2 - Local Data Area  INSPECT Statement - Format 1 - TALLYING  INSPECT Statement - Format 3 - TALLYING REPLACING ═══ FROM Menu ═══ Select which occurence of FROM you want to display:  RECORD CONTAINS Clause - Format 3 - Variable Length Records  INSPECT Statement - Format 3 - TALLYING REPLACING  READ Statement - Format 2 - Sequential Retrieval/Dynamic Access  ACCEPT Statement - Format 1 - Data Transfer  ACCEPT Statement - Format 2 - System Information Transfer  ACCEPT Statement - Format 3 - Feedback  ACCEPT Statement - Format 4 - Local Data Area  ACCEPT Statement - Format 5 - PIP Data Area  ACCEPT Statement - Format 6 - Attribute Data  ACCEPT Statement - Format 7 - Workstation I/O  ACCEPT Statement - Format 8 - Session I/O  DROP Statement  PERFORM Statement - Format 4 - VARYING  RELEASE Statement  WRITE Statement - Format 1 - Sequential Files  WRITE Statement - Format 2 - Indexed and Relative Files  WRITE Statement - Format 3 - FORMATEFILE  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile)  WRITE Statement - Format 5 - TRANSACTION (Subfile) ═══ GIVING Menu ═══ Select which occurence of GIVING you want to display:  GIVING Phrase (arithmetic operations)  MERGE Statement  SORT Statement ═══ GLOBAL Menu ═══ Select which occurence of GLOBAL you want to display:  GLOBAL Clause (File Description Entry)  GLOBAL Clause (Data Description Entry) ═══ GREATER Menu ═══ Select which occurence of GREATER you want to display:  GREATER THAN Relational Condition Operator  START Statement ═══ IN Menu ═══ Select which occurence of IN you want to display:  RECORD CONTAINS Clause - Format 3 - Variable Length Records  SORT Statement  UNSTRING Statement ═══ INDEXED Menu ═══ Select which occurence of INDEXED you want to display:  ORGANIZATION Clause - Format 2 - Indexed Files  OCCURS Clause - Format 1 - Fixed-Length Tables  OCCURS Clause - Format 2 - Variable-Length Tables ═══ INITIAL Menu ═══ Select which occurence of INITIAL you want to display:  IDENTIFICATION DIVISION  INSPECT Statement - Format 1 - TALLYING  INSPECT Statement - Format 2 - REPLACING  INSPECT Statement - Format 3 - TALLYING REPLACING  INSPECT Statement - Format 4 - CONVERTING ═══ INPUT Menu ═══ Select which occurence of INPUT you want to display:  OPEN Statement - Format 1 - Sequential Files  OPEN Statement - Format 2 - Indexed and Relative Files  SORT Statement ═══ INTO Menu ═══ Select which occurence of INTO you want to display:  DIVIDE Statement - Format 1 - DIVIDE INTO  DIVIDE Statement - Format 2 - DIVIDE INTO GIVING  DIVIDE Statement - Format 4 - DIVIDE INTO GIVING REMAINDER  READ Statement - Format 1 - Sequential Retrieval/Sequential Access  READ Statement - Format 2 - Sequential Retrieval/Dynamic Access  READ Statement - Format 3 - Random Retrieval  READ Statement - Format 4 - TRANSACTION (Nonsubfile)  READ Statement - Format 5 - TRANSACTION (Subfile)  RETURN Statement  STRING Statement  UNSTRING Statement ═══ INVALID Menu ═══ Select which occurence of INVALID you want to display:  DELETE Statement  READ Statement - Format 3 - Random Retrieval  READ Statement - Format 5 - TRANSACTION (Subfile)  REWRITE Statement - Format 1  REWRITE Statement - Format 2 - TRANSACTION (Subfile)  START Statement  WRITE Statement - Format 2 - Indexed and Relative Files  WRITE Statement - Format 5 - TRANSACTION (Subfile) ═══ IS Menu ═══ Select which occurence of IS you want to display:  IDENTIFICATION DIVISION  PROGRAM COLLATING SEQUENCE Phrase (OBJECT-COMPUTER Paragraph)  SEGMENT-LIMIT Phrase (OBJECT-COMPUTER Paragraph)  SPECIAL-NAMES Paragraph  ALPHABET Clause  CLASS Clause  CURRENCY SIGN Clause  DECIMAL POINT IS COMMA Clause  CONSOLE Clause  CURSOR Clause  CRT STATUS Clause  LINKAGE TYPE Clause  ORGANIZATION Clause - Format 1 - Sequential Files  ORGANIZATION Clause - Format 2 - Indexed Files  ORGANIZATION Clause - Format 3 - Relative Files  ORGANISATION Clause - Format 5 - TRANSACTION  ACCESS MODE Clause - Format 1 - Sequential Files  ACCESS MODE Clause - Format 2 - Indexed Files  ACCESS MODE Clause - Format 3 - Relative Files  ACCESS MODE Clause - Format 5 - TRANSACTION  RECORD KEY Clause  RELATIVE KEY Clause  FILE STATUS Clause  CONTROL-AREA Clause  EXTERNAL Clause (File Description Entry)  GLOBAL Clause (File Description Entry)  RECORD CONTAINS Clause - Format 3 - Variable Length Records  LABEL RECORDS Clause  VALUE OF Clause  DATA RECORDS Clause  LINAGE Clause  CODE-SET Clause  EXTERNAL Clause (Data Description Entry)  GLOBAL Clause (Data Description Entry)  OCCURS Clause - Format 1 - Fixed-Length Tables  OCCURS Clause - Format 2 - Variable-Length Tables  PICTURE Clause  SIGN Clause  USAGE Clause  VALUE Clause  Class Condition Operator  Relation Condition Operator  Sign Condition Operator  ACCEPT Statement - Format 7 - Workstation I/O  CALL Statement - Format 1 - ON OVERFLOW  CALL Statement - Format 2 - ON EXCEPTION  CANCEL Statement  DELETE Statement  DISPLAY Statement - Format 3 - Workstation I/O  MERGE Statement  READ Statement - Format 1 - Sequential Retrieval/Sequential Access  READ Statement - Format 2 - Sequential Retrieval/Dynamic Access  READ Statement - Format 3 - Random Retrieval  READ Statement - Format 4 - TRANSACTION (Nonsubfile)  READ Statement - Format 5 - TRANSACTION (Subfile)  REWRITE Statement - Format 1  REWRITE Statement - Format 2 - TRANSACTION (Subfile)  SEARCH Statement - Format 2 - Binary Search  SORT Statement  START Statement  WRITE Statement - Format 2 - Indexed and Relative Files  WRITE Statement - Format 3 - FORMATEFILE  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile)  WRITE Statement - Format 5 - TRANSACTION (Subfile) ═══ KEY Menu ═══ Select which occurence of KEY you want to display:  RECORD KEY Clause  RELATIVE KEY Clause  OCCURS Clause - Format 1 - Fixed-Length Tables  OCCURS Clause - Format 2 - Variable-Length Tables  DELETE Statement  MERGE Statement  READ Statement - Format 3 - Random Retrieval  READ Statement - Format 5 - TRANSACTION (Subfile)  REWRITE Statement - Format 1  REWRITE Statement - Format 2 - TRANSACTION (Subfile)  SEARCH Statement - Format 2 - Binary Search  SORT Statement  START Statement  WRITE Statement - Format 2 - Indexed and Relative Files  WRITE Statement - Format 5 - TRANSACTION (Subfile) ═══ LEADING Menu ═══ Select which occurence of LEADING you want to display:  SIGN Clause  INSPECT Statement - Format 1 - TALLYING  INSPECT Statement - Format 2 - REPLACING  INSPECT Statement - Format 3 - TALLYING REPLACING ═══ LESS Menu ═══ Select which occurence of LESS you want to display:  LESS THAN Relational Condition Operator  START Statement ═══ LINE Menu ═══ Select which occurence of LINE you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O  WRITE Statement - Format 1 - Sequential Files  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile) ═══ LINES Menu ═══ Select which occurence of LINES you want to display:  LINAGE Clause  WRITE Statement - Format 1 - Sequential Files  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile) ═══ LINKAGE Menu ═══ Select which occurence of LINKAGE you want to display:  LINKAGE TYPE Clause  LINKAGE SECTION  CALL Statement - Format 1 - ON OVERFLOW  CALL Statement - Format 2 - ON EXCEPTION  CANCEL Statement ═══ LOCK Menu ═══ Select which occurence of LOCK you want to display:  CLOSE Statement - Format 1  CLOSE Statement - Format 2 - Tape Files  READ Statement - Format 1 - Sequential Retrieval/Sequential Access  READ Statement - Format 2 - Sequential Retrieval/Dynamic Access  READ Statement - Format 3 - Random Retrieval ═══ MODE Menu ═══ Select which occurence of MODE you want to display:  WITH DEBUGGING MODE Phrase (SOURCE-COMPUTER Paragraph)  ACCESS MODE Clause - Format 1 - Sequential Files  ACCESS MODE Clause - Format 2 - Indexed Files  ACCESS MODE Clause - Format 3 - Relative Files  ACCESS MODE Clause - Format 5 - TRANSACTION  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O ═══ NEXT Menu ═══ Select which occurence of NEXT you want to display:  IF Statement  DISPLAY Statement - Format 3 - Workstation I/O  READ Statement - Format 1 - Sequential Retrieval/Sequential Access  READ Statement - Format 2 - Sequential Retrieval/Dynamic Access  SEARCH Statement - Format 1 - Serial Search  SEARCH Statement - Format 2 - Binary Search ═══ NO Menu ═══ Select which occurence of NO you want to display:  CLOSE Statement - Format 1 - Sequential Files  DISPLAY Statement - Format 1 - Data Transfer  DISPLAY Statement - Format 4 - Session I/O  OPEN Statement - Format 1 - Sequential Files  READ Statement - Format 1 - Sequential Retrieval/Sequential Access  READ Statement - Format 2 - Sequential Retrieval/Dynamic Access  READ Statement - Format 3 - Random Retrieval ═══ NOT Menu ═══ Select which occurence of NOT you want to display:  Class Condition Operator  Relation Condition Operator  Sign Condition Operator  Complex Condition Operator  SIZE ERROR Phrases  ACCEPT Statement - Format 5 - PIP Data Area  ACCEPT Statement - Format 7 - Workstation I/O  CALL Statement - Format 2 - ON EXCEPTION  DELETE Statement  EVALUATE Statement  READ Statement - Format 1 - Sequential Retrieval/Sequential Access  READ Statement - Format 2 - Sequential Retrieval/Dynamic Access  READ Statement - Format 3 - Random Retrieval  READ Statement - Format 4 - TRANSACTION (Nonsubfile)  READ Statement - Format 5 - TRANSACTION (Subfile)  RETURN Statement  REWRITE Statement - Format 1  REWRITE Statement - Format 2 - TRANSACTION (Subfile)  START Statement  STRING Statement  UNSTRING Statement  SUBTRACT Statement - Format 1  SUBTRACT Statement - Format 2 - GIVING  SUBTRACT Statement - Format 3 - CORRESPONDING  WRITE Statement - Format 1 - Sequential Files  WRITE Statement - Format 2 - Indexed and Relative Files  WRITE Statement - Format 3 - FORMATEFILE  WRITE Statement - Format 5 - TRANSACTION (Subfile) ═══ NUMBER Menu ═══ Select which occurence of NUMBER you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O ═══ NUMERIC Menu ═══ Select which occurence of NUMERIC you want to display:  Class Condition (identifer IS/IS NOT NUMERIC)  INITIALIZE Statement ═══ OF Menu ═══ Select which occurence of OF you want to display:  RERUN Clause  ADDRESS OF Statement  ADDRESS OF Special Register  VALUE OF Clause  LENGTH OF Special Register  SET Statement - Format 5 - Pointer Data Item  SET Statement - Format 6 - Procedure-pointer Data Item ═══ OFF Menu ═══ Select which occurence of OFF you want to display:  SPECIAL-NAMES Paragraph  SET Statement - Format 3 - ON / OFF Phrase ═══ OMITTED Menu ═══ Select which occurence of OMITTED you want to display:  LABEL RECORDS Clause  CALL Statement - Format 1 - ON OVERFLOW  CALL Statement - Format 2 - ON EXCEPTION ═══ ON Menu ═══ Select which occurence of ON you want to display:  SPECIAL-NAMES Paragraph  RERUN Clause  RECORD CONTAINS Clause - Format 3 - Variable Length Records  OCCURS Clause - Format 2 - Variable-Length Tables  SIZE ERROR Phrases  ACCEPT Statement - Format 5 - PIP Data Area  ACCEPT Statement - Format 7 - Workstation I/O  CALL Statement - Format 1 - ON OVERFLOW  CALL Statement - Format 2 - ON EXCEPTION  GO TO Statement - Format 2 - Conditional  MERGE Statement  SET Statement - Format 3 - ON / OFF Phrase  SORT Statement  STRING Statement  SUBTRACT Statement - Format 1  SUBTRACT Statement - Format 2 - GIVING  SUBTRACT Statement - Format 3 - CORRESPONDING  UNSTRING Statement ═══ OR Menu ═══ Select which occurence of OR you want to display:  Relation Condition Operator  Complex Condition Operator  START Statement  UNSTRING Statement ═══ OUTPUT Menu ═══ Select which occurence of OUTPUT you want to display:  MERGE Statement  OPEN Statement - Format 1 - Sequential Files  OPEN Statement - Format 2 - Indexed and Relative Files  SORT Statement ═══ OVERFLOW Menu ═══ Select which occurence of OVERFLOW you want to display:  CALL Statement - Format 1 - ON OVERFLOW  STRING Statement  UNSTRING Statement ═══ POINTER Menu ═══ Select which occurence of POINTER you want to display:  USAGE Clause  STRING Statement  UNSTRING Statement ═══ PROCEDURE Menu ═══ Select which occurence of PROCEDURE you want to display:  LINKAGE TYPE Clause  CALL Statement - Format 1 - ON OVERFLOW  CALL Statement - Format 2 - ON EXCEPTION  CANCEL Statement  MERGE Statement  SORT Statement ═══ PROGRAM Menu ═══ Select which occurence of PROGRAM you want to display:  IDENTIFICATION DIVISION  PROGRAM COLLATING SEQUENCE Phrase (OBJECT-COMPUTER Paragraph)  LINKAGE TYPE Clause  CALL Statement - Format 1 - ON OVERFLOW  CALL Statement - Format 2 - ON EXCEPTION  CANCEL Statement  EXIT PROGRAM Statement ═══ RECORD Menu ═══ Select which occurence of RECORD you want to display:  RECORD KEY Clause  SAME RECORD AREA Clause  RECORD CONTAINS Clause - Format 1 - Fixed Length Records  RECORD CONTAINS Clause - Format 2 - Fixed or Variable Length Records  RECORD CONTAINS Clause - Format 3 - Variable Length Records  LABEL RECORDS Clause  DATA RECORDS Clause  DELETE Statement  READ Statement - Format 1 - Sequential Retrieval/Sequential Access  READ Statement - Format 2 - Sequential Retrieval/Dynamic Access  READ Statement - Format 3 - Random Retrieval  READ Statement - Format 4 - TRANSACTION (Nonsubfile)  READ Statement - Format 5 - TRANSACTION (Subfile)  RETURN Statement ═══ RECORDS Menu ═══ Select which occurence of RECORDS you want to display:  RERUN Clause  BLOCK CONTAINS Clause  LABEL RECORDS Clause  DATA RECORDS Clause ═══ RELATIVE Menu ═══ Select which occurence of RELATIVE you want to display:  ORGANIZATION Clause - Format 3 - Relative Files  RELATIVE KEY Clause ═══ REPLACING Menu ═══ Select which occurence of REPLACING you want to display:  INITIALIZE Statement  INSPECT Statement - Format 2 - REPLACING  INSPECT Statement - Format 3 - TALLYING REPLACING ═══ REWIND Menu ═══ Select which occurence of REWIND you want to display:  CLOSE Statement - Format 1 - Sequential Files  OPEN Statement - Format 1 - Sequential Files ═══ RIGHT Menu ═══ Select which occurence of RIGHT you want to display:  JUSTIFIED Clause  SYNCHRONIZED Clause ═══ SAME Menu ═══ Select which occurence of SAME you want to display:  SAME AREA Clause  SAME RECORD AREA Clause  SAME SORT AREA Clause  SAME SORT-MERGE AREA Clause ═══ SECTION Menu ═══ Select which occurence of SECTION you want to display:  FILE SECTION  LINKAGE SECTION  WORKING-STORAGE SECTION ═══ SEQUENCE Menu ═══ Select which occurence of SEQUENCE you want to display:  PROGRAM COLLATING SEQUENCE Phrase (OBJECT-COMPUTER Paragraph)  MERGE Statement  SORT Statement ═══ SEQUENTIAL Menu ═══ Select which occurence of SEQUENTIAL you want to display:  ORGANIZATION Clause - Format 1 - Sequential Files  ACCESS MODE Clause - Format 1 - Sequential Files ═══ SIGN Menu ═══ Select which occurence of SIGN you want to display:  CURRENCY SIGN Clause  SIGN Clause ═══ SIZE Menu ═══ Select which occurence of SIZE you want to display:  MEMORY SIZE Phrase (OBJECT-COMPUTER Paragraph)  RECORD CONTAINS Clause - Format 3 - Variable Length Records  SIZE ERROR Phrases  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O  STRING Statement  SUBTRACT Statement - Format 1  SUBTRACT Statement - Format 2 - GIVING  SUBTRACT Statement - Format 3 - CORRESPONDING ═══ SORT Menu ═══ Select which occurence of SORT you want to display:  SAME SORT AREA Clause  SORT Statement ═══ STATUS Menu ═══ Select which occurence of STATUS you want to display:  SPECIAL-NAMES Paragraph  CRT STATUS Clause  FILE STATUS Clause ═══ TALLYING Menu ═══ Select which occurence of TALLYING you want to display:  INSPECT Statement - Format 1 - TALLYING  INSPECT Statement - Format 3 - TALLYING REPLACING  UNSTRING Statement ═══ TERMINAL Menu ═══ Select which occurence of TERMINAL you want to display:  READ Statement - Format 4 - TRANSACTION (Nonsubfile)  READ Statement - Format 5 - TRANSACTION (Subfile)  REWRITE Statement - Format 2 - TRANSACTION (Subfile)  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile)  WRITE Statement - Format 5 - TRANSACTION (Subfile) ═══ THAN Menu ═══ Select which occurence of THAN you want to display:  Relation Condition Operator  START Statement ═══ THROUGH Menu ═══ Select which occurence of THROUGH you want to display:  ALPHABET Clause  CLASS Clause  RENAMES Clause  VALUE Clause  EVALUATE Statement  PERFORM Statement - Format 1  PERFORM Statement - Format 2 - TIMES  PERFORM Statement - Format 3 - UNTIL  PERFORM Statement - Format 4 - VARYING  SORT Statement  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile) ═══ THRU Menu ═══ Select which occurence of THRU you want to display:  ALPHABET Clause  CLASS Clause  RENAMES Clause  VALUE Clause  EVALUATE Statement  PERFORM Statement - Format 1  PERFORM Statement - Format 2 - TIMES  PERFORM Statement - Format 3 - UNTIL  PERFORM Statement - Format 4 - VARYING  SORT Statement  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile) ═══ TIMES Menu ═══ Select which occurence of TIMES you want to display:  OCCURS Clause - Format 1 - Fixed-Length Tables  OCCURS Clause - Format 2 - Variable-Length Tables  PERFORM Statement - Format 2 - TIMES ═══ TO Menu ═══ Select which occurence of TO you want to display:  ASSIGN Clause  BLOCK CONTAINS Clause  RECORD CONTAINS Clause - Format 2 - Fixed or Variable Length Records  RECORD CONTAINS Clause - Format 3 - Variable Length Records  EQUAL TO Relational Condition Operator  ADD Statement - Format 1  ADD Statement - Format 2 - GIVING  ADD Statement - Format 3 - CORRESPONDING  ALTER Statement  GO TO Statement - Format 1 - Unconditional  GO TO Statement - Format 2 - Conditional  GO TO Statement - Format 3 - Altered  MOVE Statement - Format 1  MOVE Statement - Format 2 - CORRESPONDING  SEARCH Statement - Format 2 - Binary Search  SET Statement - Format 1 - TO Phrase  SET Statement - Format 3 - ON / OFF Phrase  SET Statement - Format 4 - TRUE Phrase  SET Statement - Format 5 - Pointer Data Item  SET Statement - Format 6 - Procedure-pointer  START Statement ═══ TRUE Menu ═══ Select which occurence of TRUE you want to display:  EVALUATE Statement  SET Statement - Format 4 - TRUE Phrase ═══ TYPE Menu ═══ Select which occurence of TYPE you want to display:  LINKAGE TYPE Clause  CALL Statement - Format 1 - ON OVERFLOW  CALL Statement - Format 2 - ON EXCEPTION  CANCEL Statement ═══ UP Menu ═══ Select which occurence of UP you want to display:  SET Statement - Format 2 - UP BY / DOWN BY  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile) ═══ USING Menu ═══ Select which occurence of USING you want to display:  VALUE Clause  USING Phrase (PROCEDURE DIVISION)  CALL Statement - Format 1 - ON OVERFLOW  CALL Statement - Format 2 - ON EXCEPTION  MERGE Statement  SORT Statement ═══ VALUE Menu ═══ Select which occurence of VALUE you want to display:  VALUE OF Clause  VALUE Clause ═══ VARYING Menu ═══ Select which occurence of VARYING you want to display:  RECORD CONTAINS Clause - Format 3 - Variable Length Records  PERFORM Statement - Format 4 - VARYING  SEARCH Statement - Format 1 - Serial Search ═══ WHEN Menu ═══ Select which occurence of WHEN you want to display:  BLANK WHEN ZERO Clause  EVALUATE Statement  SEARCH Statement - Format 1 - Serial Search  SEARCH Statement - Format 2 - Binary Search ═══ WITH Menu ═══ Select which occurence of WITH you want to display:  WITH DEBUGGING MODE Phrase (SOURCE-COMPUTER Paragraph)  RECORD KEY Clause  ACCEPT Statement - Format 7 - Workstation I/O  CLOSE Statement - Format 1  CLOSE Statement - Format 2 - Tape Files  DISPLAY Statement - Format 3 - Workstation I/O  OPEN Statement - Format 1 - Sequential Files  PERFORM Statement - Format 3 - UNTIL  PERFORM Statement - Format 4 - VARYING  READ Statement - Format 1 - Sequential Retrieval/Sequential Access  READ Statement - Format 2 - Sequential Retrieval/Dynamic Access  READ Statement - Format 3 - Random Retrieval  SORT Statement  STRING Statement  UNSTRING Statement ═══ ZERO Menu ═══ Select which occurence of ZERO you want to display:  BLANK WHEN ZERO Clause  Sign Condition Operator ═══ > (GREATER THAN) Menu ═══ Select which occurence of > (GREATER THAN) you want to display:  > (GREATER THAN) Relational Condition Operator  START Statement ═══ < (LESS THAN) Menu ═══ Select which occurence of < (LESS THAN) you want to display:  < (LESS THAN) Relational Condition Operator  START Statement ═══ = (EQUAL TO) Menu ═══ Select which occurence of = (EQUAL TO) you want to display:  EQUAL TO Relational Condition Operator  COMPUTE Statement  SEARCH Statement - Format 2 - Binary Search  START Statement ═══ ADDRESS Menu ═══ Select which occurence of ADDRESS you want to display:  ADDRESS OF Statement  ADDRESS OF Special Register  SET Statement - Format 5 - Pointer Data Item ═══ EXTERNALY-DESCRIBED-KEY Menu ═══ Select which occurence of EXTERNALLY-DESCRIBED-KEY you want to display:  RECORD KEY Clause ═══ FORMAT Menu ═══ Select which occurence of FORMAT you want to display:  DELETE Statement  READ Statement - Format 1 - Sequential Retrieval/Sequential Access  READ Statement - Format 2 - Sequential Retrieval/Dynamic Access  READ Statement - Format 3 - Random Retrieval  READ Statement - Format 4 - TRANSACTION (Nonsubfile)  READ Statement - Format 5 - TRANSACTION (Subfile)  REWRITE Statement - Format 1  REWRITE Statement - Format 2 - TRANSACTION (Subfile)  WRITE Statement - Format 2 - Indexed and Relative Files  WRITE Statement - Format 3 - FORMATEFILE  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile)  WRITE Statement - Format 5 - TRANSACTION (Subfile) ═══ INDIC Menu ═══ Select which occurence of INDIC you want to display:  READ Statement - Format 4 - TRANSACTION (Nonsubfile)  READ Statement - Format 5 - TRANSACTION (Subfile)  REWRITE Statement - Format 2 - TRANSACTION (Subfile)  WRITE Statement - Format 3 - FORMATEFILE  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile)  WRITE Statement - Format 5 - TRANSACTION (Subfile) ═══ INDICATOR Menu ═══ Select which occurence of INDICATOR you want to display:  READ Statement - Format 4 - TRANSACTION (Nonsubfile)  READ Statement - Format 5 - TRANSACTION (Subfile)  REWRITE Statement - Format 2 - TRANSACTION (Subfile)  WRITE Statement - Format 3 - FORMATEFILE  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile)  WRITE Statement - Format 5 - TRANSACTION (Subfile) ═══ INDICATORS Menu ═══ Select which occurence of INDICATORS you want to display:  READ Statement - Format 4 - TRANSACTION (Nonsubfile)  READ Statement - Format 5 - TRANSACTION (Subfile)  REWRITE Statement - Format 2 - TRANSACTION (Subfile)  WRITE Statement - Format 3 - FORMATEFILE  WRITE Statement - Format 4 - TRANSACTION (Nonsubfile)  WRITE Statement - Format 5 - TRANSACTION (Subfile) ═══ NULL Menu ═══ Select which occurence of NULL you want to display:  VALUE Clause  Figurative Constant - NULL  SET Statement - Format 5 - Pointer Data Item  SET Statement - Format 6 - Procedure-pointer ═══ NULLS Menu ═══ Select which occurence of NULLS you want to display:  VALUE Clause  Figurative Constant - NULLS  SET Statement - Format 5 - Pointer Data Item  SET Statement - Format 6 - Procedure-pointer ═══ SUBFILE Menu ═══ Select which occurence of NULLS you want to display:  READ Statement - Format 5 - TRANSACTION (Subfile)  REWRITE Statement - Format 2 - TRANSACTION (Subfile)  WRITE Statement - Format 5 - TRANSACTION (Subfile) ═══ BACKGROUND-COLOR Menu ═══ Select which occurence of BACKGROUND-COLOR you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O ═══ BACKGROUND-COLOUR Menu ═══ Select which occurence of BACKGROUND-COLOUR you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O ═══ BEEP Menu ═══ Select which occurence of BEEP you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O ═══ BELL Menu ═══ Select which occurence of BELL you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O ═══ BLINK Menu ═══ Select which occurence of BLINK you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O ═══ COL Menu ═══ Select which occurence of COL you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O ═══ CRT Menu ═══ Select which occurence of CRT you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O  CONSOLE Clause  CRT STATUS Clause ═══ FOREGROUND-COLOR Menu ═══ Select which occurence of FOREGROUND-COLOR you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O ═══ FOREGROUND-COLOUR Menu ═══ Select which occurence of FOREGROUND-COLOUR you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O ═══ HIGHLIGHT Menu ═══ Select which occurence of HIGHLIGHT you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O ═══ REVERSE-VIDEO Menu ═══ Select which occurence of REVERSE-VIDEO you want to display:  ACCEPT Statement - Format 7 - Workstation I/O  DISPLAY Statement - Format 3 - Workstation I/O ═══ ═══ Represents one of the following, depending on the context:  The numeric value zero (0)  One or more occurrences of the nonnumeric character zero (0) -----IBM Extension-----  The Boolean value B"0" ---End of IBM Extension--- ═══ ═══ Represents one or more blanks or spaces; treated as a nonnumeric literal. ═══ ═══ Represents one or more occurrences of the character that has the highest ordinal position in the collating sequence used. For the NATIVE and EBCDIC collating sequences, the character is X'FF'; for the STANDARD-1 and STANDARD-2 collating sequences, the character is X'07'; for other collating sequences, the actual character used depends on the collating sequence. HIGH-VALUE is treated as a nonnumeric literal. ═══ ═══ Represents one or more occurrences of the character that has the lowest ordinal position in the collating sequence used. For the NATIVE, EBCDIC, STANDARD-1, and STANDARD-2 collating sequences, the character is X'00'; for other collating sequences, the actual character used depends on the collating sequence. LOW-VALUE is treated as a nonnumeric literal. ═══ ═══ Represents one or more occurrences of the quotation mark character and must be nonnumeric. QUOTE, or QUOTES cannot be used in place of a quotation mark or an apostrophe to enclose a nonnumeric literal. -----IBM Extension----- When APOST is specified as a compiler option, the figurative constant QUOTE has the EBCDIC value of an apostrophe. ---End of IBM Extension--- ═══ ═══ Represents one or more occurrences of the string of characters comprising the literal. The literal must be a nonnumeric literal or a figurative constant other than the ALL literal. When a figurative constant other than ALL literal is used, the word ALL is redundant and is used for readability only. The figurative constant ALL literal must not be used with the INSPECT, STOP, or STRING statements. Note: The figurative constant ALL literal, when associated with a numeric or numeric-edited item and when the length of the literal is greater than one, is an obsolete element and is to be deleted from the next revision of the ANSI Standard. -----IBM Extension----- The literal used in an ALL literal can be a Boolean literal.. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Represents a value used to indicate that a data item defined with the USAGE IS POINTER clause, USAGE IS PROCEDURE-POINTER clause, ADDRESS OF phrase, or ADDRESS OF special register does not contain a valid address. NULL can be used only where explicitly allowed in the syntax format. In the ILE COBOL/400 language, a value of NULL is undefined. ---End of IBM Extension--- ═══ ═══ This register is syntax checked only. ═══ ═══ The opening delimiter for hexadecimal notation of a nonnumeric literal. (If the compiler option *APOST or the PROCESS statement option APOST is specified, the opening delimiter is X'.) ═══ ═══ The closing delimiter for hexadecimal notation of a nonnumeric literal. (If the compiler option *APOST or the PROCESS statement option APOST is specified, the closing delimiter is '.) ═══ ═══ Hexadecimal digits are characters that range from 0 to 9, a to f, and A to F, inclusive. Two hexadecimal digits represent a single character, so an even number of hexadecimal digits must be specified in each case. ═══ ═══ A space can immediately precede or follow any separator except:  The opening pseudo-text delimiter (where the preceding space is required).  Within quotation marks (or apostrophes if the APOST option is in effect). Spaces between quotation marks are considered part of the nonnumeric literal; they are not considered separators. ═══ ═══ A separator period, comma, or semicolon is composed of a period, comma, or semicolon followed by a space. The separator period must be used only to indicate the end of a sentence, or as shown in formats. The separator comma and separator semicolon may be used anywhere the separator space is used.  In the Identification Division, separator commas and separator semicolons can be used in the comment-entries. Each paragraph must end with a separator period.  In the Environment Division, separator commas or separator semicolons may separate clauses and operands within clauses. The SOURCE-COMPUTER, OBJECT-COMPUTER, SPECIAL-NAMES, and I-O-CONTROL paragraphs must each end with a separator period. In the FILE-CONTROL paragraph, each File-Control entry must end with a separator period.  In the Data Division, separator commas or separator semicolons may separate clauses and operands within clauses. File (FD), Sort/Merge file (SD), and data description entries must each end with a separator period.  In the Procedure Division, separator commas or separator semicolons may separate statements within a sentence, and operands within a statement. Each sentence and each procedure must end with a separator period. ═══ ═══ Except in pseudo-text, they must appear as balanced pairs of left and right parentheses. They delimit subscripts, reference modification, arithmetic expressions, and conditions. ═══ ═══ An opening quotation mark must be immediately preceded by a space or a left parenthesis. A closing quotation mark must be immediately followed by a separator (space, comma, semicolon, period, or right parenthesis). Quotation marks must appear as balanced pairs. They delimit nonnumeric literals, except when the literal is continued (see Continuation Lines). -----IBM Extension----- Under the *APOST compiler option, or the APOST PROCESS option, an apostrophe can be used in place of a quotation mark. ---End of IBM Extension--- ═══ ═══ An opening pseudo-text delimiter must be immediately preceded by a space. A closing pseudo-text delimiter must be immediately followed by a separator (space, comma, semicolon, or period). Pseudo-text delimiters must appear as balanced pairs. They delimit pseudo-text. (See COPY Statement.) ═══ ═══ The colon is a separator, and is required when shown in general formats. ═══ ═══ -----IBM Extension----- B" is a separator when used to describe a Boolean literal. The B must immediately precede the quotation mark. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- X" is a separator when used to describe a hexadecimal nonnumeric literal. The X must immediately precede the quotation mark. ---End of IBM Extension--- ═══ ═══ An entry is a series of clauses ending with a separator period. ═══ ═══ A clause is an ordered set of consecutive COBOL character-strings that specifies an attribute of an entry. ═══ ═══ A sentence is a sequence of one or more statements, ending with a separator period. ═══ ═══ A statement is a valid combination of a COBOL verb and its operands. It specifies an action to be taken by the object program. For descriptions of the different types of statements, see:  Imperative Statements  Conditional Statements  Delimited Scope Statements  Compiler-Directing Statements. ═══ ═══ Each clause or statement in the program can be subdivided into smaller units called phrases. ═══ ═══ Can be a record-name. ═══ ═══ Must be identified by an FD or SD entry in the Data Division. File-name-1 must be uniquely identifiable. ═══ ═══ Must be qualified each time it is referenced if more than one file description entry containing a LINAGE clause has been specified in the source program. ═══ ═══ Must be identified by an FD entry in the Data Division. File-name-2 must be unique within this program. ═══ ═══ Can be defined in the Data Division or in the SPECIAL-NAMES paragraph within the Configuration Section of the Environment Division. If condition-name is defined in the Configuration Section, it can be referred to in the program containing the Configuration Section or in a nested program. If the condition-name is defined in the Data Division, it can be referenced according to the scoping rules for global and local names (see Global and Local Names). If explicitly referenced, a condition-name must be unique or be made unique through qualification and/or subscripting except when the scope of names conventions by themselves ensure uniqueness of reference. If qualification is used to make a condition-name unique, the associated conditional variable may be used as the first qualifier. If qualification is used, the hierarchy of names associated with the conditional variable itself must be used to make the condition-name unique. If references to a conditional variable require subscripting, reference to any of its condition-names also requires the same combination of subscripting. The format and restrictions on the combined use of qualification and subscripting of condition-name is exactly that of "identifier" except that data-name-1 is replaced by condition-name-1. In the general format of the chapters that follow, "condition-name" refers to a condition-name qualified or subscripted, as necessary. ═══ ═══ Can be a record-name. ═══ ═══ Must be identified by an FD or SD entry in the Data Division. File-name-1 must be unique within this program. ═══ ═══ Must be subordinate to a data description entry which contains an OCCURS clause. ═══ ═══ Must contain an OCCURS clause or must be subordinate to a data description entry which contains an OCCURS clause. ═══ ═══ Can be signed. If signed, it must be positive. ═══ ═══ Must be a numeric elementary item representing an integer. Data-name-3 can be qualified. ═══ ═══ Corresponds to a data description entry in the hierarchy of the table being referenced which contains an INDEXED BY phrase specifying the index-name. ═══ ═══ Must be an unsigned integer. ═══ ═══ Must refer to a data item whose implicit or explicit usage is DISPLAY. Data-name-1 can be qualified or subscripted. -----IBM Extension----- Must not refer to a Boolean data item. ---End of IBM Extension--- ═══ ═══ Must be an arithmetic expression. The evaluation of the leftmost-character-position must result in a positive nonzero integer that is less than or equal to the number of characters in the data item referenced by data-name-1. ═══ ═══ Must be an arithmetic expression. The sum of leftmost-character-position and length minus the value one must be less than or equal to the number of characters in data-name-1. If length is omitted, then the length used will be equal to the number of characters in data-name-1 plus one minus the leftmost-character-position. The evaluation of length must result in a positive nonzero integer. Note: If the result of an arithmetic expression is something other than an integer, truncation occurs, resulting in an integer. ═══ ═══ A user-defined word that must be identical to a program-name declared in a preceding PROGRAM-ID paragraph. Refer to program-name in PROGRAM-ID Paragraph for the rules for formation of the program-name. ═══ ═══ -----IBM Extension----- Must be a nonnumeric literal. Refer to literal in PROGRAM-ID Paragraph for the rules for formation of the literal. ---End of IBM Extension--- ═══ ═══ Sibling programs are those that are directly contained by the same program. ═══ ═══ Name of the author of the program. It is syntax checked only. ═══ ═══ Name of the company or location. It is syntax checked only. ═══ ═══ Date the program was written. It is syntax checked only. ═══ ═══ Date the program was compiled. ═══ ═══ Level of confidentiality of the program. ═══ ═══ A system-name. The suggested computer-name is: IBM-AS400. ═══ ═══ A system-name, which is syntax checked but has no effect on the execution of the program. The suggested computer-name is: IBM-AS400. ═══ ═══ Expressed in words, characters, or modules. ═══ ═══ The collating sequence. ═══ ═══ Must be an integer varying in value from 1 through 49. ═══ ═══ Specifies the ASCII character set. ═══ ═══ Specifies the International Reference Version of the ISO 7-bit code defined in International Standard 646, 7-bit Coded Character Set for Information Processing Interchange. ═══ ═══ Specifies the EBCDIC character set. ═══ ═══ Specifies the EBCDIC character set. ═══ ═══ Use the SRTSEQ and LANGID specifications in the compiler options (or implied defaults) for alternate collating sequence aspects of the alphabet-name. An alphabet-name associated with NLSSORT can be referred to only in the PROGRAM COLLATING SEQUENCE clause or in the COLLATING SEQUENCE phrase of the SORT and MERGE statements. ═══ ═══ -----IBM Extension----- Must be described in the WORKING-STORAGE SECTION and must be a 6-byte alphanumeric field or a 6-byte unsigned zoned integer. If data-name-2 is referenced from a nested program, it must be defined as global in the outermost program. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Linkage to a program object (*PGM) is generated. This is synonymous to an environment-name-3 of PGM. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Linkage to an ILE procedure is generated. This is synonymous to an environment-name-3 of PRC. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Literal-7 is the name of the program object or procedure. Literal-7 can contain an extended-name. It can be at most 10 characters long for program names and 256 characters long for procedure names. Literal-7 is affected by the OPTION(*MONOPRC) parameter. When *MONOPRC is specified, lowercase characters are converted to uppercase and the rules for formation of a program-name are followed. See program-name in PROGRAM-ID Paragraph for details. ---End of IBM Extension--- ═══ ═══ May be specified only for sequential and relative files opened in the input, I-O or extend mode. You must specify SELECT OPTIONAL for such input files that are not necessarily present each time the object program is executed. ═══ ═══ Must be identified by an FD or SD entry in the Data Division. A file-name must conform to the rules for a COBOL user-defined name, must contain at least one alphabetic character, and must be unique within this program. ═══ ═══ Must be defined in the Data Division as an alphanumeric one-character data item, and must not be defined in the File Section. Data-name-6 can be qualified. ═══ ═══ Must be a 1-character nonnumeric literal. ═══ ═══ If STANDARD-1 is specified, the external medium must be a magnetic tape file. ═══ ═══ Can be any COBOL word. ═══ ═══ Records in the file are accessed in the sequence established when the file was created or extended (arrival sequence). ═══ ═══ Records in the file are accessed in the ascending sequence of relative record numbers of existing records in the file. ═══ ═══ Records in the file are accessed in the sequence of ascending record key values according to the collating sequence of the file. -----IBM Extension----- When using an externally described file, if the DDS keyword DESCEND is used when the field is specified as a key field, the records in the file are accessed in the sequence of descending record key values within the index. Either the DESCEND keyword, or the ASCEND keyword (if DESCEND is not specified) appears under the heading RETRIEVAL in a comment table in the COBOL source program listing. ---End of IBM Extension--- ═══ ═══ The value placed in a relative key data item specifies the record to be accessed. ═══ ═══ The value placed in a record key data item for the current key of reference specifies the record to be accessed. ═══ ═══ Records in the file may be accessed sequentially or randomly, depending on the form of the specific input-output request. ═══ ═══ Records in the file may be accessed sequentially or randomly, depending on the form of the specific input-output request. ═══ ═══ The name of a sequentially organized file. The file named in the RERUN clause must be a file defined in the same program as the I-O-CONTROL paragraph, even if the file is defined as GLOBAL. ═══ ═══ This name can be any user defined word. The file named in the RERUN clause must be a file defined in the same program as the I-O-CONTROL paragraph, even if the file is defined as GLOBAL. ═══ ═══ A checkpoint record is to be written for every integer-1 record in file-name-2 that is processed. When multiple integer-1 RECORDS phrases are specified, no two of them may specify the same file-name-2. Integer-1 must be an unsigned integer. It specifies the number of records to be processed before the RERUN information is written. ═══ ═══ No two multiple END OF REEL or END OF UNIT phrases can specify the same file-name-2. The definition of UNIT is determined by each assignment-name-1. ═══ ═══ Only one RERUN clause containing the CLOCK-UNITS phrase can be specified. ═══ ═══ Must be specified in the FILE-CONTROL paragraph of the same program as the I-O-CONTROL paragraph. They cannot reference an external file connector. ═══ ═══ Must be an unsigned integer. It specifies the relative position of the file on the tape. ═══ ═══ Names the files that share the tape. ═══ ═══ Represents the highest level of organization in the File Section. It provides information about the physical structure and identification of a file, and gives the record-name(s) associated with that file. For the format and the clauses required in a file description entry, see Data Division-File and Sort Description Entries. ═══ ═══ A set of data description entries that describe the particular record(s) contained within a particular file. For the format and the clauses required in a record description entry, see Data Division-Data Description Entry. More than one record description entry may be specified; each is an alternative description of the same record storage area. Data areas described in the File Section are not available for processing unless the file containing the data area is open. ═══ ═══ Independent items in the Working-Storage Section that bear no hierarchic relationship to one another need not be grouped into records, provided that they do not need to be further subdivided. Each is defined in a separate data-item description entry that begins with either the level number 77 or 01. For the format and the clauses required in a data-item description entry, see Data Division-Data Description Entry. ═══ ═══ Must be nonzero unsigned integers. They specify the number of characters or records. ═══ ═══ Must be an unsigned integer that specifies the number of character positions contained in each record in the file. ═══ ═══ Specifies the minimum number of character positions to be contained in any record of the file. If integer-4 is not specified, the minimum number of character positions to be contained in any record of the file is equal to the smallest number of character positions described for a record in that file. If specified, integer-4 must be nonzero and less than integer-5. ═══ ═══ Specifies the maximum number of character positions in any record of the file. If integer-5 is not specified, the maximum number of character positions in any record of the file is equal to the greatest number of character positions described for a record in that file. ═══ ═══ Must be an elementary unsigned integer. If data-name-1 is specified:  The number of character positions in the record must be placed into the data item referenced by data-name-1 before any RELEASE, REWRITE, or WRITE statement is executed for the file.  The execution of a DELETE, RELEASE, REWRITE, START, or WRITE statement or the unsuccessful execution of a READ or RETURN statement does not alter the contents of the data item referenced by data-name-1.  After the successful execution of a READ or RETURN statement for the file, the contents of the data item referenced by data-name-1 indicate the number of character positions in the record just read. ═══ ═══ Must be unsigned integers. Integer-6 specifies the size of the smallest data record, and integer-7 specifies the size of the largest data record. ═══ ═══ Labels conforming to system specifications exist for this file. ═══ ═══ No labels exist for this file. ═══ ═══ Must follow the rules for formation of a user-defined word. ═══ ═══ Can be any literal. ═══ ═══ Should be qualified when necessary, but cannot be subscripted. It must be described in the Working-Storage Section, and cannot be described with the USAGE IS INDEX clause. ═══ ═══ The names of record description entries associated with this file. ═══ ═══ The number of lines that can be written and/or spaced on this logical page. The area of the page that these lines represent is called the page body. The value must be greater than zero. ═══ ═══ Integer-9 or the value in data-name-4 specifies the first line number of the footing area within the page body. The footing line number must be greater than zero, and not greater than the last line of the page body. The footing area extends between those two lines. ═══ ═══ Integer-10 or the value in data-name-5 specifies the number of lines in the top margin of the logical page. The value may be zero. ═══ ═══ Integer-11 or the value in data-name-6 specifies the number of lines in the bottom margin of the logical page. The value may be zero. ═══ ═══ -----IBM Extension----- Can refer to an elementary item, a group item, or an index-name. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Specifies the difference in length between the new and existing items. It can be signed. If a blank or a + precedes the integer, the new item is longer. If a - precedes the integer, the new item is shorter. You cannot use the LIKE clause to:  Change the length of an edited item  Change the length of an index, pointer, or procedure-pointer item  Change the number of decimal places in a data item Note that an item whose attributes include BLANK WHEN ZERO is treated as an edited item. ---End of IBM Extension--- ═══ ═══ Specifies the exact number of occurrences, and must be greater than zero. In the ILE COBOL/400 language, integer-2 must be between 1 and 16 711 568 bytes. ═══ ═══ Must be the name of the subject entry, or the name of an entry subordinate to the subject entry. If data-name-2 names the subject entry, that entire entry becomes the ASCENDING/DESCENDING KEY, and is the only key that may be specified for this table element. If data-name-2 does not name the subject entry, then data-name-2:  Must be subordinate to the subject of the table entry itself  Must not be subordinate to, or follow, any other entry that contains an OCCURS clause  Must not contain an OCCURS clause ═══ ═══ index-name-1 Must follow the rules for formation of user-defined words. At least one character must be alphabetic. Each index-name specifies an index to be created by the compiler for use by the program. These index-names are not data-names, and are not identified elsewhere in the COBOL program; instead, they can be regarded as private special registers for the use of this object program only. As such, they are not data, or part of any data hierarchy; as such, each must be unique. If a data item possessing the GLOBAL attribute includes a table accessed with an index, the index defined for the table also possess the GLOBAL attribute. ═══ ═══ The minimum number of occurrences. The value of integer-1 must be greater than or equal to zero; it must also be less than the value of integer-2. ═══ ═══ The maximum number of occurrences. ═══ ═══ Specifies the object of the OCCURS DEPENDING ON clause; that is, the (integer) data item whose current value represents the current number of occurrences of the subject item. The contents of items whose occurrence numbers exceed the value of the object are unpredictable. ═══ ═══ Is the redefined item or the REDEFINES object. Contrast it with data-name-1, which is the REDEFINES clause subject. ═══ ═══ A user-specified name that associates a value with a conditional variable. If the associated conditional variable requires subscripts or indexes, each procedural reference to the condition-name must be subscripted or indexed as required for the conditional variable. Condition-names are tested procedurally in condition-name conditions (see Conditional Expressions). ═══ ═══ When literal-1 is specified alone, the condition-name is associated with a single value. ═══ ═══ The condition-name is associated with at least one range of values. Whenever the THROUGH phrase is used, literal-1 must be less than literal-2. ═══ ═══ Must reference a data item whose usage is DISPLAY. When the identifier is a group item of zero length and NOT is specified in the class condition, the result is always true. If NOT is not specified, the result is always false. ═══ ═══ When used, NOT and the next keyword define the class test to be executed for truth value. For example, NOT NUMERIC is a truth test for determining that an identifier is nonnumeric. ═══ ═══ The data item referenced by the identifier consists entirely of any combination of the lowercase or uppercase alphabetic characters A through Z, and the space. ═══ ═══ The data item referenced by the identifier consists entirely of any combination of the lowercase alphabetic characters a through z, and the space. ═══ ═══ The data item referenced by the identifier consists entirely of any combination of the uppercase alphabetic characters A through Z, and the space. ═══ ═══ The data item referenced by the identifier consists entirely of the characters listed in the definition of class-name in the SPECIAL-NAMES paragraph. The class-name test must not be used with an identifier described as numeric. ═══ ═══ The subject of the relation condition. ═══ ═══ The object of the relation condition. ═══ ═══ -----IBM Extension----- May specify any level item defined in the Data Division Section, except level 66 and level 88. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Must be described as USAGE IS POINTER. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Can be used only if the other operand is one of these:  An item whose usage is POINTER  The ADDRESS OF an item  The ADDRESS OF special register. That is, NULL=NULL is not allowed. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Must be described as USAGE IS PROCEDURE-POINTER (see PROCEDURE-POINTER Phrase for more information). ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Used only if the other operand is defined as USAGE IS PROCEDURE-POINTER. NULL=NULL is not allowed. ---End of IBM Extension--- ═══ ═══ Must be defined as a numeric identifier, or it must be defined as an arithmetic expression that contains at least one reference to an identifier. An unsigned operand is either POSITIVE or ZERO. ═══ ═══ An algebraic test is executed for the truth value of the sign condition. For example, NOT ZERO is regarded as true when the operand tested is positive or negative in value. ═══ ═══ Must be defined in the SPECIAL-NAMES paragraph as associated with the ON or OFF value of an UPSI switch. (See SPECIAL-NAMES Paragraph.) ═══ ═══ The receiving data item. ═══ ═══ -----IBM Extension----- May be specified in place of mnemonic-name. Valid environment-names are CONSOLE and SYSIN. ---End of IBM Extension--- ═══ ═══ The receiving data item. ═══ ═══ Has the implicit PICTURE 9(6). The sequence of data elements (from left to right) is: 2 digits for year of century 2 digits for month of year 2 digits for day of month Thus, 16 November 1963 is expressed as: 631116 ═══ ═══ Has the implicit PICTURE 9(5). The sequence of data elements (from left to right) is: 2 digits for year of century 3 digits for day of year Thus 25 December 1988 is expressed as: 88360 ═══ ═══ Has the implicit PICTURE 9(1). The single data element represents the day of the week thus: 1 represents Monday 2 represents Tuesday 3 represents Wednesday 4 represents Thursday 5 represents Friday 6 represents Saturday 7 represents Sunday Thus Thursday is expressed as: 4 ═══ ═══ Has the implicit PICTURE 9(8). The sequence of data elements (from left to right) is: 2 digits for hour of day 2 digits for minute of hour 2 digits for second of minute 2 digits for hundredths of second Thus 12.25 seconds after 2:41 PM is expressed as: 14411225 ═══ ═══ -----IBM Extension----- Identifier-1 can be any fixed-length group item or an elementary alphabetic, alphanumeric, or external decimal item. File-name-1 must be defined in an FD entry, and must be open prior to the execution of the ACCEPT statement. If file-name-1 is not open, the contents of identifier-1 remain unchanged. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The FROM phrase specifies a mnemonic-name that must be associated with an environment-name of OPEN-FEEDBACK or I-O-FEEDBACK in the SPECIAL-NAMES paragraph. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- When the FOR phrase is specified, the feedback information is from the file specified in the phrase. When the FOR phrase is not specified, the feedback information is from the last file opened or used in an input or output operation of the current program. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- This format is only applicable when the mnemonic-name in the SPECIAL-NAMES paragraph is associated with the environment-name LOCAL-DATA. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- When the FOR phrase is specified, it is syntax checked during compilation but treated as a comment during execution. The value of literal-1 or identifier-2 indicates the program device name of the device that is associated with the local data area. There is only one local data area for each job, and all devices in a job access the same local data area. Literal-1, if specified, must be nonnumeric and 10 characters or less in length. Identifier-2, if specified, must refer to an alphanumeric data item, 10 characters or less in length. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- This format only applies when you associate the mnemonic-name in the SPECIAL-NAMES paragraph with the environment-name PIP-DATA. The move into identifier-1 takes place according to the rules for the MOVE statement for a group move without the CORRESPONDING phrase. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- If the PIP data area exists, the job is a prestart job, and any imperative statement specified in the NOT ON EXCEPTION phrase is processed. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- If the PIP data area does not exist, the job is not a prestart job, and any imperative statement specified in the ON EXCEPTION phrase is processed. In the absence of the ON EXCEPTION phrase, a run-time message is issued if the PIP data area does not exist. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The END-ACCEPT explicit scope terminator serves to delimit the scope of the ACCEPT statement. END-ACCEPT permits a conditional ACCEPT statement to be nested in another conditional statement. END-ACCEPT may also be used with an imperative ACCEPT statement. For more information, see Delimited Scope Statements. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Mnemonic-name must be associated with the environment-name ATTRIBUTE-DATA in the SPECIAL-NAMES paragraph. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- If file-name-1 is not specified, the default file for the ACCEPT statement is the first TRANSACTION file specified in a SELECT clause of the FILE-CONTROL paragraph. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Literal-1 or the contents of identifier-2, if specified, indicates the program device name for which attribute data is made available. For an ICF file, this device must have been defined (through a ADDICFDEVE, CHGICFDEVE, or OVRICFDEVE command) as available to be acquired by the file, but need not have actually been acquired. For a display file, if the program device name is not the name of the display device, then the device must have been specified in the DEV parameter when the file was created, changed, or overridden, and before the OPEN is issued for the file. Literal-1, if specified, must be nonnumeric and 10 characters or less in length. The contents of identifier-2, if specified, must be an alphanumeric data item 10 characters or less in length. If an invalid program device name is specified, message LNR7205 is issued and execution terminates. If both FOR phrases are omitted (indicating the default TRANSACTION file is being used) the ACCEPT statement uses the program device from which a READ, WRITE, REWRITE, or ACCEPT (Attribute Data) operation on the default file was most recently performed. If the only prior operation on the file was an OPEN, the ACCEPT statement uses the program device implicitly acquired by the file when the file was opened. When both FOR phrases are omitted, a program device must have been acquired in order to use this format of the ACCEPT statement. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- A data item whose value may be updated. Fields accepted or displayed require an attribute byte before and after the field. To accomplish this, space must be available on the screen for, at a minimum, the initial display attribute. For this reason, line 1 and column 1 cannot be used for data because that position is required for the first display attribute. The lowest position that can be used on the screen for data is line 1, column 2. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The LINE phrase specifies the line at which the screen item starts on the screen. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The COLUMN phrase specifies the column at which the screen item starts on the screen. COL is an abbreviation for COLUMN. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Identifier-2 and integer-1 must be an unsigned numeric integer with a value greater than or equal to zero and less than 9 digits. If the value for LINE or COLUMN is negative, the absolute value is taken. Identifier-2 or integer-1 is moved into a PIC 9(3) number. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Identifier-3 must be a PIC 9(4) or a PIC 9(6) field. Integer-2 must be a 4- or 6-byte numeric field. If identifier-3 or integer-2 is 4 digits long, the first 2 digits specify the line, and the second 2 digits specify the column. If identifier-3 or integer-2 is 6 digits long, the first 3 digits specify the line, the second 3 digits specify the column. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Indicates that the ACCEPT statement is extended. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The identifier is to be treated as an elementary item; thus, even if it is a group item it is accepted as one item. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- If ON EXCEPTION is specified, imperative-statement-1 is executed if the ACCEPT operation finishes with anything other than a normal completion. That is, if the CRT Status Key 1 is other than 0. The use of the ON EXCEPTION phrase does not prevent the generation of a run-time message for such conditions as workstation boundaries or out-of-screen ranges. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- If NOT ON EXCEPTION is specified, imperative-statement-2 is executed if the ACCEPT operation finishes with a normal completion. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- END-ACCEPT is optional. It is required if ACCEPT statements are nested. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The WITH phrase allows the user to specify certain options for the ACCEPT operation. These options are described in the following phrases. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- When a field has been filled by operator input, the cursor automatically steps to the next input field, rather than waiting for a terminating character to be entered. If the field is the last in a group, AUTO-SKIP acts as if the ENTER key had been pressed. AUTO and AUTO-SKIP may be used interchangeably. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- An audible alarm sounds each time the item containing this phrase is accepted. BELL and BEEP may be used interchangeably. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The screen item blinks when it appears on the screen. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The operator must either leave the screen item completely empty or fill it entirely with data. The FIELD-EXIT, FIELD+, FIELD- keys are not allowed. Any attempt to use the delete key on the data within the input field, followed by the enter key, is also not allowed. The FULL phrase can be satisfied by data that is initially displayed. If this phrase is specified at a group level, it applies to all suitable subordinate elementary items. The FULL phrase is effective during the execution of any ACCEPT statement. FULL and LENGTH-CHECK may be used interchangeably. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The screen item is in high-intensity mode when it appears on the screen. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The REQUIRED phrase is used to ensure that a field does not remain empty. For alphanumeric items, this means that the field must contain at least one character other than a space or a hexadecimal zero. For numeric items, the field must contain a value of other than zero. If a field remains empty when this phrase is specified, a run-time message will be issued which requires the user to press the reset key and then to re-enter the data. REQUIRED and EMPTY-CHECK may be used interchangeably. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The screen item is displayed in reverse image. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Operator-keyed data is prevented from appearing on the screen. This phrase may be specified on a group screen item, in which case it applies to all suitable elementary items which are subordinate to that item. When the SECURE phrase is specified, only spaces and cursor appear in the screen item. SECURE and NO-ECHO may be used interchangeably. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The screen item is underlined when it appears on the screen. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Operator-keyed characters are moved on the screen to the rightmost character positions of the field. Trailing spaces and trailing hexadecimal zeros are removed. This option affects only non-edited data items. This takes effect upon display of the initial data in the data item and also upon termination of the ACCEPT operation. This is the only way in which numeric data are handled. If the data item is defined with the JUSTIFIED RIGHT clause in the DATA DIVISION, then the data item is treated as if the RIGHT-JUSTIFY phrase had been specified. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Specifies the size of the data item on the screen. You can use this phrase with elementary data items only. The SIZE phrase has no effect if the size you specify is zero. In this case, the length of the field is used to display the data item. If you specify a size that is less than the size implied by the associated PICTURE clause, only the leftmost portion of the data item appears on the workstation display. When the size specified for a numeric or numeric-edited data item is less than that implied by the PICTURE clause, truncation of the rightmost positions occurs when the value is displayed, or predisplayed in the ACCEPT operation. The data item is then updated following the rules for the MOVE operation. If you specify a SIZE literal whose value causes the field length to exceed the screen size, alphanumeric data will be truncated and numeric data will be ignored and not displayed. For justified items, only the rightmost portion appears when you specify a size that is smaller than the length of the item. If the size you specify is greater than the size implied by the PICTURE clause, the displayed version of the item is padded with spaces. The padding occurs on the right. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- For non-edited data items, trailing hexadecimal zeros are converted to spaces, and the items appear on the screen with zero-suppression in all character positions. This takes effect when initial data in the data item is displayed and again when the ACCEPT operation into the data item is terminated. This option has no effect on edited fields. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The operational sign appears in the rightmost character position of the field. This takes effect upon display of initial data in the data item and also upon termination of the ACCEPT operation. This option affects only signed, non-edited numeric data items. When this option is not specified, the sign precedes the number. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The current contents of the data item are displayed before the operator is prompted to key in any new data; the initial data is then treated as though it were operator-keyed. Predisplaying by Data Type In the absence of the UPDATE phrase, you can control the predisplaying of some data. To predisplay only numeric-edited data, specify the *ACCUPDNE option of the EXTDSPOPT parameter. To predisplay all data, use the default option, *ACCUPDALL. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Non-edited data items appear on the screen with no zero-suppression. For left-justified data, trailing spaces and trailing hexadecimal zeros are converted to zeros. For right-justified data, leading spaces are converted to zeros. This takes effect when initial data in the data item is displayed and again when the ACCEPT operation into the data item is terminated. It has no effect on edited fields. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Syntax checked and then treated as documentation by the compiler. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The literal you specify, or the contents of the identifier, will specify the program device name to be acquired by the specified file. The literal must be nonnumeric and 10 characters or less in length. The identifier must refer to an alphanumeric data item 10 characters or less in length. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- File-name must be the name of a file with an organization of TRANSACTION, and the file must be open when the ACQUIRE statement is run. A compilation error message is issued if the organization is not TRANSACTION. ---End of IBM Extension--- ═══ ═══ Must be an elementary numeric item. ═══ ═══ Must be an elementary numeric item or a numeric-edited item. ═══ ═══ Must be a group item. ═══ ═══ Must be a numeric literal. ═══ ═══ This explicit scope terminator delimits the scope of the ADD statement. END-ADD converts a conditional ADD statement into an imperative statement so that it can be nested in another conditional statement. For more information, see Delimited Scope Statements. ═══ ═══ Must be a Procedure Division paragraph that contains only one sentence: a GO TO statement without the DEPENDING ON phrase. ═══ ═══ Must be a Procedure Division section or paragraph. ═══ ═══ The CALL linkage determines the type of program called and thus also restricts the content and size of literal-1. The linkage made is either to a program object or an ILE procedure. If the linkage is to a program object, then literal-1 must be nonnumeric, uppercase (except for an extended system name), and must conform to the rules for formation of program-names. The first 10 characters of the literal are used to make the correspondence between the calling program and the called subprogram. Literal-1 can contain an extended name. If the linkage is to an ILE procedure, then literal-1 must be nonnumeric and at most 256 characters long. Depending on the compiler option *MONOPRC, literal-1 might need to be uppercase and conform to the rules for formation of program-names. The literal must specify the program-name of the called subprogram. ═══ ═══ Must be an alphanumeric or a procedure-pointer data item. For an alphanumeric data item, the following rules apply:  If the linkage is to a program object, the contents of identifier-1 must conform to the rules for formation of a program-name. The first 10 characters of identifier-1 are used to make the correspondence between the calling and the called program.  If the linkage is to a procedure, the first 256 characters of identifier-1 are used. The called procedure must be in the same compilation unit as the calling procedure.  Depending on the compiler option *MONOPRC, the contents of identifier-1 might need to be uppercase and conform to the rules for formation of program-names. Procedure-pointer data items must be set to the address of a program or a procedure using the SET statement prior to the CALL. For information on setting procedure-pointer data items, see Format 6 - Procedure-Pointer Data Item. ═══ ═══ The type of linkage the compiler will generate for the CALL. Environment-name-1 can be defined as: PGM Linkage to a program object (*PGM) is generated. PRC Linkage to an ILE procedure is generated. ═══ ═══ Linkage to a program object (*PGM) ═══ ═══ Linkage to an ILE procedure ═══ ═══ Must be defined as a level-01, level-77, or elementary data item in the File Section, Working-Storage Section, or Linkage Section. -----IBM Extension----- It can be:  A data item of any level in the Data Division  A pointer data item (an item defined implicitly or explicitly as USAGE IS POINTER)  A procedure-pointer data item ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Must appear in an FD entry. It passes a null pointer data item. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- For standard arguments when a parameter is passed BY REFERENCE, a pointer to the original data item is passed to the called program. When OMITTED is specified, a NULL pointer is passed to the called program. In this case, the called program will use its default value. OMITTED can only be specified on calls to programs with a LINKAGE TYPE of procedure. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Can be:  A nonnumeric literal  A figurative constant  A Boolean literal ---End of IBM Extension--- ═══ ═══ The ON OVERFLOW phrase has the same effect as the ON EXCEPTION phrase. ═══ ═══ This phrase delimits the scope of the CALL statement. END-CALL permits a conditional CALL statement to be nested in another conditional statement. END-CALL can also be used with an imperative CALL statement. For more information, see Delimited Scope Statements. ═══ ═══ The name of the subprogram to be canceled. Literal-1 can contain an extended name. The CANCEL linkage determines the type of program to be canceled and thus also restricts the content and size of literal-1. The linkage made is either to a program object or an ILE procedure. If the linkage is to a program object, then literal-1 must be nonnumeric, uppercase (except for an extended system name), and must conform to the rules for formation of program-names. The first 10 characters of the literal are used to make the correspondence between the calling program and the called subprogram. If the linkage is to an ILE procedure, then literal-1 must be nonnumeric and at most 250 characters long. Depending on the compiler option *MONOPRC, literal-1 might need to be uppercase and conform to the rules for formation of program-names. The literal must specify the program-name of the called subprogram. ═══ ═══ Must be an alphanumeric data item where the following rules apply:  If the linkage is to a program object, the contents of identifier-1 must conform to the rules for formation of a program-name. The first 10 characters of identifier-1 are used to make the correspondence between the calling and the called program.  If the linkage is to a procedure, the first 250 characters of identifier-1 are used.  If the compiler option *MONOPRC is specified, the contents of identifier-1 need to be uppercase and must conform to the rules for formation of program-names. Each literal or contents of the identifier specified in the CANCEL statement must be the same as the literal or contents of the identifier specified in an associated CALL statement. ═══ ═══ -----IBM Extension----- The LINKAGE TYPE phrase is used to specify the type of program that the CANCEL statement targets. It could target a program object (*PGM) or an ILE procedure. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The type of program that the CANCEL statement will affect. Environment-name-1 can be defined as: PGM A program object (*PGM) PRC An ILE procedure ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- A program object (*PGM) is canceled. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- An ILE procedure is canceled. ---End of IBM Extension--- ═══ ═══ Designates the file upon which the CLOSE statement is to operate. If more than one file name is specified, the files need not have the same organization or access. File-name-1 must not be a sort or merge file. ═══ ═══ Must be either elementary numeric item(s) or elementary numeric-edited item(s). ═══ ═══ May be any arithmetic expression, as defined in Arithmetic Expressions. When the COMPUTE statement is executed, the value of the arithmetic expression is calculated, and this value is stored as the new value of each data item referenced by identifier-1. An arithmetic expression consisting of a single identifier or numeric literal allows the user to set the value of the data item(s) referenced by identifier-1 equal to the value of that identifier or literal. ═══ ═══ This explicit scope terminator serves to delimit the scope of the COMPUTE statement. END-COMPUTE permits a conditional COMPUTE statement to be nested in another conditional statement. END-COMPUTE may also be used with an imperative COMPUTE statement. For more information, see Delimited Scope Statements. ═══ ═══ Must be defined in an FD entry in the Data Division and must be the name of an indexed or relative file. ═══ ═══ The key fields in the record area are the locations in the buffer selected in accordance with a record format or specification in order to build a search argument. ═══ ═══ The INVALID KEY phrase must be specified for files for which an applicable USE procedure is not specified. For more information, refer to INVALID KEY Condition. ═══ ═══ After the successful processing of a DELETE statement for which there is a NOT INVALID KEY phrase, control transfers to the imperative statement associated with the phrase. ═══ ═══ The FORMAT phrase applies only to indexed files of device type DATABASE. It is required when processing a file that has multiple record formats and has unique keys. If the record key is defined with duplicates, the FORMAT phrase is incorrect and is ignored. The value specified in the FORMAT phrase contains the name of the record format to use for this I-O operation. The system uses this to specify or select which record format must be operated on. If an identifier is specified, it must be a character string of ten characters or less, and it must be the name of one of the following:  A Working-Storage Section entry  A Linkage Section entry  A record description entry for a previously opened file. If a literal is specified, it must be an uppercase character string of ten characters or less. A value of all blanks is treated as though the FORMAT phrase were not specified. If the value is not valid for a file, a FILE STATUS of 9K is returned and a USE procedure is invoked, if applicable for the file. ═══ ═══ This explicit scope terminator delimits the scope of the DELETE statement. It permits a conditional DELETE statement to be nested in another conditional statement. END-DELETE can also be used with an imperative DELETE statement. ═══ ═══ If it is numeric and is not described as external decimal, the identifier is converted automatically to external format, as follows:  Binary or internal decimal items are converted to external decimal. Negative signed values cause a low-order sign to be displayed. For example, if SIGN WITH SEPARATE CHARACTER is not specified and two numeric items have the values -34 and 34, they are displayed as 3M and 34, respectively. If SIGN WITH SEPARATE CHARACTER is specified, a + or a - sign is displayed as either leading or trailing, depending on how the number was specified. Note: Group items containing packed or binary data (COMP, COMP-3, PACKED-DECIMAL, BINARY, or COMP-4) should not be displayed on a display station. Such data can contain display station control characters which can cause undesirable and unpredictable results.  No other identifiers require conversion. ═══ ═══ May be any figurative constant. When a figurative constant is specified, only a single occurrence of that figurative constant is displayed. Each numeric literal must be an unsigned integer. -----IBM Extension----- Signed noninteger numeric literals are allowed. ---End of IBM Extension--- ═══ ═══ mnemonic-name must be associated in the SPECIAL-NAMES paragraph with either the workstation (REQUESTOR) or the system operator's message queue (CONSOLE or SYSTEM-CONSOLE). ═══ ═══ -----IBM Extension----- environment-name may be specified in place of mnemonic-name. Valid environment-names are CONSOLE and SYSOUT. ---End of IBM Extension--- ═══ ═══ When the UPON phrase is omitted, the DISPLAY statement sends output to the REQUESTOR. ═══ ═══ This phrase is syntax checked only and ignored. For a description of a functional WITH NO ADVANCING phrase see Format 4 - Session I/O. ═══ ═══ -----IBM Extension----- This format is only applicable when the mnemonic-name in the SPECIAL-NAMES paragraph is associated with the environment-name LOCAL-DATA. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The FOR phrase, when specified, is syntax checked during compilation but is treated as comments during execution. The value of literal-2 or identifier-2 indicates the program device name of the device that is writing data to the local data area. There is only one local data area for each job, and all devices in a job access the same local data area. Literal-2, if specified, must be nonnumeric and 10 characters or less in length, and identifier-2, if specified, must refer to an alphanumeric data item 10 characters or less in length. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The LINE phrase specifies the line at which the screen item starts on the screen. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The COLUMN phrase specifies the column at which the screen item starts on the screen. COL is an abbreviation for COLUMN. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Identifier-2 and integer-1 must be unsigned numeric integers greater than or equal to zero, and less than 9 digits. If LINE or COLUMN is negative, the absolute value is taken. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Identifier-3 must be a PIC 9(4) or a PIC 9(6) field. Integer-2 must be a 4- or 6-byte numeric field. If identifier-3 or integer-2 is 4 digits long, the first two digits specify the line, and the second two digits specify the column. If identifier-3 or integer-2 is 6 digits long, the first three digits specify the line, and the second three digits specify the column. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Indicates that the DISPLAY statement is extended. CRT-UNDER also underlines the displayed data item preceding the UPON CRT-UNDER phrase. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The identifier is treated as an elementary item. Even if it is a group item, it is displayed as one item. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The WITH phrase allows the user to specify certain options for the DISPLAY operation. These options are described in the following phrases. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- An audible alarm sounds each time the item containing this phrase is displayed. BELL and BEEP can be used interchangeably. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- BLANK is effective each time the screen item containing this clause is displayed. BLANK LINE erases from the current cursor position to the end of the current line. BLANK SCREEN erases the entire screen and places the cursor at line 1, column 2. The erasing is done before the item is displayed. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The screen item blinks when it appears on the screen. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The screen item is in high-intensity mode when it appears on the screen. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The screen item is displayed in reverse image. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Identifier-4 must be an unsigned numeric integer, and must not be subject to an OCCURS clause. Integer-3 must be unsigned. If identifier-4 or integer-3 has a sign, the compiler uses the absolute value, and issues a warning message. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The screen item is underlined when it appears on the screen. ---End of IBM Extension--- ═══ ═══ Must be an elementary numeric item. ═══ ═══ Must be an elementary numeric or numeric-edited item. ═══ ═══ Must be a numeric literal. ═══ ═══ For Formats 4 and 5, the quotient used to calculate the remainder is in an intermediate field. The value of the intermediate field is truncated rather than rounded. ═══ ═══ The result of subtracting the product of the quotient and the divisor from the dividend is stored in identifier-4. If identifier-3, the quotient, is a numeric-edited item, the quotient used to calculate the remainder is an intermediate field that contains the unedited quotient. Any subscripts for identifier-4 in the REMAINDER phrase are evaluated after the result of the divide operation is stored in identifier-3 of the GIVING phrase. ═══ ═══ For Formats 4 and 5, if the size error occurs in the quotient, no remainder calculation is meaningful. Therefore, the contents of the quotient field (identifier-3) and the remainder field (identifier-4) are unchanged. If size error occurs in the remainder, the contents of the remainder field (identifier-4) are unchanged. In either of these cases, you must analyze the results to determine which situation has actually occurred. ═══ ═══ This explicit scope terminator delimits the scope of the DIVIDE statement. END-DIVIDE converts a conditional DIVIDE statement into an imperative statement so that it can be nested in another conditional statement. ═══ ═══ -----IBM Extension----- Literal or the contents of identifier indicates the program device name of the device to be dropped. Literal, if specified, must be nonnumeric and 10 characters or less in length. Identifier, if specified, must refer to an alphanumeric data item, 10 characters or less in length. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- File-name must refer to a file with an organization of TRANSACTION, and the file must be open in order to be used in the DROP statement. If no DROP statement is issued, program devices attached to a TRANSACTION file are implicitly released when that file is finally closed. ---End of IBM Extension--- ═══ ═══ A system name that has no defined meaning. It must follow the rules for formation of a user-defined word. At least one character must be alphabetic. ═══ ═══ Must follow the rules for formation of a user-defined word. At least one character must be alphabetic. ═══ ═══ Separates selection subjects within a set of selection subjects; separates selection objects within a set of selection objects. ═══ ═══ This explicit scope terminator serves to delimit the scope of the EVALUATE statement. END-EVALUATE permits a conditional EVALUATE statement to be nested in another conditional statement. ═══ ═══ Any selection subject specified by identifier-1, identifier-2, . . . and any selection object specified by identifier-3 and/or identifier-5 without the NOT or THRU phrase, are assigned the value and class of the data item that they reference. ═══ ═══ Any selection subject specified by literal-1, literal-2, . . . and any selection object specified by literal-3 and/or literal-5 without the NOT or THRU phrase, are assigned the value and class of the specified literal. If literal-3 and/or literal-5 is the figurative constant ZERO, it is assigned the class of the corresponding selection subject. ═══ ═══ Any selection subject in which expression-1, expression-2, . . . is specified as an arithmetic expression, and any selection object without the NOT or THRU phrase in which arithmetic-expression-1 and/or arithmetic-expression-3 is specified, are assigned numeric values according to the rules for evaluating an arithmetic expression. (See Arithmetic Expressions.) Note: Comparing one arithmetic expression to another is system-specific. The truth status of the comparison may depend on the intermediate results created on that system. Any selection subject in which expression-1, expression-2, . . . is specified as a conditional expression, and any selection object in which condition-1 and/or condition-2 is specified, are assigned a truth value according to the rules for evaluating conditional expressions. (See Conditional Expressions.) ═══ ═══ Any selection subject or any selection object specified by the words TRUE or FALSE is assigned a truth value. The truth value "true" is assigned to those items specified with the word TRUE, and the truth value "false" is assigned to those items specified with the word FALSE. ═══ ═══ Any selection object specified by the word ANY is not further evaluated. ═══ ═══ If the THRU phrase is specified for a selection object without the NOT phrase, the range of values is all values that, when compared to the selection subject, are greater than or equal to the first operand and less than or equal to the second operand, according to the rules for comparison. If the first operand is greater than the second operand, there are no values in the range. Note: Results of comparisons with nonnumeric operands may not be consistent across systems, if the comparisons depend on the system's native collating sequence. ═══ ═══ If the NOT phrase is specified for a selection object, the values assigned to that item are all values not equal to the value, or range of values, that would have been assigned to the item had the NOT phrase been omitted. ═══ ═══ Must be a section or paragraph in the same Procedure Division as the GO TO statement. ═══ ═══ Must be a section or paragraph in the Procedure Division. ═══ ═══ Must be a numeric elementary data item which is an integer. If 1, control is transferred to the first statement in the procedure named by the first occurrence of procedure-name-1; If 2, control is transferred to the first statement in the procedure named by the second occurrence of procedure-name-1, and so forth. If the value of identifier is anything other than a value within the range of 1 through n (where n is the number of procedure-names specified in this GO TO statement), no control transfer occurs. Instead, control passes to the next statement in the normal sequence of execution. ═══ ═══ May be any simple or complex condition, as described in Conditional Expressions. ═══ ═══ Can be any one of the following:  An imperative statement  A conditional statement  An imperative statement followed by a conditional statement ═══ ═══ If the END-IF phrase is specified, the NEXT SENTENCE phrase must not be specified. -----IBM Extension----- NEXT SENTENCE can be specified with END-IF. ---End of IBM Extension--- ═══ ═══ May be omitted if it immediately precedes a separator period that ends the IF statement. ═══ ═══ This explicit scope terminator serves to delimit the scope of the IF statement. END-IF permits a conditional IF statement to be nested in another conditional statement. For more information, see Delimited Scope Statements. ═══ ═══ Receiving area(s). ═══ ═══ Sending area(s). ═══ ═══ Is the inspected item; an elementary or group item with USAGE DISPLAY. In Format-1, identifier-1 is a sending item. In the other formats, it is treated as a sending data item for the purpose of determining its length. ═══ ═══ The count field. It must be an elementary numeric item defined without the symbol P in its PICTURE character-string. You must initialize identifier-2 before the INSPECT statement is executed. ═══ ═══ The tallying operand (the item whose occurrences are tallied) If the tallying operand is a figurative constant, it is considered to be a 1-character nonnumeric literal. ═══ ═══ The subject field. ═══ ═══ The substitution field. ═══ ═══ These are not counted or replaced. However, counting and/or replacing of the inspected item is bounded by the presence of the identifiers and literals. If the delimiter (identifier-4 or literal-2) is a figurative constant, it is considered to be 1 character in length. ═══ ═══ The name given in the SD entry that describes the record. No file-name may be repeated in the MERGE statement. Do not specify a pair of file names in the MERGE statement that already share storage through a SAME AREA, SAME SORT AREA, or SAME SORT-MERGE AREA clause. However, you may specify file names in the MERGE statement that share the SAME RECORD AREA clause if they are also associated with the GIVING clause (file-name-4). ═══ ═══ Is a key data-name. Records are processed in ascending or descending order on this key. ═══ ═══ Must be specified in the SPECIAL-NAMES paragraph ALPHABET clause. Any one of the alphabet-name clause phrases can be specified with the following results:  When NATIVE is specified, the EBCDIC collating sequence is used for all nonnumeric comparisons.  When NLSSORT is specified, the collating sequence is determined by the LANGID and SRTSEQ parameters of the CRTCBLMOD and CRTBNDCBL commands.  When the literal phrase is specified, the collating sequence established by the specification of literals in the alphabet-name clause is used for all nonnumeric comparisons.  When STANDARD-1 is specified, the ASCII collating sequence is used for all nonnumeric comparisons.  When STANDARD-2 is specified, the International Reference Version of the ISO 7-bit code defined in International Standard 646, 7-bit Coded Character Set for Information Processing Interchange is used. ═══ ═══ Specifies the first (or only) section or paragraph in the OUTPUT PROCEDURE. ═══ ═══ Identifies the last section or paragraph of the OUTPUT PROCEDURE. ═══ ═══ Sending item ═══ ═══ Receiving item or items ═══ ═══ Must be an elementary numeric item. ═══ ═══ Must be a numeric literal. ═══ ═══ Must be an elementary numeric or numeric-edited item. ═══ ═══ This explicit scope terminator serves to delimit the scope of the MULTIPLY statement. END-MULTIPLY converts a conditional MULTIPLY statement into an imperative statement. This allows it to be nested in another conditional statement. For more information, see Delimited Scope Statements. ═══ ═══ -----IBM Extension----- Permits opening the file for both input and output operations. The I-O phrase can be specified only for files assigned to direct access devices, such as DISK, DATABASE, and workstation files. ---End of IBM Extension--- ═══ ═══ Permits opening the file for output operations. The EXTEND phrase must not be specified for a multiple file reel. The EXTEND phrase is not allowed for:  FORMATFILE files  Printer files  DISKETTE files ═══ ═══ Designates a file upon which the OPEN statement is to operate. If more than one file is specified, the files need not have the same organization or access. Each file-name must be defined in an FD entry in the Data Division, and must not name a sort or merge file. The FD entry must be equivalent to the information supplied when the file was defined. ═══ ═══ Must be a section or paragraph in the Procedure Division. When both procedure-name-1 and procedure-name-2 are specified, if either is a procedure-name in a declarative procedure, both must be procedure-names in the same declarative procedure. If the PERFORM statement is in a declarative section, procedure-name-1 and procedure-name-2 must also be in a declarative section. If procedure-name-1 is specified, imperative-statement and the END-PERFORM phrase must not be specified. If procedure-name-1 is omitted, imperative-statement and the END-PERFORM phrase must be specified. ═══ ═══ The statement(s) to be executed for an in-line PERFORM. ═══ ═══ Delimits the scope of the in-line PERFORM statement. Execution of an in-line PERFORM is completed after the last statement contained within it has been executed. ═══ ═══ Must be an integer item. If identifier-1 is zero or a negative number at the time the PERFORM statement is initiated, control passes to the statement following the PERFORM statement. After the PERFORM statement has been initiated, any change to identifier-1 has no effect in varying the number of times the procedures are initiated. ═══ ═══ May be any condition described under Conditional Expressions. If the condition is true at the time the PERFORM statement is initiated, the specified procedure(s) are not executed. Any subscripting associated with the operands specified in condition-1 is evaluated each time the condition is tested. ═══ ═══ If the TEST BEFORE phrase is specified or assumed, the condition is tested before any statements are executed (corresponds to DO WHILE). If the TEST AFTER phrase is specified, the statements to be performed are executed at least once before the condition is tested (corresponds to DO UNTIL). In either case, if the condition is true, control is transferred to the next executable statement following the end of the PERFORM statement. If neither the TEST BEFORE nor the TEST AFTER phrase is specified, the TEST BEFORE phrase is assumed. ═══ ═══ May be any condition described under Conditional Expressions. If the condition is true at the time the PERFORM statement is initiated, the specified procedure(s) are not executed. After the condition(s) specified in the UNTIL phrase are satisfied, control is passed to the next executable statement following the PERFORM statement. Any subscripting associated with the operands specified in condition-1 or condition-2 is evaluated each time the condition is tested. ═══ ═══ When TEST BEFORE is indicated, all specified conditions are tested before the first execution, and the statements to be performed are executed, if at all, only when all specified tests fail. When TEST AFTER is indicated, the statements to be performed are executed at least once, before any condition is tested. Any subscripting associated with the operands specified in condition-1 is evaluated each time the condition is tested. If neither the TEST BEFORE nor the TEST AFTER phrase is specified, the TEST BEFORE phrase is assumed. ═══ ═══ File-name must be defined in a Data Division FD entry, and must not name a sort or merge file. ═══ ═══ The next record in the sequence of records. ═══ ═══ This phrase is specified only for indexed files. Data-name-1 can be qualified; it cannot be subscripted. Data-name-1 must be the prime record key. This phrase is syntax checked only, and treated as documentation. ═══ ═══ After each successful completion of a READ statement with the NOT AT END phrase (the high order digit of the file status is 0), control transfers to the imperative statement associated with the phrase. ═══ ═══ The INVALID KEY phrase applies only when a relative or indexed file is read in random access mode or dynamic access mode. The INVALID KEY phrase must be specified for files for which there is not an appropriate EXCEPTION/ERROR procedure. For information about INVALID KEY phrase processing, see INVALID KEY Condition. ═══ ═══ The NOT INVALID KEY phrase applies only when a relative or indexed file is read in random access mode or dynamic access mode. After the successful completion of a READ statement with the NOT INVALID KEY phrase, control transfers to the imperative statement associated with the phrase. ═══ ═══ The NEXT phrase applies only for dynamic access mode. When a relative file is read dynamically and the NEXT phrase is specified, a sequential read is done. When omitted, a random read is done. When an indexed file is read dynamically and the NEXT phrase is specified, a sequential read is done. If NEXT, FIRST, LAST and PRIOR are all omitted, a random access read is done. If a READ NEXT operation is performed on a block of records, a READ PRIOR operation cannot occur until the block is empty. If a READ PRIOR operation is performed first, a READ NEXT operation cannot occur until the block is empty. If this is attempted, a file status of 9U will result. To recover from file status 9U, close the file, then open it again. ═══ ═══ -----IBM Extension----- The FIRST phrase applies only when indexed files are accessed dynamically. If NEXT, FIRST, LAST and PRIOR are all omitted, a random access read is done. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The LAST phrase applies only when indexed files are accessed dynamically. If NEXT, FIRST, LAST and PRIOR are all omitted, a random access read is done. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The PRIOR phrase applies only when indexed files are accessed dynamically. When specified, a sequential read is done. If NEXT, FIRST, LAST and PRIOR are all omitted, a random access read is done. If a READ PRIOR operation is performed on a block of records, a READ NEXT operation cannot occur until the block is empty. If a READ NEXT operation is performed first, a READ PRIOR operation cannot occur until the block is empty. If this is attempted, a file status of 9U will result. To recover from file status 9U, close the file, then open it again. ---End of IBM Extension--- ═══ ═══ This explicit scope terminator serves to delimit the scope of the READ statement. END-READ permits a conditional READ statement to be nested in another conditional statement. END-READ may also be used with an imperative READ statement. For more information, see Delimited Scope Statements. ═══ ═══ -----IBM Extension----- The INTO phrase cannot be specified unless:  All records associated with the file and the data item specified in the INTO phrase are group items or elementary alphanumeric items. OR  Only one record description is subordinate to the file description entry. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The KEY IS phrase may be specified only for indexed files. Data-name must identify a record key associated with file-name-1. Data-name-1 may be qualified; it may not be subscripted. Note: The KEY IS phrase is syntax checked only and has no effect on the operation of the READ statement. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Literal-1 or identifier-2 specifies the name of the record format to be read. Literal-1, if specified, must be nonnumeric, uppercase, and 10 characters or less in length. Identifier-2, if specified, must refer to an alphanumeric data item, 10 characters or less in length. If identifier-2 contains blanks, the READ statement is executed as if the FORMAT phrase were omitted. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- When the NO DATA phrase is specified, the READ statement will determine whether data is immediately available. If data is available, the data is returned in the record area. If no data is immediately available, imperative-statement-1 is executed. The NO DATA phrase prevents the READ statement from waiting for data to become available. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Literal-2 or identifier-3 specifies the program device name. Literal-2, if specified, must be nonnumeric and 10 characters or less in length. Identifier-3, if specified, must refer to an alphanumeric data item, 10 characters or less in length. The program device must have been acquired before the READ statement is executed. If identifier-3 contains blanks, the READ statement is executed as if the TERMINAL phrase was omitted. For a single device file, the TERMINAL phrase can be omitted. The program device is assumed to be that single device. If the TERMINAL phrase is omitted for a READ of a Transaction file that has acquired multiple program devices, the default program device is used. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Specifies which indicators are to be read when a data record is read. Indicators can be used to pass information about the data record and how it was entered into the program. Identifier-4 must be either an elementary Boolean data item specified without the OCCURS clause or a group item that has elementary Boolean data items subordinate to it. For detailed information on the INDICATORS phrase, refer to Using Indicators with Transaction Files in the ILE COBOL/400 Programmer's Guide. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The AT END phrase serves to explicitly delimit the scope of the statement. Imperative-statement-2 is executed when the AT END condition is detected. The AT END condition occurs when there are no invited program devices and the timer function is not in effect. The AT END phrase should be specified when no applicable USE procedure is specified for the file-name. If the AT END phrase and a USE procedure are both specified for a file, and the AT END condition arises, control transfers to the AT END imperative statement and the USE procedure is not run. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- This phrase allows you to specify procedures that will be performed when the AT END condition does not exist for the statement that is used. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- This explicit scope terminator serves to delimit the scope of the READ statement. END-READ permits a conditional READ statement to be nested in another conditional statement. END-READ may also be used with an imperative READ statement. For more information, see Delimited Scope Statements. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- See Format 4 above for general considerations concerning the TERMINAL phrase. For a Format 5a or 5b READ, if the TERMINAL phrase is omitted for a file that has multiple devices acquired for it, a record is read from the subfile associated with the default program device. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Specifies which indicators are to be read when a data record is read. Indicators can be used to pass information about the data record and how it was entered into the program. For detailed information on the INDICATORS phrase, refer to Using Indicators with Transaction Files in the ILE COBOL/400 Programmer's Guide. Identifier-4 must be either an elementary Boolean data item specified without the OCCURS clause or a group item that has elementary Boolean data items subordinate to it. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- If the RELATIVE KEY data item at the time of the execution of the READ statement contains a value that does not correspond to a relative record number for the subfile, the INVALID KEY condition exists and the execution of the READ statement is unsuccessful. The INVALID KEY phrase must be specified if the NEXT MODIFIED phrase is not specified and there is no applicable USE procedure specified for the file-name. For information about what happens when the invalid key condition occurs, see INVALID KEY Condition. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- This phrase specifies the procedures that will be performed when an invalid key condition does not exist for the statement that is used. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- If NEXT MODIFIED is specified and there is no user-modified record in the subfile, the AT END condition exists, and the execution of the READ statement is unsuccessful. The AT END phrase should be specified when the NEXT MODIFIED phrase is used, and no applicable USE procedure is specified for the file-name. If the AT END phrase and a USE procedure are both specified for a file, and the AT END condition arises, control transfers to the AT END imperative statement and the USE procedure is not executed. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- This phrase allows you to specify procedures that will be performed when the AT END condition does not exist for the statement that is used. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- This explicit scope terminator serves to delimit the scope of the READ statement. END-READ permits a conditional READ statement to be nested in another conditional statement. END-READ may also be used with an imperative READ statement. For more information, see Delimited Scope Statements. ---End of IBM Extension--- ═══ ═══ Must specify the name of a record in a sort-merge file description entry (SD). Record-name-1 may be qualified. ═══ ═══ Makes the RELEASE statement equivalent to the statements: MOVE identifier-1 to record-name-1 RELEASE record-name-1 Moving takes place according to the rules for the MOVE statement without the CORRESPONDING phrase. ═══ ═══ The name of a record in the File Section, having the same number of character positions as the record being replaced. The name of the record cannot be reference modified. ═══ ═══ This is the sending item. ═══ ═══ -----IBM Extension----- Multiple data records, each with a different format, can be concurrently active for a Transaction file. If the FORMAT phrase is specified, it must specify a valid format name that is defined to the system, and the I-O operation must be performed on a data record of the same format. If the format is an invalid name or if it does not exist, the FILE STATUS data item, if specified, is set to a value of 9K and the contents of the record area are undefined. Note: 1. The record format specified in the FORMAT phrase must be the record format accessed on the previous read operation. 2. Literal-1 or the contents of identifier-2 must be the name of the subfile format accessed on the previous READ. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The TERMINAL phrase indicates which program device's subfile is to have a record rewritten. If the TERMINAL phrase is specified, literal-2 or identifier-3 must refer to a workstation that has been acquired by the Transaction file. If literal-2 or identifier-3 contains blanks, the TERMINAL phrase has no effect. The program device specified by the TERMINAL phrase must have been acquired, either explicitly or implicitly, and must have a subfile associated with the device. Literal-2 or identifier-3 must be a valid program device name. Literal-2, if specified, must be nonnumeric and 10 characters or less. Identifier-3, if specified, must refer to an alphanumeric data item, 10 characters or less in length. If the TERMINAL phrase is omitted from a Transaction file that has acquired multiple program devices, the subfile used is the subfile associated with the last program device from which a READ of the Transaction file was attempted. The REWRITE statement cannot be used for communications devices. If the REWRITE statement is used for a communications device, the operation fails and a file status of 90 is set. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Specifies which indicators are to be used when a data record is rewritten. Indicators can be used to pass information about the data record and how it was entered into the program. For detailed information on the INDICATORS phrase, refer to Using Indicators with Transaction Files in the ILE COBOL/400 Programmer's Guide. Identifier-4 must be either an elementary Boolean data item specified without the OCCURS clause or a group item that has elementary Boolean data items subordinate to it. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- If, at the time of the rewrite operation, the RELATIVE KEY data item contains a value that does not correspond to the relative record number of the record from the previous read operation, the INVALID KEY condition exists. The INVALID KEY phrase should be specified for files for which an appropriate USE procedure is not specified. Undesirable results may occur if the INVALID KEY phrase is not specified, and no USE procedure is specified. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- After the successful completion of a REWRITE statement with the NOT INVALID KEY phrase, control transfers to the imperative statement associated with the phrase. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- This explicit scope terminator serves to delimit the scope of the REWRITE statement. END-REWRITE permits a conditional REWRITE statement to be nested in another conditional statement. END-REWRITE may also be used with an imperative REWRITE statement. For more information, see Delimited Scope Statements. ---End of IBM Extension--- ═══ ═══ Each condition-name specified must have only a single value, and each must be associated with an ASCENDING/DESCENDING KEY identifier for this table element. ═══ ═══ Must specify an ASCENDING/DESCENDING KEY data item in the identifier-1 table element and must be indexed by the first identifier-1 index-name, along with other indexes or literals, as required. Each data-name may be qualified. ═══ ═══ Must not be an ASCENDING/DESCENDING KEY data item for identifier-1 or an item that is indexed by the first index-name for identifier-1. Must not be a pointer or procedure-pointer data item. ═══ ═══ May be any of the expressions defined under Arithmetic Expressions, with the following restriction: Any identifier in the arithmetic-expression must not be an ASCENDING/DESCENDING KEY data item for identifier-1 or an item that is indexed by the first index-name for identifier-1. When an ASCENDING/DESCENDING KEY data item is specified, explicitly or implicitly, in the WHEN phrase, all preceding ASCENDING/DESCENDING KEY data-names for identifier-1 must also be specified. ═══ ═══ Receiving fields. Must be either index data items or elementary numeric integer items. ═══ ═══ Sending field. The value before the SET statement is executed must correspond to the occurrence number of its associated table. ═══ ═══ Sending field. Must be either an index data item or an elementary numeric integer item. ═══ ═══ Sending field. Must be a positive integer. ═══ ═══ This index-name value both before and after the SET statement execution must correspond to the occurrence numbers in an associated table. ═══ ═══ This sending field must be an elementary integer data-item. ═══ ═══ This sending field must be an integer. ═══ ═══ Must be associated with an external switch, the status of which can be altered. For Format 3 each mnemonic-name must be associated with an external switch, the status of which can be altered. The only external switches allowed are the UPSI switches, UPSI-0 through UPSI-7. The status of each external switch associated with the specified mnemonic-name is modified such that the truth value resultant from evaluation of a condition-name associated with that switch will reflect an on status if the ON phrase is specified, or an off status if the OFF phrase is specified. ═══ ═══ Must be associated with a conditional variable. ═══ ═══ -----IBM Extension----- Receiving fields. Must be described as USAGE IS POINTER. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Receiving fields. This is the ADDRESS OF special register. Must be a level-01 or level-77 item defined in the Linkage Section. It is set to the value of the operand specified in the TO phrase. It cannot be subscripted or reference modified. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Sending field. Must be described as USAGE IS POINTER. Must not contain an address within the program's own Working-Storage or File section. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Sending field. Must be an item in the data division section of any level except 66 or 88. ADDRESS OF identifier-7 contains the address of the identifier, rather than its contents. Identifier-7 can be subscripted, reference modified, or both. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Sending field. Sets the receiving field to contain the value of an invalid address. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Procedure-pointer-data-item-1 is the receiving field. They must be described as USAGE IS PROCEDURE-POINTER. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Must be defined as an alphanumeric item such that the value can be a program name. (For more information, see PROGRAM-ID Paragraph.) The procedure-pointer data item is set to the outermost COBOL program (an ILE procedure) of the same compilation unit, or to the program object (*PGM), named in identifier-1. The contents of the identifiers are affected by the *MONOPRC option of the CRTCBLMOD or CRTBNDCBL command. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Must be nonnumeric and must conform to the rules for formation of program-names. The literals are affected by the *MONOPRC option of the CRTCBLMOD or CRTBNDCBL command. The procedure-pointer data item can be set to the outermost COBOL program (an ILE procedure) of the same compilation unit, the outermost COBOL program (an ILE procedure) in another compilation unit, an ILE procedure (written in another ILE language), or a program object (*PGM). The procedure-pointer data item cannot be set to a nested COBOL program even if the nested COBOL program of the specified name is visible from the point of SET. The LINKAGE TYPE phrase of the ENTRY clause, along with the LINKAGE TYPE clause of the SPECIAL-NAMES paragraph and the LINKLIT parameter of the CRTCBLMOD or CRTBNDCBL command determine the type of object that the procedure-pointer data item is set to. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The LINKAGE TYPE phrase is used to specify the type of program that the procedure-pointer data item is set to. It could be set to the address of a separately compiled program object (*PGM) or a procedure within a program. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The type of program that procedure-pointer-data-item-1 will be set to. Environment-name-1 can be defined as:  PGM (a program object, or *PGM)  PRC (a procedure) ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Procedure-pointer-data-item-1 is set to a program object (*PGM). ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Procedure-pointer-data-item-1 is set to a procedure. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Sets the receiving field to contain the value of an invalid address. ---End of IBM Extension--- ═══ ═══ The name given in the SD entry that describes the records being sorted. ═══ ═══ Specifies a KEY data item on which the sort will be based. Each such data-name must identify a data item in a record associated with file-name-1. The following rules apply:  A specific KEY data item must be physically located in the same position and have the same data format in each input file. However, it need not have the same data-name.  If file-name-1 has more than one record description, then the KEY data items need be described in only one of the record descriptions.  If file-name-1 contains variable length records, all of the KEY data-items must be contained within the first n character positions of the record, where n equals the maximum record size specified for file-name-1.  KEY data items must not contain an OCCURS clause or be subordinate to an item that contains an OCCURS clause.  The total length of the KEY data item must not exceed 2 000 bytes.  KEY data items can be qualified, but they cannot be subscripted or indexed. -----IBM Extension-----  KEY data items can be reference modified, but they cannot be subscripted or indexed. ---End of IBM Extension---  Variable length fields can not be used in a SORT key as a variable length field. Variable length fields are converted into group items by ILE COBOL/400. Since variable length fields are converted into group items, they are compared as alphanumeric data items when used in a SORT key.  Date, time, and timestamp fields can not be used as part of a SORT key as date, time, and timestamp fields. In ILE COBOL/400, date, time, and timestamp fields are converted to alphanumeric data items. They are compared as alphanumeric data items when used in a SORT key. SORT lists the KEY data items from left to right in order of decreasing significance, no matter how they are divided into KEY phrases. The leftmost data-name is the major key, the next data-name is the next most significant key, and so forth. ═══ ═══ Must be specified in the alphabet-name clause of the SPECIAL-NAMES paragraph. Any one of the alphabet-name clause options may be specified. See SPECIAL-NAMES Paragraph for a list of alphabet-name clause options and their meanings. ═══ ═══ The input files. ═══ ═══ Specifies the first (or only) section or paragraph in the input procedure. ═══ ═══ Specifies the last section or paragraph in the input procedure. ═══ ═══ The output files. ═══ ═══ Specifies the first (or only) section or paragraph in the output procedure. ═══ ═══ Identifies the last section or paragraph in the output procedure. ═══ ═══ Must be a file with sequential or dynamic access. File-name-1 must be defined in an FD entry in the Data Division, and must not name a sort file. ═══ ═══ Can be qualified or reference modified, but it cannot be subscripted. -----IBM Extension----- Multiple data-names may be specified. All data-names, following the initial data-name, are syntax checked only. ---End of IBM Extension--- ═══ ═══ May be numeric, nonnumeric or Boolean, and may be any figurative constant except ALL literal. If the literal is numeric, it must be an unsigned integer. ═══ ═══ Represents the sending field(s). When the sending field or any of the delimiters is an elementary numeric item, it must be described as an integer, and its PICTURE character-string must not contain the symbol P. ═══ ═══ Represents the sending field(s). All literals must be nonnumeric literals; each may be any figurative constant without the ALL literal. When a figurative constant is specified, it is considered a 1-character nonnumeric literal. ═══ ═══ The DELIMITED BY phrase sets the limits of the string. ═══ ═══ Are delimiters; that is, character(s) that delimit the data to be transferred. If identifier-1 or identifier-2 occupies the same storage area as identifier-3 or identifier-4, undefined results will occur, even if the identifiers are defined by the same data description entry. When a figurative constant is specified, it is considered a 1-character nonnumeric literal. ═══ ═══ Transfers the complete sending area. ═══ ═══ Represents the receiving field. It must not represent an edited data item and must not be described with the JUSTIFIED clause. It must not be reference modified. If identifier-3 and identifier-4 occupy the same storage area, undefined results will occur, even if the identifiers are defined by the same data description entry. ═══ ═══ Represents the pointer field, which points to a character position in the receiving field. It must be an elementary integer data item large enough to contain a value equal to the length of the receiving area plus 1. The pointer field must not contain the symbol P in its PICTURE character-string. ═══ ═══ In Formats 1 and 2, identifier-1 and identifier-2 must be elementary numeric items. In Format 2, each identifier-3 following the word GIVING must be a numeric or numeric-edited elementary item. In Format 3, identifier-1 must be a group item. ═══ ═══ Must be a numeric literal. ═══ ═══ The CORRESPONDING phrase (CORR) allows operations to be performed on elementary numeric data-items of the same name if the group items to which they belong are specified. ═══ ═══ This explicit scope terminator delimits the scope of the SUBTRACT statement. END-SUBTRACT converts a conditional SUBTRACT statement into an imperative statement so that it can be nested in another conditional statement. For more information, see Delimited Scope Statements. ═══ ═══ Represents the sending field. It must be an alphanumeric data item; it cannot be reference modified. Data is transferred from this field to the receiving fields. ═══ ═══ Each represents one delimiter. Each must be an alphanumeric data item. ═══ ═══ Each must be a nonnumeric literal; each may be any figurative constant except the ALL literal. When a figurative constant is specified, it is considered to be a 1-character nonnumeric literal. ═══ ═══ One or more contiguous occurrences of any delimiters are treated as if they were only one occurrence, and this one occurrence is moved to the delimiter receiving field (if specified). The delimiting characters in the sending field are treated as an elementary alphanumeric item and are moved into the current delimiter receiving field, according to the rules of the MOVE statement. When DELIMITED BY ALL is not specified, and two or more contiguous occurrences of any delimiter are encountered, the current data receiving field is filled with spaces or zeros, according to the description of the data receiving field. ═══ ═══ represents the data receiving fields. Each must have USAGE DISPLAY. These fields can be defined as:  Alphabetic  Alphanumeric  Numeric (without the symbol P in the PICTURE string). ═══ ═══ Identifier-5 represents the delimiter receiving fields. Identifier-5 must be alphanumeric. The DELIMITER IN phrase can be specified only if the DELIMITED BY phrase is specified. The identifiers must not be defined as alphanumeric edited or numeric edited items. ═══ ═══ Identifier-6, an integer data-item defined without the symbol P in the PICTURE string, is the data-count field for each data transfer. Each field holds the count of examined characters in the sending field, terminated by the delimiters or the end of the sending field, for the move to this receiving field; the delimiters are not included in this count. The COUNT IN phrase must not be specified unless the DELIMITED BY phrase is specified. ═══ ═══ Identifier-7, an integer data-item defined without the symbol P in the PICTURE string, contains a value that indicates a relative position in the sending field. When this phrase is specified, the user must initialize this field before execution of the UNSTRING statement is begun. ═══ ═══ Identifier-8 is the field-count field, initialized by the user through an integer data-item defined without the symbol P in the PICTURE string, and increased by the number of data receiving fields acted upon in this execution of the UNSTRING statement. ═══ ═══ This explicit scope terminator serves to delimit the scope of the UNSTRING statement. END-UNSTRING permits a conditional UNSTRING statement to be nested in another conditional statement. END-UNSTRING may also be used with an imperative UNSTRING statement. For more information, see Delimited Scope Statements. ═══ ═══ Must be defined in a Data Division FD entry. Record-name-1 may be qualified. It must not be associated with a sort or merge file. ═══ ═══ When FROM is specified, the result is the same as: MOVE identifier-1 TO record-name-1 WRITE record-name-1 The move is performed according to the rules of the MOVE statement, without the CORRESPONDING phrase. After the WRITE statement is executed, the information is still available in identifier-1, even though it may not be in record-name-1. (See INTO/FROM Identifier Phrase.) ═══ ═══ Must be an alphanumeric or numeric edited data item. Data is transferred from this field to the receiving fields. ═══ ═══ Must be an integer data item. ═══ ═══ This explicit scope terminator serves to delimit the scope of the WRITE statement. END-WRITE permits a conditional WRITE statement to be nested in another conditional statement. END-WRITE may also be used with an imperative WRITE statement. For more information, see Delimited Scope Statements. ═══ ═══ Must be defined in a Data Division FD entry. Record-name-1 may be qualified. It must not be associated with a sort or merge file. In the case of relative files, only, the number of character positions in record-name-1 must equal the number of character positions in the record being replaced. It must not be associated with a sort or merge file. ═══ ═══ When FROM is specified, the result is the same as: MOVE identifier-1 TO record-name-1 WRITE record-name-1 After the WRITE statement is executed, the information is still available in identifier-1, even though it may not be in record-name-1. (See INTO/FROM Identifier Phrase.) ═══ ═══ Must be an alphanumeric or numeric-edited data item. Data is transferred from this field to the receiving fields. Record-name-1 and identifier-1 cannot both refer to the same storage area. ═══ ═══ If the NOT INVALID KEY phrase is specified and a valid key condition exists at the end of the execution of the WRITE statement, control is passed to the imperative statement associated with this phrase. ═══ ═══ This explicit scope terminator serves to delimit the scope of the WRITE statement. END-WRITE permits a conditional WRITE statement to be nested in another conditional statement. END-WRITE may also be used with an imperative WRITE statement. For more information, see Delimited Scope Statements. ═══ ═══ -----IBM Extension----- See Format 4 for general considerations concerning the TERMINAL phrase. The TERMINAL phrase specifies which program device's subfile is to have a record written to it. If the TERMINAL phrase is specified, literal-2 or identifier-3 must refer to a workstation associated with the TRANSACTION file. If literal-2 or identifier-3 contains a value of blanks, the TERMINAL phrase is treated as if it was not specified. The workstation specified by the TERMINAL phrase must have been acquired, either explicitly or implicitly. If the TERMINAL phrase is omitted, the subfile used is the subfile associated with the default program device. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The INVALID KEY condition exists if a record is already in the subfile with that record number, or if the relative record number specified is greater than the maximum allowable subfile record number. The INVALID KEY phrase should be specified in the WRITE SUBFILE statement for all files for which an appropriate USE procedure is not specified. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- This phrase allows you to specify procedures that will be performed when an invalid key condition does not exist for the statement that is used. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- This explicit scope terminator serves to delimit the scope of the WRITE statement. END-WRITE permits a conditional WRITE statement to be nested in another conditional statement. END-WRITE may also be used with an imperative WRITE statement. For more information, see Delimited Scope Statements. ---End of IBM Extension--- ═══ ═══ The text-name is the name of the member to be copied. The text-name must begin with an alphabetic character. The first 10 characters of the text-name are used as the member name; these first 10 characters must, therefore, be unique within one file. Text-name can be qualified by the library-name and file-name in which it resides. If no file-name is specified, QCBLLESRC is assumed as the file-name. If the copy member is not found in default file QCBLLESRC then file QLBLSRC is searched next for the copy member. If the file-name is not qualified by a library-name, file-name is assumed to reside in a library in the library list. A hyphen is required between library-name and file-name, with no intervening spaces. For example, to qualify file MYFILE in library MYLIB code as MYLIB-MYFILE. The library-name, file-name, and text-name must follow the rules for formation of a program-name. ═══ ═══ The first 10 characters of the library-name are used as the identifying name; these first 10 characters must therefore be unique within the system. To qualify file-name, a hyphen is required between library-name and file-name with no intervening spaces. ═══ ═══ -----IBM Extension----- The SUPPRESS phrase causes a COPY statement to suppress the listing of copied statements. For its duration, this type of COPY statement overrides any *CONTROL or *CBL statement. If the copied member contains *CONTROL or *CBL statements, the last one runs once the COPY member has been processed. For a nested COPY statement, SUPPRESS is in effect only until the next COPY is encountered. Suppression resumes after the nested COPY is completed. ---End of IBM Extension--- ═══ ═══ A sequence of character-strings and/or separators bounded by, but not including, pseudo-text delimiters (==). Both characters of each pseudo-text delimiter must appear on one line; however, character-strings within pseudo-text can be continued. Because of the replacement rules, the continued line of pseudo-text-2 can begin in Area A. A character-string for pseudo-text can consist of single-byte characters of any kind. The prefix portion of a data name, however, cannot be replaced using pseudo-text unless the entire data name is used. Pseudo-text-1 must not be null, nor may it consist solely of the space character, separator comma, separator semicolon, and/or of comment lines. Beginning and ending blanks are not included in the text comparison process. Embedded blanks are used in the text comparison process to indicate multiple text words. Pseudo-text-2 may be null; it may consist solely of space characters and/or comment lines. Each text word in pseudo-text-2 that is to be copied into the program is placed in the same area of the resultant program as the area in which it appears in pseudo-text-2. ═══ ═══ May be defined in any Data Division section. ═══ ═══ May be numeric or nonnumeric. ═══ ═══ May be any single COBOL word (except COPY). ═══ ═══ -----IBM Extension----- The DD option or the ALIAS option is used to reference alias (alternate) names. The specification of an alias name in DDS allows a data name of up to 30 characters to be included in the COBOL program. When the DD option or the ALIAS option is used, any alias names present replace the corresponding DDS field names. All underscores in the alias names are translated into hyphens before any replacing occurs. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The DDR option or the SUBSTITUTE option does everything that the DD option does. It also replaces the invalid COBOL characters @, #, $, and _ in a field name (or alias name, if applicable) with the corresponding valid COBOL characters A, N, D, and -. As well, it removes underscores from the end of a field name. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The DDS option copies in the internal DDS format field names. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The DDSR option does everything that the DDS option does. It also copies the internal DDS format field names, replacing the invalid COBOL characters @, #, $, and _ with the valid COBOL characters A, N, D, and - accordingly. This option also removes any underscores from the ends of the field names. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The format-name is the name of the DDS record format definition that is to be translated into COBOL data description entries. The format-name must follow the rules for formation of any AS/400 name. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The VLR option specifies copying from variable-length records. Specify the CVTOPT(*VARCHAR) option on the CRTCBLMOD or CRTBNDCBL command to make variable-length records accessible to your program. (DBCS data is not allowed.) ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- The PREFIX options allows you to specify a prefix (literal) to be inserted in front of every field name. You can use it to help identify (that is, document) the contents or usage of the field. The literal can be contained within a pair of apostrophes or a pair of quotation marks. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- If ALL-FORMATS is specified without the indicator attribute, each record format is generated as a redefinition of a 05 elementary item defined as either:  the size of the largest record format in the file, if the COPY statement appears in the FILE SECTION.  the size of the largest record format that will be generated, if the COPY statement appears outside of the FILE SECTION. When the indicator attribute is specified, no redefinition takes place. Instead, each of the formats generates a separate data structure. For details, refer to INDICATOR Attribute of the Format 2 COPY Statement. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- File-name is the name of an AS/400 system file. The generated DDS entries represent the record format(s) defined in the file. The file must be created before the program is compiled. ---End of IBM Extension--- ═══ ═══ -----IBM Extension----- Library-name is optional. If it is not specified, the current job library list is used as the default value. ---End of IBM Extension--- ═══ ═══ Can contain one or more of the following:  Text words  Separator is comma, or semicolon followed by a space  The word COPY, if it begins a valid COPY statement Character strings can be continued. ═══ ═══ -----IBM Extension----- Must be nonnumeric and may be followed by a separator period. Must not be a figurative constant. ---End of IBM Extension--- ═══ ═══ Valid for all files. When this option is specified, the procedure is executed only for the file(s) named. No file-name can refer to a sort or merge file. For any given file, only one EXCEPTION/ERROR procedure may be specified; thus, file-name specification must not cause simultaneous requests for execution of more than one EXCEPTION/ERROR procedure. -----IBM Extension----- The file-name phrase is also valid for TRANSACTION files. ---End of IBM Extension--- A USE AFTER EXCEPTION/ERROR declarative statement specifying the name of a file takes precedence over a declarative statement specifying the open mode of the file. ═══ ═══ Valid for all files. When this option is specified, the procedure is executed for all files opened in INPUT mode that get an error. ═══ ═══ Valid for all files. When this option is specified, the procedure is executed for all files opened in OUTPUT mode that get an error. ═══ ═══ Valid for all direct-access files. When this option is specified, the procedure is executed for all files opened in I-O mode that get an error. -----IBM Extension----- The I-O phrase is also valid for TRANSACTION files. ---End of IBM Extension--- ═══ ═══ When this option is specified, the procedure is executed for all files opened in EXTEND mode that get an error.