[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
Reference Manual


Previous Contents Index

Format 2---Report Writer Files

  1. A file is available if it is physically present and recognized by the I-O system.
    Table 6-16 shows the results of opening available and unavailable Report Writer files.

    Table 6-16 Opening Available and Unavailable Report Writer Files
    Open Mode File Is Available File Is Unavailable
    OUTPUT Creates a new version of the file The OPEN creates the file
    EXTEND Normal OPEN The OPEN is unsuccessful
    EXTEND
    (optional file)
    Normal OPEN The OPEN creates the file
  2. Successful OPEN statement execution makes the file's record area available to the Report Writer Control System. If the file connector is an external file connector, the file has only one record area for the executable image.
  3. When a file is not in an open mode, no statement that references the file can execute either implicitly or explicitly, except for the OPEN statement.
  4. An OPEN statement for a file-name must execute successfully before an INITIATE statement executes for the file. Table 6-17 shows allowable Report Writer statements by file organization and open mode for Report Writer files.

    Table 6-17 Allowable Statements for Report Writer Files
      Open Mode
    Statement OUTPUT EXTEND
    INITIATE Yes Yes
    GENERATE Yes Yes
    SUPPRESS Yes Yes
    TERMINATE Yes Yes
    All other I-O statements No No (for record I-O only)

Technical Notes

  • OPEN statement execution can result in these FILE STATUS data item values:
    File Status Meaning
    00 Open is successful.
    05 Optional file not present.
    07 No rewind on non-reel device.
    35 File not found.
    37 An open in I-O mode is attempted for a nonmass storage file, or an open is attempted for nonmass storage file that was declared as a relative or indexed file.
    38 An open is attempted on a file closed with lock.
    39 A mismatch exists between the current program's description of an index key and the existent file's description of the key, or (for OpenVMS systems) there is a conflict of maximum record size or record type.
    41 File is already open
    91 Open is unsuccessful; file locked by another access stream.
    95 No file space on device.
    30 All other permanent errors.

    You must use the I-O-CONTROL statement APPLY PREALLOCATION with a value greater than 0 (the default is 0) to enable the detection of "device full" (file status 95) with the OPEN statement.
  • Attempts to specify both X/Open standard and Hewlett-Packard standard file-sharing syntax for the same file connector are invalid. When the compiler cannot detect such attempts because they occur in different compilation units, the run-time system detects and reports the violations (file status 30). This holds for explicit and implicit usage.

Additional References

6.8.25 PERFORM

Function

The PERFORM statement executes one or more intra-program procedures. It returns control to the end of the PERFORM statement when all procedures have completed execution.


first-proc

is a procedure-name that identifies a paragraph or section in the Procedure Division. The set of statements in first-proc is the first (or only) set of statements in the PERFORM range.

end-proc

is a procedure-name that identifies a paragraph or section in the Procedure Division. The set of statements in end-proc is the last set of statements in the PERFORM range.

stment

is an imperative statement.

repeat-count

is a numeric integer literal or the identifier of a numeric integer elementary item. It controls how many times the statement set (or sets) executes.

cond

can be any conditional expression.

var

is an index-name or the identifier of a numeric integer elementary data item. Its value is changed by increm each time all statements in the PERFORM range execute.

init

is a numeric literal, index-name, or the identifier of a numeric elementary data item. It specifies the value of var before any statement in the PERFORM range executes.

increm

is a nonzero numeric literal or the identifier of a numeric elementary data item. It systematically changes the value of var each time the program executes all statements in the PERFORM range.

Syntax Rules

All Formats

  1. If there is no first-proc, the PERFORM statement must contain stment and the END-PERFORM phrase. If there is a first-proc, the statement cannot have the END-PERFORM phrase.
  2. If either first-proc or end-proc is placed in the Declaratives part of the Procedure Division, both must also be placed in the same DECLARATIVES section.
  3. The words THRU and THROUGH are equivalent and interchangeable.

Formats 3 and 4

  1. If there is no TEST BEFORE or TEST AFTER phrase, TEST BEFORE is the default.

Format 4

  1. If there is no first-proc, there can be no AFTER phrase.
  2. If var is an index-name:
    • init must be an integer data item or a positive integer literal
    • increm must be an integer data item or a nonzero integer literal
  3. If init is an index-name:
    • var must be an integer data item
    • increm must be an integer data item or a positive integer literal

General Rules

All Formats

  1. When first-proc appears, the statement is an out-of-line PERFORM statement. Otherwise, it is an in-line PERFORM statement.
  2. The statements in the range of first-proc to end-proc for an out-of-line PERFORM are the statement set. For an in-line PERFORM, the statement set is contained within the scope of the PERFORM...END-PERFORM syntax.
  3. Unless restricted to in-line or out-of-line statements, all General Rules apply to both types of PERFORM statements. An in-line PERFORM statement operates according to the general rules for an out-of-line PERFORM, except for periods, which are not allowed within the body of the PERFORM. The statements in the in-line PERFORM execute in place of the statements in the range of first-proc to end-proc.
  4. When the PERFORM statement executes, control transfers to the first statement of first-proc. However, for Format 2, 3, or 4 PERFORM statements, transfer of control depends on evaluation of the specified condition.
    Transfer of control occurs only once for each PERFORM statement executed. When transfer of control does occur, after the statement set executes, control implicitly transfers back to the to the end of the perform statement as follows:
    • If first-proc is a paragraph-name and there is no end-proc, the return is after the last statement of first-proc.
    • If first-proc is a section-name and there is no end-proc, the return is after the last statement of the last paragraph of first-proc.
    • If end-proc is a paragraph-name, the return is after the last statement of end-proc.
    • If end-proc is a section-name, the return is after the last statement of the last paragraph of end-proc.
    • If the statement is an in-line PERFORM, execution ends after the last statement of the statement set.
  5. first-proc and end-proc need not be related except that first-proc is the beginning and end-proc is the last in a consecutive series of operations.
    GO TO and PERFORM statements can occur between first-proc and end-proc. If there are two or more logical paths to the return point, end-proc can be a paragraph, consisting of the EXIT statement, to which all these paths must lead.
  6. If a statement other than a PERFORM statement, transfers control to the statement set, at the end of the statement set, control transfers through the last statement of the set to the next executable statement following the set as if no PERFORM statement referenced the set.
  7. The range of a PERFORM statement consists of all statements executed as a result of executing the PERFORM. It continues through execution of the implicit control transfer to the end of the PERFORM statement.
  8. The range of the PERFORM statement additionally includes all statements executed as a result of a CALL, EXIT, GO TO, or PERFORM statement. The range the PERFORM statement also includes all statements in the Declaratives Section that can be executed if control is transferred from statements in the range of the PERFORM statement.
  9. Statements executed as the result of a control transfer caused by an EXIT PROGRAM statement are not part of the range when:
    • The EXIT PROGRAM statement is specified in the same program as the PERFORM statement, and
    • The EXIT PROGRAM statement is within the range of the PERFORM statement.
  10. A PERFORM statement in a fixed 6 segment can have only one of the following in its range:
    • Sections and paragraphs completely contained in one or more nonindependent segments
    • Sections and paragraphs completely contained in one independent segment

    However, the PERFORM statement range also includes any Declarative procedures activated during its execution.
  11. A PERFORM statement in an independent 1 segment can have only one of the following in its range:
    • Sections and paragraphs completely contained in one or more nonindependent segments
    • Sections and paragraphs completely contained in the same independent segment as the PERFORM statement itself

    However, the PERFORM statement range also includes any Declarative procedures activated during its execution.
  12. first-proc and end-proc cannot name sections or paragraphs in any other program in the executable image. Statements in other programs are in a PERFORM statement's range only if the range includes a CALL statement.
  13. A PERFORM statement range can contain another PERFORM statement. In that case, the included PERFORM statement's sequence of procedures must be either totally included in, or excluded from, the logical sequence of the first PERFORM statement.
    For example:
    • An active PERFORM statement whose execution point is in the range of another active PERFORM statement must not allow control to pass to the exit of the other active PERFORM.
    • Two or more active PERFORM statements cannot have a common exit.

    Use the check compiler option with the perform keyword to verify at run time that there is no recursive activation of a PERFORM.
    Figure 6-2 shows valid and invalid nested PERFORM statements.
  14. Undocumented results might occur when end-proc precedes first-proc or when first-proc and end-proc are not in the same program segment.

Figure 6-2 Valid and Invalid Nested PERFORM Statements


Note

6 Segmentation is described in Section 6.7. HP COBOL supports segmentation for compatibility with existing applications only. Hewlett-Packard recommends that you do not use segmentation in new applications.


Previous Next Contents Index