Friday, 24 May 2013

43.CREATING TABLE VIEW FOR LINE ITEMS WITH DEPENDENT CONTEXT NODES



We know that every service contract can have multiple line items. In order to display those items, Let us create one table view in our component.

Go to the component and create one new view.  Give any suitable name to the view.
In the step, ADD MODEL node, we will create dependent nodes. First create one context node with BTAdminh as base entity.  This will context node will act as a parent context node. Next click on CREATE button as highlighted in the screen shot. 






It will add one new row. Enter the context node name and choose BTItems as a base entity. We need this context node dependent on the HEADER context node. So click on the higher level model node. It will show ‘header’ context node. Choose it. 







Then we need to specify the relation between the base entity of higher level context node to the base entity of dependent context node.  Click on BOL relation and choose the value.


We need to add one more model node, which will be dependent on ITEMSET node. Click on create and in the new row give context node name and choose BTAdminI as base entity. To make it dependent on ITEMSET context node chooses entries as shown below. 



Here BTAdminI is dependent on BTItems and BTItems dependent on BTAdminH.  So if we are able to feed the data to BTAdminH. With help of relations, required data automatically flows to its child nodes. Just click on continue up to the step CREATE LINKS TO CUSTOM CONTROLLERS. 

Here we bind the HEADER context node in our table view to the HEADER context node of the custom controller. So that data will automatically flow. Choose the entries as shown below. 


In the step ‘SELECT VIEW TYPE’, choose the view type as table type. Here we need to specify which context node will act as a base for our table view. As we want to show line item details, specify the last context node and choose the option configurable check box. Complete the wizard. 




Why we have created three context nodes ?

The answer lies in the design we chose and the model on which we are working.
First we have created BTAdminH (header context node).  We need to feed data first to this one because it’s independent node in our hierarchy.  For this we have done the binding from this context node to the context node of custom controller while creating view itself. So feeding data to the top node is done. 

When we create dependent nodes with relations, framework will automatically add code to one method called ON NEW FOCUS of context node classes.  See the below screen shot. This method will be used to fetch the data for dependent nodes based on the data from their corresponding parents. 


Let us examine this .

Go to the context class *CTXT and find the method CREATE CONTEXT NODES.



Double click on it to see the code. This method will be used to create all three context nodes. 




As per the code, first CREATE_HEADER method will be triggered. Double click on it to see the code. 


We can see the method DO CONEXT NODE BINDING. As soon as header node is created then binding is done to the custom controller context node(This code is there because we bound it to the custom controller while creating view). So data will flow from the custom controller context node to this header context node. Data is feeding to the top node is done.

Next go back and double click on next method CREATE_ITEMSET.








Here, from 18 and to 21, they are reading record from header context node and at 25, they are calling the ON NEW FOCUS method of ITEM SET ( dependent of header ) by sending the record from the header context node.
Double click on NEW FOCUS to see the code.
 



Here you can see the relation that we have given while creating second context node. So data is read from the top node using the relation and feeding it to the context node collection.So data from top node is reached to its dependent. 

Go  back to the CRAETE CONTEXT NODEs method and double click on the last method. 




We can see now they are reading the record from the second context node ( the data feed to second context node is done in the on new focus of second context node class ) and again calling the on new focus method of third context node class by sending the second context node record ( parent of last context node ).
Double click on the on new focus again, you can notice that data is fetched from using method get related entities and relationship name is the relation that we mentioned while creating third context node.
So data to the last context node is done from the second context node. This is how dependent context nodes work.
First configure the by moving required fields from available fields section to the displaying section on configuration tab.


Go to the runtime repository add our view to the overview set and save the repository.


Now that view will be available in the overview set page configuration. Move it displayed assignment blocks section. (CREATING OVERVIEW PAGE). 











1 comment:

  1. Hi,
    A brilliant and much needed series of blogs in the end.
    I have a problem here .
    Followed all the steps mentioned, but getting exception in BIND_VIEW method at line number 116 as " View Zcomp/Viewname can not be loaded in Viewarea 0022. "
    Please note that this is I m doing in BT115H_SLSO.
    Although there is a standard page available for the required functionality but somehow even that page is not loading even after proper config settings for all value.
    The functionality required is of showing REFERENCE OBJECTS in sales orders screen
    (BTRefObj is what i tried,but failed :( . )

    ReplyDelete