Skip to Content
0
Former Member
Aug 15, 2005 at 06:13 PM

Nothing returned from BAPI call

39 Views

Hi - I'm new to SAP and have just installed 6.4 Sneak Preview and JCo. I'm trying to call the example BAPI BAPI_FLBOOKING_GETLIST but am getting nothing returned. There is data in the system as I can view it through the SAP GUI. The ExportParameterList on the returned function is always null. No errors are thrown. Any ideas - I seem to be connecting successfully and can query the metadata.

Below is my the code I'm using.

TIA

Ian

import com.sap.mw.jco.IFunctionTemplate;
import com.sap.mw.jco.JCO;

public class SAP_Test_1 {
    JCO.Repository repository;
    
    /** Creates a new instance of SAP_Test */
    public SAP_Test_1() {
        JCO.Client connection = null;
        try {
            connection = JCO.createClient("000", "BCUSER",  "minisap", "EN", "developer", "NSP"); // system number
                     
            repository = new JCO.Repository("MyRepository", connection);

            IFunctionTemplate ft = repository.getFunctionTemplate("BAPI_FLBOOKING_GETLIST");
            JCO.Function function = ft.getFunction();
            connection.execute(function);
            
            if (function.getExportParameterList() == null) {
                // ***************** THIS ALWAYS HAPPENS *****************
                System.out.println("No data returned");
            } else {
                JCO.Structure returnStructure = function.getExportParameterList().getStructure("RETURN");
                 if (! (returnStructure.getString("TYPE").equals("") ||
                    returnStructure.getString("TYPE").equals("S")) ) {
                     System.out.println(returnStructure.getString("MESSAGE"));
                }
            }            
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (connection != null) {
                connection.disconnect();
            }
        }
        
    }
    
    public static void main( String[] args ) {
        new SAP_Test_1();
    }
}