Hi, I provide training in SAP UI5. Also feel free to checkout my new web page https://saptechblog.com
Webdynpro ABAP

Checking all the mandatory attributes of the view

 

When we are developing a form with the webdynpro ABAP, certain no of fields in the view may be marked as mandatory. Unlike core ABAP in Webdynpro ABAP we don’t have the mandatory field check. We need to read the data from the context node and check for its emptiness and throw an error message. If there are large number of fields on the screen which is mandatory that comes from different context node then reading the context node attributes and checking for its emptiness requires a lot code which makes the program code lengthier. Below is a piece of code which checks all the mandatory attributes in the screen.


Write the following code in the dobeforeaction method.

 

* Data declaration

  DATA: LT_MSG
TYPE CL_WD_DYNAMIC_TOOL=>T_CHECK_RESULT_MESSAGE_TAB, " Internal table:   Importing the message
        LO_VIEW_CONTROLLER
TYPE REF TO IF_WD_VIEW_CONTROLLER.                          " Object reference: View controller

* Getting the object reference of the view controller

  LO_VIEW_CONTROLLER ?= WD_THIS->WD_GET_API( ).

* Call the method check mandatory attributes to check the mandatory attributes in the view

  CL_WD_DYNAMIC_TOOL=>CHECK_MANDATORY_ATTR_ON_VIEW(
 
EXPORTING
  VIEW_CONTROLLER = LO_VIEW_CONTROLLER
  DISPLAY_MESSAGES = ABAP_TRUE
 
IMPORTING

  MESSAGES = LT_MSG ).

About Arun

0 Comments:

Post a Comment

Powered by Blogger.