‎2007 Feb 06 8:14 AM
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
‎2007 Feb 06 8:19 AM
‎2007 Feb 06 8:18 AM
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
‎2007 Feb 06 8:19 AM
‎2007 Feb 06 8:19 AM
Laxmi,
Create a sting as below:
c_rcpt2 = '0123456789'.
And use commant:
c_rcpt1 ca c_rcpt2.
This will solve your problem.
Thanks.
‎2007 Feb 06 8:23 AM
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.
‎2007 Feb 06 8:24 AM
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