Ok, I'm revisiting a project of mine - our program that prints packing slips.
Recently with our upgrade from GP7.5 to GP9 I had to make a change in how it handled ShipComplete documents - it now has to check each item on an order to make sure all the items on the document are shipping.
Previously this is the process it took:
Gather all Orders that haven't printed before
Weed out ones that shouldn't print using the following checks:
Make sure order has items that would ship out
Make sure there isn't a hold on the order
Make sure there isn't a lock on the order (someone has it open)
Make sure the document date isn't in the future
Do ShipComplete check.
After the GP9 upgrade this whole process slowed down considerably, namely due to the fact I changed how I was dealing with ShipComplete documents (previously it was a hold and a third-party plugin removed the hold when it was ready).
I want to streamline this process to make it faster. I'm trying to consolidate all the steps into a single SQL statement to speed things up. So far I've got everything into 1 sql statement, except checking items on ShipComplete documents.
Here is the sql code I have so far:
Maybe I'll have better luck in the SQL forums, but I figured I'd better check here first - as you guys know the GP system better. I'll post in the SQL forums tomorrow - if I don't figure it out in the meantime.
Recently with our upgrade from GP7.5 to GP9 I had to make a change in how it handled ShipComplete documents - it now has to check each item on an order to make sure all the items on the document are shipping.
Previously this is the process it took:
Gather all Orders that haven't printed before
Weed out ones that shouldn't print using the following checks:
Make sure order has items that would ship out
Make sure there isn't a hold on the order
Make sure there isn't a lock on the order (someone has it open)
Make sure the document date isn't in the future
Do ShipComplete check.
After the GP9 upgrade this whole process slowed down considerably, namely due to the fact I changed how I was dealing with ShipComplete documents (previously it was a hold and a third-party plugin removed the hold when it was ready).
I want to streamline this process to make it faster. I'm trying to consolidate all the steps into a single SQL statement to speed things up. So far I've got everything into 1 sql statement, except checking items on ShipComplete documents.
Here is the sql code I have so far:
Code:
SELECT RTRIM(SOP10100.SOPNUMBE) AS DOCNUMBE, COUNT(SOP10200.ITEMNMBR) AS ShippableItems,
COUNT(SOP10104.PRCHLDID) AS HoldCount, SOP10100.DOCDATE,
COUNT(tempdb.dbo.DEX_LOCK.row_id) AS LockCount
FROM SOP10100
LEFT OUTER JOIN SOP10200 ON (SOP10100.SOPTYPE = SOP10200.SOPTYPE AND SOP10100.SOPNUMBE = SOP10200.SOPNUMBE AND (SOP10200.DROPSHIP = 0 AND SOP10200.QTYTOINV >0))
LEFT OUTER JOIN SOP10104 ON (SOP10100.SOPTYPE = SOP10104.SOPTYPE AND SOP10100.SOPNUMBE = SOP10104.SOPNUMBE AND (SOP10104.DELETE1 = 0))
LEFT OUTER JOIN tempdb.dbo.DEX_LOCK ON (SOP10100.DEX_ROW_ID = tempdb.dbo.DEX_LOCK.row_id AND tempdb.dbo.DEX_LOCK.table_path_name = 'PDP.dbo.SOP10100')
WHERE
SOP10100.TIMESPRT = 0 AND SOP10100.SOPTYPE = 2 AND
SOP10100.DOCDATE <= GETDATE()
GROUP BY SOP10100.SOPNUMBE, SOP10100.DOCDATE
HAVING COUNT(SOP10200.ITEMNMBR) > 0 AND COUNT(SOP10104.PRCHLDID) = 0 AND
COUNT(tempdb.dbo.DEX_LOCK.row_id) = 0
Maybe I'll have better luck in the SQL forums, but I figured I'd better check here first - as you guys know the GP system better. I'll post in the SQL forums tomorrow - if I don't figure it out in the meantime.