on 05-02-2006 7:35 PM
Hi,
I want to create userfields with the di object UserFieldsMD, but I get the error "Ref count for this object is higher then 0".
I've a record set object before and if I don't use a recordset object it's ok, but I really need to use it.
Any Delphi code for this ? (adding userfield in delphi without error)
Thank you for your help
Jodérick
Hi Joderick Picard
SAP only allows one meta data object at a time, so no di api objects should be active when doing meta data operations. Creating userfields is using a metadata object, they do this to mantain data integrity. So the reordset must be closed off before performing the meta data transaction.
In certain cases where you use the recordset, what ever values needed, get them, store them in vb variable and the close the recordset. The continue with meta data operation. here is an example of how i did it once
RS = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
'query to check if column exists
RS.DoQuery("SELECT SysObjects.Name, SysColumns.Name FROM SysColumns INNER JOIN SysObjects ON SysObjects.ID = SysColumns.ID WHERE SysObjects.Name='octr' and SysColumns.Name ='U_Brnch'")
If (RS.RecordCount = 0) Then
'if column does not exist recordcount will be zero
'Here i release the object
System.Runtime.InteropServices.Marshal.ReleaseComObject(RS)
'this next line is not needed, just cautious
RS = Nothing
'function that adds field
AddField("OOPR", "Brnch", "Branch", SAPbobsCOM.BoFieldTypes.db_Alpha, SAPbobsCOM.BoFldSubTypes.st_None, 20)
End If
The above is vb.net example. In delphi just set recordset to nothing/null or release com object. Should work.
Hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.