null pointer exception

Question: Hi ,
while exceuting this jco.. I am getting Null pointer exception.pls give some solution..
try {

// Get a function template from the repository
IFunctionTemplate ftemplate = repository.getFunctionTemplate("BAPI_PO_GET_LIST");

// Create a function from the template
JCO.Function function = new JCO.Function(ftemplate);

// Get a client from the pool
JCO.Client client = JCO.getClient("R3");

// Fill in input parameters
JCO.ParameterList input = function.getImportParameterList();

input.setValue("02", "REL_GROUP");
input.setValue("02", "REL_CODE");
input.setValue("X", "ITEMS_FOR_RELEASE");

// Call the remote system
client.execute(function);
System.out.println("step6");
// Print return message
JCO.Structure ret = function.getExportParameterList().getStructure("RETURN");
System.out.println("BAPI_PO_GET_LIST RETURN: " + ret.getString("MESSAGE"));

// Get table containing the orders
// JCO.Table pur_orders = function.getTableParameterList().getTable("PO_ADDRESSES");
JCO.Table pur_orders = function.getTableParameterList().getTable("PO_HEADERS");
System.out.println("pur_orders============="+pur_orders);
// JCO.Table pur_orders = function.getTableParameterList().getTable("PO_ITEMS");

Answer:
if you wan't us to solve this problem, you should give us more information.
e.g. post what printStackTrace of the exception prints out.

Answer:
Hi Jane,
I am getting errro:
Caught an Exception:
Java.lang.NullPointerException

Answer:
If you are not able to see 'step6' then i guess you are not able to get the function from R3.

IFunctionTemplate ftemplate = repository.getFunctionTemplate("BAPI_PO_GET_LIST"); --> Fails .

Also its possible that function and client objects are not created( because of some error).


Try this

if (function!=null && client !=null ){

JCO.ParameterList input = function.getImportParameterList();

input.setValue("02", "REL_GROUP");
input.setValue("02", "REL_CODE");
input.setValue("X", "ITEMS_FOR_RELEASE");

// Call the remote system
client.execute(function);
System.out.println("step6");
...Rest of code



}else
{
//print error

}
Copyright ?2007 - 2008 www.jt77.com