cancel
Showing results for 
Search instead for 
Did you mean: 

Filter BP Choose From List

Former Member
0 Kudos

Hi All,

I have been trying this from a few days now and have tried around a lot of things.

I need to filter the data in BP choose from list by Sales Person.

I tried using the Conditions and Condition object but it firstly I couldn't find which is the unique id for the choose from list as there are 33 choose from list associated with BP Master Data screen.

Then I found the 7th Choose from list using OCRD (BP Master Table) and passed my condition to that choose from list but it would not filter.

This is the last thing in my add on that is stopping me to go ahead.

Any ideas or sample code is highly appreciated.

Many Thanks.

Regards

Sameer Shingala.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

1. add CFL Using screen painter,

2. add this code on Event form load

        'filter cfl
        Dim oCFL As SAPbouiCOM.ChooseFromList
        Dim oCond As SAPbouiCOM.Condition
        Dim oConds As SAPbouiCOM.Conditions

        oCFL = Form.ChooseFromLists.Item("CFL_2")
        oConds = oCFL.GetConditions
        If oConds.Count > 0 Then 'If there are already user conditions.
            oConds.Item(oConds.Count - 1).Relationship = SAPbouiCOM.BoConditionRelationship.cr_AND
        End If
        oCond = oConds.Add()
        oCond.Alias = "SlpCode"
        oCond.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL
        oCond.CondVal = "1"
        oCFL.SetConditions(oConds)
Former Member
0 Kudos

Hi Arun,

Please find the code i have tried

SAPbouiCOM.ChooseFromList objCHSFRMLIST = objForm.ChooseFromLists.Item("7"); //Where objForm = "134" BP Master Data Form.

SAPbouiCOM.Conditions emptCond = new SAPbouiCOM.Conditions();

objCHSFRMLIST.SetConditions(emptCond);

SAPbouiCOM.Conditions objConditions = objCHSFRMLIST.GetConditions();

SAPbouiCOM.Condition objCondition;

objCondition = objConditions.Add();

objCondition.Alias = "SLPCODE";

objCondition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;

objCondition.CondVal = "1";

objCHSFRMLIST.SetConditions(objConditions);

Many Thanks,

Regards

Sameer Shingala.

former_member689126
Active Contributor
0 Kudos

Hi

Is it a user defined form..

Try this one. This will set the BP choose from list with condition

private void AddChooseFromList(Form oForm)
{

	try {
		SAPbouiCOM.ChooseFromListCollection oCFLs = default(SAPbouiCOM.ChooseFromListCollection);
		SAPbouiCOM.Conditions oCons = default(SAPbouiCOM.Conditions);
		SAPbouiCOM.Condition oCon = default(SAPbouiCOM.Condition);
		oCFLs = oForm.ChooseFromLists;

		SAPbouiCOM.ChooseFromList oCFL = default(SAPbouiCOM.ChooseFromList);
		SAPbouiCOM.ChooseFromListCreationParams oCFLCreationParams = default(SAPbouiCOM.ChooseFromListCreationParams);
		oCFLCreationParams = B1Connections.theAppl.CreateObject(BoCreatableObjectType.cot_ChooseFromListCreationParams);
		oCFLCreationParams.MultiSelection = false;
		oCFLCreationParams.ObjectType = "2"; //BP
		oCFLCreationParams.UniqueID = "BPCFL";

		oCFL = oCFLs.Add(oCFLCreationParams);

		// Adding Conditions 

		oCons = oCFL.GetConditions();

		oCon = oCons.Add();
		oCon.Alias = "SLPCODE ";
		oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
		oCon.CondVal = "1";
		// SLPCODE =1
		oCFL.SetConditions(oCons);

	} 
     catch {
		Interaction.MsgBox(Err.Description);
	}
}

Former Member
0 Kudos

Hi Arun,

I have done the something except for one change in instantiating the object oCFLCreationParams. You have in your code used B1Connections object.

oCFLCreationParams = B1Connections.theAppl.CreateObject(BoCreatableObjectType.cot_ChooseFromListCreationParams

If you please post a sample code to declare and instantiate B1Connections object will be of great help.

Many Thanks,

Regards

Sameer Shingala.

former_member689126
Active Contributor
0 Kudos

Hi Sameer

Use this code

private SAPbouiCOM.Application SBO_Application;

private void AddChooseFromList(Form oForm)
{
	try {
		SAPbouiCOM.ChooseFromListCollection oCFLs = null;
		SAPbouiCOM.Conditions oCons = null;
		SAPbouiCOM.Condition oCon = null;
		oCFLs = oForm.ChooseFromLists;

		SAPbouiCOM.ChooseFromList oCFL = null;
		SAPbouiCOM.ChooseFromListCreationParams oCFLCreationParams = null;
		oCFLCreationParams = SBO_Application.CreateObject(BoCreatableObjectType.cot_ChooseFromListCreationParams);
		oCFLCreationParams.MultiSelection = false;
		oCFLCreationParams.ObjectType = "2";
		//BP
		oCFLCreationParams.UniqueID = "BPCFL";

		oCFL = oCFLs.Add(oCFLCreationParams);

		// Adding Conditions 

		oCons = oCFL.GetConditions();

		oCon = oCons.Add();
		oCon.Alias = "SLPCODE ";
		oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
		oCon.CondVal = "1";
		// SLPCODE =1

		oCFL.SetConditions(oCons);
	} catch {
		Interaction.MsgBox(Err.Description);
	}
}

i am using B1DE for addon development in that we use B1Connections.theAppl instead of private SAPbouiCOM.Application SBO_Application .

Regards

Arun

Former Member
0 Kudos

Hi Arun,

I got offline with this project for a few days.

I still have this problem.

I tried Adding the Choose from list as you suggested.

But now it does not even pops the CFL.

What I fail to understand is that if once we have added the CFL to the Form (FORM 134)?

How would the form know that it needs to pop up this newly added CFL?

Please provide some help on this one.

Many Thanks

Regards

Sameer.

former_member689126
Active Contributor
0 Kudos

Hi

Can you please post your code .

Business Partner object choose from list id is 2.

Regards

Arun