In this example, a load module, shared object or a DLL available in several versions is to be replaced at runtime with a new version and extended by a new program unit with a new TAC. The exchange operation runs in three steps.
First of all, a number of files must be requested by KDCADMI, e.g. the version of load module/shared object/DLL loaded that is before the configuration (TAC, PROGRAM statement) is modified in a second step. The actual exchange takes place in the final step.
#include <kcadminc.h> /* Include file for the administration */
INIT
...
MGET /* Read in data (name, TAC,...) */
/* of prog. unit being replaced */
... Analyse input
/********************* 1st section:check and query *********************/
KDCADMI opcode=KC_GET_OBJECT /* Is space for the TAC PROGRAM,... */
/* statements reserved ? */
KDCADMI opcode=KC_GET_OBJECT /* Check whether TAC PROGRAM statements ... */
/* already exist */
KDCADMI opcode=KC_GET_OBJECT /* Determine current version of load module */
/* shared object */
if {error in section 1:
MPUT with PEND FI } /* If error message appears on screen */
/********************* 2nd section: dyn. generation *****************/
KDCADMI opcode=KC_CREATE_OBJECT
/* Insert PROGRAM statement */
KDCADMI opcode=KC_CREATE_OBJECT
/* Insert TAC statement */
if {error in section 2: RSET}/* roll back if fault in transaction */
/********************* 3rd section: replacing program ********************/ KDCADMI opcode=KC_MODIFY_OBJECT /* Exchange program unit */ MPUT /* Message on screen */ PEND FI
If errors occur in section 2, the RSET call is necessary to prevent inconsistent generation from occurring. The KC_CREATE_OBJECT operations must be specified for the objects shown in this sequence (PROGRAM TAC), otherwise openUTM is unable to generate the necessary references.