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

validate integer value

Former Member
0 Likes
3,009

Hi experts,

how to validate integer value in selection screen event.

thanks

8 REPLIES 8
Read only

Former Member
0 Likes
1,476

Hi,

PARAMETERS p_num type i.

AT SELECTION-SCREEN.

if p_num GT 100.

message 'Greater than 100' type 'S'.

endif.

Regards,

Kumar Bandanadham

Read only

0 Likes
1,476

i need some if condition for checking.

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

Read only

0 Likes
1,476

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

Read only

0 Likes
1,476

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

Read only

Former Member
0 Likes
1,476

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

Read only

Former Member
0 Likes
1,476

use function " ISH_CHECK_INTEGER"

thanks

Venkat

Read only

Former Member
0 Likes
1,476

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..

Read only

Former Member
0 Likes
1,476

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.