Skip to Content
avatar image
Former Member

list items from database

Hi all,

Is there a business object and a method in SAP Business One which allows to list all the items of the database?

The same question for purchase orders...

Thanks for your answer!

F

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    May 18, 2006 at 10:24 AM

    Hi f b,

    You can use the databrowser object for this see the DI sample 01.BasicOperations.

    Regards

    Ad

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 18, 2006 at 12:39 PM

    If you mean listing the items in OITM then SBO also has a

    getitemlist method in the DI. I found the following code as a sample in the DI help text.

    Public Sub TestMethod_GetItemList()
        Dim vObj As SAPbobsCOM.SBObob
        Dim rs As SAPbobsCOM.Recordset
        Dim strResult As String
        Dim errResult As String
        Set vObj =m_company. GetBusinessObject(BoBridge)
        Set rs =m_company. GetBusinessObject(BoRecordset)
        Set rs = vObj.GetItemList()
        strResult = RecorsetToText(rs)
        errResult = GetLastErrorString()
        OutputMessage(strResult, errResult)
    End Sub
    
    This code returns the item code & name only. It actually seems a little more involved than using a browser, though.
    

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 18, 2006 at 01:08 PM

    Hi,

    the GetItemList() method works fine, thanks.

    is there the same thing to obtain the list of purchase order? Or may I use SQL requests?

    Thanks

    F

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      I don't see anything similar for PO's but the data browser is really pretty easy, and if you're are talking about just reading SBO tables, I use SQL directly sometimes without any problems.

      Here's an example of something I did for a data browser to load valid values to a combo box with warehouse code & name: (I don't know if it's "right" - I'm pretty new to SAP coding - or the best way, but it works)

              Dim vWhse As SAPbobsCOM.Warehouses
              Dim vWhseRS As SAPbobsCOM.Recordset
      
              vWhse = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oWarehouses)
              vWhseRS = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
              zCombobox.ValidValues.Add("", "")
      
              Try
                  Dim sql As String = "Select whscode from owhs order by 1"
                  vWhseRS.DoQuery(sql)
                  vWhse.Browser.Recordset = vWhseRS
      
                  Do While vWhse.Browser.EoF = False
      
                      zCombobox.ValidValues.Add(vWhse.WarehouseCode, vWhse.WarehouseName)
                      vWhse.Browser.MoveNext()
      
                  Loop
              Catch ex As Exception
                  MessageBox.Show(ex.ToString)
              End Try
      

      Based on the SBO help text when you use the browser, the sql statement only needs to select the field that is the key (like warehouse code) because when you connect the browser recordset to the warehouse object, all the warehouse properties (fields) are loaded "auto-magically".

      Hope it helps.