cancel
Showing results for 
Search instead for 
Did you mean: 

Checking Mandatory fields displaying messages of our choice

Former Member
0 Kudos

Hello experts,

I have a view in which i have around 10 mandatory fields.

Now when i press the save button the validation should take place checking whether all the fields are filled or not.

I have tried doing this with this piece of code,...

data:

lo_view_controller type ref to if_wd_view_controller,

lo_dyn type ref to cl_wd_dynamic_tool.

  • Create Object

create object lo_dyn.

data lt_messages type lo_dyn->t_check_result_message_tab.

  • Get view controller reference

lo_view_controller = wd_this->wd_get_api( ).

  • Call Method to verify the element has the value or not

call method cl_wd_dynamic_tool=>check_mandatory_attr_on_view

exporting

view_controller = lo_view_controller

display_messages = ABAP_TRUE

importing

messages = lt_messages .

But with this code all the messages that are being displayed in the message area are alike.(i.e Fill in all the required fields.)

Where as i need a seperate message for every field.

So i tried doing with this code below and i am able to set a seperate message for each field...

FIELD-SYMBOLS: <LV_MSG> TYPE CSEQUENCE.

And the implementation methodology for this method is:

ASSIGN 'Entered date is invalid' TO <LV_MSG>.

  • get message manager

DATA lo_api_controller TYPE REF TO if_wd_controller.

DATA lo_message_manager TYPE REF TO if_wd_message_manager.

lo_api_controller ?= wd_this->wd_get_api( ).

CALL METHOD lo_api_controller->get_message_manager

RECEIVING

message_manager = lo_message_manager.

CALL METHOD lo_message_manager->report_attribute_error_message

EXPORTING

message_text = <LV_MSG>

element = LO_EL_<ELEMENT> --> THIS IS YOUR CONTEXT ELEMENT.

attribute_name = 'DATE'.

However i need to read each attribute every time to meet my requirement...

Is there a possibility to display message of our choice using the 1st method..

Please tell me how....

Thanks In advance,

Shravan

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Shravan,

I think have you already define STATE property of input field to 'REQUIRED' right?? so no need to write any code for this,

if value is not entered you will get error message.

If you want to dsiplay your own message first change STATE property to NORMAL and wirte code. i think you already written this code. use that code.

same related issue.. check this..

Cheers,

Kris.

Former Member
0 Kudos

Hi Kris,

Thanks for your reply.

My actual problem is that i want the input fields label to be marked as RED.

And later "check_mandatory_attr_on_view" should be done.

when this is done the same message is displayed number of times.

i want to display the same number of messages of my own choice.

for ex if i have a field First Name which is mandatory and i didn fill it then the message bieng displayed is "fill in all the required fields."

What i want is to display a message "Fill in the First name" and the field to be marked RED.

Regards,

Shravan

Former Member
0 Kudos

Hi,

Take another textveiw and place it after label of input field and give '*' in text property of this textveiw.

and in scemantic color property change it to negative( i think it is red color if not check others ). you will get red mark.

Hope it solves.

Cheers,

Kris.