DCL PTR INV_PTR2 DEF(RTNTMPLT) POS(1);
DCL DD \ CHAR(1) DEF(RTNTMPLT) POS(17) INIT(X'ðð');
DCL DD ACTION CHAR(2) DEF(RTNTMPLT) POS(18);
DCL SPCPTR RTNTMPLT@ INIT(RTNTMPLT);
4. Retrieve the exception data associated with the MCH1401 exception:
RETEXCPD EXCPDBUF@, X'ð1';
5. Compare the exception data object identifier to the space identifier you create.
If they are the same, branch to label SAME:
CMPBLA(B) EXC_OBJ, OBJID / EQ(SAME);
a. If the exception data object identifier and the space identifier are not the
same, the program is truly in an unexpected error condition and the excep-
tion description needs to be disabled:
MODEXCPD DUPERROR, X'2ððð', X'ð1';
Retry the failing instruction. As the exception description is disabled, the
exception is sent to the caller of the program:
CPYBLA ACTION, X'ðððð';
B E14ð1;
b. If the exception data object identifier and the space identifier are the same,
the static storage must have been effectively reset. The program reassigns
USRSPC@ by using the returned system pointer in the exception data and
continues with the next instruction following the failed CRTS:
SAME: CPYBWP USRSPC@, EXC_OBJ@;
CPYBLA ACTION, X'ð1ðð';
E14ð1: CPYBWP INV_PTR2, INV_PTR;
RTNEXCP RTNTMPLT@;
PEND;
MICRTPG2 Complete Program (Enhanced)—MI Code Example
In its consolidated state, this is the new MICRTPG2 program:
/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/
/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/
/\ \/
/\ Program Name: MICRTPG2 \/
/\ \/
/\ Programming Language: MI \/
/\ \/
/\ Description: Enhanced version of MI program MICRTPG2, \/
/\ which provides for exception handling. \/
/\ \/
/\ \/
/\ Header Files Included: None \/
/\ \/
/\ \/
/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/
/\ Entry point and associated parameters \/
ENTRY \ (\ENTRY) EXT;
DCL SPCPTR FIL@ PARM;
DCL SPCPTR MBR@ PARM;
DCL OL \ENTRY (MBR@, FIL@) PARM EXT MIN(1);
DCL DD FIL CHAR(1ð) BAS(FIL@);
7-28 System API Programming V4R1