2007 Oct 01 8:29 AM
Hi All,
how to find out whether the first 5 chars alphabets or not in a string for a particualr field in an internal table
reply me soon if anyone can
i hv a sting like this
yruwy8900
and i have to check whether the first 5 characters are characters or numeric
Thanks in advance
Vikas
Hi,
SY-ABCDE contains alphabets with capital letters. So, string myst be in capital letters only.
Try with this code:
data: v_string(15) type c value 'APPLEBANANA2006'.
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
2007 Oct 01 8:31 AM
iHi,
IF var+0(5) CS sy-abcde.
...First 5 characters are alphabates.
ENDIF.
Regards,
Atish
2007 Oct 01 8:32 AM
2007 Oct 01 8:32 AM
Moev the string value to a character value first.. gv_char
declare a constant with all numbers (0 to 9). say gc_numbers.
then,
use this.. if gv_char+0(1) ca gc_numbers..
if gv_char+1(1) ca gc_numbers..
do the same upto 5 places in gv_char..
Cheers
2007 Oct 01 8:33 AM
Hi...
Check this condition for alphabets in a String:
IF V_STR(5) CO SY-ABCDE.
ENDIF.
reward if Helpful.
2007 Oct 01 8:34 AM
Hi Vikas ,
check out this function module,
CATS_NUMERIC_INPUT_CHECK
put the letters of the word one by one in this function module,
if the letters are characters, it will through an exception no numeric.
regards,
Santosh Thorat
2007 Oct 01 8:45 AM
Hi,
Use the below code.
data: v_char(10) type c value 'yruwy8900'.
data: v_length type i, v_count type i, v_total type i.
v_length = strlen( v_char ).
if v_length > 5.
do 5 times.
case v_char+v_count(1).
when '0' or '1' or '2' or
'3' or '4' or '5' or
'6' or '7' or '8' or '9'.
v_total = v_total + 1.
when others.
endcase.
v_count = v_count + 1.
enddo.
endif.
if v_total > 0.
write:/5 'Invalid entry'.
else.
write:/5 'Valid entry'.
endif.
2007 Oct 01 8:52 AM
Hi,
SY-ABCDE contains alphabets with capital letters. So, string myst be in capital letters only.
Try with this code:
data: v_string(15) type c value 'APPLEBANANA2006'.
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
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |