cancel
Showing results for 
Search instead for 
Did you mean: 

Batch Number

QuanNQ
Discoverer
0 Kudos

Dear Supporters,

I have a problem about Create Batches from Batch Number form.
pic1.png

Create button will open Batch form for one by one item => Batch created will save as Batches Difference temporary.

That seems to take quite a bit of time for the customer
So, i want to set auto create batch one by one item but Batches Difference matrix is a system form and i can not add row to this.
Share me how to add row to Batches Difference matrix and update Rows from Documents after add Batch success, please!
Thanks for your time!

Accepted Solutions (0)

Answers (1)

Answers (1)

QuanNQ
Discoverer
0 Kudos

Here is my code

 Matrix mtx_RowsFromDocs = (Matrix)oForm.Items.Item("3").Specific;
            
            List<BatchModel> batchModels = new List<BatchModel>();

            if (mtx_RowsFromDocs != null)
            {
                BatchModel itemModel;
                for (int i = 1; i <= mtx_RowsFromDocs.RowCount; i++)
                {

                    itemModel = new BatchModel();

                    itemModel.ItemCode = ((SAPbouiCOM.EditText)mtx_RowsFromDocs.Columns.Item("1").Cells.Item(i).Specific).Value;

                    itemModel.CountByItem = batchModels.Count(b => b.ItemCode.Equals(itemModel.ItemCode)) + 1;

                    itemModel.WhsCode = ((SAPbouiCOM.EditText)mtx_RowsFromDocs.Columns.Item("3").Cells.Item(i).Specific).Value;

                    itemModel.TotalNeed = double.Parse(((SAPbouiCOM.EditText)mtx_RowsFromDocs.Columns.Item("55").Cells.Item(i).Specific).Value);

                    itemModel.Batch = string.Format("{0}.{1}", PostingDate.ToString("yyMMdd"), itemModel.BatchAttr1);

                    batchModels.Add(itemModel);

                    Matrix mtx_BatchesDiff = (Matrix)oForm.Items.Item("5").Specific;

                    int rcount = mtx_BatchesDiff.RowCount;

                    mtx_BatchesDiff.AddRow();

                    ((SAPbouiCOM.EditText)mtx_BatchesDiff.Columns.Item("1").Cells.Item(rcount + 1).Specific).Value = itemModel.Batch;

                    ((SAPbouiCOM.EditText)mtx_BatchesDiff.Columns.Item("29").Cells.Item(rcount + 1).Specific).Value = itemModel.TotalNeed.ToString();

                    ((SAPbouiCOM.EditText)mtx_BatchesDiff.Columns.Item("52").Cells.Item(rcount + 1).Specific).Value = "-1";

                    mtx_RowsFromDocs.Item.Update();
                }
            }

But when i run to go to this code then error: form item is not editable

((SAPbouiCOM.EditText)mtx_BatchesDiff.Columns.Item("1").Cells.Item(rcount + 1).Specific).Value = itemModel.Batch;