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

CONVERT STRING INTO NUMERIC VALUE

Former Member
0 Likes
1,646

HI,

CAN ANY BODY TELL ME HOW TO CONVERT STRING VALUE IN TO NUMERIC VALUE. WITH ERROR CHECK.

FOR EXP.

IF STRING VALUE LIKE 32145 THEN ITS NUMERIC VALUE = 32145

IF STRING VALUE IS LIKE 3245\ THEN SAY NOT A NUMERIC VALUE BUT NOT GAVE DUMP

THANKS

MUKESH

4 REPLIES 4
Read only

Former Member
0 Likes
1,424

Try this Fm with your inputs .

<b>NUMERIC_CHECK</b>

returns a char data type for values other than numeric

and a numc data type for numeric values.

Regards,

Vijay.

Read only

Former Member
0 Likes
1,424

hi,

Mr. Agrawal..

Try function module CATS_ITS_MAKE_STRING_NUMERICAL

may it will help you.

cheers....................

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,424

Try the code below

CATCH SYSTEM-EXCEPTIONS conversion_errors = 1.
  MOVE text TO amount.
ENDCATCH.
IF sy-subrc EQ 1.
*not numeric

Regards

Read only

Former Member
0 Likes
1,424

Try this:

&----


*& Form convert-string-to-number (type f, i, p)

&----


FORM convert-string-to-number

USING

value(p_string) TYPE string

CHANGING

p_number TYPE any "-- f, i, p --

p_error TYPE i.

TRY.

CLEAR p_error.

p_number = p_string. "Convert string to number.

CATCH cx_sy_conversion_no_number.

p_error = 1.

CATCH cx_sy_conversion_overflow.

p_error = 2.

ENDTRY.

ENDFORM. "convert-string-to-number