Read a root segment with a GU call
Read one IMS root segment by key with a GU call to CBLTDLI and a qualified SSA, then check the PCB status code, in Enterprise COBOL 6.4.
GU (get unique) fetches a specific segment from the top of the database, so it is the call for a keyed lookup.
01 DLI-GU PIC X(4) VALUE 'GU '.
01 CUST-SSA.
05 FILLER PIC X(8) VALUE 'CUSTOMER'.
05 FILLER PIC X VALUE '('.
05 FILLER PIC X(8) VALUE 'CUSTKEY '.
05 FILLER PIC XX VALUE ' ='.
05 SSA-KEY PIC X(5).
05 FILLER PIC X VALUE ')'.
...
MOVE '00042' TO SSA-KEY.
CALL 'CBLTDLI' USING DLI-GU DB-PCB CUST-IO-AREA CUST-SSA.The call passes the function code, the database PCB, an I/O area for the segment and the SSA. The function code is four bytes, so GU has two trailing blanks. A status code of two blanks in DB-PCB means success, and GE means no segment matched.
A qualified SSA has the segment name in 8 bytes, then (, an 8-byte field name, a 2-byte operator such as = with a leading blank, the value, and ). A wrong length shifts every later field and gives status AJ (invalid SSA). On a root with a unique key, GU is direct, while a non-unique field needs a scan. This is the DL/I interface in IMS 15.