* CMSD.PM.LETTERS.CONV * PURPOSE : TO CONVERT PM.LETTERS FILE INTO NEW FORMAT * DATE : 04.30.96 * AUTHOR : KJC *************** $INCLUDE BP.MASTER PM $INCLUDE BP.MASTER EV $INCLUDE BP.MASTER PM.LETTERS $INCLUDE BP.MASTER GEN.COMMON * OPEN "EVENT.FILE" TO EVENT.FILE ELSE ABORT OPEN "PM.LETTERS" TO PM.LETTERS ELSE ABORT OPEN "PM" TO PM ELSE ABORT * CRT CS CRT @(0,0):RV:"CMSD.PM.LETTERS.CONV":ERV * EOF=0 ; CNT=0 ; WRT=0 EWRT=0 ; LWRT=0 * SELECT PM.LETTERS LOOP READNEXT ID ELSE EOF=1 UNTIL EOF DO READ LREC FROM PM.LETTERS,ID THEN CNT=CNT+1 IF LREC<2>="" AND LREC<3>="" AND LREC<4>="" ELSE OLD.LREC=LREC EVENTS.HOLD="" LCNT=DCOUNT(LREC,VM) FOR L=1 TO LCNT WRITESW=0 DATE=LREC<1,L> READ CHKREC FROM EVENT.FILE,DATE THEN LOCATE(DATE,EVENTS.HOLD,1;POS) ELSE CHKDATE=CHKREC IF NUM(CHKDATE) ELSE CHKDATE=ICONV(CHKDATE,"D") *== insert events and dates by descending date PULLDATE=CHKREC IF PULLDATE="" THEN PULLDATE=CHKREC IF PULLDATE="" THEN PULLDATE=CHKREC LOCATE(CHKDATE,EVENTS.HOLD,2;DPOS;"DR") ELSE NULL EVENTS.HOLD=INSERT(EVENTS.HOLD,1,DPOS;DATE) EVENTS.HOLD=INSERT(EVENTS.HOLD,2,DPOS;CHKDATE) EVENTS.HOLD=INSERT(EVENTS.HOLD,3,DPOS;PULLDATE) END END ELSE EVENT=LREC<4,L> LETTERS=LREC<2,L> READ EVENTREC FROM EVENT.FILE,EVENT THEN OLD.EVENT.REC=EVENTREC PULLDATE=EVENTREC IF PULLDATE="" THEN PULLDATE=EVENTREC IF PULLDATE="" THEN PULLDATE=EVENTREC IF PULLDATE="" THEN PULLDATE=DATE IF EVENTREC="" THEN EVENTREC=DATE WRITESW=1 END IF EVENTREC="" THEN EVENTREC=DATE WRITESW=1 END EVENTREC="Y" *== now insert letters into Event record SVCNT=DCOUNT(LETTERS<1>,SVM) FOR S=1 TO SVCNT LETTER=LETTERS<1,S> LOCATE(LETTER,EVENTREC,EV$MAIL.LTR;FND) ELSE EVENTREC=INSERT(EVENTREC,EV$MAIL.LTR,1;LETTER) WRITESW=1 END NEXT S END ELSE EVENTREC="" EVENTREC=DATE EVENTREC="I" EVENTREC=DATE EVENTREC=LETTERS EVENTREC="Y" WRITESW=1 END *== LOCATE(EVENT,EVENTS.HOLD,1;FND) ELSE LOCATE(DATE,EVENTS.HOLD,2;DFND;"DR") ELSE NULL EVENTS.HOLD=INSERT(EVENTS.HOLD,1,DFND;EVENT) EVENTS.HOLD=INSERT(EVENTS.HOLD,2,DFND;DATE) EVENTS.HOLD=INSERT(EVENTS.HOLD,3,DFND;PULLDATE) END *= update EVENT file IF WRITESW THEN *CRT *CRT "OLD EVENT REC MAIL DATE :":OLD.EVENT.REC *CRT "OLD EVENT REC LETTERS :":OLD.EVENT.REC *CRT "OLD EVENT REC UPD FLAG :":OLD.EVENT.REC *CRT *CRT "NEW EVENT REC MAIL DATE :":EVENTREC *CRT "NEW EVENT REC LETTERS :":EVENTREC *CRT "NEW EVENT REC UPD FLAG :":EVENTREC *CRT "********" *INPUT ANY *IF ANY="/" THEN STOP WRITE EVENTREC ON EVENT.FILE,EVENT EWRT=EWRT+1 END END NEXT L *== update PM.LETTERS file READ PM.REC FROM PM,ID ELSE NULL TTCNT=DCOUNT(EVENTS.HOLD<1>,VM) FOR TT=1 TO TTCNT PDATE=EVENTS.HOLD<3,TT> LOCATE(PDATE,PM.REC,PM$SEGMENT;PFND;"DR") ELSE NULL PMSEG=PM.REC IF PMSEG="" THEN SGCNT=DCOUNT(PM.REC,VM) PMSEG=PM.REC IF PMSEG="" THEN PMSEG=PM.REC END EVENTS.HOLD<4,TT>=PMSEG NEXT TT LREC="" LREC<1>=EVENTS.HOLD<1> LREC<2>=EVENTS.HOLD<4> *CRT *CRT "OLD LETTER REC :":OLD.LREC *CRT *CRT "NEW LETTER REC :":LREC *INPUT ANY *IF ANY="/" THEN STOP WRITE LREC ON PM.LETTERS,ID LWRT=LWRT+1 END END IF REM(CNT,100) ELSE GOSUB 1000 REPEAT GOSUB 1000 CRT "PROCESS COMPLETE" STOP ****** 1000 * CRT @(5,5):"TOTAL RECORDS READ :":CNT CRT @(5,6):"TOTAL RECORDS WRITTEN TO EVENT.FILE :":EWRT CRT @(5,7):"TOTAL RECORDS WRITTEN TO LETTERS FILE :":LWRT RETURN