SAP SDK CHEAT SHEET HELP

 ---------------------------to Click on Matrix specific row Start--------------------

__mtrx.Columns.Item("V_3").Cells.Item(pVal.Row).Click(BoCellClickType.ct_Regular);


---------------------------to Click on Matrix specific row END--------------------

-------------------------disable/enable specific cell on the matrix Start-------------------

oMatrix.CommonSetting.SetCellEditable(Row number, Column Number , false);

----------------------disable/enable specific cell on the matrix END-----------------------


----------------------disable/enable specific Column on the matrix Start--------------------

oMatrix.Columns.Item("U_CIN_QTYINKG").Editable=false;

-----------------------disable/enable specific Column on the matrix END----------------------


--------------------Recordset Entry value getting and converting to string Start-------------------

Convert.ToString(oRecoEntry.Fields.Item(0).Value);

--------------------Recordset Entry value getting and converting to string end-------------------

--------------------WRITING QUERY WITH NEWLINE AND RECORDSET START-----------------------

 string serialNo_query = Environment.NewLine + "    Select Row_Number() over (order By  IntrSerial)[RowNo],T0.SysSerial,T1.MnfSerial, IntrSerial                    "

                                   + Environment.NewLine + "   into #a from OSRI T0                                                "

                                   + Environment.NewLine + "     Inner Join OSRN T1 on T0.ItemCode=T1.ItemCode and T0.SysSerial=T1.SysNumber   "

                                   + Environment.NewLine + "     Where T0.ExpDate is null and T0.ItemCode='" + ItemCode + "' and WhsCode='" + WarehouseCode + "' and T0.Status=0 "

                                   + Environment.NewLine + "     Order By SysSerial "

                                   + Environment.NewLine + "     Select * from #a Where RowNo<='" + Quantity + "' "

                                   + Environment.NewLine + "     Drop Table #a";

            SAPbobsCOM.Recordset oReco_Sr = ClsQC_SBOAddOn.SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset) as SAPbobsCOM.Recordset;

            oReco_Sr.DoQuery(serialNo_query);

            int recCount = oReco_Sr.RecordCount;

--------------------wRITING QUERY WITH NEWLINE AND RECORDSET end---------------------------

-------------------------------------------

SAPbobsCOM.BoUTBTableType.bott_Document

-------------------------------------------

-----------SETTING FOCUS ON PERTICULAR ITEM START---------------------------

Form.Items.Item("etFocus").Click(SAPbouiCOM.BoCellClickType.ct_Regular)

-----------SETTING FOCUS ON PERTICULAR ITEM END---------------------------


------------------------- select and delete a row in the system Matrix START------------------------------------------


do the following


'SELECT ROW

oMatrix.Columns.Item(0).Cells.Item(row2delete).Click(SAPbouiCOM.BoCellClickType.ct_Regular, SAPbouiCOM.BoModifiersEnum.mt_CTRL)


'CALL CLICK

oMatrix.Columns.Item(1).Cells.Item(row2delete).Click()


'DELETE ROW same as CTRL +  K

oApplication.Menus.Item("1293").Activate() 

------------------------- select and delete a row in the system Matrix END-----------------------------------------

--------------------------GETTING MATRIX COLUMN CELL VALUE AND SETTING TO STRING VARIABLE START------------------------------------------------

 string MParty = (oMatrix.Columns.Item("PRTY").Cells.Item(v).Specific as SAPbouiCOM.EditText).Value.ToString();

--------------------------GETTING MATRIX COLUMN CELL VALUE AND SETTING TO STRING VARIABLE END----------------------------------------------------------


--------------------------SETTING MATRIX COLUMN CELLS VALUE FROM VARIABLE START------------------------------------------


  ((SAPbouiCOM.EditText)oMatrix.Columns.Item("BQTY").Cells.Item(J).Specific).Value = BQty;

  

--------------------------SETTING MATRIX COLUMN CELLS VALUE FROM VARIABLE END------------------------------------------

------------------------------Setting Combo box value Start------------------------------------------

     (__form__.Items.Item("10").Specific as SAPbouiCOM.ComboBox).Select("R", BoSearchKey.psk_ByValue);

------------------------------Setting Combo box value END------------------------------------------

------------------------------Release Recordset component start---------------------------------------------

System.Runtime.InteropServices.Marshal.ReleaseComObject(oRecord);

------------------------------Release Recordset component End---------------------------------------------

------------------------------Making Right Click disable on specific case Start----------------------------

