Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

general abap

Former Member
0 Likes
1,098

hai abapers,

topic : Division.

example : a type p decimals 3,

b = 0

c = a / b.

at this time execution , run time error comes .

how will avoid this error.

hai abapers,

topic : Division.

example : a type p decimals 3,

b = 0

c = a / b.

at this time execution , run time error comes .

how will avoid this error.

9 REPLIES 9
Read only

Former Member
0 Likes
1,078

example : a type p decimals 3,

b = 0

CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 4

OTHERS = 8.

c = a / b.

ENDCATCH.

Read only

Former Member
0 Likes
1,078

@ Fun.

Dont Divide.

@ Answer

See F1 help or search the forum for TRY....CATCH....

You can avoid by handling exceptions.

Regards

Karthik D

Read only

Former Member
0 Likes
1,078

Any number divided by zero will result infinity. so avoid dividing by zero. Perform calculation only when the denominator is not zero.

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,078

you can also do:

IF b NE 0.
c = a / b .
ELSE.
WRITE : 'Only Chuck Norris is able to divide by zero!'.
ENDIF.

Read only

0 Likes
1,078

A Chuck Norris guy

pk

Read only

0 Likes
1,078

Eric, That was a Good One. :)....

Read only

0 Likes
1,078

>

> you can also do:

>

>

IF b NE 0.
> c = a / b .
> ELSE.
> WRITE : 'Only Chuck Norris is able to divide by zero!'.
> ENDIF.

Then how the code would be if Chuck Norris write the program to divide by 0

Regards

Karthik D

Read only

0 Likes
1,078

Then we should have the same statement written in the Dump Analysis. LOL!!!!!!!!!!!

Read only

Former Member
0 Likes
1,078

Hi Raj,

As we know anything divided by zero is always zero which throws exception in ABAP to avoid that situation

in ABAP check the value of b if not 0 then divide else avoid dividing.

Regards,

Venky