Mainframe Path Start learning free
Core12 min readLesson 3 of 4

DL/I calls from COBOL

A COBOL program talks to IMS by calling CBLTDLI with a function code, a PCB, an I/O area and optional segment search arguments (SSAs). After every call it checks the two-character status code in the PCB.

The call

COBOL: read one customer
    CALL 'CBLTDLI' USING DLI-GU
                         CUSTDB-PCB
                         CUSTOMER-SEG
                         CUSTOMER-SSA
    EVALUATE CUSTDB-STATUS
       WHEN SPACES  PERFORM PROCESS-CUSTOMER
       WHEN 'GE'    PERFORM CUSTOMER-NOT-FOUND
       WHEN OTHER   PERFORM DLI-ERROR
    END-EVALUATE

The program receives its PCBs as parameters. In a batch DL/I or BMP program the entry point is typically ENTRY 'DLITCBL' USING IO-PCB CUSTDB-PCB, or the PROCEDURE DIVISION USING clause; the PCBs map onto LINKAGE SECTION structures that include the status code field.

Function codes

CodeMeaning
GUGet unique: go straight to a specific segment
GNGet next: the next segment in hierarchical sequence
GNPGet next within parent: the next child under the current parent
GHU / GHN / GHNPThe same, but hold the segment so it can be replaced or deleted
ISRTInsert a new segment (or send a message on the I/O PCB)
REPLReplace the held segment
DLETDelete the held segment and its dependents

Segment search arguments

An SSA tells IMS which segment you want. An unqualified SSA is just the 8-character segment name. A qualified SSA adds a condition in brackets: field name, operator and value.

A qualified SSAWhat it means
CUSTOMER
Segment name, padded to 8 characters
(
Start of the qualification
CUSTNO
Field name from the DBD, padded to 8 characters
=
Relational operator, 2 characters (EQ, =, GT, >= and so on)
0000012345
The value, the same length as the field
)
End of the qualification

Status codes you must know

StatusMeaning
spacesCall succeeded
GESegment not found
GBEnd of database reached on a GN
GA / GKGN moved to a different level (GA) or segment type at the same level (GK); informational
IIInsert failed: a segment with that key already exists
DJREPL or DLET without a preceding successful get-hold
ADInvalid function code
QCNo more input messages (online programs reading the I/O PCB)

An online program's shape

  1. GU on the I/O PCB to get the input message.
  2. Read and update databases with DL/I calls on the database PCBs.
  3. ISRT on the I/O PCB to send the reply.
  4. Loop back for the next message until GU returns QC.

Long-running BMPs take checkpoints (CHKP) at intervals to commit their work and release locks, and can be restarted from the last checkpoint with XRST.

TRY IT YOURSELF

A program issues GU for customer 12345 and gets status GE. What does that mean? Answer in two or three words.

Show a hint

It is the IMS equivalent of SQLCODE +100.

Show the solution

Segment not found: no CUSTOMER segment matched the SSA. It is a normal business result to handle, not an abend.

Common mistakes

REPL without a get-hold

Replace and delete need a GHU, GHN or GHNP first. Without it you get status DJ.

Treating GE and GB as abends

Not found and end of database are normal results. Handle them in the program's logic.

Mis-sized SSA fields

Segment and field names are 8 characters and the value must match the field length. A one-byte error quietly changes the search.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
← Hierarchical data: segments, DBDs and PSBsIMS in production →