Catch exception in ABAP

Catch exception in ABAP

Code example below :


  DATA : lo_error      TYPE REF TO cx_root,
         lw_mess       TYPE string.

      TRY. " Avoid dump in case of non numerical values...
          lw_1 = ls_initial-zzip * ls_guaranteed-zzmtbur * 10 ** ls_guaranteed-zzrri.
          lw_2 = ls_initial-zzmtbur * 10 ** ls_initial-zzrri.
        CATCH cx_sy_conversion_no_number INTO lo_error.  " Récupérer le type d’erreur a « catcher » en générant un dump par exple. 
          lw_mess = lo_error->get_text( ).
      ENDTRY.

  IF lw_mess IS NOT INITIAL.
        " Display error (lw_mess)
  ENDIF.

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

Leave a Reply