The manager of one of the factories in my company asked me several months ago whether it was possible to print the production drawings of parts whilst printing work orders for those same parts. I replied that it would be no problem to do this in principle, but for in order for this to work, the drawings have to be connected somehow to the parts.
Unfortunately, many of the parts produced in this factory are ad hoc parts which are created automatically by a configurator program, which builds (defines) new parts on the basis of existing parts. According to our tests, the configurator does not copy to the new part documents which are linked to the existing part.
I wrote a program which performs this copying (the documents themselves are not copied, only links to them) but hooking this program up to the output of the configurator (which is an extremely unfathomable black box external program to our ERP program) proved to be problematic. It was very difficult to test the program under controlled circumstances and seemed to work only occasionally.
We were discussing this program's short comings the other day when I suggested taking a different approach to the problem. Every part has what the ERP calls a 'base product': a part which is representative of a class of products. I suggested that the documents be linked to these base products and then at the end of every day, a program would run automatically which would copy the documents from the base product to the parts which had been created that day which belonged to the base product (that's complicated to write but the idea is quite simple).
The following day, following another discussion on the subject, it suddenly struck me that we were still taking a complicated path by focusing on copying the links to the documents. What if the program which prints the work orders printed the documents linked to the base products of the parts in the work orders? This way, there is no need to copy anything anywhere. In order to implement this, I needed to add one clause (about six words) to the SQL statement which controls which documents are to be printed.
As always, the fundamental idea in problem solving applies: the best solution will come once the core problem has been identified. I had been concentrating on copying the links when I should have been concentrating on printing the documents, which is a simpler solution by an order of magnitude.The simplest ideas are normally the best.