MainframeMaster

COBOL Tutorial

COBOL AUTO Clause

The AUTO clause represents one of COBOL's most sophisticated and specialized screen handling mechanisms, serving as the primary tool for implementing automatic field processing, advanced terminal control, and sophisticated user interface management that enables applications to create intuitive, efficient, and user-friendly interactive interfaces. Far more than a simple field attribute, the AUTO clause embodies COBOL's comprehensive approach to screen programming by providing automatic cursor movement controls, sophisticated field validation triggers, advanced data entry optimization, and comprehensive user experience enhancement mechanisms that enable applications to implement enterprise-grade interactive processing, sophisticated terminal interfaces, and advanced screen management capabilities while maintaining data integrity, user productivity, and robust interface control features that are essential for mission-critical interactive applications requiring professional-grade user interfaces and optimized data entry workflows.

In enterprise computing environments, the AUTO clause serves as a critical foundation for advanced screen programming implementation, enabling developers to create sophisticated interactive applications that handle complex user interface requirements, implement efficient data entry patterns, provide optimal user experience characteristics, and maintain enterprise-grade interface capabilities. Its capabilities extend far beyond simple automatic processing to encompass sophisticated cursor management techniques, advanced field validation integration, complex user interface optimization strategies, and integration with modern terminal management systems that are essential for applications requiring comprehensive screen programming and enterprise-grade interface management capabilities that support complex user interaction requirements and advanced interface optimization patterns across multiple terminal types and sophisticated user interface architectures.

Understanding COBOL AUTO Clause for Screen Programming

What is the AUTO Clause?

The AUTO clause is a specialized COBOL screen description attribute used primarily in screen definition contexts to control automatic cursor movement and field processing behavior. When applied to a field, AUTO instructs the system to automatically advance the cursor to the next field once the current field is completely filled, eliminating the need for users to manually press Tab or Enter to move between fields during data entry operations.

Unlike manual cursor control, AUTO creates a seamless data entry experience where users can rapidly input data without interruption, significantly improving productivity and reducing user fatigue during intensive data entry sessions. This capability is particularly valuable in high-volume data entry environments, transaction processing systems, and interactive applications where efficiency and user experience are critical business requirements. The AUTO clause integrates seamlessly with other screen attributes to create sophisticated, professional-grade user interfaces.

Key Functions of AUTO:

  • Automatic Cursor Movement: Moves cursor to next field when current field is filled
  • Data Entry Optimization: Improves efficiency and speed of data input operations
  • User Experience Enhancement: Creates smooth, professional interaction patterns
  • Field Flow Control: Manages logical progression through screen fields
  • Productivity Improvement: Reduces keystrokes and manual navigation requirements

AUTO Clause Syntax and Screen Integration

The AUTO clause is typically used within SCREEN SECTION definitions as part of field attribute specifications. It works in conjunction with other screen attributes like REQUIRED, BLANK WHEN ZERO, and validation clauses to create comprehensive field behavior patterns. The syntax integrates seamlessly with COBOL's screen description framework to provide powerful interactive capabilities.

cobol
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
*> Basic AUTO clause usage in screen definitions IDENTIFICATION DIVISION. PROGRAM-ID. AUTO-DEMO. DATA DIVISION. WORKING-STORAGE SECTION. 01 CUSTOMER-SCREEN-DATA. 05 CUST-ID-INPUT PIC X(10). 05 CUST-NAME-INPUT PIC X(30). 05 CUST-PHONE-INPUT PIC X(15). 05 CUST-ZIP-INPUT PIC X(10). 05 CUST-CREDIT-INPUT PIC 9(8)V99. 01 SCREEN-CONTROL-FIELDS. 05 SCREEN-ACTION PIC X(10). 05 CURSOR-POSITION PIC 9(3). 05 ERROR-MESSAGE PIC X(50). SCREEN SECTION. 01 CUSTOMER-ENTRY-SCREEN. 05 BLANK SCREEN. 05 LINE 2 COLUMN 20 VALUE "CUSTOMER DATA ENTRY". 05 LINE 4 COLUMN 1 VALUE "Customer ID:". 05 LINE 4 COLUMN 15 PIC X(10) USING CUST-ID-INPUT AUTO REQUIRED HIGHLIGHT. 05 LINE 6 COLUMN 1 VALUE "Customer Name:". 05 LINE 6 COLUMN 15 PIC X(30) USING CUST-NAME-INPUT AUTO REQUIRED HIGHLIGHT. 05 LINE 8 COLUMN 1 VALUE "Phone Number:". 05 LINE 8 COLUMN 15 PIC X(15) USING CUST-PHONE-INPUT AUTO HIGHLIGHT. 05 LINE 10 COLUMN 1 VALUE "ZIP Code:". 05 LINE 10 COLUMN 15 PIC X(10) USING CUST-ZIP-INPUT AUTO REQUIRED HIGHLIGHT. 05 LINE 12 COLUMN 1 VALUE "Credit Limit:". 05 LINE 12 COLUMN 15 PIC ZZZ,ZZ9.99 USING CUST-CREDIT-INPUT AUTO BLANK WHEN ZERO HIGHLIGHT. 05 LINE 15 COLUMN 1 VALUE "Press F3 to Save, F12 to Cancel". 05 LINE 16 COLUMN 1 PIC X(50) FROM ERROR-MESSAGE FOREGROUND-COLOR 4. *> Advanced AUTO usage with conditional processing 01 PRODUCT-ORDER-SCREEN. 05 BLANK SCREEN. 05 LINE 2 COLUMN 25 VALUE "PRODUCT ORDER ENTRY". 05 LINE 5 COLUMN 1 VALUE "Product Code:". 05 LINE 5 COLUMN 15 PIC X(12) USING PRODUCT-CODE AUTO REQUIRED UPPER HIGHLIGHT. 05 LINE 7 COLUMN 1 VALUE "Quantity:". 05 LINE 7 COLUMN 15 PIC ZZZ,ZZ9 USING ORDER-QUANTITY AUTO REQUIRED HIGHLIGHT. 05 LINE 9 COLUMN 1 VALUE "Unit Price:". 05 LINE 9 COLUMN 15 PIC ZZZ,ZZ9.99 USING UNIT-PRICE AUTO BLANK WHEN ZERO HIGHLIGHT. 05 LINE 11 COLUMN 1 VALUE "Discount %:". 05 LINE 11 COLUMN 15 PIC ZZ9.99 USING DISCOUNT-PERCENT AUTO BLANK WHEN ZERO HIGHLIGHT. PROCEDURE DIVISION. MAIN-PROCESSING. PERFORM CUSTOMER-DATA-ENTRY PERFORM PROCESS-CUSTOMER-DATA GOBACK. CUSTOMER-DATA-ENTRY. MOVE SPACES TO ERROR-MESSAGE DISPLAY CUSTOMER-ENTRY-SCREEN *> AUTO fields will automatically advance cursor ACCEPT CUSTOMER-ENTRY-SCREEN *> Validate data after entry PERFORM VALIDATE-CUSTOMER-DATA IF ERROR-MESSAGE NOT = SPACES PERFORM CUSTOMER-DATA-ENTRY END-IF. VALIDATE-CUSTOMER-DATA. IF CUST-ID-INPUT = SPACES MOVE "Customer ID is required" TO ERROR-MESSAGE END-IF IF CUST-NAME-INPUT = SPACES MOVE "Customer Name is required" TO ERROR-MESSAGE END-IF IF CUST-ZIP-INPUT = SPACES MOVE "ZIP Code is required" TO ERROR-MESSAGE END-IF.

Basic AUTO clause usage in screen definitions for automatic cursor advancement.

Notice how each field with the AUTO attribute will automatically advance the cursor when the field is completely filled. This creates a smooth data entry experience where users can type continuously without manual cursor movement. The combination with REQUIRED and HIGHLIGHT attributes creates a professional, user-friendly interface that guides users through the data entry process efficiently.

Advanced AUTO Implementation Patterns

Advanced AUTO usage involves sophisticated combinations with other screen attributes and validation logic to create comprehensive user interface systems. These patterns include conditional AUTO behavior, dynamic field enabling/disabling, and integration with complex business validation rules. Such implementations are essential for enterprise applications requiring sophisticated user interface control.

Modern COBOL screen programming leverages AUTO clauses in conjunction with function keys, screen navigation controls, and data validation frameworks to create complete interactive systems. These systems must handle various user interaction patterns, error conditions, and business requirements while maintaining optimal performance and user experience standards.

cobol
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
*> Advanced AUTO patterns with conditional processing IDENTIFICATION DIVISION. PROGRAM-ID. ADVANCED-AUTO-DEMO. DATA DIVISION. WORKING-STORAGE SECTION. 01 TRANSACTION-DATA. 05 TRANS-TYPE PIC X(1). 05 ACCOUNT-NUMBER PIC X(12). 05 AMOUNT PIC 9(8)V99. 05 DESCRIPTION PIC X(40). 05 REFERENCE-NUMBER PIC X(15). 05 AUTHORIZATION-CODE PIC X(8). 01 SCREEN-ATTRIBUTES. 05 AUTO-ENABLED PIC X(1) VALUE 'Y'. 05 VALIDATION-LEVEL PIC 9(1) VALUE 1. 05 USER-EXPERIENCE-MODE PIC X(10) VALUE "STANDARD". SCREEN SECTION. 01 TRANSACTION-SCREEN. 05 BLANK SCREEN. 05 LINE 2 COLUMN 20 VALUE "TRANSACTION PROCESSING". *> Transaction type with AUTO and validation 05 LINE 5 COLUMN 1 VALUE "Transaction Type (D/C/T):". 05 LINE 5 COLUMN 25 PIC X(1) USING TRANS-TYPE AUTO REQUIRED UPPER HIGHLIGHT. *> Account number - AUTO enabled conditionally 05 LINE 7 COLUMN 1 VALUE "Account Number:". 05 LINE 7 COLUMN 17 PIC X(12) USING ACCOUNT-NUMBER AUTO REQUIRED HIGHLIGHT. *> Amount field with specialized AUTO behavior 05 LINE 9 COLUMN 1 VALUE "Amount:". 05 LINE 9 COLUMN 17 PIC ZZZ,ZZZ,ZZ9.99 USING AMOUNT AUTO REQUIRED HIGHLIGHT. *> Description - AUTO with variable length handling 05 LINE 11 COLUMN 1 VALUE "Description:". 05 LINE 11 COLUMN 17 PIC X(40) USING DESCRIPTION AUTO HIGHLIGHT. *> Conditional fields based on transaction type 05 LINE 13 COLUMN 1 VALUE "Reference Number:". 05 LINE 13 COLUMN 19 PIC X(15) USING REFERENCE-NUMBER AUTO HIGHLIGHT. 05 LINE 15 COLUMN 1 VALUE "Auth Code:". 05 LINE 15 COLUMN 19 PIC X(8) USING AUTHORIZATION-CODE AUTO UPPER HIGHLIGHT. *> Dynamic AUTO control based on business rules PROCEDURE DIVISION. TRANSACTION-PROCESSING. PERFORM INITIALIZE-SCREEN PERFORM PROCESS-TRANSACTION-ENTRY PERFORM VALIDATE-TRANSACTION PERFORM SAVE-TRANSACTION-DATA GOBACK. INITIALIZE-SCREEN. MOVE SPACES TO TRANSACTION-DATA MOVE 'Y' TO AUTO-ENABLED *> Set initial screen state DISPLAY TRANSACTION-SCREEN. PROCESS-TRANSACTION-ENTRY. *> Enhanced AUTO processing with dynamic control ACCEPT TRANSACTION-SCREEN *> Process based on transaction type EVALUATE TRANS-TYPE WHEN 'D' PERFORM PROCESS-DEBIT-TRANSACTION WHEN 'C' PERFORM PROCESS-CREDIT-TRANSACTION WHEN 'T' PERFORM PROCESS-TRANSFER-TRANSACTION WHEN OTHER PERFORM HANDLE-INVALID-TRANS-TYPE END-EVALUATE. PROCESS-DEBIT-TRANSACTION. *> Debit transactions require authorization IF AUTHORIZATION-CODE = SPACES DISPLAY "Authorization code required for debit transactions" PERFORM REENTER-AUTHORIZATION END-IF. PROCESS-CREDIT-TRANSACTION. *> Credit transactions may skip some fields IF REFERENCE-NUMBER = SPACES MOVE "AUTO-GENERATED" TO REFERENCE-NUMBER END-IF. PROCESS-TRANSFER-TRANSACTION. *> Transfer transactions require all fields PERFORM VALIDATE-ALL-FIELDS IF AMOUNT > 10000 PERFORM REQUIRE-MANAGER-APPROVAL END-IF.

Advanced AUTO implementation with conditional processing and business logic integration.

AUTO Performance and User Experience Optimization

cobol
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
*> Performance-optimized AUTO implementation 01 PERFORMANCE-METRICS. 05 FIELDS-PROCESSED PIC 9(5) VALUE 0. 05 AUTO-ADVANCES PIC 9(5) VALUE 0. 05 MANUAL-ADVANCES PIC 9(5) VALUE 0. 05 VALIDATION-FAILURES PIC 9(3) VALUE 0. *> Optimized screen with intelligent AUTO usage 01 HIGH-PERFORMANCE-SCREEN. 05 BLANK SCREEN. *> Fast-entry fields with optimized AUTO 05 LINE 5 COLUMN 1 VALUE "Code:". 05 LINE 5 COLUMN 7 PIC X(6) USING PRODUCT-CODE AUTO UPPER REQUIRED. 05 LINE 5 COLUMN 15 VALUE "Qty:". 05 LINE 5 COLUMN 20 PIC ZZ9 USING QUANTITY AUTO REQUIRED. 05 LINE 5 COLUMN 25 VALUE "Price:". 05 LINE 5 COLUMN 32 PIC ZZZ9.99 USING UNIT-PRICE AUTO. *> Intelligent AUTO control for optimal UX PROCEDURE DIVISION. OPTIMIZED-DATA-ENTRY. PERFORM SETUP-PERFORMANCE-MONITORING PERFORM HIGH-SPEED-DATA-ENTRY PERFORM REPORT-PERFORMANCE-METRICS. SETUP-PERFORMANCE-MONITORING. INITIALIZE PERFORMANCE-METRICS MOVE FUNCTION CURRENT-DATE TO START-TIME. HIGH-SPEED-DATA-ENTRY. DISPLAY HIGH-PERFORMANCE-SCREEN *> Optimized accept with AUTO field tracking ACCEPT HIGH-PERFORMANCE-SCREEN ADD 1 TO FIELDS-PROCESSED *> Track AUTO effectiveness IF CURSOR-ADVANCED-AUTOMATICALLY ADD 1 TO AUTO-ADVANCES ELSE ADD 1 TO MANUAL-ADVANCES END-IF.

AUTO Clause Best Practices

Enterprise AUTO Implementation Guidelines

  • Consistent Field Sizing: Ensure AUTO fields have predictable, fixed lengths
  • Logical Field Flow: Arrange AUTO fields in natural data entry sequence
  • Validation Integration: Combine AUTO with appropriate validation attributes
  • User Feedback: Provide clear visual indicators for AUTO-enabled fields
  • Error Handling: Implement robust error handling for AUTO field processing
  • Performance Monitoring: Track AUTO usage metrics for optimization

Common AUTO Implementation Patterns

Sequential Data Entry Pattern

Implement AUTO on consecutive fields for rapid data entry workflows.

cobol
1
2
3
4
*> Sequential entry with AUTO progression 05 FIELD-1 PIC X(10) USING DATA-1 AUTO REQUIRED. 05 FIELD-2 PIC X(15) USING DATA-2 AUTO REQUIRED. 05 FIELD-3 PIC 9(8) USING DATA-3 AUTO.

