cancel
Showing results for 
Search instead for 
Did you mean: 

cfl for matrix

Former Member
0 Kudos

hi friends

i had created a form with a matrix and an editbox. i can apply the cfl for the editbox but i cant use the same for the first column of the matrix...can anyone provide any sample coding for this process

thanks and regards

manoj nagaraj

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

Look this. I think this code is complete.

Best regards

Sierdna S.


Public Sub SBO_CreateForm(...)
'... add controls to form, matrix, matrix columns,...
  Call AddChooseFromList(oForm)
  oForm.Visible = True
End Sub

Private Sub AddChooseFromList(ByRef oForm As SAPbouiCOM.Form)
  Try
    Dim oCFLs As SAPbouiCOM.ChooseFromListCollection
    Dim oCons As SAPbouiCOM.Conditions
    Dim oCon As SAPbouiCOM.Condition

    oCFLs = oForm.ChooseFromLists

    Dim oCFL As SAPbouiCOM.ChooseFromList
    Dim oCFLCreationParams As SAPbouiCOM.ChooseFromListCreationParams
    oCFLCreationParams = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams)

    ' CFL for Items ------------------------------
    oCFLCreationParams.MultiSelection = False
    oCFLCreationParams.ObjectType = 4
    ' Item Code
    oCFLCreationParams.UniqueID = "cflIC"
    oCFL = oCFLs.Add(oCFLCreationParams)
    oCons = oCFL.GetConditions()
    oCon = oCons.Add()
    ' Item Name
    oCFLCreationParams.UniqueID = "cflIN"
    oCFL = oCFLs.Add(oCFLCreationParams)
    oCons = oCFL.GetConditions()
    oCon = oCons.Add()
    ' CFL button
    oCFLCreationParams.UniqueID = "cflIB"
    oCFL = oCFLs.Add(oCFLCreationParams)
    oCons = oCFL.GetConditions()
    oCon = oCons.Add()

    Catch ex As Exception
      ' log exception
    Finally
      System.GC.Collect() 'Release the handle to the table
    End Try
End Function

Public Sub ManageItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean)
  Dim oForm As SAPbouiCOM.Form
  oForm = SBO_Application.Forms.Item(FormUID)

  Select Case pVal.EventType
    Case BoEventTypes.et_CHOOSE_FROM_LIST
      If Not pVal.BeforeAction Then

	Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent
	oCFLEvento = pVal
	Dim sCFL_ID As String
	sCFL_ID = oCFLEvento.ChooseFromListUID
	Dim oCFL As SAPbouiCOM.ChooseFromList
	oCFL = oForm.ChooseFromLists.Item(sCFL_ID)

	Dim oDataTable As SAPbouiCOM.DataTable
	oDataTable = oCFLEvento.SelectedObjects

	Dim sCode As String = ""
	Dim sName As String = ""
	Try
	  sCode = oDataTable.GetValue(0, 0) ' Code
	  sName = oDataTable.GetValue(1, 0) ' Name
	Catch ex As Exception
	  sCode = ""
	  sName = ""
	  ' log exception
	End Try
	' Rows
	If (pVal.ColUID = "colICode") Or (pVal.ColUID = "colIName") Then
	  oForm.DataSources.DBDataSources.Item("@USER_TABLE").SetValue("U_ItemCode", pVal.Row, sCode)
	  oForm.DataSources.DBDataSources.Item("@USER_TABLE").SetValue("U_ItemName", pVal.Row, sName)
	  Call UpdateCells(oForm, pVal.Row, sCode, sName)
	End If

      End If
    
  End Select

  oForm = Nothing

End Sub

Private Function UpdateCells(ByRef oForm As SAPbouiCOM.Form, ByVal iRow As Integer, _
			     ByVal sCode As String, ByVal sName As String) As Boolean
  Dim b As Boolean = True
  Try

    Dim oMatrix As SAPbouiCOM.Matrix
    Dim oColumn As SAPbouiCOM.Column
    Dim oCell As SAPbouiCOM.Cell
    Dim oEdit As SAPbouiCOM.EditText

    ' MatrixID
    oMatrix = oForm.Items.Item(MatrixID).Specific

    oColumn = oMatrix.Columns.Item("colICode")
    oCell = oColumn.Cells.Item(iRow)
    oEdit = oCell.Specific
    oEdit.String = sCode

    oColumn = Nothing
    oCell = Nothing
    oEdit = Nothing

    oColumn = oMatrix.Columns.Item("colIName")
    oCell = oColumn.Cells.Item(iRow)
    oEdit = oCell.Specific
    oEdit.String = sName

    oColumn = Nothing
    oCell = Nothing
    oEdit = Nothing
    oMatrix = Nothing

  Catch ex As Exception
    b = False
    ' log exception
  Finally
    System.GC.Collect() 'Release the handle to the table   
  End Try

  Return b

End Function

Former Member
0 Kudos

Just define a CFL in ur XML


<ChooseFromList UniqueID="ItemCFL" ObjectType="4" MultiSelection="0" IsSystem="0"/>

And chage the XML like this


    <column uid="ColUID" type="116" title="Activity" description="" visible="1" AffectsFormMode="1" width="121" disp_desc="0" editable="1" right_just="0" val_on="Y" val_off="N" backcolor="-1" forecolor="-1" text_style="0" font_size="-1" ChooseFromListUID="ItemCFL" ChooseFromListAlias="ItemCode">
                        <databind databound="1" table="@TableName" alias="U_XXX"/>
                        <ExtendedObject linkedObject="-1" LinkedObjectType="-1"/>
                        <ExtendedObject/>
                    </column>
                

Former Member
0 Kudos

hi sridhar

thanks for you coding.i modified all those things but how to run that xml file in the sap b1?

thanks and regards

manoj nagaraj

Former Member
0 Kudos

U should load the XML file in the menu event of ur class....