Skip to Content
author's profile photo Former Member
Former Member

Mandatory check with WDR_SELECT_OPTIONS

Hi,

I have developed a WD application with 2 fields as a selection criteria(input) reusing WDR_SELECT_OPTIONS component.

I made them OBLIGATORY while calling the ADD_SELECTION_FIELDS method.

I have a button(DISPLAY) in the screen, which will take me to next screen upon clicking.

It should throw an error message if either of the mandatory fields are not filled.

I tried calling CHECK_MANDATORY_ATTRIBUTES and CHECK_MANDATORY_ATTR_ON_VIEW, but it didn't work for me.

My understanding is that, by putting wa_parameters-m_obligatory = abap_true. WD framework should throw an error message.

Please see the following code.

lr_range_table = wd_comp_controller->mo_sel->create_range_table( 'BUKRS' ).

wa_parameters-m_id = 'BUKRS'.

wa_parameters-m_within_block = 'SAPWD_MAIN_BLOCK'.

wa_parameters-m_description = 'Company Code'.

wa_parameters-mt_range_table = lr_range_table. " type ref to data,

wa_parameters-m_obligatory = abap_true.

wa_parameters-m_value_help_type = 'SEARCHHELP'.

wa_parameters-m_value_help_id = 'C_T001'.

wa_parameters-m_value_help_structure = ' '.

wa_parameters-m_value_help_structure_field = ' '.

wa_parameters-m_no_extension = abap_true. " type wdy_boolean,

wa_parameters-m_no_intervals = abap_true.

wa_parameters-m_tooltip = 'Company Code'.

wa_parameters-m_width = '10'.

APPEND wa_parameters TO lt_parameters.

CLEAR wa_parameters.

lr_range_table = wd_comp_controller->mo_sel->create_range_table( 'GJAHR' ).

wa_parameters-m_id = 'GJAHR'.

wa_parameters-m_within_block = 'SAPWD_MAIN_BLOCK'.

wa_parameters-m_description = 'Fiscal Year'.

wa_parameters-mt_range_table = lr_range_table. " type ref to data,

wa_parameters-m_obligatory = abap_true.

wa_parameters-m_no_extension = abap_true. " type wdy_boolean,

wa_parameters-m_no_intervals = abap_true.

wa_parameters-m_tooltip = 'Fiscal Year'.

wa_parameters-m_width = '4'.

APPEND wa_parameters TO lt_parameters.

CLEAR wa_parameters.

CALL METHOD wd_comp_controller->mo_sel->add_selection_fields

EXPORTING

it_fields = lt_parameters.

Please help.

Thanks,

Bharath.K

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 04, 2010 at 11:46 AM

    I had observed, system throws an error message for all the mandatory fileds when user put cursor in any of the field and press ENTER button.

    But i am expecting the same functionality when i am navigating to another screen(View) by pressing the Display button.

    Thomas, Can you please answer this question?

    Thanks.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 14, 2010 at 12:11 PM

    Hi Bharath,

    Try putting something like following code in Views WDDOBEFOREACTION,

    DATA lo_api_controller TYPE REF TO if_wd_view_controller.

    DATA lo_action TYPE REF TO if_wd_action.

    data: lv_year type REF TO apyear.

    lo_api_controller = wd_this->wd_get_api( ).

    lo_action = lo_api_controller->get_current_action( ).

    IF lo_action IS BOUND.

    CASE lo_action->name.

    WHEN 'SHOW'.

    lv_year ?= wd_this->m_handler->get_value_of_parameter_field( i_id = 'YEAR' ).

    ENDCASE.

    ENDIF.

    warm regards,

    Atul

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 15, 2011 at 02:48 AM

    Yes, the cl_wd_dynamic_tool=>check_mandatory_attr_on_view does not work as intended - not sure why. It may be something to do with the fact that the selection screen WDA is typically embedded in the Window therefore the mandatory check is only executed after the View is processed - maybe...?

    I used this alternative in the view method on click of a button on the View.

    data: lv_error type i.

    CALL METHOD wd_comp_controller->mo_sel->check_selection_screen

    IMPORTING

    e_num_error_msgs = lv_error_count.

    if lv_eror_count > 0.

    exit. "Do not proceed with the rest of the button event processing.

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.