cancel
Showing results for 
Search instead for 
Did you mean: 

UI开发中,如何获取当前窗体,并根据当前窗体获得当前DI对象?

Former Member
0 Kudos

在UI开发中,如何获取当前窗体,并根据当前窗体获得当前DI对象?如:如何确定我的当前窗体是采购订单,

并知道我在处理的当前窗体的对应的采购订单的DI对象?当我在点击工具栏上的打印按钮时我可以捕获这个对象并对之进行相应的处理?

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

1. 获取当前窗体的表名很简单吧 打开视图的系统信息 在相应单据的窗口最下方就可以显示出来了

2. DI对象在后台数据库的对应表 查询'OBJECT_TYPE'字段即可

Former Member
0 Kudos

目前无法做到从UI对象直接获取DI对象,可以通过获取UI某控件的值,然后使用DI API来GetByKey获得相应DI对象

Former Member
0 Kudos

但是,在窗体对象上应该获取不到DocEntry,并且即使获取得到,也不能用GetByKey获取吧,因为这时应该还没有提交到数据库呢吧?

Former Member
0 Kudos

你是不是想获取还未提交到数据库的对象?

如果想在提交之前对数据操作的话,截获Button click事件,当before_event = true 时用UI API对form上的matrix操作。

或者当before_event = false也就是当B1操作完成,提交数据之后,用DI API操作数据库

YatseaLi
Product and Topic Expert
Product and Topic Expert
0 Kudos

你好,

监听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

Former Member
0 Kudos

您理解的跟我所说的意思一致

Former Member
0 Kudos

这个方法看起来可行,回头我试下。谢谢您!

Former Member
0 Kudos

谢谢楼上的回答!不过我说的是窗体对应的DI对象,比如采购订单的窗体,我想获取对应的PurchaseOrder 的DI对象

Former Member
0 Kudos

一个很简单的办法:在sdk的帮助中搜索u201C表名u201D 有很多主题列出来,那么找到 ...... object 这样的就好了

Former Member
0 Kudos

在sbo的菜单栏中,选择u201C视图u201C>>u201D系统信息u201C

在左下角将会看到Form = ..... Item =.....