on 03-26-2008 10:27 AM
Hi
how to find length of a string.. i have a requirement that user cannot add more than 9 digits in a string.. i am new to WD Abap..
Regards,
Puneet
Hi,
You can use STRLEN command for your requirement.
First read your input field using code wizard.
Then using STRLEN command you can find the length of the Input field.
For Example :
Here input is your input field.
data : length type i.
length = strlen(input).
If length < 9.
raise error msg.
endif.
Edited by: Viji on Mar 26, 2008 11:30 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Puneet,
1. Go to SE11 and create Data element with your specified length. Ex : ZTemp [ char length 10].
2. Then give the type of your attribute as ZTemp.
3. Set the length as 10 for the input field in Layout of your application.
So follow these procedure you can restrict user enteries at the input field.
Thanks.
If you do not want to restrict field length at data element level, validate the input field some action. eg if you have a button on the view, in the Event handler of the action bound to the button, read the current element's static attributes and give an error message if length of particular atrrib is greater than 10.
But this will not restrict the user from entering a longer string. It will only validate the length after user has entered it .. on some action.
Data Element length restriction is best suited to restrict user input.
Regards,
Reema
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.