Cobol 101 Anne Michelle Santos Roumel Mendoza COBOL
Cobol 101 Anne Michelle Santos Roumel Mendoza
COBOL 101 l COBOL l l l Common Business Oriented Language A third-generation programming language, Was one of the earliest high-level programming languages; still wide used today. l l Business Computing Domain. First proposed in 1959 by the Conference on Data Systems Languages (CODASYL). Three ANSI standards for COBOL have been produced in 1968, 1974 and 1985. Object-oriented COBOL is the fourth edition in the continuing evolution of ANSI/ISO standard COBOL .
Underlining Philosophy l Like the name suggests, COBOL was meant to be ‘common’ or compatible among a significant group of manufacturers l COBOL is designed for developing business, typically file-oriented, applications, and is not designed for writing systems programs. l Primary domain in business, finance, and administrative systems for companies and governments.
Pro’s and Con’s - Advantages - Simple Portable Maintainable - Disadvantages - -very wordy - has a very rigid format -not designed to handle scientific applications
Distinct features l l l l The language is simple No pointers No user defined types No user defined functions ‘Structure like’ data types File records are also described with great detail, as are lines to be output to a printer COBOL is self documenting
Structure of COBOL l COBOL programs are hierarchical in structure. l Each element of the hierarchy consists of one or more subordinate elements. l The levels of hierarchy are Divisions, Sections, Paragraphs, Sentences and Statements l There are 4 main divisions and each division provides an essential part of the information required by the complier
Structure of COBOL (continued) l l l At the top of the COBOL hierarchy are the four divisions. The sequence in which they are specified is fixed, and must follow the order: l IDENTIFICATION DIVISION supplies information about the program to the programmer and the compiler. l ENVIRONMENT DIVISION is used to describe the environment in which the program will run. l DATA DIVISION provides descriptions of the data-items processed by the program. l PROCEDURE DIVISION contains the code used to manipulate the data described in the DATA DIVISION. It is here that the programmer describes his algorithm. Some COBOL compilers require that all the divisions be present in a program while others only require the IDENTIFICATION DIVISION and the PROCEDURE DIVISION
Hello. World Example 000100 000200 000300 000400 000500 000600 000700 000800 000900 001000 001100 101200 101300 101400 101500 101600 IDENTIFICATION DIVISION. PROGRAM-ID. HELLOWORLD. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. RM-COBOL. OBJECT-COMPUTER. RM-COBOL. DATA DIVISION. FILE SECTION. PROCEDURE DIVISION. MAIN-LOGIC SECTION. DISPLAY "Hello world!" STOP RUN.
Writing, Compiling and Executing Creating. cbl programs 1. l Notepad/Text Editors and save as. cbl Compiling and Running 2. l l Open RM/Cobol Directory Compile l l l Type in prompt: rmcobol <filename. extn> filename. extn is the source code Execute l If no errors: l l Type in prompt: runcobol <filename> Filename is the object code
Data Types in COBOL l COBOL is not a strongly typed language l In COBOL, there are only three data types l l Numeric, lphanumeric (text/string), alphabetic Data types are declared using: l l l A level number A data-name or identifier A Picture clause. l l For detailed field specification e. g. 01 Gross. Pay PIC 9(5)V 99 VALUE ZEROS.
Group Items l l l Group items are the COBOL equivalent of structures. The items with a group item must be elementary items or other group items. Ultimately every group item should be defined in terms of elementary items. The hierarchy in a group item is represented by different level numbers e. g. 01 Date. Of. Birth. 02 Day. Of. Birth PIC 99. 02 Month. Of. Birth PIC 99. 02 Year. Of. Birth PIC 9(2).
Basic Commands l l l l ADD a TO b GIVING c. SUBTRACT a FROM b GIVING c. MULTIPLY a BY b GIVING c. DIVIDE a INTO b GIVING c. COMPUTE x = a + b * c. MOVE a TO b c SORT sort-file ON ASCENDING KEY k USING inventory-file GIVING sorted-inventory-file.
Basic Commands (Contd. ) l MERGE merge-work-file ON ASCENDING KEY K USING input-file 1 input-file 2 GIVING output-file. l DISPLAY Accept total-cost. identifier. PERFORM paragraphname 1 THROUGH paragraphname 2 VARYING index FROM value 1 BY value 2 UNTIL condition.
Advanced Cobol (somehow)
Two Types Job Control Language (JCL) l CICS® (Customer Information Control System) l
Job Control Language (JCL) l A scripting language used on IBM mainframe operating systems l l to instruct the Job Entry Subsystem (that is, JES 2 or JES 3) on how to run a batch program or start a subsystem. Acts as the driver and scheduler for batch COBOL programs
DB 2 l IBM's line of RDBMS l l As IBM now calls it, data server Software products within IBM's broader Information Management software line l Acts as the backend database for COBOL programs l IBM's flagship relational database management system DB 2 Enterprise Server Edition or the top of the line DB 2 Data Warehouse Edition (DB 2 DWE) which runs on Unix, Windows or Linux servers.
Sample Program EXEC SQL SELECT TKT_NUM , TKT_ISS_DTE , MEMO_NUM , MEMO_CRTN_DTE , WVR_CDE , WVR_CRTN_DTE INTO : WVU 0140 A-TKT-NUM , : WVU 0140 A-TKT-ISS-DTE , : WVU 0140 A-MEMO-NUM , : WVU 0140 A-MEMO-CRTN-DTE : WSW-NULL-INDICATOR , : WVU 0140 A-WVR-CDE , : WVU 0140 A-WVR-CRTN-DTE FROM T_WVR WHERE TKT_NUM = : W 400 -PRMY-TKT-NUM WITH UR END-EXEC.
CICS® / Customer Information Control System l A transaction server that runs primarily on IBM mainframe systems l Acts as the driver and GUI for online COBOL programs l A transaction processing system designed for both online and batch activity l l Can be written in numerous programming languages l l easily supports thousands of transactions per second, making it a mainstay of enterprise computing COBOL, PL/I, C, C++, Assembler, REXX, and Java Over 90 percent of Fortune 500 companies are reported to rely on CICS (running on z/OS) for their core business functions; most state and national governments do as well
CICS® / Customer Information Control System l Each CICS program is initiated using a transaction id. l l CICS screens are sent as maps using a programming language such as COBOL. l The end user inputs data which is made accessible to the program by receiving a map. l CICS screens may contain text that is highlighted, having different colors or blinking. l An example of how a map can be sent through COBOL is given below. l EXEC CICS SEND MAPSET(MPS 1) MAP(MP 1) END-EXEC.
Key References l l l Wikipedia. org http: //www. cs. wayne. edu/~jcc/CSC 114/lec. html http: //www. csis. ul. ie/COBOL/examples/default. ht m#Simple. Programs
- Slides: 21