COBOL Tutorial

Progress0 of 0 lessons

COBOL User Interface Design

User interface design in COBOL means how users see and interact with your program: batch reports, console I/O (DISPLAY and ACCEPT), or interactive screens (e.g. CICS with BMS and 3270). Good design uses clear labels, sensible field order, helpful error messages, and consistent layout. This page gives an overview of UI options in COBOL and principles that apply to each.

Explain Like I'm Five: What Is UI in COBOL?

The user interface is what the user sees and uses. In batch, that might be a printed report: titles, columns, and totals. In an interactive program, it is the screen: where the user types (fields) and what they read (labels and messages). Designing the UI means deciding where things go, what to call them, and what to say when something goes wrong so the user can understand and correct it.

Types of COBOL User Interfaces

Common UI types in COBOL
TypeDescriptionDesign focus
BatchReports, listings, job outputReport layout, headings, totals, column alignment
Console (DISPLAY/ACCEPT)Simple terminal I/OClear prompts, readable output, validation messages
CICS / 3270 (BMS)Form-based screensMap layout, field order, labels, protected/unprotected, error lines

Batch: Reports and Listings

In batch, the "interface" is the report or listing the program produces. Design includes: report title and page headers, column headings, alignment of data (numbers right-aligned, text left-aligned), control breaks and subtotals, and grand totals. Use consistent column positions and edited PICTUREs so output is readable. See Report Generation and Output Formatting for details.

Console: DISPLAY and ACCEPT

DISPLAY sends data to the console (or system output). ACCEPT reads from the console (or system input). For a simple UI, use clear prompts (DISPLAY "Enter customer ID: ") before each ACCEPT, and DISPLAY error or confirmation messages after validation. Keep prompts short and place them where the user expects them. Validate input and show a clear message when input is invalid.

cobol
1
2
3
4
5
6
7
DISPLAY "Enter customer number (1-99999): " ACCEPT WS-CUST-NUM IF WS-CUST-NUM < 1 OR WS-CUST-NUM > 99999 DISPLAY "Invalid. Please enter 1 to 99999." ELSE DISPLAY "Accepted: " WS-CUST-NUM END-IF

CICS and BMS: 3270 Screens

In CICS, screens are usually defined with BMS (Basic Mapping Support). You define a mapset and maps with field positions and attributes. BMS generates symbolic maps that your COBOL program copies in; you move data to the map fields and SEND the map, or RECEIVE into the map and read the fields. Design the map so labels are in one area (e.g. left), input fields in a consistent column, and a line reserved for messages. Use protected attributes for labels and unprotected for input. Keep the tab order logical (top to bottom, left to right).

Principles for Good UI Design

  • Clarity: labels and messages should be clear and, where possible, free of jargon.
  • Consistency: use the same column positions, wording style, and message placement across screens or reports.
  • Feedback: after an action or validation failure, tell the user what happened and what to do next.
  • Layout: align fields and headings so the eye can scan easily; avoid crowding.
  • Error handling: validate input and display specific, actionable error messages (e.g. "Customer number must be 1–99999").

Step-by-Step: Designing a Simple Screen (BMS idea)

  • Sketch the screen: title at top, then rows of label + input field, then a message line at the bottom.
  • Define the mapset and map in BMS; define each field with position and attributes (protected for labels, unprotected for input).
  • In COBOL, copy the symbolic map, MOVE data to output fields or move user input from received map fields.
  • SEND the map to display it; RECEIVE to get user input; validate and either process or SEND again with an error message.

Test Your Knowledge

1. For simple console input and output in COBOL, you use:

  • READ and WRITE only
  • DISPLAY and ACCEPT
  • SEND and RECEIVE only
  • BMS only

2. BMS in CICS is used for:

  • Sorting files
  • Defining 3270 screen layouts and maps
  • Database access
  • Report Writer

Related Concepts

Related Pages