cancel
Showing results for 
Search instead for 
Did you mean: 

Menu not getting created

ramco1917
Participant
0 Kudos

Hi

 I have below code but Menu not getting created

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

View Entire Topic
ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi ramco1917,

Your code is not complete. You are not adding the Menus in the end.

You should use something as below:

 

oMenus.AddEx( oCreationPackage );

 

Hope it helps!

Kind regards,

ANKIT CHAUHAN

SAP Business One Support