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: 

Numeric Fields

Former Member
0 Kudos
155

Hi,

I need to give only numeric value in the field.wat validation must be done on it?

1 ACCEPTED SOLUTION

Former Member
0 Kudos
120

hi,

***************************************************************************************

data:

p_fld(10) type c .

......................................

................................

at selection-screen on field p_fld.

if p_fld cn '0123456789'.

message 'enter valid number' type 'E'.

endif.

............................................

............................

regards,

naresh.

5 REPLIES 5

Former Member
0 Kudos
120

declare the field type i.

Former Member
0 Kudos
120

this is my code --

DATA : VA_COND(50) VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&()_+=-/'.

IF SY-UCOMM EQ 'SAVE' OR SY-UCOMM EQ 'ENTER'.

IF NOT SCR_WGT IS INITIAL .

IF SCR_WGT CA VA_COND.

  • IF SY-SUBRC NE 0.

SET CURSOR FIELD 'SCR_WGT'.

CLEAR SCR_WGT.

MESSAGE E100 WITH 'Please enter a numeric value here'.

  • CALL SCREEN 200.

  • ENDIF.

ENDIF.

ENDIF.

ENDIF.

0 Kudos
120

You can can write as below.

DATA : VA_COND(10) VALUE '0123456789'.

IF SY-UCOMM EQ 'SAVE' OR SY-UCOMM EQ 'ENTER'.

IF NOT SCR_WGT IS INITIAL .

IF SCR_WGT CO VA_COND.

ELSE.

  • IF SY-SUBRC NE 0.

SET CURSOR FIELD 'SCR_WGT'.

CLEAR SCR_WGT.

MESSAGE E000(0) WITH 'Please enter a numeric value here'.

  • CALL SCREEN 200.

  • ENDIF.

ENDIF.

ENDIF.

ENDIF.

Former Member
0 Kudos
121

hi,

***************************************************************************************

data:

p_fld(10) type c .

......................................

................................

at selection-screen on field p_fld.

if p_fld cn '0123456789'.

message 'enter valid number' type 'E'.

endif.

............................................

............................

regards,

naresh.

laxmanakumar_appana
Active Contributor
0 Kudos
120

Hi,

Check this, It will work.

if fld1 CO '12345 67890'.
   write 'Numeric'
else.
   write 'Non-Numeric'
endif.

Regards

L Appana