on 2012 Apr 02 7:36 PM
Hi..........
Module1:
Module Module1
Public Sub main()
'// Creating an object
Dim a As Class1
a = New Class1
' Start Message Loop
System.Windows.Forms.Application.Run()
End Sub
End Module
class1:
Public Class Class1
Private WithEvents SBO_Application As SAPbouiCOM.Application
Private oCompany As SAPbobsCOM.Company
Private oform As SAPbouiCOM.Form
Public oMatrix As SAPbouiCOM.Matrix
Public oItem As SAPbouiCOM.Item
Dim oedit As SAPbouiCOM.EditText
Public oColumns As SAPbouiCOM.Columns
Public oColumn As SAPbouiCOM.Column
Dim filename As String
Public Sub New()
MyBase.New()
SetApplication()
If Not SetConnectionContext() = 0 Then
SBO_Application.MessageBox("Failed setting a connection to DI API")
End
End If
If Not ConnectToCompany() = 0 Then
SBO_Application.MessageBox("Failed connectting to the company's Data Base")
End
End If
AddMenuItems1()
AddMenuItems()
SBO_Application.MessageBox("DI Connected To: " & oCompany.CompanyName & "Add-on is loaded")
' oedit.DataBind.SetBound(True, "", "EditDS")
End Sub
Private Function ConnectToCompany() As Integer
'// Establish the connection to the company database.
ConnectToCompany = oCompany.Connect
End Function
Private Function SetConnectionContext() As Integer
Dim sCookie As String
Dim sConnectionContext As String
Try
oCompany = New SAPbobsCOM.Company
sCookie = oCompany.GetContextCookie
sConnectionContext = SBO_Application.Company.GetConnectionContext(sCookie)
If oCompany.Connected = True Then
oCompany.Disconnect()
End If
'// Set the connection context information to the DI API.
SetConnectionContext = oCompany.SetSboLoginContext(sConnectionContext)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function
Private Sub SetApplication()
Dim SboGuiApi As SAPbouiCOM.SboGuiApi
Dim sConnectionString As String
SboGuiApi = New SAPbouiCOM.SboGuiApi
sConnectionString = Environment.GetCommandLineArgs.GetValue(1)
' SboGuiApi.AddonIdentifier = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"
SboGuiApi.Connect(sConnectionString)
SBO_Application = SboGuiApi.GetApplication()
End Sub
Private Sub AddMenuItems1() ' Jobwork Receipts Menu adding
Dim oMenus As SAPbouiCOM.Menus ' The menus collection
Dim oMenuItem As SAPbouiCOM.MenuItem ' The new menu item
oMenus = SBO_Application.Menus
Dim oCreationPackage As SAPbouiCOM.MenuCreationParams
oCreationPackage = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)
oMenuItem = SBO_Application.Menus.Item("43520") 'moudles'
Dim sPath As String
sPath = Application.StartupPath
sPath = sPath.Remove(sPath.Length - 3, 3)
oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_POPUP
oCreationPackage.UniqueID = "SDK1"
oCreationPackage.String = "SDK Sample"
oCreationPackage.Enabled = True
'oCreationPackage.Image = IO.Directory.GetParent(Application.StartupPath).ToString & "\f1.BMP"
oCreationPackage.Position = 7
oMenus = oMenuItem.SubMenus
Try ' If the manu already exists this code will fail
oMenus.AddEx(oCreationPackage)
'oMenus.AddEx(oCreationPackage)
Catch er As Exception ' Menu already exists
SBO_Application.MessageBox("Menu Already Exists")
End Try
End Sub
Private Sub AddMenuItems()
Try
' API PharmaMenu adding
Dim oMenus As SAPbouiCOM.Menus
Dim oMenuItem As SAPbouiCOM.MenuItem
oMenus = SBO_Application.Menus
Dim oCreationPackage As SAPbouiCOM.MenuCreationParams
oCreationPackage = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)
oMenuItem = SBO_Application.Menus.Item("SDK1")
oMenus = oMenuItem.SubMenus
' oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING
' oCreationPackage.UniqueID = "I8_DM_"
'oCreationPackage.String = "Depreciation Master"
'oCreationPackage.Enabled = True
'oMenus.AddEx(oCreationPackage)
oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING
oCreationPackage.UniqueID = "ss"
oCreationPackage.String = "Sales item"
oCreationPackage.Enabled = True
oMenus.AddEx(oCreationPackage)
'Try ' If the manu already exists this code will fail
oMenus.AddEx(oCreationPackage)
'oMenus.AddEx(oCreationPackage)
Catch er As Exception ' Menu already exists
'SBO_Application.MessageBox("Menu Already Exists")
End Try
End Sub
Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
Try
If FormUID = "PA" Then
oform = SBO_Application.Forms.Item(FormUID)
Select Case pVal.EventType
Case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED
' '//************************************************************
' '// Check if the event was raised by one of the Folder items
' '// and change the form's pane level
' '//************************************************************
If pVal.ItemUID = "1000002" Then ' folder u_id number ' and their pane number
oform.PaneLevel = 1
End If
If pVal.ItemUID = "1000001" Then
oform.PaneLevel = 2
End If
End Select
End If
If pVal.Before_Action = True Then ' Tab functionality of "Indender" field.
Select Case pVal.FormUID
Case "PA"
Select Case pVal.EventType
Case SAPbouiCOM.BoEventTypes.et_KEY_DOWN
If pVal.ItemUID = "4" Then 'And pVal.FormMode = "3" Then 'cardcode id'
If (pVal.CharPressed = 9) Then
oform = SBO_Application.Forms.Item("PA") '
If (oform.Items.Item("4").Specific.Value = "") Then 'cardcode id'
BubbleEvent = False
SBO_Application.SendKeys("+{F2}")
Else
BubbleEvent = True
If (pVal.ItemUID = "4") Then 'cardcode id'
Dim ds1 As SAPbobsCOM.Recordset
ds1 = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
Dim sql As String
sql = " SELECT T0.[CardName] as n FROM OCRD T0 where T0.[CardCode]='" & oform.Items.Item("4").Specific.Value & "'"
ds1.DoQuery(sql)
oform.Items.Item("3").Specific.Value = ds1.Fields.Item("n").Value 'card name id'
oform = SBO_Application.Forms.Item("PA")
oItem = oform.Items.Item("1000003") 'matrix id'
oMatrix = oItem.Specific
oColumns = oMatrix.Columns
oMatrix.AddRow()
oMatrix.Columns.Item("V_-1").Cells.Item(oMatrix.RowCount).Specific.Value = oMatrix.RowCount
'' oform.Items.Item("4").Specific.Value = ds1.Fields.Item("n").Value
'' 'oForm.Items.Item("8").Specific.Value = ds1.Fields.Item("gp").Value
'' 'ds1.DoQuery("SELECT COUNT(T0.[U_ICODE]) AS CNT FROM [dbo].[@I8_FA] T0 WHERE T0.[U_ICODE]='" & oForm.Items.Item("9").Specific.Value & "' ")
'' 'Dim d As Double = 0.0
'' 'd = ds1.Fields.Item("CNT").Value
'' 'd = d + 1
'' 'oForm.Items.Item("30").Specific.Value = d ' ds1.Fields.Item("CNT").Value
End If
End If
End If
End If
End Select
End Select
End If
If pVal.Before_Action = True Then
' 'Update amount when qty is updated..
If pVal.FormUID = "PA" Then
If pVal.ItemUID = "1000003" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_KEY_DOWN Then 'matrix id'
If pVal.ColUID = "V_1" Then
If (pVal.CharPressed = 9) Then
Dim J As Integer
oform = SBO_Application.Forms.Item("PA")
oItem = oform.Items.Item("1000003")
oMatrix = oItem.Specific
oColumns = oMatrix.Columns
J = 0
J = CInt(pVal.Row)
Dim oColumn1 As SAPbouiCOM.Column
For Each oColumn1 In oMatrix.Columns
Select Case oColumn1.UniqueID
Case pVal.ColUID
oedit = oColumn1.Cells.Item(Int32.Parse(J)).Specific
If (oedit.Value = "") Then
BubbleEvent = False
SBO_Application.SendKeys("+{F2}")
Else
If (pVal.ColUID = "V_1") Then
Dim ds1 As SAPbobsCOM.Recordset
ds1 = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
Dim sql As String
sql = " SELECT T0.[ItemName] as n FROM OITM T0 where T0.[ItemCode]='" & oMatrix.Columns.Item("V_1").Cells.Item(pVal.Row).Specific.Value & "'" '2nd column
ds1.DoQuery(sql)
oMatrix.Columns.Item("V_0").Cells.Item(pVal.Row).Specific.Value = ds1.Fields.Item("n").Value ' 3rd column
' End If
oform = SBO_Application.Forms.Item("PA")
oItem = oform.Items.Item("1000003")
oMatrix = oItem.Specific
oColumns = oMatrix.Columns
oMatrix.AddRow()
oMatrix.Columns.Item("V_-1").Cells.Item(oMatrix.RowCount).Specific.Value = oMatrix.RowCount 'first column
End If
BubbleEvent = True
End If
End Select
Next
End If
End If
End If
'End Select
End If
End If
Catch ex As Exception
SBO_Application.MessageBox(ex.Message)
End Try
End Sub
Private Sub SBO_Application_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.MenuEvent
If pVal.BeforeAction = False Then '1281 for Find Mode
If pVal.MenuUID = "1282" Then
If filename = "sample.srf" Then
BubbleEvent = False
oform = SBO_Application.Forms.Item("PA")
' oform.DataBrowser.BrowseBy = "DocNum"
'oForm.Select()
' combo(5)
'getNextDocNum(2)
End If
End If
If pVal.MenuUID = "ss" Then
'End If
filename = "sample.srf"
Try
' SBO_Application.ActivateMenuItem("2050")
' oForm = SBO_Application.Forms.ActiveForm
oform = SBO_Application.Forms.Item("PA")
oform.Select()
Catch ex As Exception
DrawForm(filename)
oform = SBO_Application.Forms.Item("PA")
'oForm.DataBrowser.BrowseBy = "DocNum"
oform.SupportedModes = -1
End Try
End If
End If
End Sub
Private Sub DrawForm(ByRef filename As String) ' Drawing form
Try
LoadFromXML(filename)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub LoadFromXML(ByRef filename As String)
Dim oXmlDoc As Xml.XmlDocument
oXmlDoc = New Xml.XmlDocument
Dim sPath As String
sPath = IO.Directory.GetParent(Application.StartupPath).ToString
oXmlDoc.Load(sPath & "\" & filename)
SBO_Application.LoadBatchActions(oXmlDoc.InnerXml)
End Sub
Private Sub SaveAsXML(ByRef Form As SAPbouiCOM.Form)
Dim oXmlDoc As Xml.XmlDocument
Dim sXmlString As String
oXmlDoc = New Xml.XmlDocument
sXmlString = Form.GetAsXML
oXmlDoc.LoadXml(sXmlString)
Dim sPath As String
sPath = IO.Directory.GetParent(Application.StartupPath).ToString
oXmlDoc.Save((sPath & "MM.srf"))
oXmlDoc.Save((sPath & "TS.srf"))
End Sub
End Class
Plz see the image there is one matrix is there it contains three columns sno, one, two
sdk2, sdk3 --screen painter and their values , matrix and their values
at one if press and select iteam code , iteam name will come but it is comming with error bad value
where is the error...... i assigned the matrix column values currectly...........
Request clarification before answering.
Hi There,
Are these fields bounded to a table or a datasource? If yes then check your second column character limit.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 59 | |
| 29 | |
| 21 | |
| 11 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.