CLOSE [ HP Transact Reference Manual ] MPE/iX 5.0 Documentation
HP Transact Reference Manual
CLOSE
Closes an MPE or KSAM file, a data set or database, or a VPLUS forms
file.
Syntax
CLOSE file-name[,option-list];
CLOSE closes and rewinds an MPE or KSAM file or a data set, or closes the
entire database. Except to rewind or set a file or data set to its
beginning, you need not use CLOSE. Transact automatically closes all
files and data sets at the end of a command sequence and at the end of a
program.
You typically use CLOSE to set a file or data set to its beginning when
you are planning to use the STATUS option with a database access verb
that performs serial or reverse serial access. These verbs are FIND,
GET, DELETE, and OUTPUT which have (SERIAL) and (RSERIAL) modifiers. You
would also use CLOSE before a FILE(SORT) statement.
The CLOSE statement has the following special forms:
CLOSE $FORMLIST Closes the spool file used by the VPRINTFORM
intrinsic of VPLUS.
CLOSE $PRINT Closes the print file TRANLIST. This statement is
useful for directing output to the printer using
SET(OPTION) PRINT without terminating your program.
CLOSE $VPLS Closes the terminal block mode and the active VPLUS
forms file, releasing the memory space used by
VPLUS in the DB-DL stack area (Transact/V only).
This relieves the contention for DB-DL stack memory
between VPLUS and other subsystems such as
DSG/3000. Do not use between a SET(FORM) verb and
another forms verb.
For a discussion about using CLOSE during dynamic transactions, see the
"Database Close" section in Chapter 6.
Statement Parts
file-name The file or data set to be closed. If the data set
is not in the home base as defined in the SYSTEM
statement, you must specify the base name in
parentheses as follows:
set-name(base-name)
You can close an entire database by specifying
file-name as a database with the following format:
@[(base-name)]
To close the home base, omit base-name; to close
any other base, specify a base-name.
option-list One or more of the following options separated by
commas:
ERROR=label Suppresses the default error
([item-name]) return that Transact normally
takes. Instead, the program
branches to the statement
identified by label, and the
stack pointer for the list
register is set to the data
item item-name. Transact
generates an error at execution
time if the item cannot be
found in the list register.
The item-name must be a parent.
If you do not specify an item
name, as in ERROR=label();, the
list register is cleared. If
you use an * instead
of item-name, as in
ERROR=label(*);, then the list
register is not touched. For
more information, see
"Automatic Error Handling" in
Chapter 7.
NOMSG Suppresses the standard error
message produced as a result of
a file or database error.
STATUS Suppresses the action defined
in Chapter 7 under "Automatic
Error Handling." You may have
to add status checking to your
code if you use this option.
When STATUS is specified, the
effect of a CLOSE statement is
described by the 32-bit integer
value in the status register:
Status Meaning
Register
Value
0 The CLOSE operation was successful.
>0 For a description of the condition
that occurred, refer to the database
or MPE/KSAM file system error
documentation that corresponds to
the value.
See "Using the STATUS Option"
in Chapter 7.
Examples
You can use the STATUS option with CLOSE to do exit processing on an
error. For example:
CLOSE KSAM-FILE,
STATUS;
IF STATUS <> 0 THEN
GO TO ERROR-CLEANUP;
The statement below closes the file ACCREC. If an error occurs, it passes
control to the statement labeled FIX and sets the list register to
CUST-NAME.
CLOSE ACCREC,
ERROR = FIX (CUST-NAME);
MPE/iX 5.0 Documentation