cancel
Showing results for 
Search instead for 
Did you mean: 

how to validate all input fields ?

Former Member
0 Kudos

Hi, I have a requirement to validate all input fields.. if they are empty i have to show error ?

i hav tried with :

1) Mandatory field check using check mandatory fields method but using this method im getting more messages based on no of fields empty..

2) Report messages but i dont know how to validate multiple input fields at a time ..

pls help me..

Accepted Solutions (1)

Accepted Solutions (1)

chengalarayulu
Active Contributor
0 Kudos

Lokesh you can check the below documents.

http://scn.sap.com/docs/DOC-25768 - This will satisfy your requirement.

http://scn.sap.com/docs/DOC-25932

Answers (3)

Answers (3)

Former Member
0 Kudos

To display messages,

Get the WD message manager of type IF_WD_MESSAGE_MANAGER.

This interface provides various methods to display messages.

Former Member
0 Kudos

hi sachdeva.. i hav used the same way.. it is validating mandatory fields but the thing is im getting same message multiple times as same as no of mandatory fields empty...

i want to display only one message..


Former Member
0 Kudos

In this case, you can just check if you get any error messages.

While caling the method CHECK_MANDATORY_ATTR_ON_VIEW, mark the parameter DISPLAY_MESSAGES as ABAP_FALSE. This should stop messages from being displayed.

Parameter MESSAGES should give you all error messages.

And then If there are error messages, you can display your own message something like

'Fill all required fields'.

Former Member
0 Kudos

hi i tried with this one also but by keeping abap_false it stop showing messages but i dont want to go further action from dobefore method  to another  ...

but i t is validating at the same time it is moving to another method..

Former Member
0 Kudos

Once you find errors in the MESSAGES, it is upon you how you hanlde it.

You can put EXIT or RETURN statements from further processing.

Or

You can mark a flag and check this flag in other methods. If the flag is set, then simply return. Else follow the logic.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Declare in component controller attribute a variable called flag and then update the value to 'X' when you find error. Proceed the action in other methods only if the flag is initial.

Make sure that you clear the flag in proper place(may be in WDDOINIT).

Former Member
0 Kudos

hi can u give me a saple code for using flag in WDDOINIT ? ?

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Declare the attribute in component controller/view.

Clear the flag attribute clear wd_this->flag in wddoinit.

And then whenever you find the error pass the value wd_this->flag = 'X'.

Do further processing only if flag is initial.

Former Member
0 Kudos

Hi Lowkeshwar,

If all the fields are 'Mandatory' to be filled, you can follow the steps:

1. For the input fields, mark the property 'State' as 'Required'. This will give an asterisk to the input field.

2. To validate all fields that are marked as required in Step 1, you can use method CHECK_MANDATORY_ATTR_ON_VIEW of class CL_WD_DYNAMIC_TOOL. This method automatically checks for all input fields that have property 'State' set as 'Required' and gives errors for the input fields that are not filled.

You can get the errors from the method above and display them.

Former Member
0 Kudos

Hi Lokeshwar,

U can try by two ways:

1.

read all the input field values if anyone of them is empty Set a flag as "X".

Then while using throwing Error messages check whether this flag is set If yes then display error message.

2. clear all the messages using message manager ( Clear_message ) then set your own message.

Thanks and regards,

Nsingh