Add CFL into the matrix columns in SAP B1

Add CFL into the matrix columns:-

Add CFL into the matrix columns in SAP B1. In this post, I will explain to you how to Add CFL into the matrix columns.CFL stands for ChooseFromList .It is feature of the sap that allow you to put the CFl on form items like EditText,Column,Button ,etc.Through it we can  choose value from the list for the form items.

Examples:

I have made a function for adding the CFL into the matrix column. We need to pass only some parameters to this
function that is required for putting the CFL into the matrix.

STEP 1:-We will call the function on the form load event.

private void onLoad(){

SAPbouiCOM.Conditions oSearchConditions = null;

oColumn = oMatrix.Columns.Item(“ColItemCode”);                                                              AddChooseFromList(oColumn, “4”, “ItemCode”, false, oSearchConditions, ClsSBOAddOn.SBOApplication);

 

}

STEP 2:-Now Let me explain ,what are these parameters all about.

oColumn : This parameter is specific column of the matrix.(with ColUID-“ColItemCode”).
strObjectType : This parameter takes ObjectID (like 1,2,3,4).You want to open in to the columns.(Ex-4 for the Item Master)
strAliasName :This parameter takes field name of the database column.(Ex-“ItemCode”)
oCFLCollection :It is a collection of ChooseFromList Objects in the form. (Ex- oCFLs = oForm.ChooseFromLists)
bIsMultiSelect :this parameter takes true or false.If true then you can select multiple values if false then we can select only single value.(Ex-False)
oConditions : condition on which you want to filters the record.(Ex-SAPbouiCOM.Condition oCondition=null; pass oCondition object if you don’t want to put condition)
oSBOApplication:Pass Aplication Object

STEP 3:-Now i am  giving the definition of the function.

public static void AddChooseFromList(SAPbouiCOM.Column oColumn, string strObjectType, string strAliasName,SAPbouiCOM.ChooseFromListCollection oCFLCollection, bool bIsMultiSelect, SAPbouiCOM.Conditions oConditions, SAPbouiCOM.Application oSBOApplication)
{
try
{
SAPbouiCOM.ChooseFromList oCFL;
SAPbouiCOM.ChooseFromListCreationParams oCFLCreationParams;

oCFLCreationParams = (SAPbouiCOM.ChooseFromListCreationParams)oSBOApplication.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams);

oCFLCreationParams.MultiSelection = bIsMultiSelect;
oCFLCreationParams.ObjectType = strObjectType;

string strCFLID = GetChooseFromListID(oSBOApplication);
oCFLCreationParams.UniqueID = strCLFID;
oCFL = oCFLCollection.Add(oCFLCreationParams);

oCFL.SetConditions(oConditions);

oColumn.ChooseFromListUID = strCLFID;
oColumn.ChooseFromListAlias = strAliasName;
}
catch (Exception ex)
{

}
}

After calling this function Cfl will be opend on the column of the matrix but the selected value can not be set on the columns of the matrix.

STEP4:- Setting the selected value into the column.
For setting on the column what will have to do ,we need to put code for setting the value in the column in ChooseFromListAfter event. This code is as:
Example:- Suppose ColumnId=”ColItemCode” and we have made matrix instance as oMatrix. Then we can set the value into the column as.

protected override void CHOOSE_FROM_LIST_AFTERACTION(ref SAPbouiCOM.ItemEvent pVal, SAPbouiCOM.DataTable oDataTable, out bool BubbleEvent)
{
BubbleEvent = true;
try
{
//It Contains information about the current choose from list event,
SAPbouiCOM.ChooseFromListEvents oCflEvent=null;

//Here pVal is an ItemEvent ,Thus we need to cast it as ChooseFromListEvent to access it as ChooseFromListEvent .
oCflEvent= (SAPbouiCOM.ChooseFromListEvent)pVal;
if (oCflEvent.SelectedObjects != null)
{

((SAPbouiCOM.EditText)oMatrix.Columns.Item(“ColItemCode”).Cells.Item(pVal.Row).Specific).Value=oCflEvent.SelectedObjects.GetValue(“ItemCode”, 0).ToString();

 

//You can also set into the datasource                                                                                           oDBHeader.SetValue(“U_UNE_ITCD”, oDBHeader.Offset, oCflEvent.SelectedObjects.GetValue(“ItemCode”, 0).ToString());
}
}
Catch(Exception ex)
{
throw ex;
}
}

 


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!