Error 52 "Due to an internal error..."

15 posts / 0 new
Last post
loliman
Offline
Joined: 09/16/2013 - 10:48
Error 52 "Due to an internal error..."

Hi there,
Firstly, I've got a huuuuuuuuuge script here (11k+ lines of code) so I will not post the whole in this thread. ;)
Anyway, the problem, that I've got with my script, that I randomly get a "Errornumber: 52,"Due to an internal error, the Project Overview information for this task was not recorded."". Lets say, I will run the script five times, three out of this five times, work perfectly, one throws the mentiond error, pretty often followed by a "Bad file name or number", and the other time simply crashes IDEA.
I have no clue why, when I'm debugging the script everything seems fine, but letting it run independently leads to the problems mentioned above. Following there is one expample-function of my script.
 
Function Analysis_PU_02_VendorMaster_without_purchasing_volume_in_last_two_years_no_Central_Deletion_Flag
On Error GoTo ErrHandler 
  Dim dbname As String
  Dim finname As String
  finname = "PU_02_VendorMaster_without_purchasing_volume_in_last_two_years_no_Central_Deletion_Flag"
dbname = workingdirectory + "\03 Results\PU_02_VendorMaster_without_purchasing_volume_in_last_two_years.IDM"
Set db = Client.OpenDatabase(dbname)
Set task = db.Extraction
task.DisableProgressNotification = True
task.IncludeAllFields
dbName = workingdirectory + "\03 Results\"+finname+".IDM"
task.AddExtraction dbName, "", "CENTRAL_DELETION_FLAG_FOR_MASTER_RECORD_ = ""No"""
 
Client.CloseAll
dim copycomplete as boolean
copycomplete = moveIt(finname, "Vendor Master without purchasing Volume in last to Years no central Deletion Flag")
Set task = Nothing
Set db = Nothing
 
Exit Function
ErrHandler:
If Err.Number = 0 Then
Write #1, Now, " - ERROR - " , "Analysis_PU_02_VendorMaster_without_purchasing_volume_in_last_two_years_no_Central_Deletion_Flag", Err.Number, Err.Description, "Error Not defined"
Else
Write #1, Now, " - ERROR - " , "Analysis_PU_02_VendorMaster_without_purchasing_volume_in_last_two_years_no_Central_Deletion_Flag", Err.Number, Err.Description
End If
errorOccurred = TRUE
Resume Next
End Function
 
As I said, this is just a small bit of my whole script (which basicly is a GUI to choose different scripts, that should be executed). I'm getting the error in a lot of different functions, but not always in the same, just sometimes... if it wants to... and if its not working as intendent (I think you might understand my confusion :( ).
Any help about this problem is appreciated! :) Thanks in advance,
loliman
(If you need more information, then I'll provide you!)

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi loliman,

Is the script always working out of the same project folder?  The only thing I can think of off the top of my head is that the path and filename is becoming too long and that is causing a problem.  Windows allows for a maximum of 260 characters, I noticed your filename is long and depending on how many levels down it might be in your directory structure could you be exceeding the 260 limit on occasion?

It can be frustrating when a script doesn't work as planned. 

Also for the new name you are not using the client.uniquefilename function, any chance that the file might already exist and that is giving a problem, if it does exist IDEA should stop and ask if you want to overwrite the file.  Sorry without more info it is difficult to tell what is going on.

When you run the script and you have a problem is it on the same files that has worked before?  Have you deleted the previous files?  Sometimes it can be difficult to find the variable that is causing the problem and sometimes it might be some limit you have reached that is causing the error.  Hopefully we can figure this out.

loliman
Offline
Joined: 09/16/2013 - 10:48

Opps, double post... see below :)

loliman
Offline
Joined: 09/16/2013 - 10:48

Hi Brian,
 
thanks for looking into my problem! As I said, the problems seem to occure pretty random, thats why I've not provided you with further information.
Regarding your first guess, I tried the script in different projectfolders. Sometimes its working well, sometimes not, no matter if the projectfolder is C:\Folder or C:\200moreChars\Folder.
 