protected override void RIGHT_CLICK_BEFOREACTION(ref ContextMenuInfo eventInfo, out bool BubbleEvent)

        {

            BubbleEvent = true;

            if ((eventInfo.ItemUID == "edtx" || eventInfo.ItemUID == "12" || eventInfo.ItemUID == "78" || eventInfo.ItemUID == "255000122") && (__form__.Mode == BoFormMode.fm_OK_MODE || __form__.Mode == BoFormMode.fm_UPDATE_MODE))

            {

                 BubbleEvent = false;

                 ClsQC_SBOAddOn.SBOApplication.SetStatusBarMessage("RightClick not allowed ", SAPbouiCOM.BoMessageTime.bmt_Short, false);

                 return;

            }

            if (eventInfo.ItemUID == "37" && eventInfo.ColUID == "14")

            {

                 BubbleEvent = false;

                 ClsQC_SBOAddOn.SBOApplication.SetStatusBarMessage("RightClick not allowed ", SAPbouiCOM.BoMessageTime.bmt_Short, false);

                 return;

            }

        }

------------------------------Making Right Click disable on specific case END----------------------------

-------------------------Syntax to Activate menu Start------------------------------------------------


ClsQC_SBOAddOn.SBOApplication.ActivateMenuItem("1304");


-------------------------Syntax to Activate menu Start------------------------------------------------

-------------------------READING AND PARSING VALUE TYPE START------------------------------------------------

 string Planned = __OWOR.GetValue("PlannedQty", 0).Trim();

                            string Total = Convert.ToString(oRecord.Fields.Item(0).Value);

                            decimal pl = 0, to = 0;

                            decimal.TryParse(Planned, out pl);

                            decimal.TryParse(Total, out to);

                            if (to < pl)

                            {


                            }

-------------------------READING AND PARSING VALUE TYPE END------------------------------------------------

------------------------- GETTING LAST ADDED DOCENTRY FROM SYSTEM FORM START-------------------------------------------------------------

string  name;

        protected override void etoForm_DATA_ADDAfterAction(ref BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)

        {

            BubbleEvent = true;

            string SerialNumber = (__form__.Items.Item("edtx").Specific as SAPbouiCOM.EditText).Value.ToString();

            if (BusinessObjectInfo.ActionSuccess == true)

            {

                var document = System.Xml.Linq.XDocument.Parse(BusinessObjectInfo.ObjectKey);

                 name = document.Element("ProductionOrderParams").Element("AbsoluteEntry").Value.ToString();


                 

                 if (CheckProductionStage(name))

                 {

                     try

                     {

                         string Query = "Update OWOR Set U_CINN_3SPD='" + name + "'  Where DocEntry in ('" + pdNo + "','" + pd2STNo + "')";

                        SAPbobsCOM.Recordset oRecordset;

                        oRecordset = (SAPbobsCOM.Recordset)ClsQC_SBOAddOn.SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                        oRecordset.DoQuery(Query);

                     }

                     catch (Exception)

                     {

                         

                         throw;

                     }

                 }

                                               

            }

        }

------------------------- GETTING LAST ADDED DOCENTRY FROM SYSTEM FORM END-------------------------------------------------------------

--------------------------ADDING FORM ITEM VIA CODE START-----------------------------------------------------------------------

oItem = __form__.Items.Item("255000113");

            SAPbouiCOM.Item oNewItemxlnk = __form__.Items.Add("lnk1", SAPbouiCOM.BoFormItemTypes.it_LINKED_BUTTON);

            oNewItemxlnk.Left = oItem.Left;

            oNewItemxlnk.Width = oItem.Width;

            oNewItemxlnk.Top = oItem.Top + 19;

            oNewItemxlnk.Height = oItem.Height;

            SAPbouiCOM.LinkedButton lnk = (SAPbouiCOM.LinkedButton)oNewItemxlnk.Specific;

            lnk.LinkedObjectType = "22";

            lnk.LinkedObject = BoLinkedObject.lf_PurchaseOrder;

            lnk.Item.LinkTo = "txt8";

            oNewItemxlnk.Visible = true;

--------------------------ADDING FORM ITEM VIA CODE END-----------------------------------------------------------------------

--------------------------INITIALIZING OBJECT ON FORM LOAD  START--------------------------------------------------------------------------

   this.__form__ = ClsQC_SBOAddOn.SBOApplication.Forms.GetForm(pVal.FormTypeEx, pVal.FormTypeCount);

                    this.__OWOR = this.__form__.DataSources.DBDataSources.Add("OWOR");

                    this.__WOR1 = this.__form__.DataSources.DBDataSources.Add("WOR1");

                    this.__matrix__ = this.__form__.Items.Item("37").Specific as SAPbouiCOM.Matrix;

                    SAPbouiCOM.Item oItem = __form__.Items.Item("234000002");

