cancel
Showing results for 
Search instead for 
Did you mean: 

Validations on input fields

Former Member
0 Kudos

Hi All,

I have a scenario where in I have around 10 input fields and a button named SEARCH in a view. Upon clicking on search button, based on that filled values Iam writing a select statement .

Now I would like to validate the values in that fields before putting them in select statement.

In the method WDBEFOREACTION Iam trying to validate them and I could display the error message.So, whenever I press on Button SEARCH if the values in input fields are not correct error messages are getting displayed but what ever code I have in SEARCH button is also getting executed. But when there is an error i dont want that code getting executed.

Is there any standard functionlity wherein I use in this case or I have to handle maually?

Please Suggest.

Thank You,

Suresh.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Which method of the message manager are you using to report errors? If you use report_exception, I think the search will not get executed. It is like raising an exception.

Regards,

Nithya

Former Member
0 Kudos

Hi Nithya,

I tried that. Its still going in.

Former Member
0 Kudos

Hi Suresh,

Check this , see Regina's reply. This will work for you too. You should report the error message on an attribute that is bound to your input field.

Regards

Nithya

Former Member
0 Kudos

Thanks a lot Nithya.

Its working.

Suresh

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Nithya,

In that thread she said "Check the values in WDDOBEFOREACTION. In this method you can check the name of the action, if it is an action of the same view. Maybe you want to skip testing, if the user pressed the CANCEL button or something similar."

How exactly you check the action. In my case I have a clear button where in I dont want to perform any validations.

Please Suggest.

Former Member
0 Kudos

Use the following code to get the name of the action which has been triggered.

data: lr_view_ctrl type ref to if_wd_view_controller,

lv_action type ref to if_wd_action.

lr_view_ctrl = wd_this->wd_get_api( ).

lv_action = lr_view_ctrl->get_current_action( ).

lv_action->name is the name of the action.

You could then check if lv_action->name = 'CLEAR'.

Regards,

Nithya

Former Member
0 Kudos

Thank You Nithya.

--Suresh

Madhu2004
Active Contributor
0 Kudos

Suresh,

I have handled one that scenario in the following way:

[1].created a method to check and validate the input fields

[2].created a method report error , and called the same method whenevr ab error is reported.

[3}.declared the message manager globally in component controller and calling the methods wherever necessary.

[4].written a method to check if any errors reported, source code as follows:

DATA:l_error_list_empty TYPE abap_bool.

*Check if any errors are reported

CALL METHOD wd_comp_controller-><u><b>l_message_manager->is_empty</b></u>

RECEIVING

empty = l_error_list_empty.

IF l_error_list_empty EQ abap_true.

errors_reported = abap_false.

ELSE.

errors_reported = abap_true.

ENDIF.

errors_returned is a returning parametr of type boolean.

[5].created a mthod to do the search

[6]. on action search, do the following code:

DATA: errors_reported TYPE abap_bool.

*Checking the input fields

wd_this->check_input( ).

errors_reported = wd_this->check_errors_reported( ).

*If no errors are reported call the method to get the statements

IF errors_reported EQ abap_false.

wd_comp_controller->get_statement( ).

*else clear the list which was populated earlier

ELSE.

wd_comp_controller->clear_alv( ).

ENDIF.

it worked for me.

cheers,

Madhu

mohammed_anzys
Contributor
0 Kudos

Hi

In your action , use a local flag MCHECK of type xfeld. First check whether the fields are valid , if yes ..then set the flag as 'X' else space.And in your search functionality execute the code only when the flag is 'X'.

Thanks

Anzy

Former Member
0 Kudos

Hi,

You could also validate your input fields in the search event method. Report an error message if the validation fails and return from the method.This would solve your problem.

Regards,

Shruthi R