Skip to Content
0
Nov 05, 2018 at 09:34 AM

Multiple Conditions in CFL (not working)

86 Views Last edit Nov 05, 2018 at 09:38 AM 2 rev

Hello there

I've been trying to make this excerpt of code to work but kept failing.

Here's the code I am working on.

 private void SetChooseFormList(string sUID) //ChooseFromList
    {


        SAPbouiCOM.Conditions oConds = null;
        SAPbouiCOM.Condition oCon = null;
        string oOpt;
        string oITMSGRPCOD = "";
        string oCHK = "";


        try
        {
            
            oITMSGRPCOD = oForm.DataSources.UserDataSources.Item("ITMSGRPCOD").Value.Trim();
            oCHK = oForm.DataSources.UserDataSources.Item("CHK").Value.Trim();
            Console.WriteLine("oITMSGRPCOD: " + oITMSGRPCOD);
            Console.WriteLine("oCHK:" + oCHK);




            //itemcode 
            if (sUID == "SCODE" | sUID == "ECODE")
            {


                if (oCHK == "Y") {
                    
                              
                    oCon = oConds.Add();
                    oCon.BracketOpenNum = 2;
                    oCon.Alias = "ITMSGRPCOD";
                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                    oCon.CondVal = oITMSGRPCOD;
                    oCon.BracketCloseNum = 1;
                    oCon.Relationship = SAPbouiCOM.BoConditionRelationship.cr_AND;
                    oCon = oConds.Add();
                    oCon.BracketOpenNum = 1;
                    oCon.Alias = "validFor";
                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                    oCon.CondVal = "Y";
                    oCon.BracketCloseNum = 2;


                    oForm.ChooseFromLists.Item("SCODE").SetConditions(oConds);
                    oForm.ChooseFromLists.Item("ECODE").SetConditions(oConds);


                }
                
                else 
                {


                    oCon = oConds.Add();
                    oCon.BracketOpenNum = 2;
                    oCon.Alias = "ITMSGRPCOD";
                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                    oCon.CondVal = oITMSGRPCOD;
                    oCon.BracketCloseNum = 1;
                    oCon.Relationship = SAPbouiCOM.BoConditionRelationship.cr_AND;
                    oCon = oConds.Add();
                    oCon.BracketOpenNum = 1;
                    oCon.Alias = "validFor";
                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                    oCon.CondVal = "N";
                    oCon.BracketCloseNum = 2;


                    oForm.ChooseFromLists.Item("SCODE").SetConditions(oConds);
                    oForm.ChooseFromLists.Item("ECODE").SetConditions(oConds);


                }


            }
            
        }


        catch (Exception Error)
        {
            ZSBO.SBO_Application.SetStatusBarMessage(Error.Message, SAPbouiCOM.BoMessageTime.bmt_Short, true);
        }
    }

What am I doing wrong here?

Thanks in advance!