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

string

Former Member
0 Likes
697

hai all,

data : c_rcpt1 type string.

i am checking that string contains 0,1,2,3,4,5,6,7,8,9 i have to make changes in code. for that i am using code c_rcpt1 cs '0' or c_rcpt1 cs '1' or c_rcpt1 cs '2' and so on

is there any code directly comparing like

c_rcpt1 cs '0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9'.

plese help

Thanks,

laxmi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
656

if c_rcpt1 ca '0123456789'.

endif.

5 REPLIES 5
Read only

Former Member
0 Likes
656

Hi Laxmi,

YOu want to check if the string is numeric?

Then do this:

call function 'NUMERIC_CHECK'

exporting

string_in = c_rcpt1

importing

string_out = c_rcpt1

htype = type.

if type = 'NUMC'.

write:/ 'The string contains only numbers.

endif.

Regards,

Ravi

Read only

Former Member
0 Likes
657

if c_rcpt1 ca '0123456789'.

endif.

Read only

Former Member
0 Likes
656

Laxmi,

Create a sting as below:

c_rcpt2 = '0123456789'.

And use commant:

c_rcpt1 ca c_rcpt2.

This will solve your problem.

Thanks.

Read only

Former Member
0 Likes
656

Hi,

Try

CA (Contains Any):

c1 contains at least one character from the string c2.

If c1 or c2 is of type C, the comparison takes into account the full length of the field, including blanks at the end.

If c1 or c2 is of type STRING and empty, the result of the comparison is always negative.

If the result of the comparison is positive, the system field SY-FDPOS contains the offset of the first character in c1 which is also in c2.

If the result of the comparison is negative, the system field SY-FDPOS contains the length of c1.

The comparison is case-sensitive.

Examples:

'ABCDE' CA 'CY' is true; SY-FDPOS = 2.

'ABCDE' CA 'XY' is false; SY-FDPOS = 5.

So this may solve ur problem.

Read only

Former Member
0 Likes
656

try to use CA instead of CS CA (contains any). and if you are checking only no then you can use CO(contains only).

regards

shiba dutta