2008 Apr 30 8:26 AM
Hi all,
I know TRY and CATCH in Java.
Lets say in Java, if I know the particular SQL error then it will throw exception into SQLException. For general or unknown exception it will throw into Exception.
What should I use for ABAP programming?
Please use above example to show me please.
Thank you very much.
2008 Apr 30 8:36 AM
If you know which exception will be thrown you can use this. But if you are not really sure and you haven't been able to find out it is possible to use the root exception (main exception of which all other exceptions are inherited).
Main exception: cx_root.
data:lr_error type ref to cx_root.
try.
catch cx_root into lr_error.
endtry.
Other exceptions.
data:lr_error type ref to particular exception.
try.
catch particular exception into lr_error.
endtry.
Hi all,
I know TRY and CATCH in Java.
Lets say in Java, if I know the particular SQL error then it will throw exception into SQLException. For general or unknown exception it will throw into Exception.
What should I use for ABAP programming?
Please use above example to show me please.
Thank you very much.
2008 Apr 30 8:36 AM
If you know which exception will be thrown you can use this. But if you are not really sure and you haven't been able to find out it is possible to use the root exception (main exception of which all other exceptions are inherited).
Main exception: cx_root.
data:lr_error type ref to cx_root.
try.
catch cx_root into lr_error.
endtry.
Other exceptions.
data:lr_error type ref to particular exception.
try.
catch particular exception into lr_error.
endtry.
2008 Apr 30 8:41 AM
Hi Micky Oestreich,
Thanks so much for your prompt replied.
It really solved my problem and doubts.
Thanks so much.
2008 Apr 30 9:16 AM
Just to be complete:
Maybe not all SQL errors can be caught by the class based exceptions. In some cases you might have to use the traditional way of catching exceptions with statement:
CATCH EXCEPTIONS .... (Use F1 help for exact syntax).
2008 Apr 30 10:33 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |