cancel
Showing results for 
Search instead for 
Did you mean: 

Error in Choose from list on Matrix

Former Member
0 Kudos

Hi all,

I am using CFL in matrix for my user define form, When i choose a value from CFL , i am getting the following error

<b>" Item -Can't set value on item because the item can't get focus [66000-153]"</b>

<u>the code i used is given below</u>

<u>this is in Item Event</u>

Try

If FormUID = ("FRMIGRP") Then

If pVal.Before_Action = False Then

If (pVal.EventType = SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST) Then

' If pVal.EventType = SAPbouiCOM.BoEventTypes.et_GOT_FOCUS Then

Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent

oCFLEvento = pVal

Dim sCFL_ID As String

sCFL_ID = oCFLEvento.ChooseFromListUID

Dim oForm As SAPbouiCOM.Form

oForm = SBO_Application.Forms.Item(FormUID)

Dim oCFL As SAPbouiCOM.ChooseFromList

oCFL = oForm.ChooseFromLists.Item(sCFL_ID)

If oCFLEvento.BeforeAction = False Then

Dim oDataTable As SAPbouiCOM.DataTable

oDataTable = oCFLEvento.SelectedObjects

Dim val As String

Dim val1 As String

Dim val2 As String

Dim val3 As String

Try

val = oDataTable.GetValue(0, 0)

val1 = oDataTable.GetValue(1, 0)

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

Try

If (pVal.ItemUID = "txtcode") Then

Dim oDS As SAPbouiCOM.DBDataSource

oDS = oForm.DataSources.DBDataSources.Item("@PSSIT_GRPHDR") 'add your dbdatasource here

oDS.SetValue("U_grpcode", oDS.Offset, val) ' val1 is the value you are setting

oDS.SetValue("U_grpname", oDS.Offset, val1)

End If

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

Try

val2 = oDataTable.GetValue(0, 0)

val3 = oDataTable.GetValue(1, 0)

If (pVal.ItemUID = "matr") And (pVal.ColUID = "supp") Then

Dim oEdit As SAPbouiCOM.EditText

oMatrix.FlushToDataSource()

oForm.DataSources.UserDataSources.Item("EditDS2").ValueEx = val2.ToString

oEdit = subcol.Cells.Item(pVal.Row).Specific

oEdit.Value = val2.ToString

oEdit = subname.Cells.Item(pVal.Row).Specific

oEdit.Value = val3.ToString

("EditDS2").ValueEx = Nothing

End If

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End If

And i used data source also to set the value using below code, but for that also value is not set in to the field

Dim oEdit As SAPbouiCOM.EditText

Dim oDS As SAPbouiCOM.DBDataSource

oDS = oForm.DataSources.DBDataSources.Item("@PSSIT_GRPDTL") 'add your dbdatasource here

oDS.SetValue("U_supcode", oDS.Offset, val2) ' val1 is the value you are setting

oDS.SetValue("U_supname", oDS.Offset, val3)

SOmebody can help me to solve this issue

Regards

Suresh R

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

this is what I use:

Dim oedit As EditText

Dim oitem As Item

oitem = form.Items.Item("CMDPC")

oedit = oitem.Specific

oedit.DataBind.SetBound(True, "", "EditDS")

Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent

oCFLEvento = CFLEvent

Dim sCFL_ID As String

sCFL_ID = oCFLEvento.ChooseFromListUID

Dim oCFL As SAPbouiCOM.ChooseFromList

oCFL = form.ChooseFromLists.Item(sCFL_ID)

Dim oDataTable As SAPbouiCOM.DataTable

oDataTable = oCFLEvento.SelectedObjects

Dim val As String = ""

If Not (oDataTable Is Nothing) Then

val = oDataTable.GetValue(0, 0)

form.DataSources.UserDataSources.Item("EditDS").ValueEx = val

End If

Return val

Former Member
0 Kudos

Same code only i also used, but i used for Matrix. Have u used for matrix ?

Still i am facing same error

Could you pl help me on this

Suresh

Former Member
0 Kudos

Suresh,

Try this one,

