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

ASUUDATE.m

Go to the documentation of this file.
  1. ASUUDATE ; IHS/ITSC/LMH -DATE UTILITY FUNCTIONS ;
  1. ;;4.2T2;Supply Accounting Mgmt. System;;JUN 30, 2000
  1. ;This routine is a utility which stores various versions of the Date
  1. ;and time data into local 'Constant' variables ASUK("DT") which are
  1. ;used by SAMS routines rather than the DT variable. In this way, a
  1. ;date may be set before an update is run to be used as the 'As Of' date
  1. ;for the update. Normally, however the current computer date contained
  1. ;in variable DT is used to set up the ASUK("DT") array.
  1. DAYTIM ;EP; -SET DATE AND TIME
  1. D DATE
  1. D TIME
  1. I $D(ASUT) S ASUT(ASUT,"TRKY")=ASUK("DT","FM")_"."_ASUK("TIME","F")_"."_DUZ
  1. Q
  1. DATE ;EP; -SET ASUK("DT")
  1. N X
  1. I ($D(ASUK("DT"))#10)=0 D
  1. .D NOW^%DTC S Y=% X ^DD("DD")
  1. .D SETDT(X)
  1. Q
  1. SETDT(X) ;EP ;
  1. S ASUK("DT","FM")=X,ASUK("DT")=$P(Y,"@"),ASUK("DT","TIME")=Y
  1. S ASUK("DT","MOFM")=$E(ASUK("DT","FM"),1,5)_"00"
  1. S ASUK("DT","ENXYR")=$E(X,1,3)+1_"1231"
  1. S ASUK("DT","YEAR")=$P(ASUK("DT"),",",2),ASUK("DT","YMD")=$E(X,2,7)
  1. S ASUK("DT","YR")=$E(X,2,3),ASUK("DT","MO")=$E(X,4,5),ASUK("DT","DA")=$E(X,6,7)
  1. S ASUK("DT","CFYEDT")=$E(X,1,3)
  1. S ASUK("DT","MONTH")=$P(ASUK("DT")," ")
  1. S ASUK("DT","YRMO")=$E(X,2,5)
  1. S ASUK("DT","FYMO")=ASUK("DT","YRMO")
  1. S ASUK("DT","FYM#")=$E(ASUK("DT","FYMO"),3,4)+3 S:ASUK("DT","FYM#")>12 ASUK("DT","FYM#")=ASUK("DT","FYM#")-12
  1. S ASUK("DT","CFY")=ASUK("DT","YR")
  1. I +ASUK("DT","MO")>9 D
  1. .S ASUK("DT","CFYEDT")=ASUK("DT","CFYEDT")+1
  1. .S ASUK("DT","CFY")=$E(ASUK("DT","CFYEDT"),2,3)
  1. .S ASUK("DT","FYMO")=ASUK("DT","CFY")_ASUK("DT","MO")
  1. S ASUK("DT","PFYBDT")=ASUK("DT","CFYEDT")-1
  1. S ASUK("DT","PFY")=$E(ASUK("DT","PFYBDT"),2,3)
  1. S ASUK("DT","CFYEDT")=ASUK("DT","CFYEDT")_"1231"
  1. S ASUK("DT","PFYBDT")=ASUK("DT","PFYBDT")_"0131"
  1. S X1=ASUK("DT","FM"),X2=$E(ASUK("DT","FM"),1,3)_"0101" D ^%DTC
  1. S ASUK("DT","JUL")=X+1
  1. Q:'$D(%H)
  1. S ASUK("DT","H")=$P(%H,","),ASUK("TIME","H")=$P(%H,",",2)
  1. S ASUK("TIME")=$P(Y,"@",2)
  1. Q
  1. ASKDATE ;EP -ASK FOR A DATE AND SET ASUK("DT") ARRAY
  1. N %DT S %DT="AS" D ^%DT S X=Y
  1. X ^DD("DD")
  1. D SETDT(X),TIME
  1. Q
  1. TIME ;EP; -SET ASUK("TIME")
  1. N X
  1. S %H=$H D YX^%DTC
  1. S ASUK("TIME")=$P(Y,"@",2),ASUK("TIME","H")=$P(%H,",",2)
  1. S ASUK("TIME","F")=$P(ASUK("TIME"),":")_$P(ASUK("TIME"),":",2)_$P(ASUK("TIME"),":",3)
  1. I ($D(ASUK("DT"))#10) D
  1. .S ASUK("DT","TIME")=ASUK("DT")_"@"_ASUK("TIME")
  1. E D
  1. .S ASUK("DT","TIME")=Y
  1. Q
  1. GETRUN ;EP ; -GET RUN FISCAL YEAR AND MONTH
  1. I ($D(ASUK("DT"))#10)'=1 D DATE
  1. S DIR(0)="D" D ^DIR K DIR
  1. Q:$D(DTOUT) Q:$D(DUOUT)
  1. S ASUK("DT","RUN")=ASUK("DT","FM")
  1. S ASUK("DT","RUNMY")=$E(Y,4,5)_$E(Y,2,3)
  1. S ASUK("DT","RUNMO")=ASUK("DT","MO")
  1. S ASUK("DT","RUNYR")=ASUK("DT","CFY")
  1. I $E(ASUK("DT","RUNMO"))=0&($E(ASUK("DT","RUNMO"),2,2))>0 D
  1. .S ASUK("DT","RUNMO")=$E(ASUK("DT","RUNMO"),2,2)
  1. Q
  1. SETMO(X) ;EP ; -SET MONTHLY RUN PARAMETERS
  1. S ASUP("MO")=X
  1. S ASUP("YR")=$S(X="09"&(ASUK("DT","MO")'="09"):ASUK("DT","PFY"),1:ASUK("DT","CFY"))
  1. S ASUP("MOYR")=ASUP("MO")_ASUP("YR")
  1. S ASUP("ERR")=0
  1. I ASUK("DT","MO")="01",ASUP("MO")="12",ASUK("DT","DA")'>ASUP("MOL") Q
  1. I ASUK("DT","MO")=ASUP("MO") Q
  1. I +ASUP("MO")=$S(ASUK("DT","MO")="01":12,1:ASUK("DT","MO")-1),ASUK("DT","DA")<ASUP("MOL") Q
  1. I ASUP("MO")>ASUK("DT","MO") S ASUP("ERR")=3 Q
  1. S ASUP("ERR")=2 Q
  1. Q
  1. SETRUN ;EP ; -SET RUN DATE EQUAL DATE
  1. I ($D(ASUK("DT"))#10)'=1 D DATE
  1. S ASUK("DT","RUN")=ASUK("DT","FM")
  1. ;WAR 5/18/99 REM'd next line & added $E of ASUP("LSMO")
  1. ;I +$E(ASUK("DT","RUN"),4,5)>+ASUP("LSMO"),ASUP("MOL")<ASUP("MOE"),ASUK("DT","DA")<ASUP("MOL") D
  1. I +$E(ASUK("DT","RUN"),4,5)>+$E(ASUP("LSMO"),1,2),ASUP("MOL")<ASUP("MOE"),ASUK("DT","DA")<ASUP("MOL") D
  1. .S X=ASUK("DT","MO")-1 S:X<10 X="0"_X
  1. .S ASUK("DT","RUNMO")=X
  1. .S:ASUK("DT","RUNMO")="00" ASUK("DT","RUNMO")=12
  1. .S ASUK("DT","RUNYR")=ASUK("DT","CFY")
  1. .S:ASUK("DT","RUNMO")="09" ASUK("DT","RUNYR")=ASUK("DT","PFY")
  1. E D
  1. .S ASUK("DT","RUNMO")=ASUK("DT","MO")
  1. .S ASUK("DT","RUNYR")=ASUK("DT","CFY")
  1. S ASUK("DT","RUNMY")=ASUK("DT","RUNMO")_ASUK("DT","RUNYR")
  1. S ASUK("DT","RUNLS")=$P(^ASUSITE(1,0),U,14),ASUK("DT","RUNNM")=$E(ASUK("DT","RUNLS"),1,2)+1
  1. S:ASUK("DT","RUNNM")=13 ASUK("DT","RUNNM")=1
  1. I +ASUK("DT","RUNNM")=+ASUK("DT","RUNMO") D
  1. .W " (MMYY)=",ASUK("DT","RUNMY")
  1. E D
  1. .I ASUP("TYP")=2,ASUK("DT","RUNMO")[9 D
  1. ..W !,"Processing Yearly Closeout"
  1. .E D
  1. ..W !,"The computer date indicates that this run should be part of month ",ASUK("DT","RUNMO"),","
  1. ..W !,"but the Run Control table ASUTBL SITE indicates the most recent Monthly",!,"run was for ",ASUK("DT","RUNLS"),", therefore "
  1. ..I $E(ASUK("DT","RUNLS"),1,2)=ASUK("DT","RUNMO") D
  1. ...W "a monthly run has already sucessfully completed",!,"for month ",ASUK("DT","RUNMO"),"."
  1. ..E D
  1. ...I $E(ASUK("DT","RUNLS"),1,2)<ASUK("DT","RUNMO") D
  1. ....W "a month or more has passed without sucessful",!,"completion of monthly run(s)."
  1. ...E D
  1. ....W "the most recent monthly run was for a month after the",!,"current computer date."
  1. ..W !!,"The computer program is unable to determine correct run Month",*7,*7,!!,"***** Notify your Supervisor to take corrective action *****",*7,*7,!!,*7,*7
  1. ..K DIR S DIR(0)="E" D ^DIR
  1. ..S DUOUT=1
  1. Q
  1. SETQTR ;EP ;INPUT- DT AND ASUP("MO") OUTPUT- ASUP("QTR") IN YRQT FORMAT
  1. I ($D(ASUK("DT"))#10)'=1 D DATE
  1. I '$D(ASUP("MO")) S DIR("A")="Enter Month & Fiscal Year for Quarterly Reports (MMFY)" D ASK^ASUCORUN
  1. Q:$D(DTOUT) Q:$D(DUOUT)
  1. S ASUV("YR")=$S($L(ASUP("YR"))=4:ASUP("YR"),ASUP("YR")<60:20_ASUP("YR"),1:19_ASUP("YR"))
  1. S ASUP("QTR")=ASUV("YR")_$S(ASUP("MO")<4:"02",ASUP("MO")<7:"03",ASUP("MO")>9:"01",1:"04")
  1. K ASUV("YR")
  1. Q