action.skip

COMMIT Statement

The COMMIT statement unlocks locked records and flushes buffers to disk.

General Format:

COMMIT.

General Rules:

  1. The COMMIT statement causes unwritten file buffers to be written to the target file.
  2. After writing file buffers, the COMMIT statement releases record and file locks held by the target file.

Code Sample:

       IDENTIFICATION DIVISION. 
       PROGRAM-ID. COMMIT-1.
       ENVIRONMENT DIVISION. 
       INPUT-OUTPUT SECTION. 
       FILE-CONTROL. 
           SELECT RESWORDS ASSIGN TO "RESWORDS" 
           ORGANIZATION IS INDEXED 
           ACCESS IS DYNAMIC 
           RECORD KEY IS RESERVED-WORD 
           FILE STATUS IS RESWORDS-STAT. 

       DATA DIVISION. 
       FILE SECTION. 
       FD RESWORDS. 
       01 RESWORDS-RECORD. 
           03 RESERVED-WORD        PIC X(30). 

       WORKING-STORAGE SECTION. 
       77 RESWORDS-STAT PIC XX. 
           88 END-OF-RESWORDS VALUE "10". 
       77 DUMMY                    PIC X. 

       PROCEDURE DIVISION. 
       MAIN. 
           OPEN OUTPUT RESWORDS. 
           MOVE "ACCEPT" TO RESERVED-WORD. 
           WRITE RESWORDS-RECORD. 
           COMMIT. 
           DISPLAY "COMMIT-1 FINISHED!" LINE 10 COL 10. 
           ACCEPT DUMMY LINE 10 COL 30. 

           CLOSE RESWORDS. 
           STOP RUN.