Identification Division. Program-Id. TAGTEST. * This program demonstrates dynaTrace CICS 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. * Environment Division. Data Division. Working-Storage Section. * Optional name to describe the initial path. 77 PATHNAME Pic X(24) Value "Started from tagging ADK". 77 PATHNAME_LEN Pic S9(9) Comp Value 24. 77 PATHNAME_CCSID Pic S9(9) Comp Value 0. * Buffer to hold the tag that will identify a child path. * Note: DynaTrace 5.x requires a buffer of at least 77 bytes. 77 TAG_BUFFER Pic X(100). 77 TAG_BUFFER_LEN Pic S9(9) Comp value 100. 77 TAG_LEN Pic S9(9) Comp. 77 TERM_MSG Pic X(23) Value "COBOL TAGTEST complete.". 77 RC Pic S9(9) Comp. 01 ERROR_MSG. 05 MSG_API Pic X(8). 05 MSG_TEXT Pic X(16) Value "API returned RC ". 05 MSG_RC Pic zz9. Procedure Division. * ---------------------------------------------------------------* * Start an initial path for this transaction. * * 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. * ---------------------------------------------------------------* Call "DTSPTF", Using PATHNAME, PATHNAME_LEN, PATHNAME_CCSID Returning RC. If RC Not Equal ZERO MOVE "DTSPTF" to MSG_API MOVE RC to MSG_RC EXEC CICS WRITE OPERATOR TEXT(ERROR_MSG) END-EXEC. * ---------------------------------------------------------------* * 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 CICS agent automatically tags CICS * transactions started by DPL LINK or START requests made by any * traced transaction, so insert link is typically used to tag * service requests made to programs running on non-CICS 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. * ---------------------------------------------------------------* Move TAG_BUFFER_LEN to TAG_LEN. Call "DTILTF", Using TAG_BUFFER, TAG_LEN Returning RC. If RC Not Equal ZERO MOVE "DTILTF" to MSG_API MOVE RC to MSG_RC EXEC CICS WRITE OPERATOR TEXT(ERROR_MSG) END-EXEC. * ---------------------------------------------------------------* * 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. * ---------------------------------------------------------------* Call "DTEP" Returning RC. If RC Not Equal ZERO MOVE "DTEP" to MSG_API MOVE RC to MSG_RC EXEC CICS WRITE OPERATOR TEXT(ERROR_MSG) END-EXEC. * ---------------------------------------------------------------* * 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. * ---------------------------------------------------------------* Call "SUB1" Using TAG_BUFFER, TAG_LEN Returning RC. * ---------------------------------------------------------------* * Send a message to the terminal and return to CICS. * ---------------------------------------------------------------* EXEC CICS SEND TEXT FROM(TERM_MSG) ERASE END-EXEC. EXEC CICS RETURN END-EXEC. Identification Division. Program-Id. SUB1. Data Division. Working-Storage Section. 77 NODENAME Pic X(8) Value "TESTPROG". 77 NAMELEN Pic S9(9) Comp Value 8. 77 ARGUMENT Pic X(6) Value "Hello.". 77 ARGLEN Pic S9(9) Comp Value 6. 77 ARGCCSID Pic S9(9) Comp Value 0. 77 RC8 Pic S9(9) Comp Value 8. 77 RC Pic S9(9) Comp. 77 TOKEN Pic S9(9) Comp. 01 ERROR_MSG. 05 MSG_API Pic X(8). 05 MSG_TEXT Pic X(16) Value "API returned RC ". 05 MSG_RC Pic zzzz9. Linkage Section. 77 TAG Pic X(100). 77 TAGLEN Pic S9(9) Comp. Procedure Division using TAG, TAGLEN. * ---------------------------------------------------------------* * Start the linked path. If your CICS transaction receives a * dynaTrace tag from another platform, a DTSLP* API is all that * is required to trace the transaction and any other CICS * transactions that it starts through a supported protocol. * ---------------------------------------------------------------* Call "DTSLPTF" Using TAG, TAGLEN Returning RC. If RC Not Equal ZERO MOVE "DTSLPTF" to MSG_API MOVE RC to MSG_RC EXEC CICS WRITE OPERATOR TEXT(ERROR_MSG) END-EXEC. * -------------------------------------------------------------* * 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. * -------------------------------------------------------------* Call "DTDCTF" Using ARGUMENT, ARGLEN, ARGCCSID Returning RC. If RC Not Equal ZERO MOVE "DTDCTF" to MSG_API MOVE RC to MSG_RC EXEC CICS WRITE OPERATOR TEXT(ERROR_MSG) END-EXEC. * -------------------------------------------------------------* * Enter the simulated program. * -------------------------------------------------------------* Call "DTENTF" Using NODENAME, NAMELEN, TOKEN Returning RC. If RC Not Equal ZERO MOVE "DTENTF" to MSG_API MOVE RC to MSG_RC EXEC CICS WRITE OPERATOR TEXT(ERROR_MSG) END-EXEC. * ---------------------------------------------------------------* * The application work associated with this program goes here. * ---------------------------------------------------------------* Move RC8 to RETURN-CODE. * -------------------------------------------------------------* * End the program node that we added with a return code 8. * * Start by capturing the return value. * -------------------------------------------------------------* Call "DTDCI" Using RC8 Returning RC. If RC Not Equal ZERO MOVE "DTDCI" to MSG_API MOVE RC to MSG_RC EXEC CICS WRITE OPERATOR TEXT(ERROR_MSG) END-EXEC. * -------------------------------------------------------------* * Exit from the simulated program using the token from the most * recent Enter API. * -------------------------------------------------------------* Call "DTEX" Using TOKEN Returning RC. If RC Not Equal ZERO MOVE "DTEX" to MSG_API MOVE RC to MSG_RC EXEC CICS WRITE OPERATOR TEXT(ERROR_MSG) END-EXEC. * ---------------------------------------------------------------* * End the linked path before returning. * ---------------------------------------------------------------* Call "DTEP" Returning RC. If RC Not Equal ZERO MOVE "DTEP" to MSG_API MOVE RC to MSG_RC EXEC CICS WRITE OPERATOR TEXT(ERROR_MSG) END-EXEC. Goback. End Program SUB1. End Program TAGTEST.