Skip to Content

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

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

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

    (0) 

Leave a Reply