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 Pattern Comparison

muhammad_sohail
Participant
0 Likes
585

Dear Experts,

I want to compare my input string with the pattern as:

Input String = 'ABCD-100'.

I want to compare before -(dash) entered string should only contains character(s) (e.g; A, b, D, C etc.); not the numbers.

how should I do it.

Regards,

Sohail

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
550

hi,


PARAMETERS p_date(20)." 
DATA : lv_po TYPE sy-fdpos,
       l_date(10).

IF p_date CA '-'. "check the - sybol is there or not

lv_po = sy-fdpos. "get the position

l_date = p_date(lv_po).

IF l_date CA '123456789'. " any numbers is there or not
MESSAGE 'error' TYPE 'E'.
else.
  MESSAGE 'Sucess' TYPE 'S'.
ENDIF.

ENDIF.

Regards,

Dhina..

3 REPLIES 3
Read only

sridhar_meesala
Active Contributor
0 Likes
550

Hi,

Split the string at '-' into two variables and then check the first variable if it contains any alphabets.

Thanks,

Sri.

Read only

Former Member
0 Likes
551

hi,


PARAMETERS p_date(20)." 
DATA : lv_po TYPE sy-fdpos,
       l_date(10).

IF p_date CA '-'. "check the - sybol is there or not

lv_po = sy-fdpos. "get the position

l_date = p_date(lv_po).

IF l_date CA '123456789'. " any numbers is there or not
MESSAGE 'error' TYPE 'E'.
else.
  MESSAGE 'Sucess' TYPE 'S'.
ENDIF.

ENDIF.

Regards,

Dhina..

Read only

Former Member
0 Likes
550

Try this...

data str type string value 'AB2D-100'.

data: str1 type string,

str2 type string.

split str at '-' into str1 str2.

if str1 na '0123456789'.

write: 'Not containing Numbers'.

else.

write: 'Contain Numbers'.

endif.