‎2006 Aug 25 9:44 PM
Hi Folks!
I have a requirement where I need to handle an exception. What i'm doing is a batch input, though I doing it over a standard transaction, I need to be sure that if a dump occurs in the time executing the transaction, I can catch it and execute some cleanup process.
Something like this:
Controlled block:
Perform transaction 'XK02'.
IF an error ocurred, catch and execute cleanup.
I've got an example, however it is through objects and I'm getting an error that CX_ROOT is unknown.
<i>report DEMO_HANDLE_EXCEPTIONS.
parameters NUMBER type I.
data RESULT type P decimals 2.
data OREF type ref to CX_ROOT.
data TEXT type STRING.
start-of-selection.
write: / 'Testing divison and Sqare root with', NUMBER.
uline.
try.
if ABS( NUMBER ) > 100.
raise exception type CX_DEMO_ABS_TOO_LARGE.
endif.
try.
RESULT = 1 / NUMBER.
write: / 'Result of division:', RESULT.
RESULT = SQRT( NUMBER ).
write: / 'Result of square root:', RESULT.
catch CX_SY_ZERODIVIDE into OREF.
TEXT = OREF->GET_TEXT( ).
cleanup.
clear RESULT.
endtry.
catch CX_SY_ARITHMETIC_ERROR into OREF.
TEXT = OREF->GET_TEXT( ).
catch CX_ROOT into OREF.
TEXT = OREF->GET_TEXT( ).
endtry.
if not TEXT is initial.
write / TEXT.
endif.
write: / 'Final result:', RESULT.</i>
Please guide me how I could handle this, the cleanup it's pretty critical.
Thanks.
Regards,
Gilberto Li
‎2006 Aug 25 10:27 PM
Hello Gilberto
If you are doing standard BDC using
CALL TRANSACTION 'XK02' USING lt_bdcdata
MESSAGES INTO lt_messages.then you can collect all messages of the batch-input and analyse them afterwards. So you do not need any TRY/CATCH block.
However, if the syntax check says that CX_ROOT does not exist this would mean that you are working on an old release not having this root exception class.
Regards
Uwe
‎2006 Aug 25 10:27 PM
Hello Gilberto
If you are doing standard BDC using
CALL TRANSACTION 'XK02' USING lt_bdcdata
MESSAGES INTO lt_messages.then you can collect all messages of the batch-input and analyse them afterwards. So you do not need any TRY/CATCH block.
However, if the syntax check says that CX_ROOT does not exist this would mean that you are working on an old release not having this root exception class.
Regards
Uwe
‎2006 Aug 25 10:41 PM
Hi Uwe, thanks for your reply.
1. You're right, i'm working on an older version that doesn't have the exception handling feature, I was suspecting that.
2. I know you can collect the error messages, however what if while executing the batch input it gives a dump, the execution of the calling program (the program making the call transaction) will be ended too, and I need to process some clean up operations if this happens.
3. I know that usually and the probabilities that a standard transaction gives a dump its pretty low, but I still need to prevent that if an error(not a transaction error, by error I meaning a dump) still occurs do the clean up that it's critical.
Thanks again.
Regards,
Gilberto Li
‎2006 Aug 25 10:46 PM
I don't think that is possible. How can you catch and process an error thrown by a standard application. I know the probability is low, but if it happens then you have to fix it by implementing OSS notes if there is any for that error.
Thanks,
‎2006 Aug 25 11:38 PM
Hi Somen, thanks for your reply.
Yes, I think this isn't possible either now. I thought in a beggining that a exception handling could do the trick, but now that I know I can't count with it, it seems that I won't be able to control an error.
I will have to deal with the low probabilities of a standard transaction givin a dump, and if it happens fix it as soon as possible with OSS Notes.
Thanks again.
Regards,
Gilberto Li.