Skip to Content

How can we run an add-on by clicking a menu from SAP?

Hi, everybody

I have successfully registered a test add-on in SAP B1.

To run the add-on, this is what I should do:

> Modules > Administration > Add-ons > Add-on Manager > Start

I wish to run the add-on by clicking a menu in SAP, instead of doing as above.

For example, suppose I create a sub-menu called MYMENU within the INVENTORY MENU. (I know how to create the sub-menu.)

Now, I wish to run my add-on by simply clicking on MYMENU

How can we do this? Can anyone briefly outline the steps to achieve this?

I want the facility to remain permanently in SAP, unless I deliberately remove it.

Thank you

Leon

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    May 11, 2017 at 01:16 PM

    Hi Leon,

    Why don't you set the add-on startup to 'Mandatory' rather than doing so much customization?

    Kind regards,

    ANKIT CHAUHAN

    SAP SME Support

    Add comment
    10|10000 characters needed characters exceeded

    • Hi, Leon

      Thanks again.

      I'll see how I can adapt your helpful suggestions to my problem.

      Best Regards,

      Leon

      -----------------

      Added:

      I think I will adopt this simple solution - not too much customization as you said...

      I install the add-on as manual (so as not to consume too much memory when it's not in use) rather than mandatory or automatic.

      Then I give the users a shortcut (say F3) to Add-on Manager.

      This is the simplest solution (but which I have not thought before). I found that the users can have access to Add-on Manager without having access to other Admin menus.

      Best Regards,

      Leon

  • May 11, 2017 at 02:28 PM

    On Visual Studio 2013, a new SBO project has by default a file called Menu.cs which does this for you. Here's a sample

    using System;
    using System.Collections.Generic;
    using System.Text;
    using SAPbouiCOM.Framework;
    
    
    namespace ImportOrders
    {
        class Menu
        {
            public void AddMenuItems()
            {
                SAPbouiCOM.Menus oMenus = null;
                SAPbouiCOM.MenuItem oMenuItem = null;
    
    
                oMenus = Application.SBO_Application.Menus;
    
    
                SAPbouiCOM.MenuCreationParams oCreationPackage = null;
                oCreationPackage = ((SAPbouiCOM.MenuCreationParams)(Application.SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)));
                oMenuItem = Application.SBO_Application.Menus.Item("43520"); // modules'
    
    
                oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_POPUP;
                oCreationPackage.UniqueID = "ImportOrders";
                oCreationPackage.String = "ImportOrders";
                oCreationPackage.Enabled = true;
                oCreationPackage.Position = -1;
    
    
                oMenus = oMenuItem.SubMenus;
    
    
                try
                {
                    //  If the manu already exists this code will fail
                    oMenus.AddEx(oCreationPackage);
                }
                catch (Exception e)
                {
    
    
                }
    
    
                try
                {
                    // Get the menu collection of the newly added pop-up item
                    oMenuItem = Application.SBO_Application.Menus.Item("ImportOrders");
                    oMenus = oMenuItem.SubMenus;
    
    
                    // Create s sub menu
                    oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING;
                    oCreationPackage.UniqueID = "ImportOrders.Form1";
                    oCreationPackage.String = "Form1";
                    oMenus.AddEx(oCreationPackage);
                }
                catch (Exception er)
                { //  Menu already exists
                    Application.SBO_Application.SetStatusBarMessage("Menu Already Exists", SAPbouiCOM.BoMessageTime.bmt_Short, true);
                }
            }
    
    
            public void SBO_Application_MenuEvent(ref SAPbouiCOM.MenuEvent pVal, out bool BubbleEvent)
            {
                BubbleEvent = true;
    
    
                try
                {
                    if (pVal.BeforeAction && pVal.MenuUID == "ImportOrders.Form1")
                    {
                        Form1 activeForm = new Form1();
                        activeForm.Show();
                    }
                }
                catch (Exception ex)
                {
                    Application.SBO_Application.MessageBox(ex.ToString(), 1, "Ok", "", "");
                }
            }
    
    
        }
    }
    
    
    
    Add comment
    10|10000 characters needed characters exceeded