cancel
Showing results for 
Search instead for 
Did you mean: 

Copying data between Views/Components...

Former Member
0 Kudos

CRM 7

Within the Contact screen the detail section displays the contact details in the left pane (BP_CONT) and the address details in the right pane (BP_ADDR).

When a user enters an email address into the left pane I need to copy that value into the email address of the right pane.

The left pane showing Account/Contact relationship details and right pane showing just the Contact address details.

Normally I would perfom such copying in the DO_PREPARE_OUTPUT method of a controlling class that has all the appropriate context nodes, but in this case the view for the left pane (BP_CONT/ContactDetails) has no Address related context nodes. Is this something I'll need to build by adding context nodes and binding them accordingly?.

Upto now I've never needed to do this, but, would there not be an issue when the same context node appears twice in two different views/components but on the same screen?.

I assume that there's no other way of achieving this?.

Any advice would be welcome.

Jason

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member206299
Contributor
0 Kudos

Hi Jason,

We can capture the field value of the left pane from its GET Method.

Pass this value to a View controller custom attribute.

then deafult field value of the right pane from the view controller attribute.

Set the value to the context node using the SET method.

Regards,

Sijo

Edited by: sijokjohn85 on Aug 26, 2010 6:14 PM

Former Member
0 Kudos

Both the left and right pane have different controllers, so how does one do that. Higher up, they both seem to be using the component view BP_CONT/BPCONTOverview, but this does not seem to have the two context nodes to access.

So I'm a little confused as to how I can copy the content of fields from the left pane to the right pane by manipulating code in a controller class. Which controller class would I use in this case.

Within both the left and right panes if I press F2 when in the e-mail fields and then click the 'Show view location' I can see that the hierarchy shows BP_CONT/BPCONTOverview (root) , followed by BP_CONT/ContactViewSet (0001) and then the actual component/view for the pane. I assumed I could just add code to the controller class for BP_CONT/ContactViewSet, but, this has NO context nodes when displayed, so how can I find out which controller class might have access to the context nodes/attributes for both panes?.

Jason

former_member206299
Contributor
0 Kudos

Hi Jason,

In the View controllers you can define your variable.Select the view controller class of the left pane.declare an attribute in the view controller class.

Pass the value from the GET_METHOD to this attribute.

In the right pane pass it from the view controller attribute to the field in the right pane & set it to the context nod eusing the SET Method.

Regards,

Sijo

former_member189678
Active Contributor
0 Kudos

Jason,

See if you can use the Method GET_COMPONENT_USAGE_NAME of the Window Controller to access the Context Node of other component and hence the Email attribute.

Rg,

Harshit

Former Member
0 Kudos

Harshit,

How exactly is this method used for this purpose?.

For example, I get the value using:

DATA: lr_window TYPE REF TO cl_bsp_wd_window,
      lv_name   TYPE STRING.

lr_window = me->view_manager->get_window_controller( ).
lv_name = lr_window->get_component_usage_name( ).

When in debug the lr_name contains the value of 'overview', but the context node 'Workaddress' or 'standardaddress' do not exist under the BP_CONT/BPCONTOverview view.

Jason

Former Member
0 Kudos

Sijo,

I have used a process similar to this before whereby the controller class accessed a variable from the view class, but in this case the two views belong to different components.

This is the hierarchy that I have.

BP_CONT/BPCONTOverview (Parent) CL_BP_CONT_CONTACTVIEWSET_IMPL

BP_CONT/ContactDetails (Child, Left pane) ZL_BP_CONT_CONTACTDETAIL5_IMPL

BP_CONTOverview (Child, Right pane) ZL_BP_ADDR_STANDARDADDRES_IMPL

Just to summerise, within the contact screen using the WebUI I am attempting to copy whatever email that is entered into the left pane of the detail screen into the right pane. When I press F2 against both email fields I can see that both belong to different components, but seem to have a parent controller class as shown above. However, I have not yet managed to identified how these are linked to the parent controller class yet.

I am now trying to determine a way of copy the contents from one component/contextnode/attribute into another attribute belonging to a different component/view. The only commonality is the parent controller class shown above.

Jas

former_member189678
Active Contributor
0 Kudos

Jason,

There is a Context Node in the Component Controller of BP_CONT & BP_ADDR named "PARTNER". Please check if you can access it and check for the attribute that you would like to copy.

Since the context Node is at Component Controller Level, i do hope that the data is not destroyed.

Rg,

Harshit

Former Member
0 Kudos

Thanks Harshit,

I had looked at that area previously, but without success. The PARTNER context node does not contain the attribute 'STRUCT.E_MAILSMT' which is the attribute reported when we press F2 against the email address for the left and right pane.

When in the Contact screen I can press F2 and then click 'Show View Location' to see the hierarchy. The email address in both the left and right pane have the same parent according to the hierarchy, with the parent being BP_CONT/ContactViewSet. However, when I look at this component/view there are NO context nodes displayed under it.

If the context nodes are not displayed under the controller then is it safe to assume that the controller can not access these context nodes?.

If I place the following code in the 'do_prepare_output' method for the controller class of BP_CONT/ContactViewSet, like so:

