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

catch

Former Member
0 Likes
448

what is the use catch and endcatch in bapi programming

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
424

Hi,

You can handle with this way some incorrect arithmetic operation, like division by zero...

Your program will not have a short dump, keeps the control, and you can write a nice error handling.

Note: there are catchable and non-catchable exceptions. Non-catchable ones will cause ABAP dump, even when they are between CATCH-ENDCATCH.

DATA: result TYPE i,

number TYPE i.

CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 4

OTHERS = 8.

...

result = 1 / number.

...

ENDCATCH.

IF sy-subrc 0.

...

ENDIF.

Regards,

Shiva.

3 REPLIES 3
Read only

Former Member
0 Likes
425

Hi,

You can handle with this way some incorrect arithmetic operation, like division by zero...

Your program will not have a short dump, keeps the control, and you can write a nice error handling.

Note: there are catchable and non-catchable exceptions. Non-catchable ones will cause ABAP dump, even when they are between CATCH-ENDCATCH.

DATA: result TYPE i,

number TYPE i.

CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 4

OTHERS = 8.

...

result = 1 / number.

...

ENDCATCH.

IF sy-subrc 0.

...

ENDIF.

Regards,

Shiva.

Read only

Former Member
0 Likes
424

Hi,

this is not specific to BAPIs u can use catch..endcatch in programs,FMs,classes,...

catch..endcatch is for handling the catchable system exceptions.

for more info refer to this link.

http://help.sap.com/saphelp_nw70/helpdata/en/cf/f2bbce142c11d3b93a0000e8353423/content.htm

rgds,

bharat.

Read only

Former Member
0 Likes
424

Hi ,

We can use ' catch & end catch' for a BAPI function module to catch the system exceptions when a program dumps?

Sample code check :

DATA : res TYPE i,

number TYPE i.

CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 4

OTHERS = 8.

...

res = 1 / number.

...

ENDCATCH.

IF sy-subrc eq 0.

...

ENDIF.

Reward if useful.

Jagadeesh.G