public Document getDoucumet1(Database CurDb, Session session,AgentContext agentContext)throws Exception{
Database Configdb = null;
Database SysDb = null;
Document SapConfigDoc = null;
Document Sysdoc = null;
View ConView = null;
View DepView = null;
View ComView = null;
View SysView = null;
String sysdbname = "AIS_Org.nsf";
String depkey = "";
String comkey = "";
try{
String DbPath;
String DbPath1;
DbPath = CurDb.getFilePath();
DbPath = DbPath.substring(0,DbPath.length() - CurDb.getFileName().length());
DbPath1 = DbPath + sysdbname;
DbPath = DbPath + configDbName;
//读取组织库
SysDb = session.getDatabase(CurDb.getServer(),DbPath1,true);
//读取个人配置试图
SysView = SysDb.getView("v_or_deptbyperson_new");
//读取个人配置文档
Sysdoc = SysView.getDocumentByKey(agentContext.getEffectiveUserName().toUpperCase(),true);
depkey = Sysdoc.getItemValueString("ParentCompanyNumber")+"_"+Sysdoc.getItemValueString("TXTINDEPARTMENT");
comkey = Sysdoc.getItemValueString("ParentCompanyNumber");
// System.out.println(depkey+comkey);
//读取配置数据库
Configdb = session.getDatabase(CurDb.getServer(),DbPath,true);
//读取视图
ConView = Configdb.getView("v_or_saplink_byuser");
DepView = Configdb.getView("v_or_saplink_bydep");
ComView = Configdb.getView("v_or_saplink_bycom");
//读取配置文档
SapConfigDoc = ConView.getDocumentByKey(agentContext.getEffectiveUserName().toUpperCase(), true);
if (SapConfigDoc==null){
SapConfigDoc = DepView.getDocumentByKey(depkey, true);
if (SapConfigDoc==null){
SapConfigDoc = ComView.getDocumentByKey(comkey, true);
}
}
return SapConfigDoc;
}catch(Exception e) {
e.printStackTrace();
return null;
}
}
SAP,JAVA环境下RFC调用示例(2)
内容版权声明:除非注明,否则皆为本站原创文章。