Skip to Content
0

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

May 11, 2017 at 01:07 PM

98

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
ANKIT CHAUHAN
May 11, 2017 at 01:16 PM
1

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

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hi, Ankit

Thanks for your reply.

I am not very familiar with using add-ons, as I am still developing my add-on.

.

> Why do I want so much customization?

Really don't know. I was just thinking that my future users won't have access to Administration module.

So, I think it would be better to have a sub-menu in Inventory (to which they do have access)

.

> Why don't you set the add-on startup to 'Mandatory'

I did a test with Mandatory. I am not sure what Mandatory does. It seems this runs the add-on automatically when SAP is opened.

.

It may help you to understand my problem if I give you a few additional facts:

The add-on we are developing is quite huge, and I don't think I will make it install automatically (more likely I will make it run manually) to save memory. At the same time, I would like to give a facility to our users to run the add-on by simply clicking on a sub-menu).

.

Clicking a menu is just something I am thinking of. But there may be more practical solutions.What would be the best advice you can give me?

I am thinking of something like SAP B1 Studio. I don't use Studio, and hard code everything in VB.NET.

But I find the idea interesting: you click on a sub-menu, and the add-on runs! .... How can we achieve this wonder?

.

Best Regards,

Leon

0

Hi Leon,

If add-on startup is set to 'Mandatory' then the add-on will be started automatically. Also user will not be able to stop this add-on from Administration module. It will be mandatory to have this add-on.

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0

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

0
Rudá Gonçalves May 11, 2017 at 02:28 PM
1

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", "", "");
            }
        }


    }
}


Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hi, Rudá

Thanks for your reply.

I'll try your suggestion. However, I have 2 problems:

1. I use Visual Studio 2010. Does your code work with VS 2010?

2. I use VB.NET i/o C#. I'll try to convert.

Best Regards

Leon

0

I guess it works on any VS version as long as you are using "SAP Business Onde SDK.dll" and not those obsolete dlls.

0

Thanks again, Rudá

Leon

0