on 02-17-2011 11:40 PM
Hi,
I am making 3 fields manditory dynamically based on condition..
button1 selection : field 1 and field 2 should be mandatory and field 3 not
button2 selection : field 1 and field 2 no mandatory and field 3 is mandatory.
When i am selecting both buttons...Mandatory field mark ( *) coming correct.
But when i am saving with save button...it is asking input value for field which is not mandatory...
There is no * symbol to that field also...but still it is asking input value.
If anybody know solution please provide me...
Thanks,
Subba
You should bind the inputfield to context attributes of type string and check if it is INITIAL OR NOT and then give the messages accordingly using the Message Manager.
For the Asterisk you should set the 'state' property accordingly.
Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So use the following code:
First get the value of the field by getting the value of the context attribute as:
DATA lo_nd TYPE REF TO if_wd_context_node.
DATA lo_el TYPE REF TO if_wd_context_element.
DATA ls_el TYPE wd_this->Element_<nodename>.
DATA lv TYPE wd_this->Element_<nodename>-<attribute-name>.
navigate from <CONTEXT> to <Node> via lead selection
lo_nd_n_upload = wd_context->get_child_node( name = wd_this->wdctx_<nodename>).
get single attribute
lo_el_n_upload->get_attribute(
EXPORTING
name = `<attribute-name>`
IMPORTING
value = lv ).
Then check if the value is blank, call the Message Manager:
if lv 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_ATTRIBUTE_EXCEPTION
EXPORTING
MESSAGE_OBJECT =
ELEMENT =
ATTRIBUTE_NAME =
MSG_USER_DATA =
MESSAGE_TYPE = CO_TYPE_ERROR
IS_PERMANENT = ABAP_FALSE
SCOPE_PERMANENT_MSG = CO_MSG_SCOPE_CTXT_ELEMENT
MSG_INDEX =
CANCEL_NAVIGATION =
IS_VALIDATION_INDEPENDENT = ABAP_FALSE
ENABLE_MESSAGE_NAVIGATION =
VIEW =
RECEIVING
MESSAGE_ID =
and send the message to display to the user.
Hope it helps
Instead of just making the field mandatory using the utility class write the logic in the eventhandler of the save button to check
if hte value has been entered or not.
the save button check for the values of the fields and if it is initial then throw the message.
>
> Hi Shikal,
>
> What are the parameters i need to pass this method..
>
> CALL METHOD lo_message_manager->REPORT_ATTRIBUTE_EXCEPTION
>
> Thanks,
> Subba
and use REPORT_ATTRIBUTE_ERROR_MESSAGE instead.
* report message
CALL METHOD lo_message_manager->REPORT_ATTRIBUTE_ERROR_MESSAGE
EXPORTING
MESSAGE_TEXT = 'ERROR MESSASGE ' " message text that you want to display to the user
ELEMENT = lo_el_n_upload " pass the context element which belongs to ur attribute
ATTRIBUTE_NAME = `<attribute-name>` "pass the attribute name here
.
thanks
sarbjeet singh
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
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.