Esempio n. 1
0
        public static void CreateUDT(String udtName, String udtDesc, SAPbobsCOM.BoUTBTableType udtType)
        {
            if (!CheckTableExists(udtName))
            {
                //SDK -> UserTableMD Object -> Fields Required
                SAPbobsCOM.IUserTablesMD oUDTMD = null;
                try
                {
                    // 1. Get Company Object
                    oUDTMD = AddOnUtilities.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);

                    // 2. Set Table Properties
                    oUDTMD.TableName        = udtName;
                    oUDTMD.TableDescription = udtDesc;
                    oUDTMD.TableType        = udtType;
                    // 3. Add

                    AddOnUtilities.IRetCode = oUDTMD.Add();
                    // 4. Error Handling
                    AddOnUtilities.DIErrorHandler(String.Format("UDT {0} Created.", udtName));
                }
                catch (Exception ex)
                {
                    AddOnUtilities.MsgBoxWrapper(ex.Message + " " + ex.StackTrace, Enum.MsgBoxType.B1StatusBar, SAPbouiCOM.BoMessageTime.bmt_Short, true);
                }
                finally
                {
                    //Important - release COM Object
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oUDTMD);
                    GC.Collect();
                    oUDTMD = null;
                }
            }
        }
Esempio n. 2
0
        private static bool CheckTableExists(String tableName)
        {
            SAPbobsCOM.IUserTablesMD oUdtMD = null;
            bool blnFlag = false;

            try
            {
                tableName = tableName.Replace("@", "");
                oUdtMD    = AddOnUtilities.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);

                if (oUdtMD.GetByKey(tableName))
                {
                    blnFlag = true;
                }
            }
            catch (Exception ex)
            {
                blnFlag = false;
                AddOnUtilities.MsgBoxWrapper(ex.Message + " " + ex.StackTrace);
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oUdtMD);
                oUdtMD = null;
                GC.Collect();
            }

            return(blnFlag);
        }