--------------------------INITIALIZING OBJECT ON FORM LOAD  END--------------------------------------------------------------------------


--------------------------ADDING FORM ITEM COMBO BOX AND FILLING WITH QUERY RESULT START---------------------------------------------------------------------------

oItem = __form__.Items.Item("edtx");

                    oNewItemx = __form__.Items.Add("comb1", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX);

                    oNewItemx.Left = oItem.Left;

                    oNewItemx.Width = oItem.Width;

                    oNewItemx.Top = oItem.Top+17;

                    oNewItemx.Height = oItem.Height;

                    SAPbouiCOM.ComboBox comb = (SAPbouiCOM.ComboBox)oNewItemx.Specific;

                    comb.Item.LinkTo = "comb";

                    comb.DataBind.SetBound(true, "OWOR", "U_WORK");

                    comb.ExpandType = BoExpandType.et_DescriptionOnly;

                    comb.Item.DisplayDesc = true;

                    ClsQC_SBOAddOn.FillCombo(ref comb, "   SELECT Code, ISNULL(Name,'')+ISNULL('-'+CAST(U_CNN_NAME AS VARCHAR),'')+ISNULL('-'+CAST(U_CNN_CNTRNM AS VARCHAR),'') AS U_CNN_NAME FROM \"@CNN_WORKER\"  ");

--------------------------ADDING FORM ITEM COMBO BOX AND FILLING WITH QUERY RESULT END---------------------------------------------------------------------------

---------------------------fORCEFULLY BINDING VALUE IN MATRIX COMBO BOX WITH QUERY VALUE START-------------------------------------------------------------------------

SAPbouiCOM.ComboBox _cmbDr = (SAPbouiCOM.ComboBox)_mtrx.Columns.Item("U_CINN_DRMAN").Cells.Item(1).Specific;

                    _cmbDr.Item.DisplayDesc = true;

                    _cmbDr.ExpandType = BoExpandType.et_DescriptionOnly;

                    string sSQL = "Select empID,CONCAT(FirstName,' ',LastName)[Name] from OHEM Where Dept='3' ";

                    SAPbobsCOM.Recordset businessObject = (SAPbobsCOM.Recordset)ClsQC_SBOAddOn.SBOCompany.GetBusinessObject(BoObjectTypes.BoRecordset);

                    businessObject.DoQuery(sSQL);

                    businessObject.MoveFirst();

                    while (!businessObject.EoF)

                    {

                        _cmbDr.ValidValues.Add(businessObject.Fields.Item((object)0).Value.ToString(), businessObject.Fields.Item((object)1).Value.ToString());

                        businessObject.MoveNext();

                    }

                    Marshal.ReleaseComObject((object)businessObject);

---------------------------fORCEFULLY BINDING VALUE IN MATRIX COMBO BOX WITH QUERY VALUE END-------------------------------------------------------------------------

---------------------------- checking duplicate value in matrix Start----------------------------------------------------------------------

 #region CHECK DUPLICATE VALUE IN MATRIX


        public bool CheckDuplicateMatrixValue(SAPbouiCOM.Matrix oMatrix, string oColumnNo)

        {

            bool oFlag = false;

            for (int i = 1; i <= oMatrix.RowCount; i++)

            {

                string oNewValue = ((SAPbouiCOM.EditText)oMatrix.Columns.Item(oColumnNo).Cells.Item(i).Specific).String;

                for (int j = 1; j < oMatrix.RowCount; j++)

                {

                    if (i != j)

                    {

                        string oOldValue = ((SAPbouiCOM.EditText)oMatrix.Columns.Item(oColumnNo).Cells.Item(j).Specific).String;

                        if (oNewValue == oOldValue)

                        {

                            oFlag = true;

                            break;

                        }

                    }

                }

            }

            return oFlag;

        }


        #endregion

---------------------------- checking duplicate value in matrix End----------------------------------------------------------------------

-----------------------------setting line number on matrix  Start-----------------------------------------------------------------------------------------------------------

        public void LineNumber()

        {

            for (int i = 1; i <= __mtrx.VisualRowCount; i++)

            {

                (__mtrx.Columns.Item("V_-1").Cells.Item(i).Specific as SAPbouiCOM.EditText).Value = i.ToString();

            }

        }

