Ü  %ERROR

·         If an 'E' operation code extender is present on the calculation specification and error indicator is not present then the error occurred will be handled by this operator extender ‘E’.

·         The errors in this case are identified using the function %ERROR built-in function.

·         But this operator extender’s use is limited only to the op-codes listed below:

ACQ         CLOSE       OCCUR       REL         TEST

ADDDUR      COMMIT      OPEN        RESET       UNLOCK

ALLOC             DEALLOC     NEXT        ROLBK       UPDATE

CALL       DELETE      OUT         REALLOC     WRITE

CALLB             DSPLY       POST        SCAN        XLATE

CALLP             EXFMT       READ        SETGT       XML-INTO

CHAIN             EXTRCT      RAEDE       SETLL       XML-SAX

CHECK             FEOD        READP       SUBDUR

CHECKR      IN          READPE      SUBST

 

·         The error will be handled using the built-in functions %STATUS and %ERROR.

·         Control resumes with the next ILE RPG operation.

 

Example – I –%error built-in function in rpgle

ERROR HANDLING USING E-OPERATOR EXTENDER BUT NOT HANDLING ERROR WITH %ERROR


Columns . . . :    6  80                                                    AMITCC/QRPGLESRC
SEU==>                                                                            E_OP_EXTN3
FMT H  HKeywords++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*************** Beginning of data *************************************************
0001.00 HOPTION(*SRCSTMT)                                                               130122
0002.00 FCUST      UF A E             DISK    USROPN                                    130122
0003.00                                                                                 130121
0006.00 C     1             SETLL(E)  CUSTR                                             130123
0008.00 C                   EVAL      CSNAME='AMI'                                      130123
0009.00 C                   UPDATE(E) CUSTR                                             130122
0011.00 C                   SETON                                        LR             130122
****************** End of data ******************************************************

 

OUTPUT

Here you won't get any error but there will be logical error i.e. file CUST will not get updated.

 

 

Example – II –%error built-in function in rpgle

ERROR HANDLING USING E-OPERATOR EXTENDER AND WITH %ERROR BUILT-IN FUNCTION


Columns . . . :    6  80                                                    AMITCC/QRPGLESRC
SEU==>                                                                           E_OP_EXTND
FMT H  HKeywords++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*************** Beginning of data ************************************************
0001.00 HOPTION(*SRCSTMT)                                                               130122
0002.00 FCUST      UF A E             DISK    USROPN                                    130122
0003.00                                                                                 130121
0004.00 C     1             SETLL(E)  CUSTR                                             130123
0005.00 C                   EXSR      @ERROR                                            130123
0006.00 C                   EVAL      CSNAME='CCC'                                      130123
0007.00 C                   UPDATE(E) CUSTR                                             130122
0008.00 C                   EXSR      @ERROR                                            130123
0009.00 C                   SETON                                        LR             130122
0010.00  *                                                                              130122
0011.00 C     @ERROR        BEGSR                                                       130122
0012.00 C                   IF        %ERROR()                                          130122
0013.00 C                   IF        %STATUS(CUST)=1211                                130122
0014.00 C                   OPEN      CUST                                              130122
0015.00 C                   ELSEIF    %STATUS(CUST)=1221                                130122
0016.00 C                   READ(E)   CUST                                              130122
0017.00 C                   EVAL      CSNAME='CCC'                                      130123
0018.00 C                   UPDATE(E) CUSTR                                             130122
0019.00 C                   ENDIF                                                       130122
0020.00 C                   ENDIF                                                       130122
0021.00 C                   ENDSR                                                       130122
****************** End of data ****************************************************

 

OUTPUT

File CUST will be updated successfully.   

 





User Comments:





Copyright © Go4as400.com, 2013-2017. Copyright notice