TAGTEST: PACKAGE; %INCLUDE DTADKPLI; ADKPLI: PROC (IO_PCB,ALT_IOPCB) OPTIONS(MAIN); DCL PLITDLI ENTRY EXTERNAL; DCL IO_PCB POINTER; DCL ALT_IOPCB POINTER; DCL ERROR BIT(1) INIT('0'B); DCL WTOMSG CHAR(80) INIT(' '); /* This program demonstrates dynaTrace IMS ADK APIs. */ /* One group of APIs contains functions for starting and * ending a Purepath for the transaction and associated tagging * functions. A newer group of APIs permits nodes to be inserted * into a Purepath that is already in progress and to capture * its arguments or return value. The two groups of APIs are * unrelated, but they can be used within the same transaction. */ /* Optional name to describe the initial path. */ DCL PATHNAME CHAR(100) VARYING INIT('Started from tagging ADK'); /* Buffer to hold the tag that will identify a child path. * Note: DynaTrace 5.x requires a buffer of at least 77 bytes. */ DCL TAG_BUFFER CHAR(100) VARYING; DCL TAG_BUFFER_LEN FIXED BIN(31) INIT(100); DCL TERM_MSG CHAR(22) STATIC INIT('PL/I TAGTEST Complete.'); DCL TERM_MSG_ERROR CHAR(35) STATIC INIT('PL/I TAGTEST COMPLETED WITH ERROR.'); DCL RC FIXED BIN(31) init(0); DCL 1 ERROR_MSG, 5 MSG_API CHAR(10), 5 MSG_TEXT CHAR(16) INIT("API returned RC "), 5 MSG_RC PIC'SSS9'; DCL PARMCOUNT FIXED BIN(31); DCL GU CHAR(4) INIT('GU '); DCL ISRT CHAR(4) INIT('ISRT'); DCL SPACES CHAR(1) INIT(' '); DCL 1 INPUT_MSG, 3 IN_LL FIXED BINARY(31,0), 3 IN_ZZ FIXED BINARY(15,0), 3 IN_TC CHAR(8); DCL 1 OUTPUT_MSG, 03 OUT_LL FIXED BINARY(31,0) INIT(38), 03 OUT_ZZ FIXED BINARY(15,0) INIT(0), 03 OUT_MESSAGE CHAR(35) INIT(' '); DCL 1 IOPCB BASED(IO_PCB), /*-----------------------*/ 5 TNAME CHAR(08), /* TRAN NAME */ 5 TC CHAR(02), /* */ 5 IO_STCODE CHAR(02), /* STATUS CODE */ 5 DBPRO CHAR(04), /* PROC OPTION */ 5 IOF1 CHAR(04), /* RESERVED */ 5 DBLKA FIXED BIN(31), /* LEN OF KEY FDBK AREA */ 5 DBNSS FIXED BIN(31), /* # OF SENSITIVE SEGMENT*/ 5 DBKA CHAR(17), /* KEY FEEDBACK AREA */ 5 IOF2 CHAR(03); /* */ PARMCOUNT = 3; CALL PLITDLI (PARMCOUNT,GU,IO_PCB,INPUT_MSG); IF IO_STCODE <> SPACES THEN DO; /* error on GU call */ MSG_API = "GU Error"; ERROR = '1'B; WTOMSG = MSG_API||MSG_TEXT||IO_STCODE; DISPLAY (WTOMSG); END; /* ----------------------------------------------------------------* * Start an initial path for this transaction. * * The first parameter is a varying PLI string, * The second parameter is its code page. * Zero indicates the default code page of the IMS region. * ----------------------------------------------------------------*/ /* ----------------------------------------------------------------* * Note that a transaction that receives a tag from a program * running on another platform should start a linked path instead * so it can set a tag. For an example, see subroutine SUB1 * below. * ----------------------------------------------------------------*/ RC = DTSPTP(PATHNAME, 0); IF RC <> 0 THEN DO; MSG_API = "DTSPTP "; MSG_RC = RC; ERROR = '1'B; WTOMSG = MSG_API||MSG_TEXT||MSG_RC; DISPLAY (WTOMSG); END; /* ----------------------------------------------------------------* * Note: * Any activity that occurs in this transaction between a start * path or start linked path API and the next DTEP API will be * associated with the started path. Optionally, insert link APIs * can be used to create tags to represent subpaths for children * of this transaction. The IMS agent automatically tags IMS * transactions started by a message switch made by any traced * transaction, so insert link is typically used to tag service * requests made to programs running on non-IMS platforms. * ----------------------------------------------------------------*/ /* ----------------------------------------------------------------* * Insert a link for a child path to trace a service request to a * program that will run on another platform. The tag length must * be initialized to the size of the buffer to hold the tag that * will be returned. * ----------------------------------------------------------------*/ RC = DTILTP(TAG_BUFFER, TAG_BUFFER_LEN); IF RC <> 0 THEN DO; MSG_API = "DTILTP "; MSG_RC = RC; ERROR = '1'B; WTOMSG = MSG_API||MSG_TEXT||MSG_RC; DISPLAY (WTOMSG); END; /* ----------------------------------------------------------------* * Note: * Pass the tag that was obtained above to the service to identify * the path that it will set to report its activity. * ----------------------------------------------------------------*/ /* ----------------------------------------------------------------* * End the initial path early because one transaction can't be * linked to two paths at once. Normally this API would be used * when the transaction is finished or when it wants to start * another path to trace a new unit of work. * ----------------------------------------------------------------*/ RC = DTEP(); IF RC <> 0 THEN DO; MSG_API = "DTEP "; MSG_RC = RC; ERROR = '1'B; WTOMSG = MSG_API||MSG_TEXT||MSG_RC; DISPLAY (WTOMSG); END; /* ----------------------------------------------------------------* * To avoid the inconvenience of defining additional transactions * and programs, we will call an embedded subroutine here instead * of making a request to an external service. * ----------------------------------------------------------------*/ /* ----------------------------------------------------------------* * Perform some calculations * ----------------------------------------------------------------*/ S = SUM(TAG_BUFFER); /* ----------------------------------------------------------------* * Send a message to the terminal and return to IMS. * ----------------------------------------------------------------*/ IF ERROR THEN OUT_MESSAGE = TERM_MSG_ERROR; ELSE OUT_MESSAGE = TERM_MSG; PARMCOUNT = 3; CALL PLITDLI (PARMCOUNT,ISRT,IO_PCB,OUTPUT_MSG); IF IO_STCODE <> SPACES THEN DO; /* error on isrt call */ MSG_API = "ISRT ERROR"; WTOMSG = MSG_API||MSG_TEXT||IO_STCODE; DISPLAY (WTOMSG); END; END ADKPLI; SUM: PROCEDURE(TAG) RETURNS(BIN FIXED(15)); DCL (M, N) FIXED BIN(15); DCL TAG CHAR(100) VARYING; DCL R FIXED BIN; DCL ERROR BIT(1) INIT('0'B); DCL WTOMSG CHAR(80) INIT(' '); DCL RC FIXED BIN(31); DCL NODENAME CHAR(8) VARYING INIT("TESTPROG"); DCL ARGUMENT CHAR(6) VARYING INIT("Hello."); DCL TOKEN FIXED BIN(31); DCL 1 ERROR_MSG, 5 MSG_API CHAR(10), 5 MSG_TEXT CHAR(16) INIT("API returned RC "), 5 MSG_RC PIC'SSS9'; /* ----------------------------------------------------------------* * Start the linked path. If your IMS transaction receives a * dynaTrace tag from another platform, a DTSLP* API is all that * is required to trace the transaction and any other IMS * transactions that it starts through a supported protocol. * ----------------------------------------------------------------*/ RC = DTSLPTP(TAG); IF RC <> 0 THEN DO; MSG_API = "DTSLPTP "; MSG_RC = RC; ERROR = '1'B; WTOMSG = MSG_API||MSG_TEXT||MSG_RC; DISPLAY (WTOMSG); END; /* ----------------------------------------------------------------* * Simulate calling another program by inserting another node * into the Purepath here. A Data Capture API is used to specify * a string argument. Note that these functions are unrelated * to the tagging functions that are also being demonstrated * elsewhere in this program. * * The token value must be retained and supplied on the matching * Exit API. If nested nodes are created, each will have its own * token and the most recent one must be exited first. * * Start by capturing an argument for the simulated program node. * ----------------------------------------------------------------*/ RC = DTDCTP(ARGUMENT, 0); IF RC <> 0 THEN DO; MSG_API = "DTDCTP"; MSG_RC = RC; ERROR = '1'B; WTOMSG = MSG_API||MSG_TEXT||MSG_RC; DISPLAY (WTOMSG); END; /* ----------------------------------------------------------------* * Enter the simulated program. * ----------------------------------------------------------------*/ RC = DTENTP(NODENAME, TOKEN); IF RC <> 0 THEN DO; MSG_API = "DTENTP"; MSG_RC = RC; ERROR = '1'B; WTOMSG = MSG_API||MSG_TEXT||MSG_RC; DISPLAY (WTOMSG); END; /* ----------------------------------------------------------------* * The application work associated with this program goes here. * ----------------------------------------------------------------*/ R = 8; /* ----------------------------------------------------------------* * End the program node that we added with a return code 8. * * Start by capturing the return value. * ----------------------------------------------------------------*/ RC = DTDCS(R); IF RC <> 0 THEN DO; MSG_API = "DTDCS"; MSG_RC = RC; ERROR = '1'B; WTOMSG = MSG_API||MSG_TEXT||MSG_RC; DISPLAY (WTOMSG); END; /* ----------------------------------------------------------------* * Exit from the simulated program using the token from the most * recent Enter API. * ----------------------------------------------------------------*/ RC = DTEX(TOKEN); IF RC <> 0 THEN DO; MSG_API = "DTEX"; MSG_RC = RC; ERROR = '1'B; WTOMSG = MSG_API||MSG_TEXT||MSG_RC; DISPLAY (WTOMSG); END; /* ----------------------------------------------------------------* * End the linked path before returning. * ----------------------------------------------------------------*/ RC = DTEP(); IF RC <> 0 THEN DO; MSG_API = "DTEP "; MSG_RC = RC; ERROR = '1'B; WTOMSG = MSG_API||MSG_TEXT||MSG_RC; DISPLAY (WTOMSG); END; RETURN(R); END SUM;