Skip to Content

Reading out complex data structures

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Aug 06, 2009 at 08:29 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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