on 07-22-2007 6:36 AM
Hello All,
in my WD application, i have few input fields , now on click of button i want to validate input fields so that no blank value can be passed.
1) Postal code : this should be 5 digit ( if someone enter more or less then 5 digit
it will not take )
2) Time Zone : (no blank value can be passed ).
3) Valid to & Valid from date : Valid to date greater then equal to Valid from date .
Could anyone plz let me know how to create error message for this ?
I assume the postcode was type char ?
But you wan to check for Integer.
A simple check in ABAP
if postcode co '0123456789'.
"all INT as expected
else.
" message please enter a valid post code
endif.
regards
Phil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can do all your validation in the wddobeforeaction method. To report messages, you need to first get the instance of the message manager. You can do that as follows:
data: lr_view type ref to if_wd_view_controller,
msg type ref to if_wd_message_manager.
lr_view = wd_this->wd_get_api( ).
msg = lr_view->get_message_manager( ).
When the user presses 'Save' or something, if you want the validations to happen, check if the current action is the action you want. You can do that as below:
data: lr_action type ref to if_wd_action.
lr_action = lr_view->get_current_action ( ).
Now, read the context attributes of the respective fields, and pass them to your validation APIs. If there is a error, report it using the report_attribute_error_message of the message manager. Check out if_wd_message_manager for various messages that are possible. If you report it on an attribute, the actual event handler for the action will not be called.
Hope this helps. Revert for any clarification.
Regards
Nithya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HiNithya ,
For length its working , but I want to check for integer or character type.
I cants change item_postal(user input field) to type INT as its already declared.
could you please send me the code , how to check whether given field is integer or charcter type ).
item_postal LIKE stru_maintain_address-postal. .
elem_maintain_address->get_attribute(
EXPORTING
name = `POSTAL`
IMPORTING
value = item_postal ).
IF strlen( item_postal ) < 5.
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 = 'POSTAL CODE INVALID '
Thanks for your time .
rahul
Hi,
You have to use the interface 'IF_WD_MESSAGE_MANAGER' to raise messages .
Check for the condition (in your case, if length of postal code > 5 digits),then call one of the methods form message manager interface. There are number of waus in which you can display messages to the user using this message manager interface.
For more details,
see this link
http://help.sap.com/saphelp_nw70/helpdata/en/6c/7aae42cd7fb611e10000000a155106/frameset.htm
Regards,
Sharadha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.