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

New error exception concept

Former Member
0 Likes
433

Hi,

Can any one give me an example for New error exception concept

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
408

Hi,

In release 6.10 a new exception concept has been introduced. Please find below a basic syntax of how to code the new error-handling concept.

*Syntax for TRY .. ENDTRY construct

TRY.

CALL METHOD o1->m1.

PERFORM f1.

CATCH cx_root. "Handler for all exceptions

" ABAP code(What to do when error occures)........

ENDTRY.

FORM f1 RAISING cx_my.

TRY.

IF ...... RAISE EXCEPTION TYPE cx_my2. ENDIF.

CALL METHOD o1->m3.

CATCH cx_my1 cx_my3 INTO ex.

RAISE EXCEPTION TYPE cx_my4.

CATCH cx_my4.

"Handler for exceptions of type cx_my4

" ABAP code(What to do when error occures)........

CLEANUP.

"Cleanup section, used to restore to a consistant state

" ABAP code........

ENDTRY.

ENDFORM.

Reward if helpful..

Sowjanya.

2 REPLIES 2
Read only

Former Member
0 Likes
408

hi Riyaz,

Exceptions are also called errors.

but these errors will be handled using Raise command in FMs.

or else we can handle them by throw/catch commands.

chandra

Read only

Former Member
0 Likes
409

Hi,

In release 6.10 a new exception concept has been introduced. Please find below a basic syntax of how to code the new error-handling concept.

*Syntax for TRY .. ENDTRY construct

TRY.

CALL METHOD o1->m1.

PERFORM f1.

CATCH cx_root. "Handler for all exceptions

" ABAP code(What to do when error occures)........

ENDTRY.

FORM f1 RAISING cx_my.

TRY.

IF ...... RAISE EXCEPTION TYPE cx_my2. ENDIF.

CALL METHOD o1->m3.

CATCH cx_my1 cx_my3 INTO ex.

RAISE EXCEPTION TYPE cx_my4.

CATCH cx_my4.

"Handler for exceptions of type cx_my4

" ABAP code(What to do when error occures)........

CLEANUP.

"Cleanup section, used to restore to a consistant state

" ABAP code........

ENDTRY.

ENDFORM.

Reward if helpful..

Sowjanya.