U command code
As IMS satisfies each
level in a retrieval or ISRT call, a position on
the segment occurrence that satisfies that level is established. The
U command code prevents position from being moved from a segment during
a search of its hierarchic dependents.
If the segment has a unique sequence field, using this code is equivalent to qualifying the SSA so that it is equal to the current value of the key field. When a call is being satisfied, if the position is moved above the level that the U code was issued at, the code has no effect for the segment type whose parent changed position.
U is especially useful when unkeyed dependents or non-unique keyed segments are being processed. The position on a specific occurrence of an unkeyed or non-unique keyed segment can be held by using this code.
Example: Suppose you want to find out about the illness that brought a patient named Mary Warren to the clinic most recently, and about the treatments she received for that illness. The following figure shows the PATIENT, ILLNESS, and TREATMNT segments for Mary Warren.

GU call:
GU PATIENTb(PATNObbb=b05810
ILLNESSb*LGN call below with the U command
code: GN PATIENTb*U
ILLNESSb*U
TREATMNTIn this example, the U command code indicates to IMS that you want only TREATMNT segments that
are dependents of the ILLNESS and PATIENT segments on which IMS has established position. Issuing
the above GN call the first time retrieves the TREATMNT
segment with the key of 19860412. Issuing the GN call
the second time retrieves the TREATMNT segment with the key 19860418.
If you issue the call a third time, IMS returns
a not-found status code. The U command code tells IMS that, if it does not find a segment that
satisfies the lower qualification under this parent, it cannot continue
looking under other parents. If the U command code was not in the
PATIENT SSA, the third GN call causes IMS to move forward at the root level in an attempt
to satisfy the call. If you supply a U command code for a qualified
SSA, IMS ignores the U.
If used in conjunction with command code F or L, the U command code is disregarded at the level and all lower levels of SSA for that call.