on 09-25-2008 8:02 AM
Hi,
In my form i have a combo. My requirement is, for example i load 5 data A,B,C,D,E in combo. First i select the 'A' and load the corresponding elements in the matrix, next i select 'B' and the corresponding elements of 'B' was loaded in matrix now again i select 'A ' it should check 'A' is already selected and the corresponding elements are already displayed in matrix again the elements of 'A' should not be loaded in matrix. Plz tell how to check this.
Thanks in Advance.
Regards,
Madhavi
U can put this code into itemevent for button's et_ITEM_PRESSED with beforeaction = true :
Set objComboBox = objForm.Items.Item("combo").Specific
Set objMatrix = objForm.Items.Item("mtx").Specific
Set objColumns = objMatrix.Columns
For loopcombo = 0 to (objcombobox.ValidValues.Count - 1)
strComboValue = Trim(objComboBox.ValidValues.Item(loopcombo).Value)
blnExist = False
For i = 1 To objMatrix.RowCount
If trim(objColumns.item("newcolumn").Cells(i).Specific.Value) = strComboValue Then
blnExist = True
exit for
End If
Next i
if Not blnExist then
bubbleevent = false
---display some message error here
exit sub
End If
Next loopcombo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, the code assume the combobox not inside the matrix.
Which part or code that confuse u ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
U can put this code into itemevent for et_combo_select :
Set objComboBox = objForm.Items.Item("combo").Specific
strComboValue = Trim(objComboBox.Selected.Description)
Set objMatrix = objForm.Items.Item("mtx").Specific
Set objColumns = objMatrix.Columns
blnAdd = True
For i = 1 To objMatrix.RowCount
If trim(objColumns.item("newcolumn").Cells(i).Specific.Value) = strComboValue Then
blnAdd = False
bubbleevent = false
exit sub
End If
Next i
If blnAdd then
---U can put code here to run select query, and the query result is adding to the matrix.
---When add into the matrix, fill also objColumns.item("newcolumn").Cells(i).Specific.Value = strComboValue
End If
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Madhavi,
here are the main parts of my little example.
Some hints:
The form is managed in a shared class (only one form at a time)
The Matrix is loaded via a DataTable
The Matrix is ReLoaded on every time the "ABCDE-Combo" is selected (except the value is already selected)
In the example I load Businesspartners into matrix where their CardName starts with A or B or....or E (you must adapt it for your needs)
SboCon.SboDI is the SAPbobsCOM.Company
SboCon.SboUI is the SAPbouiCOM.Application
Some global vars (initialize them somewhere when the form is opened!):
Private Shared oForm As SAPbouiCOM.Form
Private Shared oUds As SAPbouiCOM.UserDataSources
Private Shared oDts As SAPbouiCOM.DataTables
Private Shared oDtBp As SAPbouiCOM.DataTable
Private Shared oMtxBp As SAPbouiCOM.Matrix
Private Shared SelVals As System.Collections.ArrayList ' The values of the combo which already selected by the user
Init the vars somewhere (where you normally do this) on form load:
oForm = '...set it in your way
oDts = oForm.DataSources.DataTables
oUds = oForm.DataSources.UserDataSources
oMtxBp = oForm.Items.Item("MTX_BP").Specific
' DataBinding and related:
'### Data Tables
'#
oDts.Add("DT_BP")
'#
'###
'### UserDataSources
'#
'# ABCDE Combo:
oUds.Add("UDS_SELBP", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 100)
oForm.Items.Item("CBX_SELBP").Specific.databind.setbound(True, "", "UDS_SELBP")
'#
'###
'### Fill ABCDE Combo
'#
oForm.Items.Item("CBX_SELBP").DisplayDesc = True
oCbx = oForm.Items.Item("CBX_SELBP").Specific
oCbx.ValidValues.Add("0", "Please select...")
For val As Integer = Asc("A") To Asc("E")
oCbx.ValidValues.Add(Chr(val), "Load " & Chr(val) & " BP")
Next
oUds.Item("UDS_SELBP").ValueEx = "0"
'#
'###
The Combo Select Event:
If pVal.ItemUID = "CBX_SELBP" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_COMBO_SELECT Then
If Not pVal.BeforeAction Then
If oUds.Item("UDS_SELBP").ValueEx != "0" Then
Dim oCbx As SAPbouiCOM.ComboBox = oForm.Items.Item("CBX_SELBP").Specific
If SelVals.Contains(oUds.Item("UDS_SELBP").ValueEx) Then
' BP already selected - do nothing
SboCon.SboUI.StatusBar.SetText("Already selected!")
Else
If Not SelVals.Contains(oUds.Item("UDS_SELBP").ValueEx) Then
SelVals.Add(oUds.Item("UDS_SELBP").ValueEx)
End If
Dim query As String
oDtBp.Clear()
oMtxBp.Clear()
' Build query for BPs where their names starts with the Combo-Value
query = "SELECT CardCode, CardName FROM OCRD WHERE "
For i As Int16 = 0 To SelVals.Count - 1
If i > 0 Then query &= " OR "
query &= "CardName LIKE '" & SelVals(i) & "%' "
Next
query &= " ORDER BY CardName"
' load the MTX via DataTable (reloaded every time based on collected combo-values)
oDtBp.ExecuteQuery(query)
With oMtxBp.Columns
' Zeilen-Nr.
.Item("0").DataBind.Bind("DT_BP", "CardCode")
'
.Item("1").DataBind.Bind("DT_BP", "CardName")
End With
oMtxBp.LoadFromDataSource()
oMtxBp.AutoResizeColumns()
SboCon.SboUI.StatusBar.SetText(oUds.Item("UDS_SELBP").ValueEx & " added!", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success)
End If
' reset Combo to "Please select..."
oUds.Item("UDS_SELBP").ValueEx = 0
End If
End If
End If
ATTENTION: REPLACE the "!=" with less (<)/greater(>) symbol, they're not shown in ths forum
I hope I didn't forget sth. - here it works..
Cheers,
Roland
Edited by: Roland Toschek on Sep 25, 2008 11:54 AM
Hi
Try this with little modifications: change combobox name "cComboABC"; write Matrix_Fill(...) function.
Hope to help
Regards
Sierdna S.
Private Sub SBO_Application_ItemEvent( _
ByVal FormUID As String, _
ByRef pVal As SAPbouiCOM.ItemEvent, _
ByRef BubbleEvent As Boolean _
) Handles SBO_Application.ItemEvent
Dim oForm As SAPbouiCOM.Form
oForm = SBO_Application.Forms.Item(FormUID)
If pVal.EventType = SAPbouiCOM.BoEventTypes.et_COMBO_SELECT _
And pVal.FormUID = sgloFormUID _
And pVal.ItemUID = "cComboABC" _
And pVal.BeforeAction = False _
And pVal.ItemChanged = True _
Then
Try
Dim oCombo As SAPbouiCOM.ComboBox
Dim sValue As String = ""
oCombo = oForm.Items.Item("cComboABC").Specific()
If oCombo.Selected Is Nothing Then Throw New Exception("Select some value...")
sValue = oCombo.Selected.Value
' ++++++++++++++++++++++++++++++++++++
Select Case
Case "A"
' fill matrix for "A"
Call Matrix_Fill(oForm,"A")
Case "B"
' fill matrix for "B"
Call Matrix_Fill(oForm,"B")
Case "C"
' fill matrix for "C"
Call Matrix_Fill(oForm,"C")
Case "..."
' fill matrix for "..."
Call Matrix_Fill(oForm,"...")
Case else
End Select
' ++++++++++++++++++++++++++++++++++++
End If
BubbleEvent = False
Catch ex1 As Exception
' log exception
End Try
Catch ex As Exception
' log exception
End Try
End If
' Other events +++
End Sub
Private Sub Matrix_Fill(ByRef oForm As SAPbouicom.Form, sWitch As String)
Dim sSql As String = ""
sSql = "SELECT DocNum,.. FROM ... WHERE ..." ' modify select
oRS = SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oRS.DoQuery(sSql)
If oRS.RecordCount > 0 Then
Dim i As Integer = 0
oRS.MoveFirst()
While oRS.EoF = False
i = i + 1
' add matrix columns
oForm.DataSources.UserDataSources.Item("uNr").Value = i ' 1" matrix column for row number
oForm.DataSources.UserDataSources.Item("uDocNum").Value = oRS.Fields.Item("DocNum").Value
'...
oMatrix.AddRow()
oRS.MoveNext()
End While
End If
End Sub
Edited by: Sierdna S on Sep 25, 2008 9:21 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How about this :
Add one column which its value come from the combobox. And when u select the combobox, u loop the matrix and check the column's value whether there is row from the selected value from the combobox or not.
Regards,
Riny
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Riny,
I already tried as u said but i dont know how to check the value in matrix already exist. The code follow plz help how to do
Dim i As Integer
Dim CatVal As String
Dim rs As SAPbobsCOM.Recordset
Try
rs = Ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
rs.DoQuery("select distinct(U_catcode),U_paramcat from [@PSSIT_NPLANHDR] a, [@PSSIT_NPLANDTL] b where a.code = b.code and U_catcode is not null and a.u_itemcode ='" & itemcode & "' and a.U_supcode='" & supcode & "' ")
rs.MoveFirst()
For i = 1 To Oform.Items.Item("mat2").Specific.RowCount
CatVal = rs.Fields.Item(0).Value
If InStr(Oform.Items.Item("mat2").Specific.Columns.item("CatCode").Cells(i).Specific.Value, " & CatVal & ") > 0 Then
-
What Condition i should give here----
End If
Next i
Catch ex As Exception
Throw ex
End Try
madhavi
Edited by: Madhavi on Sep 25, 2008 9:55 AM
Hi,
U need to write ur code in the combo select event in the Before action = False part....
My suggestion is it will be more flexible for u if u have different matrices with differnt data and just make them visible and invisible depending on the value selected in the combo box.
Hope it helps,
Vasu Natari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
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.