Here i have used for check the dulpicate entry also, that is if we choose one item in the first row in second row or third we cant able to choose the same. If u no need just neglect it.

Case SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST And pVal.BeforeAction = False

Dim oCFLE As SAPbouiCOM.IChooseFromListEvent

oCFLE = pVal

Dim CFLID As String

CFLID = oCFLE.ChooseFromListUID

PI_Frm = app.Forms.Item(FormUID)

Dim oCFL As SAPbouiCOM.ChooseFromList

oCFL = PI_Frm.ChooseFromLists.Item(CFLID)

oCFL.UniqueID = "CFL2" Then

Dim oDT As SAPbouiCOM.DataTable

oDT = oCFLE.SelectedObjects

Try

Dim oMat As SAPbouiCOM.Matrix

Dim t, t1 As String

Dim Rec, Rec1, Rec2 As SAPbobsCOM.Recordset

oMat = PI_Frm.Items.Item("m_det").Specific

t = oDT.GetValue(0, 0)

t1 = oDT.GetValue(1, 0)

If Trim(HEAD_oDBds.GetValue("U_pid", 0)).Equals("") = False Then

oMat.Columns.Item("rate").Editable = False

Else

oMat.Columns.Item("rate").Editable = True

End If

Dim Bool As Boolean = False

For i As Integer = 1 To oMat.VisualRowCount

oMat.GetLineData(i)

If Trim(DETAIL_oDBds.GetValue("U_itno", (i - 1))).Equals(Trim(oDT.GetValue(0, 0))) = True Then

Bool = False

Exit For

Else

Bool = True

End If

Next

If Bool = True Then

If pVal.Row = oMat.VisualRowCount Then

oMat.AddRow()

oMat.FlushToDataSource()

Me.SetEmptyRow(DETAIL_oDBds.Size)

End If

Rec = com.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

Rec1 = com.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

Rec2 = com.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

Rec.DoQuery("select BuyUnitMsr from OITM where ItemCode ='" & Trim(oDT.GetValue(0, 0)) & "'")

DETAIL_oDBds.Offset = (pVal.Row - 1)

DETAIL_oDBds.SetValue("LineId", DETAIL_oDBds.Offset, pVal.Row)

DETAIL_oDBds.SetValue("U_itno", DETAIL_oDBds.Offset, oDT.GetValue(0, 0))

DETAIL_oDBds.SetValue("U_itdesc", DETAIL_oDBds.Offset, oDT.GetValue(1, 0))

DETAIL_oDBds.SetValue("U_unit", DETAIL_oDBds.Offset, Rec.Fields.Item(0).Value)

DETAIL_oDBds.SetValue("U_poqty", DETAIL_oDBds.Offset, "0")

DETAIL_oDBds.SetValue("U_qnos", DETAIL_oDBds.Offset, "0")

DETAIL_oDBds.SetValue("U_pur", DETAIL_oDBds.Offset, "")

Rec1.DoQuery("select U_basicrate from [@RATE_MASTER_DETAIL] where U_itemid='" & oDT.GetValue(0, 0) & "'")

DETAIL_oDBds.SetValue("U_rate", DETAIL_oDBds.Offset, Rec1.Fields.Item(0).Value)

Rec2.DoQuery("select a.OnHand ,b.ItemCode,b.DfltWH,a.WhsCode from OITW a,OITM b where a.ItemCode=b.ItemCode and b.DfltWH=a.WhsCode and b.DfltWH='01' and b.ItemCode='" & oDT.GetValue(0, 0) & "'")

DETAIL_oDBds.SetValue("U_stx", DETAIL_oDBds.Offset, Rec2.Fields.Item(0).Value)

oMat.SetLineData(pVal.Row)

End If

If it helps give me reward points.

Regards,

Anitha

Former Member
0 Kudos

Hi Anitha,

Thanks for ur reply... it helps me lot. Can i have a decleration part from ur code.. Where do u assign the "DETAIL_oDBds" datasource in grid?

Is it to be assigned to the control ?

i am getting error in the below line

i delecared DETAIL_oDBds as

