java.util.HashMap cannot be cast to com.sap.conn.jco.JCoTable 50
privateJCoTabletable=(JCoTable)newHashMap();我想new一个JCoTable,可是直接JCoTabletable=newJCoT...
private JCoTable table = (JCoTable) new HashMap();
我想new
一个JCoTable ,可是直接JCoTable table = new JCoTable()是不行的,这个要怎么new呢 展开
我想new
一个JCoTable ,可是直接JCoTable table = new JCoTable()是不行的,这个要怎么new呢 展开
2个回答
展开全部
Properties logonProperties = new Properties();
logonProperties.put("jco.client.ashost", "10.10.11.22");
logonProperties.put("jco.client.client", "100");
logonProperties.put("jco.client.sysnr", "01");
logonProperties.put("jco.client.user", "username");
logonProperties.put("jco.client.passwd", "password");
File file = new File("sapconnection.jcoDestination");
FileOutputStream stream = new FileOutputStream(file, false);
logonProperties.store(stream, "SAP connection properties");
stream.close();
JCoDestination destination = JCoDestinationManager.getDestination("sapconnection");
JCoRepository repository = destination.getRepository();
JCoFunction function = repository.getFunction("Z_SD_XXXX");
JCoParameterList list = function.getImportParameterList();
//设置输入参数
list.setValue("PLANT", "1000");
...
function.execute(destination);
JCoTable rs = function.getTableParameterList().getTable("TABLE_HEAD");
//获取输出
List<HeadBean> sh = new ArrayList<HeadBean>();
for (int i = 0; i < rs.getNumRows(); i++) {
rs.setRow(i);
HeadBean s = new HeadBean();
s.setCompanyCode(rs.getString("COMPANY_CODE"));
s.setSalesOrg(rs.getString("SALES_ORG"));
...
sh.add(s);
}
参考:http://joeblow.iteye.com/blog/679775
logonProperties.put("jco.client.ashost", "10.10.11.22");
logonProperties.put("jco.client.client", "100");
logonProperties.put("jco.client.sysnr", "01");
logonProperties.put("jco.client.user", "username");
logonProperties.put("jco.client.passwd", "password");
File file = new File("sapconnection.jcoDestination");
FileOutputStream stream = new FileOutputStream(file, false);
logonProperties.store(stream, "SAP connection properties");
stream.close();
JCoDestination destination = JCoDestinationManager.getDestination("sapconnection");
JCoRepository repository = destination.getRepository();
JCoFunction function = repository.getFunction("Z_SD_XXXX");
JCoParameterList list = function.getImportParameterList();
//设置输入参数
list.setValue("PLANT", "1000");
...
function.execute(destination);
JCoTable rs = function.getTableParameterList().getTable("TABLE_HEAD");
//获取输出
List<HeadBean> sh = new ArrayList<HeadBean>();
for (int i = 0; i < rs.getNumRows(); i++) {
rs.setRow(i);
HeadBean s = new HeadBean();
s.setCompanyCode(rs.getString("COMPANY_CODE"));
s.setSalesOrg(rs.getString("SALES_ORG"));
...
sh.add(s);
}
参考:http://joeblow.iteye.com/blog/679775
追问
我要的只是new一个JCoTable table,连接SAP接口啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询