Create User Table

Hi... pals
i want to create my usertable and userfield via DI but add method says
"Ref count for this object is higher than 0"
what does it means ??
regards
<b>toRo</b>

HI Ria Hantoro ,
                        Ref count  o problem will come unless u release the object  .I am giving u  the sample code .
''//**** This will create the UserTable   as 'Test '
        Dim oUserTablesMD As SAPbobsCOM.UserTablesMD
        ' Init the MetaData object
        oUserTablesMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)
        ' set the 2 mandatory fields
        oUserTablesMD.TableName = "Test"
        oUserTablesMD.TableDescription = "TestTable"
        'Document type
        oUserTablesMD.TableType = SAPbobsCOM.BoUTBTableType.bott_Document
        lRetCode = oUserTablesMD.Add
        '//  it will return integer value if = 0 then success
        If lRetCode <> 0 Then
            oCompany.GetLastError(lErrCode, sErrMsg)
            MsgBox(sErrMsg)
        Else
            'MsgBox("Table: " & oUserTablesMD.TableName & " was added successfully")
        End If
        ' to release the object
        System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserTablesMD)
              <b>      '//****NOW WE ARE READY TO ADD  USER FIELDS AS </b>
'//****  This is for Field Creation
  ' A User Fields object
        Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD
        ' Remember to free occupied resources
        GC.Collect()
        ' Init the user fields object
        oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
        ' Adding the "DocNum" field
        ' Setting the Field's mandatory properties
        oUserFieldsMD.TableName = "@Test"
        oUserFieldsMD.Name = "DocNum"
        oUserFieldsMD.Description = "Document Number"
        oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Numeric
        oUserFieldsMD.EditSize = 11
        '// Adding the Field to the Table
        lRetCode = oUserFieldsMD.Add
        '// Check for errors
        If lRetCode <> 0 Then
            oCompany.GetLastError(lErrCode, sErrMsg)
            MsgBox(sErrMsg)
        Else
            MsgBox("Field: '" & oUserFieldsMD.Name & "' was added successfuly to " & oUserFieldsMD.TableName & " Table")
        End If
  '//****** End of Field creation
              lRetCode   is a long variable
                        The above code will help u . 
Regards
V.Rangarajan

