cancel
Showing results for 
Search instead for 
Did you mean: 

Check numbers in alpha numeric string

Former Member
0 Kudos

Hi All

Is there any direct command or function module which will find numbers in alpha numeric string or it will check that the string contains only numbers ?

Regards

Yogesh

Accepted Solutions (1)

Accepted Solutions (1)

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Here is the sample code.Kindly reward points by clikcing the star on the left of reply,if it helps.

data : alphanumeric(38).

parameters fname(4).

AT SELECTION-SCREEN ON fname.

IF fname CA '0123456789' and fname ca sy-abcde.

message e000(zhrt) with 'alphanumeric'.

elseif fname ca '0123456789'.

message e000(zhrt) with 'no'.

elseif fname ca sy-abcde.

message e000(zhrt) with 'alphabet'.

ENDIF.

Answers (5)

Answers (5)

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

If your question is answered,could you please close the thread by clikcing the blue star against the reply,which solved your problem.If you solved it on your own,click solved on my own against your question.

If your question is still not solved,kindly get back for clarifications.

vinod_gunaware2
Active Contributor
0 Kudos

HI

u can use STRING operation like CS,CP..etc.

regard

vinod

Former Member
0 Kudos

Hi Yogesh,

What exactly do you want to do here? Please explain in detail. In case you want to validate the input in a text box, SAP does that automatically based on the underlying field's definition.

Regards,

Madhur

Former Member
0 Kudos

hi,

There is no FM to find out if the string contains only numbers, but you can check this using this sample code.

data: numb type i.

ranges : num for numb.

num-low = 1.

num-high = 9.

num-option = 'BT'.

num-sign = 'I'.

append num.

parameters: p(1) .

Check p co num .

write: / 'it is in 1-9'.

endif.

Former Member
0 Kudos

hi,

data: fvalue(4) type c,

nvalue(4) type n.

fvalue = 'ABC1'.

nvalue = fvalue.

if fvalue cn nvalue .

message i000(zz) with 'fvalue contains not Only numbers'.

else.

message i000(zz) with 'fvalue containsOnly numbers'.

endif.

Regards,

Sailaja.