on 03-17-2008 10:02 PM
Hi Experts,
I would like to know how to do Input field validation in WD4A.
I'm having a field in my iView which should accept only number and if user enters other than number it should validate and give message to end-user.
How to do it???
Responses are appreciated and rewarded.
Thanks,
Suba
Hi Suba,
First the read the attribute[User entered input]. Then using CO statement for validation.
Check this code.
Consider input is the attribute name and it contains user entered input. Then,
If Input CO '0123456789'.
"write tour coding.
else.
* get message manager
DATA: l_current_controller TYPE REF TO if_wd_controller,
l_message_manager TYPE REF TO if_wd_message_manager.
l_current_controller ?= wd_this->wd_get_api( ).
CALL METHOD l_current_controller->get_message_manager
RECEIVING
message_manager = l_message_manager
.
* report message
CALL METHOD l_message_manager->report_error_message
EXPORTING
message_text = 'Please Enter Numeric value'.
endif.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Viji,
ur response helped me a lot.
I do have another couple of question.
1.Can we display the error message at the bottom of the page. By default error message is displayed at the top.
2.Can u help me in giving code sample for report_attribute_error_message
Looking forward to reward u.
Thanks,
Suba
Hi Suba,
Yes defaultly all messages will displays at the top of the page. If you want to put the message at the bottom means you can use the UI element "Message area".
You can put the message area where ever you want. Then write the code for generating message.
Then it will display at where you fixed your message area.
Check the below code for report_attribute_error_message.
Write this code under your condition.
Before write this code ensure that the Context node should contains the data. Otherwise it will raise the error.
* get message manager
DATA: l_current_controller TYPE REF TO if_wd_controller,
l_message_manager TYPE REF TO if_wd_message_manager.
l_current_controller ?= wd_this->wd_get_api( ).
CALL METHOD l_current_controller->get_message_manager
RECEIVING
message_manager = l_message_manager
.
* report message
CALL METHOD l_message_manager->report_attribute_error_message
EXPORTING
message_text = 'error'
element = elem_node1
attribute_name = 'CARD_NO'.
Thanks.
Any issues let me know.
Hi,
for displaying the error message, first simply insert an UI element called MessageArea at the bottom.
code:
if <<check ur input field here(condition)>>.
"get message manager
data lo_api_controller type ref to if_wd_controller.
data lo_message_manager type ref to if_wd_message_manager.
lo_api_controller ?= wd_This->Wd_Get_Api( ).
CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER
RECEIVING
MESSAGE_MANAGER = lo_message_manager.
"report message
CALL METHOD lo_message_manager->RAISE_ERROR_MESSAGE
EXPORTING
MESSAGE_TEXT = '<ERROR TEXT GOES HERE>'.
PARAMS =
MSG_USER_DATA = .
endif.
Hi Suba,
For Message area UI element there is no need for any code.
Just place the message area at the bottom of the page and then write the code for message.
When ever message is present at your view it will be displayed at the message area.
For more information about message area you can refer the standard application WDR_TEST_EVENTS --> Message area view.
Thanks.
Hi Suba,
If the field on the View is defined as an integer (Type I) Or NUMC (Numeric Chars), SAP checks for entries other than Numeric values and throws a messaga ' The Entered Value Can Only Contain Numerical Characters'
Regards,
Sravan Varagani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.