clea
close data
set safe off
set cent on
set date germ

sele 1
use IND_NEW
zap

sele 2
use SL_MAG
go top
do while !eof()

 @ 24,0 say "MAG"+SL_MAG->NR_MAG

 mm="MAG"+SL_MAG->NR_MAG
 pp="DOK"+SL_MAG->NR_MAG+"P"

 sele IND_NEW
 appe from &mm for STAN<>0
 appe from &pp for DATA_DOK>=ctod("31.12.2016")

 sele SL_MAG
 skip
endd


sele IND_NEW
@ 24,0 say "TOW     " 
appe from TOW for INDEKS="9"
@ 24,0 say "SPR_P   " 
appe from SPR_P 
@ 24,0 say "        " 
index on INDEKS to kk uniq
copy to IND_TMP
zap
appe from IND_TMP
dele file IND_TMP
@ 24,0 say "KONIEC"
close data

