Use JavaAction + Jco to Call SAP RFC. How to return a List ?

Because of the old sap version, I have to use JavaAction + Jco to call “SAP RFC”, and cannot use "Mendix SAP OData Connector". My requirement: Find the required data according to the input parameters Input : String Ouput : List Example: Part of the code is as follows: public static void accessTable() throws JCoException { JCoDestination destination = JCoDestinationManager.getDestination(ABAP_AS_POOLED); //RFC Name JCoFunction function = destination.getRepository().getFunction("ZRFC_TEST_JCO_SELECT"); //Set Parameter function.getImportParameterList().setValue("CARRID", "LH"); if(function == null) throw new RuntimeException("ZRFC_TEST_JCO_SELECT not found in SAP."); //Execute try { function.execute(destination); } catch(AbapException e) { System.out.println(e.toString()); return; } JCoTable exportTable = function.getTableParameterList().getTable("DATA"); exportTable.firstRow(); //Print column for(int i = 0; i < exportTable.getMetaData().getFieldCount(); i++) { System.out.print(exportTable.getMetaData().getName(i) + " " ); } System.out.println(); //Print Result for(int j = 0; j< exportTable.getNumRows();j++) { for(int k = 0; k < exportTable.getMetaData().getFieldCount(); k++) { System.out.print(exportTable.getString(k) + " " ); } exportTable.nextRow(); System.out.println(); } } Result:   But I have some questions, How to convert data to “Mendix List” and return it? How to convert data to “Mendix Object” and return it?
1 answers

To get a Mendix object, I would use the proxy classes that are generated for all the entities in the domain model. Create an object using one of these, then use the getMendixObject() method on it to get the Mendix object back. 

To create a list, I would just create an ArrayList of IMendixObject and add the objects you created to that and return it.

For example, if you have a SapData entity in your domain model, with a Name attribute, you could use something like this to create the object, set the attribute, add it to a list, and return it in a Java action.

List<IMendixObject> returnList = new ArrayList<IMendixObject>();
SapData sapData = new SapData(this.getContext());
return returnList;

Hope this helps