ASUUINTG ; IHS/ITSC/LMH - MASTER TO HISTORY INTEGRITY ;
;;4.2T2;Supply Accounting Mgmt. System;;JUN 30, 2000
VALQTY ;
N S,X,H,C,V,Q,F,F1,E
S S=40002,X=0,F1=0
F S X=$O(^ASUMS(S,1,X)) Q:X'?1N.N D
.S V=$P(^ASUMS(S,1,X,0),U,16),Q=$P(^ASUMS(S,1,X,0),U,17),F=0
.S H=999999999 F C=0:1 S H=$O(^ASUH("I",X,H),-1) Q:H']"" D Q:F=1
..S HQ=$P(^ASUH(H,1),U,6),HV=$P(^ASUH(H,1),U,7),HS=$P(^ASUH(H,0),U,24),HMQ=$P(^ASUH(H,0),U,21),HMV=$P(^ASUH(H,0),U,22)
..I HMQ=Q,HMV=V D
...S Q=(Q-(HQ*HS)),V=(V-(HV*HS))
..E D Q
...I F1=0 D
....S F1=1
....W !,"INDEX",?8,"QTY",?14," VALUE ",?23,"HIST"
....W ?29,"HQTY",?35,"MQTY",?41,"QTYD"
....W ?47," VALUE ",?57,"MSTRVAL",?67," VAL DIFF ",?77,"TRANS BACK"
...W !,$E(X,3,7),".",$E(X,8)
...W ?8,$J($FN(Q,","),5)
...W ?14,$J($FN(V,",",2),8)
...W ?23,$J(H,5),?29,$J($FN(Q,","),5)
...W ?35,$J($FN(HMQ,","),5)
...W ?41,$J($FN((Q-HMQ),","),5)
...W ?47,$J($FN(V,",",2),8)
...W ?57,$J($FN(HMV,",",2),8)
...W ?67,$J($FN((V-HMV),",",2),8)
...S F=1,E=$G(E)+1
.W:$G(F)>0 ?76,$J($FN(C,","),4)
W !!,"TOTAL ERRORS:",$J($FN($G(E),","),8)
Q
KEYS ;
N H,K,B,D,A,S
S H=0 F C=0:1 S H=$O(^ASUH(H)) Q:H'?1N.N D
.S K=$P(^ASUH(H,0),U),D=$P(K,"-",2),S=$P(K,"-",3)
.I D'=$G(B) W:D'>$G(B) !,"DATE SEQ ERR:PREV:",B," NEXT:",D S B=D,A=1
.I A'=+S W !,"SEQ ERR:#",H," DATE:",D," SEQ:",$J(+S,6)," CNT:",$J(A,6) I S>A W " DROPED:",A W:S>(A+1) "-",(S-1) S A=S
.S A=$G(A)+1
Q
ASUUINTG ; IHS/ITSC/LMH - MASTER TO HISTORY INTEGRITY ;
+1 ;;4.2T2;Supply Accounting Mgmt. System;;JUN 30, 2000
VALQTY ;
+1 NEW S,X,H,C,V,Q,F,F1,E
+2 SET S=40002
SET X=0
SET F1=0
+3 FOR
SET X=$ORDER(^ASUMS(S,1,X))
IF X'?1N.N
QUIT
Begin DoDot:1
+4 SET V=$PIECE(^ASUMS(S,1,X,0),U,16)
SET Q=$PIECE(^ASUMS(S,1,X,0),U,17)
SET F=0
+5 SET H=999999999
FOR C=0:1
SET H=$ORDER(^ASUH("I",X,H),-1)
IF H']""
QUIT
Begin DoDot:2
+6 SET HQ=$PIECE(^ASUH(H,1),U,6)
SET HV=$PIECE(^ASUH(H,1),U,7)
SET HS=$PIECE(^ASUH(H,0),U,24)
SET HMQ=$PIECE(^ASUH(H,0),U,21)
SET HMV=$PIECE(^ASUH(H,0),U,22)
+7 IF HMQ=Q
IF HMV=V
Begin DoDot:3
+8 SET Q=(Q-(HQ*HS))
SET V=(V-(HV*HS))
End DoDot:3
+9 IF '$TEST
Begin DoDot:3
+10 IF F1=0
Begin DoDot:4
+11 SET F1=1
+12 WRITE !,"INDEX",?8,"QTY",?14," VALUE ",?23,"HIST"
+13 WRITE ?29,"HQTY",?35,"MQTY",?41,"QTYD"
+14 WRITE ?47," VALUE ",?57,"MSTRVAL",?67," VAL DIFF ",?77,"TRANS BACK"
End DoDot:4
+15 WRITE !,$EXTRACT(X,3,7),".",$EXTRACT(X,8)
+16 WRITE ?8,$JUSTIFY($FNUMBER(Q,","),5)
+17 WRITE ?14,$JUSTIFY($FNUMBER(V,",",2),8)
+18 WRITE ?23,$JUSTIFY(H,5),?29,$JUSTIFY($FNUMBER(Q,","),5)
+19 WRITE ?35,$JUSTIFY($FNUMBER(HMQ,","),5)
+20 WRITE ?41,$JUSTIFY($FNUMBER((Q-HMQ),","),5)
+21 WRITE ?47,$JUSTIFY($FNUMBER(V,",",2),8)
+22 WRITE ?57,$JUSTIFY($FNUMBER(HMV,",",2),8)
+23 WRITE ?67,$JUSTIFY($FNUMBER((V-HMV),",",2),8)
+24 SET F=1
SET E=$GET(E)+1
End DoDot:3
QUIT
End DoDot:2
IF F=1
QUIT
+25 IF $GET(F)>0
WRITE ?76,$JUSTIFY($FNUMBER(C,","),4)
End DoDot:1
+26 WRITE !!,"TOTAL ERRORS:",$JUSTIFY($FNUMBER($GET(E),","),8)
+27 QUIT
KEYS ;
+1 NEW H,K,B,D,A,S
+2 SET H=0
FOR C=0:1
SET H=$ORDER(^ASUH(H))
IF H'?1N.N
QUIT
Begin DoDot:1
+3 SET K=$PIECE(^ASUH(H,0),U)
SET D=$PIECE(K,"-",2)
SET S=$PIECE(K,"-",3)
+4 IF D'=$GET(B)
IF D'>$GET(B)
WRITE !,"DATE SEQ ERR:PREV:",B," NEXT:",D
SET B=D
SET A=1
+5 IF A'=+S
WRITE !,"SEQ ERR:#",H," DATE:",D," SEQ:",$JUSTIFY(+S,6)," CNT:",$JUSTIFY(A,6)
IF S>A
WRITE " DROPED:",A
IF S>(A+1)
WRITE "-",(S-1)
SET A=S
+6 SET A=$GET(A)+1
End DoDot:1
+7 QUIT