CLEAR 

use (m.fn_food_dat) ALIAS food_dat NOUPDATE 
INDEX on c_stredisk TO qwe FOR pgm = "MAN"

SELECT c_stredisk, c_dokl, pz1, pz2, provedl, "  " as id_man ;
       WHERE operace = "VK" from (m.fn_doklady) INTO TABLE (m.gcpri_path + "dokl")
SET RELATION TO c_stredisk INTO food_dat
REPLACE ALL id_man WITH food_dat.id

SELECT 0
use (m.fn_sk_sez) ALIAS sk_sez
SCAN FOR EMPTY(odecteno)
   SCATTER MEMVAR 
   ? m.uzaverka, m.id_kas, m.id_man
   SELECT dokl
   LOCATE FOR (pz2 = m.uzaverka + "/" + m.id_kas) .and. (id_man = m.id_man)
   IF FOUND()
      SELECT sk_sez
      REPLACE odecteno WITH dokl.provedl + " " + ALLTRIM(STR(dokl.c_dokl))
   ELSE 
      SELECT sk_sez
   ENDIF 
ENDSCAN 

