Skip to Content
0
Former Member
Sep 08, 2011 at 11:36 AM

Cant add the coloums in the table

22 Views

dear all

i had done the following code but its not working

mean its running well but cant added the coloums in the database table.....

can you tell me whats wrong in thes code

  Public Sub FieldsForMCHAR()
        Try

            Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD
            i = 0
            oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)

            oUserFieldsMD.TableName = "MCHAR"
            oUserFieldsMD.Name = "CharType"
            oUserFieldsMD.Description = "Characteristic Type "
            oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Alpha
            oUserFieldsMD.SubType = SAPbobsCOM.BoFldSubTypes.st_None
            oUserFieldsMD.Size = 20
            oUserFieldsMD.EditSize = 20
            Try
                i = oUserFieldsMD.Add()
                SBO_Application.StatusBar.SetText("Field : " & oUserFieldsMD.Name, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success)
            Catch ex As Exception
            End Try



            System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD)
            oUserFieldsMD = Nothing
            oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
            oUserFieldsMD.TableName = "MCHAR"
            oUserFieldsMD.Name = "CreateBy"
            oUserFieldsMD.Description = "Created By"
            oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Alpha
            oUserFieldsMD.SubType = SAPbobsCOM.BoFldSubTypes.st_None
            oUserFieldsMD.Size = 15
            oUserFieldsMD.EditSize = 15
            Try
                i = oUserFieldsMD.Add()
                SBO_Application.StatusBar.SetText("Field : " & oUserFieldsMD.Name, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success)
            Catch ex As Exception
            End Try


            System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD)
            oUserFieldsMD = Nothing
            oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
            oUserFieldsMD.TableName = "MCHAR"
            oUserFieldsMD.Name = "REMARK"
            oUserFieldsMD.Description = "REMARK"
            oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Memo
            oUserFieldsMD.SubType = SAPbobsCOM.BoFldSubTypes.st_None
            'oUserFieldsMD.Size = 15
            'oUserFieldsMD.EditSize = 15
            Try
                i = oUserFieldsMD.Add()
                SBO_Application.StatusBar.SetText("Field : " & oUserFieldsMD.Name, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success)
            Catch ex As Exception
            End Try


            System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD)
            oUserFieldsMD = Nothing
            oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
            oUserFieldsMD.TableName = "MCHAR"
            oUserFieldsMD.Name = "UpdateBY"
            oUserFieldsMD.Description = "UpdateBY"
            oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Alpha
            oUserFieldsMD.SubType = SAPbobsCOM.BoFldSubTypes.st_None
            oUserFieldsMD.Size = 15
            oUserFieldsMD.EditSize = 15
            Try
                i = oUserFieldsMD.Add()
                SBO_Application.StatusBar.SetText("Field : " & oUserFieldsMD.Name, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success)
            Catch ex As Exception
            End Try

            System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD)
            oUserFieldsMD = Nothing
            oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
            oUserFieldsMD.TableName = "MCHAR"
            oUserFieldsMD.Name = "GrpCode"
            oUserFieldsMD.Description = "GrpCode"
            oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Alpha
            oUserFieldsMD.SubType = SAPbobsCOM.BoFldSubTypes.st_None
            oUserFieldsMD.Size = 15
            oUserFieldsMD.EditSize = 15

            Try
                i = oUserFieldsMD.Add()
                SBO_Application.StatusBar.SetText("Field : " & oUserFieldsMD.Name, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success)
            Catch ex As Exception
            End Try

            System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD)
            oUserFieldsMD = Nothing
            oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
            oUserFieldsMD.TableName = "PDN1"
            oUserFieldsMD.Name = "QA"
            oUserFieldsMD.Description = "QA Status"
            oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Alpha
            oUserFieldsMD.SubType = SAPbobsCOM.BoFldSubTypes.st_None


            oUserFieldsMD.ValidValues.Value = "D"
            oUserFieldsMD.ValidValues.Description = "Done"
            oUserFieldsMD.ValidValues.Add()
            oUserFieldsMD.ValidValues.Value = "A"
            oUserFieldsMD.ValidValues.Description = "Pending"
            oUserFieldsMD.ValidValues.Add()
            oUserFieldsMD.ValidValues.Value = "NA"
            oUserFieldsMD.ValidValues.Description = "Not Applicable"


            oUserFieldsMD.DefaultValue = "NA"

            oUserFieldsMD.Size = 50
            oUserFieldsMD.EditSize = 50
            Try
                i = oUserFieldsMD.Add()
                SBO_Application.StatusBar.SetText("Field : " & oUserFieldsMD.Name, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success)
            Catch ex As Exception
            End Try


            System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD)
            oUserFieldsMD = Nothing
            oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
            oUserFieldsMD.TableName = "MCHAR1"
            oUserFieldsMD.Name = "VldValue"
            oUserFieldsMD.Description = "Valid Values"
            oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Alpha
            oUserFieldsMD.SubType = SAPbobsCOM.BoFldSubTypes.st_None
            oUserFieldsMD.Size = 50
            oUserFieldsMD.EditSize = 50
            Try
                i = oUserFieldsMD.Add()
                SBO_Application.StatusBar.SetText("Field : " & oUserFieldsMD.Name, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success)
            Catch ex As Exception
            End Try





            System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD)
            oUserFieldsMD = Nothing
            GC.Collect()

        Catch ex As Exception
            SBO_Application.MessageBox(ex.Message)
        End Try


    End Sub  

Edited by: kishor karanjkar on Sep 8, 2011 1:37 PM