SAP,JAVA环境下RFC调用示例(二)

2014-11-24 03:08:13 · 作者: · 浏览: 15
r_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;
}
}


public void DelInfo(Database db,String pobh)
{
try
{

View view=db.getView("v_key_tx");
DocumentCollection dc =view.getAllDocumentsByKey(pobh, true);
if (dc.getCount()>0){
dc.removeAll(true);
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}

//用关键字返回文档
public Document ReturnTypeDoc(Database db,String Key,String vname) throws Exception{

Document DateDoc = null;
View SearchSubView = null;

Vector SearchKey = new Vector();

try{
SearchSubView = db.getView(vname);
SearchSubView.refresh();
SearchKey.addElement(Key);

DateDoc = SearchSubView.getDocumentByKey(SearchKey,true);

if (SearchSubView != null){
SearchSubView.recycle();
}
SearchKey = null;

if (DateDoc != null){
return DateDoc;
}else{
return null;
}



}catch(Exception e) {
e.printStackTrace();
return null;
}
}

public Document getDoucumet(Database CurDb, Vector SapSearchKey, Session session)throws Exception{

Database Configdb = null;
Document SapConfigDoc = null;
View ConView = null;
try{
String DbPath;
DbPath = CurDb.getFilePath();
DbPath = DbPath.substring(0,DbPath.length() - CurDb.getFileName().length());
DbPath = DbPath + configDbName;

//读取配置数据库
Configdb = session.getDatabase(CurDb.getServer(),DbPath,true);
//读取视图
ConView = Configdb.getView(viewName);
//读取配置文档
SapConfigDoc = ConView.getDocumentByKey(SapSearchKey, false);
return SapConfigDoc;
}catch(Exception e) {
e.printStackTrace();