Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

convt_no_number error

Former Member
0 Likes
968

Hello ABAP Experts,

I get this error in my program. convt_no_number..

what does this error mean

Suggestions appreciated.

Thanks,

BWer

Hello ABAP Experts,

I get this error in my program. convt_no_number..

what does this error mean

Suggestions appreciated.

Thanks,

BWer

2 REPLIES 2
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
794

This means that you are trying to move a value into a numeric field that has a character that can not be converted to numeric. I see this a lot when trying to move a number with a thousands separator, like ',' into a numeric field.

This will produce the runtime error.

data: c(10) type c value '1,234.00'.
data: i type i.

i = c.

You can get around this by getting rid of the commm.



data: c(10) type c value '1,234.00'.
data: i type i.

<b>translate c using ', '.
condense c no-gaps.</b>
i = c.



Please check your value for non-numeric characters.

REgards,

Rich Heilman

Read only

Former Member
0 Likes
794

Hello,

You might find function RS_CONV_EX_2_IN_NO_DD useful for validating numeric input when moving from a character to numeric field. This handles the specific decimal notation of the user e.g. European "1.123,54" or US "1,123.54". Here is a little report where you can enter a test string on the selection screen:

REPORT zznumeric.

PARAMETERS:
  p_string         TYPE text12.

START-OF-SELECTION.
  DATA:
* Target numeric field with 3 decimal places
    lw_dec_fld(7) TYPE p DECIMALS 3.

  WRITE: / p_string.

* Check that the qty is a valid numeric value
  CALL FUNCTION 'RS_CONV_EX_2_IN_NO_DD'
       EXPORTING
            input_external  = p_string
       IMPORTING
            output_internal = lw_dec_fld
       EXCEPTIONS
            error_message   = 1
            OTHERS          = 2.

  IF sy-subrc <> 0.
    WRITE: / 'Invalid numeric input'.
  ELSE.
    WRITE / lw_dec_fld.
  ENDIF.

- Anthony.

p.s. In general you can prevent your program from short dumping by putting the code that may trigger the system exception in a CATCH SYSTEM-EXCEPTIONS ... ENDCATCH block

e.g.

  CATCH SYSTEM-EXCEPTIONS convt_no_number = 1.
    lw_dec_fld = p_string.
  ENDCATCH.

  IF sy-subrc = 1.
    WRITE: / 'Invalid number'.
  ENDIF.