on 01-23-2009 9:12 AM
I have a Requirement in which i have a person number (Inputfield is used) which Requires to be mandatorily entered by the user.
As i am new to webdynpro i want to know how can i make the Inputfield Mandatory.
Thanks in advance.
Regards,
Swapnil
Hi Swapnil,
You have a property by name STATE for the input field set it to REQUIRED. This marks the input field as an mandatory field to the system but in order for the checks to be triggered you need to do an additional thing.
You need to call the static method check_mandatory_attr_on_view of class cl_wd_dynamic_tool. This would then automatically verify if all the mandatory fields have been filled or not. It would then populate the error messages into an internal table and display them in the view. Also the mandatory fields which haven't been filled would be highlighted with a red border. You need to put the below coding into the action up on which you want to trigger the data checks.
data: lt_msg TYPE cl_wd_dynamic_tool=>t_check_result_message_tab,
lo_view_controller TYPE REF TO if_wd_view_controller,
lo_message_manager type ref to if_wd_message_manager.
lo_view_controller ?= wd_this->wd_get_api( ).
lo_message_manager = lo_view_controller->get_message_manager( ).
cl_wd_dynamic_tool=>check_mandatory_attr_on_view(
EXPORTING
view_controller = lo_view_controller
display_messages = abap_true
IMPORTING
messages = lt_msg ).
Regards,
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Swapnil,
Just by changing the field property as required you cannot make the field mandatory you need to make your own code level validations for validating the input field. Required property will only set a star * on the screen.
You can call the below static method:
cl_wd_dynamic_tool=>check_mandatory_attr_on_view
in the WDDOMODIFY view where the condition is:
check first_time = abap_false.
WDDOMODIFY view will be called when you press some button and then mandatory fields will be checked.
Try using this .
Regards,
Sana.
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 make field mandatory by changing the state of the filed.
The input field UI Element has a property called STATE which you need to change into "Required" from 'Normal Item'.
Now when you do this it makes that input field a mandatory field and will give you an error message in case if you leave that empty.
Regards
Madhu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
First try to bind the input UI field to the context attribute say example field u2018pernru2019 of type pa0001-pernr.
Set the attribute state of the UI as u2018Requiredu2019.
During the save or validate or final action on the screen add the following code.
data lo_nd_employee type ref to if_wd_context_node.
data lo_el_employee type ref to if_wd_context_element.
data ls_employee type wd_this->element_employee.
data lv_pernr like ls_employee-pernr.
navigate from <CONTEXT> to <EMPLOYEE> via lead selection
lo_nd_employee = wd_context->get_child_node( name = wd_this->wdctx_employee ).
get element via lead selection
lo_el_employee = lo_nd_employee->get_element( ).
get single attribute
lo_el_employee->get_attribute(
exporting
name = `PERNR`
importing
value = lv_pernr ).
*Check the input here
If lv_pernr is initial.
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->report_error_message
exporting
message_text = u2018Please input the personnel Numberu2019
Endif.
Thanks,
Rajkumar.S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear swapnil,
Please change the input field property STATE as required.
There is one property called STATE for the input field.By default it is in Normal item , change it to required.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Swapnil,
Check this wiki written by me.Here I explined how ti make mandatory fields in view.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
see the [documentation|http://help.sap.com/saphelp_nw70ehp1/helpdata/en/d7/ef8841e3af1609e10000000a155106/frameset.htm]
Regards, Heidi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.