cancel
Showing results for 
Search instead for 
Did you mean: 

Problem binding a matrix in the Sales Order Form

Former Member
0 Kudos

Hi everybody!

I am working in an Add-On. What I do is modify the sales order form in runtime. I catch the event when the form is loading and then I add a new folder with some fields and a matrix.

I've got a matrix in this form with the employees that participate in an order and when I go through all the orders by using the next and previous record buttons I have to rebind it to show the participants in a specific order. The code for the event is the following:

If (pVal.ItemUID = "57") And pVal.Before_Action = False And pVal.EventType = et_ITEM_PRESSED Then

BindParticipantGrid

BubbleEvent = False

End If

After bind the grid, BO shows a System message indicating that the form has been changed and asking me if I want to save the changes to the order. Looks like, whenever the bind function finds rows to add to the matrix it changes the mode of the form by adding rows to the matrix. How can I prevent that when I'm in view mode?

This is the code for the binding function

Sub BindParticipantGrid()

Dim myForm As SAPbouiCOM.Form

Dim oMatrix As SAPbouiCOM.Matrix

Dim rs As sapbobsCOM.Recordset

Dim strSQL, OrdreNr As String

Dim oText As SAPbouiCOM.EditText

Set myForm = SBOApplication.Forms.GetFormByTypeAndCount(139, 1)

Set oText = myForm.Items("8").Specific

If oText.Value <> "" Then

OrdreNr = oText.Value

Else

OrdreNr = "0"

End If

Set oMatrix = myForm.Items("matrix").Specific

oMatrix.Clear

Set rs = myCompany.GetBusinessObject(sapbobsCOM.BoObjectTypes.BoRecordset)

strSQL = "SELECT [@HL_PART].Code as Code, [@HL_PART].U_DocNum as DocNum, [@HL_PART].U_EmpId as EmpId, [@HL_PART].U_EmpName as EmpName, [@HL_PART].U_Message as Message, [@HL_PART].U_MessRead as MessRead, [@HL_PART].U_MainPart as MainPart, [@HL_PART].U_StartDt as StartDt, [@HL_PART].U_StartHr as StartHr, [@HL_PART].U_FinishDt as FinishDt, [@HL_PART].U_FinishHr as FinishHr, [@HL_PART].U_Finished as Finished FROM [@HL_PART] WHERE [@HL_PART].U_DocNum = " & OrdreNr

rs.DoQuery strSQL

While Not rs.EOF

myForm.DataSources.UserDataSources.Item("EmpId").Value = rs.fields("EmpId").Value

myForm.DataSources.UserDataSources.Item("EmpName").Value = rs.fields("EmpName").Value

myForm.DataSources.UserDataSources.Item("Message").Value = rs.fields("Message").Value

myForm.DataSources.UserDataSources.Item("MessRead").Value = rs.fields("MessRead").Value

myForm.DataSources.UserDataSources.Item("MainPart").Value = rs.fields("MainPart").Value

myForm.DataSources.UserDataSources.Item("StartDt").Value = rs.fields("StartDt").Value

myForm.DataSources.UserDataSources.Item("StartHr").Value = rs.fields("StartHr").Value

myForm.DataSources.UserDataSources.Item("FinishDt").Value = rs.fields("FinishDt").Value

myForm.DataSources.UserDataSources.Item("FinishHr").Value = rs.fields("FinishHr").Value

myForm.DataSources.UserDataSources.Item("Finished").Value = rs.fields("Finished").Value

oMatrix.AddRow

rs.MoveNext

Wend

oMatrix.SelectionMode = ms_Auto

End Sub

I will apreciate all king of help

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You have a property of the form which allows you to change the mode

myForm.Mode = fm_ADD_MODE

myForm.Mode = fm_EDIT_MODE

myForm.Mode = fm_VIEWMODE_MODE

.....

You may change it after you modify you matrix data to fm_VIEWMODE_MODE and I guess you won't have the system question again.

Sebastien

Answers (0)