cancel
Showing results for 
Search instead for 
Did you mean: 

Validation in dropdown

Former Member
0 Kudos

Hi,

I have a dropdown by index. First value of it is blank. Now i have to validate that user must select one value from it. I have written this code but it is not working , also not marking the field with red.

Node_Exit_Type = Node_Z_Eth_Update_Separat->get_Child_Node( Name = wd_This->wdctx_Exit_Type ).

  • get element via lead selection

Elem_Exit_Type = Node_Exit_Type->get_Element( ).

IF Stru_Exit_Type-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 = Stru_Exit_Type-EXIT_TYP.

APPEND LS_PARAM TO LT_PARAMS.

iserror = iserror + 1 .

ENDIF.

can any one help?

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi, Prosun, thank you for your response.....

I prepare to delete the first null value and set the first non-null value as default lead selection and avoid validation check ......

Former Member
0 Kudos

Hi, Prosun,

Have you resolved this problem?

Right now I encountered the same problem in DropdownByIndex.If you have solved the problem, could you please give the answer to me in this forum or mail it to shaomingpeng@yahoo.com.cn?

I appreciate for your any advice...

Best Regards,

Eddy

Former Member
0 Kudos

sorry, the problem yet not solved.

Former Member
0 Kudos

Hi,

you can simply make the field required and then check on mandatory fields,

using the method cl_wd_dynamic_tool=>check_mandatory_attr_on_view

grtz,

Koen

Message was edited by:

Koen Labie

Former Member
0 Kudos

yes, i have made the field required.

Former Member
0 Kudos

Hi,

in the action handler to navigation or save functionalities,

begin with executing the function i mentioned, if the

result gives error, stop the rest and display message

grtz,

Koen

mohammed_anzys
Contributor
0 Kudos

Hi

Whats Stru_Exit_Type? it should be different right?

Thanks

Anzy

Former Member
0 Kudos

hi,

these is the complete code.

data:

Node_Exit_Type type ref to If_Wd_Context_Node,

Elem_Exit_Type type ref to If_Wd_Context_Element,

Stru_Exit_Type type Wd_This->Element_Exit_Type .

  • navigate from <Z_ETH_UPDATE_SEPARAT> to <EXIT_TYPE> via lead selection

Node_Exit_Type = Node_Z_Eth_Update_Separat->get_Child_Node( Name = wd_This->wdctx_Exit_Type ).

  • get element via lead selection

Elem_Exit_Type = Node_Exit_Type->get_Element( ).

IF Stru_Exit_Type-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 = Stru_Exit_Type-EXIT_TYP.

APPEND LS_PARAM TO LT_PARAMS.

iserror = iserror + 1 .

ENDIF.

Former Member
0 Kudos

Hi,

try this instead:

types:

begin of t_check_result_message,

t100_message type symsg,

context_element type ref to if_wd_context_element,

attribute_name type string,

end of t_check_result_message .

types:

t_check_result_message_tab type standard table of t_check_result_message .

data: lt_messages type t_check_result_message_tab,

lv_message type string,

ls_ieinfo type einfo.

field-symbols: <fs_attribute> type line of wdr_context_attr_info_map,

<fs_case_attributes> type bapiproptb,

<fs_message> type t_check_result_message.

not_complete = abap_false.

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.

if lt_messages is not initial.

loop at lt_messages assigning <fs_message>.

move-corresponding <fs_message>-t100_message to ls_ieinfo.

call function 'MESSAGE_GET_TEXT'

exporting

ieinfo = ls_ieinfo

ilangu = sy-langu

importing

etext = lv_message

exceptions

no_t100_found = 1

others = 2.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

else.

  • report message

call method wd_this->m_messages->report_attribute_error_message

exporting

message_text = lv_message

element = <fs_message>-context_element

attribute_name = <fs_message>-attribute_name.

endif.

endloop.

not_complete = abap_true.

exit.

endif.

grtz,

Koen

Former Member
0 Kudos

Hi,

please mark thread as answered when it solves your problem

grtz,

Koen

Former Member
0 Kudos

Hi Koen,

i tried with your code, what is m-view ? Is that my view name. I tried with that also i got activation errors. Can u please your code also? My problem not yet solved.