‎2015 Aug 15 6:22 PM
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?
‎2015 Aug 16 12:21 PM
Hi Imran,
Pls check the following two URLs, they will be helpful for you..!!
https://scn.sap.com/thread/688485p
Thanking You All..!!
‎2015 Aug 16 12:21 PM
Hi Imran,
Pls check the following two URLs, they will be helpful for you..!!
https://scn.sap.com/thread/688485p
Thanking You All..!!
‎2015 Aug 16 12:30 PM
‎2015 Aug 17 4:17 AM
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
‎2015 Aug 17 10:15 AM
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.
‎2015 Aug 17 2:28 PM
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..!!
‎2015 Aug 17 3:50 PM
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.
‎2015 Aug 17 5:21 PM
‎2015 Aug 17 5:21 PM