IDENTIFICATION DIVISION.
PROGRAM-ID. CETAK-DATA.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PEGAWAI ASSIGN TO DISK
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
SELECT CETAK ASSIGN TO PRINTER.
DATA DIVISION.
FILE SECTION.
FD PEGAWAI.
LABEL RECORD IS STANDARD
VALUE OF FILE-ID IS ‘PEG.DAT’
DATA RECORD IS REC-PEG.
01 REC-PEG.
………………{SAMA DENGAN PROGRAM SBLNYA}
FD CETAK
LABEL RECORD IS OMITTED
DATA RECORD IS BARIS-CETAK.
01 BARIS-CETAK PIC X(80).
WORKING-STORAGE SECTION.
01 JUDUL-1.
02 F PIC X(18) VALUE SPACES.
02 F PIC X(15) VALUE ‘LAPORAN PEGAWAI’
01 JUDUL-2.
……………..
01 GARIS.
02 F PIC X(70) VALUE ALL ‘-‘.
01 DATA-PEG-O.
02 NAMA-O PIC X(10).
02 ALAMAT-O PIC X(20).
02 UMUR-O PIC 99.
PROCEDURE DIVISION.
BUKA-FILE.
OPEN INPUT PEGAWAI
OUTPUT CETAK.
Contoh program Cobol pada organisasi file sequential
MULAI.
PERFORM CETAK-JUDUL
PERFORM CETAK-ISI-TABEL
PERFORM CETAK-GARIS.
SELESAI.
CLOSE PEGAWAI, CETAK
STOP RUN.
CETAK-JUDUL.
WRITE BARIS-CETAK FROM JUDUL-1.
……..
CETAK-ISI-TABEL.
READ PEGAWAI AT END GO TO SELESAI.
MOVE NAMA TO NAMA-O
MOVE ALAMAT TO ALAMAT-O
MOVE UMUR TO UMUR-O
WRITE BARIS-CETAK FROM DATA-PEG-O.
CETAK-GARIS.
WRITE BARIS-CETAK FROM GARIS.
LAY-OUT DARI PROGRAM :
LAPORAN PEGAWAI
NAMA ALAMAT UMUR
……… ………………………. ….
…… ………………………. ….
TOTAL JUMLAH PEGAWAI : XX