Cobol – An Introduction. Mainframes 3. 60. COBOL is a language for business applications. COBOL (COmmon Business Oriented Language) is a high- level programming language suited to develop business applications. ![]() COBOL programs are employed in business processes like. Payroll, Accounting, Inventory Management, Billing, Reservation Systems etc. Applications built in COBOL are in wide- spread use across the globe. The way COBOL works. Computers really understand only one language : machine code, a binary stream of 0s and 1s. You must convert your COBOL code into machine code with the aid of a compiler. Anatomy of a COBOL program When z/OS runs your COBOL program, it looks for a specially coded DIVISION that looks exactly like: PROCEDURE DIVISION. STOP RUN. The z. OS runs everything in the PROCEDURE DIVISION of your COBOL program and stops execution at STOP RUN. In COBOL, you put instructions or code inside the PROCEDURE DIVISION, followed by STOP RUN.
![]() ![]() Code Structure in COBOL COBOL programs have an IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION and a PROCEDURE DIVISION. DIVISION's can have SECTION's and SECTION's have paragraphs. A paragraph is a block of code that has COBOL statements, we'd like to call them sentences. You put declarative statements in the IDENTIFICATION DIVISION, ENVIRONMENT DIVISION and DATA DIVISION. You write instructions or executable statements in the PROCEDURE DIVISION. PROCEDURE DIVISION is where the ball starts rolling. The first part of the COBOL program is the IDENTIFICATION DIVISION. This division has information that helps identify the program- name, author, date it was written etc. The ENVIRONMENT DIVISION has information on the platform/environment, the program would run. The DATA DIVISION declares variables and data structures. The PROCEDURE DIVISION contains executable code. MYPROG0. 1. ENVIRONMENT DIVISION. DATA DIVISION. PROCEDURE DIVISION. MAIN. DISPLAY 'I RULE!'STOP RUN. Look at the lean program I've written above. The IDENTIFICATION DIVISION is the first division in every COBOL program. PROGRAM- ID is a paragraph in the IDENTIFICATION DIVISION. MYPROG0. 1 is a statement inside PROGRAM- ID. The z/OS will identify this program as MYPROG0. Next, the ENVIRONMENT DIVISION must describe the system or platform for the program. The DATA DIVISION declares data- items. Don't worry about these right now, this is just to get you started! I've defined a paragraph 0. ![]() MAIN in PROCEDURE DIVISION. The DISPLAY statement in COBOL displays text strings on the terminal. STOP RUN indicates the end of the COBOL program and execution stops. What can you say in the PROCEDURE DIVISION? Once you're inside the PROCEDURE DIVISION, the fun begins! Like in most programming languages, you can do normal things like assignments, arithmetic. You can do something under a condition - IF/ELSE tests. You can do something again and again - Loop or iterate. An Introduction to the COBOL/400 Programming Language. 1 Extensions to the ANSI Standard. 1 Features of the COBOL/400 Compiler. 2 Using COBOL/400 Syntax Notation.2Read. Beginning COBOL for Programmers is a comprehensive, sophisticated tutorial and modular skills reference on the COBOL programming language for established programmers. This book is for you if you are a developer who would like to-or must-add COBOL to. COBOL is a high-level programming language like C, C#, Java, Pascal, or BASIC, but it is one with a particular focus and a long history. COBOL’s Target Application Domain The name COBOL is an acronym that stands for Common Business Oriented L. COBOL is verbose and has English- like expressions to depict logic(Its inventors envisioned that perhaps COBOL could be read by programmers and managers alike). MOVE is used for assignments : MOVE 'JOHN RAMBO' TO FULL- NAME, MOVE 1. TO PRINCIPAL- SUM, MOVE TOTAL- COST TO RPT- FIELD- 1. COMPUTE helps with writing and evaluating arithmetic expressions. Say, you had to find the volume of sphere. Just code COMPUTE VOLUME = (4/3) * (3. RADIUS ** 3). COBOL is a structured programming language. It employs a top- down design model. The whole program logic is divided into smaller sections and paragraphs. For example, 3. 00. PROCESS- FILE logic can be divided into 3. OPEN- FILE, 3. 20. READ- FILE and 3. CLOSE- FILE paragraphs. This makes it highly modular. You usually map- out similar functions or logic to its own separate paragraph. The logic for reading from a file can be encapsulated in a 3. READ- FILE para. At any point in the program, if a file is to be read, you can just invoke or PERFORM 3. READ- FILE. Looping and looping and.. COBOL has a standard looping construct PERFORM UNTIL. We'll talk about loops at length, later. The syntax is so simple - you're probably asleep already. Keep doing everything inside the PERFORM . END- PERFORM block over and over. Whatever it is that you want repeat, has to be inside the block. The key to a loop is a conditional- test. In COBOL, a conditional- test is an expression that returns a boolean value, in other words a TRUE or FALSE. If you say something like, . As long as the conditional- test is FALSE, keep juggling. When no more juggling balls are left, you stop. Introduction to Business System COBOL Programs. Get the full title to continue reading from where you left off, or restart the preview.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
August 2017
Categories |