IMS DB Segement Search Argument (SSA)
An SSA is a parameter used in DL/I (Data Language/I) calls to identify the specific segment or segments an application program intends to access within an IMS database. It is an optional parameter. We can include any number of SSAs depending on the requirement. There are two primary types:
- Unqualified SSA: Specifies only the segment name.
- Qualified SSA: Specifies the segment name along with conditions to identify a specific segment occurrence.
Unqualified SSA
An unqualified SSA identifies the segment type without specifying any particular occurrence. It's used when the program wants to access the next occurrence of a segment type without any search criteria. The syntax of a Unqualified SSA is as follows −
01 UNQUALIFIED-SSA.
05 SEGMENT-NAME PIC X(8).
05 FILLER PIC X VALUE SPACE.
- SEGMENT-NAME: The name of the segment, left-justified and padded with spaces to make 8 characters.
- FILLER: A single space character indicating it's an unqualified SSA.
Example:
If you have a segment named "EMPLOYEE", the unqualified SSA would be:
01 UNQUALIFIED-SSA.
05 SEGMENT-NAME PIC X(8).
05 FILLER PIC X.
Qualified SSA
A qualified SSA specifies the segment type along with a condition to identify a specific occurrence. It's used when the program needs to access a segment occurrence that meets certain criteria. The syntax of a Qualified SSA is as follows −
01 QUALIFIED-SSA.
05 SEGMENT-NAME PIC X(8).
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 ')'.
- SEGMENT-NAME: The name of the segment, left-justified and padded with spaces to make 8 characters.
- FILLER: A left parenthesis '(' indicating the start of the qualification.
- FIELD-NAME: The name of the field to be compared, left-justified and padded with spaces to make 8 characters.
- REL-OPR: A two-character relational operator (e.g., EQ, NE, GT, GE, LT, LE).
- EQ Equal to
- NE Not equal to
- GT Greater than
- GE Greater than or equal
- LT Less than
- LE Less than or equal
- SEARCH-VALUE: The value to compare against the field.
- FILLER: A right parenthesis ')' indicating the end of the qualification.
Example:
To access a "EMPLOYEE" segment where the "EMPID" field equals "12345":
01 QUALIFIED-SSA.
05 SEGMENT-NAME PIC X(8) VALUE 'EMPLOYEE'.
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 ')'.
Multiple Qualifications
Multiple qualifications allow you to specify more than one condition within a single SSA to narrow down the segment occurrences you want to access. IMS supports the following Boolean operators to combine multiple qualifications:
- AND: Represented by & or *. All conditions must be true for the segment to be selected.
- OR: Represented by + or |. At least one condition must be true for the segment to be selected.
A multiple qualification SSA extends the structure of a qualified SSA by including additional field conditions separated by Boolean operators. Here's the general structure:
01 QUALIFIED-SSA.
05 SEGMENT-NAME PIC X(8).
05 FILLER PIC X VALUE '('.
05 FIELD-NAME1 PIC X(8).
05 REL-OPR1 PIC X(2).
05 SEARCH-VALUE1 PIC X(n).
05 BOOLEAN-OPERATOR PIC X VALUE '&'.
05 FIELD-NAME2 PIC X(8).
05 REL-OPR2 PIC X(2).
05 SEARCH-VALUE2 PIC X(m).
05 FILLER PIC X VALUE ')'.
Example:
Suppose you want to retrieve EMPLOYEE segments where the EMPID is greater than or equal to 1000 and less than or equal to 2000.
01 QUALIFIED-SSA.
05 SEGMENT-NAME PIC X(8) VALUE 'EMPLOYEE'.
05 FILLER PIC X VALUE '('.
05 FILLER PIC X(08) VALUE 'EMPID'.
05 REL-OPR1 PIC X(2) VALUE '>='.
05 CUSTID-LOW PIC X(4) VALUE '1000'.
05 FILLER PIC X VALUE '&'.
05 FILLER PIC X(08) VALUE 'EMPID'.
05 REL-OPR2 PIC X(2) VALUE '<='.
05 CUSTID-HIGH PIC X(4) VALUE '2000'.
05 FILLER PIC X VALUE ')'.