IMS DL/I Status Codes
IMS call returns GB status
When IMS call returns GB status, check the two-character PCB status code right after the failing DL/I call — blank means success, and anything else is a precise diagnosis.
What it means
- Every DL/I call returns a status in the PCB; a disciplined program tests it after every single call.
- GE (segment not found) is NORMAL at the end of sequential processing — it is only a problem when you expected data.
- GB (end of database) is how a sequential program knows it has read everything — the clean way to end the loop.
Common causes
- The SSA names a segment or field that does not exist in the DBD or PSB definition.
- The program reads past the last segment without testing for GE or GB first (infinite loop).
- The PCB in the PSB does not include the database or segment being accessed.
- A DLET or REPL was issued without a prior successful Get Hold (GHU/GHN) call.
How to diagnose
- Display the PCB status code immediately after the failing call — never assume it is blank.
- For GE on a GU call: the key or SSA does not match any segment — verify the key value in the SSA.
- For GB: confirm the loop treats it as end-of-data rather than an error.
- Cross-check PSBGEN/ACBGEN output: the PCB must reference the right DBD with the right processing options.
How to fix it
- Code the status check after every DL/I call: blank continues, GE/GB ends the loop, anything else goes to the error routine.
- Fix the SSA or the PSB definition when the status points to a definition mismatch.
- Always issue GHU before DLET or REPL — update calls require a held position.
Example: DL/I status check pattern (COBOL)
CALL 'CBLTDLI' USING GHU-CODE, PCB-MASK, SEG-IO-AREA, SSA1
IF PCB-STATUS-CODE = SPACES
PERFORM PROCESS-SEGMENT
ELSE
IF PCB-STATUS-CODE = 'GE'
SET END-OF-DATA TO TRUE
ELSE
DISPLAY 'DL/I ERROR: ' PCB-STATUS-CODE
PERFORM ABEND-ROUTINE
END-IF
END-IF
GE ends the loop cleanly; only unexpected codes go to the error routine.
Interview tip
- Q: An IMS program loops forever reading a database — the classic IMS call returns GB status symptom. What is the likely bug?
- A: It is not checking for GB (end of database) or GE (segment not found) after the GN call. Without the status test, the program re-reads the last segment forever. The fix is testing PCB-STATUS-CODE after every DL/I call.
Prevention checklist
- Standardize one status-check paragraph used after every DL/I call.
- Test with an empty database — GE on the first call must end the program cleanly.
- Keep PSB and DBD definitions in sync with what the program SSAs expect.
