APFileLocation := 'N:\Payables\'; ARFileLocation := 'N:\Receivables\'; OnPreReport() IF GUIALLOWED THEN Window.OPEN('Processing #####################################1#####'); APFileLocation := DELCHR(APFileLocation,'>','\') + '\'; ARFileLocation := DELCHR(ARFileLocation,'>','\') + '\'; MyFile.SETRANGE(Path,APFileLocation); MyFile.SETRANGE("Is a file",TRUE); IF MyFile.FIND('-') THEN REPEAT VendorLedger.RESET; VendorLedger.SETCURRENTKEY("Document No."); VendorLedger.SETRANGE("Document No.",COPYSTR(MyFile.Name,1,STRLEN(MyFile.Name)-4)); VendorLedger.SETRANGE("Document Type",VendorLedger."Document Type"::Invoice); IF VendorLedger.FINDFIRST THEN BEGIN IF GUIALLOWED THEN Window.UPDATE(1,VendorLedger."Document No."); recordLink.SETRANGE(Description,MyFile.Name); IF recordLink.ISEMPTY THEN BEGIN VendorLedger.ADDLINK(MyFile.Path+MyFile.Name,MyFile.Name); COMMIT; END; END; UNTIL MyFile.NEXT = 0; MyFile.SETRANGE(Path,ARFileLocation); MyFile.SETRANGE("Is a file",TRUE); IF MyFile.FIND('-') THEN REPEAT CustLedger.RESET; CustLedger.SETCURRENTKEY("Document No."); CustLedger.SETRANGE("Document No.",COPYSTR(MyFile.Name,1,STRLEN(MyFile.Name)-4)); CustLedger.SETRANGE("Document Type",VendorLedger."Document Type"::Invoice); IF CustLedger.FINDFIRST THEN BEGIN IF GUIALLOWED THEN Window.UPDATE(1,CustLedger."Document No."); recordLink.SETRANGE(Description,MyFile.Name); IF recordLink.ISEMPTY THEN BEGIN CustLedger.ADDLINK(MyFile.Path+MyFile.Name,MyFile.Name); COMMIT; END; END; UNTIL MyFile.NEXT = 0; IF GUIALLOWED THEN Window.CLOSE;
Answers