Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Error: Ref count for this object is higher then 0

Hello All,

I am trying to create User Defined Tables in SAP through Coding but while running the code the error "Ref count for this object is higher then 0 " is showing .

I have created a temporary table in which the Table Description are stored as follows :-

Create Table Test_Table (TblCode Varchar(30),TblName Varchar(100),TblType int)

From this table then using recordset i am getting the table details for creation :-

oRecord.DoQuery("Select TblCode,TblName,TblType From Csv_UDT")

While Not oRecord.EoF

Dim Table_Id As String = oRecord.Fields.Item("TblCode").Value

Dim Table_Name As String = oRecord.Fields.Item("TblName").Value

Dim Table_Type As integer = oRecord.Fields.Item("TblType").Value

Dim oUserTablesMD As SAPbobsCOM.UserTablesMD

oUserTablesMD = Class_OprTbl_Main.ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)

'// set the table parameters

oUserTablesMD.TableName = Table_Id

oUserTablesMD.TableDescription = Table_Name

oUserTablesMD.TableType = Table_Type

lRetCode = oUserTablesMD.Add

If lRetCode <> 0 Then

If lRetCode = -1 Then


Class_OprTbl_Main.ocompany.GetLastError(lRetCode, sErrMsg)

Class_OprTbl_Main.SBO_Application.MessageBox(sErrMsg + oUserTablesMD.TableName)

End If

End If


oUserTablesMD = Nothing

But while running this code the error is coming .

How to solve this error ........



Former Member
Former Member replied

First of all, you are not meant to create temporary table in SAP database. SAP have never made an official announcement, but I think they would not be too happy if they saw it and may withdraw support. Just something to be aware of.

Secondly, your error is very common and you would have found the solution by searching the forum. It is caused by having an open recordset while trying to use a metadata object.

You will have to change how your code works. You can not use the UserFieldsMD or UserTablesMD object while you have an undisposed recordset object.

-1120 - Ref count for this object is higher then 0

Ref count for this object is higher then 0

Error: Ref count for this object is higher then 0

Meaning of Error Msg: "Ref count for this object is higher than 0"

The solution is you must dispose of any recordset object before attempting to use the UserTablesMD object:

oRecordSet= Nothing

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question