‎2012 Aug 29 1:23 PM
Hi,
I am creating a Z table data upload program where I do not want the end user to see the dump screen with code and text not relevant or understandable to him. The dump can be generated by any reason for example type conversion errors, arithmetic error etc. In short the exception number can not be predefined in Catch statement. Is there any way to just get into the Catch loop if any dump has occurred? So that I can at least print a simple error message with the record number on which the error might have occurred (instead of hardcoding the exception type - I tried with catching CX_root but it is not catching ' CONVT_NO_NUMBER' dump).
Thanks,
Binita
‎2012 Aug 29 2:04 PM
Could you past part of your code as CX_ROOT should be able to catch all catchable exceptions.
TRY.
MOVE w1-field TO w2-field.
* CATCH cx_sy_conversion_no_number.
* text = oref->get_text( ).
* CATCH cx_sy_conversion_overflow.
* text = oref->get_text( ).
* CATCH cx_sy_move_cast_error
* text = oref->get_text( ).
CATCH cx_root INTO oref.
text = oref->get_text( ).
ENDTRY.
Remember some errors are NOT CATCHABLE, look for information at MOVE documentation or INSERT dbtab documentation.
Regards,
Raymond
‎2012 Aug 29 2:04 PM
Could you past part of your code as CX_ROOT should be able to catch all catchable exceptions.
TRY.
MOVE w1-field TO w2-field.
* CATCH cx_sy_conversion_no_number.
* text = oref->get_text( ).
* CATCH cx_sy_conversion_overflow.
* text = oref->get_text( ).
* CATCH cx_sy_move_cast_error
* text = oref->get_text( ).
CATCH cx_root INTO oref.
text = oref->get_text( ).
ENDTRY.
Remember some errors are NOT CATCHABLE, look for information at MOVE documentation or INSERT dbtab documentation.
Regards,
Raymond
‎2012 Aug 29 2:39 PM
Thanks for the response Raymond.
Try.
if X_DATA-VALUE+3(2) > 12 or X_DATA-VALUE+0(2) > 31.
V_COUNT_IN = V_COUNT_IN + 1
endif.
catch CX_root into OREF.
TEXT = OREF->GET_TEXT( ).
concatenate 'The following error generated on record ' V_INDEX 'on column ' X_TABDESCR-NAME into error SEPARATED BY space .
write : / error . "INDEX.
write / text .
return.
endtry..
this is part of my code. here X_DATA-VALUE has to be numeric value for it to be compared to a number. If this value is non-numeric, the exception should be caught in Catch loop. This never gets into catch loop. but gives dump directly. What could be wrong?
Thanks,
Binita
‎2012 Aug 29 3:01 PM
try moving data before evaluation of logical expression
TRY.
lv_mm = x_data-value+3(2). " LV_MM defined as TYPE I so raise an error
lv_dd = x_data-value+0(2). " LV-DD defined as TYPE I
IF lv_mm > 12 OR lv_dd > 31.
v_count_in = v_count_in + 1.
ENDIF.
CATCH cx_root INTO oref.
text = oref->get_text( ).
CONCATENATE 'The following error generated on record ' v_index 'on column ' x_tabdescr-name INTO error SEPARATED BY space .
WRITE : / error . "INDEX.
WRITE / text .
RETURN.
ENDTRY.
Regards,
Raymond
‎2012 Aug 30 5:52 AM
It's not a conversion you are doing but it is a logical expression check, so it is not catching the exception. As you see Raymond has moved it into a variable of type i, so the conversion exception gets caught.
Make it simple like below for this special case
if X_DATA-VALUE CO '1234567890'.
if X_DATA-VALUE+3(2) > 12 or X_DATA-VALUE+0(2) > 31.
V_COUNT_IN = V_COUNT_IN + 1
endif.
else.
Populate the manual message here, for the rest of the case let the exception be caught.
endif.
‎2012 Aug 31 7:20 AM
Thanks Raymond and Kesavadas. It did solve the problem and caught the exception. will
cx_root be able to catch all assigned exceptions? like database exception, primary key violation etc if the 'Insert into table XXXXX' syntax is written between this Try Catch? is there any way to be sure that the client wont see the dump screen.
Thanks,
Binita Joshi