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: 

validate integer value

Former Member
0 Kudos

Hi experts,

how to validate integer value in selection screen event.

thanks

8 REPLIES 8

Former Member
0 Kudos

Hi,

PARAMETERS p_num type i.

AT SELECTION-SCREEN.

if p_num GT 100.

message 'Greater than 100' type 'S'.

endif.

Regards,

Kumar Bandanadham

0 Kudos

i need some if condition for checking.

Like i want to check whether certain value is interger or string.

0 Kudos

Hi,

DATA: v_num(10) VALUE '0123456789',

v_len TYPE i.

PARAMETERS p_num(30) TYPE c.

AT SELECTION-SCREEN.

v_len = STRLEN( p_num ).

IF v_len GT 0.

IF p_num+0(v_len) CO v_num.

MESSAGE 'Numeric' TYPE 'S'.

ELSE.

MESSAGE 'Char' TYPE 'S'.

ENDIF.

ELSE.

MESSAGE 'Char' TYPE 'S'.

ENDIF.

Regards,

Kumar Bandanadham

Edited by: Velangini Showry Maria Kumar Bandanadham on Jun 16, 2009 6:46 AM

0 Kudos

Hi,

parameters p_num type char20.

at selection-screen.
if p_num ca sy-abcde or p_num ca '~!@#$%^&*()_+'. "---> here you can check 
      " even for the special characters
message 'This is not an integer value' type 'E'.
endif.

Thanks&Regards

Sarves

Former Member
0 Kudos

Hi

Use the following function module.

DATA v_type TYPE dd01v-datatype.

CALL FUNCTION 'NUMERIC_CHECK'

EXPORTING

string_in = value_to_be_validated

IMPORTING

htype = v_type

.

if v_type NE 'NUMC'.

raise error message.

endif.

Thanks and regards,

Venkat

Former Member
0 Kudos

use function " ISH_CHECK_INTEGER"

thanks

Venkat

Former Member
0 Kudos

Hi,

Please try this code:


lv_wild(37) TYPE c VALUE '*`~!@#$%^&()-_+=|\}{][;:,<>./?''' <----------- Or 26 english alphabets ...

 LOOP AT so_name.
      lv_len = strlen( so_name-low ).
      CLEAR lv_pos.
      WHILE lv_pos LT lv_len.
        lv_c = so_name-low+lv_pos(lv_no).
        lv_pos = lv_pos +  1.
        IF lv_wild CA lv_c.
          REFRESH so_name.
          CLEAR so_name.
          EXIT.
        ENDIF.
      ENDWHILE.
    ENDLOOP.

Hope this helps you..

Former Member
0 Kudos

data x type i value 1000.

data y type TOBJ_TPO-TPL_NAME.

y = x.

CALL FUNCTION 'TPL_CHECK_VALID_CHARACTERS'

EXPORTING

TEMPLATE_NAME = y

EXCEPTIONS

NOT_VALID = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

write 😕 ' x is an integer'.

ENDIF.

Instead of declaring x as I if u declare x as character type this FM will return sy-subrc as 0.

In case of integer , as integer has leading blank spaces it will return sy-subrc as 1 for Integers.