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 Problem

Former Member
0 Likes
889

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

7 REPLIES 7
Read only

Former Member
0 Likes
849

iHi,

IF var+0(5) CS sy-abcde.

...First 5 characters are alphabates.

ENDIF.

Regards,

Atish

Read only

amit_khare
Active Contributor
0 Likes
849

str1 = str2+0(5).

if str1 CS sy-abcd.

<do some thing>

endif.

Read only

abdulazeez12
Active Contributor
0 Likes
849

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

Read only

varma_narayana
Active Contributor
0 Likes
849

Hi...

Check this condition for alphabets in a String:

IF V_STR(5) CO SY-ABCDE.

ENDIF.

reward if Helpful.

Read only

Former Member
0 Likes
849

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

Read only

Former Member
0 Likes
849

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.

Read only

Former Member
0 Likes
849

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