Skip to Content
0
Former Member
Jul 04, 2014 at 10:21 AM

Add or Update subGrid

43 Views

hi, every body.

i have a main form and left click on the form a new sub grid form open.

in the sub grid form i write Observations & Remarks against some items.then press the update button form close but the Observations & Remarks are not saved.

for more clarification of the scenario please see the attached screen short and the source code. My code is in vb.net.

on clicking the update button this SaveSubGrid() function invoke.

here is code:

Sub SaveSubGrid(ByVal Row As Integer)

Try

Dim initSize As Integer = v_dbdsn2.Size

Dim currSize As Integer = v_dbdsn2.Size

For i As Integer = 0 To initSize - 1

v_dbdsn2.Offset = i - (initSize - currSize)

If v_dbdsn2.GetValue("U_detailid", v_dbdsn2.Offset).Trim <> "" Then

If CInt(v_dbdsn2.GetValue("U_detailid", v_dbdsn2.Offset)) = Row Then

v_dbdsn2.RemoveRecord(v_dbdsn2.Offset)

End If

End If

currSize = v_dbdsn2.Size

Next

Dim matrix3 As SAPbouiCOM.Matrix

matrix3 = frmSubGridForm.Items.Item("sgrid").Specific

v_dbdsn3 = frmSubGridForm.DataSources.DBDataSources.Item("@QC_INWARDSGRID")

matrix3.FlushToDataSource()

Dim oEmpty As Boolean = True

If v_dbdsn2.Size = 0 Then

v_dbdsn2.InsertRecord(v_dbdsn2.Size)

End If

v_dbdsn2.Offset = 0

If v_dbdsn2.Size = 1 And Trim(v_dbdsn2.GetValue("U_detailid", v_dbdsn2.Offset)).Equals("") = True Then

oEmpty = True

Else

oEmpty = False

End If

For i As Integer = 0 To matrix3.VisualRowCount - 1

v_dbdsn3.Offset = i

If oEmpty = True Then

v_dbdsn2.Offset = v_dbdsn2.Size - 1

v_dbdsn2.SetValue("U_detailid", v_dbdsn2.Offset, Row)

v_dbdsn2.SetValue("U_pname", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_pname", i).Trim)

v_dbdsn2.SetValue("U_spec", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_spec", i).Trim)

v_dbdsn2.SetValue("U_observation", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_observation", i).Trim)

v_dbdsn2.SetValue("U_remarks", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_remarks", i).Trim)

If i <> (matrix3.VisualRowCount - 1) Then

v_dbdsn2.InsertRecord(v_dbdsn2.Size)

End If

ElseIf oEmpty = False Then

v_dbdsn2.InsertRecord(v_dbdsn2.Size)

v_dbdsn2.Offset = v_dbdsn2.Size - 1

v_dbdsn2.SetValue("U_detailid", v_dbdsn2.Offset, Row)

v_dbdsn2.SetValue("U_pname", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_pname", i).Trim)

v_dbdsn2.SetValue("U_spec", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_spec", i).Trim)

v_dbdsn2.SetValue("U_observation", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_observation", i).Trim)

v_dbdsn2.SetValue("U_remarks", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_remarks", i).Trim)

End If

Next

frmSubGridForm.Close()

Catch ex As Exception

oApplication.StatusBar.SetText("Save SubGrid Method Failed:" & ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)

Finally

End Try

End Sub

Attachments

error.png (28.6 kB)