点击此处---> 群内免费提供SAP练习系统(在群公告中)
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
嗨,
我尝试使用DI API发送消息,我在SAP \ SAP Business One SDK \ Samples \ COM DI \中引用示例\ VB.NET \ 10.Messages Service,但是当我尝试运行时,出现错误 java.lang.ClassCastException:com.sap.smb.sbo.wrapper.com.Dispatch无法投射 到com.sap.smb.sbo.api.IMessage
这是我的Java编码:
IMessage oMessage = null;
IMessageDataColumns pMessageDataColumns = null;
IMessageDataColumn pMessageDataColumn = null;
IMessageDataLines oLines = null;
IMessageDataLine oLine = null;
IRecipientCollection oRecipientCollection = null;
尝试{
ICompanyService oCompany = company.getCompanyService();
IMessagesService oMsgServ = SBOCOMUtil.newMessagesService(oCompany);
//获取新消息的数据接口
oMessage =(IMessage)oMsgServ.getDataInterface(SBOCOMConstants.MessagesServiceDataInterfaces_msdiMessage);
//填写主题
oMessage.setSubject(" Test");
oMessage.setText("测试发送消息");
//添加收件人
oRecipientCollection = oMessage.getRecipientCollection();
oRecipientCollection.add();
//发送内部消息
oRecipientCollection.item(0).setSendInternal(SBOCOMConstants.BoYesNoEnum_tYES);
//添加现有用户名
oRecipientCollection.item(0).setUserCode(" manager");
//获取列数据
pMessageDataColumns = oMessage.getMessageDataColumns();
//获取列
pMessageDataColumn = pMessageDataColumns.add();
//设置列名
pMessageDataColumn.setColumnName("订单号");
//在应用程序pMessageDataColumn.setLink(SBOCOMConstants.BoYesNoEnum_tYES)中设置到真实对象的链接;
//获取行
oLines = pMessageDataColumn.getMessageDataLines();
//添加新行
oLine = oLines.add();
//设置行值
oLine.setValue(" 155");
//将链接设置为BusinessPartner(Bp的对象类型为2)
oLine.setObject(" 2");
//设置Bp代码
oLine.setObjectKey(" DocEntry");
//发送消息
oMsgServ.sendMessage(oMessage);
} catch(异常e){
e.printStackTrace();
}
对象oMessage;
//获取新消息的数据接口
oMessage = oMessageSrv.getDataInterface(SBOCOMConstants.MessagesServiceDataInterfaces_msdiMessage); IMessage iMessage =新消息(oMessage);
一周热门 更多>