Import of AP Bills - random errors

Hi Experts,

I created an integration that pulls CSV files with AP Bills from an FTP server and imports those into Sage 100. Every time the script runs it imports 20 to 50 AP Bills. The bills are often for different company codes, so the integration switches back and forth between companies.

Randomly we are getting the following error: "The child data source is not on file". Once this error starts, it will repeat for multiple AP bills during that session. Sometimes then the error stops to occur in the session, but then the nSetKey() to create a new invoice returns 1 instead of 2 (as if the invoice would already exist). 

With a new script session the invoices will import just fine the next time.

Is there any specific clean up that I need to do when switching companies? Or is there anything else I should do to prevent the Sage objects from crashing?

Thanks for your help!

Best,

B.