Purpose:
We noticed that in CRM WebUI, if we input values for search fields, navigate away and then navigate back to this search screen again, the search values are always kept. For example, in business role SALESPRO, search accounts screen:
- input value 'TESTNAME' to search field 'Name 1 /Last Name':
- Navigate away to any other screen:
- Then navigate back via menu:
- The search value will keep:
Why it behaves in this way?
- From the framework perspective, some instances for context nodes will be created when component is initially loaded and then kept in buffer in order to reuse in current session. For example, context nodes instances for component controller and customer controller, etc.
- However, instances for context nodes of views won't be kept.
- Also, context nodes can be bound in some way, like using method DO_CONTEXT_NODE_BINDING. In this way, context nodes in views can be bound to the context nodes in component controllers.
- Since instances of context nodes in component controller always exist in current session, the search values can be retrieved even after the search screen is navigated away and then back again.
In this article, basic logics will be explained with a sample of search accounts.
Logics and Reason(after the search screen is navigated again):
- Context nodes for views will be newly created every time when navigating into a screen. In the above case, the view is BP_HEAD_SEARCH/MainSearch, the context nodes for the search fields are SEARCH. When navigating into this search screen, CL_BP_HEAD__MAINSEARCH_CTXT->CREATE_SEARCH is executed to create a new instance for the node SEARCH, the codes are owner->create_model. Detailed parameters are:
- Even though an instance for SEARCH is created, the values COLLECTION_WRAPPER->COLLECTION_REF->IF_BSP_WD_COLLECTION_REF~COLLECTION is {O:INITIAL} at the time:
- Then next, it calls method DO_CONTEXT_NODE_BINDING. This method binds the context node SEARCH in view BP_HEAD_SEARCH/MainSearch with the context nodes SEARCH in component controller:
- After this binding, we can see the values COLLECTION_WRAPPER->COLLECTION_REF->IF_BSP_WD_COLLECTION_REF~COLLECTION is not initial any more(on and after the 2nd navigation to the screen only. For the 1st navigation to the search screen, COLLECTION will be created later on. Pease refer to Additional part):
- If we double click 'IF_BSP_WD_COLLECTION_REF~COLLECTION', check its value: ENTITY_LIST->{O:5892*\CLASS=CL_CRM_BOL_DQUERY_SERVICE}->SELECTION_PARAM_COL, we can see it is '[4X2(12)]Standard Table':
- Double click on 'ENTITY_LIST', double click its first entry, then check 'PARAMETER_DATA', double click on '{A:13600*\TYPE=GENILT_SELECTION_PARAMETER}', we get search value information:
What is the context nodes SEARCH of component controller?
- Execute T-code BSP_WD_CMPWB, display component BP_HEAD_SEARCH.
- Double click on 'Component Controller' on the left side.
- On the right side, expand 'Context Nodes', there is 'SEARCH' context node.
- For this context node SEARCH, its instance is created in method CL_BP_HEAD__BSPWDCOMPONEN_CTXT->CREATE_SEARCH. This method will be only executed once when the component BP_HEAD_SEARCH is loaded initially:
The same thing is for customer controllers. Actually, we can also find another case in search leads which binds context in view with context in customer controller(BT108S_LEA/SEARCH):
Here is the customer controller:
Additional:
Collection wrapper will be added firstly during context initialization. In this case, please refer to method CL_BSP_WD_ADVSEARCH_CONTROLLER->DO_INIT_CONTEXT:
Keywords:
CL_CRM_BOL_DQUERY_SERVICE, GET_INSTANCE, COLLECTION_WRAPPER->ADD, CL_BSP_WD_CONTROLLER=>CO_TYPE_CUSTOM, CL_BSP_WD_CONTROLLER=>CO_TYPE_COMPONENT