User-Defined Instance Methods SAP ABAP Web Dynpro

In the Methods tab, we can create our own user-defined methods with or without parameters. After creating a user-defined method, we can call it in the same controller, by using the wd_this self reference.

In this case, we copy our example from the wdDoModifyView Hook method and we create two extra user-defined methods:

  • A method named GREETING that has two import parameters
  • A method named PERFORM_VALLIDATION that has one import parameter

In the ONACTIONNEXT event handler method, we check whether the attribute NAME is initial, respective if the user didn’t enter his first name. In case of initial attribute, we call our own defined PERFORM_VALIDATION method. By using this method, we show an error message. In case this attribute is not empty, we call our own defined GREETING method to create a greeting for the end user.

The user-defined GREETING method. As we can see, this method has defined an importing parameter named P_NAME of STRING type and an importing parameter named P_NODE of ref to if_wd_context_node type. The P_NAME parameter holds the value of the NAME attribute.

Theuser-defined PERFORM_VALIDATION method. As we can see, this method has an importing parameter named P_ELEMENT, referable to the interface IF_WD_CONTEXT_ELEMENT.

In this case, we have used the method REPORT_ATTRIBUTE_ERROR_MESSAGE of the interface IF_WD_MESSAGE_MANAGER to report a Web Dynpro error message to a context attribute.

The ONACTIONNEXT event handler method.As we can see, the local variable lv_name holds the value of the NAME attribute. If this attribute is empty, we have to show an error message. To do this, we use our own defined PERFORM_VALIDATION method.

User-defined GREETING method

User-defined GREETING method

User-defined PERFORM_VALIDATION method

User-defined PERFORM_VALIDATION method

wd_this->perform_validation(EXPORTING p_element = lr_element).If this attribute is not initial, we use its value as exporting parameter for our own defined method GREETING.

The onactionnext event handler method



Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

SAP ABAP Web Dynpro Topics