SalesOrderLine.RESET; SalesOrderLine.SETRANGE("Document Type","Document Type"); SalesOrderLine.SETRANGE("Document No.","No."); SalesOrderLine.SETFILTER("Quantity Invoiced",'<>0'); IF SalesOrderLine.FIND('-') THEN BEGIN SalesOrderLine.SETRANGE("Quantity Invoiced"); SalesOrderLine.SETFILTER("Outstanding Quantity",'<>0'); IF NOT SalesOrderLine.FIND('-') THEN BEGIN SalesOrderLine.SETRANGE("Outstanding Quantity"); SalesOrderLine.SETFILTER("Qty. Shipped Not Invoiced",'<>0'); IF NOT SalesOrderLine.FIND('-') THEN BEGIN SalesOrderLine.LOCKTABLE; IF NOT SalesOrderLine.FIND('-') THEN BEGIN SalesOrderLine.SETRANGE("Qty. Shipped Not Invoiced"); DocDim.SETRANGE("Table ID",DATABASE::"Sales Line"); IF SalesOrderLine.FIND('-') THEN REPEAT
Comments
Any FIND('-') is due to old codes which M$ does not find it profitable to update for new versions.
ERP Consultant (not just Navision) & Navision challenger
The script I posted is from NAV5.0 sp1.
I wonder when do they find it profitable :shock:
Such codes are indeed, everywhere...
But what are about the nested FIND('-')?
1. WHERE Doc#=Doc#, Type=Type, "Quantity Invoiced" <> 0
2. Get result set
3. Remove from WHERE clause "Quantity Invoiced" <> 0
4. Add to WHERE clause: "Qty Shipped Not Invoiced" <> 0
5. Get result set
6. Remove from WHERE clauase "Qty Shipped Not Invoiced" <> 0
7. ...
Any particular reason to such filter-fetch-clear nesting you think?
The sequence looks like a series of AND clause
is there any line which have something invoiced?
if yes, is there any line with some Outstanding quantity?
if no, is there any line with some quantity shiped, but not invoiced?
if no, lock the records and delete the order...
You cannot do that in with one set of filters...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.