on 04-07-2010 9:09 AM
Hello experts,
below i try to report some pieces of my code:
private void creaMRP()
{
try {
while (i < resultQueryMain.Count)
{
ret = elaboraTransazione(ref i);
}
}
catch (Exception ex)
{
SwissAddonFramework.UI.Dialogs.MessageBox.Show("Errore Imprevisto: " + ex.Message, "OK");
}
finally
{
if (docOrdineCliente != null)
{
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(docOrdineCliente) != 0) ;
docOrdineCliente = null;
}
if (docOrdineFornitore != null)
{
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(docOrdineFornitore) != 0) ;
docOrdineFornitore = null;
}
}
}
private int elaboraTransazione(ref int i)
docOrdineCliente = (Documents)B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
...
...
...
for (int j = 0; j < docOrdineFornitore.Lines.Count; j++)
{
if (docOrdineCliente.Update() != 0) // -> HERE I GET THE ERROR <-
{
SwissAddonFramework.UI.Dialogs.MessageBox.Show("Errore Imprevisto: " + B1Connector.GetB1Connector().Company.GetLastErrorDescription() + " " + B1Connector.GetB1Connector().Company.GetLastErrorCode(), "OK");
throw new Exception("errore in aggiornamento ordine cliente: " + B1Connector.GetB1Connector().Company.GetLastErrorDescription() + " " + B1Connector.GetB1Connector().Company.GetLastErrorCode());
}
}
can someone help me to fix it ?
thanks in advance.
Best regards
Andrea
Hi Andrea Gigliotti ,
I thing you are using SwissAddonFramework.Can u explain me what this framework do.
i send one mail to u.please check it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
probably the cause of this error is related with wrong data created via DI API
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Andrea,
Check the following threads
tips:
1. You will find 2 notes inside, check them
2. Check the database response time and run (sp_updatestats)
I have seen in your code:
docOrdineFornitore.Lines.UserFields.Fields.Item("U_OrdEntry").Value = resultQueryMain<i>["DocEntry"].ToString();
docOrdineFornitore.Lines.UserFields.Fields.Item("U_OrdLine").Value = resultQueryMain<i>["LineNum"].ToString();
Change them by by sap note 1235603 and it will work
Regards,
János
Edited by: János Nagy on Apr 8, 2010 2:17 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello János,
the Sap Note: 1234122 shows me the following message:
"The requested SAP Note is either in reworking or is released internally only "
I applied everythings suggested in Sap Note n.1235603 but I still have the same error message!
I changed the two lines as below:
SAPbobsCOM.Document_Lines dl = docOrdineFornitore.Lines;
SAPbobsCOM.Field uf1 = dl.UserFields.Fields.Item("U_OrdEntry");
uf1.Value = resultQueryMain["DocEntry"].ToString();
SAPbobsCOM.Field uf2 = dl.UserFields.Fields.Item("U_OrdLine");
uf2.Value = resultQueryMain["LineNum"].ToString();
What can I try to solve the issue ?
Is this a bug of SAP B1 ? I'm using SAP B1 2007 A (8.00.231) SP:01 PL:06 HOTFIX1
Many Thanks
Regards
Andrea
Hi Andrea.
I've been through this error that but in loop to insert invoices.
Place a collector of memory in your loop to see if it solves. For example, in. Net I use the GC.Collect ().
Kind regards,
Fábio.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i can't solve the issue, below the whole code where the error occurs:
private int elaboraTransazione(ref int i)
{
double qta;
double giacenza;
String articolo;
String documento;
String riga;
int ret;
int ritorno = -1;
Dictionary["CardCode"].ToString();
i++;
count++;
B1Connector.GetB1Connector().Application.SetStatusBarMessage("Elaborazione MRP record n." + count + " su " + totaleRighe + " attendere prego...", SAPbouiCOM.BoMessageTime.bmt_Short, false);
}
// ho finito di processare tutti gli articoli del fornitore
ritorno = -2;
if (docOrdineFornitore.Lines.Count <= 1)
{
// se non ci sono righe ordine fornitore
throw new Exception("ordine fornitore senza righe");
}
if (docOrdineFornitore.Add() != 0) // creo ordine fornitore
{
throw new Exception("errore in creazione ordine acquisto: " + B1Connector.GetB1Connector().Company.GetLastErrorDescription() + " " + B1Connector.GetB1Connector().Company.GetLastErrorCode());
}
// leggo docentry per ordine acquisto appena creato
if (!docOrdineFornitore.GetByKey(int.Parse(B1Connector.GetB1Connector().Company.GetNewObjectKey())))
{
throw new Exception("errore: ordine fornitore non trovato!");
}
for (int j = 0; j < docOrdineFornitore.Lines.Count; j++)
{
docOrdineFornitore.Lines.SetCurrentLine(j);
ordine.ordineFornitore = docOrdineFornitore.DocEntry;
ordine.rigaOrdineFornitore = docOrdineFornitore.Lines.LineNum;
ordine.ordineCliente = int.Parse(docOrdineFornitore.Lines.UserFields.Fields.Item("U_OrdEntry").Value.ToString());
ordine.rigaOrdineCliente = int.Parse(docOrdineFornitore.Lines.UserFields.Fields.Item("U_OrdLine").Value.ToString());
ordiniFornitore.Add(ordine);
}
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(docOrdineFornitore) != 0) ;
docOrdineFornitore = null;
docOrdineCliente = (Documents)B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
// aggiorno righe ordine cliente con righe ordine fornitore collegate
for (int j = 0; j < ordiniFornitore.Count; j++)
{
ordine = (Ordine)ordiniFornitore[j];
if (!docOrdineCliente.GetByKey(ordine.ordineCliente))
{
throw new Exception("errore: ordine cliente non trovato!");
}
docOrdineCliente.Lines.SetCurrentLine(ordine.rigaOrdineCliente);
docOrdineCliente.Lines.UserFields.Fields.Item("U_OrdEntry").Value = ordine.ordineFornitore;
docOrdineCliente.Lines.UserFields.Fields.Item("U_OrdLine").Value = ordine.rigaOrdineFornitore;
// aggiorno ordine cliente
if (docOrdineCliente.Update() != 0) <--- IN THIS LINE I GET THE ERROR -
-
{
SwissAddonFramework.UI.Dialogs.MessageBox.Show("Errore Imprevisto: " + B1Connector.GetB1Connector().Company.GetLastErrorDescription() + " " + B1Connector.GetB1Connector().Company.GetLastErrorCode(), "OK");
throw new Exception("errore in aggiornamento ordine cliente: " + B1Connector.GetB1Connector().Company.GetLastErrorDescription() + " " + B1Connector.GetB1Connector().Company.GetLastErrorCode());
}
Thread.Sleep(500);
GC.Collect();
}
B1Connector.GetB1Connector().Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
ritorno = 0;
}
catch (Exception ex)
{
if (B1Connector.GetB1Connector().Company.InTransaction)
B1Connector.GetB1Connector().Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
listaEccezioni.Add(record["DocNum"].ToString()+record["LineNum"].ToString(), ex.Message + " ::: " + ex.StackTrace);
if (ritorno == -2) listaFornitoriConErrore.Add(record); // registro la riga ordine cliente con errore
SwissAddonFramework.UI.Dialogs.MessageBox.Show("Errore Imprevisto:: " + ex.Message, "OK");
count++;
B1Connector.GetB1Connector().Application.SetStatusBarMessage("Elaborazione MRP record n." + count + " su " + totaleRighe + " attendere prego...", SAPbouiCOM.BoMessageTime.bmt_Short, false);
}
finally
{
if (docOrdineCliente != null)
{
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(docOrdineCliente) != 0) ;
docOrdineCliente = null;
}
if (docOrdineFornitore != null)
{
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(docOrdineFornitore) != 0) ;
docOrdineFornitore = null;
}
}
return ritorno;
}
-
-
I noted I got the error AFTER some loop iterations (sometimes 10 or 11 or 15 iterations)
I also tried to put Thread.Sleep(500) and GC.Collect() in the loop but I still have the error message!
Can someone help me ?
Many thanks
Andrea
the error I got could be linked with releasing COM object ?
I'm using the below code not inside the "elaboraTransazione" method but outside in the calling method "creaMRP".
if (docOrdineCliente != null)
{
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(docOrdineCliente) != 0) ;
docOrdineCliente = null;
}
if (docOrdineFornitore != null)
{
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(docOrdineFornitore) != 0) ;
docOrdineFornitore = null;
}
Andrea
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andrea,
probably you use not only the SAP Business One SDK and .NET Framework but also the Coresuite Framework. It is right?
The prefix RPC refers to "Remote Procedure Call". Probably is an error Thrown by a Coresuite library.
If you post all the exception text and also the line reference of the exception, probably we can better help you.
Carmine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes! I also use the Coresuite Framework.
the complete exception text is:
The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)) at SAPbobsCOM.IDocuments.Update() at .........elaboraTransazione(Int32& i) in .............OrdineFornitore.cs:line 404
the line n.404 is:
if (docOrdineCliente.Update() != 0)
Andrea
Hi Andrea,
where you take the document?
Probably, in some place of your code, exists a line like:
docOrdineCliente.GetByKey(....)
You must check if the document was find.
But I don't really understand your loop. You loop through the document lines and, in each iteration, you update the document without change anything. Please check the semantic of the code.
Hope its help
Carmine
Carmine,
below the loop:
for (int j = 0; j < docOrdineFornitore.Lines.Count; j++)
{
docOrdineFornitore.Lines.SetCurrentLine(j);
if (!docOrdineCliente.GetByKey(int.Parse(docOrdineFornitore.Lines.UserFields.Fields.Item("U_OrdEntry").Value.ToString())))
{
throw new Exception("errore: ordine cliente non trovato!");
}
docOrdineCliente.Lines.SetCurrentLine(int.Parse(docOrdineFornitore.Lines.UserFields.Fields.Item("U_OrdLine").Value.ToString()));
docOrdineCliente.Lines.UserFields.Fields.Item("U_OrdEntry").Value = docOrdineFornitore.DocEntry;
docOrdineCliente.Lines.UserFields.Fields.Item("U_OrdLine").Value = docOrdineFornitore.Lines.LineNum;
// aggiorno ordine cliente
if (docOrdineCliente.Update() != 0)
{
SwissAddonFramework.UI.Dialogs.MessageBox.Show("Errore Imprevisto: " + B1Connector.GetB1Connector().Company.GetLastErrorDescription() + " " + B1Connector.GetB1Connector().Company.GetLastErrorCode(), "OK");
throw new Exception("errore in aggiornamento ordine cliente: " + B1Connector.GetB1Connector().Company.GetLastErrorDescription() + " " + B1Connector.GetB1Connector().Company.GetLastErrorCode());
}
}
in each iteration I have to update the sales order line with the corresponding purchase order line.
Hi Andrea,
you are using two document at a time so, probably, in some place of your code you have:
docOrdineCliente = (Documents)B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
...
docOrdineFornitore = (Documents)B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
I think the problem is the simultaneous use of this object. You can make only one instance of Documents at a time, so you need to collect the data into the docOrdineFornitore filling your own array, then dispose the object
docOrdineFornitore = null;
then you can make the docOrdineCliente object, loop on the array you made before, and update the docOrdineCliente with the right data. Update It and dispose it.
Hope its help.
Carmine
Yes! in the same method "elaboraTransazione" I declared:
docOrdineCliente = (Documents)B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
docOrdineFornitore = (Documents)B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
Hi Andrea,
the SAP Business One DI API don't permit you to haw two instance of Documents at same time.
If you call:
docOrdineCliente = (Documents)B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
then, before make the object for the Purchase Orders you need to dispose the docOrdineCliente
System.Runtime.InteropServices.Marshal.ReleaseComObject(docOrdineCliente);
docOrdineCliente = null;
docOrdineFornitore = (Documents)B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
So the problem is in the loop because you use the two objects at the same time.
Andrea, I miss to ask you which version of SAP Business One you use.
Carmine
Hello dude,
i was also facing the same issue. pls check this solution will help for you or not
https://www.linkedin.com/feed/update/urn:li:activity:7166391771059482624
Best Regards,
Mahendrakumar D.P.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
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.