Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ASU0PURG

ASU0PURG.m

Go to the documentation of this file.
  1. ASU0PURG ; IHS/ITSC/LMH -DELETE TRANS - RANGE OF DATES ;
  1. ;;4.2T2;Supply Accounting Mgmt. System;;JUN 30, 2000
  1. ;This routine is invoked by the yearly closeout update (at entry point
  1. ;EN2) to purge all history transaction record older than 3 years.
  1. ;Although it may also be invoked from the top, no Kernel option is
  1. ;provided to do this since it could easly be mis-used - for example all
  1. ;transactions except for the current year could be accidently
  1. ;deleted if a range of 'First allowed date' to 'Last allowed date' were
  1. ;selected.
  1. D DATE^ASUUDATE,TIME^ASUUDATE
  1. S:'$D(DTIME) DTIME=$$DTIME^XUP(DUZ)
  1. D CLS^ASUUHDG
  1. W !!,"Warning -if you continue, You will be asked for a range of 'PROCESS DATES' and",!,"Transactions of all types which were PROCESSED BETWEEN THOSE DATES will be DELETED!!"
  1. K DIR
  1. S DIR("A")="Are you SURE you wish to CONTINUE",DIR(0)=Y,DIR("B")="N"
  1. D ^DIR K DIR
  1. I 'Y Q
  1. W !!,"Beginning date may not be before three years ago",!
  1. S %DT="APE",%DT("A")="Enter Beginning Date : ",%DT(0)=ASUK("DT","FM")-30000 D ^%DT
  1. Q:Y<0 S ASUU("BEGIN")=$P(Y,".") D DD^%DT S ASUU("1ST")=Y K Y
  1. W !!,"Ending date may not be after one year ago",!
  1. S %DT("A")="Enter Ending Date : ",%DT(0)=(ASUK("DT","FM")-10000)*-1 D ^%DT
  1. Q:Y<0 S ASUU("END")=$P(Y,".") D DD^%DT S ASUU("LAST")=Y K Y,%DT
  1. DOIT ;
  1. S ASUU("AC")="AC",(ASUC("DEL"),ASUC("KEPT"))=0
  1. S DIK="^ASUH("
  1. S ASUU("NXDT")=DIK_"ASUU(""AC""),ASUU(""DT"")"
  1. S ASUU("NXTRN")=ASUU("NXDT")_",DA)"
  1. S ASUU("NXDT")=ASUU("NXDT")_")"
  1. X "S ASUU(""E#"")=$P("_DIK_"0),U)"
  1. S ASUU("DT")=0,(ASUA("DELT",ASUU("E#")),ASUA("KEPT",ASUU("E#")))=0
  1. S ASURX="W !,""Now Processing History Transaction File""" D ^ASUUPLOG
  1. F ASUC("TR")=1:1 S ASUU("DT")=$O(@ASUU("NXDT")) Q:ASUU("DT")'?1N.N D
  1. .I ASUU("DT")=""!(ASUU("DT")<ASUU("BEGIN"))!(ASUU("DT")>ASUU("END")) D
  1. ..I '$D(ASUA("PROC",ASUU("DT"))) S ASUA("PROC",ASUU("DT"))="",ASUC("KEPT")=ASUC("KEPT")+1
  1. ..S ASUA("KEPT",ASUU("E#"))=ASUA("KEPT",ASUU("E#"))+1
  1. .E D
  1. ..S DA=0
  1. ..F ASUC("TR")=1:1 S DA=$O(@ASUU("NXTRN")) Q:DA="" D ^DIK
  1. ..S ASUA("DELT",ASUU("E#"))=ASUA("DELT",ASUU("E#"))+ASUC("TR")
  1. S ASUC("DEL")=ASUC("DEL")+ASUA("DELT",ASUU("E#"))
  1. S ASUU(2)=1 K ^XTMP("ASUR","R02")
  1. S ^XTMP("ASUR","R02",0)=ASUK("DT","FM")+10000_U_ASUK("DT","FM")
  1. S ASURX="W !,""Statistics for Transaction Purge for the Date Range"",!,""Beginning "_ASUU("1ST")_" Ending "_ASUU("LAST")_""",!!" D LOG
  1. S ASUU(1)=""
  1. F ASUC("TR")=1:1 S ASUU(1)=$O(ASUA("DELT",ASUU(1))) Q:ASUU(1)="" D
  1. .S ASURX="W !,"""_ASUU(1)_" Records deleted "",?55,"_ASUA("DELT",ASUU(1)) D LOG
  1. S ASURX="W !,""Total records Deleted "",?55,"_ASUC("DEL")_",!" D LOG
  1. S ASUU(1)=""
  1. F ASUC("TR")=1:1 S ASUU(1)=$O(ASUA("KEPT",ASUU(1))) Q:ASUU(1)="" D
  1. .S ASURX="W !,"""_ASUU(1)_" Days Processed Kept "",?55,"_ASUA("KEPT",ASUU(1)) D LOG
  1. S ASURX="W !,""Total Processed Days Kept"",?55,"_ASUC("KEPT") D LOG
  1. K ASUU,ASUC("TR"),ASUC,ASULA
  1. I $G(ASUP("TYP"))="" D
  1. .S DIR(0)="E" D ^DIR
  1. Q
  1. EN2 ;EP; FROM YEARLY UPDATE
  1. I '$D(ASUK("DT","FM")) D DATE^ASUUDATE,TIME^ASUUDATE
  1. S ASUU("BEGIN")=1,ASUU("1ST")="FIRST DATE",ASUU("END")=$E(ASUK("DT","FM"),1,3)-3_1001,Y=ASUU("END") D DD^%DT S ASUU("LAST")=Y
  1. G DOIT
  1. LOG ;
  1. S ^XTMP("ASUR","R02",ASUU(2))=ASURX,ASUU(2)=ASUU(2)+1
  1. I $G(ASUP("TYP"))="" X ASURX
  1. Q