-----------------------------setting line number on matrix  End-----------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------

 if (oRecoEntry.RecordCount > 0)

            {

               

                int i = 1;

                while(!oRecoEntry.EoF)

                {

                   // __mtrx.FlushToDataSource();

                   // _MSR1.SetValue("LineID", i, (i + 1).ToString());

                   // _MSR1.SetValue("U_CNN_S1ISRNO", i, Convert.ToString(oRecoEntry.Fields.Item(0).Value));

                    //_MSR1.SetValue("CNN_S1ISRNO", i, Convert.ToString(oRecoEntry.Fields.Item(0).Value));

                    __mtrx.AddRow(1, i);

                    ((IEditText)this.__mtrx.Columns.Item((object)"V_-1").Cells.Item((object)i).Specific).Value = i.ToString();

                    ((IEditText)this.__mtrx.Columns.Item((object)"V_3").Cells.Item((object)i).Specific).Value = Convert.ToString(oRecoEntry.Fields.Item(0).Value);

                    i++;

                   

                    oRecoEntry.MoveNext();

                   


                }



            }

----------------------------------------------------------------------------------------------------

--------------------------------validation for Not adding with no row detail Start--------------------------------------------------------------------

if (pVal.ItemUID == "1" && (oForm.Mode == SAPbouiCOM.BoFormMode.fm_ADD_MODE || oForm.Mode == SAPbouiCOM.BoFormMode.fm_UPDATE_MODE))

                {


                    oMatrix.FlushToDataSource();


                    if (ODBDetail.Size == 0 || String.IsNullOrEmpty(ODBDetail.GetValue("U_ITMCD", 0).Trim()))

                    {


                        ClsSBOAddOn.ShowErrorMessage("Document cannot be added Without Details");


                        BubbleEvent = false;

                        

                        return;

                    }


                }

--------------------------------validation for Not adding with no row detail end--------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------

