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

Validation on Integer Field

Former Member
0 Likes
975

Hi All,

I have a Integer Field.

I need to do a validation that this field should not be initial ie it is mandatory. But this validation should not happen if '0' ie ZERO is entered on the field.

But if i check by 'INITIAL' or 'SPACE', it is taking zero also as initial.

I dont want the validation to happen if ZERO is entered.

Is there any way to do so?

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
830

REPORT ZSRK_075 MESSAGE-ID ZMSG .

PARAMETERS : P_F1 TYPE I MEMORY ID PID.

DATA : L_F1(6).

AT SELECTION-SCREEN.

GET PARAMETER ID 'PID' FIELD L_F1.

IF L_F1 EQ ' '.

MESSAGE E001 WITH 'Enter a value in P_F1'.

ENDIF.

6 REPLIES 6
Read only

Former Member
0 Likes
830

IF field1 CN '0123456789'.

ENDIF.

use this

Regards,

Ajay

Read only

Former Member
0 Likes
830

i think u have to validate only for characters .

u can try like this also .

IF field1 CA sy-abcde.

ENDIF.

Read only

Former Member
0 Likes
830

Hi,

You can do like this.

1.)

If field ne 0.
      perform validation.
     endif.

or

2.)

Declare field as a string and use like this.

IF field CA '0123456789'.
        perform validation.
    endif.

Thanks

Nitesh

Edited by: Nitesh Kumar on Dec 2, 2008 3:34 PM

Read only

Former Member
0 Likes
830

Hello Tejas,

1)If u want this validation on selection screen,

At selection-screen.

if int_field = ' 0'.

leave to screen 0.

or u can display error msg

endif.

2)if u want it in module pool.

write same if else condition in PAI.

Read only

Former Member
0 Likes
830

Hi,

Try like this:

parameters: p_int type i.

at selection-screen on p_int.

if p_int is initial.

if p_int = 0.

if p_int EQ space.

message e000(00) with 'Enter value other than 0 is not initial.'.

endif.

endif.

endif.

Regards,

Bhaskar

Read only

Former Member
0 Likes
831

REPORT ZSRK_075 MESSAGE-ID ZMSG .

PARAMETERS : P_F1 TYPE I MEMORY ID PID.

DATA : L_F1(6).

AT SELECTION-SCREEN.

GET PARAMETER ID 'PID' FIELD L_F1.

IF L_F1 EQ ' '.

MESSAGE E001 WITH 'Enter a value in P_F1'.

ENDIF.