IMS DB Command Codes

Command codes are special one-letter modifiers that can be included in SSAs to alter the behavior of DL/I calls, providing more control and efficiency in database operations. Command codes are single-character instructions that modify how DL/I processes a call. By incorporating command codes into SSAs, you can:

  • Reduce the number of DL/I calls needed.
  • Retrieve multiple segments in a single call.
  • Control the position and parentage in the database hierarchy.
  • Manage concurrent access to segments.​

Incorporating Command Codes into SSAs:

To include a command code in an SSA:

  • Insert an asterisk '*' in the 9th position immediately after the segment name.
  • Follow the asterisk with the desired command code(s).
  • Unqualified SSA: The command code is followed by a space. Format -
    01 QUALIFIED-SSA.
       05 SEGMENT-NAME  PIC X(8).
       05 FILLER        PIC X VALUE '*'.
       05 COMMAND-CODE  PIC X.
       05 FILLER        PIC X.
  • Qualified SSA: The command code is followed by a left parenthesis (. Format -
    01 QUALIFIED-SSA.
       05 SEGMENT-NAME  PIC X(8).
       05 FILLER        PIC X VALUE '*'.
       05 COMMAND-CODE  PIC X.
       05 FILLER        PIC X     VALUE '('.
       05 FIELD-NAME    PIC X(8).
       05 REL-OPR       PIC X(2).
       05 SEARCH-VALUE  PIC X(n).
       05 FILLER        PIC X     VALUE ')'.

Common Command Codes:

CodeNameDescription
CConcatenated KeyAllows access to a segment by specifying a concatenated key of all parent segments. Useful when all higher-level keys are known.
DPath Call. Retrieve the segment and all its dependents.
FFirst occurrence of the segmentAllows access to a segment by specifying a concatenated key of all parent segments. Useful when all higher-level keys are known.
LLast occurrence of the segmentRetrieves the last occurrence of a segment type. Often used with GN or GNP calls.
NPath Call Ignore. Suppress replacement of higher-level segmentsUsed with D command to prevent replacement of higher-level segments during a path call.
PSet Parentage. Establish parentage at a higher levelEstablishes parentage at a higher level segment rather than the lowest level segment retrieved.
QEnqueue Segment. Enqueue the segment to prevent concurrent accessPrevents other programs from accessing a segment until the current program reaches a commit point.
UMaintain position at the current levelMaintains the current position at a specific level in the hierarchy during retrieval.
VMaintain parentage at current and higher levelsMaintains the current position at the specified level and all higher levels.
.Null Command CodePlaceholder indicating no command code is used. Useful for dynamic command code assignment.

Examples:

Scenario1 - Qualified SSA: To retrieve the last occurrence of the "EMPLOYEE" segment:

01 QUALIFIED-SSA.
   05 SEGMENT-NAME  PIC X(8) VALUE 'EMPLOYEE'.
   05 FILLER        PIC X     VALUE '*'.
   05 CMD-CODE      PIC X     VALUE 'L'.
   05 FILLER        PIC X     VALUE '('.
   05 FIELD-NAME    PIC X(8) VALUE 'EMPID  '.
   05 REL-OPR       PIC X(2) VALUE 'EQ'.
   05 SEARCH-VALUE  PIC X(5) VALUE '12345'.
   05 FILLER        PIC X     VALUE ')'.

Scenario2 - Unqualified SSA: To retrieve the first occurrence of the EMPLOYEE segment:

01 QUALIFIED-SSA.
   05 SEGMENT-NAME  PIC X(8) VALUE 'EMPLOYEE'.
   05 FILLER        PIC X     VALUE '*'.
   05 CMD-CODE      PIC X     VALUE 'L'.
   05 FILLER        PIC X     VALUE ' '.