You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: COBOL Programming Course #1 - Getting Started/COBOL Programming Course #1 - Getting Started.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1861,7 +1861,7 @@ The relationships among all data to be used in a program is defined in the DATA
1861
1861
1862
1862
A structured level number hierarchic relationship is available to all DATA DIVISION sections. Figure 1. shows the level number hierarchic relationship with programmer chosen level numbers, variable names and PIC clauses in the File Section where “01 PRINT-REC” references the following “05”-level group of variables and the “01 ACCT-FIELDS” references the following “05"-level group of variables. Observe 05-level CLIENT-ADDR is further subdivided into several 10-level names. COBOL code referencing the name CLIENT-ADDR includes the 10-level names.
1863
1863
1864
-

1864
+

1865
1865
1866
1866
*Figure 1. Level number hierarchic relationship*
1867
1867
@@ -1873,7 +1873,7 @@ After a record is defined, it can be subdivided to provide more detailed data re
1873
1873
1874
1874
MOVE and COMPUTE reserved word statements alter the value of variable names. Each MOVE shown in Figure 2. results in a literal stored in a 77-level variable name. The COMPUTE statement, also shown in Figure 2. , stores the value of `HOURS * RATE` in `GROSS-PAY.` All three variable names are assigned a numeric value data type using PIC 9, which is necessary for the operation of the COMPUTE statement.
1875
1875
1876
-

1876
+

1877
1877
1878
1878
*Figure 2. MOVE and COMPUTE example*
1879
1879
@@ -2003,7 +2003,7 @@ The ENVIRONMENT DIVISION and DATA DIVISION describes the inputs and outputs used
2003
2003
2004
2004
The FILE-CONTROL paragraph associates each COBOL internal file name with an external dataset name. Within the FILE-CONTROL paragraph, the SELECT clause creates an internal file name and the ASSIGN clause creates an external dataset name. Figure 1. shows the PRINT-LINE internal file name associated with the PRTLINE external dataset name and the ACCT-REC internal file name associated with the ACCTREC external dataset name. Section titled Assign Clause further explains the SELECT ASSIGN TO relationship.
2005
2005
2006
-

2006
+

2007
2007
2008
2008
*Figure 1. FILE-CONTROL*
2009
2009
@@ -2013,7 +2013,7 @@ While SELECT gives a name to an internal file and ASSIGN gives a name to the ext
2013
2013
2014
2014
The COBOL reserved word 'FD' is used to give the COBOL compiler more information about internal file names in the FILE-SECTION. The code below the FD statement is the record layout. The record layout consists of level numbers, variable names, data types, and lengths as shown in Figure 2.
2015
2015
2016
-

2016
+

2017
2017
2018
2018
*Figure 2. FILE-SECTION*
2019
2019
@@ -2076,7 +2076,7 @@ During COBOL program runtime, SELECT ASSIGN TO a JCL DDNAME is mandatory. If th
2076
2076
2077
2077
COBOL inputs and outputs must be opened to connect the selected internal name to the assigned external name. Figure 4. opens the file name ACCT-REC as program input and file name PRINT-LINE as program output.
2078
2078
2079
-

2079
+

2080
2080
2081
2081
*Figure 4. OPEN-FILES*
2082
2082
@@ -2102,7 +2102,7 @@ When reading records, the program needs to first check for no records to be read
2102
2102
2103
2103
READ-NEXT-RECORD repeatedly executes READ-RECORD and WRITE-RECORD until a last record is encountered. When the last record is encountered, then CLOSE-STOP is executed stopping the program.
2104
2104
2105
-

2105
+

2106
2106
2107
2107
*Figure 6. Reading and writing records*
2108
2108
@@ -2843,7 +2843,7 @@ This section briefly reviews certain aspects of the ENVIRONMENT DIVISION for the
2843
2843
2844
2844
The "File handling" section covered the SELECT and respective ASSIGN programmer chosen names, whereas this chapter focuses on output. Figure 1. shows a coding example using PRINT-LINE as the programmer chosen COBOL internal file name for output.
2845
2845
2846
-

2846
+

2847
2847
2848
2848
*Figure 1. SELECT and ASSIGN*
2849
2849
@@ -2855,7 +2855,7 @@ The File Description (FD), previously described under the FILE-CONTROL paragraph
2855
2855
2856
2856
Observe the data name FILLER. While most data fields have unique names, FILLER is a COBOL reserved word data name, that is useful for output formatting. This is in part because FILLER allocates memory space without the need for a name. Also, FILLER allocated memory has a defined length in the output line and may contain spaces or any literal. Figure 2. shows multiple VALUE SPACES for FILLER. SPACES create white space between data-items in the output which is valuable in keeping the code readable. More specifically in Figure 2. FILLER PIC X(02) VALUE SPACES, represents the output line containing two spaces.
2857
2857
2858
-

2858
+

2859
2859
2860
2860
*Figure 2. FILLER*
2861
2861
@@ -2911,7 +2911,7 @@ Writing report or column headers requires a structured output layout designed by
2911
2911
2912
2912
HEADER-2 includes the year, month, day of the report together with FILLER area, creating blank spaces between the year, month, and day, as you can see in Figure 3. Figure 4. is an example of the data name layout used to store the values of CURRENT-DATE. The information COBOL provides in CURRENT-DATE is used to populate the output file in HEADER-2.
2913
2913
2914
-

2914
+

2915
2915
2916
2916
*Figure 4. CURRENT-DATE intrinsic function*
2917
2917
@@ -2920,7 +2920,7 @@ HEADER-2 includes the year, month, day of the report together with FILLER area,
2920
2920
2921
2921
Figures 1 through 4 are a designed data layout that includes a data line and report headers. Using the storage mapped by the data line and report headers, COBOL processing logic can write the headers followed by each data line. Figure 5. is an example of an execution logic resulting used to write the header layout structure in a COBOL program.
2922
2922
2923
-

2923
+

2924
2924
2925
2925
*Figure 5. Execution logic to write header layout structure*
0 commit comments