Vejamos um exemplo que mostra como inserir um registro em um novo arquivo quando a organização é sequencial:
Codificação COBOL:
IDENTIFICATION DIVISION. PROGRAM-ID. COBWRITE. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT EMPLOYEE ASSIGN TO EMP-FILE ORGANIZATION IS SEQUENTIAL ACCESS IS SEQUENTIAL. DATA DIVISION. FILE SECTION. FD EMPLOYEE. 01 EMPLOYEE-FILE. 05 EMPLOYEE-ID PIC X(5). 05 NAME PIC A(10). PROCEDURE DIVISION. OPEN EXTEND EMPLOYEE. MOVE '100' TO EMPLOYEE-ID. MOVE 'REVATHY' TO NAME. WRITE EMPLOYEE-FILE END-WRITE. CLOSE EMPLOYEE. STOP RUN. |
100 REVATHY |