2010 Dec 06 10:30 AM
Hi,
i try this simple code and get allways a short dump with CONVT_NO_NUMBER.
DATA: WA_CHAR TYPE CHAR128 VALUE 'TEST'.
*
IF WA_CHAR = 0. WRITE: 'is 0'. ENDIF.
Then i try it with CATCH and get still the short dump.
DATA: WA_CHAR TYPE CHAR128 VALUE 'TEST'.
*
TRY.
IF WA_CHAR = 0. WRITE: 'is 0'. ENDIF.
CATCH CX_SY_CONVERSION_NO_NUMBER.
WRITE: / 'ERROR'.
ENDTRY.
Has anyone an idea with mistake i do.
thanks.
Regards, Dieter
Hi,
i try this simple code and get allways a short dump with CONVT_NO_NUMBER.
DATA: WA_CHAR TYPE CHAR128 VALUE 'TEST'.
*
IF WA_CHAR = 0. WRITE: 'is 0'. ENDIF.
Then i try it with CATCH and get still the short dump.
DATA: WA_CHAR TYPE CHAR128 VALUE 'TEST'.
*
TRY.
IF WA_CHAR = 0. WRITE: 'is 0'. ENDIF.
CATCH CX_SY_CONVERSION_NO_NUMBER.
WRITE: / 'ERROR'.
ENDTRY.
Has anyone an idea with mistake i do.
thanks.
Regards, Dieter
2010 Dec 06 10:41 AM
Hi,
You have defined char type, you should always use character literals in comparision.
IF ld_char = '0'.
....
ENDIF.
Regards
Praveen
2010 Dec 06 10:43 AM
Dieter is wondering why he cannot catch the exception, not how to properly convert between types (which would be too basic and get locked...)
Thomas
2010 Dec 06 10:42 AM
The way you're doing the conversion implicitely ("IF WA_CHAR = 0"), the exception is not assigned to a class and cannot be caught with TRY / CATCH / ENDTRY.
If you declare a number field and move the content from the character to the number field, then class CX_SY_CONVERSION_NO_NUMBER will be assigned. Compare the headings of the respective short dumps.
Thomas
2010 Dec 06 10:45 AM
Hi,
If you want to avoid the dump write as :
IF WA_CHAR = '0'.
WRITE: 'is 0'.
ENDIF.
Regards,
Srini.
2010 Dec 06 11:06 AM
Hi,
thanks, but i will not avoid it by changing the statement.
I will catch this exception (as Thomas allready says).
Regards, Dieter
2010 Dec 06 12:45 PM
Run the following code
DATA: WA_CHAR TYPE CHAR128 VALUE 'TEST'.
data oref TYPE REF TO cx_root.
TRY.
RAISE EXCEPTION TYPE cx_sy_conversion_no_number.
IF WA_CHAR = 0.
RAISE EXCEPTION TYPE cx_sy_conversion_no_number.
WRITE: 'is 0'.
ENDIF.
CATCH CX_SY_CONVERSION_NO_NUMBER into oref.
WRITE: / 'ERROR'.
CATCH cx_root into oref.
CLEANUP.
clear wa_char.
ENDTRY.
2010 Dec 07 10:40 AM
Hi Krupaji,
can you please explain your code for the dummy?
As I understand, the first thing you do after TRY .. CATCH block is opened with
TRYRAISE EXCEPTION TYPE cx_sy_conversion_no_number.This will transfer directly to the CATCH block, the lines
IF WA_CHAR = 0.
RAISE EXCEPTION TYPE cx_sy_conversion_no_number.
WRITE: 'is 0'.
ENDIF.Are never processed. Processing continues with
CATCH CX_SY_CONVERSION_NO_NUMBER into oref.
WRITE: / 'ERROR'.regardsless of WA_CHAR value
CATCH cx_root into oref.is not reached from anywhere
CLEANUP.
clear wa_char.will work as designed: Clear WA_CHAR regardsless of value.
The reason for the uncatchable exception is in the kernel architecture: If you compare a text value with a numeric dataobject, the text value is converted implicitly to a number allowing all kind of comparisons like GT, GE, EQ, NE, LT, LE.
This implicit conversion can not be caught, even CX_ROOT will not catch it.
This is also new to me: I thought I could catch just everything with CX_ROOT.
Regards,
Clemens
ENDTRY.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |