...

Contoh Program FILE SEKUENSIAL

by user

on
Category: Documents
0

views

Report

Comments

Transcript

Contoh Program FILE SEKUENSIAL
Contoh Program untuk memasukkan data
IDENTIFICATION DIVISION.
PROGRAM-ID. CONTOH-FILE.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PEGAWAI ASSIGN TO DISK
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
FILE-STATUS IS STATUS-SALAH.
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.
02 NAMA PIC X(10).
02 ALAMAT PIC X(20).
02 UMUR PIC 99.
WORKING-STORAGE SECTION.
77 STATUS-SALAH PIC XX.
01 SUDAH-BENAR PIC X.
88 BENAR VALUE ‘y’, ‘Y’.
88 BELUM VALUE ‘T’,’t’.
01 MASUKKAN-DATA-LAGI PIC X.
88 LAGI VALUE ‘Y’, ‘y’.
88 TIDAK VALUE ‘T’, ‘t’.
SCREEN SECTION.
01 HAPUS-LAYAR.
02 BLANK SCREEN.
01 LAYAR-DATA.
02 LINE 4 COLUMN 5 ‘NAMA :’
02 COLUMN PLUS 1 PIC X(10) TO NAMA.
02 LINE 5 COLUMN 5 ‘ALAMAT :’
02 COLUMN PLUS 1 PIC X(25) TO ALAMAT.
02 LINE 6 COLUMN 5 ‘UMUR :’
02 COLUMN PLUS 1 PIC 99 TO UMUR.
Contoh program Cobol pada organisasi file sequential
PROCEDURE DIVISION.
BUKA-FILE.
OPEN OUTPUT PEGAWAI.
MULAI.
MOVE SPACE TO SUDAH-BENAR
PERFORM INPUT-DATA UNTIL BENAR
PERFORM REKAM-DATA
PERFORM ADA-LAGI.
TANYA-ADA-LAGI.
IF LAGI GO TO MULAI.
SELESAI.
CLOSE PEGAWAI.
STOP RUN.
INPUT-DATA.
DISPLAY HAPUS-LAYAR
DISPLAY LAYAR-DATA
ACCEPT LAYAR-DATA.
DISPLAY (10, 5) ‘SUDAH BENAR (Y/T) ?’
ACCEPT ( , ) SUDAH-BENAR.
REKAM-DATA.
MOVE SPACE TO STATUS-SALAH
WRITE REC-PEG.
PERFORM TANYA-REKAM.
ADA-LAGI.
DISPLAY (12, 5) ‘ADA LAGI DATA (Y/T) ? ‘
ACCEPT ( , ) MASUKKAN-DATA-LAGI.
TANYA-REKAM.
IF STATUS-SALAH =’34’
DISPLAY (12, 5) ‘DISK FULL’.
------------------------------------********----------------------------------NILAI STATUS ORGANISASI FILE URUT
NILAI
00
10
30
34
91
KETERANGAN
TDK TERJADI KESALAHAN
EOF
FILE NOT FOUND
DISK SPACE FULL
STRUKTUR FILE RUSAK
Contoh program Cobol pada organisasi file sequential
Contoh program untuk mencetak data
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
Contoh program Cobol pada organisasi file sequential
Fly UP