cancel
Showing results for 
Search instead for 
Did you mean: 

Mandatory fields validation in webdynpro abap

former_member210804
Active Participant
0 Kudos

Hi Experts,

I would like to validate mandatory fields.If we did not enter any data, fields should get highlited and should show appropriate message.

for example ,check the below screenshot.

Here batch or meterial or plant are mandatory fields. these field are highlighted and shown a message using

'cl_wd_dynamic_tool=>check_mandatory_attr_on_view'.  Highlited is fine. but i need an appropriate message as well.

How would i achive both functionalities (ie. highlighted and appropriate message)

Best regards,

Narasimha. 

Accepted Solutions (1)

Accepted Solutions (1)

Gowtham
Contributor
0 Kudos

Hi Narasimha,

You can use the concept of report attribute error message in order the display you own error message with highlighted fields.

please find the following code , pass the error message to message_text , pass the element name to element and pass the attribute name which needs to be highlighted too attribute , call this method if the particular field is empty.


IF ls_business_details-vc_name IS INITIAL.

       wd_this->message(

          attribute = 'VC_NAME'

          element = lo_el_business_details

          message_text = 'Fill data for Business Details' ).

        


Endif.


  METHOD message .

  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   = message_text

           element        = element

           attribute_name = attribute.

Endmethod.

- Gowtham

former_member210804
Active Participant
0 Kudos

THANK YOU GOWTHAM

Answers (0)