Show TOC

Procedure documentationAccess to Tables Locate this document in the navigation structure


In the next step you call the CompanyCode.GetList BAPI and a table of all the company codes is displayed. The corresponding RFM is called BAPI_COMPANYCODE_GETLIST. This RFM does not contain any import parameters.

  1. First, get the table by accessing the table parameter list (getTableParameterList()).

  2. Within this list, access the actual table (getTable()). The interface JCoTable contains all methods that are available for JCoStructure, together with additional methods for navigation in a table. A table can have any number of rows, or can also have no rows. The diagram below shows navigation with the method setRow(), in which the current row pointer is moved to every row in the table in turn. The method getNumRows() specifies how many rows exist in total. Instead of setRow(), you can also use the method nextRow(), as displayed in the lower section of the diagram.

Syntax Syntax

Accessing a Table

  1. public static void step4WorkWithTable() throws JCoException
  2.     {
  3.         JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME2);
  4.         JCoFunction function = destination.getRepository().getFunction("BAPI_COMPANYCODE_GETLIST");
  5.         if(function == null)
  6.             throw new RuntimeException("BAPI_COMPANYCODE_GETLIST not found in SAP.");
  7.         try
  8.         {
  9.             function.execute(destination);
  10.         }
  11.         catch(AbapException e)
  12.         {
  13.             System.out.println(e.toString());
  14.             return;
  15.         }
  17.         JCoStructure returnStructure = function.getExportParameterList().getStructure("RETURN");
  18.         if (! (returnStructure.getString("TYPE").equals("")||returnStructure.getString("TYPE").equals("S"))  )   
  19.         {
  20.            throw new RuntimeException(returnStructure.getString("MESSAGE"));
  21.         }
  23.         JCoTable codes = function.getTableParameterList().getTable("COMPANYCODE_LIST");
  24.         for (int i = 0; i < codes.getNumRows(); i++) 
  25.         {
  26.             codes.setRow(i);
  27.             System.out.println(codes.getString("COMP_CODE") + '\t' + codes.getString("COMP_NAME"));
  28.         }
End of the code.