Implementing Application Service Operations
Use
You need to implement the query methods you have created in the previous step of this tutorial.
Procedure
- Save and generate your application.
- Open the Implementation tab page of the TravelLocationApp application service.
- To open java editor, choose TravelLocationAppBeanImpl.java.
- In the findById method, delete the generated instruction return null; and add the following code:
public com.sap.demo.carpool.modeled.TravelLocation findById(java.lang.Long id) throws com.sap.caf.rt.exception.CAFServiceException { return getTravelLocationService(). findById(QueryFilterFactory.createFilter(id)). iterator().next(); } - In the getAll methos, delete the generated instruction return null; and add the following code:
public java.util.List<com.sap.demo.carpool.modeled.TravelLocation> getAll() throws com.sap.caf.rt.exception.CAFServiceException return getTravelLocationService().findAll(); }
Result
You have implemented your application service operations. Now you need to generate, build and deploy your application. The operations just delegate the call to a business object node operation. In a real application, you may put some pre and postprocessing with custom Java code.
More Information: Generating Code and Building Services .