cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a application service with EHP1 for SAP NetWeaver CE Preview

timobermueller
Explorer
0 Kudos

I ceated a new Composite Application with a Business Object "test" and an Application Service "search" in the Netweaver Development Studio

Business Object - test

In the Tab Structure I added the attributes id:LONG and name:STRING.

Under Operations I added findByName with the Input Parameter name:<anonymous>(String), the Output Parameter Output:test (test as a Complex Type) and the Fault "CAFFindException".

Application Service - search

I added the test BO as a Dependent Object and the Operation findByName with the Input Parameter name:String, thevOutput Parameter erg:test (Complex Type) and the Fault "CAFFindException".

As Business Logic I added the following code:

package com.sap.demo.carpool.modeled.appsrv.search;

import java.util.List;

import com.sap.caf.rt.bol.util.QueryFilterFactory;

@javax.ejb.Stateless(name="com.sap.demo.carpool.modeled.appsrv.search.search")
@javax.ejb.Local(com.sap.demo.carpool.modeled.appsrv.search.searchServiceLocal.class)
@javax.interceptor.Interceptors(com.sap.caf.rt.interceptors.LogInterceptor.class)
public class searchBeanImpl extends com.sap.demo.carpool.modeled.appsrv.search.searchBean{ //$JL-SER$ - static final long serialVersionUID is not declared

    public searchBeanImpl() {

    }
    
	@com.sap.caf.dt.CAFOperation(name="findByName")
	public com.sap.demo.carpool.modeled.Test findByName(java.lang.String name) throws com.sap.caf.rt.exception.CAFServiceException {
		List<Test> out = this.gettestService().findByName(QueryFilterFactory.createFilter(name));
		return out;
	}
	
}

I alway got the error: "Test cannot be resolved to a type" or "Type mismatch: cannot convert from List to Test"

I would be very thankful if you could help me.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Obermueller_T

If you want to return a List you need to configure the cardinality of output parameter of method findByName as 0..n.

Probably the method findByName return just Test Object. In this case, your method return just Test no List<Test>.

Reards

Marcos

timobermueller
Explorer
0 Kudos

Hi Marcos,

thank you so much!!!

After changing the cardinality the return type of the operation "findByName" switches to "java.util.List". Everything is working now!

The code now looks like this:

@com.sap.caf.dt.CAFOperation(name="findByName")
	public java.util.List<com.sap.demo.carpool.modeled.Test> findByName(java.lang.String name) throws com.sap.caf.rt.exception.CAFServiceException {
		java.util.List<com.sap.demo.carpool.modeled.Test> out = this.gettestService().findByName(QueryFilterFactory.createFilter(name));
		return out;
	}

Thank you so much! I'm so happy .... This problem frustrated me ....

Thank you ....

Former Member
0 Kudos

Hi Obermueller_T

Great, you wellcome!!

Don't forget to mark your questions as resolved.

All the Best

Marcos

Answers (0)