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

How to check a char. in a variable.

Former Member
0 Likes
2,480

Hi friends.

I want to check one variable type Numc, if it contains alphabet(either capital or small). I have to raise the message for that.

Please help me.

with regards.

Koteswar.

5 REPLIES 5
Read only

Former Member
0 Likes
1,413

Hi,

Use the function module NUMERIC_CHECK.

Exx

DATA: S_STRING TYPE STRING.

DATA: DDIC_TYPE TYPE DD01V-DATATYPE.

CALL FUNCTION 'NUMERIC_CHECK'

EXPORTING

STRING_IN = S_STRING

IMPORTING

STRING_OUT = S_STRING

HTYPE = DDIC_TYPE.

IF HTYPE = 'NUMC'.

***OK..

ELSE.

***NOT OK..

ENDIF.

Thanks,

Naren

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,413
if var co '1234567890'.
else.
 Message e001(00) 'Var is not numeric'.
endif.

Regards,

Rich HEilman

Read only

Former Member
0 Likes
1,413
if v_var CA SY-ABCDE.
  message e001(ZZ) with ' Variable contains alphabets'.
endif.

TRANSLATE SY-ABCDE TO lower  CASE.

if v_var CA SY-ABCDE.
  message e001(ZZ) with ' Variable contains alphabets'.
endif.
Read only

Former Member
0 Likes
1,413

hi!

First of all a NUMC variable can't hold a character.it can only accumulate numbers.

Regards,

Neha Bansal.

Message was edited by:

Neha Bansal

Read only

Former Member
0 Likes
1,413

hai,

data var(9) type n.

var = '123asd123'.

if var co '1234567890'.

message 'var is numeric' type 'S'.

else.

Message e001(00) 'Var is not numeric'.

endif.

it never give 'Var is not numeric'.

becaz it not allow any char other than number.

regards ,

ananth.

Message was edited by:

ananth