IMS DB DL/I Functions

The DL/I serves as the interface between application programs and the IMS database. DL/I functions are specific operations that an application can perform on the database, such as retrieving, inserting, updating, or deleting data.​

Each DL/I function is represented by a four-character code and is used as the first parameter in a DL/I call.

Declaring DL/I Functions in COBOL

In a COBOL program, DL/I function codes are typically defined in the Working-Storage Section as follows:

01 DLI-FUNCTIONS.
   05 DLI-GU        PIC X(4)    VALUE 'GU  '.
   05 DLI-GHU       PIC X(4)    VALUE 'GHU '.
   05 DLI-GN        PIC X(4)    VALUE 'GN  '.
   05 DLI-GHN       PIC X(4)    VALUE 'GHN '.
   05 DLI-GNP       PIC X(4)    VALUE 'GNP '.
   05 DLI-GHNP      PIC X(4)    VALUE 'GHNP'.
   05 DLI-ISRT      PIC X(4)    VALUE 'ISRT'.
   05 DLI-DLET      PIC X(4)    VALUE 'DLET'.
   05 DLI-REPL      PIC X(4)    VALUE 'REPL'.
   05 DLI-CHKP      PIC X(4)    VALUE 'CHKP'.
   05 DLI-XRST      PIC X(4)    VALUE 'XRST'.
   05 DLI-PCB       PIC X(4)    VALUE 'PCB '.

These function codes are used in DL/I calls to specify the desired operation.​

Categories of DL/I Functions

DL/I functions are broadly categorized into:

  • Get Functions: Used to retrieve data from the database.​
  • Update Functions: Used to modify the database (insert, delete, replace).​​
  • Other Functions: Used for database management tasks like checkpointing and restarting.​

Get Functions

Get functions are analogous to read operations and are used to fetch segments from the IMS database. The following Get functions are used in IMS DB −

  • Get Unique
  • Get Next
  • Get Next within Parent
  • Get Hold Unique
  • Get Hold Next
  • Get Hold Next within Parent

Get Unique

'GU' code is used for the Get Unique function. It retrieves a specific segment occurrence based on key values. The field values can be provided using segment search arguments. The syntax of a GU call is as follows −

CALL 'CBLTDLI' USING DLI-GU
                     PCB-MASK
                     IO-AREA
                     [SSA]

Get Next

'GN' code is used for the Get Next function. It retrieve the next segment in hierarchical sequence. The predefined pattern for accessing data segment occurrences is top down hierarchy, then left to right. The syntax of a GN call is as follows −

CALL 'CBLTDLI' USING DLI-GN
                     PCB-MASK
                     IO-AREA
                     [SSA]

Repeated GN calls traverse the database hierarchy sequentially.

Get Next within Parent

'GNP' code is used for the Get Next Parent function. It retrieve the next child segment under the current parent segment. The syntax of a GNP call is as follows −

CALL 'CBLTDLI' USING DLI-GNP
                     PCB-MASK
                     IO-AREA
                     [SSA]

Get Hold Unique

'GHU' code is used for Get Hold Unique. It retrieve a specific segment and hold it for update. The Get Hold Unique function equals to the Get Unique call except holding the segment for update. Given below is the syntax of a GHU call −

CALL 'CBLTDLI' USING DLI-GHU
                     PCB-MASK
                     IO-AREA
                     [SSA]

Get Hold Next

'GHN' code is used for Get Hold Next. It retrieve the next segment and hold it for update. The Get Hold Next function corresponds to the Get Next call except holding the segment for update. Given below is the syntax of a GHN call −

CALL 'CBLTDLI' USING DLI-GHU
                     PCB-MASK
                     IO-AREA
                     [SSA]

Get Hold Next within Parent

'GHNP' code is used for Get Hold Next within Parent. It retrieve the next child segment under the current parent and hold it for update. The Get Hold Next within Parent function corresponds to the Get Next within Parent call. Given below is the syntax of a GHNP call −

CALL 'CBLTDLI' USING DLI-GHNP
                     PCB-MASK
                     IO-AREA
                     [SSA]

Update Functions

Update functions allow application programs to modify the database by inserting, deleting, or replacing segments. These operations are performed using DL/I (Data Language/I) calls. Before performing an update, the segment should be retrieved using a "Get Hold" function. The following Update functions are used in IMS DB −

  • Insert
  • Delete
  • Replace

Insert

'ISRT' code is used for the Insert function. It adds a new segment to the database. It is used to change an existing database or load a new database. Given below is the syntax of an ISRT call −

CALL 'CBLTDLI' USING DLI-ISRT
                     PCB-MASK
                     IO-AREA
                     [SSA]

Delete

'DLET' code is used for the Delete function. It removes a segment from the database. Given below is the syntax of an DLET call −

CALL 'CBLTDLI' USING DLI-DLET
                     PCB-MASK
                     IO-AREA
                     [SSA]

Replace

'REPL' code is used for Get Hold Next within Parent. It updates the contents of a segment. Given below is the syntax of an REPL call −

CALL 'CBLTDLI' USING DLI-REPL
                     PCB-MASK
                     IO-AREA
                     [SSA]

Other DL/I Functions

In IMS DB, beyond the standard data retrieval and update operations, there are specialized functions designed to manage program execution and recovery. These include:

  • Checkpoint (CHKP)
  • Restart (XRST)
  • PCB

Checkpoint (CHKP)

The CHKP function is used to create a checkpoint during the execution of a program. This allows the program to be restarted from that point in case of a failure, ensuring data integrity and consistency. Given below is the syntax of an CHKP call −

CALL 'CBLTDLI' USING DLI-CHKP
                      PCB-MASK
                      CHECKPOINT-ID

CHECKPOINT-ID: An identifier for the checkpoint, typically a unique value.

Restart (XRST)

The XRST function is used to restart a program from the last established checkpoint. This is crucial for recovery in long-running or critical batch processes. Given below is the syntax of an XRST call −

CALL 'CBLTDLI' USING DLI-XRST
                      PCB-MASK
                      CHECKPOINT-ID

CHECKPOINT-ID: The identifier of the checkpoint from which to restart.

PCB

In CICS environments, the PCB function is used to retrieve the address of the Program Communication Block. This is essential for programs that need to access the PCB dynamically.​ Given below is the syntax of an PCB call −

CALL 'CBLTDLI' USING DLI-PCB
                      PCB-MASK
                      IO-AREA