|
HP COBOL Reference Manual
- Close file
The file is closed.
- Reel/unit removal
The current reel rewinds and is logically
removed from the run unit However, the run unit can access the reel
again in its proper order of reels in the file. To do this, the
executable image must subsequently execute the following:
- A CLOSE statement without the REEL/UNIT phrase for the file
- An OPEN statement for the file
- File lock
The executable image cannot open the file again in
its current execution.
- Close reel/unit
For input and input-output files, if the
current reel is the last or only reel for the file:
- A reel swap does not occur.
- The Current Volume Pointer remains the same.
- The File Position Indicator denotes that there is no next logical
record.
If another reel follows the current reel for the file:
- A reel swap occurs.
- The Current Volume Pointer points to the next reel for the file.
- The File Position Indicator points to the next record in the file.
If there are no records for the current volume, another reel swap
occurs.
For output files (reel/unit media), a reel swap occurs. The Current
Volume Pointer points to the new reel. Executing the next WRITE
statement for the file transfers a logical record to the new reel of
the file. For output files (nonreel/unit media), execution of this
statement is considered successful. The file remains in the open mode
and no action takes place, except as specified in General Rule 2.
- Rewind
The current reel (or device) is positioned to its
physical beginning.
- Optional phrases ignored
The CLOSE statement is executed as if
none of the optional phrases are present.
- Invalid
This is an invalid combination of CLOSE option and file
category. It results in FILE STATUS data item value 30.
Technical Note
CLOSE statement execution can result in these FILE STATUS data item
values:
File Status |
Meaning |
00
|
Successful
|
07
|
CLOSE statement with NO REWIND, REEL/UNIT, or FOR REMOVAL phrase
referenced a file on a nonreel/unit medium
|
30
|
Any other CLOSE error
|
42
|
File never opened, already closed, or not currently open
|
Additional Reference
See Section 6.6.8, I-O Status for more information.
6.8.7 COMPUTE
Function
The COMPUTE statement evaluates an arithmetic expression and stores the
result in one or more data items.
rsult
is the identifier of an elementary numeric item or elementary numeric
edited item. It is the resultant identifier.
arithmetic-expression
is an expression as described in Section 6.4, Arithmetic Expressions.
stment
is an imperative statement executed when a size error condition has
occurred.
stment2
is an imperative statement executed when no size error condition has
occurred.
General Rules
- The arithmetic expression is evaluated. Its value then replaces
the current value of each occurrence of rsult, from left to
right.
- If the arithmetic-expression consists of a single
identifier or literal, the COMPUTE statement behaves like a MOVE
statement with the single identifier or literal acting as the source
operand and each result operand acting as a destination operand.
- For any rsult specification that includes the word
rounded, the value of the expression is rounded before being moved to
rsult.
Additional References
Examples
Each of the examples assume these data descriptions and initial values:
INITIAL VALUES
03 ITEMA PIC 999V99 VALUE 2. 2.00
03 ITEMB PIC 999V99 VALUE 3. 3.00
03 ITEMC PIC 999V99 VALUE 4. 4.00
03 ITEMD PIC 999V99 VALUE 5. 5.00
|
RESULTS
- No rounding:
COMPUTE ITEMC = ITEMC = 2.82
(ITEMA + 6) ** (.1 * ITEMD).
|
- With rounding:
COMPUTE ITEMC ROUNDED = ITEMC = 2.83
(ITEMA + 6) ** (.1 * ITEMD).
|
- The ON SIZE ERROR phrase:
COMPUTE ITEMB = (ITEMA * ITEMD) ** 3 ITEMB = 3.00
ON SIZE ERROR
MOVE 100 TO ITEMC. ITEMC = 100.00
|
- The NOT ON SIZE ERROR phrase:
COMPUTE ITEMB = (ITEMA * ITEMD) ** 2 ITEMB = 100.00
ON SIZE ERROR
MOVE 100 TO ITEMC
NOT ON SIZE ERROR
MOVE 200 TO ITEMC. ITEMC = 200.00
|
6.8.8 CONTINUE
Function
The CONTINUE statement indicates that no executable statement is
present. It causes an implicit control transfer to the next executable
statement.
Syntax Rule
The CONTINUE statement can be used wherever a conditional or imperative
statement can be used.
General Rule
The CONTINUE statement causes an implicit control transfer to the next
executable statement.
Example
READ FILE-A
INVALID KEY
CONTINUE.
MOVE ...
|
This example shows how CONTINUE can replace an INVALID KEY imperative
statement. Control passes to the MOVE statement whether or not the
INVALID KEY condition occurs.
6.8.9 DELETE
Function
The DELETE statement logically removes a record from a mass storage
file.
file-name
is the name of a relative or indexed file described in the Data
Division. It cannot be the name of a sequential or line sequential file
or a sort or merge file.
stment
is one or more imperative statements executed for an invalid key
condition.
stment2
is one or more imperative statements executed for a not invalid key
condition.
Syntax Rules
- There cannot be an INVALID KEY phrase or a NOT INVALID KEY phrase
for a DELETE statement that references a file in sequential access mode.
- There must be an INVALID KEY phrase if: (a) the file is not in
sequential access mode and (b) there is no applicable USE AFTER
EXCEPTION procedure.
General Rules
- The file must be open in I-O mode when the DELETE statement
executes.
- For a file in sequential access mode, a successfully executed READ
statement must be the last input-output statement executed for the file
before the DELETE statement. The I/O system logically removes the
record that the READ statement accessed.
- For a relative file in random or dynamic access mode, the I/O
system logically removes the record identified by the file's RELATIVE
KEY data item. If the file does not contain that record, an invalid key
condition exists.
- For an indexed file in random access mode, the I/O system
(logically removes the record identified by the file's primary record
key data item. If the file does not contain that record, an invalid key
condition exists.
- For an indexed file in dynamic access mode, the behavior depends
on the DUPLICATES phrase of the RECORD KEY clause of the SELECT
statement. If the primary key allows duplicates, Rule 2 applies. If the
primary key does not allow duplicates, Rule 4 applies.
- After successful DELETE statement execution, the identified record
has been logically removed from the file. It is no longer accessible.
- DELETE statement execution does not affect the contents of the
record area. It also does not affect the contents of the data item
referred to in the DEPENDING ON phrase of the file's RECORD clause.
- For sequential access files, DELETE statement execution does not
affect the File Position Indicator.
- For dynamic access files, the File Position Indicator can point to
the record to be deleted before the DELETE statement executes. In this
case, once the DELETE statement executes, the File Position Indicator:
- Points to a relative file's next existing record
- Points to an indexed file's next existing record, as
established by the Key of Reference
- Indicates the at end condition if the file has no next record
In all other cases, the File Position Indicator is not affected by
the execution of a DELETE statement.
- DELETE statement execution updates the value of the FILE STATUS
data item for the file.
- If there is an applicable USE AFTER EXCEPTION procedure, it
executes whenever an input or output condition occurs that would result
in a nonzero value in the first character of a FILE STATUS data item.
However, it does not execute if the condition is invalid key, and there
is an INVALID KEY phrase. If the condition is not invalid key and no
applicable USE AFTER EXCEPTION Declarative procedure exists, the run
unit terminates abnormally.
|