Friday, 24 May 2013

47.UNDERSTANDING VIEW GROUP CONTEXT



Before doing operations like edit, save and create operations, we need to know one concept called VIEW GROUP CONTEXT. 

When we are on overview page, certain times, we need to put all assignment blocks in edit mode and some times, only few or one assignment block should be edited.

Every implementation class of view has one attribute called VIEW_GROUP_CONTEXT which is type of IF_BSP_WD_VIEW_GROUP_CONTEXT.


At runtime view group context instance can be represented using the class CL_BSP_WD_VIEW_GROUP_CONTEXT.

Generally we create an instance of view group for top level controllers. Suppose if OP is an overview page, which is hosting three different assignment blocks A, B and C. Then we will set the property VIEW_GROUP_CONTEXT of OP implementation class. Remaining views A, B and C will automatically inherit its parent view group context. Here their parent is OP. 

We use SET_VIEW_GROUP_CONTEXT method to set the VIEW_GROUP_CONTEXT property. When setting this property, we always check whether its parent view group context is initial or not. If it is initial, then only we will create one instance of class CL_BSP_WD_VIEW_GROUP_CONTEXT and assign this instance to the VIEW GROUP CONTEXT property. Code will look like below. 




We can see that we are checking first parent view group context. If it is not initial, then we are assigning it to the current view viewgroupcontext property else we are creating new one. 

This class offers some methods to control the display mode of views. 

In order to set a view in editable mode, we use IF_BSP_WD_VIEW_GROUP_CONTEXT~SET_VIEW_EDITABLE method by sending the instance of view implementation class to it. 

In order to check, whether a view is in editable mode or not, we use IF_BSP_WD_VIEW_GROUP_CONTEXT~IS_VIEW_IN_DISPLAY_MODE method by sending the instance of view implementation class to it. 

To put all views in editable mode, we use IF_BSP_WD_VIEW_GROUP_CONTEXT~SET_ALL_EDITABLE ( ). This method will be used in top level controllers like OVERVIEW PAGES. 

To make any view which is in editable mode in to display mode, we use IF_BSP_WD_VIEW_GROUP_CONTEXT~RESET (). This method not only reset the current view group context but also reset the view group context of its children. 

Users who generally work on transactions may know that clicking on CANCEL button on top will put all views in to display mode at one go.

Whenever we use IF_BSP_WD_VIEW_GROUP_CONTEXT~SET_VIEW_EDITABLE method, it simply adds our view to one internal table. See the below code. 






Later when you use the method IF_BSP_WD_VIEW_GROUP_CONTEXT~IS_VIEW_IN_DISPLAY_MODE, it by sending instance of view controller, it simply checks whether this controller is there in the internal table or not. If it is there, then it will return false saying that it is not in display mode else it will return true. 







This flag will be given to the DISPLAY MODE property of major configuration tags. So finally based on this value returned by the above mentioned method, configuration tags will decide to make a view editable or not. You can find below code on major views .htm pages.
Like below. 





1 comment:

  1. Hi Mannala,

    Thanks for your effort to make us learn CRM in an easy way.

    I have an issue. I used the above mentioned steps for a component to switch between Edit and Display mode. But in this case, the input field's borders are missing in display mode, appearing in edit mode. Kindly advise.

    Thanks in Advance,
    Jeethu Susan John.

    ReplyDelete