‎2008 Sep 03 3:41 PM
I must restrict a field entry with letters from A-Z, a-z, 0-9, '-', '/' only.
if there is a charecter other than this, trigger a message and dont save the transaction.
I am doing all this in a exit.
how can i do this?
Thanks
Kiran
‎2008 Sep 03 3:54 PM
>
> I am doing all this in a exit.
> Kiran
Though You dont need to selection screen and start of selection logic.if you are already working in Exit.
than i think Naimesh's solution would definaltely work for you but only you need :
IF P_TEXT NA 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-/'."P_TEXT is your field on which you want put check
WRITE: 'Error'."transaction not save
ELSE.
WRITE: 'string is ok'."should be save
ENDIF.
‎2008 Sep 03 3:46 PM
Try something like this:
PARAMETERS: P_TEXT TYPE CHAR30 LOWER CASE.
START-OF-SELECTION.
IF P_TEXT NA 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-/'.
WRITE: 'Error'.
ELSE.
WRITE: 'string is ok'.
ENDIF.
Regards,
Naimesh Patel
‎2008 Sep 03 3:46 PM
Hi...
You wrote...
> dont save the transaction
Let me know this reuirement in which area...?
Is it screen programming?
Thanks,
Naveen.I
‎2008 Sep 03 3:49 PM
its in IE01.
am having a validation on the material serial number.
Is there any other way than to write such a big string from a to z twice??
Thanks
Kiran
‎2008 Sep 03 3:52 PM
If you are looking for special characters, you can use FM CHECK_STRING_SPEC_CHARACTERS
‎2008 Sep 03 3:54 PM
>
> I am doing all this in a exit.
> Kiran
Though You dont need to selection screen and start of selection logic.if you are already working in Exit.
than i think Naimesh's solution would definaltely work for you but only you need :
IF P_TEXT NA 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-/'."P_TEXT is your field on which you want put check
WRITE: 'Error'."transaction not save
ELSE.
WRITE: 'string is ok'."should be save
ENDIF.
‎2008 Sep 03 3:58 PM
I already did the same way as naimesh told:
Below is my code which is not working. I mean, message is not getting triggered when I entered Aa1-@ as SERNR value.
DATA: sernr TYPE equi-sernr.
MOVE data_equi-sernr TO sernr.
IF sernr NA 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-/'.
MESSAGE e001(00)
WITH 'Invalid Character in Serial Number.'
'Charaters from A-Z, a-z, 0-9 - / are only permitted'.
ENDIF.
Thanks
Kiran
‎2008 Sep 03 4:03 PM
Sorry. I used the wrong relational operator.
IF P_TEXT CN 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-/ '.
WRITE: 'Error'.
ELSE.
WRITE: 'string is ok'.
ENDIF.
Make sure, you include one SPACE at the last. Otherwise, it will give an error event if the input is " ABAP".
Regards,
Naimesh Patel
‎2008 Sep 03 4:04 PM
Sorry i used now wrong relational oprator.
Edited by: Amit Gujargoud on Sep 3, 2008 5:04 PM
‎2008 Sep 03 4:08 PM
Naimesh, That was wonderful about the space catch.
But can you please explain why so?
Also, I would like to know if I can allow user to allow to make his changes when he enters a invalid charater instead of stopping by error message.
Awarded Very help ful points for now.
Shall give you full points when i close this thread.
Thanks
Kiran
‎2008 Sep 03 4:14 PM
>
> Awarded Very help ful points for now.
> Shall give you full points when i close this thread.
> Thanks
> Kiran
Voilation of rules.
>
> Naimesh, That was wonderful about the space catch.
> But can you please explain why so?
> Also, I would like to know if I can allow user to allow to make > his changes when he enters a invalid charater instead of stopping by error message.
>
reason is already given by Naimesh.
Use information message instead of error message to allow the user.
‎2008 Sep 03 4:18 PM
Allowing User to re-enter the string will depend on the place where you give the Error message.
If you would find the Enhancment / BADI which is being triggered at the PAI level in CHAIN.. ENDCHAIN than you can use the Error message and still system will open the field for input. But, unfortunatly we don't have much enhancment or BADI of this kind.
If you are in ECC 6 than you can very well use the Enhancement Spot.
Regards,
Naimesh Patel