This repository was archived by the owner on Jul 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcobol.html
More file actions
344 lines (344 loc) · 12.8 KB
/
cobol.html
File metadata and controls
344 lines (344 loc) · 12.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta http-equiv="X-UA-Compatible" content="ie=edge"><meta name="description" content="COBOL is a high-level language mainly used with mainframes on legacy and modern systems."><!-- Bing --><meta name="msvalidate.01" content="45CBBE1BD8265A2217DFDA630EB8F84A" /><title>Tiny Brain Fans - COBOL</title><link rel="stylesheet" href="tinystyle.css"></head><body>
<main id="main"><article id="content"><h1 id="title">COBOL</h1><p>Most of this is in the IBM Z/OS variety, but I assume most of it is pretty agnostic to the exact implementation hardware. Plus the manuals are all over the internet, so shouldn't be too hard to grab what you need.</p>
<h2>Syntax</h2>
<h3>Characters</h3>
<p>'Characters' are lowest in the hierarchy and they cannot be divided further. The COBOL Character Set includes 78 characters which are shown below.</p>
<table>
<thead>
<tr>
<th>Sr.No.</th>
<th>Character</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Alphabets (Upper Case)</td>
<td><code>A</code> - <code>Z</code></td>
</tr>
<tr>
<td>2</td>
<td>Alphabets (Lower Case)</td>
<td><code>a</code> - <code>z</code></td>
</tr>
<tr>
<td>3</td>
<td>Numeric</td>
<td><code>0</code>-<code>9</code></td>
</tr>
<tr>
<td>4</td>
<td>Space</td>
<td><code> </code></td>
</tr>
<tr>
<td>5</td>
<td>Plus Sign</td>
<td><code>+</code></td>
</tr>
<tr>
<td>6</td>
<td>Minus Sign or Hyphen</td>
<td><code>-</code></td>
</tr>
<tr>
<td>7</td>
<td>Asterisk</td>
<td><code>*</code></td>
</tr>
<tr>
<td>8</td>
<td>Forward Slash</td>
<td><code>/</code></td>
</tr>
<tr>
<td>9</td>
<td>Currency Sign</td>
<td><code>$</code></td>
</tr>
<tr>
<td>10</td>
<td>Comma</td>
<td><code>,</code></td>
</tr>
<tr>
<td>11</td>
<td>Semicolon</td>
<td><code>;</code></td>
</tr>
<tr>
<td>12</td>
<td>Decimal Point or Period</td>
<td><code>.</code></td>
</tr>
<tr>
<td>13</td>
<td>Quotation Marks</td>
<td><code>"</code></td>
</tr>
<tr>
<td>14</td>
<td>Left Parenthesis</td>
<td><code>(</code></td>
</tr>
<tr>
<td>15</td>
<td>Right Parenthesis</td>
<td><code>)</code></td>
</tr>
<tr>
<td>16</td>
<td>Greater than</td>
<td><code>></code></td>
</tr>
<tr>
<td>17</td>
<td>Less than</td>
<td><code><</code></td>
</tr>
<tr>
<td>18</td>
<td>Colon</td>
<td><code>:</code></td>
</tr>
<tr>
<td>19</td>
<td>Apostrophe</td>
<td><code>'</code></td>
</tr>
<tr>
<td>20</td>
<td>Equal Sign</td>
<td><code>=</code></td>
</tr>
</tbody></table><h3>Coding Sheet</h3>
<p>The source program of COBOL must be written in a format acceptable to the compilers. COBOL programs are written on COBOL coding sheets. There are 80 character positions on each line of a coding sheet.</p>
<p>Character positions are grouped into the following five fields:</p>
<table>
<thead>
<tr>
<th>Positions</th>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>1-6</td>
<td>Column Numbers</td>
<td>Reserved for line numbers.</td>
</tr>
<tr>
<td>7</td>
<td>Indicator</td>
<td>It can have Asterisk (<code>*</code>) indicating comments, Hyphen (<code>-</code>) indicating continuation and Slash (<code>/</code>) indicating form feed.</td>
</tr>
<tr>
<td>8-11</td>
<td>Area A</td>
<td>All COBOL divisions, sections, paragraphs and some special entries must begin in Area A.</td>
</tr>
<tr>
<td>12-72</td>
<td>Area B</td>
<td>All COBOL statements must begin in area B.</td>
</tr>
<tr>
<td>73-80</td>
<td>Identification Area</td>
<td>It can be used as needed by the programmer.</td>
</tr>
</tbody></table><h4>Example</h4>
<p>The following example shows a COBOL coding sheet:</p>
<pre><code class="language-cobol">000100 IDENTIFICATION DIVISION. 000100
000200 PROGRAM-ID. HELLO. 000101
000250* THIS IS A COMMENT LINE 000102
000300 PROCEDURE DIVISION. 000103
000350 A000-FIRST-PARA. 000104
000400 DISPLAY “Coding Sheet”. 000105
000500 STOP RUN. 000106
</code></pre>
<p>JCL to execute the above COBOL program:</p>
<pre><code>//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C
//STEP1 EXEC PGM = HELLO
</code></pre>
<p>When you compile and execute the above program, it produces the following result:</p>
<pre><code>Coding Sheet
</code></pre>
<h3>Character Strings</h3>
<p>Character strings are formed by combining individual characters. A character string can be a</p>
<ul>
<li>Comment,</li>
<li>Literal, or</li>
<li>COBOL word</li>
</ul>
<p>All character strings must be ended with separators. A separator is used to separate character strings.</p>
<p>Frequently used separators:</p>
<ul>
<li>Space</li>
<li>Comma</li>
<li>Period</li>
<li>Apostrophe</li>
<li>Left/Right Parenthesis</li>
<li>Quotation mark</li>
</ul>
<h3>Comment</h3>
<p>A comment is a character string that does not affect the execution of a program. It can be any combination of characters.</p>
<p>There are two types of comments:</p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td>Comment Line</td>
<td>Any line with an asterisk (<code>*</code>) or slash (<code>/</code>) in the indicator area (column 7) of the line.</td>
<td><code>000250* THIS IS A COMMENT LINE 000102</code></td>
</tr>
<tr>
<td>Comment Entry</td>
<td>Comment entries are those that are included in the optional paragraphs of an Identification Division. They are written in Area B and programmers use it for reference.</td>
<td>TODO</td>
</tr>
</tbody></table><h3>Literal</h3>
<p>Literal is a constant that is directly hard-coded in a program. In the following example, "Hello World" is a literal.</p>
<pre><code class="language-cobol">PROCEDURE DIVISION.
DISPLAY 'Hello World'.
</code></pre>
<p>There are two types of literals, alphanumeric and numeric.</p>
<h4>Alphanumeric Literals</h4>
<p>Alphanumeric Literals are enclosed in single or double quotes. Length can be up to 160 characters.</p>
<h4>Numeric Literal</h4>
<p>A Numeric Literal is a combination of digits from <code>0</code> to <code>9</code>, <code>+</code>, <code>–</code>, or decimal point. Length can be up to 18 characters. Sign cannot be the rightmost character. Decimal point should not appear at the end. Valid examples are <code>100</code>, <code>+10.9</code>, and <code>-1.9</code>; invalid examples are <code>1,00</code>, <code>10.</code>, and <code>10.9-</code>.</p>
<h3>COBOL Word</h3>
<p>COBOL Word is a character string that can be a reserved word or a user-defined word. Length can be up to 30 characters.</p>
<h4>User-Defined</h4>
<p>User-defined words are used for naming files, data, records, paragraph names, and sections. Alphabets, digits, and hyphens are allowed while forming userdefined words. You cannot use COBOL reserved words.</p>
<h4>Reserved Words[7, p. 12]</h4>
<p>Reserved words are predefined words in COBOL. Different types of reserved words that we use frequently are as follows:</p>
<ul>
<li>Keywords</li>
<li>Special characters</li>
<li>Figurative constants</li>
</ul>
<h4>Figurative Constants</h4>
<table>
<thead>
<tr>
<th>Sr.No.</th>
<th>Figurative Constants</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>HIGH-VALUES</td>
<td>One or more characters which will be at the highest position in descending order.</td>
</tr>
<tr>
<td>2</td>
<td>LOW-VALUES</td>
<td>One or more characters have zeros in binary representation.</td>
</tr>
<tr>
<td>3</td>
<td>ZERO/ZEROES</td>
<td>One or more zero depending on the size of the variable.</td>
</tr>
<tr>
<td>4</td>
<td>SPACES</td>
<td>One or more spaces.</td>
</tr>
<tr>
<td>5</td>
<td>QUOTES</td>
<td>Single or double quotes.</td>
</tr>
<tr>
<td>6</td>
<td>ALL "literal"</td>
<td>Fills the data-item with "literal".</td>
</tr>
</tbody></table><h3>Variables (PICTURE Clause)[7]</h3>
<p>These are only the common ones that I've found. There are LOTS.</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Meaning</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>A character position that can contain only a letter of the Latin alphabet or a space.</td>
<td>Each ’A’ is counted as one character position in the size of the data item.</td>
</tr>
<tr>
<td>S</td>
<td>An indicator of the presence (but not the representation, and not necessarily the position) of an operational sign. An operational sign indicates whether the value of an item involved in an operation is positive or negative.</td>
<td>Not counted in the size of the elementary item, unless an associated SIGN clause specifies the SEPARATE CHARACTER phrase (which would be counted as one character position).</td>
</tr>
<tr>
<td>V</td>
<td>An indicator of the location of the assumed decimal point. Does not represent a character position.<br>When the assumed decimal point is to the right of the rightmost symbol in the string, the V is redundant.</td>
<td>Not counted in the size of the elementary item.</td>
</tr>
<tr>
<td>X</td>
<td>A character position that can contain any allowable character from the alphanumeric character set of the computer.</td>
<td>Each ’X’ is counted as one character position in the size of the data item.</td>
</tr>
<tr>
<td>Z</td>
<td>A leading numeric character position. When that position contains a zero, a space character replaces the zero.</td>
<td>Each ’Z’ is counted as one character position in the size of the data item.</td>
</tr>
<tr>
<td>9</td>
<td>A character position that contains a numeral.</td>
<td>Each nine specifies one decimal digit in the value of the item. For usages DISPLAY and NATIONAL, each nine is counted as one character position in the size of the data item.</td>
</tr>
<tr>
<td>0</td>
<td>A character position into which the numeral zero is inserted.</td>
<td>Each zero is counted as one character position in the size of the data item.</td>
</tr>
</tbody></table><h2>Learning</h2>
<h3>Courses</h3>
<ul>
<li>Learning COBOL Programming with VSCode[8]</li>
<li>IBM ZXplore[2]</li>
</ul>
<h3>Books on COBOL[3]</h3>
<ul>
<li><em>Fundamentals of Structured COBOL</em> by Carl Feingold</li>
<li><a href="https://www.murach.com/shop/murachs-mainframe-cobol-detail" target="_blank"><em>Mainframe COBOL</em> from Murach</a></li>
<li><em>Advanced COBOL for Structured and Object-Oriented Programming</em> by Gary DeWard Brown</li>
<li>Any IBM COBOL manual[7]</li>
</ul>
<h2>References</h2>
<ol>
<li><a href="https://community.ibm.com/community/user/ibmz-and-linuxone/blogs/misty-decker1/2020/04/10/cobol-education-quick-guide" target="_blank">https://community.ibm.com/community/user/ibmz-and-linuxone/blogs/misty-decker1/2020/04/10/cobol-education-quick-guide</a></li>
<li><a href="https://ibmzxplore.influitive.com/" target="_blank">https://ibmzxplore.influitive.com/</a></li>
<li><a href="https://www.teddit.net/r/cobol/comments/i8wzzr/what_is_the_cobol_bible_if_there_is_one/" target="_blank">https://www.teddit.net/r/cobol/comments/i8wzzr/what_is_the_cobol_bible_if_there_is_one/</a></li>
<li><a href="https://www.teddit.net/r/cobol/comments/id13dc/newbie_with_cobol_and_absolutely_lost/" target="_blank">Debugging COBOL</a></li>
<li><a href="https://www.tutorialspoint.com/cobol/cobol_basic_syntax.htm" target="_blank">https://www.tutorialspoint.com/cobol/cobol_basic_syntax.htm</a></li>
<li><a href="http://www.csis.ul.ie/cobol/exercises/default.htm" target="_blank">http://www.csis.ul.ie/cobol/exercises/default.htm</a></li>
<li><a href="https://www.ibm.com/docs/en/SS6SG3_4.2.0/com.ibm.entcobol.doc_4.2/PGandLR/igy3lr50.pdf" target="_blank">https://www.ibm.com/docs/en/SS6SG3_4.2.0/com.ibm.entcobol.doc_4.2/PGandLR/igy3lr50.pdf</a></li>
<li><a href="https://www.ibm.com/blogs/ibm-training/free-course-announcing-learning-cobol-programming-with-vscode/" target="_blank">https://www.ibm.com/blogs/ibm-training/free-course-announcing-learning-cobol-programming-with-vscode/</a></li>
<li><a href="https://github.com/openmainframeproject/cobol-programming-course" target="_blank">https://github.com/openmainframeproject/cobol-programming-course</a></li>
<li><a href="https://github.com/mikeroyal/COBOL-Guide" target="_blank">https://github.com/mikeroyal/COBOL-Guide</a></li>
<li><a href="https://monadical.com/posts/cobol.html#" target="_blank">https://monadical.com/posts/cobol.html#</a></li>
<li><a href="https://scribe.rip/modern-mainframe/beginners-guide-cobol-made-easy-introduction-ecf2f611ac76" target="_blank">https://scribe.rip/modern-mainframe/beginners-guide-cobol-made-easy-introduction-ecf2f611ac76</a></li>
<li><a href="https://youtube.com/watch?v=77o14aHUuSo" target="_blank">https://youtube.com/watch?v=77o14aHUuSo</a></li>
</ol>
<p class="last-modified">Last modified: 202206101419</p></article></main><footer><nav><a href="index.html">Sitemap</a></nav><div class="social"><p>Built using <a href="http://codeberg.org/milofultz/swiki" target="_blank" rel="noopener noreferrer">{{SWIKI}}</a></p><p><a href="http://codeberg.org/milofultz/" target="_blank" rel="noopener noreferrer">Codeberg</a></p><p><a href="http://milofultz.com/" target="_blank" rel="noopener noreferrer">milofultz.com</a></p><p><a href="https://merveilles.town/@milofultz" target="_blank" rel="me noopener noreferrer">Mastodon</a></p></div></footer></body></html>