Ramco Ramco

Ramco Ramco

  • 440
  • 3.4k
  • 529.1k

Menu class not getting called

Apr 19 2024 11:05 AM

Hi

  I have below code but menu class is not getting called.

namespace Sap_B1
{
    static class Program
    {
        public static SAPbouiCOM.Application oApplication = null;
        public static SAPbobsCOM.Company oCompany = null;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            try
            {
                CreateConnection();
                Menu oMenuItems = null;
                oMenuItems = new Menu();

                //  Start Message Loop
                System.Windows.Forms.Application.Run();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }
}
}

-----------------------------------------------------------------------------------------
namespace Sap_B1
{
    class Menu
    {
        public void AddMenuItems()
        {
            SAPbouiCOM.Menus oMenus = null;
            SAPbouiCOM.MenuItem oMenuItem = null;

            oMenus = Program.oApplication.Menus;
 
            SAPbouiCOM.MenuCreationParams oCreationPackage = null;
            oCreationPackage = ((SAPbouiCOM.MenuCreationParams)(Program.oApplication.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)));
            oMenuItem = Program.oApplication.Menus.Item("43520"); // moudles'

            string sPath;
            //sPath = Application.StartupPath;
            //sPath = sPath.Remove(sPath.Length - 3, 3);

            oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_POPUP;
            oCreationPackage.UniqueID = "MyMenu";
            oCreationPackage.String = "Salary Module";
            oCreationPackage.Enabled = true;
            //oCreationPackage.Image = sPath & "UI.bmp";
            oCreationPackage.Position = 15;

            oMenus = oMenuItem.SubMenus;
}
}
}

Thanks


Answers (1)