Although probably not so popular the cooperation between Web Dynpro and Composite Application Services is a very common, quick and reliable way to build advanced and complex applications, based on the NetWeaver platform. Additionally the synchronisation of those two technologies with Guided Procedures allows for an easy and intuitive modelling of your business processes.
This blog is not about explaining how those 3 SAP technologies work together (for that purpose, you can find 1000 of blogs on SDN) rather trying to give an insight on how the connection between them worked before NetWeaver 7.0 SP12 and after it.
What hasn’t changed is the way you generate the Web Dynpro Model inside a Composite Application Framework project. This is done as shown on the picture below:
After this operation, we normally get a model generated inside the Web Dynpro project that was generated together with the CAF project and in general has the same name just becomes visible when we change to the Web Dynpro Perspective. If everything with the above operation went well, the Web Dynpro View should show something like that:
As you can see there are two public parts that the wizard creates automatically. Those however could not be used as they are. No matter before or after SP12, the “package_tree” public part has to be edited in order to show the correct model classes later when it is integrated in a Web Dynpro application. The next screen shows you what you have to do in order to update the public part in NetWeaver releases until SP12 inclusive:
The only thing to do is add the model to the public part “package_tree” and then build the component. The model classes appear right away in the consumer Web Dynpro application. However due to some compatibility issues the Web Dynpro Java development team decided to change the natural way of things and changed this small operation into an effort, which could be estimated to twice as much compared to the old way. So from SP13 on, the new way to add Web Dynpro models to the public part is described in Note 1126451. I would however not really recommend following the note due to one very simple reason. The note suggests that you have to manually edit your public part entities by adding all .wdmodelclass files as file references. Well no big deal you would say and probably you would be right if we were talking about 10 files, which you just select by checking the checkbox in front of them. In real time scenarios however you normally would have to deal with the amount of 100 to 200 files. You have to agree with me, that 200 clicks in small dialog box are nothing what you dreamed of recently. I’ve had to do it, just to realise the much easier way of avoiding it all. You can count yourself lucky for getting to know the ready result. It is as simple as it gets and shows the solution for adding your model to the public part for NetWeaver installations after SP13 inclusive:
First you have to open the entity editor for the “package_tree” public part as shown above. Then the next window looks like this:
Here you have to select “Folder Tree” as entity type and then select the top folder that contains your services within the “Entities” window. This way all files inside the subfolders will be automatically included in the public part and this way also later available for use in your Web Dynpro application.
The different approach to one and the same result ends here for those of you, who recently just started dealing with those technologies. For the rest of you that have been a bit longer out there, there is one more important thing to keep in mind. To be able to submit and save data in the Composite Application Services you’ll need a reference to the Web Dynpro model in your code. To retrieve a reference you have to access the CAFServiceFactory class. During design time it is no problem to find the class when you import the appropriate DC in the Used DCs of the Web Dynpro Application. In this case the DC we need for this class is caf/UI/ptn/common (com.sap.caf.ui.utils). This would have been enough for all developments before SP12, however after that we also need a sharing reference as shown on the picture below:
Now you’re ready and set to develop CAF – Web Dynpro applications also after upgrading from SP12 to any further service pack.