on 03-11-2015 11:07 AM
Hi,
I need to add a menu option in right click menu of BP master, and on click of that menu, run a User Defined Query (query can be hardcoded).
How to do this? Can I get sample code.
Thanks.
hi,
In your code.
Please write the above code...
in Right click event
========================================
Try
Dim x As Integer
Dim foundG As Boolean = False
For x = 0 To SBO_Application.Forms.Count - 1
If SBO_Application.Forms.Item(x).Type = "134" Then
foundG = True
Exit For
End If
Next
If foundG = True Then
oForm = SBO_Application.Forms.ActiveForm
Try
Dim omenus As SAPbouiCOM.Menus
Dim omenuitem As SAPbouiCOM.MenuItem
Dim oCreationPackage As SAPbouiCOM.MenuCreationParams
oCreationPackage = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)
oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING
omenuitem = SBO_Application.Menus.Item("1280") 'Data'
'If Not omenuitem.SubMenus.Exists("delrow") Then
oCreationPackage.UniqueID = "Open Emp Master"
oCreationPackage.String = "Open Emp Master"
oCreationPackage.Enabled = True
omenus = omenuitem.SubMenus
If Not omenuitem.SubMenus.Exists("Open Emp Master") Then
omenus.AddEx(oCreationPackage)
End If
Catch ex As Exception
SBO_Application.MessageBox(ex.Message)
End Try
End If
Catch ex As Exception
SBO_Application.MessageBox(ex.Message)
End Try
End Sub
=============================================================
in menu event
Try
If pVal.BeforeAction = False Then
Select Case pVal.MenuUID
Case "Open Emp Master"
oForm = SBO_Application.Forms.ActiveForm
oForm = SBO_Application.Forms.GetFormByTypeAndCount("134", 1)
'' Here u can do what ever u wnat
' if u want to run query using recordset object run the query...
End Select
End If
Catch ex As Exception
SBO_Application.MessageBox(ex.Message)
End Try
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In your code, why are you first looping over all the forms and doing this comparison:
If SBO_Application.Forms.Item(x).Type = "134"
Secondly, you are checking whether the menu item already exists..
Is this approach better, or the one suggested by Ankit where he is removing the menu, after the Right Click?
Thanks.
ok I think I got it. Since the event does not have any property to check the form type, and the Form UID keeps changing every time, so you are checking whether the required form is currently open or not.
But cant you simply check the Form Type for the Active Form, instead of looping over all forms?
For the sake of completeness, I think I need to compare the Form Type for the ActiveForm. Otherwise if say Business Partner form is open but not the Active Form, then the right click menu will come in whichever active form, which is wrong.
So I have added the condition to check :
C# code:
if (activeForm.Type == 134)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
There is a sample in SDK Help Center for this:
|
Hope it helps.
Thanks & Regards
Ankit Chauhan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
104 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.