DATA: lr_ent         TYPE REF TO if_bol_bo_property_access.
  lr_ent ?= me->typed_context->workaddress->collection_wrapper->get_current( ).
  IF lr_ent IS BOUND.
     lr_ent->get_property_as_value(  EXPORTING iv_attr_name = 'E_MAILSMT'
  ENDIF.

I get an error saying that the 'WORKADDRESS' is unknown, which I would expect. The 'WORKADDRESS' is one of the context nodes belonging to the left pane (BP_CONT/ContactDetails).

Is it possible to set up an attribute in the parent controlling class (as public) and then access (read/write) to this attribute from the child controlling class?

Jason

Former Member
0 Kudos

Hi Jason,

As far as i have understood the problem,it goes like this:

You need to copy value from one field A of context node A of view A to field B of context node B in view B.

I would suggest two ways:

1) you create a similar context node(C) in view B.Then create a custom controller with the contxt nodes A and C bound to the same context node in custom controller.It is not a problem to show the same context node in different views in the same screen ,as long as the data binding is proper and the values shown are syncronised.

2) If you want to avoid creating context nodes,then you should manually copy the values in the DO_PREPARE_OUTPUT method of the viewset(ContactViewSet).In this,you should access the subcontroller of the views which are inside this view set using the method GET_CONTROLLER().Once you get instance of the view,you can easily get the context fo this views.Now here,using the context classes getter and setter methods,you can get the value from Field A and copy it to subcontroller of view B ->field B.

Thanks,

Suvidha

Former Member
0 Kudos

Suvidha,

Sorry to be a pain but do you have an example of how to use the GET_CONTROLLER method, especially the DATA statement which defines the variable to receive the instance?.

For example if I were trying to get an instance of the sub-controller for the component/view BP_CONT/ContactDetails which uses the controller class ZL_BP_CONT_CONTACTDETAIL5_IMPL and controller 'ContactDetails.do', which should I use in the call to the GET_CONTROLLER?.

Looking at the GET_CONTROLLER it would look like I use a controller ID, something like v110 for example, but where is this controller ID shown when you're in the component workplace and looking at the views, or is there a way to find this via code?.

Apologies for such a simple question, but this does sound like the answer to be able to access context nodes from several different components and views.

Best regards

Jason

Former Member
0 Kudos

Hi Jason,

Firstly you need not apoligise being a pain ...we are all sailing in the same boat

1)I do not have an example immediately because i am unable to access the server where i implemented this.but i just remembered that instead of get_controller you can instead use the GET_SUBCONTROLLER_BY_VIEWNAME method, pass the fully qualified view name ie for example ("BP_CONT/BPCONTOverview"). As far as i remember this should work.Also after getting the view controller, use it to get the value of attrbute "CONTEXT" which would return the context class of the view if you typecast it.

2)But i would like to tell you that this would not be classified as flexible coding.If you want to make it cleaner,you should create a custom controller and bond both your context nodes of both the views with this custom controller .Things become simpler in this case because later you can do as many changes as u want and your code still remains clean.

Also to access the custom controller attributes from viewset is very simple.use the GET_CUSTOM_CONTROLLER(<custom controller name>) method and now you can you as much getting and setting of attaibutes as you want.Also since your context nodes of Cuco are bound to the reapstive view nodes,you would easily get the values in your views.

You can get back to me for any concerns.I'd be more than happy to answer

Thanks,

Suvidha

Former Member
0 Kudos

Many thanks for the information. It sounds like the custom controller should be the way to go.

I'll be honest here, I really don't know how a custom controller works or even how to go about defining one. However, I'm going to do some research and find out though as it sounds very handy to know about.

So far though, all the search help that I am getting back in regards to custom controllers seems to be for Dynpro's for table controls and suchlike. I think I need something more geared toward the WebUI interface, but I'll keep looking.

With regards

Jason

Former Member
0 Kudos

Jason,

Please check the following link. You will find a lot info with examples.

http://blogs.moovar.com/sap/category/sap-crm/web-ui/

Thanks,

Ravi G

Former Member
0 Kudos

Ravi,

That's a great link. I looked at the section for creating a custom controller, but it's doing something that I don't think I need to do in that the example is creating a search and new view.

For what I'm trying to do it's been recommended that I use a custom controller. I'm attempting to copy a value for an atrrib from one component/view to another. Both component/views exist in the 'Contact' main detail screen. I have created a custom controller and used the 'BuilContactStandard Address' and 'BulStandard Address' BOL object to create two context nodes. I had hoped that I could then just change the 'do_prepare_output' method and add code to copy the data from one context node to the other, but this is not working, and I think it's because these nodes to be bound somehow, but how and to what?.

The two component/view/context nodes that exist in the 'Contact' screen are BP_CONT/Details/WORKADDRESS and BP_ADDR/StandardAddress/STANDARDADDRESS and it's these that I need to copy a value from one attribute to another across component/views.

Can you give any further guidance on this?.

Jason

Former Member
0 Kudos

28 views and no suggestions.

Maybe this is rocket science after all.

Jas

prasenjit_sharma
Active Contributor
0 Kudos

Hi,

You can use the event handler method EH_ONSUBMITENTER to update the email address in BP_ADDR. You just need to find the related entities for BP_ADDR and BP_CONT in the method, which should be easy.

Once you find it, use get_property_as_value to fetch the email address from BP_CONT and set_property to update it to the BP_ADDR.

Regards

Prasenjit