****************************************** * Full Vision Index (using DicIndex.dbf) * ****************************************** set safety off set deleted on LOCAL x AS Integer, y AS Integer, result AS Integer LOCAL oErr AS Exception, lHasErrors PUBLIC cDir, cHomeDir, cTable, cTagName, cIndExpr public gcPath, glhasBOM, glhasSCM, glTransport glHasBOM = .f. glhasSCM = .f. glTransport = .f. lHasErrors = .f. TRY cHomeDir = GetDir("","Home Directory") cDir = GetDir("","Company Folder") cd [&cDir] set alternate to "VisionMatrixReIndex.log" additive =LogError("About to Reindex: " + cDir) RebuildVision() RebuildMatrix() set alternate to CATCH TO oErr lHasErrors = .t. oErr.UserValue = "Nested CATCH message: Unable to handle" * ?[: Nested Catch! (Unhandled: Throw oErr Object Up) ] * ?[ Inner Exception Object: ] * ?[ Error: ] + STR(oErr.ErrorNo) * ?[ LineNo: ] + STR(oErr.LineNo) =LogError([ Message: ] + oErr.Message) * ?[ Procedure: ] + oErr.Procedure =LogError([ Details: ] + oErr.Details) * ?[ StackLevel: ] + STR(oErr.StackLevel) * ?[ LineContents: ] + oErr.LineContents * ?[ UserValue: ] + oErr.UserValue *THROW oErr FINALLY =LogError([: Completed: ] ) ENDTRY if lHasErrors =LogError("Job ABANDONED because of Errors (See Above).") endif RETURN result function Rebuild parameter cTable LogError([About to reindex: ] + cTable) use [&cTable] exclusive pack reindex LogError([Reindexed: ] + cTable) endfunc function LogError parameter cMsg set alternate on ? transform(datetime()) + [: ] + cMsg set alternate off return .t. endfunc function RebuildMatrix if not file("nm.dbc") =LogError("There are no Matrix Tables in this Database") return endif open database nm.dbc exclusive validate database recover LogError("Validate Database Completed") ReIndex_Matrix() endfunc function RebuildVision *Rebuild([account]) *Rebuild([acctable]) *Rebuild([customer]) *Rebuild([supplier]) *Rebuild([offsets]) *Rebuild([trans]) *Rebuild([trade]) LogError([About to change directory to: ]+cHomeDir) cd [&cHomeDir] use DicFiles in 0 use DicIndex in 0 LogError([About to change directory to: ]+cDir) cd [&cDir] select DicFiles scan for FileType = [C] or FileType = [B] cTable = DicFiles.FileName LogError([About to reindex: ] + cTable) use &cTable in 0 exclusive select DicIndex scan for FileName = cTable cTagName = TagName cIndExpr = IndExpr *browse Select &cTable *messagebox(cTagName) LogError([About to Create Index: ] + cTagName + [, with expression: ] + cIndExpr) cCmd = [INDEX ON ] + cIndExpr + [ TAG ] + cTagName *messagebox(cCmd) &cCMD endscan LogError([Reindexed: ] + cTable) LogError([========================================================]) endscan endfunc function ReIndex_Matrix gcPath = cDir lcFile = gcPath+"Styles" *? lcFile = OpenTable(lcFile,"Styles","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On StyleID Tag StyleID Index On zStyle Tag zStyle Index On SortCode Tag SortCode Index On Title Tag Title Index On Usr1Field Tag Usr1Field Index On Usr2Field Tag Usr2Field Index On Usr3Field Tag Usr3Field Index On Usr4Field Tag Usr4Field Index On Usr5Field Tag Usr5Field Index On Usr6Field Tag Usr6Field Index On GroupNo Tag GroupNo Index On TaxCode Tag TaxCode Index On TaxCode2 Tag TaxCode2 && RJP 8-Apr-00 for GST Index On zSizeType Tag zSizeType Index On zSeason Tag zSeason Index On Upper(Title) Tag UpperTitle Index On Upper(zStyle) Tag UpperNum * MatTasks * ----- lnPercent = 14 = BarGraph() lcFile = gcPath+"MatTasks" *? lcFile *MESSAGEBOX("About to open MatTasks",0,"Line: " + ALLTRIM(STR(LINENO()))) = OpenTable(lcFile,"MatTasks","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On TaskId Tag TaskId Index On Trim(TaskId)+Trim(Parameters) Tag TaskParam && RJP 19-Apr-98 Use * StylePak * -------- lnPercent = 21 = BarGraph() lcFile = gcPath+"StylePak" *? lcFile = OpenTable(lcFile,"StylePak","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On StyPakId Tag StyPakId Index On Style Tag Style Index On PackCode Tag PackCode Index On Style + PackCode Tag StylePak Index On StockId Tag StockId && added for David Ward for a custom report for Yarra Trail Index On PackStkID Tag PackStkID plSkip = .F. If Type("cbStyObj") != "U" If cbStyObj = 1 plSkip = .F. Else plSkip = .T. Endif Endif If plSkip = .F. * StyleObj * -------- lnPercent = 22 = BarGraph() lcFile = gcPath+"StyleObj" *? lcFile = OpenTable(lcFile,"StyleObj","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On Style Tag Style Endif plSkip = .F. Release plSkip If glhasBOM = .T. * StyBOMov * -------- lnPercent = 28 = BarGraph() lcFile = gcPath+"StyBOMov" *? lcFile = OpenTable(lcFile,"StyBOMov","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On BOMWIP Tag BOMWIP Index On Style Tag Style Index On COLOUR Tag COLOUR Index On Size Tag Size Index On LocNo Tag LocNo * StyBOMin * -------- lnPercent = 31 = BarGraph() lcFile = gcPath+"StyBOMin" *? lcFile = OpenTable(lcFile,"StyBOMin","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On BOMWIP Tag BOMWIP Index On Style Tag Style Index On LocNo Tag LocNo Index On Str(LocNo,4,0) + BOMWIP + Style Tag WIPStyle * StyBOMde * -------- lnPercent = 35 = BarGraph() lcFile = gcPath+"StyBOMde" *? lcFile = OpenTable(lcFile,"StyBOMde","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On BOMWIP Tag BOMWIP Index On Style Tag Style Index On StockId Tag StockId Index On LocNo Tag LocNo Index On Str(LocNo,4,0) + BOMWIP+Style+StockId+UniqueId Tag BOMStyStk * StyleWIP * -------- lnPercent = 42 = BarGraph() lcFile = gcPath+"StyleWIP" *? lcFile = OpenTable(lcFile,"StyleWIP","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On StyWIPid Tag StyWIPid && RJP 8-Jan-06 Added index Index On BOMWIP Tag BOMWIP * StyProdn * -------- lnPercent = 47 = BarGraph() lcFile = gcPath+"StyProdn" *? lcFile = OpenTable(lcFile,"StyProdn","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On Style Tag Style Index On CustCode Tag CustCode Index On SuppCode Tag SuppCode Index On BOMJob Tag BOMJob Index On LocNo Tag LocNo * StyJobDe * -------- lnPercent = 49 = BarGraph() lcFile = gcPath+"StyJobDe" *? lcFile = OpenTable(lcFile,"StyJobDe","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On BOMJob Tag BOMJob Index On StockId Tag StockId Index On BOMJob+StockId Tag JOBSTOCK Index On LocNo Tag LocNo * StyJobTr * -------- lnPercent = 50 = BarGraph() lcFile = gcPath+"StyJobTr" *? lcFile = OpenTable(lcFile,"StyJobTr","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On BOMJob Tag BOMJob Index On BOMWIP Tag BOMWIP Index On Style Tag Style Index On StockId Tag StockId Index On BOMJob+StockId+Str(LocNo,4,0) Tag JOBSTOCK Index On UniqueId Tag UniqueId Index On BOMJob+BOMWIP+Str(LocNo,4,0) Tag JobWIP Index On LocNo Tag LocNo Endif && glhasBOM If glhasSCM * SCMitems * -------- lnPercent = 51 = BarGraph() lcFile = gcPath+"SCMitems" *? lcFile = OpenTable(lcFile,"SCMitems","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On SCMitem Tag SCMitem Endif * StyleInv * -------- lnPercent = 52 = BarGraph() lcFile = gcPath+"StyleInv" *? lcFile = OpenTable(lcFile,"StyleInv","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On UniqueId Tag UniqueId Index On zStyle Tag zStyle Index On zColour Tag zColour Index On zSize Tag zSize Index On Season Tag Season Use * Colours * ------- lnPercent = 56 = BarGraph() lcFile = gcPath+"Colours" *? lcFile = OpenTable(lcFile,"Colours","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On COLOUR Tag COLOUR Use * Sizes * ----- lnPercent = 63 = BarGraph() lcFile = gcPath+"Sizes" *? lcFile * create a temporary dbf to sort the sizes table *jcDBTmp = SUBSTR(SYS(2015), 3) *lcDBTmpDBF = gcTmpPath+jcDBTmp + ".tmp" *lcDBTmpCDX = gcTmpPath+jcDBTmp + ".cdx" *= OpenTable(lcFile,"Sizes","EXCLUSIVE") *SORT TO &lcDBTmpDBF ON Sizes.sizetype,Sizes.sizename *Use *Use &lcDBTmpDBF exclusive *copy to &lcFile *Use *Erase &lcDBTmpDBF = OpenTable(lcFile,"Sizes","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On SizeType Tag SizeType Index On SizeName Tag SizeName Use * StyleCol * -------- lnPercent = 70 = BarGraph() lcFile = gcPath+"StyleCol" *? lcFile = OpenTable(lcFile,"StyleCol","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On zStyle Tag zStyle Index On COLOUR Tag COLOUR Use * Seasons * ------- lnPercent = 77 = BarGraph() lcFile = gcPath+"Seasons" *? lcFile = OpenTable(lcFile,"Seasons","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On Season Tag Season Use * LedgPost * -------- lnPercent = 84 = BarGraph() lcFile = gcPath+"LedgPost" *? lcFile = OpenTable(lcFile,"LedgPost","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On UserNo Tag UserNo Index On LedgerNo Tag LedgerNo Index On UniqueId Tag UniqueId Index On PostId Tag PostId Index On PeriodNo Tag PeriodNo Index On Date Tag Date Index On Desc Tag Desc INDEX ON uniqueid+desc TAG uid_desc && RJP 08-Jan-08 Used to summarize journals * RJP 05-Jun-07 Remove variable length indices as they cause error 2199 in VFP 9 *Index On Dtoc(Date) + Chr(LedgerNo) + UniqueId + Desc Tag DateCode * StockExt * -------- lnPercent = 88 = BarGraph() lcFile = gcPath+"StockExt" && Inventry.dbf extension table *? lcFile = OpenTable(lcFile,"StockExt","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On StockId Tag StockId Use * CustExt * -------- lnPercent = 90 = BarGraph() lcFile = gcPath+"CustExt" && Customer.dbf extension table *? lcFile = OpenTable(lcFile,"CustExt","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On UniqueId Tag UniqueId Index On InvoiceTo Tag InvoiceTo Index On SalesCode Tag SalesCode Use If .F. && skip rebuild of reports file as it is not necessary * MatRpts * ------- lnPercent = 92 = BarGraph() *lcFile = gcStartDir+"Matrix\MatRpts" && Matrix report database table If ("Visual" $ Version()) lcFile = gcStartDir+"Matrix32\MatRpts" && Matrix report database table Else lcFile = gcStartDir+"Matrix\MatRpts" Endif *? lcFile = OpenTable(lcFile,"MatRpts","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On Title Tag Title Use * MatCRpt * ------- lnPercent = 94 = BarGraph() If ("Visual" $ Version()) lcFile = gcStartDir+"Matrix32\MatCRpt" && Matrix Customer report database table Else lcFile = gcStartDir+"Matrix\MatCRpt" Endif *? lcFile = OpenTable(lcFile,"MatCRpt","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On Title Tag Title Use lcFile = gcPath+"TranCoys" && Transport Companies *? lcFile = OpenTable(lcFile,"TranCoys","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On TranCoyId Tag TranCoyId Index On Carrier Tag Carrier Use Endif && .f. * Distrib * ------- lnPercent = 96 = BarGraph() lcFile = gcPath+"Distrib" && Branch order allocation *? lcFile = OpenTable(lcFile,"Distrib","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On Alltrim(IntRef)+Alltrim(ExtRef) Tag OrdRef Index On Alltrim(IntRef)+Alltrim(ExtRef)+Alltrim(Branch) Tag BranchRef Use * StyleSPC * ------- lnPercent = 98 = BarGraph() lcFile = gcPath+"StyleSPC" && Style Special Prices and Costs *? lcFile = OpenTable(lcFile,"StyleSPC","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On SPCid Tag SPCid Index On zStyle Tag zStyle Index On Cust_ID Tag Cust_ID Index On Supp_ID Tag Supp_ID Use If glTransport = .T. lcFile = gcPath+"LocExt" && Location Extension *? lcFile = OpenTable(lcFile,"LocExt","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On LocNo Tag LocNo Use lcFile = gcPath+"TranTruc" && Trucks by Transport Companies *? lcFile = OpenTable(lcFile,"TranTruc","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On TranCoyId Tag TranCoyId Index On TruckRef Tag TruckRef Use lcFile = gcPath+"TranRate" && Rates charged by each Transport Company *? lcFile = OpenTable(lcFile,"TranRate","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On TranCoyId Tag TranCoyId Index On LocNo Tag LocNo Index On Journey Tag Journey Use lcFile = gcPath+"TransExt" && Trans.dbf extension table *? lcFile = OpenTable(lcFile,"TransExt","EXCLUSIVE") gcTaskInfo = "About to pack " + lcFile Pack Index On DocType Tag DocType Index On InternRef Tag InternRef Index On ExternRef Tag ExternRef Index On TranCoyId Tag TranCoyId Index On GSTTaxInv Tag GSTTaxInv Index On LocNo Tag LocNo Index On Journey Tag Journey Index On TruckRef Tag TruckRef Use Endif lnPercent = 100 = BarGraph() Release Window BarGraph *messagebox("Completed.",0,"Matrix Reindex") Return * end of function: ReIndexMatrix() function opentable parameter tcFile, tcAlias, tcMode use &tcFile alias &tcAlias &tcMode return function BarGraph return