IMS status GK: Different segment type, same level
IMS status code GK means an unqualified GN or GNP call worked and returned a segment of a different type from the previous call, at the same level of the hierarchy. It's informational, not an error.
Other names for this code
Also written as status code GK, IMS GK, DL/I status GK, GK status code.
What it means
An unqualified GN or GNP returns whatever segment comes next in hierarchic sequence. When that segment is a different type from the one returned by the previous call, but sits at the same level, DL/I sets GK in the PCB. The data is in the I/O area as usual.
Say CUSTOMER is the root and it has two child types at level 2, ORDER first and ADDRESS second. A program reads the last ORDER for a customer, and that order has no children. The next GN returns the first ADDRESS for the same customer. ADDRESS is at the same level as ORDER but is a different type, so the status is GK.
The level matters. If the last ORDER had ITEM children at level 3, the previous call would have returned an ITEM. Moving from ITEM up to ADDRESS is a move to a higher level, so the status would be GA, not GK. Only unqualified GN and GNP calls (and GHN and GHNP) return GK. Qualified calls never do, because they name the segment type.
Common causes
- An unqualified GN or GNP finished the twins of one segment type and moved to the first occurrence of the next type at the same level.
- The program reads every dependent of a parent with unqualified GNP calls, and the parent has more than one child type.
- The program treats any non-blank status as an error, so a normal GK stops the run.
How to find the problem
- Check the segment name feedback field in the PCB after the call. It names the segment type now in the I/O area.
- Check the segment level field. If it equals the level from the previous call and the name changed, GK is what IMS should return.
- Look at the DBD to see the order of child segment types under each parent. That order decides when GK appears.
How to fix it
- Treat GK as a successful call. Accept spaces, GA and GK as good results after a GN or GNP.
- Use the segment name feedback to pick the right record layout for the I/O area, since the type has changed.
- If you only want one segment type, use an SSA that names it. Then IMS won't return the other types and you won't see GK.
- Use GK as a cue that one group of twins is complete, for example to print a subtotal for the orders before handling addresses.
IBM documentation
IBM documentation: status GK. Use the documentation for your installed release.
Related codes
Questions
Is GK an error?
No. The call worked and the segment is in the I/O area. GK only tells you the segment type changed.
Why did I get GA instead of GK?
GA means the new segment is at a higher level than the last one. If the previous call returned a deeper child, moving to a sibling type of its parent counts as moving up, so you get GA.
Can GU return GK?
No. GK and GA are only set on unqualified GN and GNP calls and their hold forms.