Introduction to COBOL Programming
<ul><li>Overview and Examples </li></ul>
<ul><li>PROCEDURE DIVISION consists of uniquely named SECTIONS </li></ul><ul><ul><ul><li>section-name SECTION. </li></ul><...
<ul><li>PROCEDURE DIVISION. </li></ul><ul><li>{ section-name SECTION. </li></ul><ul><li>[paragraph-name. [sentence 1] … </...
<ul><li>Structure Of Procedure Division </li></ul>
<ul><li>A STATEMENT always starts with a VERB and consists of words and literals </li></ul><ul><li>A SENTENCE is a set of ...
<ul><li>Structure Of Procedure Division </li></ul>
<ul><li>SECTIONS in PROCEDURE DIVISION are user-defined and not fixed as in DATA and ENVIRONMENT DIVISIONS </li></ul><ul><...
<ul><li>A PARAGRAPH consists of zero or more statements </li></ul><ul><li>The PARAGRAPH is terminated by the appearance of...
<ul><li>SENTENCES and STATEMENTS must be written in AREA B </li></ul><ul><li>To avoid ambiguity, all section names must be...
<ul><li>Paragraph-name OF section-name </li></ul><ul><li>sect1  SECTION. </li></ul><ul><ul><li>this-para . [statements] </...
<ul><li>Paragraph-name OF section-name </li></ul><ul><li>sect1  SECTION. </li></ul><ul><ul><li>this-para . [statements]  t...
<ul><li>Basic Verbs </li></ul>
<ul><li>MOVE verb is necessary to transfer a data from one place to another. </li></ul><ul><li>MOVE  {identifier1 / litera...
Before Execution After  Execution Before Execution After  Execution
Before Execution After  Execution Before Execution After  Execution
Before Execution After  Execution Before Execution After  Execution
Before Execution After  Execution <ul><li>MOVE  15  TO  A </li></ul><ul><li>MOVE  “THERE IS AN ERROR”  TO  B </li></ul><ul...
<ul><li>Arithmetic Verbs </li></ul>
<ul><li>To compute sum of two or more numbers. </li></ul><ul><li>ADD  {identifier1 / literal1}  [id2, lit2] .. TO  identif...
<ul><li>Arithmetic Verbs </li></ul>
<ul><li>To subtract one, or the sum of two or more numbers from one or more numbers. </li></ul><ul><li>SUBTRACT  {identifi...
Upcoming SlideShare
Loading in …5
×

Procedure Division & Basic Verbs

4,075 views

Published on

A text on procedure division of COBOL and introduction to Basic and Arithmetic verbs.

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
4,075
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
67
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Procedure Division & Basic Verbs

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

×