WRITE:/ ||.Įxample with simple global class method (defined exactly the same way as for the local class example above, but in SE24): REPORT znon_resumable_exc_3_hacked. Ty_tt TYPE STANDARD TABLE OF ty_st WITH EMPTY KEY. * Non-resumable cx_sy_zerodivide turned into resumable one via raising resumable lcx_1ĬLASS lcx_1 DEFINITION INHERITING FROM cx_static_check. This can be solved with the workaround I found by luck (which is probably a hack, I agree) seen in the code attached (CX_SY_ZERODIVIDE is turned to be resumable here).The trick is to raise another RESUMABLE exception within the CATCH block of non-resumable one. However, sometimes we might face the situation when system exception (non-resumable by the nature) is raised during the loop processing – but we would still like to process the rest. I am using resumable exceptions exactly as Tapio Reisinger does – for handling non-critical entries in a loop (the faulty record is logged and the remaining records can still be processed this way). Maybe the information provided here can be useful for you.įor more infornation see Class-based Exceptions. The addition BEFORE UNWIND to CATCH takes care that the exception is caught before its context is deleted.The addition RESUMABLE to RAISING propagates a resumable exception (without, an resumable exception would lose this property during propagation).The addition RESUMABLE to RAISE raises an exception as a resumable exception.The property of being resumable is not part of an exception class but defined when raising an exception.The context of the exception is still availableĬLASS-METHODS meth RAISING RESUMABLE(cx_demo).With RESUME you you exit a CATCH block and resume processing after the statement that raised the exception. During handling, the prerequisite is fullfilled and the execution of the protected area of the TRY block is repeated, Of course you have to take care, that the exception does not re-occurr again and again, otherwise you end up in an endless loop.Īn exception is raised if some prerequisite (here a flag) is missing. With RETRY you exit a CATCH block and jump back to the TRY statement of the current TRY control structure in order to retry the full TRY block. Maybe not so well known are RETRY and RESUME introduced with Release 7.02. Well known facts available since Release 6.10 (yawn). Not shown here, is the INTO addition, that can be used for CLEANUP too. In the latter case, before leaving the inner TRY block, the CLEANUP block is executed, offering the opportunity to cleanup the inner TRY block. cx_demo0 is handled in the inner, cx_demo1 is handled in the outer TRY block. In this example you can decide whether to raise an exception of class cx_demo0 or cx_demo1. To be complete, also the meaning of CLEANUP shall be shown:ĬLASS cx_demo0 DEFINITION INHERITING FROM cx_static_check.ĬLASS cx_demo1 DEFINITION INHERITING FROM cx_static_check.Ĭl_demo_input=>request( CHANGING field = exception ).Įxc = COND #( WHEN exception = `cx_demo0` THEN NEW cx_demo0( )Ĭl_demo_output=>write( ‘Catching cx_demo0’ ).Ĭl_demo_output=>write( ‘Catching cx_demo1’ ). The code executed in the TRY block is called the protected area.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |