HP 3000 Manuals

General Formats (Continued) [ Micro Focus COBOL Language Reference ] MPE/iX 5.0 Documentation


Micro Focus COBOL Language Reference

General Formats (Continued) 

The CANCEL Statement 

Function.   

The CANCEL statement ensures that the next time the referenced program is
called it will be in its initial state.

General Format.   

[]
Syntax Rules. 1. Literal-1 must be a nonnumeric literal. 2. Identifier-1 must reference an alphanumeric data item. General Rules. 1. Literal-1 or the content of the data item referenced by identifier-1 identifies the program to be canceled. The name must contain the program-name contained in the PROGRAM-ID paragraph of the program to be canceled (see The Program_ID Parargraph earlier in this chapter, particularly in regard to case sensitivity). Alternatively, the name may identify a file that contains executable program code for the program to be canceled. The results of psecifying different names that identify the same file in a CANCEL statement are operating system specific. See your COBOL System Reference for details of how your system matches the given name ot previously called programs held in library files. If the name conatins the entry-name contained in an ENTRY statement, the results are undefined. 2. Subsequent to the execution of an explicit or implicit CANCEL statement, the program referred to therein ceases to have any logical relationship to the run unit in which the CANCEL statement appears. If the program referenced by a successfully executed explicit or implicit CANCEL statement in a run unit is subsequently called in that run unit, that program is in its initial state. See the section Initial State Of A Program earlier in this chapter. 3. A program named in a CANCEL statement in another program must be callable by that other program. See the sections Scope Of Names and The CALL Statement, earlier in this chapter. 4. For ANS85 only: When an explicit or implicit CANCEL statement is executed, all programs contained in the program referenced by the CANCEL statement are also cancelled. The result is the same as if a valid CANCEL statement were executed for each contained program in the reverse order in which the programs appear in the separate program . 5. A program named in the CANCEL statement must not refer directly or indirectly to any program that has been called and has not yet executed an EXIT PROGRAM or GOBACK (OSVS, VSC2 and MF only) statement. 6. A logical relationship to a cancelled program is established only by execution of a subsequent CALL statement naming that program. 7. A called program is cancelled either by being referred to as the operand of a CANCEL statement, by the termination of the run unit of which the program is a member, or by execution of an EXIT PROGRAM statement in a called program that possesses the initial attribute (ANS85 only). 8. No action is taken when an explicit or implicit CANCEL statement is executed naming a program that has not been called in this run unit has been called and is at present cancelled or is a non-COBOL program. Control is transferred to the next executable statement following the CANCEL statement. 9. For ANS85 only: The contents of data items in external data records described by a program are not changed when that program is cancelled . 10. During execution of an explicit or implicit CANCEL statement, an implicit CLOSE statement without any optional phrases is executed for each file in the open mode that is associated with an internal file connector in the program named in the CANCEL statement. Any USE procedures associated with any of these files are not executed (ANS85). 11. The CANCEL statement determines whether or not a subprogram will be re-entered in initial or last-used state. It does not necessarily free any memory used by the subprogram. However, in many operating systems, if the subprogram has been dynamically loaded, this statement will also free the memory originally used by the subprogram. EXTERNAL files and data areas of the subprogram are never freed by a CANCEL statement. For MF only: The CHAIN Statement Function. The CHAIN statement transfers control from one object program to another in the run unit with no subsequent return of control. The effect is as though the chained program is the main program in the new run unit. General Format.
[]
Syntax Rules. 1. The syntax of the CHAIN statement is similar to the syntax of the CALL statement and the two are subject to common syntax rules as indicated in the section The CALL Statement. All the identifiers, literals and integers in the general format of the CHAIN statement correspond to the identifiers, literals and integers of the CALL statement. General Rules. 1. Literal-1 or the content of the data item referenced by identifier-1 is the name of the chained program. The program in which the CHAIN statement appears is the chaining program. The chained program must be a COBOL program that is not a nested program. The name of the chained program must contain the name contained in the PROGRAM-ID paragraph of the chained program (see The Program-ID Paragraph earlier in this chapter particularly in regard to case sensitivity). Alternatively, the name of the chained program may contain a name which identifies a file that contains executable program code for the chained program. See your COBOL System Reference for details of how your system matches the given name to previously chained programs, program filenames or programs held in library files. 2. If, when a CHAIN statement is executed, the program specified by the CHAIN statement is made available for execution, control is transferred to the chained program, and the chaining program, together with any COBOL programs called by the chaining program, are canceled. The chained program is not under the control of a chaining program and so any EXIT PROGRAM executed within the chained program has no effect. 3. If, when a CHAIN statement is executed, the program specified by the CHAIN statement is not made available for execution, thena fatal run time error is given. 4. Chained programs can contain CHAIN statements. A CHAIN statement within a chained program may reference any program except itself. 5. The form of the CHAIN statement is similar to the form of the CALL statement and the two are subject to common general rules as indicated in the section The CALL Statement. All the identifiers, literals and integers in the general format of the CHAIN statement correspond to the identifiers, literals and integers of the CALL statement. Also, where the expressions calling program and called program are used, these can be considered equivalent to the expressions chaining program and chained program. 6. The chain operation moves the value from each data item referenced in the USING phrase of the CHAIN statement to the data item referenced by the corresponding data-name in the USING phrase of the PROCEDURE DIVISION header of the chained program. 7. The value of any data item with USAGE POINTER or USAGE PROCEDURE-POINTER that is passed as an operand in the USING phrase must not represent the address that was originally derived from a COBOL data item. 8. The END-CHAIN phrase delimits the scope of the CHAIN statement. 9. The USING phrase must not be used if you have specified the system directive INTLEVEL"1". The CLOSE Statement Function. The CLOSE statement terminates the processing of reels/units and files, with optional rewind and/or lock or removal where applicable. General Formats. Format 1 (Record Sequential Files).
[]
Format 2 (Line Sequential - MF only), (Relative and Indexed Files - ANS85 only).
[]
Syntax Rules. All Formats (All Files). 1. The files referenced in the CLOSE statement need not all have the same organization or access. Format 1 (Record Sequential Files). 2. For MF only: The REEL and UNIT phrases should be specified only for files which have had MULTIPLE REEL or MULTIPLE UNIT specified in their SELECT clause. If your run-time system does not recognize multi-unit files, the statements CLOSE REEL and CLOSE UNIT are "null" statements; that is, they are documentary only. It is important that no other files are open on the device(s) closed by a CLOSE REEL or CLOSE UNIT statement. For OSVS only: The statements CLOSE REEL WITH LOCK and CLOSE UNIT WITH LOCK are treated as equivalent to CLOSE REEL FOR REMOVAL. 3. For OSVS only: The DISP option is applicable only to tape files. For MF only: It is documentary only. General Rules. All Formats (All Files). 1. A CLOSE statement can be executed only for a file in an open mode. 2. Following the successful execution of a CLOSE statement the record area associated with file-name-1 is no longer available. The unsuccessful execution of such a CLOSE statement leaves the availability of the record area undefined. 3. For ANS85 only: If a file is in the open mode when a STOP RUN statement is executed the file will be closed. If a file has been opened in a called program and not closed in that program prior to the execution of a CANCEL statement for the program that file will be closed . 4. For MF only: Following the successful execution of a CLOSE statement, all record or file locks held by the run unit on the closed file are released. 5. The execution of the CLOSE statement causes the value of the I/O status associated with file-name-1 to be updated. (See the section I/O Status earlier in this chapter.) 6. The results of executing each type of CLOSE statement for each category of file are summarized in Table 4-12. Table 4-12 : Relationship of Categories of Files and the Formats of the CLOSE Statement ---------------------------------------------------------------- | | | | CLOSE | File Category | | Statement | | | Format | | | | | ---------------------------------------------------------------- | | | | | | | | Non-Reel/ | Record | Record | Non- | | | Unit | Sequential| Sequential| record | | | | Single- | Multi- | Sequential| | | | Reel/ | Reel/ | Single/ | | | | Unit | Unit | Multi- | | | | | | Reel/ | | | | | | Unit | | | | | | | ---------------------------------------------------------------- | | | | | | | CLOSE | C | C, G | A, C, G | C | | | | | | | ---------------------------------------------------------------- | | | | | | | CLOSE WITH | C, E | C, E, G | A, C, E, | C, E | | LOCK | | | G | | | | | | | | ---------------------------------------------------------------- | | | | | | | CLOSE WITH | C*, H* | B, C | A, B, C | X | | NO REWIND | | | | | | record | | | | | | sequential | | | | | | only | | | | | | | | | | | ---------------------------------------------------------------- | | | | | | | CLOSE | F* | F*, G* | F, G | X | | REEL/UNIT | | | | | | record | | | | | | sequential | | | | | | only | | | | | | | | | | | ---------------------------------------------------------------- | | | | | | | CLOSE | F* | D*, F*, | D, F , G | X | | REEL/UNIT | | G* | | | | FOR REMOVAL | | | | | | record | | | | | | sequential | | | | | | only | | | | | | | | | | | ---------------------------------------------------------------- | | | | | | | CLOSE | X | X | F, B | X | | REEL/UNIT | | | | | | WITH NO | | | | | | REWIND | | | | | | record | | | | | | sequential | | | | | | only | | | | | | | | | | | ---------------------------------------------------------------- * ANS85 The definitions of the symbols in the table are given below. Where the definition depends on whether the file is an input, output or input- output file, alternate definitions are given; otherwise, a definition applies to input, output, and input-output files. A. Previous Reels/Units Unaffected Input Files and Input-Output Files: All reels/units in the file prior to the current reel/unit are processed except those reels/units controlled by a prior CLOSE REEL/UNIT statement. If the current reel/unit is not the last in the file, the reels/units in the file following the current one are not processed. Output Files: All reels/units in the file prior to the current reel/unit are processed except those reels/units controlled by a prior CLOSE REEL/UNIT statement. B. No Rewind of Current Reel The current reel/unit is left in its current position. C. Close File Input Files and Input-Output Files (Sequential Access Mode): If the file is at the end and label records are specified for the file, the labels are processed according to the operating system label convention. The behavior of the CLOSE statement when label records are specified but not present, or when label records are not specified but are present, is undefined. If the file is at the end and label records are not specified for the file, label processing does not take place, but other closing operations dependent on the run-time system are executed. (See your COBOL System Reference.) If the file is not at the end, the closing operations dependent on the RTS are executed, but there is no ending label processing. Input Files and Input-output Files (Random or Dynamic Access Mode); Output Files (Random, Dynamic or Sequential Access Mode): If label records are specified for the file, the labels are processed according to the operating system standard label convention. The behavior of the CLOSE statement when label records are specified but not present, or when label records are not specified but are present, is undefined. If label records are not specified for the file, label processing does not take place, but other closing operations dependent on the run-time system are executed. D. Reel/Unit Removal The reel or unit can be accessed again, in the proper order of reels or units in the file, if a CLOSE statement without the REEL or UNIT phrase has previously been executed for this file followed by the execution of an OPEN statement for the file. E. File Lock This file cannot be opened again during this execution of this run unit. F. Close Reel/Unit Input Files and Input-Output Files (Reel/Unit Media): 1. For ANS85 only: If the current reel/unit is the last or only reel/unit for the file, no reel/unit swap takes place; the current volume pointer remains unchanged, and the file position indicator is set to indicate that no next reel/unit exists . 2. If another reel/unit exists for the file, a reel/unit swap occurs, the current volume pointer is updated to point to the next reel/unit existing in the file, the standard beginning reel/unit label procedure is executed, and the file position indicator is set to one less than the number of the first record existing on the new current volume. If no data records exist for the current volume, another reel/unit swap occurs. Output Files (Reel/Unit Media): The following operations take place; 1. Execution of the standard ending reel/unit label procedure. 2. A reel/unit swap. 3. Execution of the standard beginning reel/unit label procedure. 4. The next executed WRITE statement that references that file directs the next logical data record to the next reel/unit of the file. For ANS85 only: Input Files, Input-Output Files, and Output Files (Non-Reel/Unit Media): Execution of this statement is considered successful. The file remains in the open mode, the file position indicator remains unchanged, and no action takes place except as specified in General Rule 4. G. Rewind The current reel or analogous device is positioned at its physical beginning. H. For ANS85 only: Optional Phrases Ignored (ANS85) The CLOSE statement is executed as if none of the optional phrases is present. X. Illegal This is an illegal combination of a CLOSE option and a file category. The results at object time are undefined. Format 1 (Record Sequential Files). Except where otherwise stated in the general rules below, the terms "reel" and "unit" are equivalent and completely interchangeable in the CLOSE statement. Treatment of sequential mass storage files is logically equivalent to the treatment of a file on tape or analogous sequential media. 1. In order to show the effect of various types of CLOSE statements as applied to various storage media, all files are divided into the following categories: a. Non-reel/unit. A file whose input or output medium is such that the concepts of rewind and reels/units have no meaning. b. Sequential single-reel/unit. A sequential file that is entirely contained on one reel/unit. c. Sequential multi-reel/unit. A sequential file that is contained on more than one reel/unit. 2. If the OPTIONAL phrase has been specified for the file in the FILE-CONTROL paragraph of the Environment Division and the file is not present, the standard end-of-file processing is not performed for that file. 3. If a CLOSE statement without the REEL or UNIT phrase has been executed for a file, no other statement (except the SORT or MERGE statements with the USING or GIVING phrases) can be executed that references that file, either explicitly or implicitly, unless an intervening OPEN statement for that file is executed. 4. The WITH NO REWIND and FOR REMOVAL phrases will have no effect at object time if they do not apply to the storage media on which the file resides. 5. If WITH LOCK is specified, the file cannot be reopened during the current execution of the run unit. Otherwise a normal CLOSE takes effect. For MF only: This option has no connection with the record or file locking used when sharing files. All Formats (All Files). 6. If a CLOSE statement has been executed for a file, no statement other than a delete file (MF only) can be executed that references that file, either explicitly or implicitly, unless an intervening OPEN statement for that file is executed. 7. If WITH LOCK is specified, the file cannot be reopened during the current execution of the run unit. For MF only: The COMMIT Statement Function. The COMMIT statement releases all record locks in all files held by this run unit. For COBOL systems that support the WITH...ROLLBACK clause of the SELECT statement as other than documentary, COMMIT indicates the end of the current transaction and makes the effects of that transaction permanent. General Format.
[]
General Rules. 1. Execution of the COMMIT statement causes all record locks in all files held by the run unit to be released. 2. The file lock on an exclusive file is not affected by the COMMIT statement. 3. If your COBOL system supports the WITH...ROLLBACK clause of the SELECT statement as other than documentary, then the COMMIT verb: a. Indicates completion of the current transaction b. Makes all changes applied during the transaction permanent. The COMPUTE Statement Function. The COMPUTE statement assigns to one or more data items the value of an arithmetic expression. General Format.
[]
Syntax Rules. 1. For OSVS, VSC2, and MF only: Identifiers that appear only to the left of "=" must refer to either an elementary numeric item or an elementary numeric edited item or (a floating-point item). 2. For OSVS, VSC2 and MF only: "Equal" and "=" are synonymous. General Rules. 1. See the sections The ROUNDED Phrase, The ON SIZE ERROR Phrase, Arithmetic Statements, Overlapping Operandsand Multiple Results In Arithmetic Statements in this chapter; and the sections Explicit And Implicit Scope Terminators in the chapter Concepts of the COBOL Language and Delimited Scope Statements in the chapter Concepts of a COBOL Program. 2. An arithmetic expression consisting of a single identifier or literal provides a method of setting the values of identifier-1 equal to the value of the single identifier or literal. 3. The COMPUTE statement allows the user to combine arithmetic operations without the need to explicitly store intermediate results in temporary data items, as would be necessary using the arithmetic statements ADD, SUBTRACT, MULTIPLY and DIVIDE. The expression is evaluated to as many digits as possible, and truncated or rounded to fit into identifier-1. For OSVS and VSC2 only: The intermediate results obtained during the expression evaluation are truncated as if they were moved to data items whose PICTURE is determined by the COBOL system. This behavior is selected using the ARITHMETIC directive. See your COBOL System Reference for details. 4. If more than one identifier is specified for the result of the operation, that is preceding "=", the value of the arithmetic expression is computed, and then this value is stored as the new value of each occurrence of identifier-1 in turn.


MPE/iX 5.0 Documentation