FUNCTION ProcessChoice(typeidx)
  while true
    vloadif(dpath|"cus_ent4.vw")
    error off
    #refnr = filemax([#refnr])         'message "#refnr) is:"&str(#refnr)
    if cerror
      #refnr = 0
    end if
    refcode = jobnr|"-"|str(right("00"|str(#refnr+1),2))'
    clearvar()             ' message "prodsel|$prodend is:"&str("prodsel"|$prodend)
    vloadif(dpath|"prodsel"|$prodend|".vw")
    order change index ipath|typeidx
    if prodcode = ""
      y2 = format(" Scroll to find & press {Enter} - {Esc} to leave ","M72")
      screen print 21 5 fgp bbd y2
      if $prodend = "A"
        x = bpopdb("prodsel"|$prodend,4,"","[Prod_Back]","L35","[abbrv]","L4","[Product_Code]",7,43,20,80,"",0)
      else
        x = bpopdb("prodsel"|$prodend,4,"i","[Prod_Back]","L42","[abbrv]","L4","[Product_Code]",7,36,20,80,"",0)
      end if

    else
      data goto record record-number #prodrec
      y2 = format(" Scroll to find - F3 to search ","M72")
      screen print 21 5 fgp bbd y2
      if $prodend = "A"
        x = bpopdb("prodsel"|$prodend,4,"","[Prod_Back]","L35","[abbrv]","L4","[Product_Code]",7,43,20,80,"",0)
      else
        x = bpopdb("prodsel"|$prodend,4,"i","[Prod_Back]","L42","[abbrv]","L4","[Product_Code]",7,36,20,80,"",0)
      end if
    end if
    if x = -1
      repaint off
      vloadif(dpath|"cus_ent4.vw")
      order change index "current.idx"
      y2 = format("Select requisition type or {F10} to exit","M72")
      screen print 21 5 fgp bbd y2
      vloadif(dpath|"prodsel"|$prodend|".vw")
      exit while
    end if
    #prodrec = record
    prodcode = ptstr               'message "prodcode -L720- is:"&str(prodcode)
    $backing = [Backing]
    $uos     = [Unit_Of_Sale]      ' message "$uos is:"&str($uos)
    if $prodend ="B"
      if [Note]="Y"
        CheckSupplier()
      end if
    end if
    screen shortrestore dsa
    x = Entries()
    if x = -1
      screen clear box 5 5 22 77 0 0 no-border
      screen shortrestore s_shwreq
      repaint off
      continue while
    elseif x = 0                   ' new entry made
      vloadif(dpath|"cus_ent4.vw")
      order change index "current.idx"
      data goto record last
      Title_A()                    ' message "prodsel|$prodend is:"&str("prodsel"|$prodend)
      vloadif(dpath|"prodsel"|$prodend|".vw")
      continue while
    end if
  end while
END FUNCTION ' ProcessChoice()
