cancel
Showing results for 
Search instead for 
Did you mean: 

How do I drop a UDT that doesn't have any records?

Former Member
0 Kudos

I have a UDT (not UDO). I want to use the .Remove method, because I want to clean up after myself, and the table is no longer needed. The UDT is empty, meaning it has no records/rows/keys. How do I use that method, without first using .GetByKey? Or must one first always .Add and then .GetByKey on the code that was just added? Is there another method?

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member185682
Active Contributor

Hi David,

You first should call GetByKey method.

A sample:

            UserTablesMD oUserTableMD = null;
            try
            {
                oUserTableMD = (SAPbobsCOM.UserTablesMD)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);


                if (oUserTableMD.GetByKey("Your user table name without @"))
                {
                    if(oUserTableMD.Remove() != 0)
                    {
                        //Something wrong, look oCompany.GetLastErrorCode() and oCompany.GetLastErrorDescription()
                    }
                }
                else
                {
                    //The table was not found
                }
            }
            catch(Exception ex)
            {
                //Something wrong
            }
            finally
            {
                //Release the resources used
                if (oUserTableMD != null)
                {
                    Marshal.ReleaseComObject(oUserTableMD);
                    oUserTableMD = null;
                }
            }

Kind Regards,

Diego Lother