Tuesday, 11 June 2013

62.ENHANCING STANDARD UI COMPONENT



It is very important to know how to enhance a component.  It is rare to create a new UI component. Most of the times, we need to change the existing SAP standard component according to our adjustment. 

So we need enhance the existing components to tailor it as we wanted. This is very important feature of any software. Because it is impossible to create a software to cover all business scenarios. When we enhancement a component, we will create one new bsp application in the customer name space, which reuses the standard application. Whatever the changes we do, are part of this new bsp application and sap standard component is untouched. Later if we want to delete the enhancement, the new bsp application will be deleted without creating any problem to standard component. 

Sap has provided a container to store all changes to a component while enhancing. This container is called enhancement set. There may be more than one enhancement set available in the system. However, only one enhancement set should be active during runt time. So if we do any change to a UI component under one enhancement set, same changes reflected at runtime when we load same component under same enhancement set. 


Pressing F2 button on any field in the web ui will show a popup in which we can about active enhancement set in the system. 




Let us enhance one standard component. Go to the transaction BSP_WD_CMPWB and choose the component that you want to enhance. 






The highlighted button (1) is used to toggle enhancement set field. If you click it, enhancement field will be hidden and you can display the sap component as it is.  If enhancement set field is visible, then you should specify an existing enhancement set to display the component. 

Let us create the enhancement set. Click on the create button and give required details in the next dialog box.





Enhancement set is created and will be displayed in the enhancement set field.





Now click on display button.  We will receive below message at bottom of the screen if that particular component has not been enhanced under the provided enhancement set. 






Click on the enhance component button.




First it will ask for an enhancement set. Give the enhancement set that we created in the above step. 





Choose continue, then it will ask for new bsp application. Generally we give same component name with prefix Z. (we can choose any suitable name here). 







If application does not exist in the system, it will ask to create it or not. Choose yes.
In the next step, it will ask for Repository.xml page, just continue






After this step, if there is any application exists with the same name you have given, system will ask you to overwrite it. Don’t choose yes in these situations if you are not sure. Somebody might be created it under any other enhancement set. Choose no and it will take you back to the previous dialog box, just cancel it. Again click on enhance component and give new application name and continue.
 





Once every step is completed save the entries. We have successfully enhanced the component. If a component is enhanced and if we open that component under same enhancement set, you can see a button at top ‘delete enhancement ‘. This means that component has been enhanced. Now we can see the same button in our case.





We just enhanced the component. In order to change any view or window and even component controller, we need to enhance them as well. Generally if open a component under any enhancement set, all non-enhanced parts are greyed out. If you right click on them, you can see an option Enhance. 






Let us enhance the view as well. Right click on it and choose the option Enhance. System will automatically create new Z classes for view and context. If these classes already exist in the system, then it will ask user to choose correct name for classes.
Here in my case, it asking to change the view implementation class as it already there in the system. 






Just change the name if the dialog box appears and continue. I just added 1 to the name and saved the entries. Now I could see new generated classes for view and context. 






Here observe the class highlighted with red color. Still it is showing the standard class not z class. When we enhance only view and context classes will be enhanced not the context nodes. If we want to change the any context node, then we need to enhance them separately. Right click any context node and enhance it. 






Once we enhanced, the view name is in black color before it was greyed out. Observe the difference. Once enhanced, customer can carry on according to his requirements.

HOW MAKE USE OF NEWLY CREATED ENHANCEMENT SET IN RUN TIME?

Yes, we have created enhancement set and we enhanced our UI component under it. Now we need to do something to open the same component under our set on web ui. For this there is one special BADI COMPONENT_LOADING. We need to create one new implementation for this BADI and code inside the method       IF_BSP_WD_CMP_LOADING_BADI~GET_ACTIVE_ENHANCEMENT_SET.
Sample code look like below. 





 Whatever the enhancement set mentioned in above method , will be the active enhancement set.







9 comments:

  1. Images are not very clear while reading...

    ReplyDelete
  2. hi
    kindly let me know is there any change required in the images.we will change them.

    ReplyDelete
    Replies
    1. Hi Mannala,

      Please post something more in detail about the different objects like root object ,access object and dependent object and how they are related to each other by relationship..n How to find out the relationship between the entities??

      Delete
    2. hi
      Thanks for visiting us.
      we will try to post documents on above mentioned topics soon.

      Delete
  3. images are clear just click on them.

    ReplyDelete
  4. Hi

    1. Can we use one component set for more than one component to enhance?.
    2. Do we enhance component more than once in the real time?. we will manage which component set to be executed in the above mentioned Badi. Please confirm.

    ReplyDelete
  5. Hi mannala ur documents are very help full for me & others , so kindly send some more real time object to my mail id bhusan_kanungo@yahoo.co.in . no body is like u .
    u r fantastic . all documents are very good . my heartly wishes to u . god bless u .

    ReplyDelete
  6. Hi Mannala,
    Nice blog.. :)
    Please also post somthing about genil_bol_browser.how we create entity using this transaction and how can we edit and send changes to tables.

    ReplyDelete
  7. Hi Mannala,

    Can you please explain the webui architecture in detail?
    We all know that the data flow is bol->genil->API->Database.But when it comes to a real time scenario can you please explain which is bol class and what are Genil and API classes?
    It will be of great help to beginners in CRM.

    Regards

    ReplyDelete