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:
Code | Name | Description |
---|---|---|
C | Concatenated Key | Allows access to a segment by specifying a concatenated key of all parent segments. Useful when all higher-level keys are known. |
D | Path Call. | Retrieve the segment and all its dependents. |
F | First occurrence of the segment | Allows access to a segment by specifying a concatenated key of all parent segments. Useful when all higher-level keys are known. |
L | Last occurrence of the segment | Retrieves the last occurrence of a segment type. Often used with GN or GNP calls. |
N | Path Call Ignore. Suppress replacement of higher-level segments | Used with D command to prevent replacement of higher-level segments during a path call. |
P | Set Parentage. Establish parentage at a higher level | Establishes parentage at a higher level segment rather than the lowest level segment retrieved. |
Q | Enqueue Segment. Enqueue the segment to prevent concurrent access | Prevents other programs from accessing a segment until the current program reaches a commit point. |
U | Maintain position at the current level | Maintains the current position at a specific level in the hierarchy during retrieval. |
V | Maintain parentage at current and higher levels | Maintains the current position at the specified level and all higher levels. |
. | Null Command Code | Placeholder 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 ' '.