on 02-27-2006 9:44 AM
Hi there,
I'm updating a lot of sales orders in ship date and an user defined field in a loop.
If I run the add-on on a big number of sales order lines the add-on stops after a while without of any error messages.
What may be wrong?
Hi Juri!
What does the log-file say? Does it close properly so that you can see any content of the file?
You could also check your system-logs by executing "Start"->"run" "%SystemRoot%\system32\eventvwr.msc /s"
Are there any entrys that could give clue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ad, hi Marian,
@Marian: my logfile says that the process is stopped with the message 'the server threw an exception' in the line where I try to <i>oOrder.getByKey()</i>
The eventvwr.exe I'm going to check. thanks for this hint.
@Ad: I checked the Queries I do during the whole process. There are about 130 queries mainly select-queries the add-on sends. I'm always using the same 3 or 4 recordsets. Is there anything I can do to reduce the memory consumption? Would it be better if I use local recordsets and always release them after use?
Hi Marian,
the problem is, that the add-on does not always jump to the catch block. Sometimes it is stopped without any message. Even if I would use the "GetLastError"-method the program would not execute it.
@Ad,
I thought the problem is, that the objects sometimes aren't released at all and the more objects I initialize the more memory problems I get?
Shall I initialize a new oOrder object everytime I open a new sales order and release is after update?
Hi Juri,
have you reached any solution ? I'm having similar problems in my addon. Sometimes the program hangs, sometimes it hangs consuming 100% of processor time , sometimes it crashes with "The server threw an exception." ... It happens in GetBusinessObject too.
I found several developer posts about this behavior but never any solution or statement from SAP ...
Best Regards
Jan
I have the same issue, anyone found a solution yet?
This is pretty critical!
/Bruno
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i had similar problems. i found out that when ever i was doing GC.Collect, the system was entering unstable state and after like 15 adding of sales orders it was crashing on different positions in the code
what solved my problems was just removing all the GC.Collect i had in the code (all of them).
now the system is stable
please try and let me know what do you get
Hi Juri,
How much RAM is your add-on using? Check this in the Windows Task Manager. You should also free your order after you have used it with
System.Runtime.InteropServices.Marshall.ReleaseComObject(oOrder)
GC.Collect
You can also time the process and if every order you update becomes slower and slower you must handle memory management a bit better.
Hope it helps,
Adele
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Adele,
thanks for your reply.
I already changed my source to only use one oOrder object like:
oSalesOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
While Not oRecSet.EoF
oSalesOrder.GetByKey(oRecSet.Fields.Item("DocEntry").Value)
oSalesOrder.Lines.SetCurrentLine(oRecSet.Fields.Item("LineNum").Value)
oSalesOrder.Lines.ShipDate = oRecSet.Fields.Item("Date").Value
oSalesOrder.Update()
oRecSet.MoveNext
End While
System.Runtime.InteropServices.Marshall.ReleaseComObject(oOrder)
GC.Collect
But the add-on is still stops without of any message. All the procedure is set in a 'try-catch' construct.
The memory usage raises up to about 100-120MB thats not so much I think.
How can I time the process, what do you mean with that? Can I take the time of every update?
Hi Alex,
I do use the return code of the update. If 0 everything is ok, if other than 0 I make an entry to a log file.
But the Add-On is stopped. It's not listed in the task manager any longer. If I go to the B1 and click anything I get this message, that the add-on is stopped and gives the three options to restart add-on, work without add-on or to logout from company.
The add-on also do not jump to the catch block that would handle any error.
Hi Juri,
I had the same problem at a client and no matter how much I tried with freeing/releasing components and objects being used there is still memory that does not get free. I have to date not found a solution. If I run the update process on the server it works fine, but when I run it from one of the workstations it does not as the add-on uses more and more memory. Luckily this is a monhtly process that the client has to run and they are happy running it from the server.
Anyone suggestions on memory management? Have you checked how much RAM it uses when your add-on crashes and how memory is built up?
Hope it helps,
Adele
Hi again.
I now made some tests.
The add-on seems to crash on oOrder.GetByKey()
I ran the add-on frm a client on the server and from the client of a special client PC. At the server the add-on ran through approx. 1300 sales order lines. At the other PC it where only about 500 lines before the add-on crashes.
Then I wrote a much simpler stand alone program.
I select all sales order lines from RDR1 and update on all of them a user defined filed. In two tries the add-on throw an error after 7700 line and another time after 10300 lines.
oSalesOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
oRecSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oRecSet2 = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oRecSet.DoQuery("SELECT DocEntry, LineNum FROM RDR1")
logFile("Sales order lines: " & oRecSet.RecordCount)
vCount = 0
Try
While Not oRecSet.EoF
If vDocEntry <> oRecSet.Fields.Item("DocEntry").Value Then
Try
oSalesOrder.Update()
Catch e3 As Exception
logFile("Error while update of SalesOrder " & oSalesOrder.DocNum & "(" & oRecSet.Fields.Item("Docentry").Value & "): " & e3.Message)
End Try
vDocEntry = oRecSet.Fields.Item("DocEntry").Value
oSalesOrder.GetByKey(oRecSet.Fields.Item("DocEntry").Value)
logFile("SalesOrder " & oSalesOrder.DocNum & " with " & oSalesOrder.Lines.Count & " Lines.")
End If
Try
oSalesOrder.Lines.SetCurrentLine(oRecSet.Fields.Item("LineNum").Value)
oRecSet2.DoQuery("SELECT Quantity, OpenQty FROM RDR1 WHERE DocEntry = " & oRecSet.Fields.Item("DocEntry").Value & " AND LineNum = " & oRecSet.Fields.Item("LineNum").Value)
oSalesOrder.Lines.UserFields.Fields.Item("U_SCHDDAT2").Value = vDate
Catch e2 As Exception
logFile("Error in line " & oRecSet.Fields.Item("LineNum").Value & ": " & e2.Message)
End Try
vCount = vCount + 1
oRecSet.MoveNext()
End While
logFile(vCount & " SO lines handlet.")
Catch e1 As Exception
logFile("General error while updating: " & vCount & " " & e1.Message)
End Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSalesOrder)
oCompany.Disconnect()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oCompany)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oRecSet)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oRecSet2)
GC.Collect()
User | Count |
---|---|
100 | |
12 | |
11 | |
6 | |
6 | |
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.