000100 ID DIVISION. 00010000 000200 PROGRAM-ID. TRPGM95. 00020000 000300*AUTHOR. Kenneth W. Caldwell. 00030000 000400*INSTALLATION. Train-Right. 00040000 000500*DATE-WRITTEN. January 18, 2011. 00050000 000600*DATE-COMPILED. 00060000 000700* 00070000 000800*SECURITY. This program is for students of Train-Right 00080000 000900* courses ONLY!. 00090000 001000* 00100000 001100*REMARKS. This program plays Rock, Paper, Scissors with 00110000 001200* another CICS system. 00120000 001300* It is a back-end Distributed Transaction Program.00130000 001400* 00140000 001500 DATA DIVISION. 00150000 001600 WORKING-STORAGE SECTION. 00160000 001700 01. 00170000 001800 05 cvda-state PIC S9(8) BINARY. 00180000 001900 05 conversation-id PIC X(4). 00190000 002000 05 conversation-tranid PIC X(4). 00200000 002100 00210000 002200 05 pgm-choice PIC 9 PACKED-DECIMAL. 00220000 002300 05 user-choice PIC X(8) VALUE SPACES. 00230000 002400 05 msg1 PIC X(39). 00240000 002500 00250000 002600 PROCEDURE DIVISION. 00260000 002700 Main. 00270000 002800 EXEC CICS HANDLE CONDITION INVREQ(Not-Dtp) END-EXEC. 00280000 002900 EXEC CICS EXTRACT ATTRIBUTES STATE(cvda-state) END-EXEC. 00290000 003000* Initial CVDA state should be RECEIVE (88). 00300000 003100* EIBRSRCE will be set. 00310000 003200 00320000 003300 MOVE eibrsrce TO conversation-id. 00330000 003400 00340000 003500 Receive-Trans-Input. 00350000 003600 EXEC CICS RECEIVE CONVID(conversation-id) 00360000 003700 STATE(cvda-state) 00370000 003800 INTO(conversation-tranid) 00380000 003900 END-EXEC. 00390000 004000* EIBCOMPL should be X'FF' (RECEIVE complete). 00400000 004100* CVDA state should be SEND (90). 00410000 004200 00420000 004300 Process-Data. 00430000 004400 COMPUTE pgm-choice ROUNDED = 00440000 004500 FUNCTION RANDOM(eibtaskn + eibtime) * 2 00450000 004600 END-COMPUTE. 00460000 004700 00470000 004800 Continue-Conversation. 00480000 004900 EVALUATE pgm-choice 00490000 005000 WHEN 0 00500000 005100 MOVE 'ROCK' TO user-choice 00510000 005200 WHEN 1 00520000 005300 MOVE 'PAPER' TO user-choice 00530000 005400 WHEN 2 00540000 005500 MOVE 'SCISSORS' TO user-choice 00550000 005600 END-EVALUATE. 00560000 005700 00570000 005800 EXEC CICS CONVERSE CONVID(conversation-id) 00580000 005900 FROM(user-choice) 00590000 006000 STATE(cvda-state) 00600000 006100 END-EXEC. 00610000 006200* EIBCOMPL should be X'FF' (RECEIVE complete). 00620000 006300 00630000 006400* If front-end transaction executed a SYNCPOINT, 00640000 006500* EIBRECV will be X'FF', but does not stay that way. 00650000 006600* EIBSYNC will be X'FF', but does not stay that way. 00660000 006700* Use the CVDA state SYNCRECEIVE (92) to determine SYNCPOINT. 00670000 006800 00680000 006900 EVALUATE cvda-state 00690000 007000 WHEN DFHVALUE(SYNCRECEIVE) 00700000 007100 EXEC CICS SYNCPOINT END-EXEC 00710000 007200* CVDA state should be RECEIVE (88). 00720000 007300 00730000 007400 EXEC CICS EXTRACT ATTRIBUTES STATE(cvda-state) END-EXEC 00740000 007500 00750000 007600 EXEC CICS RECEIVE CONVID(conversation-id) 00760000 007700 STATE(cvda-state) 00770000 007800 END-EXEC 00780000 007900 00790000 008000* If front-end transaction executed a SYNCPOINT ROLLBACK 00800000 008100* EIBRECV will be X'FF', but does not stay that way. 00810000 008200* EIBSYNRB will be X'FF', but does not stay that way. 00820000 008300* Use the CVDA state ROLLBACK (89) to determine ROLLBACK. 00830000 008400 00840000 008500 WHEN DFHVALUE(ROLLBACK) 00850000 008600 EXEC CICS SYNCPOINT ROLLBACK END-EXEC 00860000 008700* CVDA state should be RECEIVE (88). 00870000 008800 00880000 008900 EXEC CICS EXTRACT ATTRIBUTES STATE(cvda-state) END-EXEC 00890000 009000 00900000 009100 EXEC CICS RECEIVE CONVID(conversation-id) 00910000 009200 STATE(cvda-state) 00920000 009300 END-EXEC 00930000 009400 WHEN OTHER CONTINUE 00940000 009500 END-EVALUATE. 00950000 009600 00960000 009700* If front-end transaction executed a SEND LAST, 00970000 009800* EIBRECV will be X'FF', but does not stay that way. 00980000 009900* Use the CVDA state RECEIVE (88) to determine SEND LAST. 00990000 010000 01000000 010100 EVALUATE cvda-state 01010000 010200 WHEN DFHVALUE(RECEIVE) 01020000 010300 EXEC CICS RECEIVE CONVID(conversation-id) 01030000 010400 STATE(cvda-state) 01040000 010500 END-EXEC 01050000 010600* EIBSYNC should be X'FF', but does not stay that way. 01060000 010700* EIBFREE should be X'FF', but does not stay that way. 01070000 010800* CVDA state should be SYNCFREE (91) or FREE (85) 01080000 010900 01090000 011000 IF cvda-state = DFHVALUE(SYNCFREE) 01100000 011100 THEN EXEC CICS SYNCPOINT END-EXEC 01110000 011200 END-IF 01120000 011300 01130000 011400* End of conversation (no RETURN command). 01140000 011500 EXEC CICS FREE END-EXEC 01150000 011600 WHEN OTHER CONTINUE 01160000 011700 END-EVALUATE. 01170000 011800 01180000 011900 COMPUTE pgm-choice ROUNDED = FUNCTION RANDOM * 2 END-COMPUTE.01190000 012000 01200000 012100 GO TO Continue-Conversation. 01210000 012200 01220000 012300 Not-Dtp. 01230000 012400 MOVE 'Not executed as a back-end DTP program.' TO msg1. 01240000 012500 EXEC CICS SEND FROM(msg1) ERASE END-EXEC. 01250000 012600 EXEC CICS RETURN END-EXEC. 01260000 012700* Dummy GOBACK. 01270000 012800 GOBACK. 01280000