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

Regards Catch statements

Former Member
0 Likes
800

Is there any thing worng in my catch statements .because when i do debug the curser not catching the catch statements

TRY.

CALL METHOD z_co_ifoasy_01_sa_gl=>execute_asynchronous

EXPORTING

output = gv_zsafe_mt_acc_gl_posting01.

CATCH cx_ai_system_fault INTO s_exception.

CATCH cx_ai_application_fault INTO s_exception_app.

ENDTRY.

IF ( s_exception IS INITIAL AND s_exception_app IS INITIAL )

.

MESSAGE i007.

ELSE.

PERFORM update_log_table.

COMMIT WORK.

MESSAGE i009. "Message sent to XI".

ENDIF.

ENDIF.

Is there any thing worng in my catch statements .because when i do debug the curser not catching the catch statements

TRY.

CALL METHOD z_co_ifoasy_01_sa_gl=>execute_asynchronous

EXPORTING

output = gv_zsafe_mt_acc_gl_posting01.

CATCH cx_ai_system_fault INTO s_exception.

CATCH cx_ai_application_fault INTO s_exception_app.

ENDTRY.

IF ( s_exception IS INITIAL AND s_exception_app IS INITIAL )

.

MESSAGE i007.

ELSE.

PERFORM update_log_table.

COMMIT WORK.

MESSAGE i009. "Message sent to XI".

ENDIF.

ENDIF.

5 REPLIES 5
Read only

Former Member
0 Likes
752

How did you define s_exception?

I would normally define it something like:

s_exception TYPE REF TO cx_root.

Read only

DirkAltmann
Active Participant
0 Likes
752

Hi Raghunadh,

you must implements your coding betwee the catch and endtry statement for cech error class.

Regards

Dirk

Read only

Former Member
0 Likes
752

Try like below...

TRY.

CALL METHOD z_co_ifoasy_01_sa_gl=>execute_asynchronous

EXPORTING

output = gv_zsafe_mt_acc_gl_posting01.

CATCH cx_ai_system_fault INTO s_exception.

lv_exception = 'X'.

CATCH cx_ai_application_fault INTO s_exception_app.

IF ( lv_exception IS INITIAL AND s_exception_app IS INITIAL )

.

MESSAGE i007.

ELSE.

PERFORM update_log_table.

COMMIT WORK.

MESSAGE i009. "Message sent to XI".

ENDIF.

ENDTRY.

Edited by: Veeranji Reddy on Aug 7, 2009 5:15 PM

Read only

Former Member
0 Likes
752

Hi,

There should be an exception thrown by the system first in order for it to be caught. Probably your code is working correctly all the times and the exception is not thrown at all which is why the catch block is never executed. So there is nothing to worry about.

Also there is not need to check the exception reference to be initial after the endtry , because usually you should give an error message in the catch block which will automatically stop the processing of the code.

The normal structure of try ...endtry is as follows :


Try
somthing....
catch exception_name  into exception_ref  " ... To handle exceptions
  message exception_ref->longtext type 'E'. "Code will stop here.
  
endtry.

rest of the code....

KR,

Advait

Read only

Former Member