  | 
		
HP COBOL Reference Manual
 
 
6.8.39 TERMINATE
Function
 
 
The TERMINATE statement causes the Report Writer Control System (RWCS)
to complete the processing of the specified report.
  
 
report-name
names a report defined by a Report Description entry in the Report
Section of the Data Division.
 
General Rules
 
 
  - If the TERMINATE statement includes more than one
  report-name, the statement executes as if there were a
  separate TERMINATE statement for each report-name.
  
 - The program cannot execute a TERMINATE statement unless an INITIATE
  statement was executed before the TERMINATE statement for that report,
  and the program did not already execute a TERMINATE statement for that
  report.
  
 - If the program did not execute a GENERATE statement, the execution
  of a TERMINATE statement does not cause the RWCS to produce any of its
  report groups or perform any of the related processing.
  
 - The TERMINATE statement causes the RWCS to:
  
    - Produce all CONTROL FOOTING report groups beginning with the minor
    CONTROL FOOTING report group.
    
 - Produce the REPORT FOOTING report group.
  
  
     The RWCS makes the prior set of control data item values available
    to these two report groups and to any associated USE procedure. This
    action simulates a control break at the most major level.
   - The RWCS automatically processes the PAGE HEADING and PAGE FOOTING
  report groups, if present, when it must advance the report to a new
  page to present a CONTROL HEADING, DETAIL, or CONTROL FOOTING report
  group.
  
 - The TERMINATE statement does not automatically close a report file;
  the program must close the file. The program must terminate the report
  before the CLOSE statement can close the report file.
  
Additional Reference
 
 
Section 6.8.42, USE statement.
6.8.40 UNLOCK
 
Function
 
 
The UNLOCK statement removes a record lock from the current record or
from all locked records in the file. On Alpha and I64 systems, the
X/Open standard UNLOCK statement always removes the record lock from
all locked records in the file.
  
 
file-name
is the name of a sequential, relative, or indexed file described in the
Data Division.
 
Syntax Rules
 
 
  -  For Format 1, if the UNLOCK statement does not include the RECORD
  or the ALL RECORDS option, the singular RECORD option is the default.
  (However, see General Rule 3.)
  
 -  For Format 2, the RECORD and RECORDS options have the same effect:
  to unlock all currently locked records. This behavior also is the
  default if neither option is specified.
  
General Rules
 
 
  - The first access stream to lock a record owns the record lock for
  that record.
  
 - Only the owner of a record lock can unlock the record.
  
 - For Format 1, implicitly (by default) or explicitly specifying the
  RECORD option unlocks the current record. Therefore, you must specify
  ALL RECORDS explicitly to unlock all the record locks held on
  file-name. 
 The single exception to this rule for Format 1
  is that for indexed files the RECORD option (implicitly or explicitly)
  is unsupported on Tru64 UNIX systems. The ALL RECORDS phrase is
  assumed. <>
   - For Format 2, whether you specify the RECORD option or the RECORDS
  option, the effect is the same: to unlock all record locks held on
  file-name by the current access stream.
  
 - If an access stream attempts to unlock a record (or records) in a
  file containing no record locks, the statement is considered successful
  and execution resumes at the statement following the UNLOCK statement.
  
 -  Because both formats of the UNLOCK statement include the
UNLOCK RECORD
 and
UNLOCK
forms, the compiler determines whether to interpret these forms of the
statement as X/Open standard (on Alpha and I64) or Hewlett-Packard
standard as follows:
  
    -  If on Alpha and I64 X/Open standard syntax (LOCK MODE or WITH (NO)
    LOCK) has been specified for file-name prior to the UNLOCK
    statement, the compiler interprets the statement according to the
    X/Open standard.
    
 -  If Hewlett-Packard standard syntax (LOCK-HOLDING, ALLOWING, or
    REGARDLESS) has been specified for file-name prior to the
    UNLOCK statement, the compiler interprets the statement according to
    the Hewlett-Packard standard.
    
 -  If no file-sharing syntax (LOCK-HOLDING, ALLOWING, REGARDLESS,
    LOCK MODE, or WITH [NO] LOCK) has been specified for file-name
    prior to the UNLOCK statement, then the compiler uses the
    /STANDARD=[NO]XOPEN qualifier on OpenVMS Alpha and I64 (or the
    Tru64 UNIX equivalent
-std [no]xopen
 flag) to determine whether the START statement is interpreted as X/Open
 or Hewlett-Packard standard: a setting of
