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

help regarding a program using string operations.

Former Member
0 Likes
1,135

i am a student and i have a question.I wrote a simple program

PARAMETERS PHONE(10) TYPE N.

AT SELECTION-SCREEN.

  IF

    PHONE CS SY-ABCDE.

    MESSAGE 'PLZ AVOID CHAR' TYPE 'E'.

  ELSE.

    MESSAGE 'VALID PHONE NO' TYPE 'I'.

ENDIF.

As special characters are also strings,so when i  input special characters it says valid phone no.

So how to write a program where it can restrict even the special characters?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,112

Hi Imran,

Pls check the following two URLs, they will be helpful for you..!!

https://scn.sap.com/thread/688485p

Thanking You All..!!

8 REPLIES 8
Read only

Former Member
0 Likes
1,113

Hi Imran,

Pls check the following two URLs, they will be helpful for you..!!

https://scn.sap.com/thread/688485p

Thanking You All..!!

Read only

Former Member
0 Likes
1,112

thanks a lot Ankit .I am gonna try using this.

Read only

arivazhagan_sivasamy
Active Contributor
0 Likes
1,112

Hi,

PARAMETERS PHONE(10) TYPE N.

You have declared as type N.

In this case you could not enter other than 0 to 9.

Regards,

Arivazhagan S

Read only

0 Likes
1,112

Hi Ankit,

you are right.But now i changed it char.Please check the program below.

PARAMETERS PHONE(10).

DATA SPEC_CHAR(50) TYPE C VALUE '`,~,!,@,#,$,%,^,&,*,(,),-,_,=,+,{,[,},]'.

AT SELECTION-SCREEN.

  IF

    PHONE CA SY-ABCDE.

    MESSAGE 'PLZ AVOID CHAR' TYPE 'E'.

    ENDIF.

  IF

    PHONE CA SPEC_CHAR.

    MESSAGE 'PLZ AVOID CHAR' TYPE 'E'.

  ELSE.

    MESSAGE 'VALID PHONE NO' TYPE 'I'.

ENDIF.

I would really appreciate if you can analyze and let me know if there is any other more efficient way of writing it.

Thanks.

Read only

0 Likes
1,112

Hi Imran,

You can use appropriate data types, may be constants for special character, see if there is any message class for the message you want to display.

Also use one If-Elseif block instead to two If blocks.

Thanking You All..!!

Read only

0 Likes
1,112

IF

    PHONE CA SY-ABCDE or PHONE CA SPEC_CHAR.

    MESSAGE 'PLZ AVOID CHAR' TYPE 'E'.

ELSE.     "I think no need if valid.

    MESSAGE 'VALID PHONE NO' TYPE 'S'.

ENDIF.

Read only

0 Likes
1,112

Thanks Ankit.

It really helped and made it very simple.

Read only

0 Likes
1,112

Thanks a lot fatih.