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

ASUV4AL.m

Go to the documentation of this file.
ASUV4AL ; IHS/ITSC/LMH -RPT ADJUSTMENT DOC ;  
 ;;4.2T2;Supply Accounting Mgmt. System;;JUN 30, 2000
 ;This routine creates the Physical Inventory Adjustments Documents
 ;report.
 D:'$D(DT) ^XBKVAR S %H=$H D YX^%DTC S ASUK("RUN","DT")=$P(Y,"@") K X,Y,%H
 D:'$D(IO(0)) HOME^%ZIS
 S %DT="T",X="NOW" D ^%DT S ASUV("DT")=Y
 D CLS^ASUUHDG
 I $G(ASUL(2,"STA","E#"))']"" D STA^ASUV0NT I $D(DTOUT)!($D(DUOUT)) G EXIT
 S DIC("A")="PRINT RPT 37C 'ADJUSTMENT DOCUMENT' FOR WHAT ACCOUNT?"
 S DIC="9002039.09",DIC(0)="AMEZQ"
 D ^DIC K DIC
 I $D(DTOUT)!($D(DUOUT)) Q
 Q:'$D(Y)  Q:Y=""
 I Y>0 D
 .S ASUMV("ACC")=$P(Y,U),ASUMV("E#","ASA")=ASUL(2,"STA","E#")_ASUMV("ACC")
 .D ACC^ASULDIRF(ASUMV("ACC"))
 E  D
 .S ASUMV("E#","ASA")=ASUL(2,"STA","E#")
 G:ASUMV("E#","ASA")="" EXIT
 I $D(^ASUMV(ASUMV("E#","ASA"),0)) D
 .D ACCOUNT^ASUV9IMR
 E  D  G EXIT
 .W !!,"NO INVENTORY IS ACTIVE FOR ACCOUNT ",ASUMV("ACC")," ",ASUL(9,"ACC","NM")
 .S DIR(0)="E" D ^DIR K DIR
 S ASUV("ASA")=ASUMV("E#","ASA")
 S ASUF=$G(ASUF)
 I ASUF=2 D
 .S ASUF=0,ASUMV("MODE")=3
 E  D
 .S ASUV("MSG",1)="YOU HAVE REQUESTED AN ADJUSTMENT DOCUMENT BUT "
 .D ASUV3AN0^ASUV3AN
 G:ASUF EXIT
 D ASUV4AL0
 I '$D(IO) D HOME^%ZIS
 I '$D(DUZ(2)) W !,"Report must be run from Kernel option" G EXIT
 I '$D(ASUL(1,"AR","AP")) D SETAREA^ASULARST
 S ASUV("ASA")=ASUMV("E#","ASA")
 S ZTRTN="ASUV4AL1^ASUV4AL",ZTDESC="SAMS INVENTORY ADJUSTMENTS LIST" D O^ASUUZIS
 I POP S IOP=$I D ^%ZIS G EXIT
 I ASUK(ASUK("PTR"),"Q") K IOP,POP,ZTDESC,ZTRTN,ZTSK,ASUK(ASUK("PTR")),ASUK("PTR"),ASUK("PTR-Q") G EXIT
 D ASUV4AL1
EXIT ;
 K ASUU(11),ASUC,ASUR,ASUSAV,ASUF,ASUMS,ASUMV,ASUV,ASUMX
 K DTOUT,DUOUT,ZTRTN,ZTDESC,X,Y,X1
 D:$D(ASUK("PTR")) C^ASUUZIS
 Q
ASUV4AL0 ;ADJUSTMENT DOCUMENT SORT
 K ^ASUV("AJ")
 S ASUMV("E#","SLC")=0
 F  S ASUMV("E#","SLC")=$O(^ASUMV(ASUMV("E#","ASA"),1,ASUMV("E#","SLC"))) Q:ASUMV("E#","SLC")'?1N.N  D
 .S ASUMV("E#","INDX")=0
 .F  S ASUMV("E#","INDX")=$O(^ASUMV(ASUMV("E#","ASA"),1,ASUMV("E#","SLC"),1,ASUMV("E#","INDX"))) Q:ASUMV("E#","INDX")'?1N.N  D
 ..Q:$P(^ASUMV(ASUMV("E#","ASA"),1,ASUMV("E#","SLC"),1,ASUMV("E#","INDX"),0),U,7)=0
 ..S ASUL(2,"STA","E#")=$P(^ASUMV(ASUMV("E#","ASA"),1,ASUMV("E#","SLC"),1,ASUMV("E#","INDX"),0),U,2)
 ..S ^ASUV("AJ",ASUMV("E#","ASA"),ASUMV("E#","INDX"))=ASUMV("E#","SLC")
 Q
