USE d:\a\rs ALIAS racstav IN 0
USE d:\zoovet\baze\kalkstav ALIAS kalkstav IN 0

SELECT racstav
GOTO top
DO WHILE !EOF()
IF racstav.klrabat<>0
	a1=racstav.sifrob
	a2=racstav.datum
	mpro=0
	SELECT kalkstav
	SET ORDER TO tag sifrob
	GOTO top
	SEEK a1
	DO WHILE !EOF()
	IF  kalkstav.sifrob<>a1
		EXIT
	ENDIF
	IF kalkstav.datum<=a2 .and. kalkstav.pcena>0
		mpro=kalkstav.pcena
	ENDIF
	SKIP
	enddo		
	SELECT racstav
	replace racstav.dobcena WITH mpro
SELECT racstav
endif		
SELECT racstav
SKIP
ENDDO
