I have a report, created using database wizard connected to our manufacturing ERP system, that list parts remaining to be issued to open jobs. In the report I have a subreport that identifies if there are any open jobs to make any of the parts listed in the main report.
One of the custom fields I want to populate is going to be called "Next OP ID", which means I want to show the next incomplete operation after the last completed operation.
I am not sure if there is an easy way to do using formulas, etc., but the way I came up with is by using an SQL expression.
Here is my current expression for "Next OP ID":
In the inner SELECT, the code looks for the last completed operation (in descending order) - jmoProductionComplete = -1 means completed operation. If there is none then 0 is returned so that I can get the first operation.
Then, in the outer SELECT it looks for the next operation id that is greater than that one. The reason I do it this way is that it could be possible that an operation was skipped, and I don't want to include that operation in my sql.
It works, but the problem is the length of time it takes to generate a report. The more parts in the main section, the longer it takes.
I hope this is enough information. Let me know if more is required.
Can anyone suggest a quicker method?
One of the custom fields I want to populate is going to be called "Next OP ID", which means I want to show the next incomplete operation after the last completed operation.
I am not sure if there is an easy way to do using formulas, etc., but the way I came up with is by using an SQL expression.
Here is my current expression for "Next OP ID":
Code:
(Select Top 1 JO. jmoJobOperationID from JO WHERE jmoJobID = J.jmpJobID and JO. jmoJobOperationID >
(SELECT ISNULL
((SELECT top 1 JO.jmoJobOperationID FROM JO WHERE jmoJobID = J.jmpJobID and JO.jmoProductionComplete = -1 order by JO. jmoJobOperationID desc)
,0)))
In the inner SELECT, the code looks for the last completed operation (in descending order) - jmoProductionComplete = -1 means completed operation. If there is none then 0 is returned so that I can get the first operation.
Then, in the outer SELECT it looks for the next operation id that is greater than that one. The reason I do it this way is that it could be possible that an operation was skipped, and I don't want to include that operation in my sql.
It works, but the problem is the length of time it takes to generate a report. The more parts in the main section, the longer it takes.
I hope this is enough information. Let me know if more is required.
Can anyone suggest a quicker method?