cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

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,

0 Likes
View Entire Topic
0 Likes

Hi,

You have to implement the method WD_USAGE_INITIALIZE of the component controller class in order to complete

the binding.

Regards

Leon

Former Member
0 Likes

Thank you very much for your response.

I have implemented method WD_USAGE_INITIALIZE in component controller of Component C1 and C2 both. But still not getting data from C1 in C2.

Any suggestions?

0 Likes

Try debugging the method WD_USAGE_INITIALIZE and check if it is properly bound. Check if the context node names

are proper.

Regards

Leon

Former Member
0 Likes

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

Former Member
0 Likes

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

Former Member
0 Likes

Hi Leon,

During debug, it is not throwing any error while executing code of WD_USAGE_INITIALIZE. But in Do_init method it does not have any value in context node, even it does not initialize the context node.

Any idea what is might be missing?

Thank you.

Former Member
0 Likes

If you want to bind BTAdminH in compoent usage then why are you binding BTACTIVITYH in CTXT level ? you need to bind BTAdminH also at CTXT leve in method CREATE_ BTAdminH.

Thanks

sudhir grover

Former Member
0 Likes

Hi Sudhir,

I want binding context node from View to Component thus I am binding in _CTXT class. Shall I remove it?

Thanks and Regards,

Former Member
0 Likes

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

0 Likes

Hi,

What you are missing would be, you have not bound the context node btadminh of the view in C2 to the component

controller context node btadminh of C2.

Once you do the binding, it should work.

Regards

Leon

Former Member
0 Likes

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?

0 Likes

Hi,

Have you done the binding from context node of view in C2 to the corresponding context node in the

component controller of C2?

Regards

Leon

Former Member
0 Likes

Hi,

let me know how are your accessing the CN2 in component C2 ? are you doing this in any view of C2 or at component controller level ?

Thanks

sudhir grover

Former Member
0 Likes

I am trying to access CN2 in DO_INIT method of view V2 using below code


lr_bo_access = me->typed_context->btadminh->collection_wrapper->get_first( ).

Thanks and Regards,

Former Member
0 Likes

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,

Former Member
0 Likes

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

Former Member
0 Likes

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

Former Member
0 Likes

Thank you Sudhir.

I applied break point in method WD_USAGE_INITIALIZE of component controller CM2. But during processing the code goes first to DO_INIT and then it throws error. It is not going to that break point.

What is missing now?

Former Member
0 Likes

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

Former Member
0 Likes

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,

Former Member
0 Likes

Hi,

I just checked. you have written the code to read the value in wrong method in V2. don't write the code in method DO_INIT. just use the same code in DO_INIT_CONTEXT and delete the code from DO_INIT . it will work !!

thanks

sudhir grover

Former Member
0 Likes

Hi Sudhir,

The class is initalised but there is no value in context node of Com Node.

Anything I am missing.

Thanks and Regards,

Former Member
0 Likes

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

Former Member
0 Likes

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

Former Member
0 Likes

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,

Former Member
0 Likes

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

Former Member
0 Likes

Thak you Sudhir. I tried the option you mentioned... lr_property_access is not bound....means we have problems in binding of CN1 at CM1.

Any idea how to check that?

Thanks and Regards,

Former Member
0 Likes

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

Former Member
0 Likes

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?

Former Member
0 Likes

Only thing remains to be checked now is how you are setting the btadminh entity in V1. try to see whether collection wrapper of btadminh in V1 is having the data when you are trying to move from CM1 to CM2. how are you moving from CM1 to CM2 ? is there any event ?

Thanks

sudhir grover

0 Likes

Do you have a specfic requirement to access in the DO_INIT method?

Have you tried accessing in the DO_PREPARE_OUTPUT method?

Regards

Leon

Former Member
0 Likes

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.

0 Likes

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

Former Member
0 Likes

Did you check the way i told you in my last post ??

Sudhir

Former Member
0 Likes

Hi Sudhir,

Sorry for delay. The Data is moving from CM1 to CM2 based on event. The event is trigerred and View V2 is called.

Any idea how can I check whether data is successfully transferred from CM1?

Thanks and Regards,

Former Member
0 Likes

Hi Leon,

The Context node is bound in CM2. I can see the Context node binding details. In context node it shows like>

-


Bound to Context Node BTADMINH

Implementation Class ZL_Z_C_BSPWDCOMPONEN_CN03

-


Thank you,

0 Likes

That's good enough. Can you also check the same binding in the component 1 for the corresponding

context node from the view to the component controller in CM1.

Regards

Leon

Former Member
0 Likes

The same binding is available in CM1.

Thank you.

Former Member
0 Likes

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,

former_member192854
Active Participant
0 Likes

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.

Former Member
0 Likes

When I reach to view V2 do I need to read the context node from component controller CM1's context node CN1?

If yes then how to read that?

Thank you.

former_member192854
Active Participant
0 Likes

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!

Former Member
0 Likes

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.

former_member192854
Active Participant
0 Likes

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

0 Likes

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

former_member192854
Active Participant
0 Likes

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