コード例 #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;
                }
            }
        }
コード例 #2
0
        public static void CreateUDF(String udt, //can put business object as well
                                     String udfName, String udfDesc, SAPbobsCOM.BoFieldTypes udfType, SAPbobsCOM.BoFldSubTypes udfSubType, int udfEditSize, Dictionary <string, string> udfValidValues = null, SAPbobsCOM.BoYesNoEnum udfMandatory = SAPbobsCOM.BoYesNoEnum.tNO)
        {
            if (!CheckFieldExists(udt, udfName))
            {
                SAPbobsCOM.UserFieldsMD oUDFMD = null;

                try
                {
                    oUDFMD = AddOnUtilities.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields);

                    oUDFMD.TableName   = udt;
                    oUDFMD.Name        = udfName;
                    oUDFMD.Description = udfDesc;
                    oUDFMD.Type        = udfType;
                    oUDFMD.SubType     = udfSubType;
                    oUDFMD.EditSize    = udfEditSize;
                    oUDFMD.Mandatory   = udfMandatory;

                    //foreach(var udfValidValue in udfValidValues)
                    //{
                    //    oUDFMD.ValidValues.Value = udfValidValue.Key;
                    //    oUDFMD.ValidValues.Value = udfValidValue.Key;
                    //    oUDFMD.ValidValues.Add();
                    //}

                    AddOnUtilities.IRetCode = oUDFMD.Add();

                    AddOnUtilities.DIErrorHandler(String.Format("UDF {0} Created.", udfName));
                }
                catch (Exception ex)
                {
                    AddOnUtilities.MsgBoxWrapper(ex.Message + " " + ex.StackTrace);
                }
                finally
                {
                    //Important - release COM Object
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oUDFMD);
                    GC.Collect();
                    oUDFMD = null;
                }
            }
        }