From 81a70274be420009cbbee66b2e685be0d06f1511 Mon Sep 17 00:00:00 2001 From: Marc Bernard <59966492+mbtools@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:12:01 -0400 Subject: [PATCH] Catch exception in exit form (#4966) Closes #4965 --- src/zabapgit_forms.prog.abap | 46 +++++++++++++++--------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/src/zabapgit_forms.prog.abap b/src/zabapgit_forms.prog.abap index cbe61481c..1cf4cbe17 100644 --- a/src/zabapgit_forms.prog.abap +++ b/src/zabapgit_forms.prog.abap @@ -2,9 +2,6 @@ *& Include ZABAPGIT_FORMS *&---------------------------------------------------------------------* -*&---------------------------------------------------------------------* -*& Form run -*&---------------------------------------------------------------------* FORM run. DATA: lx_exception TYPE REF TO zcx_abapgit_exception. @@ -32,25 +29,11 @@ FORM open_gui RAISING zcx_abapgit_exception. ENDFORM. -*&---------------------------------------------------------------------* -*& Form branch_popup -*&---------------------------------------------------------------------* -* text -*----------------------------------------------------------------------* -* -->TT_FIELDS text -* -->PV_CODE text -* -->CS_ERROR text -* -->CV_SHOW_POPUP text -* -->RAISING text -* -->zcx_abapgit_exception text -* -->##CALLED text -* -->##NEEDED text -*----------------------------------------------------------------------* FORM branch_popup TABLES tt_fields TYPE zif_abapgit_popups=>ty_sval_tt USING pv_code TYPE clike CHANGING cs_error TYPE svale cv_show_popup TYPE c - RAISING zcx_abapgit_exception ##called ##needed. + RAISING zcx_abapgit_exception ##CALLED ##NEEDED. * called dynamically from function module POPUP_GET_VALUES_USER_BUTTONS DATA: lx_error TYPE REF TO zcx_abapgit_exception, @@ -73,6 +56,7 @@ FORM branch_popup TABLES tt_fields TYPE zif_abapgit_popups=>ty_sval_tt ENDFORM. "branch_popup FORM output. + DATA: lx_error TYPE REF TO zcx_abapgit_exception, lt_ucomm TYPE TABLE OF sy-ucomm. @@ -92,9 +76,12 @@ FORM output. CATCH zcx_abapgit_exception INTO lx_error. MESSAGE lx_error TYPE 'S' DISPLAY LIKE 'E'. ENDTRY. + ENDFORM. -FORM exit RAISING zcx_abapgit_exception. +FORM exit. + + DATA lx_error TYPE REF TO zcx_abapgit_exception. " The exit logic should only be applied for our 'main' selection screen 1001. " All other selection-screens are called as popups and shouldn't influence @@ -103,14 +90,19 @@ FORM exit RAISING zcx_abapgit_exception. RETURN. ENDIF. - CASE sy-ucomm. - WHEN 'CBAC' OR 'CCAN'. "Back & Escape - IF zcl_abapgit_ui_factory=>get_gui( )->back( ) = abap_true. " end of stack - zcl_abapgit_ui_factory=>get_gui( )->free( ). " Graceful shutdown - ELSE. - LEAVE TO SCREEN 1001. - ENDIF. - ENDCASE. + TRY. + CASE sy-ucomm. + WHEN 'CBAC' OR 'CCAN'. "Back & Escape + IF zcl_abapgit_ui_factory=>get_gui( )->back( ) = abap_true. " end of stack + zcl_abapgit_ui_factory=>get_gui( )->free( ). " Graceful shutdown + ELSE. + LEAVE TO SCREEN 1001. + ENDIF. + ENDCASE. + CATCH zcx_abapgit_exception INTO lx_error. + MESSAGE lx_error TYPE 'S' DISPLAY LIKE 'E'. + ENDTRY. + ENDFORM. FORM password_popup