Skip to Content
author's profile photo Former Member
Former Member

Item Already Exists

Hi

I have created Grid , it is giving me error "Item already exists [66000-13] Form Unique ID : F_28, Item Unique ID : MyGrid

oNewItem = oForm.Items.Add("MyGrid", SAPbouiCOM.BoFormItemTypes.it_GRID)

I want that if Grid already exists then it should not recreate Grid

Thanks

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Nov 12, 2012 at 01:15 AM

    Hi Sunny,

    You should learn how to debug your application.

    When you browse for a record, your application threw an error.

    The error is in the Form Data Load Event on this line :

    Dim oGrid As SAPbouiCOM.Grid = oForm.Items.Item("MyGrid")

    Change it to this :

    Dim oGrid As SAPbouiCOM.Grid = oForm.Items.Item("MyGrid").Specific

    Second, if you dont want the data to show when you first load your form, then remove the

                TryoForm.DataSources.DataTables.Add("MyDataTable")            Catch            End TryoForm.DataSources.DataTables.Item(0).ExecuteQuery("select CardCode, CardName, DocDate, DocNum, DocTotal, DocStatus from OINV")            oGrid.DataTable = oForm.DataSources.DataTables.Item("MyDataTable")

    from your Form Load Event.

    Regards

    Edy

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 08, 2012 at 01:39 AM

    Hi Sunny,

    You can use @Pedro Magueija code.

    But you need to do some fine tuning on your logic here.

    The Grid should not be re-added in the first place.

    You need to rethink when (which event) you should create the Grid.

    Since an item should never be added twice in a specific form, the best place to add an item in a form is during the Form Load event.

    This event is only triggered once during the lifetime of the form.

    Hence, you will need to worry about adding the item twice.

    Regards

    Edy

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Edy Simon

      Hi Edy

      Problem i am facing now is Grid appears on Blank record , on existing record Grid does not appear . Secondly when i close the form & re-opens again the NewTab does not appear.

      Private Sub SBO_Application_FormDataEvent(ByRef BusinessObjectInfo As SAPbouiCOM.BusinessObjectInfo, ByRef BubbleEvent As Boolean) Handles SBO_Application.FormDataEvent

      If ((BusinessObjectInfo.FormTypeEx = "60100" And BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD) And (BusinessObjectInfo.BeforeAction = False)) Then

      Dim oForm As SAPbouiCOM.Form = Me.SBO_Application.Forms.Item(BusinessObjectInfo.FormUID)

      Dim oGrid As SAPbouiCOM.Grid = oForm.Items.Item("MyGrid")

      Dim oDT As SAPbouiCOM.DataTable = oGrid.DataTable

      oDT.ExecuteQuery("select CardCode, CardName, DocDate, DocNum, DocTotal, DocStatus from OINV ")

      oGrid.DataTable = oDT

      oGrid.Columns.Item(0).Width = 50

      oGrid.Columns.Item(1).Width = 125

      oGrid.Columns.Item(2).Width = 75

      End If

      Endif

      Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

      If ((pVal.FormTypeEx = "60100" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD And pVal.BeforeAction = False)) Then

      oForm = SBO_Application.Forms.Item(pVal.FormUID)

      oForm.DataSources.UserDataSources.Add("FolderDS", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 1)

      oNewItem = oForm.Items.Add("UserFolder", SAPbouiCOM.BoFormItemTypes.it_FOLDER)

      oNewItem.AffectsFormMode = False

      oItem = oForm.Items.Item("147")

      oNewItem.Top = oItem.Top

      oNewItem.Height = oItem.Height

      oNewItem.Width = oItem.Width

      oNewItem.Left = oItem.Left + oItem.Width

      oFolderItem = oNewItem.Specific

      oFolderItem.Caption = "NewTab"

      oFolderItem.GroupWith("147")

      oForm.PaneLevel = 1

      oItem = oForm.Items.Item("15")

      oNewItem = oForm.Items.Add("MyGrid", SAPbouiCOM.BoFormItemTypes.it_GRID)

      oNewItem.FromPane = 8

      oNewItem.ToPane = 8

      oNewItem.Left = oItem.Left + 125

      oNewItem.Top = oItem.Top

      oNewItem.Width = 275

      oNewItem.Height = 175

      oGrid = oNewItem.Specific

      Try

      oForm.DataSources.DataTables.Add("MyDataTable")

      Catch

      End Try

      oForm.DataSources.DataTables.Item(0).ExecuteQuery("select CardCode, CardName, DocDate, DocNum, DocTotal, DocStatus from OINV")

      oGrid.DataTable = oForm.DataSources.DataTables.Item("MyDataTable")

      End If

      End sub

      Thanks

  • Posted on Nov 07, 2012 at 07:06 PM

    Hi Sunny,

    A quick way to check if an item exists is to do try catch block around it.

    bool ItemExists(Form oForm, string ItemUid){     Item oItem;     try     {              oItem = oForm.Items.Item(ItemUid);     }     catch(Exception e)     {          // item does not exist          return false;     }     return true;}

    Best regards,

    Pedro Magueija

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.