After all processing is complete for a session, the application should terminate the session.
Application
In the DBCAREA, the application supplies the session id of the session to be terminated and sets the function code to disconnect (DBFDSC). Then it calls DBCHCL.
DBCHCL
DBCHCL generates a dummy request (including RCB and buffers). DBCHCL builds a Logoff parcel in the message body part of the Request Buffer for the dummy request. DBCHCL then sets the function code in the MTDP Control Block to MTDPLOFF and calls MTDP.
MTDP
MTDP terminates the session and then returns control to DBCHCL.
DBCHCL
All the requests attached to the disconnected session are removed by deallocating their buffers and RCBs, and then the associated SCB are removed from the session queue and returns it to the free memory pool. DBCHCL then returns a success code to the application program. If the return code in the MTDP Control Block is abnormal, DBCHCL returns an error message to the application.
Application
If the return code in the DBCAREA is not normal the application makes the appropriate changes and re-submits the DBCAREA to DBCHCL, as described above. Otherwise, the session is terminated.