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

Enhancing a View controller

 

Implementing an Enhancement in a view is nothing but the modifying the layout of the view or changing the properties of the existing UI elements. Take any standard component and if you go to the layout tab of any view you can see the list of UI elements available in those views and the way they are formatted in the layout. You cannot edit any of these and hence to modify you need an enhancement.

 

Is enhancing a Webdynpro component is a big deal? Does it require a lot of efforts? The answer is no, you just create an enhancement object and start doing whatever you want just like the way you work on with the component you created. All the modifications which you are doing will be recorded in the independent object developed for the Enhancement.

 

What kind of enhancement we can do in the view is as below.

1.      Creating a new UI element

2.      Suppressing existing UI element

3.      Add Actions, Inbound Plugs and Outbound Plugs.

 

Creating a UI element:

You can create new UI elements and the procedure is no different. You can simply insert a new UI element in the layout and process it as usual.

 

Suppressing Existing UI element:

We cannot remove the existing UI element from the hierarchy. Instead if we don’t want the UI element to be displayed we can suppress its visibility. Choose the UI element you want to hide, right click on the UI element and select remove UI element. The UI element will not disappear in the hierarchy instead in the property of the UI element a new line gets added with the following information.

 

clip_image002

 

The properties of the UI element before removing it from the hierarchy.

 

clip_image004

 

The properties of the UI element after removing it from the hierarchy.

 

clip_image006

 

clip_image008

 

 

Actions, Inbound and Outbound plugs:

 

For each view we can additionally create plugs and an action for the UI elements.

 

Now let us see an example program on how to enhance a view.

 

Let us take a standard component demotree and enhance it. The output of the component is as below.

 

clip_image010

 

Lets hide the subtype of petrol and add a button UI element create an action for it and on click on the button we will display a message that view has been enhanced.

 

Step 1: Go to the Tcode SE80 and Choose the component DEMOTREE.

 

clip_image012

 

Go to the layout tab of the view controller and click on the enhance button in the application tool bar to create the enhancement.

 

clip_image014

 

 

 

System will prompt for enhancement name and description. Enter the name and description for the enhancement and provide the name for composite enhancement framework and click on create. Else provide the name for composite enhancement and click on enter.

 

clip_image016

 

 

Enter the description for the composite enhancement framework and press enter.

 

clip_image018

 

 

After the composite enhancement implementation is created press enter again for the enhancement implementation for the Webdynpro component to be created. After creating the enhancement you can see the status of the view changed as below.

 

clip_image020

 

 

Now to remove the subtype, right click on the node of the tree UI element type and choose remove node element.

 

clip_image022

 

Once you have done that you will be now able to see the properties of the node type changed as below. However these elements do not disappears in the UI elements hierarchy as I explained above in the post.

 

clip_image024

 

 

 

 

 

Right click on the root UI element container and select insert element to add the button UI element.

 

clip_image026

 

 

Create an action for the button UI element.

 

clip_image028

 

 

In the event handler method for the button write the coding to display the message.

 

  

DATA LO_API_CONTROLLER     TYPE REF TO IF_WD_CONTROLLER.
DATA LO_MESSAGE_MANAGER    TYPE REF TO
IF_WD_MESSAGE_MANAGER.

LO_API_CONTROLLER ?= WD_THIS->WD_GET_API( ).


CALL METHOD
LO_API_CONTROLLER->GET_MESSAGE_MANAGER
  RECEIVING
    MESSAGE_MANAGER = LO_MESSAGE_MANAGER
    .


* report message

CALL METHOD LO_MESSAGE_MANAGER->REPORT_MESSAGE
 
EXPORTING

    MESSAGE_TEXT              =
'View Have been enhanced'

    .

 

Save and activate the component and test the application for output.

 

 

Output:

 

You can see the subtype for petrol and diesel now been hidden.

 

clip_image030

 

Click on display.

 

clip_image032

About Arun

2 Comments:

  1. How deactivate the enhancement explained by you.

    ReplyDelete
  2. How to deactivate the enhanced webdynpro application

    ReplyDelete

Powered by Blogger.