if (pVal.ItemUID == "btnImport" && oForm.Mode == SAPbouiCOM.BoFormMode.fm_ADD_MODE)

                {

                    if (dt.Rows.Count > 0)

                    {

                        Regex regex = new Regex(@"^[0-9]\d*(\.\d+)?$");

                        ClsSBOAddOn.ShowWarningMessage("Please wait Data refreshing....");

                        int J = 1;


                        for (int i = 0; i < dt.Rows.Count; i++)

                        {

                            oMatrix.AddRow(1, i);

                           // ((SAPbouiCOM.EditText)oMatrix.Columns.Item("SNO").Cells.Item(J).Specific).Value = dt.Rows[i][0].ToString().Trim();

                            if (this.CheckDepotExist(dt.Rows[i][1].ToString().Trim()))

                            {

                                ((SAPbouiCOM.EditText)oMatrix.Columns.Item("DEPT").Cells.Item(J).Specific).Value = dt.Rows[i][1].ToString().Trim();

                            }

                            else

                            {

                                ClsSBOAddOn.ShowErrorMessage("Depot/Godown Code not exist in system for import Sheet S.No " + dt.Rows[i][0].ToString().Trim());

                                oMatrix.DeleteRow(J);

                                BubbleEvent = false;

                                return;

                            }

                            if (this.CheckMonthMatch(dt.Rows[i][2].ToString().Trim(), ODBmaster.GetValue("U_MONTH", 0).ToString().Trim()))

                            {

                                ((SAPbouiCOM.EditText)oMatrix.Columns.Item("DATE").Cells.Item(J).Specific).Value = dt.Rows[i][2].ToString().Trim();

                            }

                            else

                            {

                                ClsSBOAddOn.ShowErrorMessage("Form Month and Sheet Month not match for import Sheet S.No " + dt.Rows[i][0].ToString().Trim());

                                oMatrix.DeleteRow(J);

                                BubbleEvent = false;

                                return;

                            }

                            if (this.CheckPartyExist(dt.Rows[i][3].ToString().Trim()))

                            {


                                ((SAPbouiCOM.EditText)oMatrix.Columns.Item("PRTY").Cells.Item(J).Specific).Value = dt.Rows[i][3].ToString().Trim();

                            }

                            else

                            {

                                ClsSBOAddOn.ShowErrorMessage("PartyCode not exist in system for import Sheet S.No " + dt.Rows[i][0].ToString().Trim());

                                oMatrix.DeleteRow(J);

                                BubbleEvent = false;

                                return;

                            }

                            if (this.CheckItemExist(dt.Rows[i][4].ToString().Trim()))

                            {

                                ((SAPbouiCOM.EditText)oMatrix.Columns.Item("ItemCode").Cells.Item(J).Specific).Value = dt.Rows[i][4].ToString().Trim();

                            }

                            else

                            {

                                ClsSBOAddOn.ShowErrorMessage("Itemcode not exist in system for import Sheet S.No " + dt.Rows[i][0].ToString().Trim());

                                oMatrix.DeleteRow(J);

                                BubbleEvent = false;

                                return;

                            }

                            ((SAPbouiCOM.EditText)oMatrix.Columns.Item("Itmnm").Cells.Item(J).Specific).Value = dt.Rows[i][5].ToString().Trim();

                            ((SAPbouiCOM.EditText)oMatrix.Columns.Item("BRND").Cells.Item(J).Specific).Value = dt.Rows[i][6].ToString().Trim();

                            ((SAPbouiCOM.EditText)oMatrix.Columns.Item("PLC").Cells.Item(J).Specific).Value = dt.Rows[i][8].ToString().Trim();

                            ((SAPbouiCOM.EditText)oMatrix.Columns.Item("SIZE").Cells.Item(J).Specific).Value = dt.Rows[i][7].ToString().Trim();

                            ((SAPbouiCOM.EditText)oMatrix.Columns.Item("OWN").Cells.Item(J).Specific).Value = dt.Rows[i][9].ToString().Trim();

                            if (regex.IsMatch(dt.Rows[i][10].ToString().Trim()))

                            {

                                ((SAPbouiCOM.EditText)oMatrix.Columns.Item("SQTY").Cells.Item(J).Specific).Value = dt.Rows[i][10].ToString().Trim();

                            }

                            else

                            {

                                ClsSBOAddOn.ShowErrorMessage("Sales Quantity is not valid format for import Sheet S.No " + dt.Rows[i][0].ToString().Trim());

                                oMatrix.DeleteRow(J);

                                BubbleEvent = false;

                                return;

                            }

                            if (regex.IsMatch(dt.Rows[i][11].ToString().Trim()))

                            {

                                ((SAPbouiCOM.EditText)oMatrix.Columns.Item("BQTY").Cells.Item(J).Specific).Value = dt.Rows[i][11].ToString().Trim();

                            }

                            else

                            {

                                ClsSBOAddOn.ShowErrorMessage("Sales Quantity in Btl is not in valid format for import Sheet S.No " + dt.Rows[i][0].ToString().Trim());

                                oMatrix.DeleteRow(J);

                                BubbleEvent = false;

                                return;

                            }

                            if (regex.IsMatch(dt.Rows[i][12].ToString().Trim()))

                            {

                                ((SAPbouiCOM.EditText)oMatrix.Columns.Item("CQTY").Cells.Item(J).Specific).Value = dt.Rows[i][12].ToString().Trim();

                            }

                            else

                            {

                                ClsSBOAddOn.ShowErrorMessage("Quantity of closing in case is not in valid format for import Sheet S.No " + dt.Rows[i][0].ToString().Trim());

                                oMatrix.DeleteRow(J);

                                BubbleEvent = false;

                                return;

                            }

                            if (regex.IsMatch(dt.Rows[i][13].ToString().Trim()))

                            {

                                ((SAPbouiCOM.EditText)oMatrix.Columns.Item("CBQTY").Cells.Item(J).Specific).Value = dt.Rows[i][13].ToString().Trim();

                            }

                            else

                            {

                                ClsSBOAddOn.ShowErrorMessage("Quantity of closing in Btl is not in valid format for import Sheet S.No " + dt.Rows[i][0].ToString().Trim());

                                oMatrix.DeleteRow(J);

                                BubbleEvent = false;

                                return;

                            }

                            if (regex.IsMatch(dt.Rows[i][14].ToString().Trim()))

                            {

                                ((SAPbouiCOM.EditText)oMatrix.Columns.Item("TCQTY").Cells.Item(J).Specific).Value = dt.Rows[i][14].ToString().Trim();

                            }

                            else

                            {

                                ClsSBOAddOn.ShowErrorMessage("Total Quantity In case is not in valid format for import Sheet S.No " + dt.Rows[i][0].ToString().Trim());

                                oMatrix.DeleteRow(J);

                                BubbleEvent = false;

                                return;

                            }

                            if (regex.IsMatch(dt.Rows[i][15].ToString().Trim()))

                            {

                                ((SAPbouiCOM.EditText)oMatrix.Columns.Item("TBQTY").Cells.Item(J).Specific).Value = dt.Rows[i][15].ToString().Trim();

                            }

                            else

                            {

                                ClsSBOAddOn.ShowErrorMessage("Total Quantity In Btl is not in valid format for import Sheet S.No " + dt.Rows[i][0].ToString().Trim());

                                oMatrix.DeleteRow(J);

                                BubbleEvent = false;

                                return;

                            }

                            oMatrix.AutoResizeColumns();

                            J++;

                        }

                        ClsSBOAddOn.ShowSucessMessage("Data Refresh Successfully");

                    }

                }

