tldm-universe/CMS/BP.CNV/CMSD.PM.LETTERS.CONV
2024-09-10 15:25:06 -04:00

146 lines
4.5 KiB
Plaintext
Executable File

* 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<LT$EVENT>,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<EV$EVENT.DATE>
IF NUM(CHKDATE) ELSE CHKDATE=ICONV(CHKDATE,"D")
*== insert events and dates by descending date
PULLDATE=CHKREC<EV$PULL.DATE>
IF PULLDATE="" THEN PULLDATE=CHKREC<EV$MAIL.DATE>
IF PULLDATE="" THEN PULLDATE=CHKREC<EV$EVENT.DATE>
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<EV$PULL.DATE>
IF PULLDATE="" THEN PULLDATE=EVENTREC<EV$MAIL.DATE>
IF PULLDATE="" THEN PULLDATE=EVENTREC<EV$EVENT.DATE>
IF PULLDATE="" THEN PULLDATE=DATE
IF EVENTREC<EV$MAIL.DATE>="" THEN
EVENTREC<EV$MAIL.DATE>=DATE
WRITESW=1
END
IF EVENTREC<EV$EVENT.DATE>="" THEN
EVENTREC<EV$EVENT.DATE>=DATE
WRITESW=1
END
EVENTREC<EV$MAIL.UPD>="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<EV$EVENT.DATE>=DATE
EVENTREC<EV$EVENT.STATUS>="I"
EVENTREC<EV$MAIL.DATE>=DATE
EVENTREC<EV$MAIL.LTR>=LETTERS
EVENTREC<EV$MAIL.UPD>="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<EV$MAIL.DATE>
*CRT "OLD EVENT REC LETTERS :":OLD.EVENT.REC<EV$MAIL.LTR>
*CRT "OLD EVENT REC UPD FLAG :":OLD.EVENT.REC<EV$MAIL.UPD>
*CRT
*CRT "NEW EVENT REC MAIL DATE :":EVENTREC<EV$MAIL.DATE>
*CRT "NEW EVENT REC LETTERS :":EVENTREC<EV$MAIL.LTR>
*CRT "NEW EVENT REC UPD FLAG :":EVENTREC<EV$MAIL.UPD>
*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<PM$SEGMENT,PFND>
IF PMSEG="" THEN
SGCNT=DCOUNT(PM.REC<PM$SEG.DATE>,VM)
PMSEG=PM.REC<PM$SEGMENT,SGCNT>
IF PMSEG="" THEN PMSEG=PM.REC<PM$SEGMENT,1>
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