Download - Procedure Division & Basic Verbs
![Page 1: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/1.jpg)
Introduction to COBOL Programming
![Page 2: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/2.jpg)
Overview and Examples
![Page 3: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/3.jpg)
PROCEDURE DIVISION consists of uniquely named SECTIONS section-name SECTION.
A SECTION can have zero or more PARAGRAPHS
A PARAGRAPH has zero or more SENTENCES
SENTENCES are a set of STATEMENTS terminated by a period
STATEMENTS are operations to be performed by the computer
![Page 4: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/4.jpg)
PROCEDURE DIVISION. { section-name SECTION. [paragraph-name. [sentence 1] … … [sentence n] ] … }
PROCEDURE DIVISION. [paragraph-name. [sentence 1] …
[sentence n] ] …
![Page 5: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/5.jpg)
Structure Of Procedure Division
![Page 6: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/6.jpg)
A STATEMENT always starts with a VERB and consists of words and literals
A SENTENCE is a set of one or more STATEMENTS terminated by a period ‘.’
ADD A TO B. IF X GREATER THAN 1000 GO TO PARA-BIG.
There can be more than one STATEMENT or SENTENCE in a line. Alternatively, a STATEMENT can be broken and can be continued in the next line
![Page 7: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/7.jpg)
Structure Of Procedure Division
![Page 8: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/8.jpg)
SECTIONS in PROCEDURE DIVISION are user-defined and not fixed as in DATA and ENVIRONMENT DIVISIONS
SECTIONS are terminated either by the appearance of another SECTION HEADER or at the end of PROCEDURE DIVISION
SECTIONS must start with a name followed by SECTION keyword with at least one space in between
Section-name SECTION.
![Page 9: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/9.jpg)
A PARAGRAPH consists of zero or more statements
The PARAGRAPH is terminated by the appearance of another PARAGRAPH HEADER or SECTION HEADER or at the end of PROCEDURE DIVISION
Para-one. MOVE d-rate TO rate MULTIPLY amt BY rate GIVING dividend.
Para-two. Para-three.
![Page 10: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/10.jpg)
SENTENCES and STATEMENTS must be written in AREA B
To avoid ambiguity, all section names must be unique and different from paragraph names, data names
All paragraphs within a section must have unique name, but need not be unique in the entire program
![Page 11: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/11.jpg)
Paragraph-name OF section-name
sect1 SECTION. this-para. [statements] second-para. [statements]
sect2 SECTION. this-para. [sentences]
![Page 12: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/12.jpg)
Paragraph-name OF section-name
sect1 SECTION. this-para. [statements] this-
para OF sect1 second-para. [statements]
sect2 Section. this-para. [sentences] this-para
OF sect2
![Page 13: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/13.jpg)
Basic Verbs
![Page 14: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/14.jpg)
MOVE verb is necessary to transfer a data from one place to another.
MOVE {identifier1 / literal 1} TO identifer2, [,id3]…
MOVE A TO B. MOVE 3 TO C. MOVE X TO Y, Z.
![Page 15: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/15.jpg)
Before Execution
After Execution
Before Execution
After Execution
![Page 16: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/16.jpg)
Before Execution
After Execution
Before Execution
After Execution
![Page 17: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/17.jpg)
Before Execution
After Execution
Before Execution
After Execution
![Page 18: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/18.jpg)
Before Execution
After Execution MOVE 15 TO A MOVE “THERE IS AN ERROR” TO
B MOVE A TO B, C, D
![Page 19: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/19.jpg)
Arithmetic Verbs
![Page 20: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/20.jpg)
To compute sum of two or more numbers.
ADD {identifier1 / literal1} [id2, lit2] .. TO identifier3 [, id4] …
ADD {identifier1 / literal1} {id2, lit2} .. GIVING identifr3 [, id4] …
ADD A To B B = A + B ADD A B C TO D D = A + B + C + D ADD 15 A TO B B = 15 + A + B ADD A B GIVING C C = A + B ADD A B GIVING C D E C = D = E = A + B
![Page 21: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/21.jpg)
Arithmetic Verbs
![Page 22: Procedure Division & Basic Verbs](https://reader033.vdocuments.site/reader033/viewer/2022061305/5498d051b4795938328b4bb5/html5/thumbnails/22.jpg)
To subtract one, or the sum of two or more numbers from one or more numbers.
SUBTRACT {identifier1 / literal1} [id2, lit2] .. FROM identifier3 [, id4] … [, GIVING identifier5 [, identifier6] … ]
SUBTRACT A FROM B B = B – A SUBTRACT A B FROM C C = C – A – B [=C – (A+B) ] SUBTRACT A B FROM C GIVING D D = C – (A + B) SUBTRACT A B From 50 GIVING C C = 50 – (A +
B) SUBTRACT 15 FROM A B A = A – 15 & B = B – 15