'PISUPINV - creates permanent indices for unprocessed Suppliers' invoices

external   dpath vloadif() prpath sch scw progress() fgp bgp remove()
external   progtag() bgi fgi makeidx() sipath

public     ptstr suppcode

global     x Suppliers() i suppname


MAIN
single-step off
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  progress(fgp,bgp," Deleting old Suppliers' indices on"&sipath|"˙",0)
  file unload all
  remove(sipath|"*.*")
  vloadif(dpath|"supplier.vws")
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  for i = 1 to precords
    suppcode = [Supplier_Code]
    suppname = [Name]
    if not (deleted)
      Suppliers()
    end if
    vloadif(dpath|"supplier.vws")
    data goto record next
  end for
  file unload all
END MAIN


FUNCTION Suppliers()
  progress(fgp,bgp," ˙˙˙˙Building new index files for Supplier's invoices ˙˙˙˙",1)
  progtag(fgi,bgi," Re-indexing"&suppname&"("|suppcode|") ")

'   if suppcode = "GEO001"
' repaint on
' repaint
' single-step on
'   end if

  vloadif(dpath|"suppinv1.vw")
  order change key "[Supplier_Code]"
  data query execute "supp_inv.dfq" index "suppinv1.idx"
' ŚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄæ
'   [Supplier_Code] = suppcode and len([Invoice_Nr])=0 and not(deleted)
' ĄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ
'   if cerror
'       messbox(" No Goods Received to check for"&suppname,0,0,1)
'     screen clear box 1 1 sch scw 0 0 no-border
'     return (1)
'   end if
'   order sort now dictionary sipath|"si"|suppcode fields "[Order_Nr]" ascending

  if cerror
    x=makeidx("gds_rcvd",sipath|"si"|suppcode|".idx","0",5)
  else
    order sort now dictionary sipath|"si"|suppcode|".idx" fields "[Order_Nr]" ascending
'     order sort now dictionary prpath|"PR"|suppcode|".idx" fields "[Product_MRC]" ascending
  end if
END FUNCTION ' Suppliers()

