cancel
Showing results for 
Search instead for 
Did you mean: 

Nothing returned from BAPI call

Former Member
0 Kudos

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();
    }
}

Accepted Solutions (0)

Answers (2)

Answers (2)

guru_subramanianb
Active Contributor
0 Kudos

Hi Ian,

Did u get all your system.out.println getting printed on your console?

What does "Message" contains in your back end.I am guessing it is a structure of Data.

Did you bind your context attribute properly I mean your input and output parameters.

Rdgs,

G

gregorw
Active Contributor
0 Kudos

Hello Ian,

what is retured from this BAPI when you run it in Test mode in Transaction SE37?

Regards

Gregor

Former Member
0 Kudos

It seems that all the results are returned in the table parameter list. So I needed to call function.getTableParameterList() instead of function.getExportParameterList().

Is their any standard with BAPIs about how you can check for successful completion of a call? It seems in other examples I've looked at the RESULT has been part of the Export parameter list?

gregorw
Active Contributor
0 Kudos

Hello Ian,

in the most cases you will get a Parameter RETURN. But it can also be a Table Parameter RETURN if there are more Messages. The Return-Type should be "S" if the call was sucessfull. But it can also be space.

Regards

Gregor