Skip to Content
0
Former Member
Feb 17, 2009 at 03:06 AM

Problem on reading a multiple entry in the Grid

26 Views

Hi experts, I have a validation of data entry on every row before add and update, my problem is, it read only the first row... below is my code.... any help would be appreciated...

If pVal.ItemUID = "1" Then

If (oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE _

Or oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE) Then

mCol = ""

mItem = ""

Select Case pVal.FormTypeEx

Case "392"

mItem = "76"

mCol = "1"

Case "670"

mItem = "28"

mCol = "7"

Case "170" Or "426"

mItem = "71"

mCol = "8"

Case Else

mItem = "38"

mCol = "29"

End Select

Try

i = 1

oForm = SBO_Application.Forms.Item(pVal.FormUID)

Do While True

mValMsg = ""

mVal = ""

mDept = ""

mClient = ""

mBill = ""

mEquipt = ""

mEmp = ""

mValMsg = ""

oMtrx = oForm.Items.Item(mItem).Specific

oEdit = oMtrx.Columns.Item(mCol).Cells.Item(i).Specific

mVal = oEdit.Value

If mVal = "" Then

oMtrx = oForm.Items.Item("39").Specific

oEdit = oMtrx.Columns.Item("2").Cells.Item(i).Specific

mVal = oEdit.Value

End If

If mVal = "" Then Exit Do

If oForm.DataSources.DataTables.Count = 0 Then oForm.DataSources.DataTables.Add("QryTable")

oForm.DataSources.DataTables.Item("QryTable").ExecuteQuery("select u_department,u_client,u_billing,u_equipment,u_employee from oact where acctcode = '" & Trim(mVal) & "'")

mValMsg = IIf(Trim(oForm.DataSources.DataTables.Item("QryTable").Columns.Item(0).Cells.Item(0).Value) = "Y", " DEPARTMENT,", "")

mValMsg = mValMsg & IIf(Trim(oForm.DataSources.DataTables.Item("QryTable").Columns.Item(1).Cells.Item(0).Value) = "Y", " CLIENT,", "")

mValMsg = mValMsg & IIf(Trim(oForm.DataSources.DataTables.Item("QryTable").Columns.Item(2).Cells.Item(0).Value) = "Y", " BILLING,", "")

mValMsg = mValMsg & IIf(Trim(oForm.DataSources.DataTables.Item("QryTable").Columns.Item(3).Cells.Item(0).Value) = "Y", " EQUIPMENT,", "")

mValMsg = mValMsg & IIf(Trim(oForm.DataSources.DataTables.Item("QryTable").Columns.Item(4).Cells.Item(0).Value) = "Y", " EMPLOYEE", "")

mFields = Trim(oForm.DataSources.DataTables.Item("QryTable").Columns.Item(0).Cells.Item(0).Value) _

& Trim(oForm.DataSources.DataTables.Item("QryTable").Columns.Item(1).Cells.Item(0).Value) _

& Trim(oForm.DataSources.DataTables.Item("QryTable").Columns.Item(2).Cells.Item(0).Value) _

& Trim(oForm.DataSources.DataTables.Item("QryTable").Columns.Item(3).Cells.Item(0).Value) _

& Trim(oForm.DataSources.DataTables.Item("QryTable").Columns.Item(4).Cells.Item(0).Value)

oEdit = oMtrx.Columns.Item(mDept_Col).Cells.Item(i).Specific

mDept = oEdit.Value

oEdit = oMtrx.Columns.Item(mClient_Col).Cells.Item(i).Specific

mClient = oEdit.Value

oEdit = oMtrx.Columns.Item(mBill_Col).Cells.Item(i).Specific

mBill = oEdit.Value

oEdit = oMtrx.Columns.Item(mEquipt_Col).Cells.Item(i).Specific

mEquipt = oEdit.Value

oEdit = oMtrx.Columns.Item(mEmp_Col).Cells.Item(i).Specific

mEmp = oEdit.Value

If (mDept = "" And Mid(mFields, 1, 1) = "Y") Or _

(mClient = "" And Mid(mFields, 2, 1) = "Y") Or _

(mBill = "" And Mid(mFields, 3, 1) = "Y") Or _

(mEquipt = "" And Mid(mFields, 4, 1) = "Y") Or _

(mEmp = "" And Mid(mFields, 5, 1) = "Y") Then

SBO_Application.MessageBox("Mandatory field(s) at ROW(" & Str(i) & ")" & mValMsg & Space(22) & " cannot be empty")

BubbleEvent = False

Exit Sub

End If

i = i + 1

If mVal = "" Then

BubbleEvent = True

Exit Sub

End If

Loop

Catch ex As Exception

If Err.Number = -7030 Then

BubbleEvent = True

Throw ex

Exit Sub

Else

SBO_Application.SetStatusBarMessage(Err.Number & " " & Err.Description, SAPbouiCOM.BoMessageTime.bmt_Medium)

BubbleEvent = False

End If

End Try

End If

End If