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

digits

Former Member
0 Likes
724

hi i have a 6 char field .

in that i have to check each character is a char or numeric .

pls help me

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
695

Hi

declare 2 variables:

data: char(26) type c value 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',

num(9) type value '1234567890',

str(6) type c value 'ABF123'.

now use the string comparison paramters like CS,CO,CN etc and check

if str CS char or Str CO num.

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

endif.

Regards

Anji

6 REPLIES 6
Read only

Former Member
0 Likes
695

USING SEARCH SYNTAX U CAN EASY FIND EASYLY DO.

Read only

Former Member
0 Likes
696

Hi

declare 2 variables:

data: char(26) type c value 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',

num(9) type value '1234567890',

str(6) type c value 'ABF123'.

now use the string comparison paramters like CS,CO,CN etc and check

if str CS char or Str CO num.

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

endif.

Regards

Anji

Read only

JozsefSzikszai
Active Contributor
0 Likes
695

hi Chaaya,

IF string CO '0123456789'.

==> it is number

ELSE.

==> it is something else (i. e. not only numbers)

ELSE.

if you have to do it character by character, than you can do in a DO-ENDDO.

hope thishelps

ec

Read only

Former Member
0 Likes
695

do.

try

if string(sy-index) IN '0123456789'.

write: / string(sy-index) ' is a number'.

else

write: / string(sy-index) ' is not a number'.

catch CX_root.

exit.

endtry.

enddo.

*reward if solved*

Read only

Former Member
0 Likes
695

data: cnt type i value 0.

do 6 times.

if str+cnt(1) CO '0123456789'.

message i000.

endif.

enddo.

Hope dis helps..

Reward if it does

Read only

Former Member
0 Likes
695

Hi,

Try like this:

data: v_string(15) type c value 'BHASKAR2006'.

data : str(10) type c.

str = v_string+0(5).

write str.

if str CA sy-abcde.

write 'Characters'.

else.

write 'Numerics'.

endif.

Regards,

Bhaskar