Application Development 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: 

Solve Runtime Error CONVT_NO_NUMBER

Former Member
0 Kudos

Dear All,

When I test a subroutine that included in SAPScript,a runtime error occured.Below is the error message.

-


Unable to interpret "XXXXXXXXXXX.XX " as a number.

-


<b>Error analysis</b>

An exception occurred. This exception is dealt with in more detail below. The exception, which is assigned to the class 'CX_SY_CONVERSION_NO_NUMBER', was neither

caught nor passed along using a RAISING clause, in the procedure "Z_CALCULATE_GROSS" "(FORM)".

Since the caller of the procedure could not have expected this exception to occur, the running program was terminated.

The reason for the exception is:

The program attempted to interpret the value "XXXXXXXXXXX.XX " as a number, but

since the value contravenes the rules for correct number formats,

this was not possible.

-


<b>The related source code is :</b>

-


000160

000170 FORM Z_CALCULATE_GROSS TABLES IN_TAB STRUCTURE ITCSY

000180 OUT_TAB STRUCTURE ITCSY.

000190

000200 DATA: NET_VALUE LIKE EKPO-NETPR, " TYPE C,

000210 GROSS TYPE P DECIMALS 2. "LIKE EKPO-NETPR.

000220

000230 READ TABLE IN_TAB WITH KEY 'EKPO-NETPR'.

<b>-----> NET_VALUE = IN_TAB-VALUE.</b>

000250

-


It seems that the data type of NET_VALUE can not be assigned a type CHAR data source.But the data source IN_TAB-VALUE actually is a CHAR type.

How should I solve this problem ?

Thanks!

Brian Liu

5 REPLIES 5

Former Member
0 Kudos

Hi,

The problem is you are assigning a char field to a currency field.

DATA: NET_VALUE LIKE EKPO-NETPR,

its a currency field with length 11 and decimal place 2.

you can ceck the netpr filed from ekpo table in se11.

So the filed value filed in IN_TAB table should be like ekpo-netpr.

if this solves your query please reward points

Former Member

Hi

the internal tables that transfer date from sapscript to form save the data in char format, so before moving your value to variable you should check the type of that variable because a dump could occur.

Now in IN_TAB-VALUE you have a amount and it's char type and output form. If you have 101060.34 in IN_TAB-VALUE you'll have: 101.060,34. The system can't interpret the value as number when you try to transfer in NET_VALUE.

So you convert your value before moving it to NET_VALUE.

For example:

DO.

REPLACE '.' WITH SPACE INTO IN_TAB-VALUE.

IF SY-SUBRC <> 0. EXIT.

ENDDO.

CONDENSE IN_TAB-VALUE NO-GAPS.

REPLACE ',' WITH '.' INTO IN_TAB-VALUE.

Now you can move IN_TAB-VALUE to NET_VALUE.

Max

Message was edited by: max bianchi

Former Member
0 Kudos

hi,

the problem with

DATA: NET_VALUE LIKE EKPO-NETPR,

because number to currency and vice versa is cause this error

DATA: NET_VALUE type p decimals 2,

for that you define like decimal or P

cheers,

sasi

Former Member
0 Kudos

Also, a good way of exception handling like in this case, would be to catch catchable runtime errors like this one and handle exceptions to your requirements:


CATCH SYSTEM-EXCEPTIONS CONVT_NO_NUMBER = 5.
 DO.
  ......
  ......
 ENDDO.
ENDCATCH.

IF SY-SUBRC = 5.
 "handle your exceptions here
ENDIF.

Cheers,

Sougata.

Former Member
0 Kudos

Closed the topic and thanks all of you!