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 #2 - Advanced Topics/COBOL Programming Course #2 - Advanced Topics.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -300,7 +300,7 @@ Additionally, we cannot compare or move dynamic-length group items to any other
300
300
301
301
To define a dynamic length item, we can include the DYNAMIC LENGTH clause on the data description entry. Here are a couple of examples of how to indicate the clause:
302
302
303
-
```
303
+
```COBOL
304
304
01 MY-DYN PIC X DYNAMIC.
305
305
01 NAME PIC X DYNAMIC LENGTH.
306
306
01 DYN-PRICE PIC X DYNAMIC LIMIT 500.
@@ -321,7 +321,7 @@ There are three ways that Enterprise COBOL uses to define UTF-8 data items.
321
321
322
322
This type of UTF-8 data item is defined when the PICTURE clause contains one or more 'U' characters, or a single 'U' followed by a repetition factor. Take for example the piece of code below:
323
323
324
-
```
324
+
```COBOL
325
325
01 NEW-UTF-CHAR PIC U(10).
326
326
```
327
327
@@ -331,7 +331,7 @@ In this case, we define a fixed character-length UTF-8 data item that holds 10 U
331
331
332
332
Like fixed character-length, we define this by the inclusion of the 'U' character in the PICTURE clause. But now, we will add a phrase called BYTE-LENGTH. Observe the code below:
333
333
334
-
```
334
+
```COBOL
335
335
01 NEW-UTF-BYTE PIC U BYTE-LENGTH 10.
336
336
```
337
337
@@ -341,7 +341,7 @@ In this case, we define a fixed byte-length UTF-8 data item that holds 10 bytes
341
341
342
342
Lastly, we have the dynamic-length UTF-8 data items. This is defined when we have a PICTURE clause with the 'U' character and the DYNAMIC LENGTH clause. Observe the code below:
343
343
344
-
```
344
+
```COBOL
345
345
01 NEW-UTF-DYN PIC U DYNAMIC LIMIT 10.
346
346
```
347
347
@@ -409,7 +409,7 @@ Each middleware has unique reserved words available to Enterprise COBOL.
409
409
410
410
Enterprise COBOL unique API reserved words are in Example 1.
411
411
412
-
```
412
+
```COBOL
413
413
EXEC SQL
414
414
EXEC CICS
415
415
CALL 'MQ...'
@@ -422,7 +422,7 @@ Each of the above COBOL API's enable the program to communcate with Db2, CICS, M
422
422
### COBOL EXEC SQL
423
423
SQL, Structured Query Language, is the documented standard for communicating will all relational databases. Enterprise COBOL is capable of including Db2 for z/OS SQL. A few simple COBOL EXEC SQL reserved words are shown in Example 2.
@@ -469,7 +469,7 @@ The fields in the Db2 table record were defined using CREATE TABLE SQL. The EXE
469
469
470
470
Observe ":CUSTOMER-RECORD" in the EXEC SQL FETCH statement. A colon (:) precedes COBOL program defined variables that are used in SQL statements so that Db2 can distinguish a variable name from a column name. Example 3. shows the COBOL program data items describing the COBOL program variable names.
@@ -883,7 +883,7 @@ The recommended pattern for input:
883
883
```
884
884
885
885
The recommended pattern for output:
886
-
```
886
+
```COBOL
887
887
OPEN OUTPUT fn
888
888
...
889
889
* Construct output record in local-storage item.
@@ -967,7 +967,7 @@ We can also use top-down programming constructs. In simpler term, we would work
967
967
968
968
Before we continue, let us talk a bit about in-line and out-of-line PERFORM statements. Chances are you have seen them without realizing what they are. Take a look at the example below:
969
969
970
-
```
970
+
```COBOL
971
971
PERFORM 010-INITIALIZE
972
972
PERFORM UNTIL END-OF-FILE
973
973
READ FILE-DATA INTO WS-DATA
@@ -991,15 +991,15 @@ It is also suggested to avoid the use of the following constructs:
991
991
992
992
We can also factor expressions in our programs to eliminate unnecessary computation. Take a look at the examples below. The first block of code is more efficient than the second block of code.
993
993
994
-
```
994
+
```COBOL
995
995
MOVE ZERO TO TOTAL
996
996
PERFORM VARYING I FROM 1 BY 1 UNTIL I = 10
997
997
COMPUTE TOTAL = TOTAL + ITEM(I)
998
998
END-PERFORM
999
999
COMPUTE TOTAL = TOTAL * DISCOUNT
1000
1000
```
1001
1001
1002
-
```
1002
+
```COBOL
1003
1003
MOVE ZERO TO TOTAL
1004
1004
PERFORM VARYING I FROM 1 BY 1 UNTIL I = 10
1005
1005
COMPUTE TOTAL = TOTAL + ITEM(I) * DISCOUNT
@@ -1044,7 +1044,7 @@ We can also define integer items as BINARY or PACKED-DECIMAL with nine or fewer
1044
1044
1045
1045
We can use floating point for exponentiations for large exponents to achieve faster and more accurate results. For example, the first statement below is computed more quickly and accurately compared with the second statement:
0 commit comments