COBOL STANDARD-1 Clause - Quick Reference
The STANDARD-1 clause in COBOL specifies compliance with the COBOL 85 standard (ANSI X3.23-1985). It ensures that the program uses only features available in the COBOL 85 specification, providing maximum portability and compatibility with legacy systems.
Primary Use
Specify COBOL 85 standard compliance
Division
ENVIRONMENT DIVISION
Section
CONFIGURATION SECTION
Status
Optional clause
Overview
The STANDARD-1 clause is part of the CONFIGURATION SECTION in the ENVIRONMENT DIVISION. It specifies that the program should follow the COBOL 85 standard (ANSI X3.23-1985). This ensures maximum portability and compatibility with different COBOL implementations by restricting the program to use only features defined in the COBOL 85 specification.
Syntax
123456789101112131415ENVIRONMENT DIVISION. CONFIGURATION SECTION. STANDARD-1. * Examples: ENVIRONMENT DIVISION. CONFIGURATION SECTION. STANDARD-1. * With other configuration clauses: ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. IBM-3090. OBJECT-COMPUTER. IBM-3090. STANDARD-1.
Practical Examples
Basic STANDARD-1 Usage
123456789101112131415161718192021222324252627* Basic STANDARD-1 clause example (COBOL 85) IDENTIFICATION DIVISION. PROGRAM-ID. STANDARD-1-EXAMPLE. ENVIRONMENT DIVISION. CONFIGURATION SECTION. STANDARD-1. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-COUNTER PIC 9(3) VALUE ZERO. 01 WS-RESULT PIC 9(5). 01 WS-MESSAGE PIC X(50) VALUE "Using COBOL 85 Standard". PROCEDURE DIVISION. MAIN-LOGIC. DISPLAY WS-MESSAGE DISPLAY "Standard: COBOL 85 (STANDARD-1)" * Use COBOL 85 features only PERFORM VARYING WS-COUNTER FROM 1 BY 1 UNTIL WS-COUNTER > 5 COMPUTE WS-RESULT = WS-COUNTER * 10 DISPLAY "Counter: " WS-COUNTER " Result: " WS-RESULT END-PERFORM DISPLAY "STANDARD-1 processing completed" STOP RUN.
Explanation: This example demonstrates basic usage of the STANDARD-1 clause. The program specifies COBOL 85 compliance, which restricts the program to use only features available in the COBOL 85 standard. This includes basic arithmetic operations, PERFORM loops, and standard COBOL syntax. The compiler will flag any usage of newer COBOL features as errors.
STANDARD-1 with File Processing
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253* STANDARD-1 with file processing (COBOL 85) IDENTIFICATION DIVISION. PROGRAM-ID. STANDARD-1-FILE-EXAMPLE. ENVIRONMENT DIVISION. CONFIGURATION SECTION. STANDARD-1. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT INPUT-FILE ASSIGN TO "INPUT.DAT" ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS WS-FILE-STATUS. DATA DIVISION. FILE SECTION. FD INPUT-FILE. 01 INPUT-RECORD PIC X(80). WORKING-STORAGE SECTION. 01 WS-FILE-STATUS PIC XX. 01 WS-RECORD-COUNT PIC 9(5) VALUE ZERO. 01 WS-EOF-FLAG PIC X(1) VALUE 'N'. PROCEDURE DIVISION. MAIN-LOGIC. DISPLAY "STANDARD-1 File Processing Example" * Open file using COBOL 85 syntax OPEN INPUT INPUT-FILE * Check file status IF WS-FILE-STATUS NOT = "00" DISPLAY "Error opening file: " WS-FILE-STATUS STOP RUN END-IF * Read records using COBOL 85 syntax PERFORM UNTIL WS-EOF-FLAG = 'Y' READ INPUT-FILE AT END MOVE 'Y' TO WS-EOF-FLAG NOT AT END ADD 1 TO WS-RECORD-COUNT DISPLAY "Record " WS-RECORD-COUNT ": " INPUT-RECORD END-READ END-PERFORM * Close file CLOSE INPUT-FILE DISPLAY "Total records processed: " WS-RECORD-COUNT STOP RUN.
Explanation: This example shows STANDARD-1 usage with file processing. The program uses only COBOL 85 file processing features, including the standard READ statement with AT END and NOT AT END clauses. This ensures compatibility with COBOL 85 implementations and older systems that may not support newer file processing features.
STANDARD-1 Data Validation
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869* STANDARD-1 data validation example IDENTIFICATION DIVISION. PROGRAM-ID. STANDARD-1-VALIDATION. ENVIRONMENT DIVISION. CONFIGURATION SECTION. STANDARD-1. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-INPUT-DATA PIC X(20). 01 WS-VALIDATION-STATUS PIC X(1) VALUE 'Y'. 01 WS-ERROR-MESSAGE PIC X(50). 01 WS-VALIDATION-COUNTERS. 05 WS-TOTAL-RECORDS PIC 9(5) VALUE ZERO. 05 WS-VALID-RECORDS PIC 9(5) VALUE ZERO. 05 WS-INVALID-RECORDS PIC 9(5) VALUE ZERO. PROCEDURE DIVISION. MAIN-LOGIC. DISPLAY "STANDARD-1 Data Validation Example" * Simulate data validation using COBOL 85 features PERFORM VALIDATE-DATA-RECORDS * Display validation results DISPLAY "Validation Results:" DISPLAY "Total Records: " WS-TOTAL-RECORDS DISPLAY "Valid Records: " WS-VALID-RECORDS DISPLAY "Invalid Records: " WS-INVALID-RECORDS STOP RUN. VALIDATE-DATA-RECORDS. * Simulate processing multiple records PERFORM VARYING WS-TOTAL-RECORDS FROM 1 BY 1 UNTIL WS-TOTAL-RECORDS > 10 * Simulate input data MOVE "RECORD DATA " TO WS-INPUT-DATA MOVE WS-TOTAL-RECORDS TO WS-INPUT-DATA(12:5) * Perform validation using COBOL 85 features PERFORM VALIDATE-SINGLE-RECORD IF WS-VALIDATION-STATUS = 'Y' ADD 1 TO WS-VALID-RECORDS DISPLAY "Record " WS-TOTAL-RECORDS " is valid" ELSE ADD 1 TO WS-INVALID-RECORDS DISPLAY "Record " WS-TOTAL-RECORDS " is invalid: " WS-ERROR-MESSAGE END-IF END-PERFORM. VALIDATE-SINGLE-RECORD. * Reset validation status MOVE 'Y' TO WS-VALIDATION-STATUS MOVE SPACES TO WS-ERROR-MESSAGE * Check for required data using COBOL 85 features IF WS-INPUT-DATA = SPACES MOVE 'N' TO WS-VALIDATION-STATUS MOVE "Record is empty" TO WS-ERROR-MESSAGE END-IF * Check field length using COBOL 85 features IF FUNCTION LENGTH(WS-INPUT-DATA) < 10 MOVE 'N' TO WS-VALIDATION-STATUS MOVE "Record too short" TO WS-ERROR-MESSAGE END-IF.
Explanation: This example demonstrates data validation using STANDARD-1 features. The program uses only COBOL 85 validation techniques, including basic IF statements, PERFORM loops, and standard COBOL data manipulation. Note that FUNCTION LENGTH would not be available in true COBOL 85, so this would need to be replaced with manual length checking.
Portability and Compatibility Example
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859* STANDARD-1 portability and compatibility example IDENTIFICATION DIVISION. PROGRAM-ID. STANDARD-1-PORTABILITY. ENVIRONMENT DIVISION. CONFIGURATION SECTION. STANDARD-1. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-PORTABILITY-INFO. 05 WS-STANDARD-LEVEL PIC X(10) VALUE "STANDARD-1". 05 WS-COBOL-VERSION PIC X(10) VALUE "COBOL 85". 05 WS-COMPATIBILITY PIC X(1) VALUE 'Y'. 01 WS-SYSTEM-CHECKS. 05 WS-COMPILER-NAME PIC X(20). 05 WS-COMPILER-VERSION PIC X(15). 05 WS-SYSTEM-NAME PIC X(20). 01 WS-FEATURE-TESTS. 05 WS-BASIC-FEATURES PIC X(1) VALUE 'Y'. 05 WS-ADVANCED-FEATURES PIC X(1) VALUE 'N'. 05 WS-FILE-FEATURES PIC X(1) VALUE 'Y'. PROCEDURE DIVISION. MAIN-LOGIC. DISPLAY "STANDARD-1 Portability Analysis" DISPLAY "Standard Level: " WS-STANDARD-LEVEL DISPLAY "COBOL Version: " WS-COBOL-VERSION * Perform portability checks PERFORM CHECK-PORTABILITY * Display compatibility results DISPLAY "Compatibility Results:" DISPLAY "Basic Features: " WS-BASIC-FEATURES DISPLAY "Advanced Features: " WS-ADVANCED-FEATURES DISPLAY "File Features: " WS-FILE-FEATURES IF WS-COMPATIBILITY = 'Y' DISPLAY "Program is compatible with COBOL 85 systems" ELSE DISPLAY "Compatibility issues detected" END-IF STOP RUN. CHECK-PORTABILITY. * Check if program uses only COBOL 85 features IF WS-BASIC-FEATURES = 'Y' AND WS-ADVANCED-FEATURES = 'N' AND WS-FILE-FEATURES = 'Y' MOVE 'Y' TO WS-COMPATIBILITY DISPLAY "Portability check passed" ELSE MOVE 'N' TO WS-COMPATIBILITY DISPLAY "Portability check failed" END-IF.
Explanation: This example shows how to analyze portability and compatibility when using STANDARD-1. The program includes logic to check if it's using only COBOL 85 features and provides feedback on compatibility. This is useful for ensuring that programs will run correctly on different COBOL implementations and legacy systems that only support COBOL 85.
Best Practices and Considerations
Important Considerations
- STANDARD-1 restricts access to newer COBOL features
- Use for maximum portability across COBOL implementations
- Ensures compatibility with legacy systems
- May limit functionality compared to newer standards
- Compiler will flag non-COBOL 85 features as errors
Advantages
- Maximum portability across COBOL implementations
- Compatibility with legacy systems
- Clear standard compliance
- Reduced dependency on newer features
- Easier maintenance on older systems
Limitations
- Restricts access to newer COBOL features
- May limit functionality
- Cannot use built-in functions
- Limited exception handling capabilities
- May require more verbose code
Best Practices
- • Use for maximum portability requirements
- • Test on target COBOL implementations
- • Document standard compliance clearly
- • Avoid newer COBOL features
- • Consider migration path to newer standards
Test Your Knowledge
1. What does STANDARD-1 represent in COBOL?
- COBOL 2002 standard
- COBOL 85 standard
- COBOL 74 standard
- COBOL 2014 standard
2. In which COBOL division is the STANDARD-1 clause typically used?
- IDENTIFICATION DIVISION
- ENVIRONMENT DIVISION
- DATA DIVISION
- PROCEDURE DIVISION
3. What is the primary purpose of specifying STANDARD-1?
- To enable newer COBOL features
- To ensure COBOL 85 compliance and restrict features
- To improve performance
- To enable debugging features
4. Which of the following features is NOT available in STANDARD-1?
- Basic PERFORM statements
- Built-in functions like FUNCTION LENGTH
- Standard arithmetic operations
- File processing statements
5. What happens if you try to use STANDARD-2 features in a STANDARD-1 program?
- The program runs normally
- The compiler generates warnings or errors
- The features are automatically converted
- The program uses STANDARD-2 instead