on 01-12-2015 10:43 AM
Hello professionals ..
when i try to update batch number after updating a sales order document I get the error "Invalid row "due to SetCurrentLine in sales order document lines.it doesnt happen often but when it does it causes a big problem .
here is my code ; I only update the new lines by adding the batch number because the old lines are updated by the system ..
private void Form_DataUpdateAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
{
int i=0;
try
{
oOrder = (SAPbobsCOM.Documents)Program.oDiCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
oOrder.GetByKey(DocEntry);
SAPbobsCOM.Document_Lines DocLn = (SAPbobsCOM.Document_Lines)oOrder.Lines;
for ( i = 0; i < Matrix0.VisualRowCount - 1; i++)
{
SAPbouiCOM.ComboBox CMB = (SAPbouiCOM.ComboBox)Matrix0.GetCellSpecific("U_PHI_RP_RSV", i + 1);
String Reserve = CMB.Value;
if (Reserve == "1")//Old line
continue;
// add a batch number to the new lines
DocLn.SetCurrentLine(i);
SAPbobsCOM.BatchNumbers Batch = DocLn.BatchNumbers;
Batch.BatchNumber = ((SAPbouiCOM.EditText)Matrix0.GetCellSpecific("U_CMC_RP_NLO", i + 1)).Value;
String value = ((SAPbouiCOM.EditText)Matrix0.GetCellSpecific("11", i + 1)).Value;
Batch.Quantity = CalculRow.ConvertDouble(((SAPbouiCOM.EditText)Matrix0.GetCellSpecific("11", i + 1)).Value);
Batch.Add();
DocLn.UserFields.Fields.Item("U_PHI_RP_RSV").Value = "1";
}
int error = oOrder.Update();
if (error != 0)
Application.SBO_Application.SetStatusBarMessage("Erreur lors de la mise a jour des lôts ");
else
Application.SBO_Application.StatusBar.SetText("Opération de mise à jour des lôts correctement achevée ", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
}
catch (Exception ex)
{
Application.SBO_Application.MessageBox(ex.Message);
}
}
please help .. I'm totally lost
Best regards.
Radhia
Hi Radhia,
the error basically means that your DocLn.SetCurrentLine(i); is trying to access a non existing line.
Is it sure, that every row in your Matrix always represents one line in the document ( mybe two rows/ different batches for one document line )?
Also your Batch.Add() is not needed, since there is always already one line present - the Add() just adds another empty line to the collection.
regards,
Maik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What you did sounds correct, but it doesn't solve your actual problem.
You got lines in your Matrix ( where is the data coming from ? ) which are not ( anymore ) present in your document. Apart from your described issue it can also happen that you write wrong data in the document.
The best overall solution imho would be to have also the actual linenum of your document present in the Matrix and when updating the document to verify the data ( matrix linenum == document linenum ).
regards,
Maik
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.