User defined tables:  amending Index on the database level. Opinions???

Hi everybody who has some spare time to read my stuff
I had a problem that some of you might have had. I have a user defined table, let’s call it ProductTypes. Now system by default creates two columns in this table, one is Code (primary key) and another is Name (Index). I have added third column called Department. Now, if I wanted to add the following data (see bellow) to the table I would have had a constraint violation message pointing me out that I have problems with indexing.
Code, Name, Department
1, Cream, Fragrances
2, Cream, Beauty Products
      ^^
I could thing of couple workarounds of this problem
1. Is to duplicate Code into Name and storing rest of the data using user columns
Code, Name, Product Name, Department
1, 1,Cream, Fragrances
2, 2, Cream, Beauty Products
This approach isn’t very convenient as it requires UI development should we decide to attach this table to the Item master data form in a form of combo box.
2. Is to amend Index on the database level. Initially, the index KProductTypes_Name consisted of only one column Name, what I have done is added another column which is Code to indexing. I don’t see how this can harm database consistency or damage the core system.  Please correct me if I am wrong.
Another way of amending index in order to solve my problem could be choosing ignoring duplicate values option for column Name.
Please let me know what are your thoughts.
Best wishes

> Why don't you try adding a trigger 'instead of
> insert' where code = max(code)1 and name=max(name)1
> and use only user columns for your data. This
> provided you know SQL basics.
in this scenario we would have to do UI SDK development for the output and going to have an extra column with meaningless data in it.

Similar Messages

  • Error while  adding records in user defined table

    Dear all,
                    I am adding a record in user defined table using   .add() method. the code is given below. while adding it raises the following error
    "-1[Microsoft]  [SQL Native Client] [SQL Server] Conversion failed when converting the nvarchar value '-3 @BG_MAILSETTINGS'  to data type int. (CINF).  "
    All the fields are varchar date type.  
                Dim oUDT As SAPbobsCOM.UserTable
                oUDT = oCompany.UserTables.Item("BG_MAILSETTINGS")
                With oForm.DataSources.UserDataSources           
                        oUDT.Code = "1"
                        oUDT.Name = "SMTPSERVER"
                        oUDT.UserFields.Fields.Item("U_SERVER").Value = .Item("EDTSMTPSVR").ValueEx
                        oUDT.UserFields.Fields.Item("U_EMAIL").Value = .Item("EDTFEMAIL").ValueEx
                        oUDT.UserFields.Fields.Item("U_PORT").Value = .Item("EDTSMTPPRT").ValueEx
                        oUDT.UserFields.Fields.Item("U_USERNAME").Value = .Item("EDTSMTPUSR").ValueEx
                        oUDT.UserFields.Fields.Item("U_PASSWORD").Value = .Item("EDTSMTPPWD").ValueEx
                        oUDT.UserFields.Fields.Item("U_AUTHENT").Value = .Item("CMBSMTPAUT").ValueEx
                        K = oUDT.Add
                        If K <> 0 Then
                            oCompany.GetLastError(iErrCode, sErrMsg)
                            MsgBox(CStr(iErrCode) & "-" & sErrMsg, vbCritical, "Error")
                            Exit Sub
                        End If
                 End with
    Could any one please say the solution for this.
    Many thanks,
    Manikandan.
    Edited by: Rui Pereira on Dec 23, 2008 3:49 PM

    Dear Manikandan P,
    Is there any change and check in stored procedure SBO_SP_TransactionNotification?
    Best Regards
    Jane Jing
    SAP Business One Forums team
    Edited by: Rui Pereira on Dec 23, 2008 3:56 PM

  • Item Code Auto Generation Based on User defined Tables

    I need the Item code like
    PRODUCT TYPE-ITEMGROUP-ITEMCODE-SUBITEM-BRAND-COLOR  e.g .FG-01-01-00-001-00.
    I created the following User define Tables and link to Item Master data
    U_PRO             - FOR PRODUCT TYPE
    U_GROUP        - FOR  ITEM GROUP
    U_ITEMCODE    - FOR ITEMCODE
    U_SUBITEM       - FOR SUB ITEM
    U_BRD              - FOR BRAND NAME
    U_COLOR         - FOR COLOR
    i need a formatted search in Item code to fetch the codes from the user defined  table
    i tried with the following
    SELECT T5.[Code]'-'T2.[Code]'-'T3.[Code]'-'T4.[Code]'-'T0.[Code]'-'T1.[Code] FROM [dbo].[@BRD]  T0 , [dbo].[@COLOR]  T1, [dbo].[@GROUP]  T2, [dbo].[@ITEMCODE]  T3, [dbo].[@SUBITEM]  T4, [dbo].[@PRO]  T5 INNER JOIN OITM T6 ON T5.Code = T6.U_PRO WHERE
    T5.[Code] = T6.[$U_PRO] AND 
    T2.[Code] = T6.[$ U_GROUP] AND
    T3.[Code] = T6.[$U_ITEMCODE] AND
    T4.[Code] = T6.[$U_SUBITEM] AND
    T0.[Code]  = T6.[$U_BRD] AND
    T1.[Code]  = T6.[$U_COLOR]
    showing errors. Can any one help me regarding this. I badly need the query for Auto generation of Itemcode

    Hi,
    How can you assign those UDF value without ItemCode in the first place?
    Thanks,
    Gordon

  • Linking UDF to User Defined Table

    Dear Experts,
      I have a UDF on the batch tables that I would like to link to a User defined table. After creating the link, the UDF drop down cannot open up to display anything. The drop down box is there on the UDF but cannot open or drop to display anything from the user defined table.
    Has anyone came across this problem before ?
    Regards,
    Edited by: MARTIN KAMAU on Jan 4, 2011 10:12 AM

    Hi Martin,
    When you click on the UDF for the drop-down, do you see an option for "Define New"?
    What version of SAP are you using?
    Regards
    Sudatt

  • Formatted Search on User Defined Table

    Dear Experts,
    I have the following formatted search query on a user defined table : select $[dbo.[@SALES_BUDGET].U_AcctCode]
    It throws an error when I attempt to execute it. What's the proper way to write formatted searches on User Defined Tables. Please advice.
    Kind Regards

    This works very well on the delivery docs :
      select  $[ODLN.DocNum] 
       on the header fields of a delivery document, Why not this
    select  $[SALES_BUDGET.U_AcctCode]  
    on a field in the User defined Table  ? Is it the syntax ?
    Edited by: MARTIN KAMAU on Sep 27, 2010 2:28 PM

  • Will any change in tempdb database affect the user defined tables?

    Will any change in tempdb database affect the user defined tables?
    Suppose I have deleted a table from system database tempdb, will it effect the user defined tables?
    Anujit Karmakar Sr. Software Engineer

    The short answer is no; deleting a table from tempdb will not affect user databases.
    Of course I could make up some connection between the two that you haven't described. For example, if a stored procedure created a temporary table, and was busy using it when you deleted it, the deletion could cause unexpected behavior in the user database,
    which could affect some table data.
    Also, some system actions in user databases can store data in tempdb temporarily. But you aren't likely to be talking about system usages of tempdb.
    So, unless you describe some connection, the tables in tempdb are independent from the user database tables.
    Rick Byham, Microsoft, SQL Server Books Online, Implies no warranty

  • How to add a DataBase Field in PLD from a User Defined Table

    Hi All,
    Please tell me how should i add a database field in PLD from User Defined Field...
    The DropDown for tables in the Property window does not shows the User Define tables...How should i see them...
    Thanx in Advance
    Manish

    In PLD choose object Database. Then press Alt + table combobox, this will show the UDT. Then choose the column.

  • Attach User define tables and view table need add to database into my add-o

    Hi there,
    I want to deploy an addon, there are User define tables and view table need add to database.
    I need some advice on some issues..
    1. Can I attach User define tables and view table need add to database into my addon.
    2. I wonder which chance is properly to add them, if add these user define objects in time of install and I can't get the enough information that connect to SQL server
    Thanks for any help.

    Hi Weerachai,
    Here's an example of how to create a user-defined table in code. My suggestion would be to check if it exists when your add-on starts up and then if not, create the tables, fields and objects.
    'User Table
        Private Sub CreateTable(ByVal sTable As String, ByVal sDescription As String, ByVal oObjectType As SAPbobsCOM.BoUTBTableType)
            Dim oUserTablesMD As SAPbobsCOM.UserTablesMD
            Dim iResult As Long
            Dim sMsg As String
            oUserTablesMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)
            If Not oUserTablesMD.GetByKey(sTable) Then
                oUserTablesMD.TableName = sTable
                oUserTablesMD.TableDescription = sDescription
                oUserTablesMD.TableType = oObjectType
                iResult = oUserTablesMD.Add()
                If iResult <> 0 Then
                    oCompany.GetLastError(iResult, sMsg)
                    MessageBox.Show("Error Creating Table: " & sTable & " Error: " & sMsg)
                End If
            End If
            System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserTablesMD)
        End Sub
    'User Field
        Private Sub CreateField(ByVal sTable As String, ByVal sName As String, ByVal sDescription As String, _
                                ByVal iSize As Integer, ByVal aFieldType As SAPbobsCOM.BoFieldTypes, _
                                ByVal aSubType As SAPbobsCOM.BoFldSubTypes, ByVal sLink As String, _
                                ByVal bMandatory As SAPbobsCOM.BoYesNoEnum)
            Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD
            Dim oTable As SAPbobsCOM.UserTable
            Dim iResult As Long
            Dim sMsg As String
            Dim i As Integer
            Dim x As Integer
            Dim bFound As Boolean = False
            Dim oField As SAPbobsCOM.Field
            oTable = oCompany.UserTables.Item(sTable)
            For i = 0 To oTable.UserFields.Fields.Count - 1
                oField = oTable.UserFields.Fields.Item(i)
                'MessageBox.Show(oField.Name)
                If oField.Name = "U_" & sName Then
                    bFound = True
                End If
            Next
            System.Runtime.InteropServices.Marshal.ReleaseComObject(oTable)
            If Not bFound Then
                oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
                oUserFieldsMD.TableName = "@" & sTable
                oUserFieldsMD.Name = sName
                oUserFieldsMD.Description = sDescription
                oUserFieldsMD.Type = aFieldType
                If aFieldType = SAPbobsCOM.BoFieldTypes.db_Alpha Or aFieldType = SAPbobsCOM.BoFieldTypes.db_Numeric Then
                    oUserFieldsMD.EditSize = iSize
                Else
                    oUserFieldsMD.SubType = aSubType
                    oUserFieldsMD.Mandatory = bMandatory
                End If
                oUserFieldsMD.LinkedTable = sLink
                iResult = oUserFieldsMD.Add()
                If iResult <> 0 Then
                    oCompany.GetLastError(iResult, sMsg)
                    MessageBox.Show("Error Creating Field: " & sTable & "." & sName & " Error: " & sMsg)
                End If
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD)
            End If
        End Sub
    If you want to create a View I think you would have to use the RecordSet object. This will ensure that you don't have to log in to the database again
    Hope it helps,
    Adele

  • How to fill the records from a User Define Table to PO item Grid

    Hi To all,
    I need to fill data from User Define table records into Purchase Order Item Grid.
    I created an UDF Filed in PO - Header Part - "PRS"(Filed Name)
    By using Formatted Search in itemcode column, i called a query,
    "Select itemcode, qty from (@user define tablename) where PRS = $http://OPOR.U_PRS"
    For eg:
    Output from querry
    ItemCode Qty
    ABC 1
    DEF 2
    DFG 7
    SDGD 9
    By using formatted search it is filling only first data in to itemcode column in PO Grid.
    Please help, how can i fill ALL the data in to my PO Grid?
    Thanks in Advance
    SAGAR

    The easisest way is to create datasource and the result bind to grid.
    Datasource:
               oDBDataSource = oForm.DataSources.DBDataSources.Add("@usertablename")
                Dim xoConditions As SAPbouiCOM.Conditions
                Dim xoCondition As SAPbouiCOM.Condition
                xoConditions = New SAPbouiCOM.Conditions
                xoCondition = xoConditions.Add
                xoCondition.BracketOpenNum = 1
                xoCondition.Alias = "u_zn"
                xoCondition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL
                xoCondition.CondVal = "cond"
                xoCondition.BracketCloseNum = 1
                oDBDataSource.Query(xoConditions)
    binding (example for matrix, in grid is simillar)
                oMatrix.Clear()
                Dim cols As SAPbouiCOM.Columns
                Dim column As SAPbouiCOM.Column
                cols = oMatrix.Columns
                column = cols.Item("colX")
                column.DataBind.SetBound(True, "@usertable", "u_x")
    oMatrix.LoadFromDataSource()
    hoep it helps
    Petr

  • 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

  • Update the data in user-defined table

    Dear All,
    Is there anyway we can insert / update the data in user-defined table in a batch instead of update it from the interface one by one? Our customer has 1,000+ data need to be imported.
    They are on SAP2007A SP00 PL45, SQL 2005, CA localization. Thanks a lot.
    Regards,
    yuka

    Dear Yuka,
    If it is UDT, you may use any SQL query to insert, update it. It is not under SAP support anyway.
    Thanks,
    Gordon

  • HOW TO TRANSFER USER DEFINED TABLE DATA IN NEW DATABASE

    Dear all , I am trying to transfer user defined table data,in new database ,can you please tell how i can do it

    Thanks for Quick responce
    I have Following databases
    1) Targate Database EOU TEST
    2) Source database  STI_BLANK
    Table @MACHINE
    I tried But it has some error
    INSERT INTO EOU TEST.@MACHINE
    SELECT STI_BLANK.@MACHINE* FROM STI_BLANK.@MACHINE
    Edited by: Abhijit Bhise on Apr 1, 2010 3:27 PM
    Edited by: Abhijit Bhise on Apr 1, 2010 3:28 PM

  • Dealing with User Defined Tables with the DI Server

    I have a general question about the best way of working with the data in user defined tables using the DI Server. It appears from previous posts that it is not possible to use the standard methods such as UpdateObject. Also since update/insert and delete statements or explicitly forbidden using the ExecuteSQL method then how do we interact with the data in the tables?
    Do we need to code our own data access layer for this type of access and is this a good practice?
    Is this type of functionality going to be available in a future release of the DI Server?
    Thanks

    Using SQL for Update/Insert/Delete is not forbidden on UDTs (at least non-UDO UDTs; UDO UDTs are somehow in a gray area since they carry internal fields + e.g. inserts require further manipulation in B1 tables...)...
    I.e. using ExecuteSQL to add data into UDTs is OK for DI Server...
    HTH,
    Frank

  • What is the Object Type for User Define table ?

    Dear All Experts,
    I create one of the User Define Table with no. of UDF's
    I already register User Define Table with Unique ID.
    As per my knowledge, Unique ID is our Object type for that User Define Table.
    I want to add Transaction Notification Code for created Used Define Table.
    This Transaction Notification prevents user to must enter name in that form.
    IF (@object_type = 'Z_Roto' AND (@TRANSACTION_TYPE = 'A' or @TRANSACTION_TYPE = 'U'))
    BEGIN
    If not Exists (Select T0.DocEntry from [@Z_ROTO] T0 Where ( T0.Name is null  OR  T0.Name = ' ' ) AND T0.Code  = @list_of_cols_val_tab_del )
    begin
    SET @error = 1
    SET @error_message = 'Name is NULL then So, Please enter ZERO Value i.e. 0 in Filed_Name'
    End
    End
    Please help me for this problem.
    Thanks & Regards,
    Nishit Makadia

    Hi All,
    Thanks for your replay.
    Below code is working for User Define Table's Transaction Notification
    IF (@transaction_type = 'A' OR @transaction_type = 'U') AND @object_type = 'Z_Roto'
    BEGIN
    If Exists (Select T0.Code from [@Z_ROTO] T0 Where ( T0.Name is null  OR  T0.Name = ' ' ) AND T0.Code  = @list_of_cols_val_tab_del)
    begin
    select @error = 10
    select @error_message = 'Name is NULL then So, Please enter ZERO Value i.e. 0 in Filed_Name'
    End
    End
    Necessary to Remember 4 Things. That are mentioned below.
    1) Register User Define Table (UDT) with using "Object Registration Wizard". For Example : @object_type = 'Z_Roto'
    2) When you define selection criteria then it must be compulsory for use Code Field. For Example : Select T0.Code from [@Z_Roto]
    3) When you define selection criteria then it must be compulsory for use Code for @list_of_cols_val_tab_del.
    4) Use error code as 10 Number
    Thanks & Regards,
    Nishit Makadia

  • Formatted search in the User defined table

    Hi All..
    I created two user defined table one is for document row and other is for document master.So in the master table created one column named as Sales order no and through formatted search call the sales order no in that column.Now i want that in my child table i want to show the those items which belongs to the selected sales order no in the master table.So how can i do that through Formatted search.Is there any query of it then please forward it..
    Thanks

    Ya Sure..
    I need some quality check on the items after delivery so i am trying to manage it through the user defined tables.I created two tables first is document type ,Second is Document type rows.Now i created 5 user defined field in both the table.Now i want to call my sales order and its items in the UDT.so i created one fms and call the sales order in the Document table now when i double click on the first row after that i am able to see the new table which is the document row table .Now i need the item code and description of the selected sales order in the document rows table.So how the items and description can come in the row type table through FMS..
    I hope now u r able to get my scenario..

Maybe you are looking for