Skip to Content
Author's profile photo Kiran Kumar Valluru

Dynamically Create/Modify UI elements of Standard components without Enhancing

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.

/wp-content/uploads/2014/10/1_566500.jpg

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

/wp-content/uploads/2014/10/4_566501.jpg

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):

/wp-content/uploads/2014/10/2_566502.jpg

/wp-content/uploads/2014/10/3_566503.jpg

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

/wp-content/uploads/2014/10/5_566504.jpg

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

/wp-content/uploads/2014/10/6_566505.jpg

Implementation

Go to SE18 transaction and open the BAdI.

/wp-content/uploads/2014/10/7_566506.jpg

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

/wp-content/uploads/2014/10/8_566507.jpg

Enter the Enhancement Implementation and description and click on Ok.

/wp-content/uploads/2014/10/9_566508.jpg

Enter the BAdI implementation name, description and Implementation Class.

/wp-content/uploads/2014/10/10_566509.jpg

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

/wp-content/uploads/2014/10/13_566510.jpg

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

/wp-content/uploads/2014/10/11_566511.jpg

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_visiblenone ).

*     Hide Depart.City Input

       lr_ui_elem ?= view->get_element( ‘CITYFROM_INPUTFIELD_1_CP’ ).

       lr_ui_elem->set_visible( cl_wd_uielement=>e_visiblenone ).

     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!.

/wp-content/uploads/2014/10/14_566513.jpg

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).

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi,

      Very useful info. Thanks for sharing!

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal

      Good one Kiran, Thanks..

      Author's profile photo Pasumpon Karuppaiah
      Pasumpon Karuppaiah

      Nice Document Kiran...

      Author's profile photo Former Member
      Former Member

      Hi Kiran,

      Thanks for the wonderful blog.

      Thanks

      KH

      Author's profile photo Former Member
      Former Member

      Hi Kiran,

      Excellent blog.

      Cheers

      Bhanu

      Author's profile photo Former Member
      Former Member

      Hi Kiran,

      Very helpful document .

      Thanks for writing.

      Author's profile photo Johannes Konings
      Johannes Konings

      Hi Kiran,

      thank you for this blog.

      I have used the BAdI WD_BADI_DOMODIFYVIEW to initialize the Canvas Manager for all views. (NWBC and Sidepanel: Initialize the Canvas Manager for all WebDynpro views)

      Author's profile photo Sarmath Syed
      Sarmath Syed

      HI,

              I added on custom field in SRM (RFX Leve) and assigned DDIC field for search help, my custom field getting displayed with F4 help in editable mode but my req is i want to change that F4 help into read only mode so that user can select from F4 help only. Please help me how to solve this.

      Author's profile photo Manoj Mohanty
      Manoj Mohanty

      Very useful. Thanks for sharing.

      Author's profile photo Francisco Curvelo
      Francisco Curvelo

      Hello everyone.

      I hope someone can help me. I need to change the label of an item in the output table. And add a column to the body of the alv. In the image it is possible to change the CLIENT label for another text. I already implemented this Badi but I have not achieved the result.

      If someone can tell me something specific in the code that is in the Exit table in the ALV I would appreciate it.

       

       

       

      Author's profile photo Chris Wake
      Chris Wake

      Thanks for sharing