I have used CX_SY_ZERODIVIDE class to handle exception.
Code :
REPORT zvp_try_catch.
DATA: c TYPE int4.
PARAMETERS: p_a TYPE int4,
p_b TYPE int4.
START-OF-SELECTION.
TRY .
c = p_a / p_b.
WRITE: c.
CATCH cx_sy_zerodivide.
WRITE:/ 'Error!! Divided by zero'.
ENDTRY.
DATA: c TYPE int4.
PARAMETERS: p_a TYPE int4,
p_b TYPE int4.
START-OF-SELECTION.
TRY .
c = p_a / p_b.
WRITE: c.
CATCH cx_sy_zerodivide.
WRITE:/ 'Error!! Divided by zero'.
ENDTRY.
Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.
Post a Comment