Conditional AUTO Pattern

Enable AUTO based on field content or business rules.

cobol
1
2
3
4
5
6
*> Conditional AUTO based on field type IF FIELD-TYPE = "FIXED" MOVE AUTO-ATTRIBUTE TO FIELD-CONTROL ELSE MOVE MANUAL-ATTRIBUTE TO FIELD-CONTROL END-IF.

Validation-Integrated AUTO Pattern

Combine AUTO with validation for complete field processing.

cobol
1
2
3
4
5
6
*> AUTO with integrated validation 05 VALIDATED-FIELD PIC X(12) USING INPUT-DATA AUTO REQUIRED UPPER HIGHLIGHT.

Frequently Asked Questions

Q: What happens if a user doesn't fill an AUTO field completely?

The cursor will not automatically advance. Users must manually press Tab or Enter to move to the next field. This behavior ensures data integrity and prevents unwanted cursor movement.

Q: Can AUTO be used with variable-length fields?

AUTO works best with fixed-length fields. For variable-length fields, the cursor advances when the maximum field length is reached, which may not always be desired behavior.

Q: How does AUTO interact with field validation?

AUTO cursor movement occurs independently of validation. The cursor advances when the field is full, regardless of whether the data is valid. Validation should be performed separately.

Q: Can AUTO be disabled at runtime?

AUTO is typically set at screen definition time. Dynamic control requires redisplaying the screen with different attribute settings or using compiler-specific extensions.

Q: What's the difference between AUTO and AUTO-SKIP?

AUTO advances to the next field when current field is full. AUTO-SKIP automatically skips the field entirely during cursor movement, typically used for display-only fields.

Practice Exercises

Exercise 1: Basic AUTO Implementation

Create a customer information screen with AUTO-enabled fields for efficient data entry.

Requirements:

  • Customer ID field (10 characters) with AUTO
  • Customer name field (30 characters) with AUTO
  • Phone number field (15 characters) with AUTO
  • All fields should be required and highlighted
  • Implement proper validation for each field

Exercise 2: Advanced AUTO Patterns

Build a transaction entry system with conditional AUTO behavior based on transaction type.

Requirements:

  • Transaction type field that determines subsequent field behavior
  • Amount field with AUTO and proper numeric formatting
  • Description field with AUTO for rapid entry
  • Authorization code field (conditional based on transaction type)
  • Implement business rule validation

Exercise 3: Performance-Optimized AUTO

Design a high-volume data entry screen optimized for maximum efficiency.

Requirements:

  • Multiple compact fields on single line with AUTO
  • Performance metrics tracking
  • Error handling that maintains cursor position
  • Function key support for rapid navigation
  • Batch processing capabilities

Knowledge Check Quiz

Question 1: AUTO Behavior

When does the AUTO clause cause cursor advancement?

A) When the user presses Enter
B) When the field is completely filled
C) When validation passes
D) When the field loses focus
Show Answer

B) When the field is completely filled - AUTO advances the cursor automatically when the field reaches its maximum length.

Question 2: AUTO and Validation

How does AUTO interact with field validation?

A) AUTO waits for validation to complete
B) AUTO triggers validation automatically
C) AUTO and validation are independent
D) AUTO disables validation
Show Answer

C) AUTO and validation are independent - AUTO moves the cursor based on field length, while validation is a separate process.

Question 3: AUTO Best Practices

What is a key consideration when implementing AUTO fields?

A) All fields must have AUTO
B) AUTO fields should have consistent, fixed lengths
C) AUTO eliminates the need for validation
D) AUTO only works with numeric fields
Show Answer

B) AUTO fields should have consistent, fixed lengths - This ensures predictable cursor advancement behavior and good user experience.

Related Topics

AUTO-SKIP

Learn about AUTO-SKIP for automatic field skipping in screen navigation.

ACCEPT

Understand ACCEPT statements for user input processing and screen interaction.

DISPLAY

Explore DISPLAY statements for screen output and user interface creation.

Screen Handling

Complete guide to COBOL screen programming and user interface development.