Private DETAIL_oDBds As SAPbouiCOM.DataSource

In item event i used like this

DETAIL_oDBds.SetValue("U_supcode", DETAIL_oDBds.Offset, oDT.GetValue(0, 0))

but i am getting error as

<b>"Object variable or with block variable not set"</b>

can u help me on this

Regards

Suresh R

Former Member
0 Kudos

Thanks for ur points Suresh,

Dim DETAIL_oDBds As SAPbouiCOM.DBDataSource

DETAIL_oDBds = PI_Frm.DataSources.DBDataSources.Item("@PUR_PI_DETAIL")

This what i declared....

Regards,

Anitha

Former Member
0 Kudos

Hi Anitha,

Thanks for ur reply and it works for me also..

Can i have code for <b>"SetEmptyRow"</b> function. Becaz one more row is added with value , so i need to emty the next row. So if i have this its very helpful to me

Regards

Suresh

Former Member
0 Kudos

this is the Code,

Sub SetEmptyRow(ByVal Row As Integer)

Try

Dim oMatrix As SAPbouiCOM.Matrix

oMatrix = PI_Frm.Items.Item("m_det").Specific

DETAIL_oDBds.Offset = Row - 1

DETAIL_oDBds.SetValue("LineId", DETAIL_oDBds.Offset, oMatrix.VisualRowCount)

DETAIL_oDBds.SetValue("U_itno", DETAIL_oDBds.Offset, "")

DETAIL_oDBds.SetValue("U_itdesc", DETAIL_oDBds.Offset, "")

DETAIL_oDBds.SetValue("U_unit", DETAIL_oDBds.Offset, "")

DETAIL_oDBds.SetValue("U_stx", DETAIL_oDBds.Offset, "")

DETAIL_oDBds.SetValue("U_poqty", DETAIL_oDBds.Offset, "")

DETAIL_oDBds.SetValue("U_qnos", DETAIL_oDBds.Offset, "")

DETAIL_oDBds.SetValue("U_rate", DETAIL_oDBds.Offset, "")

DETAIL_oDBds.SetValue("U_total", DETAIL_oDBds.Offset, "")

DETAIL_oDBds.SetValue("U_rdate", DETAIL_oDBds.Offset, "")

DETAIL_oDBds.SetValue("U_act", DETAIL_oDBds.Offset, "")

DETAIL_oDBds.SetValue("U_pur", DETAIL_oDBds.Offset, "")

DETAIL_oDBds.SetValue("U_pdate", DETAIL_oDBds.Offset, "")

oMatrix.SetLineData(Row)

Catch ex As Exception

'app.MessageBox(ex.Message)

End Try

End Sub

Regards,

Anitha

Former Member
0 Kudos

Hi Anitha,

Thanks for ur reply.. It helps me lot

I gave u full mark..........

Regards

Suresh

Answers (1)

Answers (1)

Former Member
0 Kudos

Dim matrix As Matrix

Dim ocols As Columns

Dim ocol As Column

' Dim oEditItmPrice As EditText

Dim Item As Item

Item = form.Items.Item(CFLEvent.ItemUID)

matrix = CType(Item.Specific, Matrix)

ocols = matrix.Columns

ocol = ocols.Item("CMG61")

matrix.Columns.Item("CMG61").DataBind.SetBound(True, "", "EditItem")

'ocol.DataBind.SetBound(True, "", "EditItem")

matrix.GetLineData(CFLEvent.Row)

Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent

oCFLEvento = CFLEvent

Dim sCFL_ID As String

sCFL_ID = oCFLEvento.ChooseFromListUID

Dim oCFL As SAPbouiCOM.ChooseFromList

oCFL = form.ChooseFromLists.Item(sCFL_ID)

Dim oDataTable As SAPbouiCOM.DataTable

oDataTable = oCFLEvento.SelectedObjects

Dim val As String = ""

If Not (oDataTable Is Nothing) Then

val = oDataTable.GetValue(0, 0)

form.DataSources.UserDataSources.Item("EditItem").ValueEx = val

matrix.SetLineData(CFLEvent.Row)

End If

Return val