xopen
 selects the X/Open standard, whereas a setting of
noxopen
 selects the Hewlett-Packard standard.
  
  
     Any subsequent I-O locking syntax for the same file connector in
    your program must be consistent: X/Open standard locking and
    Hewlett-Packard standard locking (implicit or explicit) cannot be mixed
    for the same file connector.
  
Technical Notes
 
 
  -  UNLOCK statement execution can result in these FILE STATUS data
  item values:
  
    File   Status  | 
    File   Organization  | 
    Access   Method  | 
    Meaning  | 
   
  
    | 
      00
     | 
    
      All
     | 
    
      All
     | 
    
      Unlock is successful
     | 
   
  
    | 
      93
     | 
    
      All
     | 
    
      All
     | 
    
      No current record
     | 
   
  
    | 
      94
     | 
    
      All
     | 
    
      All
     | 
    
      File not open, or incompatible open mode
     | 
   
  
    | 
      30
     | 
    
      All
     | 
    
      All
     | 
    
      All other permanent errors
     | 
   
 
  
Additional References
 
 
Hewlett-Packard Standard Examples
 
 
These examples assume only one access stream for the image. The
following examples refer to this partial program:
 
 
  
    
       
      
CONFIGURATION SECTION.
FILE-CONTROL.
    SELECT MASTER-FILE ASSIGN TO "CLIENT.DAT"
    ORGANIZATION IS INDEXED
    ACCESS MODE IS DYNAMIC
    RECORD KEY IS MASTER-KEY
    FILE STATUS IS FILE-STAT.
I-O-CONTROL.
*
* This APPLY clause is required syntax for manual record locking
*
    APPLY LOCK-HOLDING ON MASTER-FILE.
DATA DIVISION.
FD  MASTER-FILE
    LABEL RECORDS STANDARD.
01  MASTER-RECORD.
     .
     .
     .
PROCEDURE DIVISION.
A100-BEGIN.
*
*  The ALLOWING phrase enables file sharing
*
    OPEN I-O MASTER-FILE ALLOWING ALL.
     .
     .
     .
A900-END-OF-JOB.
 |   
  - Unlocking the record lock on the current record by taking the
  default RECORD option:
 
  
    
       
      
     READ MASTER-FILE KEY IS MASTER-KEY
          ALLOWING NO OTHERS.
     REWRITE MASTER-RECORD ALLOWING NO OTHERS.
     UNLOCK MASTER-FILE.
 |   
   - Explicitly unlocking the record lock on the current record:
 
  
    
       
      
     READ MASTER-FILE KEY IS MASTER-KEY
          ALLOWING NO OTHERS.
     .
     .
     .
     UNLOCK MASTER-FILE RECORD.
 |   
   - Unlocking all records in MASTER-FILE:
 
  
    
       
      
     PERFORM A100-READ-MASTER UNTIL
               MASTER-KEY = ID-KEY
            OR
               MASTER-KEY > ID-KEY.
     .
     .
     .
     UNLOCK MASTER-FILE ALL RECORDS.
     .
     .
     .
 A100-READ-MASTER.
     READ MASTER-FILE ALLOWING NO OTHERS.
 |   
  
X/Open Standard Example (Alpha, I64)
 
 
The following example shows the use of X/Open standard syntax:
 
 
  
    
       
      
  SELECT employee-file ASSIGN TO "EMPFIL"
         ORGANIZATION IS INDEXED
         ACCESS MODE IS DYNAMIC
         RECORD KEY IS employee-id
         LOCK MANUAL LOCK ON MULTIPLE RECORDS
         FILE STATUS IS emp-stat.
   .
   .
   .
* The file is implicitly shareable via the SELECT specification.
    OPEN I-O employee-file.
    PERFORM UNTIL emp-stat = end-of-file
        READ employee-file NEXT RECORD
             WITH LOCK
        IF employee-job-code = peon-code
           PERFORM find-boss-record
        ENDIF
   .
   .
   .
        REWRITE employee-record
*   This will unlock this record and the boss's
*   record found earlier.
        UNLOCK employee-file RECORDS
     END-PERFORM.
FIND-BOSS-RECORD.
    START employee-file
          KEY > employee-job-code.
    READ employee-file NEXT WITH LOCK.
 |   
  
  
		 |