on 10-18-2008 6:05 AM
Hi,
I have been through all the Matrix Samples and read many threads here but I just dont get a few things with the Matrix.
I have created an add on that adds a new folder to the Business Partners Form,
I can have built a matrix in this form and created bound columns bound to my UDO Table @xxxx
I have an event that fires when a business partner is chosen and the folder is only shown when a Customer is selected.
I can even get the matrix to fill with data related to the specific customer only when the customer is selected - using conditions on the DBDataSource.
This is all great but the 2 problems I have are :
I have created a button called Add Row that Adds a Row to Matrix - this button turns into an Update button when the row is added in the Matrix.
Problem 1 : When the row is added in the Matrix it takes the data from the last row of the data and duplicates it in the new row - you can change this data of course however I would like a blank row inserted instead.
Problem 2 : When I update I do a Matrix.FlushToDataSource - then I requery but it has not saved the new entry ?
How do I get the new entry to save into the database.
Any Help would be appreciated.
Thanks
hi,
i think u have given buttonUID as '1'.
remove 1 as uid and assign some other UID
because 1 is default for Add and 2 is default for Cancel Buttons in SAP B1.
so, that you can over come changing of caption from addrow to update.
in update mode if u add a row the new row automatically gets duplicated.it is SAP B1 functionality.
in order to overcome that
before adding row to matrix
Use following code.
oForm.Freeze(True)
oMatrix.AddRow()
oMatrix.Columns.Item("ColumnUID").Cells.Item(oMatrix.RowCount).Specific.Value="" 'if it is string and numeric type of columns.
oMatrix.Columns.Item("ColumnUID").Cells.Item(oMatrix.RowCount).Specific.Value="0" 'if it is Double type of columns for eg: Quantity,Rate, Price etc.
oForm.Freeze(False)
regards,
varma
Edited by: Varma on Oct 18, 2008 11:06 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks -
I didn't have a problem with the button - thanks for your help on the new Row.
Now how about saving the record.
the records in the matrix relate only to the currently selected business partner and I am trying to get the column that is U_CARDCODE to be hidden - I still dont understand how to save the newly entered matrix row to the UDO DBDatasouce
Hi..
1.problem u have to give (omatrix.Rowcount)
2.problem delete udo and again create.
Regards..
Billa 2007
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
if u dont mind,
can u send me image of your screen how u r adding.
regards,
varma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks - I sent the Screen shot - here is the event code
If ((pVal.FormType = 134 And pVal.EventType <> SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD) And (pVal.Before_Action = True)) Then
oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)
If ((pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD) And (pVal.Before_Action = True)) Then
oNewItem = oForm.Items.Add("BOMFolder", SAPbouiCOM.BoFormItemTypes.it_FOLDER)
oItem = oForm.Items.Item("9")
oNewItem.Top = oItem.Top
oNewItem.Height = oItem.Height
oNewItem.Width = oItem.Width
oNewItem.Left = oItem.Left + oItem.Width
oFolderItem = oNewItem.Specific
oFolderItem.Caption = "Lynxs BOM"
oFolderItem.GroupWith("9")
SetupBOMMatrix()
oForm.PaneLevel = 1
End If
If pVal.EventType = SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST Then
If pVal.ItemUID = "mat" Or pVal.ItemUID = "colitem" Then
Try
Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent
oCFLEvento = pVal
Dim sCFL_ID As String
sCFL_ID = oCFLEvento.ChooseFromListUID
Dim oForm1 As SAPbouiCOM.Form
oForm1 = SBO_Application.Forms.Item(FormUID)
Dim oCFL As SAPbouiCOM.ChooseFromList
oCFL = oForm1.ChooseFromLists.Item(sCFL_ID)
If oCFLEvento.BeforeAction = False Then
Dim oDataTable As SAPbouiCOM.DataTable
oDataTable = oCFLEvento.SelectedObjects
Dim val As String
Dim nam As String
Try
val = oDataTable.GetValue(0, 0)
nam = oDataTable.GetValue(1, 0)
Catch ex As Exception
val = "none"
nam = "none"
End Try
Try
Call UpdateCells(oForm1, pVal.Row, val, nam)
Catch
MsgBox("Couldnt Set Data Tables")
End Try
End If
Catch
MsgBox("Error in Item Event - CFL : " & Err.Description)
End Try
End If
End If
If pVal.ItemUID = "btnAddRow" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.Before_Action = True Then
'
'
'
' SOMETHING IS AMISS HERE
'
'
'
Dim ob As SAPbouiCOM.Button = oForm.Items.Item("btnAddRow").Specific
Dim oe As SAPbouiCOM.EditText = oForm.Items.Item("5").Specific
oMatrix = oForm.Items.Item("mat").Specific
If MatrixMode = "Nothing" Then
oMatrix.AddRow()
Dim i As Integer
i = oMatrix.RowCount
Dim oc As SAPbouiCOM.Column
Dim ocell As SAPbouiCOM.Cell
Dim oed As SAPbouiCOM.EditText
oc = oMatrix.Columns.Item("colArea")
oed = oc.Cells.Item(i).Specific
oed.String = ""
oc = oMatrix.Columns.Item("colItem")
oed = oc.Cells.Item(i).Specific
oed.String = ""
oc = oMatrix.Columns.Item("colItemtxt")
oed = oc.Cells.Item(i).Specific
oed.String = ""
oc = oMatrix.Columns.Item("colFitted")
oed = oc.Cells.Item(i).Specific
oed.Value = 0
oc = oMatrix.Columns.Item("colCritica")
oed = oc.Cells.Item(i).Specific
oed.Value = 0
oc = oMatrix.Columns.Item("colSpares")
oed = oc.Cells.Item(i).Specific
oed.Value = 0
MatrixMode = "Add"
ob.Caption = "Update Row"
Else
oMatrix.FlushToDataSource()
Dim oConditions As SAPbouiCOM.Conditions
Dim ocondition As SAPbouiCOM.Condition
oConditions = New SAPbouiCOM.Conditions
ocondition = oConditions.Add
ocondition.BracketOpenNum = 1
ocondition.Alias = "U_CARDCODE"
ocondition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL
ocondition.CondVal = oe.Value.ToString
ocondition.BracketCloseNum = 1
oDBDatasource.Query(oConditions)
oMatrix.LoadFromDataSource()
MatrixMode = "Nothing"
ob.Caption = "Add Row"
End If
End If
If pVal.ItemUID = "BOMFolder" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.Before_Action = True Then
'// when the new folder is clicked change the form's pane level
'// by doing so your items will apear on the new folder
'// assuming they were placed correctly and their pane level
'// was also set accordingly
oForm.PaneLevel = 11
End If
End If
Hai Nick,
Did i understand ur question or not i dont know. Now u need is to save the matrix values in ur table rite..
Instead of creating new table, you can insert the fields in existing table its very easier.If u do so, while u creating matirx itself u can write the following code.
This is the code snippnet
oItem = PO_Frm.Items.Add("oMat", SAPbouiCOM.BoFormItemTypes.it_MATRIX)
oItem.Top = 170 '210
oItem.Left = 20
oItem.Height = 150
oItem.Width = 500
oItem.FromPane = 100
oItem.ToPane = 100
oMat = oItem.Specific
oCols = oMat.Columns
oCol = oCols.Add("LineId", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oCol.TitleObject.Caption = "#"
oCol.Width = 30
oCol.Editable = True
PO_Frm.DataSources.UserDataSources.Add("DS_code", SAPbouiCOM.BoDataType.dt_SHORT_TEXT)
oCol = oCols.Add("TextCode", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oCol.DataBind.SetBound(True, "", "DS_code")
oCol.TitleObject.Caption = "Code"
oCol.Width = 150
oCol.ChooseFromListUID = "CFL1"
oCol.ChooseFromListAlias = "TextCode"
PO_Frm.DataSources.UserDataSources.Add("DS_desc", SAPbouiCOM.BoDataType.dt_LONG_TEXT)
oCol = oCols.Add("Text", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oCol.DataBind.SetBound(True, "", "DS_desc")
oCol.TitleObject.Caption = "Description"
oCol.Width = 300
oMat.AddRow()
PO_Frm.Items.Item("112").Click()
oMat = PO_Frm.Items.Item("38").Specific
This code specifies the matrix with two fields code and description.
After creating this, u run the code and click add button the data's will save automatically in the database.
Regards,
Anitha
Hi Ani,
Thanks for the reply, I think I have worked out the the matrix flushtodatasource will not work for me.
The matrix loads only with records that are related to the current Business Partner so when I add new rows I think I need to :
My table is called @LYNXS_SPARES
To do the save I need to
Do a DELETE FROM @LYXNS_SPARES WHERE U_CARDCODE = 'currentcard'
Then INSERT INTO @LYNXS_SPARES (Columns) VALUES
(Iterate through the Matrix rows)
So - Have I got it right, and How do I do this easiest and most effectively ?
My reasoning here is that I think the Matrix is like a blank spreadsheet - you must load into it from a datasource and then dump out of it back into a datasource - thus the flushtodatasource command clears the datasource then relaoads with the contents of the matrix - it is not full-time connected like a .net datagrid - Yes ?
Thanks.
User | Count |
---|---|
98 | |
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.