TRY Imperative-Statement-1 [ CATCH {Exception-Class} Imperative-Statement-2 ] ... [ CATCH EXCEPTION Imperative-Statement-3 ] [ FINALLY Imperative-Statement-4 ] END-TRY |
CONFIGURATION SECTION. REPOSITORY. CLASS JFILE AS "java.io.File" . WORKING-STORAGE SECTION. 77 W-STATUS PIC 9(9). 88 FILE-NOTFOUND VALUE 0. 88 FILE-EXISTS VALUE 1. 88 ERROR-CONDITION VALUE 2. LINKAGE SECTION. 77 FILENAME PIC X(256). PROCEDURE DIVISION USING FILENAME. MAIN. TRY IF JFILE:>new(FILENAME):>exists() SET FILE-EXISTS TO TRUE ELSE SET FILE-NOTFOUND TO TRUE END-IF CATCH EXCEPTION SET ERROR-CONDITION TO TRUE DISPLAY MESSAGE EXCEPTION-OBJECT:>getMessage() FINALLY GOBACK W-STATUS END-TRY. |
CONFIGURATION SECTION. REPOSITORY. CLASS JFILE AS "java.io.File" CLASS SECEXC AS "java.lang.SecurityException" . WORKING-STORAGE SECTION. 77 W-STATUS PIC 9(9). 88 FILE-NOTFOUND VALUE 0. 88 FILE-EXISTS VALUE 1. 88 SECURITY-ERROR VALUE 2. LINKAGE SECTION. 77 FILENAME PIC X(256). PROCEDURE DIVISION USING FILENAME. MAIN. TRY IF JFILE:>new(FILENAME):>exists() SET FILE-EXISTS TO TRUE ELSE SET FILE-NOTFOUND TO TRUE END-IF CATCH SECEXC SET SECURITY-ERROR TO TRUE DISPLAY MESSAGE EXCEPTION-OBJECT:>getMessage() FINALLY GOBACK W-STATUS END-TRY. |