on 08-06-2009 9:01 AM
I've a problem when i try to read out a complex data structure in Netweaver Developer Studio CE 7.1 Preview Version:
I created a BO called 'Employee' with the attributes firsname and lastname.
A new complex data structure called 'EmployeeOut' contains the regular 'Employee' structure with the cardinality 0..n, named 'Out'
Next I set up an Application Service called 'EmployeeApp', wich contains the function 'getAllEmployees': The Output parameters is set to the new structure 'EmployeeOut' (moreover Dependencies of the 'EmployeeApp' is set to the BO 'Employee').
The function 'getAllEmployees' contains the following Code:
@com.sap.caf.dt.CAFOperation(name="getAllEmployees")
public com.sap.demo.demo.modeled.EmployeeOut getAllEmployees() throws com.sap.caf.rt.exception.CAFServiceException {
EmployeeOut response = new EmployeeOut();
List<Employee> employeeOut = new ArrayList<Employee>();
employeeOut = (List<Employee>)this.getEmployeeService().findAll();
response.setOut(employeeOut);
return response;
}
The Service-Test, in the Service Browser, shows that everything works fine.
Now I expose the EmployeeApp as a WebService and import this one into another Application Service 'EmployeeCall' without any Problem.
I map the Operation 'getAllEmployees' succesful. Then I create another operation and want to read out the firstname and the lastname. But how can i do this?
How can I call the Service Operation? Somthing like: this.getAllEmployees() ...?
Best Regards
Tim
Hi,
It is possible to map specific fields as well (if you have tried already).
Another way is call local getAllEmployee() directly and then extract fields from response.
>response = getAllEmployee();
>firstname = response.getFirstName();
>lastname = response.getLastname();
>//do whatever you want to do
Regards,
Gourav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gourav,
Thank you very much ...
I solved the problem, the code now looks like this:
@com.sap.caf.dt.CAFOperation(name="employeeCall")
public java.util.List<com.sap.demo.call.modeled.Output> employeeCall() throws com.sap.caf.rt.exception.CAFServiceException {
GetAllEmployees employeesOut = new GetAllEmployees();
List<Employee> employeeList = this.getAllEmployees(employeesOut.getGetAllEmployees()).getGetAllEmployeesResponse().getOut();
List<Output> response = new ArrayList<Output>();
for(Employee h : employeeList){
Output tmp = new Output();
tmp.setFirstname(h.getFirstname());
tmp.setLastname(h.getLastname());
response.add(tmp);
}
return response;
}
I think this is what you mean ....
Thank you very much ...
Best Regards
Tim
Hi Gourav,
when I put the "Output tmp = new Output();" out of the for-loop, every dataset is the same.
I think you have to create a new Output-Object in any for-step, because you have to put all the single datasets one by one in the list.
While leaving this line in the for-loop everything works fine.
But thank you for yout tip!
Best Regards
Tim
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.