ABAP Message Error Handling Standards - ABAP Development - SCN Wiki

e after specific operations such as select, read, translate, etc. Whenever it is possible for a statement to set a return code value, which must be handled to insure proper continuation of the program, SY-SUBRC should be explicitly checked and appropriate action taken.       SY-SUBRC EQ  0        : indicates a successful completion of the statement       SY-SUBRC NE  0        : indicates an error condition for the statementIf no action needs to be taken when SY-SUBRC returns an error condition a comment must be included stating such and the SY-SUBRC check is not being done.Exception CodesException codes are used to communicate errors from a function module to the calling program. The calling program must handle all possible errors generated by a function by the use of the EXCEPTIONS clause of the CALL FUNCTION statement in conjunction with SY-SUBRC. The use of OTHERS is acceptable to handle errors that do not have specific handling required. Letting error codes "fall through" is not acceptable. This makes it unnecessary to use of the MESSAGE ... RAISING EXCEPTION construct, which should, therefore, be avoided.When writing a function module, RAISE EXCEPTION should be used to terminate the processing of the function and return an error code to the calling program unless one or more of the EXPORT parameters contains valid information that the caller will require. If RAISE EXCEPTION is invoked in a function module the EXPORT parameters are not filled when control is returned (immediately) to the calling program.Example:CALL     FUNCTION 'STRING_SPLIT'     EXPORTING          DELIMITER =   ':'          STRING        =   FELD     IMPORTING          HEAD           =   HEAD          TAIL             =   TAIL     EXCEPTIONS          NOT_FOUND   =             1          OTHERS       =   2.CASE SY-SUBRC.     WHEN 1. ...     WHEN 2. ...     WHEN OTHER.ENDCASE.Closing the SpoolE and A level error messages overwrite the print spool and destroy its contents. All write statements are erased and overwritten by the ABEND. To maintain "spool integrity", if desired, insert the following code before each A or E message.Example:NEW-PAGE PRINT http://www.mianfeiwendang.comMIT WORK.                Commit spool data.              MESSAGE A... (or E...)        ABEND or error coding.Catch System ExceptionsWhen possible runtime exceptions should be captured and processed as error using the CATCH … ENDCATCH or TRY … CATCH …ENDTRY statements instead of allowing a program to dump.When a runtime exception is trapped a detailed message should be presented to the user indicating the severity of the problem, the cause of the problem, any remedies required to fix the p

roblem, and how to reprocess the ended taskClassical ExceptionsSYSTEM-EXCEPTION-       Use an Error Class in the C

Word文档免费下载Word文档免费下载:ABAP Message Error Handling Standards - ABAP Development - SCN Wiki (共3页,当前第2页)

ABAP Message Error Handling Standards ABAP Development SCN Wiki相关文档