Skip to Content
avatar image
Former Member

to display error message abap webdynpro


I need to display an error message when the field is not selected from the drop down list..when the default value - please select-- is there.. n not other value is selected...

I did some coding where in I am getting the message for the first time... when I press a button but when I press the button for the second time after selecting some value from the drop down box.. but when I am changing it again to -

please select----, its not giving me the error message....

any demo code will be very useful.

Thanks and Regards


Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Mar 09, 2009 at 11:08 AM

    Hi Tenzin,

    Regarding your problem, you can do like this.

    When you checking the dropdown value on an action that time you will read the selected value index and then check if index is equal to first 1 i.e. if user has selected the first record then you can raise an error message.

    For this try this logic given below :

    DATA lo_nd_dropdown1 TYPE REF TO if_wd_context_node.

    DATA lo_el_dropdown1 TYPE REF TO if_wd_context_element.

    DATA ls_dropdown1 TYPE wd_this->element_dropdown1.

    • navigate from <CONTEXT> to <DROPDOWN1> via lead selection

    lo_nd_dropdown1 = wd_context->get_child_node( name = wd_this->wdctx_dropdown1 ).

    • @TODO handle not set lead selection

    IF lo_nd_dropdown1 IS INITIAL.


    • get element via lead selection

    lo_el_dropdown1 = lo_nd_dropdown1->get_element( ).

    • @TODO handle not set lead selection

    IF lo_el_dropdown1 IS INITIAL.


    data : lv_index TYPE i.

    lv_index = lo_el_dropdown1->get_index( ).

    IF lv_index = 1.

    • report message


    message_text = 'Please select Airline Code'

    element = lo_el_dropdown1

    attribute_name = 'CARRID' ).


    Hopes this will helps you.


    Manoj Kumar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 09, 2009 at 11:11 AM

    if you are using DropDownByKey to you existing code, also add validation to event OnSelect. when new value is selected in the DropDown OnSelect event is raised. Check the value if it corresponds to the EMPTY value and Raise error using the IF_WD_MESSAGE_MANAGER .



    Add comment
    10|10000 characters needed characters exceeded

  • Mar 09, 2009 at 11:13 AM

    Hi Tenzin,

    Ideally the error message should get displayed for the second time as well.

    You should try this method as well:

    In the ONSELECT method of the drop down, just read the attribute with is binded to your drop drop.

    If lv_attribute eq 'please select'. "the default value
    call message manager to report the error.

    I hope it works.



    Edited by: Arjun Thakur on Mar 9, 2009 4:46 PM

    Add comment
    10|10000 characters needed characters exceeded