cancel
Showing results for 
Search instead for 
Did you mean: 

Mandatory check with WDR_SELECT_OPTIONS

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.