CLOSE DATABASE
SELE 0
USE &calefirma\datean\calendar ALIAS calendar
SELE calendar
SCAN
	SCATTER MEMVAR
	DATE=calefirma+'\AN'+m.an+'\DATE'+M.nl
	DO pmf1
ENDSCAN
***

DO totv




*____________________________________________
PROCEDURE pmf1
IF !FILE('&date\mf.DBF')
	RETURN
ENDIF
DELE FILE &DATE\mfa.*
DELE FILE &DATE\mfv.*
COPY FILE &dirgen\mfix2000\DATE\mf.* TO &DATE\mfa.*
SELE 0
USE &DATE\mfa.DBF AGAIN ALIAS mfa EXCLUSIVE
SELE mfa
ZAP
SELE mfa
APPEND FROM &DATE\mf
SELE mfa
REINDEX
USE
RENAME &DATE\mf.* TO &DATE\mfv.*
RENAME &DATE\mfa.* TO &DATE\mf.*
RETURN







*__________________________________
PROC pmf2
SELE 0
USE &DATE\mf.DBF EXCL ALIAS mf
IF !existacimp('mf','amorttot')
	ALTER TABLE mf ADD COLUMN amorttot N(14)
ENDIF
IF !existacimp('mf','amortlun')
	ALTER TABLE mf ADD COLUMN amortlun N(14)
ENDIF
IF !existacimp('mf','amortprec')
	ALTER TABLE mf ADD COLUMN amortprec N(14)
ENDIF
IF !existacimp('mf','uzuraprec')
	ALTER TABLE mf ADD COLUMN uzuraprec N(5)
ENDIF
USE

RETURN




*_____________________________
FUNCTION existacimp
PARAM numet,numec
FOR i=1 TO FCOUNT()
	IF UPPER(ALLT(FIELD(i)))=UPPER(ALLT(numec))
		RETURN .T.
	ENDIF
NEXT
RETURN .F.










