cancel
Showing results for 
Search instead for 
Did you mean: 

Choose From List Event Performing Very Slow

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Dear All,

Me & one of my friend is facing a very big problem & I am not able to solve it.

I have a form having matrix in it. In a column there is CFL for Sales Orders. When I select a Sales Order, some information against this SO is getting filled into the others matrix columns and some fields information in header part.

But my problem is that it is happening very slow. Here is my code :

if (pVal.ItemUID == enControlName.mtxDetails & pVal.ColUID == enControlName.colConsign & pVal.EventType == BoEventTypes.et_CHOOSE_FROM_LIST)

                                {

                                    SAPbobsCOM.Recordset oRecSetInsert = (SAPbobsCOM.Recordset)SBO_Company.GetBusinessObject(BoObjectTypes.BoRecordset);                                   

                                    string Consign = string.Empty;

                                    string DocNum = string.Empty;

                                    SAPbouiCOM.Matrix omtxDetails = default(SAPbouiCOM.Matrix);

                                    omtxDetails = (SAPbouiCOM.Matrix)this.m_SBO_Form.Items.Item(enControlName.mtxDetails).Specific;                                   

                                    StringBuilder Build = new StringBuilder();

                                    for (int i = 0; i <= oDataTable.Rows.Count - 1; i++)

                                    {

                                        Consign = Convert.ToString(oDataTable.GetValue("U_ConNum", i));

                                        if (!Item)

                                        {

                                            Build.Append("ORDR.U_ConNum = '" + Consign + "'");

                                            Item = true;

                                        }

                                        else

                                        {

                                            Build.Append("OR ");

                                            Build.Append("ORDR.U_ConNum = '" + Consign + "'");

                                        }

                                    }

                                    Item = false;

                                    SAPbobsCOM.Recordset oRecord = (SAPbobsCOM.Recordset)SBO_Company.GetBusinessObject(BoObjectTypes.BoRecordset);

                                    SAPbobsCOM.Recordset oRecordSet = (SAPbobsCOM.Recordset)SBO_Company.GetBusinessObject(BoObjectTypes.BoRecordset);

                                    string SQL = "SELECT ORDR.U_ConNum, RDR1.U_Packages, RDR1.Dscription, RDR1.U_ACweight ,RDR1.U_CWeight,RDR1.U_Freight,ORDR.U_FBrnchName, ORDR.U_TBrnchName FROM ORDR INNER JOIN RDR1 ON ORDR.DocEntry = RDR1.DocEntry where " + Build.ToString() + "  and ordr.CANCELED <> 'Y' and RDR1.U_ACweight <> 0 ";                                   

                                    oRecord.DoQuery(SQL);                                   

                                    while (oRecord.EoF == false)

                                    {

                                        string ConsignmentNumberRow = string.Empty;

                                        double TotalPackageRow = 0.0;

                                        double ActualWeightRow = 0.0;

                                        double ChrgedWeightRow = 0.0;

                                        int K = omtxDetails.VisualRowCount;

                                        try

                                        {

                                            ConsignmentNumberRow = oRecord.Fields.Item("U_ConNum").Value.ToString();

                                            oEdit = (SAPbouiCOM.EditText)omtxDetails.Columns.Item(enControlName.colConsign).Cells.Item(K).Specific;

                                            oEdit.Value = oRecord.Fields.Item("U_ConNum").Value.ToString();

                                            //System.Convert.ToString(oDataTable.GetValue("U_ConNum", 0));

                                        }

                                        catch (Exception ex)

                                        {

                                            Program.oMainSAPDI.ShowMessage(ex.Message, BoStatusBarMessageType.smt_None);

                                        }

                                        oEdit = (SAPbouiCOM.EditText)omtxDetails.Columns.Item(enControlName.colFrom).Cells.Item(K).Specific;

                                        oEdit.Value = oRecord.Fields.Item("U_FBrnchName").Value.ToString();

                                        oEdit = (SAPbouiCOM.EditText)omtxDetails.Columns.Item(enControlName.colTo).Cells.Item(K).Specific;

                                        oEdit.Value = oRecord.Fields.Item("U_TBrnchName").Value.ToString();

                                        oEdit = (SAPbouiCOM.EditText)omtxDetails.Columns.Item(enControlName.colDESCP).Cells.Item(K).Specific;

                                        oEdit.Value = oRecord.Fields.Item("Dscription").Value.ToString();

                                        oEdit = (SAPbouiCOM.EditText)omtxDetails.Columns.Item(enControlName.ColBook).Cells.Item(K).Specific;

                                        oEdit.Value = oRecord.Fields.Item("U_Packages").Value.ToString();

                                        TotalPackageRow = Convert.ToDouble(oEdit.Value);

                                        oEdit = (SAPbouiCOM.EditText)omtxDetails.Columns.Item(enControlName.colACW).Cells.Item(K).Specific;

                                        oEdit.Value = oRecord.Fields.Item("U_ACweight").Value.ToString();

                                        ActualWeightRow = Convert.ToDouble(oEdit.Value);

                                        oEdit = (SAPbouiCOM.EditText)omtxDetails.Columns.Item(enControlName.colCHGW).Cells.Item(K).Specific;

                                        oEdit.Value = oRecord.Fields.Item("U_CWeight").Value.ToString();

                                        ChrgedWeightRow = Convert.ToDouble(oEdit.Value);

                                        oEdit = (SAPbouiCOM.EditText)omtxDetails.Columns.Item(enControlName.colFreight).Cells.Item(K).Specific;

                                        oEdit.Value = oRecord.Fields.Item("U_Freight").Value.ToString();

                                        string Query = "Insert into [@ChallanTemp] Values( '" + ConsignmentNumberRow + "'," + TotalPackageRow + "," + ActualWeightRow + "," + ChrgedWeightRow + ")";

                                        oRecSetInsert.DoQuery(Query);

                                        omtxDetails.AddRow(1, omtxDetails.VisualRowCount);

                                        oRecord.MoveNext();

                                    }

                                    try

                                    {

                                        string Query = "Select SUM(Packages) as 'Pkg', SUM(ActualWeight) as 'Actual', SUM (ChargedWeight) as 'Charged' from [@ChallanTemp] ";

                                        oRecSetInsert.DoQuery(Query);

                                        SAPbouiCOM.EditText oPack = (SAPbouiCOM.EditText)this.m_SBO_Form.Items.Item(enControlName.TotalPack).Specific;

                                        SAPbouiCOM.EditText oEdit1 = (SAPbouiCOM.EditText)m_SBO_Form.Items.Item("61").Specific;

                                        SAPbouiCOM.EditText oEdit2 = (SAPbouiCOM.EditText)m_SBO_Form.Items.Item("63").Specific;

                                        oPack.Value = oRecSetInsert.Fields.Item("Pkg").Value.ToString();

                                        oEdit1.Value = oRecSetInsert.Fields.Item("Actual").Value.ToString();

                                        oEdit2.Value = oRecSetInsert.Fields.Item("Charged").Value.ToString();                                      

                                      

                                    }

                                    catch (Exception ex)

                                    {

                                        Program.oMainSAPDI.ShowMessage(ex.Message, SAPbouiCOM.BoStatusBarMessageType.smt_Error);

                                    }                                   

                                    omtxDetails.Columns.Item(enControlName.colConsign).Cells.Item(omtxDetails.VisualRowCount).Click(BoCellClickType.ct_Double,0);

                                }

