16 Replies Latest reply: May 28, 2012 11:57 AM by Nishit Singla RSS

call a component controller methods from a view

Prem Kumar
Currently Being Moderated

Hi,

 

I have created a view v1 with context node c1and binded the context node c1 of it with the component controller so that the values entered in the view v1 are available.

 

now can i know how to access this values from component controller context node which i binded in a other view......

 

 

 

Thanks,

Prem

  • Re: call a component controller methods from a view
    Nithish PP
    Currently Being Moderated

    Hi Prem,

     

    If you want to use the component controller's context nodes in the other views of the same component , you can use attribute comp_controller and its context nodes directly.

     

    Regards,

    Nithish

  • Re: call a component controller methods from a view
    SAYAN SUBHRA JANA
    Currently Being Moderated

    Hi Prem,

     

    Use the following code to get the reference of the component controller context node.

     

    Lets assume the component controller context node name is partner.

     

      DATA :     comp_controller      TYPE REF TO   cl_bp_head_bspwdcomponent_impl,

                     coll_wrapper            TYPE REF TO   cl_bsp_wd_collection_wrapper,

                     entity                      TYPE REF TO   cl_crm_bol_entity.

      comp_controller ?= me->comp_controller.

      coll_wrapper = comp_controller->typed_context->partner->get_collection_wrapper( ).

      entity ?= coll_wrapper->get_current( ).

     

    Now you can use the methods(like get_property_as_string) of class cl_crm_bol_entity to read individual attribute values.

     

    Regards,

    Sayan

    • Re: call a component controller methods from a view
      Prem Kumar
      Currently Being Moderated

        Hi Sayan,

        I used below code,

       

      * ztypedcontext is instance attribute in component controller class ZL_BP_HEAD_BSPWDCOMPONENT_IMPL

       

      * zpopupcn is context node binded to component controller.

       

      zpopupcn is an value node from structure and not model node..

       

      DATA : comp_controller TYPE REF TO   zl_bp_head_bspwdcomponent_impl,
                lr_entity       TYPE REF TO   cl_crm_bol_entity,


      comp_controller ?= me->comp_controller.

      lr_entity ?=          comp_controller->ztyped_context->zpopupcn->collection_wrapper->get_current( ).

       

      but i get exception shown below in second line of code.

       

      Exception Details:

      CX_SY_MOVE_CAST_ERROR - Source type

      \CLASS=CL_BSP_WD_VALUE_NODE is not compatible, for the purposes of assignment, with target type

       

      Method: ZL_BP_HEAD_BPHEADOVERVIEW_IMPL=>EH_XXXX

      Source Text Row: 13

       

       

       

       

      Message was edited by: Prem Kumar

      • Re: call a component controller methods from a view
        Mahadevi HA
        Currently Being Moderated

        Hi Sayam ,

                       Try out the prem's code correctly ......

      • Re: call a component controller methods from a view
        SAYAN SUBHRA JANA
        Currently Being Moderated

        Hi Prem,

         

        Create the context node in the component controller as well as in both the views between which you need to pass the data.

        Bind the view context nodes with component controller context node.

         

        Now you can simply access the view context nodes by the following code in the implementation class methods of the corresponding views.

         

          DATA:  entity                      TYPE REF TO   cl_crm_bol_entity.

          entity ?= me->ztyped_context->zpopupcn->collection_wrapper->get_current( ).

         

        Hope it helps,

         

        Regards,

        Sayan

        • Re: call a component controller methods from a view
          Prem Kumar
          Currently Being Moderated

          Hi Sayan,

           

          I have already created binding between context nodes of view and component controller

           

          above code is not working as the me points to that corresponding view impl class where the context node is not present...(as i'm trying to access the values in other view not in same view)

           

          i think the problem lies with the exception is that it is an value node and not a model node....

           

          do you have any other ideas .....

          • Re: call a component controller methods from a view
            Nithish PP
            Currently Being Moderated

            Hi Prem,

             

            If you would like to access a value node , declare lr_entity TYPE REF TO IF_BOL_BO_PROPERTY_ACCESS instead of TYPE REF TO   cl_crm_bol_entity.

             

            Regards,

            Nithish

          • Re: call a component controller methods from a view
            SAYAN SUBHRA JANA
            Currently Being Moderated

            Hi Prem,

             

            I asked you to create the context node in both the views and bind both of them to the component controller context node.

             

            Regards,

            Sayan

            • Re: call a component controller methods from a view
              Prem Kumar
              Currently Being Moderated

              Hi Sayan,

               

              Exception resolved by changing the declaration type of lr_entity to if_bol_bo_property_access

               

              but now by using get_property_as_string the value is not returned...

               

               

               

              Thanks,

              Prem

              • Re: call a component controller methods from a view
                SAYAN SUBHRA JANA
                Currently Being Moderated

                Hi Prem,

                 

                check in debug mode whether data is populated in the context node...if not this will be a binding issue.

                 

                Regards,

                Sayan

                • Re: call a component controller methods from a view
                  Prem Kumar
                  Currently Being Moderated

                  Hi Sayan,

                   

                  issues was due to component interface and now it is resolved...

                   

                  i have one more question.....

                   

                  how to set the values for last name, firstname, house address, postal code , country in the account management screen in bp_head component......i have to set the values for those fields from the popup. now i get these values in the view BP_HEAD/BP_HEADOverview on event EH_ONPOPUP_CLOSED(this is the set on close event triggered when popup is closed).

                   

                   

                   

                  Thanks

                  Prem.

                  • Re: call a component controller methods from a view
                    SAYAN SUBHRA JANA
                    Currently Being Moderated

                    Hi Prem,

                     

                    First check what is the attribute, context node, view and component of the fields which you want to set. Now go to component workbench and check that particular context node. See if that context node is bound to any component controller context node or not. Now go to view BP_HEAD/BPHeadOverview and check if there is any context node which is bound to the same component controller context node. If it is, then set the view context attributes in the event handler using method SET_PROPERTY.

                     

                    Please share me the technical details(the attribute, context node, view and component of the fields which you want to set and of the fields where the data is entered) so that I can explain the above approach in detail.

                     

                    Regards,

                    Sayan

                    • Re: call a component controller methods from a view
                      Prem Kumar
                      Currently Being Moderated

                      Hi Sayan,

                       

                      component : BP_HEAD

                      View: BP_HEAD/BPHeadOverview

                       

                      I have called event EH_ONPOPUP_CLOSED when popup is closed in view BP_HEAD/BPHeadOverview and i get all the values entered in the popup here using below code.

                       

                             lr_context_node = gr_popup->get_context_node( iv_cnode_name = 'ZPOPUPCN' ).
                             lr_col_wrapper = lr_context_node->collection_wrapper.
                             lr_entity = lr_col_wrapper->get_current( ).

                             IF lr_entity IS BOUND.
                               lr_entity->get_properties( IMPORTING es_attributes = ls_data ).
                             ENDIF.

                       

                      now ls_data contains all the data entered in the popup ie. - firstname, lastname, house_no, street, city, postal code, country.....

                       

                      now it have tried the below code to map/set the entries with the Account management - individual account creation screen.

                       

                      data : ls_header         TYPE crmst_header_object_buil,        " BuilHeader
                                ls_header1        TYPE crmst_address_buil,                 " BuilStandardAddress
                       

                             ls_header-firstname     = ls_data-zfirstname.
                             ls_header-lastname      = ls_data-zlastname.   
                             ls_header1-house_no     = ls_data-zhouseno.  
                             ls_header1-street       = ls_data-zstreet.      
                             ls_header1-city         = ls_data-zcity.        
                             ls_header1-postl_cod1   = ls_data-zpostcode.    
                             ls_header1-country      = ls_data-zcountry.   
                             ls_header1-telephonetel = ls_data-ztelno.        
                             ls_header1-e_mailsmt    = ls_data-zemail.


                          

                             entity ?= me->typed_context->builheader->collection_wrapper->get_current( ).

                             IF entity IS BOUND.
                               entity->set_properties( EXPORTING is_attributes = ls_header ).
                             ENDIF.

                       

                             entity1 ?= me->typed_context-> BuilStandardAddress->collection_wrapper->get_current( ).

                             IF entity IS BOUND.
                               entity1->set_properties( EXPORTING is_attributes = ls_header1 ).
                             ENDIF.


                      but the problem is both the entity is INITIAL.

                       


                      • Re: call a component controller methods from a view
                        SAYAN SUBHRA JANA
                        Currently Being Moderated

                        Hi Prem,

                         

                        You can set the attributes in the event handler EH_ONPOPUP_CLOSED. Add the following code in the event handler.

                         

                        data : ls_header         TYPE crmst_header_object_buil,        " BuilHeader
                                 ls_header1        TYPE crmst_address_buil,                 " BuilStandardAddress

                                 lr_entity            TYPE REF TO cl_crm_bol_entity,

                                 lr_stdaddr          TYPE REF TO cl_crm_bol_entity.                   

                               ls_header-firstname     = ls_data-zfirstname.
                               ls_header-lastname      = ls_data-zlastname.   
                               ls_header1-house_no     = ls_data-zhouseno.  
                               ls_header1-street       = ls_data-zstreet.      
                               ls_header1-city         = ls_data-zcity.        
                               ls_header1-postl_cod1   = ls_data-zpostcode.    
                               ls_header1-country      = ls_data-zcountry.   
                               ls_header1-telephonetel = ls_data-ztelno.        
                               ls_header1-e_mailsmt    = ls_data-zemail.

                        lr_entity ?= me->typed_context->builheader->collection_wrapper->get_current( ).

                        IF lr_entity IS BOUND.
                            lr_entity->set_properties( EXPORTING is_attributes = ls_header ).
                        ENDIF.

                        lr_stdaddr = lr_entity->get_related_entity( iv_relation_name = 'BuilStandardAddressRel' ).

                        lr_stdaddr->set_properties( EXPORTING is_attributes = ls_header1 ).

                         

                         

                        Hope it helps.

                         

                        Regards,

                        Sayan

      • Re: call a component controller methods from a view
        Nishit Singla
        Currently Being Moderated

        I think u r using context node in view is of different type as context node in controller.

         

        Thanks

Actions