Problem creating User Defined Table

I am using C# and SBO 6.5
Error Code: -1120
Error Message: "The Mete Data for this object cannot be updated,\nsince it's ref count is bigger then 0."
SAPbobsCOM.UserTablesMD m;
                    m = (SAPbobsCOM.UserTablesMD)
                              frmMain.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);
if (m.GetByKey("CBtr")==false)
m.TableName="CBtr";
                              m.TableDescription = "TEST";
fieldadded =m.Add();
if (fieldadded !=0)
frmMain.oCompany.GetLastError(out oErrorCode,out oError);
Any help is appreciated.
Thanks,
Gopal

Hi Gopal,
Please note that GetByKey on a meta data object already makes it necessary to release the object (in your case "m").
In general you should use .NET's ReleaseCOMObject (see here:
SBO-SDK Consult : Releasing COM Object in .NET) to get rid of the "reference", but note that you most likely will have to set the object variable to null.
Alternatively setting the variable to null + a call to GC.Collect() might could do the trick, but GC.Collect() apparently works asynchronously! So, the COM object might not really have been released yet when you try to reuse the variable. GC.WaitForPendingFinalizers might work better.
Regards,
Frank

Similar Messages

  • Error creating user defined tables: Ref count (-1120)

    Hi all !
    I have to create user defined tables per code, so I wrote <b>2 main functions</b>, first <i>to create a table</i> (with TableName,TableType and TableDescription properties)and  and <i>second to add fields</i> (to a certain table which is sent as parameter).
    I call these functions to create multiple tables. For the first 6 tables it works totally ok. But beginning from the 7th table it gives that "<b>Ref count for this object is higher then 0.</b> " (-1120) error. All parameters are ok just as the first 6 tables.
    Found such an explanation like below in help files.
    <i>The DI API allows only one instance of a meta data object at a time. This maintains data integrity by preventing any manipulation of a business object while modifying the object's user fields. Therefore, verify that no other DI object is active except the meta data object.</i>
    But why do I get such an error after sixth call of the function (but not beginning from the second table )?

    Gül,
    Have you tried doing some grbage collection?
    Search for a topic: "Add Usertables and Fields while having a recordset"
    HTH
    Juha

  • What the best way to create User defined table with ADDON purpose

    Hi folks, how are you ?
    I´m beginner in development to business one, and I m studying to develop ISV addons.
    But, during my exercises and analisys, I learned that have two ways to create tables and fields in business one. One way is throght by wizard in business one using Tools Menu > Configuration Tools > User Defined Tables >
    Obs: I ´m using Business One Patch Level 9.
    Other way, is create the tables and fields using DI API
    But, my question is. When I develop one addon, or one UDO form that uses one set of user defined tables or used defined fields that where created by the first way (by wizard in B1), how I deploy this in other business one installation ? The package process will ensure the creation of this tables in another enviroment or I must implement the creation of user defined tables using DI API so that this code is called during the installation?
    If in cases of addon develop I must use DI API to create user defined tables, How can I use my classes with this responsibility in package process ?
    Thanks my friends.

    Hi Renan,
    You just need to put your logic in to the startup of your application, after you've established your connection to the UI API and DI API. All this will be triggered in the constructor of your main class.
    namespace MyNamespace
    public class MyAddon
      bool runAddon = true;
      bool initialised = false;
      const string ADDON_NAME = "My Addon";
      public static void Main()
            MyAddon addOn = new MyAddon();
            if(runAddon)
                  System.Windows.Forms.Application.Run();
            else
             Application.Exit();
      public MyAddon()
            // Connect to SBO session for UI
            if(!SetApplication()) runAddon = false;
      private bool SetApplication()
            // Code goes in here to establish UI API and DI API connections
            // See SDK samples for examples
            // You should also define and filter the UI API events your addon will trap at this stage and create any menus
            // Call your routine to check if the required UDFs/UDTs exist on this company
            initialised = CheckInitialisation();
            if (!initialised)
               //  AddOn not yet intialised on this company so prompt the user to run the intialisation process
              int iResponse = app.MessageBox("The " + ADDON_NAME + " addon will now create all required fields and tables."
                                             + System.Environment.NewLine + System.Environment.NewLine
                                             + "WARNING: It is strongly recommended that all other users are logged out of this company "
                                             + "before running this process. Are you sure you wish to continue?", 2, "Yes", "No", "");
              if (iResponse == 1) initialised = InitialiseAddOn(); // Call your routine to create the objects
            return true;
    Kind Regards,
    Owen

  • Creating user defined table in SBO-COMMON

    Hello experts,
    I'd like to create a user defined table in SBO-COMMON. I'll tell you why:
    I have successfully created a SAP B1 addon which adds freight costs to an order if the total amount is under a certain threshold. We have 2 administrations running, a live one and a test administration. We have put the connectionstring to determine the expense code of the freight costs in the exe.config-file of the addon.
    We want to be able to point the addon from one administration to the other by modifying only one value, a centralized value, independent of SAP administration. The most proper way to do that in my opinion is to put it in SBO-COMMON and the only logical way to do that is a user defined table in SBO-COMMON.
    Is there such a way?
    My alternative is to abuse another database on the server and just add the info there, but I'd prefer to store it in SBO-COMMON.
    Thanks for your time!
    Vincent

    UDT cannot be created in sbo-common. You may create new db and work with table in this db (but it will be not UDT, but standard sql table), or create new company db only for this purposes and create UDT there.

  • Creating user defined table

    how make new table as i need in sap b1 and also tell me how to insert update data in that table
    thanks and regards
    Parag

    If you need to add table using a program, you have to use the UserTableMD object. Once table is created you can add fields using UserFieldsMD object.
    Help is available with SDK help center.
    Once table is created, you can add data using RecordSet objects, UserTables Objects etc.
    You can also create table and fields using SBO (Tools->Customization Tools->User-Defined Tables - Setup...) and
    (Tools->Customization Tools->User-Defined Fields - Management...) etc.
    Anoop

  • Creating User-Defined Tables

    Hi All
    When creating a user defined table, SBO creates the following default fiels:
    Code     alphanumeric (8)
    Name     alphanumeric (30)
    Is their anyway to change to this.
    Thanks John

    Hi john,
    There is unfortunately no way to change this.
    Regards
    Ad

  • Problem creating user-defined metric for Database

    I am logged in to EM/Grid Control as SYSMAN, any user with superadmin privileges or a 'normal' user with operator/full privileges for my database target. When I go to set up user-defined metrics for the target db I get the following warning "You will only be able to view User Defined metrics because you do not have Operator Privileges on host <db target name>". The Create button is disabled.
    Can anyone offer any advise on where to identify the privilege problem?
    Thanks

    Well I did it with a host UDM calling a local script (which will be installed on shared drives for the development/test and production systems).
    The local script cats the /var/opt/oracle/oratab file eliminating lines beginning with # or $ then takes the second argument of each line and loops through all entries using a checkit procedure. The checkit procedure determines if the appropriate log directores exist for the oracle home and does a find on the diretory looking for alert*.log and *.trc. If there are any then global variables get updated with the count and directory name.
    There is an if statement before exit that checks of the count of files is greater than zero and write an appropriate em_result and em_message depending on the results.
    I then created the UDM in EM to call this script and check for critical/warning thresholds.
    Regards
    Tim

  • Minor problem creating user defined reports

    Hi:
    I noticed that when you create a new user defined report or folder
    -> right click on User Defined Rpeports and choose 'Add Folder' or 'Add Report'
    the cursor focus is on the *Name field, but if you type nothing happens.
    Then you click on another field (i.e.: Description, Tooltip...) and what you typed in *Name appears in the field you selected. This is not correct.
    I see this on the Linux version.
    Does the same happen on other operating systems?
    Thanks,
    Andrea

    Thank you.
    I am running Fedora FC4 with Sun JDK-1.5.0_06
    Anyone else notices the same behaviour?
    Happy new year everyone,
    Andrea

  • User Defined Table locked when multi users try to save data?

    Hi All,
    I am having a problem with User Define Table (UDT). I am just checking if somebody having the same problem as mine (any patch level).
    I've developed an add-on to save additional data to some UDTs upon saving a Production Order. I added my code in FormDataEvent (After Action = True and ActionSuccess = True).
    Here are my sequences to save the data:
    1. Start Transaction
    2. Remove Existing Data from 3 UDTs linked to the production order number.
    3. Save to table 1, using UserTable object
    4. Call function A to save to table2 , using UserTable object
    5. Call function B to save to table 3, using UserTable object
    6. Commit Transaction.
    Note: I have a try catch and rollback the transaction if any exception thrown by .NET and SAP. Below are parts of my coding to handle exception from SAP
                    If oUserTable.Add() <> 0 Then
                        oCompany.GetLastError(ErrCode, ErrMsg)
                        Throw New ApplicationException(ErrCode & "-" & ErrMsg)
                    End If
    in the try catch block, i add the following code
                If oCompany.InTransaction Then
                    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
                    SBO_Application.MessageBox("[SaveRoute]:" & ex.Message)
                    Return False
                End If
    Now, the issue is in some occasions, when multi users try to save the Production Order, the data get deleted from the UDTs, but some of the data did not get saved yet it did not throw an exception. From our observation, it only happens when multi users are trying to save to the same table.
    Does anybody having the same or similar issue? Really appreciate if you can share on this.
    Many Thanks,
    Harianto Ng

    I Believe you should look carefully where in your code writting, you should start transaction and be sure of using end.transaction commit if the insert sends a succesfull message, and rollback it for negative message.
    I used to start transacción right before .add method
    Wha DBMS are u using?
    Hope it helps.

  • Problem in EIS with "user-defined table"

    Platform : z/osrdbms : db2 v7Olap : Db2OlapMy problem :I try to make a "User-Defined table" in a meta-model whith this SQL definitionselect a.idele, a.idele0, b.lbele from u1g.fordv0 a, u1g.eledv0 b where a.iddim = 4 and a.idarb = 10 and a.idele = b.idele and a.iddim = b.iddim(description of the two simple table :CREATE TABLE U1G.ARBD ( IDDIM INTEGER NOT NULL, IDARB INTEGER NOT NULL, LBARB VARCHAR(255) NOT NULL, DTCRE TIMESTAMP NOT NULL WITH DEFAULT, DTMAJ TIMESTAMP ) CREATE TABLE U1G.ELED ( IDDIM INTEGER NOT NULL, IDELE INTEGER NOT NULL, LBELE VARCHAR(255) NOT NULL, DDVAL DATE NOT NULL, DFVAL DATE, DTCRE TIMESTAMP NOT NULL WITH DEFAULT, DTMAJ TIMESTAMP, MDCEL CHAR(1) NOT NULL, TYPE CHAR(1) NOT NULL ) )When i look at this "user-defined table" data in the meta model, it's okWhen i try to use this table as a dimension in a meta-outiline, it's okexcept when i try to load members in a cube.The load result say "the load terminated with errors"I look in the IS log :?Tue Jul 27 10:56:40 2004~ /IS/Worker/0x0/1090922163/Error/-104/Build-PQ72292 {DB2 for OS/390}{ODBC Driver}{DSN07011} DSNT408I SQLCODE = -104, ERROR: ILLEGAL SYMBOL ".". SOME SYMBOLS THAT MIGHT BE LEGAL ARE: + - AS <IDENTIFIER> DSNT418I SQLSTATE = 42601 SQLSTATE RETURN CODE DSNT415I SQLERRP = DSNHPARS SQL PROCEDURE DETECTING ERROR DSNT416I SQLERRD = 0 0 0 -1 69 0 SQL DIAGNOSTIC INFORMATION DSNT416I SQLERRD = X'00000000' X'00000000' X'00000000' X'FFFFFFFF' X'00000045' X'00000000' SQL DIAGNOSTIC INFORMATION ERRLOC=1:13:1 ?Tue Jul 27 10:56:40 2004~ /IS/Worker/0x0/1090922163/Informational/-104/Build-PQ72292 SELECT. aa."IDELE0", aa."IDELE", aa."LBELE" FROM.(select a."idele" .., a."idele0" .., b."lbele" from u1g.fordv0 a, u1g."eledv0" b where a.iddim = 4 and a.idarb = 10 and a.idele = b.idele and a.iddim = b.iddim) aaI don't understand why it's working in the meta model (the sql is good, i got the data)and why it's not working in the meta outline ?

    Platform : z/osrdbms : db2 v7Olap : Db2OlapMy problem :I try to make a "User-Defined table" in a meta-model whith this SQL definitionselect a.idele, a.idele0, b.lbele from u1g.fordv0 a, u1g.eledv0 b where a.iddim = 4 and a.idarb = 10 and a.idele = b.idele and a.iddim = b.iddim(description of the two simple table :CREATE TABLE U1G.ARBD ( IDDIM INTEGER NOT NULL, IDARB INTEGER NOT NULL, LBARB VARCHAR(255) NOT NULL, DTCRE TIMESTAMP NOT NULL WITH DEFAULT, DTMAJ TIMESTAMP ) CREATE TABLE U1G.ELED ( IDDIM INTEGER NOT NULL, IDELE INTEGER NOT NULL, LBELE VARCHAR(255) NOT NULL, DDVAL DATE NOT NULL, DFVAL DATE, DTCRE TIMESTAMP NOT NULL WITH DEFAULT, DTMAJ TIMESTAMP, MDCEL CHAR(1) NOT NULL, TYPE CHAR(1) NOT NULL ) )When i look at this "user-defined table" data in the meta model, it's okWhen i try to use this table as a dimension in a meta-outiline, it's okexcept when i try to load members in a cube.The load result say "the load terminated with errors"I look in the IS log :?Tue Jul 27 10:56:40 2004~ /IS/Worker/0x0/1090922163/Error/-104/Build-PQ72292 {DB2 for OS/390}{ODBC Driver}{DSN07011} DSNT408I SQLCODE = -104, ERROR: ILLEGAL SYMBOL ".". SOME SYMBOLS THAT MIGHT BE LEGAL ARE: + - AS <IDENTIFIER> DSNT418I SQLSTATE = 42601 SQLSTATE RETURN CODE DSNT415I SQLERRP = DSNHPARS SQL PROCEDURE DETECTING ERROR DSNT416I SQLERRD = 0 0 0 -1 69 0 SQL DIAGNOSTIC INFORMATION DSNT416I SQLERRD = X'00000000' X'00000000' X'00000000' X'FFFFFFFF' X'00000045' X'00000000' SQL DIAGNOSTIC INFORMATION ERRLOC=1:13:1 ?Tue Jul 27 10:56:40 2004~ /IS/Worker/0x0/1090922163/Informational/-104/Build-PQ72292 SELECT. aa."IDELE0", aa."IDELE", aa."LBELE" FROM.(select a."idele" .., a."idele0" .., b."lbele" from u1g.fordv0 a, u1g."eledv0" b where a.iddim = 4 and a.idarb = 10 and a.idele = b.idele and a.iddim = b.iddim) aaI don't understand why it's working in the meta model (the sql is good, i got the data)and why it's not working in the meta outline ?

  • How to create a Foreign key relationship between 2 user defined tables...

    Hi Folks,
    I have created two user defined tables... Where in i want to create foriegn key relationship between the 2 tables.... Can anyone guide the step by step procedure to do this scenario...
    Any help would be highly appreciated...
    Thanks

    Hi
    1.  In the 2nd table call the field of the 1st table which is a primary key.
    2.  Give the same field and dataelement name.
    3.  Select that field and then click on the foreign key field icon which is beside Search Help button.
    4. Then give short text, and the 1st table name.
    5. Then in the below box give the 2nd table name and 2nd table field name which you have called from 1st table.
    6. Then click on copy, then u will be able to see Check table name and check table field name beside foreign key table name.
    7. Then again click on copy.
    Regards
    Haritha.

  • Syntax error when creating a user-defined table type in SQL Server 2012

    Why am I getting a syntax error when creating a user-defined table type in SQL Server 2014?
    CREATE TYPE ReportsTableType AS TABLE 
    ( reportId INT
    , questionId INT
    , questionOrder INT );
    Results:
    Msg 156, Level 15, State 1, Line 1
    Incorrect syntax near the keyword 'AS'.

    Hope these posts could help, 
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/37a45a9a-ed8c-4655-be93-f6e6d5ef44be/getting-incorrect-syntax-while-creating-a-table-type-in-sql-server-2008-r2?forum=transactsql
    Regards, Dineshkumar,
    Please Mark as Answer if my post answers your question and
    Vote as Helpful if it helps you

  • Problems adding new rows to a simple user defined table manually

    Hi
    I have just created a user defined table ( SAP 2007 SP01 PL9 ) but when I try to add a line using tools ->userdefined tables I get the following error -
    conversion failed when converting the nvarchar value '-3 @GLMAP to data type int ( CINF )
    The table is called GLMAP and I simply added 3 alpha fields
    I  put 1 into all the fields on screen
    Can anyone suggest anything please as ideally I would like the end user to be able to update this simple table
    Many thanks
    Regards Andy

    Andy
    I think in your case you have used  DBDataSource to display data from UDT on your form. 
    Easyier to use UDO than User Defined Table, because you do not have to programming at UDO based forms.
    What István tried to say:
    Check your sp_transactionnotification procedure, maybe you have used @object_type variable as integer instead of nvarchar
    Regards
    J

  • User defined Table and matrix problem

    Hi,
    I have a user defined table. I am displaying data from this table using DBdataSource on a matrix in my form. After making changes to a cell on the matrix when i try to save the data back to the data source, the changes are not updated. I am using SBO2004 and using FlushToDataSource method to save the changes.
    Please help.
    Thanks.

    Fabio,
    I disagree with you, FlushtoDataSource does work on user form too.
    Once you use this function, you'll have to open a the userTable object, and save the records from the DBDataSource object to the table using this object.
    Sébastien

  • Error while linking user defined table to user defined field using vb6.0

    Hi,
    I am creating a userdefined field on a SAPB1 table(PDN1) using vb 6.0
    I am trying to link this field to a user defined table.
    When i do that i get the following error:
    "The field 'Related table' should consist of 8 alphanumeric chracters with no valid or default values"
    When i try to do the same thing from SAPB1(not using code) there is no such problem.
    My vb code is as follows:
    Set oUserFieldsMD = oCmp.GetBusinessObject(oUserFields)
    oUserFieldsMD.TableName = "PDN1"
    oUserFieldsMD.Name = "OB_Locn"
    oUserFieldsMD.Description = "WH Location"
    oUserFieldsMD.Type = db_Alpha
    oUserFieldsMD.EditSize = 30
    lRetCode = oUserFieldsMD.Add
    If lRetCode <> 0 Then
        oCmp.GetLastError lErrCode, sErrMsg
        MsgBox sErrMsg
        GoTo Err_
    End If
    If Not oUserFieldsMD.GetByKey("PDN1", 0) Then
        MsgBox "Error"
        GoTo Err_
    End If
    oUserFieldsMD.LinkedTable = "OB_TEST"
    lRetCode = oUserFieldsMD.Update
    Your help will be much appreciated.
    Thanks.

    Great Sébastien!
    Looks like we could not survive here one day without your contribution
    Best regards,
    Frank
    PS: For readers of this thread who don't understand why
    EditSize
    must be "8":
    This is the size of the
    Code
    field in the user-defined table to which the new field OB_Locn (in the DB it will be U_OB_Locn) is linked to...
    So, it should be preferrably of the same size.

Maybe you are looking for

  • How to display the column dyanmically depending upon input

    I am doing a alv report of tax breaks in which i had 6 columns to be displayed as static and rest of ( vat tax )columns should be dynamic . if i enter a p.o.document no then if that p.o has taxes excise and excess then  they should be displayed and v

  • All flash components work when published except one....

    I have a website built in Dreamweaver CS4 that uses a flash header, photo gallery and video. Everything works great except for the video on the home page. From what I can tell it works fine in Firefex but not IE8 or IE8 in compatability mode. IE keep

  • How to dequeue/delete/remove a message with delay?

    I've enqueued a message with dbms_aq.enqueue using l_message_properties.delay := 24*60*60*x where x is calculated so that the message should normally be dequeued on a given date, but not before next midnight. So that if nothing happens, the message c

  • Acrobat 9 typewriter text doesn't show

    Acrobat 7 made me a big fan of the typewriter feature. Now that I've upgraded to Acrobat 9, I'm having problems with it. Suppose I add some typewriter text to a .pdf and save it. When I reopen the file, the typewriter text doesn't show. My text is th

  • Is it safe to delete installesd.dmg in mavericks?

    Is it safe to delete installesd.dmg in mavericks?  It takes up 5.3GBs and I'd like to free up the space.