2007 Oct 11 9:29 AM
Hi,
in a class, i have two methods, let me call them A and B.
method A is calling method B. In method B an exception CX_SY_CONVERSION_NO_NUMBER may occur. So the code is something like this in method A:
TRY.
me->B( par ).
catch CX_SY_CONVERSION_NO_NUMBER.
do_some_error_handling
ENDTRY.
Stll the program abends with an uncaught exception CX_SY_CONVERSION_NO_NUMBER which occured in method B. Why isnt this be caught in method A? How can i handle this in method A with try and catch?
2007 Oct 11 10:00 AM
Hi..
Here the Exception is triggered by method B. So u must have to code like this.
in the Method B Definition you must add the addition
RAISING CX_SY_CONVERSION_NO_NUMBER as a parameter. Then this code works.
TRY.
me->B( par ).
catch CX_SY_CONVERSION_NO_NUMBER.
do_some_error_handling
ENDTRY.
REWARD IF HELPFUL.
Hi,
in a class, i have two methods, let me call them A and B.
method A is calling method B. In method B an exception CX_SY_CONVERSION_NO_NUMBER may occur. So the code is something like this in method A:
TRY.
me->B( par ).
catch CX_SY_CONVERSION_NO_NUMBER.
do_some_error_handling
ENDTRY.
Stll the program abends with an uncaught exception CX_SY_CONVERSION_NO_NUMBER which occured in method B. Why isnt this be caught in method A? How can i handle this in method A with try and catch?
2007 Oct 11 9:35 AM
Hi,
Strange - have you checked whether your CATCH block is actually executed? If so, are you shure that your exception code doesn't raise an exception itself?
Regards, Joerg
2007 Oct 11 9:45 AM
No, the catch isnt executed, the abend says thats happening when i'm assigning 'A' to a decimal varbiable. Of course this is not possible, but i want to handle this myself without an abend. And yes, the exception is exactly the same i wrote in my catch expression and which finally abends the program.
2007 Oct 11 9:49 AM
Hello Rainer,
To make sure everything is caught catch the exception cx_root.
If that doesn't help you could do the following:
don't use TRY ... ENDTRY.
But use CATCH ... ENDCATCH:
CATCH SYSTEM-EXCEPTIONS.
me->B( par ).
if sy-subrc <> 0.
do_some_error_handling.
endif.
ENDCATCH.
best regards
Sven
2007 Oct 11 9:59 AM
If i'm doing it like this:
try.
tmp = 'A'.
me->convert( parameter ).
catch cx....
endtry.
the exception is caught. I thought that calling a methof/function where an exception occured is caught too, but is this not true? Are systemexceptions are being handled in the same scope?
2007 Oct 11 10:00 AM
Hi..
Here the Exception is triggered by method B. So u must have to code like this.
in the Method B Definition you must add the addition
RAISING CX_SY_CONVERSION_NO_NUMBER as a parameter. Then this code works.
TRY.
me->B( par ).
catch CX_SY_CONVERSION_NO_NUMBER.
do_some_error_handling
ENDTRY.
REWARD IF HELPFUL.
2007 Oct 11 10:20 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |