'AD - create ipath "aged_drs.idx" in default data drive

external   fentrybox() messbox() vloadif() chkdate() sch scw popuplist()
external   dpath remove() makeidx() addidxrec() progress() PrintReport()
external   chkstr() posnpopup() pmexe filedatime() getidxrecs()
external   ipath progtag() fgp bgp fgi bgi cpath spath vunloadif() strcount()
external   $drive tone()

public     ptstr $itemtype psa $ccwcode ptval ftgdate jobnr $b $branch $key
public     ftgperiod #int choice

global SelectDrs()

MAIN
single-step off
  screen clear box 1 1 sch scw 0 0 no-border
  file unload all
  SelectDrs()

END MAIN


FUNCTION SelectDrs()
  progress(15,10," Please wait ... finding balances ",1)
  progtag(fgi,bgi,"Creating index of Aged Drs ")
  vloadif(dpath|"cust_ord.vws")
  data query execute "drs_full.dfq" INDEX "first.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' [Balance_Due]>.01
' or
' [Balance_Due]<-.01
' and
' [Balance_Due]<>blank
' and
' [Inv_Nr]<>blank
' and
' not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messbox(" No outstanding debtors to list ",0,0,1)
    return (1)
  end if

  data query execute "ageddrs1.dfq" index "third.idx"   ' choose o/s balances
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [Branch] <> "C"
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messbox(" No outstanding debtors at all!! ",0,0,1)
    return (1)
  end if
  progress(15,10," Please wait ... sorting balances ",0)
  order sort now dictionary ipath|"aged_drs.idx" fields "[Branch;Job_Nr]" ascending
END FUNCTION ' SelectDrs()

