on 11-28-2006 10:02 AM
our java code was able to login to SAP client however when executing BAPI, we encountered this error message:
error message: null
Error: , error message: null
java.lang.NullPointerException
Any advice ?
error came from bapi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hai ,
Check once when you are giving exact input parameters to that bapi.
had you check this check list
--> Configure the connection
--> Creating the Repository
--> Setting Input Parameters to BAPI
--> Executing the BAPI
--> Capture the output.
Can you paste your code for reference
regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import java.util.*;
import com.sap.mw.jco.*;
public class HR_ZBAPI_1
{
static private String TEST_FNAME = "ZBAPI_1";
static private String TEST_EMPLOYEENUMBER = "001";
static private Calendar TEST_PRINTDATE = new GregorianCalendar(2006, Calendar.NOVEMBER, 25);
private JCO.Client mConnection;
private JCO.Repository mRepository;
public HR_ZBAPI_1()
{
;
Hi sorry, heres the full code,
many thanks in advance.
import java.util.*;
import com.sap.mw.jco.*;
public class HR_ZBAPI_1
{
static private String TEST_FNAME = "ZBAPI_1";
static private String TEST_EMPLOYEENUMBER = "001";
static private Calendar TEST_PRINTDATE = new GregorianCalendar(2006, Calendar.NOVEMBER, 25);
private JCO.Client mConnection;
private JCO.Repository mRepository;
public HR_ZBAPI_1()
{
;
}
public HR_ZBAPI_1(JCO.Client mConnection, JCO.Repository mRepository)
{
this.mConnection = mConnection;
this.mRepository = mRepository;
}
private String executeFunction(String name) throws Exception
{
JCO.Function function = null;
try
{
function = this.createFunction(name);
function.getImportParameterList().setValue(TEST_EMPLOYEENUMBER, "EMPLOYEENUMBER");
Date printDt = TEST_PRINTDATE.getTime();
function.getImportParameterList().setValue(printDt, "PRINTDATE");
mConnection.execute(function);
JCO.Structure returnStructure = function.getExportParameterList().getStructure("RETURN");
if(! ( returnStructure.getString("TYPE").equals("") ||
returnStructure.getString("TYPE").equals("S") ) //||
//returnStructure.getString("TYPE").equals("W") )
)
{
System.out.println("Return Type: " + returnStructure.getString("TYPE"));
System.out.println("Return Message: " + returnStructure.getString("MESSAGE"));
return returnStructure.getString("MESSAGE");
}
JCO.Table tab = function.getTableParameterList().getTable("ZRESULT");
return "";
}
catch (Exception ex)
{
System.out.println("Execute bapi function error: " + name + ", error message: " + ex.getMessage());
throw ex;
}
}
private JCO.Function createFunction(String name) throws Exception
{
try
{
IFunctionTemplate ft = mRepository.getFunctionTemplate(name.toUpperCase());
return ft.getFunction();
}
catch (Exception ex)
{
System.out.println("Create bapi function error: " + name + ", error message: " + ex.getMessage());
throw ex;
}
}
public static void main (String args[])
{
JCO.Client mConnection;
JCO.Repository mRepository;
String errMessage = null;
try
{
mConnection =
JCO.createClient("", // SAP client
"", // userid
"", // password
""", // language
"", // application server host name
""); // system number
mConnection.connect();
mRepository = new JCO.Repository("1", mConnection);
HR_ZBAPI_1 zbapi1 = new HR_ZBAPI_1(mConnection, mRepository);
errMessage = zbapi1.executeFunction(TEST_FNAME);
mConnection.disconnect();
System.out.println("Main: " + errMessage);
}
catch (Exception ex) {
System.out.println("Error: " + ", error message: " + ex.getMessage());
ex.printStackTrace();
System.exit(1);
}
finally
{
mConnection = null;
mRepository = null;
}
}
}
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.