Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member184578
Active Contributor

Introduction

Generally, when we need to modify the properties of UI elements of standard component, we go to the corresponding component, Enhance the component and change the properties of the UI element in the Layout( by removing the element and adding our element) Or, create a pre/post-exit for WDDOMODIFYVIEW method and then change the properties through code.


Instead of enhancing the Standard component(sometimes, customers don't want to enhance the standard components, so..); we can use BAdI - WD_BADI_DOMODIFYVIEW


Here, I will just show a simple standard component and change the properties of UI elements without enhancing it.


Procedure

Let's take a simple Standard WDA component, say., displaying Flight List.

Let's say we need to restrict user not to enter the Depart.City or hide it.

For this, generally we go to the corresponding WDA component and enhance it and Remove the UI element or create a post-exit for WDDOMODIFYVIEW and hide the UI element via coding.

Now, here, without touching the standard component/enhancing the standard component, we will achieve this by just creating an implementation for BAdI - WD_BADI_DOMODIFYVIEW

** WD_BADI_DOMODIFYVIEW is a Filter dependent BAdI with filters COMPONENT_NAME and VIEW_NAME. We will create an implementation with filters values of the corresponding Component name and View Name.

Find the Component and View Name( by right click on the view -> Technical Help):

Find the ID of UI element: you can find it in the technical help -> view and View Elements tab:

Or, open the WDA component in SE80 and go to layout to find all the ID's of UI elements.

Implementation

Go to SE18 transaction and open the BAdI.

Check if already an implementation available for the corresponding component(in filter value), if not, create an Implementation by right clicking on the Implementations.

Enter the Enhancement Implementation and description and click on Ok.

Enter the BAdI implementation name, description and Implementation Class.

Now, Create the Filter combination for the BAdI implementation(which is the Standard Component name and View Name).

Note: If you don't create filter values, your implementation will be called for each Web Dynpro application( and may result in dump).

Finally, implement the method IF_WD_BADI_DOMODIFYVIEW~WDDOMODIFYVIEW of the BAdI implementation Class

Write your code in the method IF_WD_BADI_DOMODIFYVIEW~WDDOMODIFYVIEW of the implementation class.

if_wd_badi_domodifyview~wddomodifyview

METHOD if_wd_badi_domodifyview~wddomodifyview.

     DATA lr_ui_elem TYPE REF TO cl_wd_uielement.

     IF first_time = abap_true.

*     Hide Depart.City Label

       lr_ui_elem ?= view->get_element( 'CITYFROM_LABEL_1_CP' ).

       lr_ui_elem->set_visible( cl_wd_uielement=>e_visible-none ).

*     Hide Depart.City Input

       lr_ui_elem ?= view->get_element( 'CITYFROM_INPUTFIELD_1_CP' ).

       lr_ui_elem->set_visible( cl_wd_uielement=>e_visible-none ).

     ENDIF.

  ENDMETHOD.

Save and activate the BAdI Implementation and Class.

Result

Execute the application and we can see that the label and input of Depart.City is hidden!.

Conclusion

Here I demonstrated a simple use case. You can also assign/change value help to UI elements or change the label texts or enable or disable UI elements without enhancing the Standard component and just creating an implementation for the BAdI with the filter values.

You can also remove the UI elements or change the order/alignment of UI elements without enhancing the Standard component. For coding you can check this document for reference: Auto Align UI Elements Dynamically in Web Dynpro ABAP

Also, you can create multiple implementations with the same filter values.

Limitation

With this you can also create UI elements and assign Actions to the UI elements(for ex: Inputs/Buttons) but you need to create the corresponding On_Action method in the Component. This is just the alternative for dynamically manipulating the UI elements instead of enhancing and creating Exit for the WDDOMODIFYVIEW of the standard component(s).

11 Comments
Labels in this area