Showing results for 
Search instead for 
Did you mean: 

Add row in a usertable

Former Member
0 Kudos


I have this code from the only example in SDK Help but it does not work:

oRegHist = oCompany.UserTables.Item(1)


'Set default, mandatory fields

oRegHist.Code = "RGST"

oRegHist.Name = "Historico"

'Set user field

oRegHist.UserFields.Fields.Item("U_FECHA").Value = datFecha

oRegHist.UserFields.Fields.Item(intIndice + 1).Value = 1

intResult = oRegHist.Add()

but since the example does not explain anything clearly I do not understand what Item(1) is, wht exactly oRegHist.Name or Code are and I am getting an error "-1 Documente UserTable can not add row".

What am i doing wrong?

Thanks a lot

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos


Try this one

oUserFieldsMD.TableName = "Table Name"

oUserFieldsMD.Name = "Field Name"

oUserFieldsMD.Description = "Field Description"

oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Alpha

oUserFieldsMD.EditSize = 10

lRetCode = oUserFieldsMD.Add


Billa 2007

Answers (7)

Answers (7)

Former Member
0 Kudos

Yes, I got this and I can create the structure. Ok.

But how can I give a value to oUserTable. ?? Fields("PartenerDesc") . ??

It has no properties I think valid to add data

Former Member
0 Kudos


You can try--

public SAPbobsCOM.UserTablesMD oUserTablesMD;

public SAPbobsCOM.UserFieldsMD oUserFieldsMD;

oUserTablesMD = (SAPbobsCOM.UserTablesMD )oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);

oUserTablesMD.TableName ="ABC";

oUserTablesMD.TableDescription ="asdas";




oUserFieldsMD.Name="epartner" ;




oUserFieldsMD.Size = 20;


Former Member
0 Kudos

Thanks, Yatsea. I was looking for information there but I cannot see that add, remove ... methods and at the end of all, they use a UPDATE sentence! :-???

I thought creating an object would avoid using plain SQL.

I have no problem with SQL (you know, I have data, I have a table, I have SQL, i have it all) but i suppossed it was not the way.

So defining my object and getting an instance,

Dim oRegHist As SAPbobsCOM.UserObjectsMD

oRegHist = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD)


how can I change a simple field and update it? (something like the next two lines, I know there is not UserField property)

oRegHist.UserFields.Fields.Item(intIndice).value = 1

intResult = oRegHist.Update()

If it is not posible and I have to execute an update, ok. I just want to stop spreading points everywhere xD

Thanks a lot

Former Member
0 Kudos

I tried, i really tried, but I have a evidently lack of information and I did not find the object to use.

I supose object get created somewhere but where? in a dll? If so, in which dll? Not? Then where?

Creating it, SAP asked me for a dll path. Where can I configure that? Does Dll get created there?

If you can tell me where to look for ...

Then I proved how people creates UDO's and gives it new columns but ... how can i insert data?

Here (in forum) there is so much information but not so complete as a beginner as me need :S

Thanks a lot.

Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Luis,

No worry. Actually you may refer to SDK onlin help for information about UDO.

Contents=>Customization Tools=>User-Defined Objects

B1 has already provided the default implementation of Add, Update, Find etc, You don't need to provide a DLL path in most cases, unless you would like to overwrite the function Add, Update, Remove etc. Please refer to SDK sample for how to use UDO and Form together after you have insatll SDK component.

<<C:\Program Files\SAP\SAP Business One SDK\Samples\UDO\BlanketAgreement>>

Kind Regards


Former Member
0 Kudos

Whatever code?

Whatever name?

Sorry but i am proving everything you say and everything i think about and i do not get anything different to that error.

Anything important to have in mind while creating the table?

There is something i am doingo wrong but i do not get it.

Trying to start from the beginning ...

In UDT definition:

- Table Name: RGST.

- Description: RegEnvios

- Object Type: Document (maybe none object??)

I add 10 fields, all integer type, EA1, EA2, ET1, ET2, ET3, RA1, RA2, RT1, RT2, RT3.

In user-object registry (is it necessary??):


- Name: RGST.

- Type: Document.

- Table: RGST.

Truely, thanks so much ...

Product and Topic Expert
Product and Topic Expert
0 Kudos


only NoObject type UDT can use UserTable to add rows. Master Data or Document Data Type UDT is not allowed to do so. You may try RecordSet in this case.

By the way, have you tried to use UDO, then set the UDO type to the form and bind the form with the relevant table. Thus B1 provide the default Add, Update, Find functions that you don't need to care how to add a record.

Kind Regards, Yatsea

Former Member
0 Kudos

But UDT.Name and UDT.Code, ¿for the record?

I really do not understand.

Active Contributor
0 Kudos


in a usertable you have always a Code and Name column !

open a usertable in SAP and you see that.

you cant add a row - also in SAP frontend - when you don't enter the two columns

got it ?

lg David

Active Contributor
0 Kudos


i think you missunderstood something.

how you name the Object is up to you

look at my sample how i add a new row to a usertable - i named the object "UDT":

SAPbobsCOM.UserTable UDT
UDT.Code ="newCode"
UDT.Name ="newName"
UDT.UserFields.Fields.Item("U_UDF").Value ="Value"

GetByKey you need to Update a existing record !

SAPbobsCOM.UserTable UDT
UDT.UserFields.Fields.Item("U_UDF").Value ="NewValue"

i hope it helps you

lg David