cancel
Showing results for 
Search instead for 
Did you mean: 

How to do Filed Validation in webdynpro ?

Former Member
0 Kudos

Hi Guys..

i created one webdynpro application ..

but its not validating..

HOw can i do field vaidation and screen validation ..?

observe the screen once in attachments..

My condition was:

1)When i pressed Search Button i want Error Message : Enter Matnr ..  like that...

Accepted Solutions (0)

Answers (4)

Answers (4)

amy_king
Active Contributor
0 Kudos

Hi K,

Field validation in Web Dynpro must be programmed by the developer, and this is usually done in hook method WDDOBEFOREACTION in the view. If the action being executed is Standard and an error message is issued during validation, process flow halts so the user can correct the error. If, on the other hand, the action is Validation-Independent, process flow continues even if an error message is issued.

Whether a field's value is valid or not must be checked manually according to the field's requirements. For checking whether all the view's required fields are filled or not can be done using one of two static methods in class CL_WD_DYNAMIC_TOOL...

  • CHECK_MANDATORY_ATTRIBUTES
  • CHECK_MANDATORY_ATTR_ON_VIEW

Mandatory fields are UI elements whose state property is set to required. Once you determine that an error message needs to be generated, you can use the code wizard to issue a message. Take a look at interface IF_WD_MESSAGE_MANAGER to see the methods available for generating a message. Messages issued via this interface will be displayed in the view's MESSAGEAREA.

Cheers,

Amy

Former Member
0 Kudos

On pressing of search button, check if the Attribute which is bind with  input field is initial.

then generate an error message using code wizard and in last of error message add exit statement.

Former Member
0 Kudos

Hi

You must have created a  method for the button on search in which you are fetching your data .

just before fetching the data , call the node:attribute that is binded to the field matnr and call its value there.If it is initial you can throw the error message.

data :

lo_api_controller     TYPE REF TO if_wd_controller.

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_error_message

       EXPORTING

         message_text = 'Please enter the value in Matnr field ' ..

Feel free to ask .Close the thread if it solves .

Regards

vaibhav Juneja


Former Member
0 Kudos

Add the below code in method 'WDDOBEFOREACTION' of your view.

   ****CHECK FOR MANDATORY FIELDS
  DATA LO_API_CONTROLLER TYPE REF TO IF_WD_VIEW_CONTROLLER.
  DATA LO_ACTION         TYPE REF TO IF_WD_ACTION.

  LO_API_CONTROLLER = WD_THIS->WD_GET_API( ).
  LO_ACTION = LO_API_CONTROLLER->GET_CURRENT_ACTION( ).

  IF LO_ACTION IS BOUND.
    CASE LO_ACTION->NAME.   
      WHEN 'ACT_ADD_SUCC'.     "Replace ACT_ADD_SUCC with the Name of Action attached with ur button
        CL_WD_DYNAMIC_TOOL=>CHECK_MANDATORY_ATTR_ON_VIEW(
          EXPORTING
            VIEW_CONTROLLER  = LO_API_CONTROLLER   " Web Dynpro: API of a View
*             DISPLAY_MESSAGES = ABAP_TRUE    " Replacement for Real Boolean Type: 'X' == True '' == False
*           IMPORTING
*             MESSAGES         =
        ).

    ENDCASE.
  ENDIF.