IMS status GB: End of database
IMS status code GB means a GN (Get Next) call reached the end of the database without finding another segment to return. It's the normal end-of-file signal for a program that reads an IMS database sequentially.
Other names for this code
Also written as status code GB, IMS GB, DL/I status GB, GB end of database, PCB status GB.
What it means
A batch program or BMP that reads a whole database issues GN or GHN calls in a loop. Each call returns the next segment in hierarchic sequence. When there is nothing left, DL/I sets GB in the database PCB and returns no data. This isn't an error. It tells the program to stop reading.
GB comes back on GN calls. An unqualified GN gets it when it runs off the end of the database. A qualified GN without an upper key limit gets it when the search runs to the end without returning anything. Other calls report the same situation differently. A GU that finds nothing gets GE. A qualified GN with a maximum key gets GE. A GNP gets GE when it runs out of children under its parent, because a GNP never looks past its parent. For a Fast Path DEDB where the program has set a range with a SETR statement, GB can also mean the end of that range.
After GB, IMS resets the position for that PCB. The next call starts from the beginning of the database. That's why a loop that ignores GB and keeps issuing GN can read the database again from the top instead of stopping.
Common causes
- The program has read every segment it is sensitive to. This is the normal end of a sequential pass.
- A qualified GN asked for keys beyond the highest key in the database, for example any root with a key greater than a value that is already past the last root.
- The database is empty, or much smaller than expected. This happens in test systems more than production.
- The program uses the wrong PCB. If the PCB order in the program's entry statement doesn't match the order in the PSB, the program may be reading a different, smaller database than it thinks.
- For a DEDB, the SETR range ended before the program expected it to.
How to find the problem
- Display the database PCB status after each GN and count the segments read. If GB comes much earlier than expected, compare the count with the database's record count from your last unload or reorganization.
- Check the DBD name in the PCB. Make sure the PCBs in the program's entry or ENTRY DLITCBL statement are listed in the same order as in the PSB.
- If a qualified GN gets GB, display the SSA and compare the key range it asks for with the highest key actually in the database.
- If the program read the database twice, look for a loop that doesn't test for GB.
How to fix it
- End the read loop on GB. Close files, write totals and finish normally.
- Handle GB and GE together in qualified GN loops, since either can mean there is nothing more to read.
- If GB arrives too early, fix the PCB order or the database the job points to, then rerun.
- Don't issue another GN after GB unless you mean to start again from the first root.
IBM documentation
IBM documentation: status GB. Use the documentation for your installed release.
Related codes
Questions
Is GB an error?
No. It's the normal signal that a GN has reached the end of the database. A program reading sequentially should expect it once per pass.
Why did my qualified GN return GE instead of GB?
IMS returns GE for a qualified GN that has a maximum key in its SSA and finds nothing. GB is for an unqualified GN, or a qualified one with no upper limit, that runs to the end.
Can a GNP call return GB?
No. A GNP stays under its established parent, so when it runs out of children it returns GE.