Next up, I don't use Client.UniqueFilename, because the script asks me to wether I want to overwrite even without it. (Is it better to use client.uniquefilename?)
Lastly, yes, the script does work on files that were causing problems just one run before. Even without deleting them (I just overwrite them). Thats whats causing my headache. :(
 
If it helps you, here's what my script does and how it works.
As I said, the whole script is more or less a GUI to run different analysises on extracted SAP data. At first step, I import some .txt files that were extracted from SAP (Thats always working like a charm).
Secondly, I choose different analysises to execute by checking checkboxes in the GUI. After clicking on the execute button (my GUI) the script will search for checked checkboxes and executes the desired analysises.
After each analysis (every analysis is a function) the generated databases are copied (! not moved) to another directory and a view is beeing applied to the "new\copied" database.
Thats basicly it. I know that the script is a bit messy at 11k lines of code, which, together with the little debugging posibilities of the IDEA editor (is there a better one then the standard one?), makes it hard to find the problem...
 
The problem seems to occure before moving the databases to the new directory, but it's hard to tell, cause I never got the script to crash while debugging and so I can't really locate the bug-causing line of code.
 
If you need more information, tell me, I'll be testing a lot today, hopefully successfull.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi loliman, I agree the scripting editor needs an update.  I have complained to idea on several occasions about this, I think they need more people to complain so please let your distributor know that they should be updating the editor, you might be the one complaint that pushes it from a nice to have to a get it done.

I was relooking at your code and I see you have a resume next for your error.  This might actually be hiding the real error, so an error happens, the program continues on until another error, i.e. a bad filename is used and it can't continue anymore.  Maybe comment out that line so that when it hits the first error you will see the location and change the write to a msgbox so you get instance feedback on what the error is, just a thought.

That is really strange, the client.uniquefilename checks to see if the file exists, if it does it adds a 1 to the end until it finds a unique filename so that you won't get the overwrite box as the file should be different and not need overwriting.  I always use it in my scripts and usually use a varaible or an array to store the different filenames to gain access to them.

Good luck, let me know how your testing turns out.  Sounds like an interesting script.

loliman
Offline
Joined: 09/16/2013 - 10:48

Back with some new findings!
 
I constantly repeated the same case, execute this function "Analysis_PU_02_Duplicate_Name_Address_VATNumber" (see below).
Out of 15 times, it failed 2 time, throwing the errormessage "#2013-09-20 15:30:04#," - ERROR - ","Analysis_PU_02_Duplicate_Name_Address_VATNumber",52,"Due to an internal error, the Project Overview information for this task was not recorded."
The task.perform has defintily been executed, cause the database PU_02_Duplicate_Name_Address_VATNumber.IDM exists and is not corrupted - conclusion: The problem has to be in the following code. The database is not opened, so the client.closeall should not be throwing the error either. 
Now two things are confusing me. Resulting the findings stated out, the problem has to be in "moveIt". But why does the error come from the Analysis_PU_02_Duplicate_Name_Address_VATNumber-Error Handler and not the one from moveIt?
I attached every possible "failzone" bellow, I just cant figure out what is causing the error.
 
Function Analysis_PU_02_Duplicate_Name_Address_VATNumber
 On Error GoTo ErrHandler 
Dim dbname As String
Dim finname As String
finname = "PU_02_Duplicate_Name_Address_VATNumber"
dbname = workingdirectory + "\03 Results\VendorMaster_without_Employees.IDM"
If fileexists(dbname)=false Then
Call Analysis_VendorMaster_without_Employees
End If
Set db = Client.OpenDatabase(dbname)
Set task = db.DupKeyDetection
task.DisableProgressNotification = True
task.IncludeAllFields
task.AddKey "NAME_1", "A"
task.AddKey "CITY", "A"
task.AddKey "POSTAL_CODE", "A"
task.AddKey "HOUSE_NUMBER_AND_STREET", "A"
task.AddKey "VAT_REGISTRATION_NUMBER", "A"
task.OutputDuplicates = TRUE
dbName = workingdirectory + "\03 Results\" + finname + ".IDM"
task.PerformTask dbName, ""
 
Client.CloseAll
Dim copycomplete As Boolean
copycomplete = moveIt(finname, "Duplicate Name Address VATNumber")
Set task = Nothing
Set db = Nothing  
 
Exit Function
ErrHandler:
If Err.Number = 0 Then
Write #1, Now, " - ERROR - " , "Analysis_PU_02_Duplicate_Name_Address_VATNumber", Err.Number, Err.Description, "Error Not defined"
Else
Write #1, Now, " - ERROR - " , "Analysis_PU_02_Duplicate_Name_Address_VATNumber", Err.Number, Err.Description
End If
errorOccurred = TRUE
'resume next
End Function
 
 
Function moveIt(thisname As String, newname As String) As Boolean
On Error GoTo ErrHandler 
Dim dbname As String
'at first check wether the database, which should be moved, is available or not
If fileexists(workingdirectory + "\03 Results\" + thisname + ".IDM") Then
'then see if it allready exists in \04 and delete if yes
If fileexists(workingdirectory + "\04 Evidences\" + newname + ".IDM") Then 
Client.DeleteDatabase(workingdirectory + "\04 Evidences\" + newname + ".IDM")
End If
 
'copy the new one
FileCopy workingdirectory + "\03 Results\" + thisname + ".IDM",  workingdirectory + "\04 Evidences\" + newname + ".IDM"
dbname = workingdirectory + "\04 Evidences\" + newname + ".IDM"
'and apply a view
Set db = Client.OpenDatabase(dbName)
If db.Count > 0 Then
'old name
If fileexists(workingdirectory + "\01 Templates\export\" + newname + ".VWM") Then
Client.OpenView workingdirectory + "\01 Templates\export\" + newname + ".VWM"
'new name
ElseIf fileexists(workingdirectory + "\01 Templates\export\" + thisname + ".VWM") Then
Client.OpenView workingdirectory + "\01 Templates\export\" + thisname + ".VWM"
'case zspn
ElseIf InStr(1, thisname, "ZSPN") And fileexists(workingdirectory + "\01 Templates\export\ZSPN.VWM") Then
Client.OpenView workingdirectory + "\01 Templates\export\ZSPN.VWM"
End If
End If
Client.CloseAll
End If
moveIt = true
Set db = Nothing
Exit Function
ErrHandler:
If Err.Number = 0 Then
Write #1, Now, " - INFORMATION - " , "moveIt", Err.Number, Err.Description, "File can not be deleted/replaced. Ignore this, no real problem." +thisname
moveIt = true
Else
Write #1, Now, " - ERROR - " , "moveIt", Err.Number, Err.Description, thisname
errorOccurred = TRUE
moveIt = false
End If
'resume next 
End Function
 
Function FileExists(PathName As String) As Boolean 
Dim i As Integer 
'Ignore errors to allow for error evaluation
    On Error resume next
    i = GetAttr(PathName) 
'Check if error exists and set response appropriately
Select Case i
Case 0 
FileExists = False 
Case Else 
FileExists = True 
End Select 
Err.Number = 0
    'Resume error checking
    On Error GoTo 0 
End Function 
 
Perhaps you are able to find the problem before me.
Thanks for your help!

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Loliman, I will try and find some time to look at this on the weekend.  I am on the road this week so it has been busy.

Brian

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Loliman,

I am just looking at the code while waiting for my flight and one possible problem I see is you don't reset the err.number.  If an error is raised once you get the error number it is not automatically reset, you need to reset it.  If you don't reset it and you check for the error somewhere else then it will show the same error number.  Not sure if this is causing your problem.  I will look at the code again when my head is in a better place.

loliman
Offline
Joined: 09/16/2013 - 10:48

Hi Brian,
thanks for your help, but how do you reset the Err.Number? I'll try some other things today, that came up my mind, hopefully we'll get this fixed!

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Loliman, all you have to do is Err.Number = 0 to reset the number.  Sorry it was a busy weekend, I didn't get a chance to look at your code closely yet.  You can even create your own errors this way.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Loliman, so how is the debugging going.

Other things you might want to watch out for is that your field names are hardcoded, so if any of the fields have been created and already exist they might not be pointing at the correct field and that could be causing you errors.  Also your filenames are hardcoded that could also cause problems if the filename gets changes either inside of the program or someone renames the file in IDEA.

Pages