L command code
You can use the L command code to retrieve the last occurrence of a particular segment type or to insert a segment as the last occurrence of a segment type.
Retrieving a segment as the last occurrence
The L command code indicates that you want to
retrieve the last segment occurrence that satisfies the SSA, or that
you want to insert the segment occurrence you are supplying as the
last occurrence of that segment type. Like F, L simplifies your programming
because you can go directly to the last occurrence of a segment type
without having to examine the previous occurrences with program logic,
if you know that it is the last segment occurrence that you want.
L can be used with GU
or GHU
, because IMS normally returns the first occurrence
when you use a GU
call. IMS disregards
L at the root level.
Using L with GU
, GN
,
and GNP
indicates to IMS that
you want the last occurrence of the segment type that satisfies the
qualification you have provided. The qualification is the segment
type or the qualification statement of the SSA. If you have supplied
just the segment type (an unqualified SSA), IMS retrieves the last occurrence of this segment
type under its parent.
For example, suppose you have this request using the medical hierarchy:
What was the illness that brought Jennifer Thompson, patient number 10345, to the clinic most recently?
GU PATIENTb(PATNObbb=b10345)
ILLNESSb*L
The first SSA gives IMS the number of the particular patient. The second SSA asks for the last occurrence (in this case, the first occurrence chronologically) of the ILLNESS segment for this patient.
Inserting a segment as the last occurrence
Use L with ISRT
only when the
segment has no key or a non-unique key, and the insert rule for the
segment is either FIRST or HERE. Using the L command code overrides
both FIRST and HERE for HDAM or PHDAM root segments and dependent
segments in any type of database.
Using the L command code
to override the RULES specification on the DBD applies only to the
path (either logical or physical) that you are using to access the
segment for the ISRT
call. For example, if you are
using the physical path to access the segment, the command code applies
to the physical path but not to the logical path. For clarification
of using command codes with the RULES specification, ask your database
administrator.