---------------------------------------------------------------------------------------------------------

----------------------------GRID making assigning datatable Start----------------------------------------------

 _Grd = (SAPbouiCOM.Grid)oform.Items.Item("3").Specific;

            oform.DataSources.DataTables.Add("MyDataTable");

            oform.DataSources.DataTables.Item(0).ExecuteQuery(Query);

            _Grd.DataTable = oform.DataSources.DataTables.Item("MyDataTable");

            _Grd.SelectionMode = BoMatrixSelect.ms_Auto;

            _Grd.Columns.Item("Select").Type = SAPbouiCOM.BoGridColumnType.gct_CheckBox;

            _Grd.Columns.Item("Image").Type = SAPbouiCOM.BoGridColumnType.gct_Picture;

            _Grd.Columns.Item("Serial Number").Editable     = false;

            _Grd.Columns.Item("ItemCode").Editable          = false;

            _Grd.Columns.Item("ItemName").Editable          = false;

            _Grd.Columns.Item("DocNum").Editable            = false;

            _Grd.Columns.Item("Posting Date").Editable      = false;

            _Grd.Columns.Item("BarCode").Visible           = false;

            _Grd.Columns.Item("Image").Editable = false;

            _Grd.AutoResizeColumns();

----------------------------GRID making assigning datatable END----------------------------------------------

----------------------------Working on checkbox  on start------------------

if (pVal.ItemUID == "cSelect")

            {

                string CheckValue = oform.DataSources.UserDataSources.Item("cSelect").Value;

                if (CheckValue == "Y")

                {

                    for (int i = 0; i < _Grd.Rows.Count; i++)

                    {


                        ((SAPbouiCOM.CheckBoxColumn)_Grd.Columns.Item("Select")).Check(i, true);


                    }

                }

                else

                {

                    for (int i = 0; i < _Grd.Rows.Count; i++)

                    {


                        ((SAPbouiCOM.CheckBoxColumn)_Grd.Columns.Item("Select")).Check(i, false);


                    }

                }


            }

------------------------Working on checkbox end------------------

------------------Choose from List After Action Start--------------------

 protected override void CHOOSE_FROM_LIST_AFTERACTION(ref SAPbouiCOM.ItemEvent pVal, SAPbouiCOM.DataTable oDataTable, out bool BubbleEvent)

        {

            BubbleEvent = true;

            try

            {

                oForm.Freeze(true);

                                SAPbouiCOM.ChooseFromListEvent cflevent = (SAPbouiCOM.ChooseFromListEvent)pVal;

                                SAPbouiCOM.ChooseFromList oCFLEvento = default(SAPbouiCOM.ChooseFromList);

                                string strUid = cflevent.ChooseFromListUID;

                                oCFLEvento = this.oForm.ChooseFromLists.Item(strUid);

                                //SAPbouiCOM.DataTable oDataTable = cflevent.SelectedObjects;

                                _chooseFromListItem = (SAPbouiCOM.IChooseFromListEvent)pVal;

                                if (_chooseFromListItem.SelectedObjects != null && oForm.Mode != SAPbouiCOM.BoFormMode.fm_FIND_MODE)

                                {

                                    {

                                        if (pVal.ItemUID == "mkt_PL1" && pVal.ColUID=="V_8")

                                        {

                                            try

                                            {

                                                //((SAPbouiCOM.EditText)oForm.Items.Item("etTech").Specific).Value = _chooseFromListItem.SelectedObjects.GetValue("firstName", 0).ToString().Trim();

                                                ODBDetail.SetValue("U_CNAME", pVal.Row - 1, _chooseFromListItem.SelectedObjects.GetValue("CardName", 0).ToString().Trim());

                                            }

                                            catch

                                            { }

                                            finally

                                            {

                                                //((SAPbouiCOM.EditText)oForm.Items.Item("etTech").Specific).Value = _chooseFromListItem.SelectedObjects.GetValue("firstName", 0).ToString().Trim();

                                            }

                                        }

                                    }

                                }

                                oForm.Freeze(false);


            }

            catch (Exception ex)

            {

                oForm.Freeze(false);

                clsUIGeneric.CreateErrorlog(ClsSBOAddOn.SBOCompany.UserName.Trim(), "Namespace:PriceList,class:PL1,Function:CHOOSE_FROM_LIST_BEFOREACTION,Error" + ex.Message, DateTime.Now, clsUIGeneric.strErrorLogFilePath);

            }

        }


