Chapter 7. Migrating a PL/I program 91
Be aware that you must use the correct level of Language Environment libraries
when you compile, link-edit and run your PL/I programs.
7.4 Step 2: Check for deadlocks and time-outs
PL/I returns some ONCODEs which indicate exceptional conditions for files
which are accessed in DFSMStvs mode. VSAM RLS creates and uses lock
tokens to reserve logical records according to the read integrity options specified
for VSAM files when they are opened for DFSMStvs access. There is a potential
for deadlocks and time-outs between I/O requests from different users of the
same record. PL/I returns new ONCODEs in the event of sharing problems in a
DFSMStvs environment when more than one user is sharing the same files.
A place to handle these ONCODEs is PL/I’s ON ERROR block. Figure 7-5
displays some basic error-handling code within an ON ERROR block.
Figure 7-5 ON ERROR block provides return and reason codes
/* --------------------------------------------------------------- */
/* Error Handling - deadlock, timeout, return RPL feedback code */
/* --------------------------------------------------------------- */
ON ERROR
BEGIN;
ON ERROR SYSTEM; /*avoids recursive invocation*/
DCL PLIRETC BUILTIN,
RPLCODE EXT ENTRY (BIN FIXED(31,0)),
FC CHAR (12),
CODES BIN FIXED (31,0);
DCL 1 CC BASED (ADDR(CODES)), /* OPEN and RPLs */
2 (RC,RSN) BIN FIXED (15,0); /* return and reason codes */
CALL RPLCODE (CODES); /* get RPL feedback code */
PUT FILE(SYSPRINT) SKIP(02) EDIT
(DATETIME(),': ONCODE=',ONCODE(),' RC=',RC,' RSN=',RSN,
' ONFILE=',ONFILE(),' ONKEY=',ONKEY())
(A, A, P'ZZZ9', A, P'99', A, P'999',
A, A, A, A );
END; /* end ON ERROR */
.
92 DFSMStvs Application Migration Guide
Please note that an external procedure, RPLCODE, is called to provide native
VSAM return and reason codes. Figure 7-7 on page 94 shows the source code
for this procedure.
The error-handling code in Figure 7-5 on page 91 can be extended to cover
certain ONCODEs. The code fragment which follows in Figure 7-6 on page 93
might be put into the above code just before the END statement of the ON
ERROR block. It can be extended to cover Transactional VSAM error conditions
and issue meaningful messages to the user.
Chapter 7. Migrating a PL/I program 93
Figure 7-6 Code within an ON ERROR block to cover exceptions
The code shown in Figure 7-6 is just an example and is not completely integrated
in our working example. We did this to keep the number of lines of code small so
that the program code is readable and can be understood easily.
The code in Figure 7-7 on page 94 contains another external procedure which
returns native VSAM return codes and feedback codes from failing I/O requests.
The code used in our working example might be considered when migrating to
DFSMStvs.
SELECT (ONCODE); /* deadlock, timeout, etc. */
WHEN (97) DO;
PUT FILE(SYSPRINT) EDIT('SMSVSAM not available ',
('or not registered to RRS') (SKIP(1),(COL(10),A)
GOTO program_end;
END;
WHEN (1068) DO;
PUT FILE(SYSPRINT) EDIT('SMSVSAM is not availab',
('le. Try to close and reopen file ',ONFILE())
(SKIP(1),(COL(10),A);
GOTO program_restart;
END;
WHEN (1069) DO;
PUT FILE(SYSPRINT) EDIT('Deadlock detected whil',
('e attempt to lock file - try backout')
(SKIP(1),(COL(10),A);
backout = on;
GOTO cmit_back;
END;
WHEN (1071) DO;
PUT FILE(SYSPRINT) EDIT('Request timed out - pr',
'obably retained locks - wait and retry')
(SKIP(1),(COL(10),A);
wait = on;
GOTO wait_on_file;
END;
OTHERWISE DO;
PUT FILE(SYSPRINT) EDIT('Unpredicted error - qu',
'it with dump') (SKIP(1),(COL(10),A);
CALL CEE3DMP('UNPRETICTED ERROR',BLOCK STOR',FC);
GOTO program_end;
END;
END; /* end SELECT ONCODEs */

Get DFSMStvs Application Migration Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.