minggu i - p_sarjono.staff.gunadarma.ac.idp_sarjono.staff.gunadarma.ac.id/downloads/files/... ·...
Post on 14-Nov-2020
5 Views
Preview:
TRANSCRIPT
1
MINGGU I
KONSEP DASAR
TINJAUAN UMUM
• Common Business Oriented Language
• Bahasa Pemrograman terstruktur
• Orientasi pada pengolahan bisnis
• Pengolahan bisnis meliputi:
– Koleksi data
– Validasi data
– Pemutakhiran data
– Pelaporan data
TINJAUAN UMUM: COBOL
• Dikembangkan oleh Conference on Data Systems Language (CODASYL) pada 1959
• Sangat dipengaruhi oleh bahasa pemrograman bisnis yang sedang digunakan saat itu, FLOW-MATIC, yang merupakan hasil karya dari Laksamana Grace Murray Hopper
• Grace Hopper adalah salah satu penasehat teknis dari CODASYL
ANSI
• American National Standard Institute
• Mengembangkan standar umum bagi berbagai compiler COBOL yang ada pada saat itu (1968)
• Standar tersebut direvisi pada 1974
• Pada 1985, direvisi kembali dan menambah fitur baru pada COBOL
• Pada 1989, ditambahkan sebuah metode penanganan tanggal dalam format 4 digit
TATA LETAK PROGRAM
• Kolom 1-6: Penomoran Baris (tidak wajib)
• Kolom 7: tanda sambung, baris komentar, page eject
• Kolom 8-11: Area A. Untuk penulisan nama Division, Paragraf, Section
• Kolom 12-72: Area B. Penulisan kode program
• Kolom 73-80: identifikasi program
STRUKTUR PROGRAM (UMUM)
• IDENTIFICATION DIVISION
•ENVIRONMENT DIVISION
•DATA DIVISION
•PROCEDURE DIVISION
IDENTIFICATION DIVISION
• Mengidentifikasi program kepada compiler
• Terdapat satu paragraf:
– PROGRAM-ID, yang berisi nama dari program yang digunakan ketika program COBOL dipanggil
• 000001 Identification Division.
• 000002 Program-Id. NameOfProgram.
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. HELLO.
000300 ENVIRONMENT DIVISION.
000400 DATA DIVISION.
000500 PROCEDURE DIVISION.
000600
000700 PROGRAM-BEGIN.
000800 DISPLAY "Hello world".
000900
001000 PROGRAM-DONE.
001100 STOP RUN.
ENVIRONMENT DIVISION
• Berisi informasi berkaitan dengan komputer tempat program dijalankan
• Terdiri atas:
• Configuration Section
– Source-Computer
– Object-computer
– Special-Names
• Input-Output Section
– File-Control
– I-O-Control
ENVIRONMENT DIVISION
• 000001 Identification Division.
• 000002 Program-Id. NameOfProgram.
• 000003 Environment Division.
• 000004 Configuration Section.
• 000005 Source-Computer. IBM-PC With Debugging Mode.
• 000006 Object-Computer. IBM-PC.
• 000007 Special-Names.
• 000008 Currency-sign is $.
ENVIRONMENT DIVISION
• 000001 Identification Division.
• 000002 Program-Id. NameOfProgram.
• 000003 Environment Division.
• 000004 Configuration Section.
• 000005 Source-Computer. IBM-PC.
• 000006 Object-Computer. IBM-PC.
• 000007 Input-Output Section.
• 000008 File-Control.
• 000009 Select Input-File assign to "IN.DAT".
DATA DIVISION
• Menggambarkan data yang digunakan oleh program, yang berasal dari disk files atau dari memory
• Terdiri atas:
– File Section
– Working-Storage Section
– Linkage Section
– Communications Section
– Report Section
– Screen Section
FILE SECTION
• Menggambarkan file yang digunakan oleh program COBOL
• Entry di bawah File Section meliputi:
– File descriptions untuk file masukkan biasa
– Dan Sort descriptions untuk sort work files.
– Sort work files adalah file yang digunakan untuk proses sortir di dalam program COBOL
WORKING-STORAGE SECTION
• Menggunakan data areas (area data) yang akan digunakan selama proses.
• Data areas digambarkan secara terinci
• Semua data items yang dirujuk oleh (referenced by) program dideklarasikan di dalam salah satu Sections dari Data Division
SCREEN SECTION
• Menggambarkan sebuah layar yang berisi:
– input,
– output,
– dan update data untuk user interface
DATA DIVISION
000001 Identification Division.
000002 Program-Id. NameOfProgram.
000003 Environment Division.
000004 Configuration Section.
000005 Source-Computer. IBM-PC.
000006 Object-Computer. IBM-PC.
000007 Input-Output Section.
000008 File-Control.
000009 Select Input-File assign to "IN.DAT".
DATA DIVISION
000010 Data Division.
000011 File Section.
000012 FD Input-file.
000013 01 Input-Record Pic X(100).
000014 Working-Storage Section.
000015 01 Work-Field Pic X(20).
PROCEDURE DIVISION
• Tempat proses program terjadi
• Pemrogram memberikan perintah penyatuan komponen program yang telah ditentukan pada Division lain
• Harus memiliki minimal satu paragraf
PROCEDURE DIVISION
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. SENTNCES.
000300 ENVIRONMENT DIVISION.
000400 DATA DIVISION.
000500 PROCEDURE DIVISION.
000600
000700 PROGRAM-BEGIN.
000800 DISPLAY "This program contains four DIVISIONS,".
000900 DISPLAY "three PARAGRAPHS".
001000 DISPLAY "and four SENTENCES".
001100 PROGRAM-DONE.
001200 STOP RUN.
PROCEDURE DIVISION
OUTPUT:
C>pcobrun comment
Personal COBOL version 2.0 from Micro Focus
PCOBRUN V2.0.02 Copyright (C) 1983-1993 Micro Focus Ltd.
This program contains four DIVISIONS,
three PARAGRAPHS
and four SENTENCES
USER-DEFINED WORDS
• Maksimal 30 karakter
• Hanya boleh menggunakan alfabet, angka, dan hypen
• Spasi tidak diperbolehkan
• Tidak dimulai atau diakhiri dengan hypen
• Tidak boleh mempergunakan COBOL Reserved Words
USER-DEFINED WORDS
BENTUK DATA
• Numerik: Angka
• Non-Numerik:
– Alfabet
– Alfanumerik
• Konstanta Figuratif:
– ZERO atau ZEROES
– SPACE(S)
– HIGH-VALUE(S)
– LOW-VALUE(S)
– QUOTE(S)
– ALL literal
IDENTIFICATION DIVISION
000100 IDENTIFICATION DIVISION.
000110 PROGRAM-ID. EXAMPLE-1-PROG.
000120 AUTHOR. ZINGMATTER.
000130 INSTALLATION. XYZ GROUP.
000140 DATE-WRITTEN. 17/5/00.
000150 DATE-COMPILED.
000160 SECURITY. LOCAL GROUP
ENVIRONMENT DIVISION
000260 ENVIRONMENT DIVISION.
000270 CONFIGURATION SECTION.
000280 SOURCE-COMPUTER. IBM-PC.
000290 OBJECT-COMPUTER. IBM-PC.
000300 INPUT-OUTPUT SECTION.
000310 FILE-CONTROL.
000320 SELECT INPUT-FILE ASSIGN TO ‘input.dat’
000330 ORGANIZATION IS LINE SEQUENTIAL.
000340 SELECT PRINT-FILE ASSIGN TO PRINTER.
DATA DIVISION
000400 DATA DIVISION.
000410 FILE SECTION.
000420
000430 FD INPUT-FILE.
000440 01 CUSTOMER-DATA.
000450 03 NAME PIC X(12).
000460 03 ADDRESS.
000470 05 HOUSE-NUMBER PIC 99.
000480 05 STREET PIC X(19).
000490 05 CITY PIC X(13).
000500 03 CUST-NUMBER PIC 9(6).
PROCEDURE DIVISION
000900 PROCEDURE DIVISION.
000910 CONTROL-PARAGRAPH.
000920 PERFORM READ-DATA-FILE
000930 PERFORM CALULATE-PRICES
000940 PERFORM PRINT-PRICE-REPORT
000950 PROGRAM-DONE.
000960 STOP RUN.
top related