CX_SY_CONVERSION_NO_NUMBER¶
Thrown when ABAP cannot convert a string to a numeric type.
Purpose¶
CX_SY_CONVERSION_NO_NUMBER is raised by the ABAP runtime whenever an implicit or explicit conversion from a character-like type (STRING, CHAR, NUMC, etc.) to a numeric type (I, P, F, DECFLOAT16, etc.) fails because the content is not a valid number. Left uncaught, this produces a CONVT_NO_NUMBER short dump.
Inheritance chain:
CX_SY_CONVERSION_NO_NUMBER → CX_SY_CONVERSION_ERROR → CX_DYNAMIC_CHECK → CX_ROOT
Because it descends from CX_DYNAMIC_CHECK, catching it is optional — the compiler will not warn you if you omit the handler.
Key attributes¶
| Attribute | Type | Description |
|---|---|---|
value |
STRING |
The string that could not be converted |
type |
STRING |
Name of the target ABAP type (e.g. I, DECFLOAT16) |
Both attributes are set by the runtime; you cannot set them yourself when re-raising.
How to catch¶
DATA lv_input TYPE string VALUE '12X4'.
DATA lv_amount TYPE p DECIMALS 2.
TRY.
lv_amount = lv_input. " implicit conversion
CATCH cx_sy_conversion_no_number INTO DATA(lx).
MESSAGE lx->get_text( ) TYPE 'I'.
" lx->value holds '12X4', lx->type holds 'P'
ENDTRY.
Use get_text( ) to retrieve a localised message string suitable for display or logging. Use get_longtext( ) for the full technical description.
" Explicit CONV also raises the same exception
TRY.
lv_amount = CONV p( lv_input ).
CATCH cx_sy_conversion_no_number INTO DATA(lx).
cl_demo_output=>display( lx->get_text( ) ).
ENDTRY.
Silent data corruption risk
Without a TRY block, a bad value causes an immediate dump in production. Wrap all external input conversions — even fields that look numeric — because leading/trailing spaces, currency symbols, or locale-specific separators all cause this exception.
MOVE-CORRESPONDING and MAPPING
MOVE-CORRESPONDING between structures can trigger implicit conversions on every matching field pair. One bad field dumps the whole operation. Use EXACT additions or validate fields individually before the move.
Common scenarios¶
Flat-file / CSV parsing¶
SPLIT lv_line AT ';' INTO TABLE lt_fields.
TRY.
lv_qty = lt_fields[ 3 ]. " field may contain 'N/A' or ''
CATCH cx_sy_conversion_no_number.
lv_qty = 0.
ENDTRY.
User input from screen fields¶
" Screen field declared TYPE char20, moved to numeric
TRY.
lv_total = p_amount.
CATCH cx_sy_conversion_no_number INTO DATA(lx).
MESSAGE lx->get_text( ) TYPE 'E'.
ENDTRY.
BAPI / RFC string fields¶
BAPIs often return amounts as CHAR or STRING. Strip formatting before conversion:
REPLACE ALL OCCURRENCES OF ',' IN lv_string WITH ''.
TRY.
lv_value = lv_string.
CATCH cx_sy_conversion_no_number.
" handle
ENDTRY.
BAPI_TRANSACTION_COMMIT pattern
Do not rely on SY-SUBRC alone when a BAPI may silently pad numeric-string fields. Validate the return table and wrap the assignment.
See also¶
- CONVT_NO_NUMBER — runtime dump analysis