SAP接口的几个注意事项

最近写sap接口,发现他真不好用,没办法,工作要求,先说基本用法:
1,设置接口信息:
//SRM 生产环境
private static Properties setSRMProdProperties() {
Properties connectProperties = new Properties();
connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, “10.138.1.26”);// IP
connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, “00”);// 系统编号
connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, “800”);//客户端编号
connectProperties.setProperty(DestinationDataProvider.JCO_USER, “jiance27”);//用户名
connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, “20082008”);//密码
connectProperties.setProperty(DestinationDataProvider.JCO_LANG, “ZH”);//语言
return connectProperties;
}
2,设置目的地,
DestinationDataProviderImpl destDataProvider = new DestinationDataProviderImpl();
destDataProvider.addDestinationProperties(“SAP”, propertiesSAP);
destDataProvider.addDestinationProperties(“HS1”, propertiesSRM);
Environment.registerDestinationDataProvider(destDataProvider);
注意:
1 Environment.registerDestinationDataProvider(destDataProvider);这是个单例的方法,如果有值了再调就会报错,
所以在设置Destination的时候要将所有的目的地一次性全部放进去,如上实例
本人当时调用有问题,把源码看了一遍才发现.
2,接口返回结果
for(bean b: list){
JCoTable returnStructure =function.getTableParameterList().getTable(“OUTPUT”);
for (int i = 0; i < returnStructure.getNumRows(); i++) {
returnStructure.setRow(i);
bean.set属性1( returnStructure.getString(“NUM1”));//设置值
}
}
注意:这里的结果returnStructure 假如是循环调用,那么这个结果是所有的循环的结果的list, 意思是说每个循环都会把之前的结果都保存而不会只返回本次的结果.

猜你喜欢

转载自blog.csdn.net/bufanrong/article/details/85122826
今日推荐