------------------Choose from List After Action End------------------------

 #region ADD COLUMNS IN MATRIX

        public void AddControls()

        {

            SAPbouiCOM.Column oCol;


            SAPbouiCOM.ProgressBar oProgressBar = null;


            try

            {

                string col = "";

                string field;

                string caption = "";


                oProgressBar = Utilities.Application.SBO_Application.StatusBar.CreateProgressBar("Creating columns...Please wait.", 50, false);

                oProgressBar.Value = 1;


                for (int i = 10; i <= 209; i++)

                {

                    field = "U_ObsvVal" + (i - 9).ToString().Trim();

                    caption = "Observed Value " + (i - 9);


                    col = i.ToString();

                    _mtMatrix.Columns.Add(col, SAPbouiCOM.BoFormItemTypes.it_EDIT);

                    _mtMatrix.Columns.Item(col).Visible = false;

                    _mtMatrix.Columns.Item(col).TitleObject.Caption = caption;

                    oCol = _mtMatrix.Columns.Item(col);

                    oCol.DataBind.SetBound(true, "@KBR_QltyChk1", field);

                }


                oProgressBar.Stop();

            }

            catch (Exception)

            {


                throw;

            }

        }

        #endregion


-----------------------Sql usefull function Start-----------------------------------------------------

 

  STRING_SPLIT--used to split Value separated by any specified character

STRING_AGG--used to concat column value in one cell separeted by specific character


DECLARE @tags NVARCHAR(400) = 'clothing,road,,touring,bike'  

  

SELECT value  

FROM STRING_SPLIT(@tags, ',')  

WHERE RTRIM(value) <> ''



-----------------------Sql usefull function Start End---------------------------------------------------------------

  

 --------------------------HANA Connection String pattern Start----------------------------

 Driver={HDBODBC32};UID=B1ADMIN;PWD=pwd;ServerNode=serverIP:31115;CS=ADSTESTDB


Driver={HDBODBC32};UID=B1ADMIN;PWD=pwd;ServerNode=serverIP:31115:31115;CS=ADSTESTDB

 --------------------------HANA Connection String pattern END----------------------------

 Driver={HDBODBC32};UID=B1ADMIN;PWD=pwd;ServerNode=serverIP:31115:30015;CS=ADSTESTDB


Driver={HDBODBC32};UID=B1ADMIN;PWD=pwd;ServerNode=serverIP:31115:31115;CS=ADSTESTDB


DRIVER={B1CRHPROXY32};SERVERNODE=ServerIP:30013;DATABASENAME=HDB;DATABASE=ADSTESTDB;UID=B1ADMIN;PWD=pwd

DRIVER={B1CRHPROXY32};SERVERNODE=serverIP:30013;DATABASENAME=HDB;DATABASE=ADSCRP;UID=B1ADMIN;PWD=Pwd

Driver={HDBODBC32};ServerNode=ServerIP:30015;CS=databaseName;UID=B1ADMIN;PWD=pwd


---------------------------------------------------------------------------------------



 Query = "Select Distinct \"U_FGSubItemGroup1\",\"U_Density\" from \"OITM\" Where \"U_Density\" is not null and \"U_Density\"<>1 and \"U_FGSubItemGroup1\"='MAGNUM' Order by \"U_FGSubItemGroup1\",\"U_Density\"";

                    ClsSBOAddOn.ExecuteSQL(ref oRecordset, Query);

                   

                    if (oRecordset.RecordCount > 0)

                    {

                        oRecordset.MoveFirst();

                        while (!oRecordset.EoF)

                        {

                            string FD = oRecordset.Fields.Item("U_FGSubItemGroup1").Value.ToString().Trim();

                            string fieldID = FD.Substring(0,3)+ Convert.ToString(oRecordset.Fields.Item("U_Density").Value);

                            string Descr = Convert.ToString(oRecordset.Fields.Item("U_FGSubItemGroup1").Value) + '-' + Convert.ToString(oRecordset.Fields.Item("U_Density").Value);

                            ClsDatabase.AddColumn("FPL1", fieldID, Descr, 50, SAPbobsCOM.BoFieldTypes.db_Float, SAPbobsCOM.BoFldSubTypes.st_Price, SAPbobsCOM.BoYesNoEnum.tNO, SAPbobsCOM.BoYesNoEnum.tNO);

                            

                            oRecordset.MoveNext();

                        }


                    }

