Friday, 24 May 2013


Before reading this tutorial, create one context node at overview page level with base entity BTAdminh and bind it to the context node(which has base entity BTAdminh) of custom controller. (Refer custom controller and data binding and CREATING CONTEXT NODE )

Go to the overview page implementation class and redefine the method SET_VIEW_GROUP_CONTEXT. Write following code and activate it. 

Let us add three buttons to the overview page to provide EDIT, SAVE and CANCEL operations. In order to add buttons to overview page, we need to add the code to the method IF_BSP_WD_TOOLBAR_CALLBACK~GET_BUTTONS of over view page implementation class.
Go the overview page in UI component and redefine the method by choosing the option redefine after right clicking on it. After redefining it, double click on it to open the method. 

Add the following code activate it. 

When you are adding a new button to standard SAP overview page, do not forget to call the super class method.
ON_CLICK: we will assign event handler name to this property. So when this button is clicked, event handler will be triggered. (event handler name is case sensitive ). 

TYPE : we can specify an icon over here. CL_THTMLB_UTIL has number of icons. 

PAGE_ID :  it is page id in framework language. It could be look like this. C1_W1_V1 where C1 is your component controller and W1 is window and V1 is your current view. 

Enabled : if this property is true, then button is enabled else disabled. 

It is a standard scenario that once you click on EDIT button, page will be in editable mode. In this mode only we will enable save ,cancel buttons and Edit button will be disabled.
When user clicks either SAVE or CANCEL, then again EDIT button will be enabled. SAVE and CANCEL buttons will be disabled. 

We are manipulating the ENABLED property of each button exactly in above mentioned way.
We will  discuss the scenario for EDIT button. 

Its clear that , to edit or save or cancel, there should be data. So we are reading the data from current context node into lr_header.

First conditions is LR_HEADER is BOUND, which means if there is data, second is LR_header->IS_CHANGE_ALLOWED which means, if data can be changed (why we are testing this condition because the same data may be locked by different user at this point of time) and last condition is VIEW_GROUP_CONTEXT->IS_ANY_VIEW_EDITABLE = ABAP_FALSE which means, no view is already in EDIT mode, then enable the EDIT button else disable it. 

You can try to understand the logic  for remaining buttons. 

Activate and test the application. 

We can notice all buttons are coming under group MORE. This is happened because we forgot to redefine one more method IF_BSP_WD_TOOLBAR_CALLBACK~GET_NUMBER_OF_VISIBLE_BUTTONS. This method controls the no of visible buttons on tool bar. Redefine it and give any integer value greater than 3.  If you give 4, then four buttons will be visible on tool bar and remaining buttons if exists any will be displayed as above.

Test the application. All your buttons should be visible.

No comments:

Post a Comment