JCO事务管理

/*
* 标准对账单过账
* @account 标准对账单号
* @year 年度
*/
public List<String> doAccountStatmentPost(String account,String year) throws JCoException{
JCoDestination destination = JCOUtil.getDestination();
JCoFunction function = destination.getRepository().getFunction("BAPI_INCOMINGINVOICE_POST");
if (function == null) {
throw new RuntimeException("BAPI_INCOMINGINVOICE_POST not found in SAP.");
}
//设置参数-对账单号
function.getImportParameterList().setValue("INVOICEDOCNUMBER", account);
//设置参数-年度
function.getImportParameterList().setValue("FISCALYEAR", year);
//<开始SESSION>
JCoContext.begin(destination);
//调用函数
function.execute(destination);
JCoTable jcoTable1 = function.getTableParameterList().getTable("RETURN");
List<String> errorMessages = new ArrayList<String>();
for (int i = 0; i < jcoTable1.getNumRows(); i++) {
jcoTable1.setRow(i);
errorMessages.add("TYPE:"+jcoTable1.getString("TYPE")+" MESSAGE:"+jcoTable1.getString("MESSAGE"));
}
if(jcoTable1.getNumRows()==0){
JCoFunction function2 = destination.getRepository().getFunction("BAPI_TRANSACTION_COMMIT");
function2.getImportParameterList().setValue("WAIT", "X");
function2.execute(destination);
}
//<结束SESSION>
JCoContext.end(destination);
return errorMessages;
}
/*

上一篇:BZOJ 1103: [POI2007]大都市meg( 树链剖分 )


下一篇:SQL Server代理(1/12):配置和概况