cancel
Showing results for 
Search instead for 
Did you mean: 

Error message in WDA?

former_member210804
Active Participant
0 Kudos

Hi Experts,

I am developing one webdynpro application . Where i need to display an error message

like 'Please enter the required fields' if the field value is initial.

please check the below image for more information.

Please give me the solution. In case of normal field ( Not required fields ) , how to achieve the same.

Best regards,

Narasimha.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello ,

You need to add a MessageArea UI element in the view , and according to your need you have do some coding on Action to put a message in the MessageArea , you can use the wizard for the purpose , see attached picture

Regards

former_member210804
Active Participant
0 Kudos

Hi ,

I have called the method check_madatory_attr_on_view. and the error message is repeating for all the attributes which are initial.

I want to display only one message

cl_wd_dynamic_tool=>check_mandatory_attr_on_view( view_controller = lr_api_main_view ).

Best regards,

Narasimha.

Former Member
0 Kudos

Ok , you could give space to the parameter DISPLAY_MESSAGES when calling the methode , then check the content of the importing parameter MESSAGES ( type T_CHECK_RESULT_MESSAGE_TAB ) if there is errors , just call you custom message by generating it into the a MessageArea  element positioned in the view

Regards

ramakrishnappa
Active Contributor
0 Kudos

Hi Narasimha,

Is your requirement is to display an error message for an attribute

Please use the method REPORT_ATTRIBUTE_ERROR_MESSAGE

Sample code:

  1.         CALL METHOD lo_message_manager->report_attribute_error_message 
  2.           EXPORTING 
  3.             message_text   = 'This field cannot be empty !!!' 
  4.             element        = lo_el 
  5.             attribute_name = 'CARRID'.  " Attribute Name 

Note: here lo_el - the context element of your attribute

Hope this helps you.

Regards,

Rama

former_member184578
Active Contributor
0 Kudos

Hi,

Instead of using check_mandatory_attr_on_view method, read the input values using get_attributes( ) method,

Then,

if lv_field1 is initial or lv_field2 is initial or lv_field3 is initial.

*Display message

lr_msg_manager->report_error_message(

                 message_text = 'Please enter all the fields!" ).

endif.

Regards,

Kiran

former_member210804
Active Participant
0 Kudos

Hi Experts,

@Kiran

If i do the same code, we can get the message but the error fields won't be highlighted.

@Ramakrishappa

If i do the same code, multiple error messages get triggered. But i want to display one error message with normal input fields.

Hope you understood what is my requirement.

Best regards,

Narasimha    

former_member184578
Active Contributor
0 Kudos

Hi Narasimha,

It is not possible to highlight all the fields and display one message.

A work around could be, create a messageArea UI and display the messages using report_attribute_error_message( to highlight the fields). Then set the maxVisibleMessages property of messageArea UI to 1. Then only 1 message will be visible ( with a scroll bar ).

Regards,

Kiran

former_member210804
Active Participant
0 Kudos

Hi Kiran ,

Still it is showing all the messages without scroll bar. Kindly do the needful.

I have written the code as below.and the message area with maxVisbleMessages = 1

IF ls_qtr_detail-number_of_rooms EQ 0.
* report message
       CALL METHOD lo_message_manager->report_attribute_error_message
         EXPORTING
           message_text   = 'Please enter Number of Rooms'
           element        = lo_el_qtr_detail
           attribute_name = 'NUMBER_OF_ROOMS'.
     ENDIF.
     IF ls_qtr_detail-quarter_area IS INITIAL.
* report message
       CALL METHOD lo_message_manager->report_attribute_error_message
         EXPORTING
           message_text   = 'Please Enter the Quarter Area'
           element        = lo_el_qtr_detail
           attribute_name = 'QUARTER_AREA'.
     ENDIF.
     IF ls_qms_det_map-constructiondate IS INITIAL.
* report message
       CALL METHOD lo_message_manager->report_attribute_error_message
         EXPORTING
           message_text   = 'Please Enter the Construction Date'
           element        = lo_el_qms_det_map
           attribute_name = 'CONSTRUCTIONDATE'.
     ENDIF.
     IF ls_qtr_detail-country IS INITIAL.
* report message
       CALL METHOD lo_message_manager->report_attribute_error_message
         EXPORTING
           message_text   = 'Please Enter Country'
           element        = lo_el_qtr_detail
           attribute_name = 'COUNTRY'.
     ENDIF.

Best regards,
Narasimha.

ramakrishnappa
Active Contributor
0 Kudos

Hi Narasimha,

Yes, It is possible to display single message and highlight all the attributes in the given context element.

If you dont pass the attribute name, it highlights all the attributes inside the context element.

    CALL METHOD lo_message_manager->report_attribute_error_message

         EXPORTING

           message_text   = 'Please fill all the fields'

           element        = lo_el_qtr_detail.


The above code, highlights all the fields inside the context element lo_el_qtr_detail.


Hope this helps you.


Regards,

Rama

Former Member
0 Kudos

if you are at an older version of SAP, then there you would find that it is not possible to change the maxvisiblemessages in the designer, only via code. Please refer to this code:

  data: lr_wd_message_area  type ref to if_wd_message_area,

        lr_view             type ref to if_wd_view_controller,

        lr_window           type ref to if_wd_window_controller.

* Set up message controller

  lr_view ?= wd_this->wd_get_api( ).

  lr_window = lr_view->GET_EMBEDDING_WINDOW_CTLR( ).

  lr_wd_message_area = lr_window->get_message_area( ).

  lr_wd_message_area->set_display_attributes(

    I_MSG_LINES_VISIBLE = 3

*    i_show_only_current = ' '

    i_for_all_instances = 'X'

*    i_use_toggle_area   = ' '

  ).

the code changes according to your use either in the window or in the view

former_member184578
Active Contributor
0 Kudos

Hi,

Yes. If you are on Lower versions, you have to do it programatically.

Regards,

Kiran

former_member210804
Active Participant
0 Kudos

Hi Experts ,

@Ramakrishappa

if do the same code, it will highlight for all the inputfields irrespective of value ( even if its not initial ).

Can u tell me how to achieve the same if the input fields are required property.

Best regards,

Narasimha

Former Member
0 Kudos

before you wanted to highlight also the fields that are not mandatory. Maybe you should sumarize your requirement first

ramakrishnappa
Active Contributor
0 Kudos

Hi Narasimha,

I have prepared a document which guides you through to accomplish your requirement.

Please check the below document:

Hope this helps you.

Regards,

Rama

former_member210804
Active Participant
0 Kudos

Thank you very much Ramakrishnappa..

could u please do the same for REQUIRED input fields. How can we achieve the same

Best regards,

Narasimha

ramakrishnappa
Active Contributor
0 Kudos

Hi Narasimha,

Please go through the below blog:

Hope this helps you.

Regards,

Rama

former_member210804
Active Participant
0 Kudos

Thank you Ramakrishnappa..

I have resolved the issue.

Thank you for the support JOZEF and KIRAN.


Best regards,

Narasimha.

Answers (0)