on 03-30-2009 3:55 AM
在UI开发中,如何获取当前窗体,并根据当前窗体获得当前DI对象?如:如何确定我的当前窗体是采购订单,
并知道我在处理的当前窗体的对应的采购订单的DI对象?当我在点击工具栏上的打印按钮时我可以捕获这个对象并对之进行相应的处理?
1. 获取当前窗体的表名很简单吧 打开视图的系统信息 在相应单据的窗口最下方就可以显示出来了
2. DI对象在后台数据库的对应表 查询'OBJECT_TYPE'字段即可
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
目前无法做到从UI对象直接获取DI对象,可以通过获取UI某控件的值,然后使用DI API来GetByKey获得相应DI对象
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
你好,
监听FormDataEvent吧,在B1开始处理时,启动一个事务,在B1在界面已经添加订单,但事务还未提交,此时可以通过FormDataEvent事件的BusinessObjectInfo或是oCompany.GetNewObjectCode(objectKey)
可以获得所加订单的DocEntry,然后再通过GetByKey()就可以获得与当前UI上关联订单了。
代码示范:
Private Sub FormDataEventHandler( _
ByRef BusinessObjectInfo As SAPbouiCOM.BusinessObjectInfo, _
ByRef BubbleEvent As Boolean) Handles oApp.FormDataEvent
'You may add the target documents, 133 - A/R invoice.
'Before action = true, start the transation
If BusinessObjectInfo.FormTypeEx = "133" _
And BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD _
And BusinessObjectInfo.BeforeAction = True Then
oCompany.StartTransaction()
'BubbleEvent = False
End If
'Before Action = false,
'Update product item tree
'Succeed, commit, otherwise rollback
If BusinessObjectInfo.FormTypeEx = "133" _
And (BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD) Then
If BusinessObjectInfo.BeforeAction = False And BusinessObjectInfo.ActionSuccess Then
Dim objectKey As String = String.Empty
oCompany.GetNewObjectCode(objectKey)
MsgBox(BusinessObjectInfo.Type)
Dim oInvoice As SAPbobsCOM.Documents = Nothing
oInvoice = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)
If oInvoice.GetByKey(CInt(objectKey)) Then
'Retrieve the UDF value in documents
Dim udfValueInDoc As String = oInvoice.UserFields.Fields.Item("***").Value
Dim oJE As SAPbobsCOM.JournalEntries = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries)
'Retrieve the JE for the document
oJE.GetByKey(CInt(oInvoice.JournalMemo))
Dim succeeded = True
'----------------------------------------------------------------------
'add you code to copy the UDF from document into JE
'----------------------------------------------------------------------
If succeeded Then
'update the production tree succesfully,
oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit)
Else
oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
End If
End If
End If
End If
End Sub
Regards, Yatsea
谢谢楼上的回答!不过我说的是窗体对应的DI对象,比如采购订单的窗体,我想获取对应的PurchaseOrder 的DI对象
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
在sbo的菜单栏中,选择u201C视图u201C>>u201D系统信息u201C
在左下角将会看到Form = ..... Item =.....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.