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

PSGWXREF.m

Go to the documentation of this file.
  1. PSGWXREF ;BHAM ISC/CML-Background job to re-index the "AMIS" xref for inventories, on-demands, and returns ; 08 Dec 93 / 9:03 AM
  1. ;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
  1. ;ODT=ON-DEMAND DATE TIME;ADA=AOU INTERNAL #;DDA=ITEM INTERNAL #;ODA=ON-DEMAND INTERNAL #;RET=RETURN INTERNAL #;INV=INVENTORY INTERNAL #
  1. W !!,"This option will re-index the ""AMIS"" cross-reference for Inventories, On-Demand",!,"Requests, and Returns for a date range beginning with the START DATE you specify",!,"to the time the job runs."
  1. W !!?34,"** WARNING **",!?22,"Since this option is CPU intensive,",!?17,"it should be QUEUED to run in the ""off"" hours!",!!
  1. ASK1 W ! S %DT("A")="Select START DATE for re-index: ",%DT(0)="-NOW",%DT="AETX" D ^%DT G:Y<0 QUIT S START=Y
  1. ASK2 X ^DD("DD") W !!,"The ""AMIS"" cross-reference will now be re-indexed starting from ",Y,"."
  1. F JJ=0:0 W !!,"Are you SURE that is what you want to do" S %=2 D YN^DICN Q:% D HELP
  1. G:%'=1 QUIT S ZTIO="",ZTRTN="START^PSGWXREF",ZTDESC="Re-index AR/WS 'AMIS' xref" S:$D(START) ZTSAVE("START")=""
  1. D ^%ZTLOAD,HOME^%ZIS I $D(ZTSK) W !!,"""AMIS"" cross reference re-indexing queued!" K ZTSK
  1. G QUIT
  1. START ; Entry point from queue
  1. ; Delete existing "AMIS" xref
  1. L +^PSI(58.5,"AMIS")
  1. S SUB1="" F JJ=0:0 S SUB1=$O(^PSI(58.5,"AMIS",SUB1)) Q:SUB1="" F KDT=START-.000001:0 S KDT=$O(^PSI(58.5,"AMIS",SUB1,KDT)) Q:'KDT K ^(KDT)
  1. D INV,OND,RET
  1. QUIT K %,%DT,%I,%H,ZTSK,ZTIO,JJ,ODT,ADA,DDA,ODA,DA,RET,INV,ANS,START,SUB1,KDT,QD,X,Y L -^PSI(58.5,"AMIS")
  1. S:$D(ZTQUEUED) ZTREQ="@" Q
  1. INV ; Re-index Inventories
  1. F ADA=0:0 S ADA=$O(^PSI(58.1,ADA)) Q:'ADA F DDA=0:0 S DDA=$O(^PSI(58.1,ADA,1,DDA)) Q:'DDA F INV=0:0 S INV=$O(^PSI(58.1,ADA,1,DDA,1,INV)) Q:'INV I $D(^PSI(58.19,INV,0)),$P(^(0),"^")'<START D SETINV
  1. Q
  1. SETINV ;
  1. S QD=$P(^PSI(58.1,ADA,1,DDA,1,INV,0),"^",5),DA(2)=ADA,DA(1)=DDA,DA=INV,X=QD I X D QD^PSGWUTL
  1. Q
  1. OND ; Re-index On-Demands
  1. F ODT=START-.000001:0 S ODT=$O(^PSI(58.1,"OND",ODT)) Q:'ODT F ADA=0:0 S ADA=$O(^PSI(58.1,"OND",ODT,ADA)) Q:'ADA F DDA=0:0 S DDA=$O(^PSI(58.1,"OND",ODT,ADA,DDA)) Q:'DDA S ODA=$O(^PSI(58.1,"OND",ODT,ADA,DDA,0)) D SETOND
  1. Q
  1. SETOND S QD=$P(^PSI(58.1,ADA,1,DDA,5,ODA,0),"^",2),DA(2)=ADA,DA(1)=DDA,DA=ODA,X=QD I X D OD^PSGWUTL
  1. Q
  1. RET ; Re-index Returns
  1. F ADA=0:0 S ADA=$O(^PSI(58.1,ADA)) Q:'ADA F DDA=0:0 S DDA=$O(^PSI(58.1,ADA,1,DDA)) Q:'DDA F RET=0:0 S RET=$O(^PSI(58.1,ADA,1,DDA,3,RET)) Q:'RET I $P(^(RET,0),"^")'<START D SETRET
  1. Q
  1. SETRET ;
  1. S QD=$P(^PSI(58.1,ADA,1,DDA,3,RET,0),"^",2),DA(2)=ADA,DA(1)=DDA,DA=RET,X=QD I X D RET^PSGWUTL
  1. Q
  1. HELP ;
  1. W !?5,"Enter 'YES' if you are satisfied with the selected date range.",!?5,"Enter 'NO' or '^' if you wish to abort the re-indexing." Q