📚 SAP Business One SDK Help

DataBrowser Operations
See Also

Description

This sample shows how to use the DataBrowser object with the BusinessPartners object.
Private Sub DataBrowserOperations()

    '//****************************************************************************
    '// A Data Browser object can not be created, it is invoked
    '// as a property of a business object.
    '// The BusinessPartners object is used to demonstrate the
    '// use of a DataBrowser object
    '//****************************************************************************

    Dim BusinessPartners As SAPbobsCOM.BusinessPartners

    '//****************************************************************************
    '// A DataBrowser object contains a Recordset object.
    '// Because a DataBrowser Object can not be created,
    '// a Recordset Object should be created and then assigned
    '// (linked) to the Recordset Property of the DataBrowser
    '//****************************************************************************

    Dim oRecordSet As SAPbobsCOM.Recordset

    '// Get a new BusinessPartners object
    Set BusinessPartners = oCompany.GetBusinessObject(oBusinessPartners)
    '// Get a new Recordset object
    Set oRecordSet = oCompany.GetBusinessObject(BoRecordset)

    '// Perform the SELECT statement.
    '// The query result will be loaded
    '// into the Recordset object
    oRecordSet.DoQuery ("Select cardcode from ocrd where cardtype = 'C'")

    '// Asign (link) the Recordset object
    '// to the Browser.Recordset property

    BusinessPartners.Browser.Recordset = oRecordSet

    '// Access the data

    '// Once the Browser points to a row in the
    '// result set you can use the properties directly
    BusinessPartners.CardCode
    BusinessPartners.CardName

    '//Get the next Business Partner

    If BusinessPartners.Browser.EOF = False Then
        BusinessPartners.Browser.MoveNext
    End If

    '//Get the previous Business Partner

    If BusinessPartners.Browser.BoF = False Then
        BusinessPartners.Browser.MovePrevious
    End If

End Sub