Please help me in this problem..... It is something urgent.

Thanks & Regards

Ankit Chauhan

Accepted Solutions (1)

Accepted Solutions (1)

edy_simon
Active Contributor
0 Kudos

Hi Ankit,

Is this a user form and user matrix?

If yes, fill the data through the datasource. Matrix object is very slow.

Your second best is use the omatrix.secellwithoutvalidation method.

Third is get the cell using the omtarix.getcellspecific.

Regards,

Edy

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Edy,

Thanks for your reply... You are always there to help...

Will it effect something, if I fill the data through the datasource...? Means can it be helpful, if I use this.?

Thanks

edy_simon
Active Contributor
0 Kudos

Hi Ankit,

If this is not system form or datasource, you can do it without side effect.

Before you update, flushtodatasource first so you will not loose user entrered data.

Regards,

Edy

edy_simon
Active Contributor
0 Kudos

Definitely updating datasource is will speed up your process.

Regards,

Edy

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi ,

If you don't mind can you please provide me a sample. Just a little bit information in code what should I do to speed up this process. Please tell me can I do the same in Add Mode.?

Your help would be appreciated.

Thanks

edy_simon
Active Contributor
0 Kudos

Hi Ankit,

Instead of your code :

ConsignmentNumberRow = oRecord.Fields.Item("U_ConNum").Value.ToString();

oEdit = (SAPbouiCOM.EditText)omtxDetails.Columns.Item(enControlName.colConsign).Cells.Item(K).Specific;

oEdit.Value = oRecord.Fields.Item("U_ConNum").Value.ToString();

Try using this :

ConsignmentNumberRow = oRecord.Fields.Item("U_ConNum").Value.ToString();

oDataTable.SetValue("U_ConNum", 0, ConsignmentNumberRow);

Where 0 is the index of the record in datatable to update.

After you have update all the columns and rows,

Call this :

omtx.LoadFromDataSource()';

You can do the above in Add Mode/Update mode the same.

Regards

Edy

Answers (0)