Hi Experts,
I want to do component binding of context node for Componenet C1 and Context Node CN1 to Componenet C2 and context node CN2.
I have defined that context node as Component Interface (in Runtime Repository Editor) in both components.I have also added code to bind in CTXT class's CreateXXXX method.
Now when I am trying to access CN2 ( which is same as CN1), I get error 'Access via 'NULL' object reference not possible.'.
Kindly help.
Thanks and Regards,
Request clarification before answering.
Hi,
You have to implement the method WD_USAGE_INITIALIZE of the component controller class in order to complete
the binding.
Regards
Leon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
i hope you have written the code in WD_USAGE_INITIALIZE of C1 as given below.
CASE iv_usage->usage_name.
WHEN 'usage name'
CALL METHOD iv_usage->bind_context_node
EXPORTING
iv_controller_type = cl_bsp_wd_controller=>co_type_component
iv_name = iv_usage->usage_name
iv_target_node_name = 'CN1' " Node of the MAIN component
iv_node_2_bind = 'CN2'. " Node of the embedded component
ENDCASE.
Thanks
sudhir grover
I have context node BTAdminH in View V1 of Component CM1. I created component binding for CN1 from view's CTXT class's CREATEBTACTIVITYH method using below code
owner->do_context_node_binding(
iv_controller_type = cl_bsp_wd_controller=>co_type_component
iv_target_node_name = 'BTACTIVITYH'
iv_node_2_bind = BTACTIVITYH ).
In Component Controller of component CM1's method WD_USAGE_INITIALIZE, I am using following code
DATA:
lv_usage TYPE REF TO if_bsp_wd_component_usage,
lr_us_bttext TYPE REF TO cl_btnote_bspwdcomponent_cn00.
lv_usage = me->comp_controller->get_component_usage( iv_usage->usage_name ).
CASE iv_usage->usage_name.
when 'CUBT127IACTI'.
CALL METHOD lv_usage->bind_context_node
EXPORTING
iv_controller_type = cl_bsp_wd_controller=>CO_TYPE_COMPONENT
iv_target_node_name = 'BTADMINH' "#EC NOTEXT
iv_node_2_bind = 'BTADMINH'.
when OTHERS.
CALL METHOD SUPER->WD_USAGE_INITIALIZE
EXPORTING
IV_USAGE = iv_usage.
ENDCASE.
Now in View V2 of another component CM2, I am trying to access the context node CN1. For this I have added context node in both view V2 and component controller of CM2. Then I created binding from V2 in _CTXT class using below code
* Added by wizard
* bind Context Node to controller
owner->do_context_node_binding(
iv_controller_type = CL_BSP_WD_CONTROLLER=>CO_TYPE_COMPONENT
iv_target_node_name = 'BTADMINH'
iv_node_2_bind = BTADMINH ).
Now in DO_INIT method I am trying to access CN2 (copy of CN2) using below code
lr_bo_access = me->typed_context->btadminh->collection_wrapper->get_first( ).
But when I execute the above code, it throws error 'Access via 'NULL' object reference not possible.'
Kindly share what is that I am missing?
Thanks and Regards,
Edited by: CRM Beginner on Jan 25, 2012 11:09 AM
Hi,
No it is fine. but you are binding the wrong context node. to pass the data from view to compoent you need to bind BTAdminH in method CREATE_ BTAdminH of CTXT class. As want to pass BTAdminH from C1 to C2 you need to get the value from view to compoent and that require binding. just add the code in CREATE_ BTAdminH just like the way you did for BTACTIVITYH. it will work !
Thanks
sudhir grover
Thank you Sudhir.
I have now added code to bind BTAdminH in View1's CTXT class method CREATEBTADMINH as follows:
CALL METHOD super->create_btadminh.
owner->do_context_node_binding(
iv_controller_type = cl_bsp_wd_controller=>co_type_component
iv_target_node_name = 'BTADMINH'
iv_node_2_bind = btadminh ).
It is not working ... I think we are close... Any observation?
Hi Leon,
I did binding.
In View V2 of another component CM2, I am trying to access the context node CN2 (Copy of CN1). For this I have added context node in both view V2 and component controller of CM2. Then I created binding from V2 in method CREATE_BTADMINH in _CTXT class using below code
* Added by wizard
* bind Context Node to controller
owner->do_context_node_binding(
iv_controller_type = CL_BSP_WD_CONTROLLER=>CO_TYPE_COMPONENT
iv_target_node_name = 'BTADMINH'
iv_node_2_bind = BTADMINH ).
Is there anything I am missing?
Thank you,
Hi,
you are trying to read data in V2 of compoent C2. so you need that binding also just add the code in method CREATE_ BTAdminH of CTXT class of V2 and bind with the compoent controller node.
owner->do_context_node_binding(
iv_controller_type = cl_bsp_wd_controller=>co_type_component
iv_target_node_name = 'BTADMINH'
iv_node_2_bind = btadminh ).
hopefully it will work now !
Thanks
sudhir grover
Just double check in component CM2 whether the context node which you are accessing is there in the runtime repository-> ComponentInterface -> InterfaceController -> Context and while debugging WD_USAGE_INITIALIZE method go inside this method iv_usage->bind_context_node by pressing F5 and see variable LV_NODE_2_BIND is having the instance of context node class of component controller of CM2. if not then binding is not happening.
thanks
sudhir
You need to debug the method WD_USAGE_INITIALIZE of compoent CM1 not CM2 because that is where you have done the context node binding fro CM1 to CM2. i believe this breakpoint you put in CM2. try in CM1 and put the BP at the code you have written to bind the node.
CASE iv_usage->usage_name.
when 'CUBT127IACTI'.
CALL METHOD lv_usage->bind_context_node
EXPORTING
iv_controller_type = cl_bsp_wd_controller=>CO_TYPE_COMPONENT
iv_target_node_name = 'BTADMINH' "#EC NOTEXT
iv_node_2_bind = 'BTADMINH'.
just press F5 when you go at method CALL METHOD lv_usage->bind_context_node in debugging and check the value of LV_NODE_2_BIND at line no 14. if value is not coming after executing ME>IF_BSP_WD_COMPONENT_USAGE~GET_CONTEXT_NODE binding is not happenig.
thanks
sudhir grover
The method WD_USAGE_INITIALIZE in CM1 is working fine. The debugged that earlier also, it is working fine. I checked the way you explained .. F5 and found LV_NODE_2_BIND is getting initialized...
If this is working then where is the problem? Am I accessing the Context node correctly in view V2 of Component CM2?
Please help.
Thanks and Regards,
Hi,
There should be one, ideally. just double check the binding in view V2 of component CM2 in method CREATE_BTADMINH of _CTXT class. i hope binding is fine to compoent controller level. Make sure firtly the model is getting created in this method with code and then only you are doing binding.
model = owner->create_model(
class_name = 'CL_BP_ADDR_ACCOUNTADDRESS_CN01' "#EC NOTEXT
model_id = 'BTADMINH' ). "#EC NOTEXT
BTADMINH ?= model.
bind Context Node to controller
owner->do_context_node_binding(
iv_controller_type = CL_BSP_WD_CONTROLLER=>CO_TYPE_COMPONENT
iv_target_node_name = 'BTADMINH'
iv_node_2_bind = BTADMINH ).
Thanks
Sudhir Grover
Hi,
There should be one, ideally. just double check the binding in view V2 of component CM2 in method CREATE_BTADMINH of _CTXT class. i hope binding is fine to compoent controller level. Make sure firtly the model is getting created in this method with code and then only you are doing binding.
model = owner->create_model(
class_name = 'CL_BP_ADDR_ACCOUNTADDRESS_CN01' "#EC NOTEXT
model_id = 'BTADMINH' ). "#EC NOTEXT
BTADMINH ?= model.
bind Context Node to controller
owner->do_context_node_binding(
iv_controller_type = CL_BSP_WD_CONTROLLER=>CO_TYPE_COMPONENT
iv_target_node_name = 'BTADMINH'
iv_node_2_bind = BTADMINH ).
Thanks
Sudhir Grover
The binding is done after model creation.
Here is the code
DATA:
model TYPE REF TO if_bsp_model,
coll_wrapper TYPE REF TO cl_bsp_wd_collection_wrapper,
entity TYPE REF TO cl_crm_bol_entity, "#EC *
entity_col TYPE REF TO if_bol_entity_col. "#EC *
model = owner->create_model(
class_name = 'ZL_Z_ZPPRPROD_CN02'
model_id = 'btadminh' ). "#EC NOTEXT
btadminh ?= model.
CLEAR model.
* Added by wizard
* bind Context Node to controller
owner->do_context_node_binding(
iv_controller_type = CL_BSP_WD_CONTROLLER=>CO_TYPE_COMPONENT
iv_target_node_name = 'BTADMINH'
iv_node_2_bind = BTADMINH ).
It is still not getting the CN1's data now in CN2. Kindly help.
Thanks and Regards,
Hi,
Try to read from component controller directly and see if value is there or not. if no value is coming it means data is not passed from C1 to C2. write the below code in DO_INIT_CONTEXT in view V2.
DATA:
my_comp_contrl TYPE REF TO cl_bp_addr_bspwdcomponent_impl,
lr_property_access TYPE REF TO if_bol_bo_property_access.
my_comp_contrl ?= me->comp_controller.
lr_property_access = my_comp_contrl->typed_context->btadminh->collection_wrapper->get_current( ).
check lr_property_access is bound.
if lr_property_access is not bound it means data hasn't come in component C2.
Thanks
sudhir grover
Hi,
Now check in the compoent CM1 and view V1 whether entity is passed from View V1 to component controller of CM1. just double check the binding of nodes in CM1 in V1 CTXT class method create_adminh. i could see in your post you have written the below code in CREATE_BTACTIVITYH in V1.
owner->do_context_node_binding(
iv_controller_type = cl_bsp_wd_controller=>co_type_component
iv_target_node_name = 'BTACTIVITYH'
iv_node_2_bind = BTACTIVITYH ).
this is not the node you are passing from CM1 to CM2. you are passing BTADMINH so you need to bind this node. so write the code in V1 CTXT class method CREATE_ BTADMINH
bind Context Node to controller
owner->do_context_node_binding(
iv_controller_type = CL_BSP_WD_CONTROLLER=>CO_TYPE_COMPONENT
iv_target_node_name = 'BTADMINH'
iv_node_2_bind = BTADMINH ).
i hope it will work this way.
Thanks
sudhir grover
Hi Sudhir,
The code shown in my previous comment was wrong. I had the binding for BTAdminH. The current binding code in V1 _CTXT class is
DATA:
model TYPE REF TO if_bsp_model,
coll_wrapper TYPE REF TO cl_bsp_wd_collection_wrapper,
entity TYPE REF TO cl_crm_bol_entity, "#EC *
entity_col TYPE REF TO if_bol_entity_col. "#EC *
model = owner->create_model(
class_name = 'CL_BT126H_A_APPTDETAILS_CN01'
model_id = 'btadminh' ). "#EC NOTEXT
btadminh ?= model.
CLEAR model.
* bind to custom controller
owner->do_context_node_binding(
iv_controller_type = cl_bsp_wd_controller=>co_type_custom
iv_name = 'BT126H_APPT/ApptDetailCuCo' "#EC NOTEXT
iv_target_node_name = 'BTADMINH'
iv_node_2_bind = btadminh ).
owner->do_context_node_binding(
iv_controller_type = cl_bsp_wd_controller=>co_type_component
iv_target_node_name = 'BTADMINH'
iv_node_2_bind = btadminh ).
The custom controller binding was defualt one. And the Component binding is the one I have added. Not sure where are we wrong now?
Hi Leon,
At the moment I am trying to access in DO_INIT_CONTEXT method. The context node is not having any value thus 'IS BOUND' check fails. After that Sudhir suggested to access context node sitting at component controller of component 2 and I found that Context node in component controller is also not having any values. It seems the data is not transferred from View V1 to Context node CN1 of component controller CM1.
Any idea how to check and correct that part?
Thank you.
Hi,
In Component 2, Have you bound the context node of your view to the context of the component controller.
You can do it via the wizard.
To check that, do the following.
Goto the view in component 2.
Goto the context node.
Expand the context node.
Check if you have a node ' Bound to Context node BTADMINH'
Expand the node and see if you have the component controller class maintained there.
If this node is not there, then you have not bound the context node to the component controller.
This has to be done in Component 2.
Regards
Leon
In View V1, Where it is calling View V2 I checked whether the component controller has values in context node using below code
DATA:
my_comp_contrl TYPE REF TO Z1_BT126H_A_BSPWDCOMPONEN_IMPL,
lr_property_access TYPE REF TO if_bol_bo_property_access.
my_comp_contrl ?= me->comp_controller.
lr_property_access = my_comp_contrl->typed_context->btadminh->collection_wrapper->get_current( ).
CHECK lr_property_access IS BOUND.
And found it does have value in Context node CN1 which I want to pass to V2. It means the data is available in component controller but it is not moving to component controller CM2.
I checked the context node is available in Runtime Repository Editor > Component Interface > Context.
Please suggest what might be missing?
Thanks and Regards,
I'm wondering, why do you need to pass it from one context node to another?
If you need to read the values, you can use the code and the context via the component controller right?
But if you need the context directly in the view (for displaying BTAdminH values), you should create a new Context node in the other view and bind this to the component controller.
Just push with your right mouse on the Model Context node BTAdminH in your view 2, and directly, choose 'Create binding'' or 'Change binding'. Fill out your current BSP Component (many times they're named the same, but please let me know if you bump into problems), the controller type (component controller) and the context node which contains the actual BTAdminH context node in the Component controller.
Then you should be set.
Validate the CREATE_ <name of your context node in V2> method in the context class (CTXT) that at the end of the method it says something like:
owner->do_context_node_binding( iv_controller_type = cl_bsp_wd_controller=>co_type_component iv_target_node_name = 'BTADMINH' iv_node_2_bind = <YOUR CONTEXT NODE NAME> ).
If this is the case, try to debug it and check if the BOL object is populated.
Good luck!
Hi Sander,
I had created context node binding at view V2 already. The context node CN2 in view V2 is binded with context node CN2(same name) in component controller CM2. This binding is done in method CREATE_BTADMINH of context class _CTXT of view V2.
At the moment issue is that the values are not populated in component controller(CM2)'s context node CN2 from CN1.
Here are the steps I have done so far:
1. Enhance the View V1 > added event to call view V2 as pop up.
2. Created binding for Context node CN11 (in view V1) with CN 12 with Component Controller CM1.
3. In Runtime Repository added context node in ComponentInterface>InterfaceController>Context.
4. Did all config and coding for calling pop up. ( It is opening the pop up window. So I am not mentioning those steps here.)
5. In View V2 > in the View V2's context class _CXTX I have created context node binding CN21 (View's context node) with Component controller(CM2)'s context node CN22.
6. In View V2's implementation class IMPL, I am trying to access CN22 or CN21 in method DOINIT_CONTEXT. But here I am not getting any value in context node CN21/CN22.
I checked at View V1's method where I am calling pop up that component controller CM1 has values in Context node CN12.
I don't understand what is missing that context node CN12's values are not passed onto context node CN22.
Please help.
Thank you.
Hi CB,
a pop-up, that explains a lot. I will have a look for you tomorrow. I think you have to redo the binding stuff, since it works differently for pop-ups. Perhaps you can take a look at standard SAP pop-up components, but i'll get back to you.
Kr. Sander
Edited by: Sander Boers on Jan 31, 2012 7:32 PM
Hi,
In case of popup, do the following
DATA:
lv_collection TYPE REF TO if_bol_bo_col,
lr_cnode TYPE REF TO cl_bsp_wd_context_node.
lr_cnode = ir_popup->get_context_node( iv_cnode_name = 'BTADMINH' ).
lr_cnode->collection_wrapper->set_collection( lv_collection ).once you create the popup, access the corresponding context node from the popup as shown in the above code.
Then set the data to that context node.
Regards
Leon
What Leon says is correct.
BTW: ir_popup is a reference IF_BSP_WD_POPUP.
For a standard example you could have a look at Web UI view: BT125H_TASK/TaskOVViewset
In here there is the event handler 'EH_ONNEW' and the close trigger 'EH_ONNEWSEL_CLOSED'.
I don't think you need to clear the context node in such a extended fashion SAP does it, but it gives you a good overall view of how a popup works combined with context passing.
Please let me know if you bump into other troubles.
Kr. Sander
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.