cancel
Showing results for 
Search instead for 
Did you mean: 

dropdown validation

Former Member
0 Kudos

I have a drop down , i have to validate it as user must select one value from it. I can not highlight it and even if user selects one value it still shows error. Does any one ever validated a drop down. Please help me.

Accepted Solutions (0)

Answers (3)

Answers (3)

S-H
Active Participant
0 Kudos

Hi,

Do you want to check if the user has selected one of the value in the dropdown the n write the code in the Button click where are leaving the view like Ok button. On button action write logic to validate the input. If user has not selected the value then raise message.

if the user selects the value and still the message appears may be because of no client side event has triggered. i mean if any client side event triggers then page refreshes and previous message disappears. If you do not want any message when the user selects any value then write an event handler method for the dropdown.

Best regards,

Suresh

Former Member
0 Kudos

i checked that. But as i am thinking this might be problem , as the cardinality for dropdown node is n ,thus it may trying to validate all. i am not sure with that it my guess.

Former Member
0 Kudos

Hi,

if you use

call method cl_wd_dynamic_tool=>check_mandatory_attr_on_view

exporting

view_controller = wd_this->m_view

  • display_messages = ABAP_TRUE

importing

messages = lt_messages.

and you created m_view in your view attributes

plus filled it in wdmodifyview,

it doesn't matter where your dropdown is, or what the context is,

it points to the missing input (little flaw of the function is that invisible mandatory elements will return error)

grtz,

Koen

Former Member
0 Kudos

what will be type of m-view, where should i declear it ? view attribute or in component controller ? what should i fill in domodify view ?

Former Member
0 Kudos

Hi,

have you checked your previous ?

grtz;

Koen

Former Member
0 Kudos

how do you validate it?

Former Member
0 Kudos

i have tried

data: l_node type ref to if_wd_context_node,

l_check_pars type Wd_This->Element_Exit_Type,

l_attr_list type CL_WD_DYNAMIC_TOOL=>t_check_mandattr_tab,

l_attr type CL_WD_DYNAMIC_TOOL=>t_check_mandattr_struct,

l_has_errors type wdy_boolean.

l_attr-node_path = s .

l_attr-attribute_name = 'EXIT_TYP'.

append l_attr to l_attr_list.

l_has_errors = cl_wd_dynamic_tool=>check_mandatory_attributes(

attribute_list = l_attr_list

display_messages = abap_true

context_root = wd_context

).

<u>and</u>

DATA: LV_TEXT TYPE STRING,

LV_TEXT_TOL TYPE STRING.

DATA: LT_PARAMS TYPE WDR_NAME_VALUE_LIST,

LS_PARAM LIKE LINE OF LT_PARAMS.

**get reference to the component contlr API

l_current_controller = wd_this->wd_get_api( ) .

*

**get reference of message manager

*

CALL METHOD l_current_controller->GET_MESSAGE_MANAGER

RECEIVING

MESSAGE_MANAGER = l_message_manager.

IF item_exit_typ IS INITIAL.

LV_TEXT = WD_ASSIST->IF_WD_COMPONENT_ASSISTANCE~GET_TEXT( KEY = '001') .

  • report message

CALL METHOD L_MESSAGE_MANAGER->REPORT_ATTRIBUTE_ERROR_MESSAGE

EXPORTING

MESSAGE_TEXT = LV_TEXT

ELEMENT = Elem_Exit_Type

ATTRIBUTE_NAME = 'EXIT_TYP'.

LS_PARAM-NAME = '1'.

LS_PARAM-VALUE = item_exit_typ.

APPEND LS_PARAM TO LT_PARAMS.

iserror = iserror + 1 .

ENDIF.

but both this went all in vain.