02-20-2014 6:28 PM
Hi all,
I am using NUMERIC_CHECK to check if the value is numeric or not.
But if I input a value like 122.22 the system treats this value as Character.
I also tried another fm CATS_NUMERIC_INPUT_CHECK with the same value, in the fm it gives me the same value in return but if i apply this fm in my program then it gives runtime error saying 'Unable to interpret . as number'
How to solve this?
any example.???
02-20-2014 6:44 PM
You can catch the runtime error to decide whether it is a number or not. Something like this.
/.
02-20-2014 7:02 PM
Hello Yash,
NUMBER_CHECK & CATS_NUMERIC_INPUT_CHECK both FM are trying to check number which are '0123456789 '.
In your example '122.22' dot after 122 system is treating as character. It is returning as Character.
You can use either of below approach.
IF P_DEC CN '.123567890 '.
MESSAGE E307 WITH 'ENTER CORRECT VALUE'.
ENDIF.
NB = STRLEN( W_FIELD ).
DO NB TIMES.
W_INDEX = SY-INDEX - 1.
ASSIGN W_INDEX TO <OFFSET>.
IF W_FIELD+<OFFSET>(1) CO '0123456789.'.
else.
exit.
ENDIF.
ENDDO.
02-20-2014 7:21 PM
Hi Yash,
As I understood , you want to check numeric with decimal also
Try this,
DATA : input(200) TYPE c,invalid TYPE c, valid TYPE c.
* Only dot then also invalid
IF input CO '.'.
invalid = 'X'.
* Contain otherthen numbers + dot then invalid
ELSEIF input CN '0123456789.'.
invalid = 'X'.
ELSE.
valid = 'X'.
ENDIF.
Keep this code in perform or function module check numeric
Thanks & Regards,
Arun
02-20-2014 8:45 PM
Hi,
I'd also use the CO operator: "if lv_string CO '123456789.'."
all the best,
Kieran
02-21-2014 5:27 AM
I am using module pool.
loop at it_weight INTO wa_weight.
if wa_weight co '0123456789.'.
st_REF-Zgross_WEIGHT = wa_weight-in.
ENDIF.
ENDLOOP.
after the loop on it_weight I have checked the condition. though it is not going in the if condition.
this is my code. I am getting value in wa_weight from clipboard.
02-21-2014 8:35 AM
Hi,
May be spaces are present in wa_weight. If yes condense the wa_weight.
Thanks & Regards,
Arun