ASU5SUPD ; IHS/ITSC/LMH -POST STATION MASTER CHANGE ;
;;4.2T2;Supply Accounting Mgmt. System;;JUN 30, 2000
;;This routine provides logic to post STATION MASTER records to
;;the database
S:$G(DDSREFT)']"" DDSREFT=$G(ASUV("DDSREFT"))
I $E(ASUT,3)="A" D ADD
I $E(ASUT,3)="B" D USERLEVL
I $E(ASUT,3)="C" D CHANGE
I $E(ASUT,3)="D" D DELETE
Q:$D(DDSERROR)
D ^ASUJHIST
K ASUS("ADD")
Q
ADD ;Add station master record
N X
S ASUMS("E#","STA")=ASUT(ASUT,"PT","STA")
D S^ASUMSTRD ;Read Station portion of Station master into variables
I $G(Y)<0 D
.S X=ASUT(ASUT,"PT","STA")
.D DIS^ASUMDIRA(.X) ;Add new Station if not on file
S (X,ASUMS("E#","IDX"))=ASUT(ASUT,"PT","IDX")
D DISX^ASUMDIRA(.X) ;Add new Index to station
;Read Index portion of Station master - new record (null variables)
D ^ASUMSTRD
;Set Station index record fields from transaction
S ASUMS("ESTB")=ASUT(ASUT,"DTS")
S ASUMS("ORD#")=ASUT(ASUT,"ORD#")
S ASUMS("SRC")=ASUT(ASUT,"SRC")
S ASUMS("LTM")=ASUT(ASUT,"LTM")
S ASUMS("RPQ-O")=ASUT(ASUT,"RPQ")
S ASUV("RPQ")=ASUMS("LTM")+1
S ASUMS("PMIQ")=ASUMS("RPQ-O")/ASUV("RPQ")
S ASUMS("PMIQ")=$J(ASUMS("PMIQ"),0,0)
S ASUMS("RPQ")=ASUT(ASUT,"RPQ")
S ASUMS("EOQ","TB")=$S($G(ASUL(2,"STA","EOQTBL")):ASUL(2,"STA","EOQTBL"),1:50)
S ASUMS("EOQ","MM")=ASUT(ASUT,"EOQ MM")
S ASUMS("EOQ","QM")=ASUT(ASUT,"EOQ QM")
S ASUMS("EOQ","AM")=ASUT(ASUT,"EOQ AM")
S ASUMS("LSTISS")=""
S ASUMS("VENAM")=ASUT(ASUT,"VEN NM")
S ASUMS("LPP")=ASUT(ASUT,"UCS")
S ASUMS("SLC")=ASUT(ASUT,"SLC")
S ASUMS("VENUI")=ASUT(ASUT,"SUI")
S ASUMS("SFSKM")="1.0"
S ASUMS("EOQ","TP")=ASUT(ASUT,"EOQ TYP")
S ASUMS("SPQ")=ASUT(ASUT,"SPQ")
;Initialize Usage statistic counters (12 months)
F ASUU(11)=1:1:12 D
.S (ASUMS("DMD","CALL",ASUU(11)),ASUMS("DMD","QTY",ASUU(11)))=0
K ASUU(11)
S ASUS("ADD")=1
;Write new Station Index record
D ^ASUMSTWR
Q
;Set Beginning Balance statistics for Station Index
USERLEVL ;User Level change transaction
I $E(ASUT,3)="B" D
.I ASUT(ASUT,"ULVQTY")]"" D ^ASUMKBPS
Q
CHANGE ;Change station master transaction
S ASUSV("FL#")="9002036.5"
;Update Station Index master fields from Transaction
I ASUT(ASUT,"EOQ TYP")]"" D
.S ASUMS("EOQ","TP")=ASUT(ASUT,"EOQ TYP")
.S (ASUMS("EOQ","MM"),ASUMS("EOQ","QM"),ASUMS("EOQ","AM"))=""
S:ASUT(ASUT,"SLC")]"" ASUMS("SLC")=ASUT(ASUT,"SLC")
S ASUMS("ESTB")=ASUT(ASUT,"DTS")
S:ASUT(ASUT,"EOQ MM")]"" ASUMS("EOQ","MM")=ASUT(ASUT,"EOQ MM")
S:ASUT(ASUT,"ORD#")]"" ASUMS("ORD#")=ASUT(ASUT,"ORD#")
S:ASUT(ASUT,"SRC")]"" ASUMS("SRC")=ASUT(ASUT,"SRC")
S:ASUT(ASUT,"UCS")>0 ASUMS("LPP")=ASUT(ASUT,"UCS")
S:ASUT(ASUT,"LTM")]"" ASUMS("LTM")=ASUT(ASUT,"LTM")
S:ASUT(ASUT,"SUI")]"" ASUMS("VENUI")=ASUT(ASUT,"SUI")
S:ASUT(ASUT,"SPQ")]"" ASUMS("SPQ")=ASUT(ASUT,"SPQ")
I ASUT(ASUT,"RPQ")]"" D
.S ASUMS("RPQ")=ASUT(ASUT,"RPQ")
.S ASUV("RPM")=ASUMS("LTM")+ASUMS("SFSKM")
.S ASUMS("PMIQ")=ASUT(ASUT,"RPQ")/ASUV("RPM")
.S ASUMS("PMIQ")=$J(ASUMS("PMIQ"),0,0)
S:ASUT(ASUT,"VEN NM")]"" ASUMS("VENAM")=ASUT(ASUT,"VEN NM")
S:ASUT(ASUT,"EOQ QM")]"" ASUMS("EOQ","QM")=ASUT(ASUT,"EOQ QM")
S:ASUT(ASUT,"EOQ AM")]"" ASUMS("EOQ","AM")=ASUT(ASUT,"EOQ AM")
D MIX^ASUMSTWR ;Write updated Station Index master record
Q
DELETE ;Delete station master trans
;S ASUMS("E#","STA")=$O(^ASUMS("C",ASUMS("E#","IDX"),"")) ;CSC 1-14-99
S ASUSV("FL#")="9002036.5"
;S ASUMS(0)=^ASUMS(ASUMS("E#","STA"),1,ASUMS("E#","IDX"),0)
;S ASUMS(2)=^ASUMS(ASUMS("E#","STA"),1,ASUMS("E#","IDX"),2)
;I $P(ASUMS(0),U,16)!($P(ASUMS(0),U,17))!($P(ASUMS(0),U,18))!($P(ASUMS(0),U,28)) D Q ;Balance was on hand -Reject Transaction
;.W *7 D MSG^ASUJHELP("Delete Unsucessful - BAL O/H") S DDSERROR=2 ;DFM P1 9/1/98
;I $P(ASUMS(2),U,2)>0 D Q ;Backorder was on file -Reject Transaction
;.W *7 D MSG^ASUJHELP("Delete Unsucessful -Back/Order O/H") S DDSERROR=1 ;DFM P1 9/1/98
;Q:$D(DDSERROR)
D D^ASUMSTWR ;Station Index record may be cleared of information
Q
;
Q:$D(DDSERROR)
D ^ASUJHIST ;Move transaction to History file
K ASUS("ADD")
Q
ASU5SUPD ; IHS/ITSC/LMH -POST STATION MASTER CHANGE ;
+1 ;;4.2T2;Supply Accounting Mgmt. System;;JUN 30, 2000
+2 ;;This routine provides logic to post STATION MASTER records to
+3 ;;the database
+4 IF $GET(DDSREFT)']""
SET DDSREFT=$GET(ASUV("DDSREFT"))
+5 IF $EXTRACT(ASUT,3)="A"
DO ADD
+6 IF $EXTRACT(ASUT,3)="B"
DO USERLEVL
+7 IF $EXTRACT(ASUT,3)="C"
DO CHANGE
+8 IF $EXTRACT(ASUT,3)="D"
DO DELETE
+9 IF $DATA(DDSERROR)
QUIT
+10 DO ^ASUJHIST
+11 KILL ASUS("ADD")
+12 QUIT
ADD ;Add station master record
+1 NEW X
+2 SET ASUMS("E#","STA")=ASUT(ASUT,"PT","STA")
+3 ;Read Station portion of Station master into variables
DO S^ASUMSTRD
+4 IF $GET(Y)<0
Begin DoDot:1
+5 SET X=ASUT(ASUT,"PT","STA")
+6 ;Add new Station if not on file
DO DIS^ASUMDIRA(.X)
End DoDot:1
+7 SET (X,ASUMS("E#","IDX"))=ASUT(ASUT,"PT","IDX")
+8 ;Add new Index to station
DO DISX^ASUMDIRA(.X)
+9 ;Read Index portion of Station master - new record (null variables)
+10 DO ^ASUMSTRD
+11 ;Set Station index record fields from transaction
+12 SET ASUMS("ESTB")=ASUT(ASUT,"DTS")
+13 SET ASUMS("ORD#")=ASUT(ASUT,"ORD#")
+14 SET ASUMS("SRC")=ASUT(ASUT,"SRC")
+15 SET ASUMS("LTM")=ASUT(ASUT,"LTM")
+16 SET ASUMS("RPQ-O")=ASUT(ASUT,"RPQ")
+17 SET ASUV("RPQ")=ASUMS("LTM")+1
+18 SET ASUMS("PMIQ")=ASUMS("RPQ-O")/ASUV("RPQ")
+19 SET ASUMS("PMIQ")=$JUSTIFY(ASUMS("PMIQ"),0,0)
+20 SET ASUMS("RPQ")=ASUT(ASUT,"RPQ")
+21 SET ASUMS("EOQ","TB")=$SELECT($GET(ASUL(2,"STA","EOQTBL")):ASUL(2,"STA","EOQTBL"),1:50)
+22 SET ASUMS("EOQ","MM")=ASUT(ASUT,"EOQ MM")
+23 SET ASUMS("EOQ","QM")=ASUT(ASUT,"EOQ QM")
+24 SET ASUMS("EOQ","AM")=ASUT(ASUT,"EOQ AM")
+25 SET ASUMS("LSTISS")=""
+26 SET ASUMS("VENAM")=ASUT(ASUT,"VEN NM")
+27 SET ASUMS("LPP")=ASUT(ASUT,"UCS")
+28 SET ASUMS("SLC")=ASUT(ASUT,"SLC")
+29 SET ASUMS("VENUI")=ASUT(ASUT,"SUI")
+30 SET ASUMS("SFSKM")="1.0"
+31 SET ASUMS("EOQ","TP")=ASUT(ASUT,"EOQ TYP")
+32 SET ASUMS("SPQ")=ASUT(ASUT,"SPQ")
+33 ;Initialize Usage statistic counters (12 months)
+34 FOR ASUU(11)=1:1:12
Begin DoDot:1
+35 SET (ASUMS("DMD","CALL",ASUU(11)),ASUMS("DMD","QTY",ASUU(11)))=0
End DoDot:1
+36 KILL ASUU(11)
+37 SET ASUS("ADD")=1
+38 ;Write new Station Index record
+39 DO ^ASUMSTWR
+40 QUIT
+41 ;Set Beginning Balance statistics for Station Index
USERLEVL ;User Level change transaction
+1 IF $EXTRACT(ASUT,3)="B"
Begin DoDot:1
+2 IF ASUT(ASUT,"ULVQTY")]""
DO ^ASUMKBPS
End DoDot:1
+3 QUIT
CHANGE ;Change station master transaction
+1 SET ASUSV("FL#")="9002036.5"
+2 ;Update Station Index master fields from Transaction
+3 IF ASUT(ASUT,"EOQ TYP")]""
Begin DoDot:1
+4 SET ASUMS("EOQ","TP")=ASUT(ASUT,"EOQ TYP")
+5 SET (ASUMS("EOQ","MM"),ASUMS("EOQ","QM"),ASUMS("EOQ","AM"))=""
End DoDot:1
+6 IF ASUT(ASUT,"SLC")]""
SET ASUMS("SLC")=ASUT(ASUT,"SLC")
+7 SET ASUMS("ESTB")=ASUT(ASUT,"DTS")
+8 IF ASUT(ASUT,"EOQ MM")]""
SET ASUMS("EOQ","MM")=ASUT(ASUT,"EOQ MM")
+9 IF ASUT(ASUT,"ORD#")]""
SET ASUMS("ORD#")=ASUT(ASUT,"ORD#")
+10 IF ASUT(ASUT,"SRC")]""
SET ASUMS("SRC")=ASUT(ASUT,"SRC")
+11 IF ASUT(ASUT,"UCS")>0
SET ASUMS("LPP")=ASUT(ASUT,"UCS")
+12 IF ASUT(ASUT,"LTM")]""
SET ASUMS("LTM")=ASUT(ASUT,"LTM")
+13 IF ASUT(ASUT,"SUI")]""
SET ASUMS("VENUI")=ASUT(ASUT,"SUI")
+14 IF ASUT(ASUT,"SPQ")]""
SET ASUMS("SPQ")=ASUT(ASUT,"SPQ")
+15 IF ASUT(ASUT,"RPQ")]""
Begin DoDot:1
+16 SET ASUMS("RPQ")=ASUT(ASUT,"RPQ")
+17 SET ASUV("RPM")=ASUMS("LTM")+ASUMS("SFSKM")
+18 SET ASUMS("PMIQ")=ASUT(ASUT,"RPQ")/ASUV("RPM")
+19 SET ASUMS("PMIQ")=$JUSTIFY(ASUMS("PMIQ"),0,0)
End DoDot:1
+20 IF ASUT(ASUT,"VEN NM")]""
SET ASUMS("VENAM")=ASUT(ASUT,"VEN NM")
+21 IF ASUT(ASUT,"EOQ QM")]""
SET ASUMS("EOQ","QM")=ASUT(ASUT,"EOQ QM")
+22 IF ASUT(ASUT,"EOQ AM")]""
SET ASUMS("EOQ","AM")=ASUT(ASUT,"EOQ AM")
+23 ;Write updated Station Index master record
DO MIX^ASUMSTWR
+24 QUIT
DELETE ;Delete station master trans
+1 ;S ASUMS("E#","STA")=$O(^ASUMS("C",ASUMS("E#","IDX"),"")) ;CSC 1-14-99
+2 SET ASUSV("FL#")="9002036.5"
+3 ;S ASUMS(0)=^ASUMS(ASUMS("E#","STA"),1,ASUMS("E#","IDX"),0)
+4 ;S ASUMS(2)=^ASUMS(ASUMS("E#","STA"),1,ASUMS("E#","IDX"),2)
+5 ;I $P(ASUMS(0),U,16)!($P(ASUMS(0),U,17))!($P(ASUMS(0),U,18))!($P(ASUMS(0),U,28)) D Q ;Balance was on hand -Reject Transaction
+6 ;.W *7 D MSG^ASUJHELP("Delete Unsucessful - BAL O/H") S DDSERROR=2 ;DFM P1 9/1/98
+7 ;I $P(ASUMS(2),U,2)>0 D Q ;Backorder was on file -Reject Transaction
+8 ;.W *7 D MSG^ASUJHELP("Delete Unsucessful -Back/Order O/H") S DDSERROR=1 ;DFM P1 9/1/98
+9 ;Q:$D(DDSERROR)
+10 ;Station Index record may be cleared of information
DO D^ASUMSTWR
+11 QUIT
+12 ;
+13 IF $DATA(DDSERROR)
QUIT
+14 ;Move transaction to History file
DO ^ASUJHIST
+15 KILL ASUS("ADD")
+16 QUIT