Application Development 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: 

help regarding a program using string operations.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Imran,

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

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

Thanking You All..!!

Former Member
0 Kudos

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

arivazhagan_sivasamy
Active Contributor
0 Kudos

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

0 Kudos

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.

0 Kudos

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..!!

0 Kudos

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.

0 Kudos

Thanks Ankit.

It really helped and made it very simple.

0 Kudos

Thanks a lot fatih.