CICS BMS MAPFAIL and Field Validation: A Practical Pattern for Reliable Online Screens
Learn a practical COBOL/CICS pattern for handling BMS MAPFAIL, validating fields safely, routing PF keys, and supporting reliable online screens.
Short introduction
A CICS screen can appear simple: send a BMS map, let the user type a value, receive the map, and process the request. In a production application, the boundary between “no input arrived,” “input is invalid,” and “the screen definition is wrong” matters a great deal. When these cases are mixed together, users see misleading messages and support teams lose the evidence needed to resolve incidents.
MAPFAIL is one of the most misunderstood conditions in CICS online programs. It normally means a RECEIVE MAP command did not receive modified map data. It is not proof that a user entered a bad claim number, and it is not automatically a CICS outage. This article shows a supportable COBOL/CICS pattern for handling MAPFAIL, validating BMS input fields, and redisplaying a screen safely. Names and values are illustrative; use local map, copybook, security, and error-handling standards.
Real-world production use case
A service representative uses a CICS inquiry transaction to view the status of a healthcare claim. The first screen asks for a claim reference and a date of service. After the representative presses Enter, the program validates the fields, checks authorization, reads a current status record, and sends a results map.
During morning support, several users report that pressing Enter returns the same input screen with a generic “invalid request” message. Treating every MAPFAIL as invalid data would hide the difference between untouched input, a PF-key action, a map attribute issue, and a malformed value. Capture the command response and EIBAID, guide an untouched Enter back to the field, and reserve business-validation messages for data that actually arrived.
Step-by-step explanation
### 1. Understand what BMS sends to the program
A BMS map has input and output fields defined by the map and represented in a generated COBOL copybook. For an input field, the copybook commonly provides a length field and a data field, such as CLMNOI and CLMNO. The exact generated names and field behavior depend on the map definition and local conventions.
Before processing a field, use the received length and data area from the map copybook. Do not assume that every field contains a usable value merely because the program issued RECEIVE MAP. Users can press Enter without modifying an unprotected field, clear a field, or use an attention key. Also avoid relying on stale working-storage values from a prior task in a pseudo-conversational design.
### 2. Treat MAPFAIL as an input-state condition
Issue RECEIVE MAP with RESP and RESP2 handling. If the response is DFHRESP(MAPFAIL), send a focused message such as “Enter a claim reference or press PF3 to exit.” Then redisplay the input map and return for the next task.
This is not an application abend path, but it should not be silently ignored. A sudden increase after a map change can point to field protection, MDT, terminal, or flow issues. Log a minimal technical event according to site policy: transaction ID, program, map name, EIBAID, response values, and a non-sensitive correlation value.
### 3. Route attention keys before business validation
EIBAID indicates the attention identifier that started the task. A PF3 or PF12 should normally take an explicit navigation path rather than fall through to validation. Clear, PA, and other keys also need a documented behavior appropriate to the application.
Check the local standard for when to test EIBAID relative to RECEIVE MAP; map receipt and key handling conventions vary by application. The important result is that a user who selects Exit does not receive “claim reference is required,” and a user who presses Enter gets the intended validation path.
### 4. Validate syntax, then apply business rules
Once map data is present, validate each field in layers. First normalize allowed presentation details, such as surrounding blanks, only if the business rule permits it. Next validate syntax: required field, permitted characters, and expected date format. Only after those checks should the program invoke DB2, VSAM, or a service layer to determine whether the claim exists or is authorized for the user.
Keep validation messages specific and safe. “Enter an eight-character claim reference” tells the user how to correct input. “DB2 read failed for member 123...” does not belong on a public-facing screen. Technical details belong in controlled diagnostics; the user screen should offer a retry or an approved support message.
### 5. Redisplay without losing valid input
When one field fails validation, preserve acceptable fields where the map and security design allow it. Highlight or position the cursor at the field needing correction. Do not redisplay protected information that the user is no longer authorized to see, and do not retain sensitive values simply for convenience.
Every redisplay path must establish the next pseudo-conversational interaction. Send the map, then use RETURN TRANSID, passing only the required state through the approved COMMAREA or channel/container design. Ensure the error path uses the same mapset, transaction ID, and state version expected on the next entry.
Example COBOL/CICS pattern
The following simplified outline separates empty input from invalid input. It assumes that CLMNOI is the received length for the claim-reference field and that WS-RESP is a fullword response area.
WORKING-STORAGE SECTION.
01 WS-RESP PIC S9(8) COMP.
01 WS-RESP2 PIC S9(8) COMP.
01 WS-MESSAGE PIC X(60).
01 WS-VALID-INPUT PIC X VALUE 'N'.
PROCEDURE DIVISION.
EXEC CICS RECEIVE MAP('CLMINQ') MAPSET('CLMSET')
RESP(WS-RESP) RESP2(WS-RESP2)
END-EXEC
EVALUATE TRUE
WHEN EIBAID = DFHPF3 OR EIBAID = DFHPF12
PERFORM RETURN-TO-MENU
WHEN WS-RESP = DFHRESP(MAPFAIL)
MOVE 'ENTER A CLAIM REFERENCE OR PRESS PF3' TO WS-MESSAGE
PERFORM SEND-INPUT-MAP
PERFORM RETURN-FOR-INPUT
WHEN WS-RESP NOT = DFHRESP(NORMAL)
PERFORM LOG-CICS-RECEIVE-ERROR
PERFORM SEND-TECHNICAL-ERROR
PERFORM RETURN-FOR-INPUT
WHEN CLMNOI = 0
MOVE 'CLAIM REFERENCE IS REQUIRED' TO WS-MESSAGE
PERFORM SEND-INPUT-MAP
PERFORM RETURN-FOR-INPUT
WHEN OTHER
PERFORM VALIDATE-CLAIM-REFERENCE
IF WS-VALID-INPUT = 'Y'
PERFORM INQUIRE-CLAIM
ELSE
PERFORM SEND-INPUT-MAP
PERFORM RETURN-FOR-INPUT
END-IF
END-EVALUATE.
VALIDATE-CLAIM-REFERENCE.
IF CLMNOI NOT = 8
MOVE 'ENTER AN 8-CHARACTER CLAIM REFERENCE' TO WS-MESSAGE
ELSE
MOVE 'Y' TO WS-VALID-INPUT
END-IF.
RETURN-FOR-INPUT.
EXEC CICS RETURN TRANSID('CLMI') END-EXEC.
```
This is a flow example, not a complete production program. Use the generated map copybook, standard error routines, map attributes for cursor placement, and a defined state-passing method.
Common mistakes
- Treating
MAPFAILas a bad business value. No modified data is different from an invalid field. - Ignoring
RESPandRESP2. A non-normal receive error needs controlled diagnostics, not a generic redisplay. - Validating before checking exit keys. PF3 or PF12 can incorrectly produce required-field messages.
- Trusting old field contents. Pseudo-conversational tasks must use the current received map and approved state.
- Showing technical details on the BMS map. SQLCODEs, dataset names, and sensitive keys belong in protected diagnostics.
- Failing to return after an error redisplay. The screen may be sent without a proper next interaction.
- Changing map fields without regression tests. Protection, MDT, field lengths, and copybooks must stay aligned.
Practical checklist
- [ ] Confirm transaction ID, program, mapset, map, and generated copybook are from the intended release.
- [ ] Test first entry, untouched Enter, cleared required field, invalid format, valid input, PF3, and PF12.
- [ ] Check
RESPandRESP2afterRECEIVE MAPand other important CICS commands. - [ ] Handle
MAPFAILas a clear retry path with an actionable user message. - [ ] Route attention keys explicitly before normal business processing.
- [ ] Validate field length and syntax before DB2, VSAM, or service calls.
- [ ] Use safe diagnostics with transaction, program, response, and approved correlation information.
- [ ] Verify all redisplay paths issue the correct
RETURN TRANSIDand preserve only necessary state. - [ ] Regression-test map changes with the deployed copybook and a realistic terminal flow.
Summary
Reliable CICS screens depend on distinguishing input state from business validity. MAPFAIL usually tells the program that no modified map data arrived; it is a prompt to guide the user, not a reason to label a claim request invalid. By handling attention keys deliberately, validating received fields in layers, protecting technical details, and returning correctly after every redisplay, COBOL/CICS programs become easier to use and easier to support.
For production teams, the practical benefit is better evidence. A support analyst can tell whether the issue was untouched input, a format error, a map-flow problem, or a downstream data-access failure—without guessing and without exposing sensitive information.