--------------------------------------------------------------------------------------------

CREATE LOCAL TEMPORARY TABLE #FinalRecord(

             PartyCode Varchar(20),

             PartyName Varchar(200),

            PurcahseQty double,

            DebitQty double,

            OpnBal double,

            ItemAvgRate double,

            AmtPaid double

                     

);

Drop Table #FinalRecord;

------------------------------------------------------------------------------------------------

Update T0

Set T0."U_POEntry"=T1."U_POEntryT"

from "@CIN_OGAE" T0

Inner Join "@CIN_OGAE" T1 on T0."DocEntry"=T1."DocEntry"

-----------------------------------------------------------------------------------------------



------------------lOADING DATA IN MATRIX COLUMN ON FORM LOAD AT ADD MODE-----------------------

public void LoadDetails()

        {

            try 

            {

                if (State != "")

                {

                    this.oForm.Items.Item("etBEntry").Enabled = false;

                    ODBmaster.SetValue("U_BaseEntry", 0, BaseEntry);

                    int i = 1;

                    ORecordset = (SAPbobsCOM.Recordset)ClsSBOAddOn.SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                    Query = "Select * from \"OITM\" where \"U_State\" = '" + State + "'";

                    ORecordset.DoQuery(Query);

                    ORecordset.MoveFirst();


                    if (ORecordset.RecordCount > 0)

                    {

                        ORecordset.MoveFirst();

                        while (!ORecordset.EoF)

                        {

                            oMatrix.AddRow();

                            oMatrix.Columns.Item("colBEntry").Cells.Item(i).Specific.Value = BaseEntry;

                            oMatrix.Columns.Item("SNO").Cells.Item(i).Specific.Value = i;

                            oMatrix.Columns.Item("ItemCode").Cells.Item(i).Specific.Value = ORecordset.Fields.Item("ItemCode").Value.ToString().Trim();

                            oMatrix.Columns.Item("Itmnm").Cells.Item(i).Specific.Value = ORecordset.Fields.Item("ItemName").Value.ToString().Trim();

                            oMatrix.Columns.Item("PCODE").Cells.Item(i).Specific.Value = PartyCode;

                            oMatrix.Columns.Item("STATE").Cells.Item(i).Specific.Value = State;

                            

                            i++;

                            ORecordset.MoveNext();

                        }

                    }

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(ORecordset);

                }

            }

            catch (Exception ex)

            {

                oForm.Freeze(false);

                clsUIGeneric.CreateErrorlog(ClsSBOAddOn.SBOCompany.UserName.Trim(), "Namespace:SecondrySale,class:PartyMasterDetails,Function:LoadDetails,Error" + ex.Message, DateTime.Now, clsUIGeneric.strErrorLogFilePath);

            }

        }

-----------------------------------------------------------------------------------------------------------------

SAPbobsCOM.Recordset oReco = ClsSBOAddOn.SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset) as SAPbobsCOM.Recordset;

                       string Query_1 = "exec  CIN_BR_VMCVFT  '" + ((SAPbobsCOM.ICompany)ClsSBOAddOn.SBOApplication.Company.GetDICompany()).UserSignature + "','CINN_OSBS','E','0'";

                oReco.DoQuery(Query_1);

                if (oReco.RecordCount > 0)

                {

                    String list = oReco.Fields.Item(0).Value;

                    String[] separator = { ";" };

                    String[] strList = list.Split(separator,StringSplitOptions.RemoveEmptyEntries);

                    for (int i = 1; i < strList.Length; i++)

                    {

                        __mtrx.Columns.Item(strList[i]).Editable = false;

                       

                        string s = strList[i];

                       

                    }

                }

-------------------------------------------------------------------------------------------------------------------

 this.__form__.Mode = BoFormMode.fm_FIND_MODE;

                ((SAPbouiCOM.EditText)this.__form__.Items.Item("txtDocEt").Specific).Value = BarCodeEntry;

                this.__form__.Items.Item("1").Click(SAPbouiCOM.BoCellClickType.ct_Regular);

---------------------------------------------------------------------------------------------------------------------