Similar Messages

  • Creating User Table, User Field ... with Script SQL in C#

    Hi every body,
    I wonder if we could create a user table, user field ... with script SQL in C#.
    Should I use the reference Microsoft.SqlServer.ScriptTask ??
    Thank you for your Help

    Haifa,
    I am not sure where your question is directed.  The forum that you have posted your question in is for questions related to the SAP Business One SDK.  Are you looking to create new user tables/fields in SAP Business One?  If so you can do this either through the SAP Business One SDK interface using Tools > User Defined Fields and/or Tools > User Defined tables.
    You can also create metadata objects in Business One programatically using the UserTablesMD and/or UserFields objects.
    SAP does not support direct SQL writes to the SAP Business One Db.
    HTH,
    Eddy

  • Create User Table from XML

    Dear All,
    I would like to ask wether anyone has ever use GetBusinessObjectFromXML to create UserTables and how to do it.
    I have tried to do so but always getting error :
    "The Mete Data for this object cannot be updated,
    since it's ref count is bigger then 0." in return.
    anyone knows what's the problem ?
    thanks in advance
    Arief

    Hi,
    " ref count is bigger then 0" means you have another reference to the Metadata object but the one trying to update/add it.
    If you're using V.Studio6 you need the clean the other objects...
    If you're working on .NET environment you'll need to use the ReleaseCOMObject(object) method.
    Please do not use the GC.Collect. see "SBO-SDK Consult : Releasing COM Object in .NET" Posted: July 29, 2004 7:53 AM
    Regards,
    Yaniv G.
    SDK Consultant,
    SAP Manage Israel.

  • Problem with adding user fields to user table

    hi everyone,
    i have written code to create user tables and some user fields to that table....
    its working fine...
    in the code i have some conditions like if the table is already created.. then it should execute the code written for creating table..?
    udTables1 = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)
                If udTables1.GetByKey("FA_MASTERDATA") Then
                    udTables1 = Nothing
                Else
                    udTables1.TableName = "FA_MASTERDATA"
                    udTables1.TableDescription = "Fixed Assets Master Data"
                    udTables1.TableType = SAPbobsCOM.BoUTBTableType.bott_MasterData
                    ret2 = udTables1.Add()
    System.Runtime.InteropServices.Marshal.ReleaseComObject(udTables1)
                    udTables1 = Nothing
                    GC.Collect()
                End If
    but how to check the same condition for adding fields????
    udfields1 = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
                '' 1st field
                udfields1.TableName = "FA_MASTERDATA"
                udfields1.Name = "Alias"
                udfields1.Description = "Alias"
                udfields1.Type = SAPbobsCOM.BoFieldTypes.db_Alpha
                udfields1.EditSize = 20
    '''how to write condition to check whether the field is already creatd or not????
                ret3 = udfields1.Add()
    System.Runtime.InteropServices.Marshal.ReleaseComObject(udfields1)
                udfields1 = Nothing
                GC.Collect()

    hi try this..
    oUserFieldsMD = muc_ParentAddon.SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
                '********Adding 1st Field
                If Not IsFieldExist("POR1", "PINo") Then
                    oUserFieldsMD.TableName = "POR1"
                    oUserFieldsMD.Name = "PINo"
                    oUserFieldsMD.Description = "Purchase Indent No"
                    oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Alpha
                    oUserFieldsMD.EditSize = 20
                    lRetCode = oUserFieldsMD.Add
                    If lRetCode <> 0 Then
                        muc_ParentAddon.SBO_Company.GetLastError(lErrCode, sErrMsg)
                        MsgBox(sErrMsg)
                        Return False
                        Exit Function
                    Else
                        Fields = True
                    End If
                End If
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD)
      Private Function IsFieldExist(ByVal as_TableName As String, ByVal as_FieldID As String) As Boolean
            Dim flag As Boolean
            Dim businessObject As SAPbobsCOM.Recordset
            Try
                businessObject = DirectCast(Me.muc_ParentAddon.SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset), SAPbobsCOM.Recordset)
                businessObject.DoQuery(String.Concat(New String() {"Select * From CUFD Where TableId = '", as_TableName, "' AND AliasID='", as_FieldID, "'"}))
                If (businessObject.RecordCount > 0) Then
                    flag = True
                Else
                    flag = False
                End If
            Catch exception1 As Exception
                Me.muc_ParentAddon.SBO_Application.SetStatusBarMessage(exception1.Message, SAPbouiCOM.BoMessageTime.bmt_Short, True)
            End Try
            System.Runtime.InteropServices.Marshal.ReleaseComObject(businessObject)
            Return flag
        End Function
    hope it helps

  • Clear User Table

    Hello,
    I created a User table. It is for me only a temporary table.
    I would like to clear it in order to re-use it.
    I do not have find the good object to do it.
    Is there someone who have any solution please ?
    Tks All
    Laetitia.

    Hi,
    I sent  message to SAP, We cannot delete row with DI in usertables.
    There is no another solution but it doesn't work anymore.
    What I want to :
    delete User Table
    create User table
    Put data in this table.
    But there is a problem. I have to do that in the same action. And it doesn't work because SBO have to refresh itself between deletion and creation.
    So It delete my table and I can't create it again.
    If someone have any Idea ?
    Tks all for your help.
    Laetitia

  • How do I create new user table in program and then access it?

    I am writing an application where I check for the existence of user objects when the add on starts and run the setup if the objects do not exist. I can create the user tables and fields but after the setup completes these objects still are not visible.
    If the user objects exist when the add on is first run everything is detected correctly.
    When a user object is added in SAP the user is eventually prompted to restart so I suspect something needs to happen prior to the add on being able to use the new fields.
    Does the add on need to wait for the DI Server to perform some action? Do I need to just quit the add on's class and rerun it, disconnect and reconnect to the company, or get a new Application and/or company object?
    What I want to do is figure out a way for the add on to automatically run the configuration if the user tables and fields do not exist yet and then kick off the regular add on code. I haven't seen anyone else's code so I don't know what is recommended or required here.
    Thanks for any assistance!

    I found that the add on can validate the existance of the user fields if I disconnect from the company object, set the SAPbouiCOM.Application and SAPbobsCOM.Company objects to null, set the new application, context, and company objects, and reconnect once more.
    HOWEVER...
    I still have to wait for the client to be restarted manually before I can run any of the form I added to the menu.
    So, I'd still like to know what the best practice is here. Should I just exit after setting up the tables and tell the user to restart SAP?

  • 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

  • Creating a User Table via DI API

    Hi all,
    I'm using
    SAP Business One 2004A (6.70.185) SP: 00 PL: 07
    and corresponding SAP Business One DI API 2004
    I want to create a user table.
    I try to create it this way:
    I have two functions
    First function to create the table
    Private Function AP_AddOn_CreateTable() As Boolean
       AP_AddOn_CreateTable = True
       Dim oUDT As SAPbobsCOM.UserTablesMD
       Dim sErrMsg As String
       Dim iErrCode As Integer
       Dim iReturn As Integer
       oUDT = oDIComp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)
       oUDT.TableName = "AP_tbItemCalc"
       oUDT.TableDescription = "ItemCalculation"
       iReturn = oUDT.Add
       If iReturn <> 0 Then
          oDIComp.GetLastError(iErrCode, sErrMsg)
          Message…
          AP_AddOn_CreateTable = False
       End If
       oUDT = Nothing
    End Function
    This works fine
    Then I call a second function to create the user fields
    Private Function AP_AddOn_CreateFields() As Boolean
       AP_AddOn_CreateFields = False
       Dim oUDF As SAPbobsCOM.UserFieldsMD
       Dim sErrMsg As String
       Dim iErrCode As Integer
       Dim iReturn As Integer
       oUDF = oDIComp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
       oUDF.TableName = "@AP_tbItemCalc"
       'Field1
       oUDF.Name = "ItemCode"
       oUDF.Description = "ItemCode"
       oUDF.Type = SAPbobsCOM.BoFieldTypes.db_Alpha
       oUDF.Size = 20
       iReturn = oUDF.Add()
       If iReturn <> 0 Then
          oDIComp.GetLastError(iErrCode, sErrMsg)
          Message…
          Exit Function
       End If
       'Field2
       oUDF.Name = "ItemName"
       oUDF.Description = "ItemName"
       oUDF.Type = SAPbobsCOM.BoFieldTypes.db_Alpha
       oUDF.Size = 100
       iReturn = oUDF.Add()
       If iReturn <> 0 Then
          oDIComp.GetLastError(iErrCode, sErrMsg)
          Message
          Exit Function
       End If
          next fields …
       AP_AddOn_CreateFields = True
    End Function
    The second function returns on adding the first field, an error, errCode -1120, errMsg ‚Ref count for this object is higher than 0’
    If i close the application after creating the table and then restart the application only executing the second function it works.
    I also tried the example as provided in ‚MetaDataOperations’ and it shows the same behaviour.
    Besides, I’m the only user on the system and no other application is running.
    Kind regards,
    Eduard

    Hi,
    See Add  userfield to usertable 1120 Error  SOLUTION
    HTH
    Ribeiro Santos

  • 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

  • Create user with read access for all tables SAP SID .*

    Hello all,
    could you please help me ? I would like to grant select privilege on all tables SAP<SID>.* for newly created user.
    I have created standard database user (not exclusive).
    I`m able to grant select for individual tables, but I would like to grant select for this user on all SAP<SID>
    schema in simplier way
    But as far as I know, the schema`s owner name must be different then schema name.
    Any idea please ?
    Thank you.
    Pavol

    create user <user_name> identified by <password> <options>;
    grant read on all tables:-
    CREATE OR REPLACE PROCEDURE GRANT_SELECT AS
    CURSOR ut_cur IS
    SELECT table_name
    FROM user_tables;
    RetVal NUMBER;
    sCursor INT;
    sqlstr VARCHAR2(250);
    BEGIN
    FOR ut_rec IN user_tabs_cur;
    LOOP
    sqlstr := 'GRANT SELECT ON '|| ut_rec.table_name
    || ' TO <user_name>';
    sCursor := dbms_sql.open_cursor;
    dbms_sql.parse(sCursor,sqlstr, dbms_sql.native);
    RetVal := dbms_sql.execute(sCursor);
    dbms_sql.close_cursor(sCursor);
    END LOOP;
    END grant_select;
    Edited by: varun4dba on Jan 18, 2011 4:13 PM

  • Properties of an answer field allowing form users to create a table

    When using Acrobat XI, is it possible to set the properties of the answer field to allow users to put in a table as an answer?

    Create the table in aanother program Such as word  then save. Then fill in the table items.
    Check this out: http://www.screencast.com/t/FxCNROO5AQj

  • How to create User and Database in different Table spaces

    How to create User and Database in different Table spaces using oracle 10g
    Regards
    daya

    I am sorry but your question does not seem to make much sense.
    Can you please rephrase your question?

  • Create user/schema is script, then tables for that user/schema

    Hi;
    First off, if I phrase this a little wrong - I'm from the Sql Server world and still trying to totally understand Oracle.
    I have a schema (.sql file) that creates my database fine. But what I would liek to add to the .sql schema is for it to create a user and then place all the tables, indexes, sequences, and triggers in as belonging to that created user.
    This way we can tell people to log in as sysop and run the script to create the schema rather than create the user, log in as the user, then run the script.
    What do I need to add?
    thanks - dave

    Hi;
    I have tried:
    CREATE USER DAVE IDENTIFIED BY password;
    CONNECT DAVE/password AS SYSDBA
    I have also tried:
    CONNECT DAVE/password AS SYSTEM
    CONNECT DAVE AS SYSDBA
    CONNECT DAVE
    In all cases ApplicationExpress says it does not recognize the CONNECT command. Should I do something different? What I want to accomplish is that all subsequent commands in the script creating tables, indexes, etc are assigned to the user/schema DAVE.
    thanks - dave

  • Permission to view content of table of SYS schema to newly created user

    Hi,
    I am facing issue giving permission to view contents of table p_users of SYS schema to newly created user.
    Regards,
    Phani Ram

    Hi Phani,
    Could you please check if you have an a authorization to give a permission to other users for particular schema.
    I mean check for privileges, user and roles.
    Warm Regards,
    Earesh kumar

  • Can I create a table called user

    Dear buddies,
    Can I create a table called user in my database.
    Please guide me.
    Thanks in advance.
    Nith

    user645399 wrote:
    I was required to create one for some reasons by a vendor so that Oracle will work with their tool.
    This tells you more about the vendor than the vendor would like you to know ......
    Like the vendor that told me their product would work with an oracle database, but they preferred SQL Server because "oracle doesn't perform will with more than 5 concurrent connections". Fortunately we were still in product evaluation and I was able to get them cut from the short list.
    After seeing all your replies, now, I have contacted them asking for alternatives and explanations.
    Anyway, Thank You to everyone of you.
    Nith

Maybe you are looking for

  • HT1657 How do I Sync a movie rental with my iPhone?

    How do I Sync a movie rental from my computer with my iPhone?

  • Captivate 6.01 32 bit crashes when adding an interaction on secured DoD/AF network

    Hello, I have been trying to work with the Adobe engineers to troubleshoot what could possibly be causing the problem, without much luck. I'm wondering if any other DoD developers who are working behind a firewalled .mil domain are having similar iss

  • Help with Button Linking

    Hello, I was wondering how come you cant use a button to open a web page. I would use text but i like how buttons when rolled over change. If any one have any suggestions or another way, it would help a lot of you could get me out of my jam! Thanks,

  • Neptune for UI development Pros and Cons

    Hi , we are evaluating neptune for UI development for what are the pros and cons of using neptune. i see only that webdynpro abap developer can be easily moved to neptune , some javascript knowledge is still required. some question 1) can neptune mak

  • ITunes syncs Aperture "Faces" when none are sellected

    I find that iTunes is syncing unchecked 'albums' from my Aperture library to both my phone and my ipad.  The most consistent issue is that I end up with all of the "Faces" when I have not selected any at all to sync. Any thoughts on how to get iTunes