ASUV4AL1 ;
 S ASUMV("E#","ASA")=ASUV("ASA")
 D U^ASUUZIS
 S (ASUC("PG"),ASUC("LN"))=0
 S (ASUC("OVR","VAL"),ASUC("OVR","LI"))=0
 S (ASUC("SHT","VAL"),ASUC("SHT","LI"))=0
 I '$D(^ASUV("AJ",ASUMV("E#","ASA"))) D  G FLAGIT
 .D ACCOUNT^ASUV9IMR
 .S Y=ASUMV("INVBEG") X ^DD("DD") S ASUV("DTPRNT")=Y K Y
 .D HEADING
 .W !!,"NO ADJUSTMENTS TO BE MADE FOR ACCOUNT '",ASUMV("ACC"),"' -",ASUL(9,"ACC","NM")," INVENTORY"
 S ASUMV("E#","SLC")=""
 D ACCOUNT^ASUV9IMR
 S Y=ASUMV("INVBEG") X ^DD("DD") S ASUV("DTPRNT")=Y K Y
 S ASUMV("E#","INDX")=""
 D:ASUC("LN")<1 HEADING
 F ASUU(11)=1:1 S ASUMV("E#","INDX")=$O(^ASUV("AJ",ASUMV("E#","ASA"),ASUMV("E#","INDX"))) Q:ASUMV("E#","INDX")'?1N.N  D
 .S ASUMV("E#","SLC")=^ASUV("AJ",ASUMV("E#","ASA"),ASUMV("E#","INDX"))
 .D STORLOC^ASUV9IMR
 .D:ASUC("LN")>55 HEADING
 .D INDEX^ASUV9IMR
 .Q:ASUMV("IDX")["*"  ;MASTER HAS BEEN DELETED
 .S ASUV("CNT","LST")=$S(ASUMV("CNT","2ND"):ASUMV("CNT","2ND"),1:ASUMV("CNT","1ST"))
 .S ASUV("ADJUST VAL")=$FN(ASUMV("QTY","DIF")*ASUMV("U/C"),"",2)
 .D READ^ASUMXDIO
 .S ASUMS("E#","IDX")=$O(^ASUMS(ASUL(2,"STA","E#"),1,"B",ASUMV("IDX"),""))
 .W !?1,$J(ASUU(11),3),?6,$E(ASUMX("IDX"),1,5),".",$E(ASUMX("IDX"),6,6)
 .W ?14,$E(ASUMX("DESC",1),1,20),?35,ASUMX("AR U/I"),?37,$J($FN(ASUMV("U/C"),",",2),6)
 .S ASUT="GEN ADJ"
 .S ASUT(ASUT,"VAL")=ASUV("ADJUST VAL")
 .I ASUMV("QTY","DIF")<1 D
 ..S ASUT("TRCD")=37
 ..S ASUT(ASUT,"QTY")=(ASUMV("QTY","DIF")*-1)
 ..S:ASUT(ASUT,"VAL")<0 ASUT(ASUT,"VAL")=(ASUT(ASUT,"VAL")*-1)
 ..D ASUV4AL3
 ..W ?62,$J(ASUMV("QTY","DIF"),6),?68,$J($FN(ASUV("ADJUST VAL"),",",2),10)
 ..S ASUC("SHT","VAL")=ASUC("SHT","VAL")+ASUV("ADJUST VAL"),ASUC("SHT","LI")=ASUC("SHT","LI")+1
 .E  D
 ..S ASUT("TRCD")=27
 ..S ASUT(ASUT,"QTY")=ASUMV("QTY","DIF")
 ..D ASUV4AL3
 ..W ?45,$J(ASUMV("QTY","DIF"),6),?52,$J($FN(ASUV("ADJUST VAL"),",",2),10)
 ..S ASUC("OVR","VAL")=ASUC("OVR","VAL")+ASUV("ADJUST VAL"),ASUC("OVR","LI")=ASUC("OVR","LI")+1
 .D SEPERATE
 .S ASUC("LN")=ASUC("LN")+2
 D:ASUC("LN")>7 FOOTING
FLAGIT ;
 U IO(0) D CLS^ASUUHDG
 I '$G(ASUF("RPRN")) D FLAGIT4^ASUV3AN
 D:$D(ASUK("PTR")) C^ASUUZIS
 Q
HEADING ;
 D CLS^ASUUHDG S ASUC("PG")=ASUC("PG")+1,ASUC("LN")=7
 W "REPORT 37C INVENTORY ADJUSTMENT DOUCMENT           DATE: ",ASUK("RUN","DT"),?70," PAGE: ",ASUC("PG")
 W !,"AREA: ",ASUL(1,"AR","NM")
 W !,"STAT: ",ASUL(2,"STA","NM"),?33,"ACCOUNT : ",ASUL(9,"ACC","NM"),?55,"INV. DATE ",ASUV("DTPRNT")
 W !,"VOUCHER NO: ",$E(ASUMV("VOU"),1,2),"-",$E(ASUMV("VOU"),3,4),"-",$E(ASUMV("VOU"),5,8)
 W !!,"ITEM  INDEX"
 W ?34,"U    UNIT       OVERAGE          SHORTAGE"
 W !,"  NO. NUMBER    DESCRIPTION"
 W ?34," I   COST    QTY      VALUE    QTY      VALUE"
 D SEPERATE
 Q
SEPERATE ;
 W !,"_______________________________________________________________________________"
 Q
FOOTING ;
 S ASUC("LN")=0
 W !!?5,"TOTALS:  OVERAGES:  NO. LI: ",$J(ASUC("OVR","LI"),6),?45," VAL: ",$J($FN(ASUC("OVR","VAL"),",",2),10)
 W !?13,"SHORTAGES:  NO. LI: ",$J(ASUC("SHT","LI"),6),?45," VAL: ",$J($FN(ASUC("SHT","VAL"),",",2),10)
 ;I $D(IO("HOME")) HANG 60  ;;ADDED 3/14/95 CSC
 Q
ASUV4AL3 ;
 Q:$G(ASUF("RPRN"))>0
 I '$D(ASUV("TIME")) S ASUV("TIME")=$H G KEY
 F  I ASUV("TIME")'=$H Q
 S ASUV("TIME")=$H
KEY ;
 S ASUT(ASUT,"DTE")=$P(ASUV("DT"),".")_"."_$P(ASUV("TIME"),",",2)
 S ASUT(ASUT,"TRKY")=ASUT(ASUT,"DTE")_"."_DUZ,ASUF("UPDT")=1,ASUC(0)=0
 S ASUT(ASUT,"STA")=ASUL(2,"STA","CD")
 S ASUT(ASUT,"VOU")=ASUMV("VOU")
 S ASUT(ASUT,"IDX")=ASUMV("IDX")
 S ASUC=$G(ASUC)
 S ASUT(ASUT,"ENTR BY")=DUZ
 S ASUT(ASUT,"DTE")=ASUK("DT","FM")
 S ASUT(ASUT,"AR")=ASUL(1,"AR","AP")
 S (ASUT(ASUT,"DTP"),ASUT(ASUT,"DTW"))="",ASUT(ASUT,"STATUS")="Y"
 S ASUT(ASUT,"PT","AR")=ASUT(ASUT,"AR")
 S ASUT(ASUT,"PT","STA")=ASUL(2,"STA","E#")
 I ASUT(ASUT,"IDX")]"" D
 .S ASUT(ASUT,"PT","IDX")=ASUT(ASUT,"AR")_ASUT(ASUT,"IDX")
 E  D
 .S ASUT(ASUT,"PT","IDX")=""
 I $G(ASUT(ASUT,"ACC"))]"" D
 .S ASUT(ASUT,"PT","ACC")=ASUT(ASUT,"ACC")
 E  D
 .I ASUT(ASUT,"PT","IDX")]"",$G(ASUL(1,"AR","WHSE"))>0 D
 ..S ASUT(ASUT,"ACC")=$P($G(^ASUMX(ASUT(ASUT,"PT","IDX"),0)),U,6)
 ..S ASUT(ASUT,"PT","ACC")=ASUT(ASUT,"ACC")
 .E  D
 ..S (ASUT(ASUT,"ACC"),ASUT(ASUT,"PT","ACC"))=""
 S DIC=9002036.6,X=ASUT(ASUT,"TRKY"),DIC(0)="L" D ^DIC
 I Y<0 D
 .W *7,*7,!,"INVENTORY ADJUSTMENT CREATION UNSUCESSFUL",!
 E  D
 .S (DA,ASUHDA)=+Y
 .S ASUC=ASUC+1
 .S ASUF("SV")=1 D WRITE^ASU0TRWR(DA,6)
 ;F X=3:1:22 K ASUL(X)   ;LMH 6/19/00
 K DA,DR,DIC,DIE,ASUMSG,X,Y
 K ASUT(ASUT),ASUC(0)
 Q