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 - Learning COBOL/COBOL Programming Course #2 - Learning COBOL.md
+71Lines changed: 71 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2773,6 +2773,77 @@ This exercise develops skills in COBOL conditional processing, program structure
2773
2773
2774
2774
**Need Help?** If you encounter difficulties, you can refer to the complete solution code `CBLC1.cobol` available in VS Code Zowe Explorer or find it on [GitHub](https://github.com/openmainframeproject/cobol-programming-course/tree/master/COBOL%20Programming%20Course%20%232%20-%20Learning%20COBOL/Labs/cbl) repository.
2775
2775
2776
+
# Case Sensitive Nature of COBOL Conditions
2777
+
2778
+
COBOL syntax is not case-sensitive for keywords and identifiers, but string literal comparisons in conditional expressions ARE case-sensitive. This distinction between language syntax and data comparisons can lead to programming errors that cause issues when your program interacts with:
2779
+
2780
+
-**External input data**, such as text files or database records
2781
+
-**Conditional expressions** that depend on exact string matches
2782
+
-**Third-party systems** that expect a specific case format
2783
+
2784
+
## Why It Matters
2785
+
2786
+
The most dangerous aspect of case sensitivity errors is that they often go unnoticed during initial testing. Programs **compile successfully**, **run without errors**, but **produce incorrect results**. These kinds of "silent failures" can persist in production systems for long periods, potentially resulting in:
`Move my-Number to your-Number` as **equivalent** because keywords and identifiers are case-insensitive.
2799
+
2800
+
However, **COBOL conditions** are case-sensitive when checking **string values**:
2801
+
2802
+
`IF USA-STATE = 'new York'` = Fails, mismatch due to case
2803
+
2804
+
`IF USA-STATE = 'New York'` = Succeeds, case matches
2805
+
2806
+
The comparison **fails silently** COBOL won't throw an error, but the result won't be as expected.
2807
+
2808
+
## Lab
2809
+
2810
+
**Case Sensitivity in Data Comparison:**
2811
+
Understand how case sensitivity in COBOL string comparisons can cause logical errors and learn to identify and fix these issues.
2812
+
2813
+
**Scenario:** You'll investigate why a program designed to count "New York" clients returns zero when New York clients actually exist in the input data file (id.DATA).
2814
+
2815
+
**Required Files:**
2816
+
2817
+
-`CBL006A.cobol` - COBOL program source
2818
+
-`CBL006AJ.jcl` - JCL job to compile and execute
2819
+
-`id.DATA` - Input data file
2820
+
2821
+
All files are available in your VS Code Zowe Explorer.
2822
+
2823
+
### Instructions
2824
+
2825
+
1. Open `CBL006A.cobol` from your VS Code Zowe Explorer.
2826
+
2827
+
This program reads account records and counts how many clients are from `"New York"`.
2828
+
2829
+
2. Submit the JCL job `CBL006AJ.jcl`. View the job output from the JOBS section.
2830
+
- Confirm that no syntax or runtime errors occurred.
2831
+
- Now carefully read the final line of the report. `New York Clients = 000`
2832
+
2833
+

2834
+
2835
+
Ask yourself: *Is this the number of New York clients you expected?*
2836
+
2837
+
3. Based on your understanding, where do you think the bug lies?
2838
+
- Consider the case format of both the **comparison string** and the **actual data** from the file (id.DATA).
2839
+
4. Go and update the source code `CBL006A.cobol` .
2840
+
- Modify the string literal in the IF condition to match the exact case format found in the data file
2841
+
5. Save your changes to `CBL006A.cobol`
2842
+
6. Recompile and resubmit the job `CBL006AJ.jcl`
2843
+
7. Verify that the report now correctly shows: `New York Clients = 005`
0 commit comments