on 11-28-2006 4:23 PM
Hi all -
I am having some difficulty with calling BAPI_CATIMESHEETMGR_INSERT via JCo.
Here is a sample method I am trying to call (note that this won't run as posted since I have other dependent classes not included).
I get a null pointer exception in the call to mConnection.execute(_function);
Is there anything obvious that I am missing?
Does anyone have some sample code using this BAPI?
public static void insertCATSRecord() {
//method label
String methodLabel = "SAPStepHandler::insertCATSRecord";
CATSRecord _cats = new CATSRecord();
// JCO functions and tables
JCO.Function _function = null;
JCO.Table _tab = null;
try {
SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");
SimpleDateFormat df2 = new SimpleDateFormat("HH:mm");
function = createFunction("BAPICATIMESHEETMGR_INSERT");
if (_function == null){
user.log("Function BAPICATIMESHEETMGR_INSERT not found in SAP");
}
JCO.Client mConnection = _user.mConnection();
//JCO.ParameterList imports = _function.getImportParameterList();
//JCO.Field profile = imports.getField("PROFILE");
//profile.setValue("BASIC");
_tab = function.getTableParameterList().getTable("CATSRECORDSIN");
_tab.appendRow();
_tab.setRow(0);
_tab.setValue(df.parse("11/28/2006"), "WORKDATE");
_tab.setValue("1602", "EMPLOYEENUMBER");
tab.setValue("0210", "ABSATT_TYPE");
_tab.setValue(2, "CATSHOURS");
_tab.setValue(df2.parse("15:00"), "STARTTIME");
_tab.setValue(df2.parse("17:00"), "ENDTIME");
tab.setValue("1000", "COAREA");
// the BAPI says we have to explicitly set numeric fields to 0
tab.setValue(0, "POITEM");
_tab.setValue(0, "PRICE");
tab.setValue(0, "REMWORK");
tab.setValue(0, "VALUATIONBASIS");
_tab.setValue(0, "BONUSVALUE");
_tab.setValue(0, "POSITION");
_tab.setValue(0, "RECITEM");
_tab.setValue(0, "TRIPNO");
//_tab.setValue(0, "FCST_FIN_DATE");
_tab.setValue(0, "QUANTITY");
_tab.setValue(0, "AMOUNT");
_tab.setValue(0, "SPLIT");
mConnection.execute(_function);
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
Thanks in advance!
Dave
oops, nevermind. I had a simple java cut and paste error in my test code. The variable that I was using for the connection was not the one I had initialized in the connection pool.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.