IMS DB Delete (DLET)

The 'DLET' (Delete) call is a DL/I function used to remove a segment and all its dependent segments from the database. Before issuing a 'DLET' call, the target segment must be retrieved and held using a Get Hold call such as 'GHU', 'GHN', or 'GHNP'. This ensures that the segment is locked for update, preventing other processes from modifying it during the deletion process. In a COBOL program, the 'DLET' call is made using the following syntax:​

CALL 'CBLTDLI' USING
    DLI-DLET
    DB-PCB
    IO-AREA
    [SSA]
  • DLI-DLET: A 4-character field with the value 'DLET', indicating the Delete function.
  • DB-PCB: The Program Communication Block for the database, defined in the LINKAGE SECTION. It specifies the database to be accessed and contains status codes and other information after the call.
  • IO-AREA: The area in the WORKING-STORAGE SECTION where the retrieved segment data will be placed.
  • SSA1, SSA2, ...: Optional. Defines the segment type and optional qualification criteria for the retrieval.

Return Codes

After executing a 'DLET' call, IMS sets a status code in the DB-PCB to indicate the outcome:

  • Blank (' '): Call was successful; segment deleted.
  • DJ: Delete call issued without a preceding Get Hold call.
  • DA: Attempted to delete a segment with a modified key field.​

Example

Scenario - Below is a simplified example of a COBOL program that uses the 'DLET' call to delete an 'EMPLOYEE' segment from an IMS database:

Hierarchical Structure -

COMPANY       ← root segment  
 └─ PROJECT    ← child of COMPANY  
      └─ EMPLOYEE   ← child of PROJECT 

Program -

IDENTIFICATION DIVISION.
PROGRAM-ID. DELETEE.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.

DATA DIVISION.
WORKING-STORAGE SECTION.

* DL/I FUNCTION CODES
01 DL-I-CODES.
   05 DLI-GHU     PIC X(4) VALUE 'GHU '.
   05 DLI-DLET    PIC X(4) VALUE 'DLET'.

* I/O AREA for segment data
01 IO-AREA.
   05 COMPANY-ID          PIC X(5).
   05 COMPANY-NAME        PIC X(30).
   05 PROJECT-ID          PIC X(5).
   05 PROJECT-NAME        PIC X(30).
   05 EMPLOYEE-ID         PIC X(5).
   05 EMPLOYEE-NAME       PIC X(25).

* SSA STRINGS to locate segment
01 SSA-STRINGS.
   05 SSA-COMPANY         PIC X(30) 
		VALUE 'COMPANY(COMPANY-ID =C001)'.
   05 SSA-PROJECT         PIC X(30) 
		VALUE 'PROJECT(PROJECT-ID =P105)'.
   05 SSA-EMPLOYEE        PIC X(35) 
		VALUE 'EMPLOYEE(EMPLOYEE-ID=E999)'.

LINKAGE SECTION.	
* PCB MASK
01 EMP-PCB.
   05 DBD-NAME            PIC X(8).
   05 SEG-LEVEL           PIC XX.
   05 STATUS-CODE         PIC XX.
   05 PROC-OPTIONS        PIC X(4).
   05 FILLER              PIC X(4).
   05 SEGMENT-NAME-FB     PIC X(8).
   05 LENGTH-KEY-FB       PIC S9(5) COMP.
   05 NUM-SENSITIVES      PIC S9(5) COMP.
   05 KEY-FEEDBACK        PIC X(50).

PROCEDURE DIVISION.

    DISPLAY "=== BEGIN: DELETE EMPLOYEE ===".

    * Step 1: Get and hold the specific EMPLOYEE
    CALL 'CBLTDLI' USING DLI-GHU,
                         EMP-PCB,
                         IO-AREA,
                         SSA-COMPANY,
                         SSA-PROJECT,
                         SSA-EMPLOYEE

    IF STATUS-CODE = '  '
        DISPLAY "EMPLOYEE HELD FOR DELETE:"
        DISPLAY "   EMPLOYEE ID   : " EMPLOYEE-ID
        DISPLAY "   EMPLOYEE NAME : " EMPLOYEE-NAME

        * Step 2: Delete the segment
        CALL 'CBLTDLI' USING DLI-DLET,
                             EMP-PCB,
                             IO-AREA

        IF STATUS-CODE = '  '
            DISPLAY "EMPLOYEE DELETED SUCCESSFULLY"
        ELSE
            DISPLAY "** DELETE FAILED. STATUS = " STATUS-CODE
        END-IF
    ELSE
        DISPLAY "** EMPLOYEE NOT FOUND. STATUS = " STATUS-CODE
    END-IF.

    DISPLAY "=== END OF PROGRAM ===".
    GOBACK.

Sample Output

=== BEGIN: DELETE EMPLOYEE ===
EMPLOYEE HELD FOR DELETE:
   EMPLOYEE ID   : E999
   EMPLOYEE NAME : ALAN RICKMAN
EMPLOYEE DELETED SUCCESSFULLY
=== END OF PROGRAM ===