Skip to Content
Aug 02, 2016 at 04:21 PM

Update value UDF in OCRY table


Hi, I add a UDF in OCRY table with this code

            SAPbobsCOM.UserFieldsMD oUserFieldsMD;
            oUserFieldsMD = (SAPbobsCOM.UserFieldsMD)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields);
            oUserFieldsMD.TableName = "OCRY";
            oUserFieldsMD.Name = "MyField";
            oUserFieldsMD.Description = "My Field";
            oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Alpha;
            oUserFieldsMD.EditSize = System.Convert.ToInt32(3);

            lRetCode = oUserFieldsMD.Add();

            // Check for errors
            if (lRetCode != 0)
                int temp_int = lErrCode;
                string temp_string = sErrMsg;
                oCompany.GetLastError(out temp_int, out temp_string);
                Console.WriteLine("Field not Add: " + sErrMsg);

Now I want update this UDF's value.

I had try with the following code, but in this way the UDF is not able to modify

            SAPbobsCOM.CountriesService oCountries;
            oCountries = (SAPbobsCOM.CountriesService)oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.CountriesService);
            SAPbobsCOM.ICountriesParams oCountriesParams = oCountries.GetCountryList();

            SAPbobsCOM.CountryParams oCountryParams;

            for (int i = 0; i < oCountriesParams.Count - 1; i++)
                oCountryParams = oCountriesParams.Item(i);
                SAPbobsCOM.Country oCountry = oCountries.GetCountry(oCountryParams);
                String name = oCountry.Name;
                String code = oCountry.Code;

In this thread I mean that it is not possibile update the UDF value, but the thread have 10 years old and I hope in a solution.

Someone can help me?