cancel
Showing results for 
Search instead for 
Did you mean: 

Using 1 View and 2 Controllers

Former Member
0 Kudos

Hi,

I'd like to use the same view to display and change some data, let's say a sales order for example.

I've imported BAPI_SALES_ORDER_CREATE and BAPI_SALES_ORDER_CHANGE into my RFC Model and created 2 Controllers for each BAPI.

I've also bound my View to the controllers, but it seems not possible to map the context elements to 2 controllers at the same time.

Is it the right solution for my scenario?

Any advice?

Thanks,

Nicolas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Do you mean that you would like to have both controllers having the same data ?

For ex: you wan to load data using a BAPI, then allow user to make some change, and finally save those changes using another bapi, depending on what have been done (create in case it's a new order, change in case it's a change)...

In that case, you can't map context elements to both, but what you could do is, before calling your final bapi (save or change), copy elements from current context element to input element of your bapi.

To do so, you can use WDCopyService.copyCorresponding(wdContext.currentSaleOrderElement(), wdContext.currentBapi_Create_Input());

Hope this helps !

Former Member
0 Kudos

Hi TWM,

Yop, it's exactly what I mean! ...and your response is great help for me, I will give it a try and let you know about the results and reward your points.

Thanks,

Nicolas

Former Member
0 Kudos

Thanks to all, it now works fine!

Answers (3)

Answers (3)

Former Member
0 Kudos

You are using two FMs you can't bind the modelnode to tow different sources at the same time.

If you create FM in such a way that after creating a new record, the RFC should return a collection of records back to the Model.

Regards, Anilkumar

Former Member
0 Kudos

Hi

You could use the Component Controller and do the mapping between the model and the Component controller and controller to the view. In this case you would be mapping the models for Change and Create BAPI to the View using the Component Controller.

Well i guess this would be a way of doing it.

regards

Ravi

Former Member
0 Kudos

I will summarize your points.

1. You want to show bothe create and display items in the same view

2. You have 2 custom controllers for each BAPI/FMs.

Solution.

1. Go to view properties and include both the coustom controllers in the required controllers.

2. Now create Modelnode in the view for both create and display BAPIs and map to coreesponding custom controller model nodes.

Regards, Anilkumar

Former Member
0 Kudos

Hi Anilkumar,

Thanks for ur answer. That's what I've done, but it seems I can't use the same Model Node in my View for both controllers create and display. It works fine if I use 2 different nodes and map them to each controller, but as they have the same structure I don't wish to do it this way. Is there any trick?

Regards,

Nicolas