Skip to Content
author's profile photo Former Member
Former Member

how Adding record (Usertable or Systemtable)

hello people of the forum, I need an example of like I add registrations to "usertable" or "systemtable" , I have looked for a lot, but I don't have left clear with the examples that exist.

thank you from already.

excuse for my bad english (power translator :o)= )

I have something like that, but it doesn't work :o(=

oUserTable:= oCompany. UserTables.Item('tablename') ;

oUserTable.UserFields.Fields.Item('field1').Value:= empid;

//empid, lastname, firstname is a edit from SBO

oUserTable.UserFields.Fields.Item('field2').Value:= lastname;

oUserTable.UserFields.Fields.Item('field3').Value:= firstname;

ousertable.Add;

thanks.

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 21, 2004 at 05:13 PM

    Hola Francisco,

    esso es un ejemplo que tambien puedes encontrar en la ayuda de la DI.

    Para creer una tabla, tienes que utilizar el objecto UserTablesMD :

    Dim oUserTablesMD As SAPbobsCOM.UserTablesMD

    oUserTablesMD = oCompany.GetBusinessObject(oUserTables)

    oUserTablesMD.TableName = "El nombre de tu tabla"

    oUserTablesMD.TableDescription = "un descripcion"

    oUserTablesMD.Add

    Para agregar un field, con el objecto UserFieldsMD

    Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD

    oUserFieldsMD = oCompany.GetBusinessObject(oUserFields)

    oUserFieldsMD.TableName = "TableName"

    oUserFieldsMD.Name = "Fied name"

    oUserFieldsMD.Description = "A user field"

    oUserFieldsMD.Type = db_Alpha '// am alphanumeric type

    oUserFieldsMD.EditSize = 20

    oUserFieldsMD.Add

    Puedes carguar la ayuda de la DI aqui (esso viene de la pagina inicia de Business One en esta sitio) https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/business_packages/a1-8-4/busonesdk_di_65_en.chm

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Sorry, I made a mistake, that was to create User Defined Table.

      To add data in a system table, you have to get its UI object :

      Exemple to add a Business Partner

      Dim vBP As SAPbobsCOM.BusinessPartners

      Set vBP = vCompany.GetBusinessObject(oBusinessPartners)

      vBP.CardCode = "HU1003"

      vBP.CardName = "ABCD"

      vBP.CardType = cCustomer

      If (0 <> vBP.Add()) Then

      vCompany.GetLastError(nErr, errMsg)

      MsgBox ("Failed to add an business partner" & vbCrlf & errMsg)

      else

      Dim objCode As String

      MsgBox ("Succeeded add a business parnter, new objcode=" + vBP.CardCode)

      End If

      Exemple to add an Item

      Dim vItem As SAPbobsCOM.Items

      Set vItem = vCmp.GetBusinessObject(oItems)

      'Set value to mandatory fields:

      vItem.ItemCode = "MyNewItem"

      'Set Value to other fields

      vItem.ItemName = "MyNewItem Name"

      vItem.WhsInfo.WarehouseCode = "01"

      'Checking the result

      If vItem.Add <> 0 Then

      vCmp.GetLastError ErrCode, ErrMsg

      MsgBox ErrCode & " " & ErrMsg

      End If

  • author's profile photo Former Member
    Former Member
    Posted on Dec 21, 2004 at 05:41 PM

    Hola Sebastian, muchas gracias por tu ejemplo, ya lo habia considerado.

    Lo que necesito es como insertar un registro en la tabla.

    intente con un recordset.doquery (insert into table campo1 values (campo1)), pero no me funciono.

    como puedo hacer eso.

    INSERT INTO TABLE ......

    gracias.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Si, disculpe....

      ya te di un ejemplo por une objecto system (la respuesta de mi primero post..),

      aqui es por una User defined table

      Dim oTable As SAPbobsCOM.UserTable

      oTable = vCmp.UserTables.Item("MyUserTable")

      oTable.Code = MyCode

      oTable.Name = MyName

      oTable.UserFields.Fields.Item("Your Field Name 1)=myValue1

      oTable.UserFields.Fields.Item("Your Field Name 2)=myValue2

      ...

      If oTable.Add<>0 Then

      vCmp.GetLastError ErrCode, ErrMsg

      MsgBox ErrCode & " " & ErrMsg

      end if

      Tienes que saber que una User Defined Table, tiene cada vez los fields Code y Name.

  • author's profile photo Former Member
    Former Member
    Posted on Dec 21, 2004 at 06:03 PM

    thanks Sebastian

    muchas gracias.

    intentare de la forma propuesta.

    ;o)=

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.