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

Try and End Try.

Former Member
0 Likes
517

Hello All,

Is there any disadvantage to use try and end try in the program.

I have developed a custom program. At starting of the program i have used TRY and at end of the program i have used catch and end try.

In order to avoid at any case short dumps in program.

Again inside the code at certain cases were the shot dump is expected i have used TRY and Catch, End try.

Please let me know is this good idea, to use try and End try in first and last of the program.

Thank you very much in advance.

Code :

Staring of the program TRY.

Select....

Perofm.....

Write ,....

Perofm.....

End of the program CATCH cx_root INTO l_oref.

l_text = l_oref->get_text( ).

MESSAGE l_text TYPE 'E'.

ENDTRY.

Thanks,

Feroz.

Hello All,

Is there any disadvantage to use try and end try in the program.

I have developed a custom program. At starting of the program i have used TRY and at end of the program i have used catch and end try.

In order to avoid at any case short dumps in program.

Again inside the code at certain cases were the shot dump is expected i have used TRY and Catch, End try.

Please let me know is this good idea, to use try and End try in first and last of the program.

Thank you very much in advance.

Code :

Staring of the program TRY.

Select....

Perofm.....

Write ,....

Perofm.....

End of the program CATCH cx_root INTO l_oref.

l_text = l_oref->get_text( ).

MESSAGE l_text TYPE 'E'.

ENDTRY.

Thanks,

Feroz.

3 REPLIES 3
Read only

Pawan_Kesari
Active Contributor
0 Likes
480

I don't see any disadvantage in using TRY.. ENDTRY block.

But if you are expecting runtime erroe in your code then you should first try to fix the logic rather than using TRY..ENTRY...

In other cases for example sap standard FM or method call it is nice to keep it in TRY .. ENTRY...

Thats my opinion...

Read only

0 Likes
480

Hello all,

I have developed an Input interface. For this interface i will get the data from the external system in text file format. If the text file contains any unexpected error data then program should not go to dump it should raise an error message.

So i have added Try and EndTRY block for the whole program so i f any unusnally un expected cases this try block and avoid the short dump.

Note : For all the expected cases i have did the required error handling.

Thanks,

Feroz.

Read only

Former Member
0 Likes
480

This message was moderated.