KMPSGE ;OAK/KAK/JML - Master Routine ;9/1/2015
;;2.0;SAGG PROJECT;**1**;Jul 02, 2007;Build 67
;
EN ;-- this routine can only be run as a TaskMan background job
;
Q:'$D(ZTQUEUED)
;
N CNT,COMPDT,HANG,KMPSVOLS,KMPSZE,LOC,MAXJOB,MGR,NOWDT,OS
N PROD,PTCHINFO,QUIT,SESSNUM,SITENUM,TEMP,TEXT,UCI,UCIVOL
N VOL,X,ZUZR,RESULT,XMZSENT
;
; maximum number of consecutively running jobs
S MAXJOB=6
; hang time for LOOP and WAIT code
S HANG=300
;
S SESSNUM=+$H,U="^",SITENUM=$P($$SITE^VASITE(),U,3)
;
S NOWDT=$$NOW^XLFDT
;
S OS=$$MPLTF^KMPSUTL1
I OS="UNK" D Q
.S TEXT(1)=" SAGG Project for this M platform is NOT implemented !"
.D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
;
S MGR=^%ZOSF("MGR"),PROD=$P(^%ZOSF("PROD"),",")
S PROD=$S($P(^KMPS(8970.1,1,0),U,3)="":PROD,1:$P(^(0),U,3))
S LOC=$P(^KMPS(8970.1,1,0),U,2)
;
L +^XTMP("KMPS")
S ^XTMP("KMPS",0)=$$FMADD^XLFDT($$DT^XLFDT,14)_U_NOWDT_U_"SAGG data"
K ^XTMP("KMPS",SITENUM),^XTMP("KMPS","ERROR")
K ^XTMP("KMPS","START"),^XTMP("KMPS","STOP")
;
; routine KMPSUTL will always be updated with patch release
S X="KMPSUTL"
X "ZL @X S PTCHINFO=$T(+2)"
S PTCHINFO=$P(PTCHINFO,";",3)_" "_$P(PTCHINFO,";",5)
; session number^M platform^SAGG version_" "_patch^start date-time^
; -> completed date-time will be set in $$PACK
S ^XTMP("KMPS",SITENUM,0)=SESSNUM_U_OS_U_PTCHINFO_U_NOWDT_U
S X="ERR1^KMPSGE",@^%ZOSF("TRAP")
S TEMP=SITENUM_U_SESSNUM_U_LOC_U_NOWDT_U_PROD
;
; KMPS*2.0*1 - Now analyzing all volumes, not just those in the SAGG PROJECT file
;
; NOTE: ^XINDEX incorrectly sees SYS("UCI" as an array. It is a global in the %SYS namespace
S CNT=0
S VOL=""
F S VOL=$O(^|"%SYS"|SYS("UCI",VOL)) Q:VOL="" D
.Q:$G(^|"%SYS"|SYS("UCI",VOL))]""
.J START^%ZOSVKSE(TEMP_U_VOL)
.S CNT=CNT+1
.I CNT=MAXJOB S CNT=$$WAIT(HANG,MAXJOB)
;
D EN^KMPSLK(SESSNUM,SITENUM)
S QUIT=0
D LOOP(HANG,SESSNUM,OS)
I 'QUIT D
.S RESULT=$$PACK(SESSNUM,SITENUM)
.S XMZSENT=+RESULT,COMPDT=$P(RESULT,U,2)
.S X=$$OUT^KMPSLK(NOWDT,OS,SESSNUM,SITENUM,XMZSENT,.TEXT)
.D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT,COMPDT)
D END^KMPSLK
Q
;
LOOP(HANG,SESSNUM,OS) ;
;---------------------------------------------------------------------
; Loop until all volume sets complete
;
; HANG..... time to wait to see if all volume sets have completed
; OS....... type of operating system
; SESSNUM.. +$Horolog number of session
;---------------------------------------------------------------------
N GBL,UCIVOL1,I
;
F Q:'$D(^XTMP("KMPS","START"))!+$G(^XTMP("KMPS","STOP")) H HANG I (+$H>(SESSNUM+3)) D TOOLNG Q
;
Q:QUIT
;
I $D(^XTMP("KMPS","ERROR")) D Q
.N J,JEND,OUT,TEXT,VOL
.S QUIT=1
.S TEXT(1)=" The SAGG Project has recorded an error on volume set(s):"
.S OUT=0,VOL="",JEND=$S(OS="CVMS":2,OS="CWINNT":4,1:5)
.F I=3:1 Q:OUT D
..S TEXT(I)=" "
..F J=1:1:JEND S VOL=$O(^XTMP("KMPS","ERROR",VOL)) S:VOL="" OUT=1 Q:VOL="" S TEXT(I)=TEXT(I)_VOL_" "
.S (TEXT(2),TEXT(I))=""
.S TEXT(I+1)=" See system error log for more details."
.I OS["C" D
..S TEXT(I+2)=""
..S TEXT(I+3)=" Also run "_$S(OS="CVMS":"Integrity",1:"INTEGRIT")_" on the listed volume(s)."
.D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
;
I $D(^XTMP("KMPS","STOP")) D Q
.N TEXT
.S QUIT=1
.S TEXT(1)=" The SAGG Project collection routines have been STOPPED! No report"
.S TEXT(2)=" has been generated."
.D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
;
I '$D(^XTMP("KMPS",SITENUM,SESSNUM,NOWDT)) D Q
.N TEXT
.S QUIT=1
.S TEXT(1)=" The SAGG Project collection routines did NOT obtain ANY global"
.S TEXT(2)=" information. Please ensure that the SAGG PROJECT file is"
.S TEXT(3)=" properly setup. Then use the 'One-time Option Queue' under"
.S TEXT(4)=" Task Manager to re-run the 'SAGG Master Background Task'"
.S TEXT(5)=" [KMPS SAGG REPORT] option."
.D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
;
Q
;
PACK(SESSNUM,SITENUM) ;
;---------------------------------------------------------------------
; PackMan ^XTMP global to KMP1-SAGG-SERVER at Albany FO
;
; SESSNUM.. +$Horolog number of session
; SITENUM.. site number
;
; Return:
; RETURN... number of SAGG data message^completed date-time
;---------------------------------------------------------------------
;
N COMPDT,N,NM,RETURN,X,XMSUB,XMTEXT,XMY,XMZ
S U="^",N=$O(^DIC(4,"D",SITENUM,0))
S NM=$S($D(^DIC(4,N,0)):$P(^(0),U),1:SITENUM)
;
I '$D(XMDUZ) N XMDUZ S XMDUZ=.5 S:'$D(DUZ) DUZ=.5
; PROTECTED VARIABLE -- REMOVING KILL: KMPS*2.0*1
; K:$G(IO)="" IO
;
; set completed date-time
S COMPDT=$$NOW^XLFDT
S $P(^XTMP("KMPS",SITENUM,0),U,5)=COMPDT
;
S XMSUB=NM_" (Session #"_SESSNUM_") XTMP(""KMPS"") Global"
;
I SITENUM=+SITENUM S XMTEXT="^XTMP(""KMPS"","_SITENUM_","
E S XMTEXT="^XTMP(""KMPS"","""_SITENUM_""","
S XMY("S.KMP1-SAGG-SERVER@FO-ALBANY.DOMAIN.EXT")=""
D ENT^XMPG
;
S RETURN=XMZ_U_COMPDT
;
Q RETURN
;
WAIT(HANG,MAXJOB) ;
;---------------------------------------------------------------------
; Wait here until less than MAXJOB volume sets are running
;
; HANG.... amount of time to wait
; MAXJOB.. maximum number of jobs allowed to run
;
; Return:
; RUN..... number of currently running jobs
;---------------------------------------------------------------------
;
N RUN
;
F H HANG S RUN=$$RUN Q:(RUN<MAXJOB)!+$G(^XTMP("KMPS","STOP"))
;
Q RUN
;
RUN() ;-- number of currently running jobs
N RUN,VOL
;
S RUN=0,VOL=""
F S VOL=$O(^XTMP("KMPS","START",VOL)) Q:VOL="" S RUN=RUN+1
;
Q RUN
;
TOOLNG ;-- job has been running too long
;
N TEXT
;
S QUIT=1
S TEXT(1)=" The SAGG Project collection routines have been running for more"
S TEXT(2)=" than 3 days. No report has been generated."
D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
Q
;
ERR1 ;
S KMPSZE=$ZE,ZUZR=$ZR,X="",@^%ZOSF("TRAP")
D @^%ZOSF("ERRTN")
K TEXT
S TEXT(1)=" SAGG Project Error: "_KMPSZE
S TEXT(2)=" See system error log for more details."
S ^XTMP("KMPS","STOP")=""
D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
G ^XUSCLEAN
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPSGE 6129 printed Nov 22, 2024@16:52:01 Page 2
KMPSGE ;OAK/KAK/JML - Master Routine ;9/1/2015
+1 ;;2.0;SAGG PROJECT;**1**;Jul 02, 2007;Build 67
+2 ;
EN ;-- this routine can only be run as a TaskMan background job
+1 ;
+2 if '$DATA(ZTQUEUED)
QUIT
+3 ;
+4 NEW CNT,COMPDT,HANG,KMPSVOLS,KMPSZE,LOC,MAXJOB,MGR,NOWDT,OS
+5 NEW PROD,PTCHINFO,QUIT,SESSNUM,SITENUM,TEMP,TEXT,UCI,UCIVOL
+6 NEW VOL,X,ZUZR,RESULT,XMZSENT
+7 ;
+8 ; maximum number of consecutively running jobs
+9 SET MAXJOB=6
+10 ; hang time for LOOP and WAIT code
+11 SET HANG=300
+12 ;
+13 SET SESSNUM=+$HOROLOG
SET U="^"
SET SITENUM=$PIECE($$SITE^VASITE(),U,3)
+14 ;
+15 SET NOWDT=$$NOW^XLFDT
+16 ;
+17 SET OS=$$MPLTF^KMPSUTL1
+18 IF OS="UNK"
Begin DoDot:1
+19 SET TEXT(1)=" SAGG Project for this M platform is NOT implemented !"
+20 DO MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
End DoDot:1
QUIT
+21 ;
+22 SET MGR=^%ZOSF("MGR")
SET PROD=$PIECE(^%ZOSF("PROD"),",")
+23 SET PROD=$SELECT($PIECE(^KMPS(8970.1,1,0),U,3)="":PROD,1:$PIECE(^(0),U,3))
+24 SET LOC=$PIECE(^KMPS(8970.1,1,0),U,2)
+25 ;
+26 LOCK +^XTMP("KMPS")
+27 SET ^XTMP("KMPS",0)=$$FMADD^XLFDT($$DT^XLFDT,14)_U_NOWDT_U_"SAGG data"
+28 KILL ^XTMP("KMPS",SITENUM),^XTMP("KMPS","ERROR")
+29 KILL ^XTMP("KMPS","START"),^XTMP("KMPS","STOP")
+30 ;
+31 ; routine KMPSUTL will always be updated with patch release
+32 SET X="KMPSUTL"
+33 XECUTE "ZL @X S PTCHINFO=$T(+2)"
+34 SET PTCHINFO=$PIECE(PTCHINFO,";",3)_" "_$PIECE(PTCHINFO,";",5)
+35 ; session number^M platform^SAGG version_" "_patch^start date-time^
+36 ; -> completed date-time will be set in $$PACK
+37 SET ^XTMP("KMPS",SITENUM,0)=SESSNUM_U_OS_U_PTCHINFO_U_NOWDT_U
+38 SET X="ERR1^KMPSGE"
SET @^%ZOSF("TRAP")
+39 SET TEMP=SITENUM_U_SESSNUM_U_LOC_U_NOWDT_U_PROD
+40 ;
+41 ; KMPS*2.0*1 - Now analyzing all volumes, not just those in the SAGG PROJECT file
+42 ;
+43 ; NOTE: ^XINDEX incorrectly sees SYS("UCI" as an array. It is a global in the %SYS namespace
+44 SET CNT=0
+45 SET VOL=""
+46 FOR
SET VOL=$ORDER(^|"%SYS"|SYS("UCI",VOL))
if VOL=""
QUIT
Begin DoDot:1
+47 if $GET(^|"%SYS"|SYS("UCI",VOL))]""
QUIT
+48 JOB START^%ZOSVKSE(TEMP_U_VOL)
+49 SET CNT=CNT+1
+50 IF CNT=MAXJOB
SET CNT=$$WAIT(HANG,MAXJOB)
End DoDot:1
+51 ;
+52 DO EN^KMPSLK(SESSNUM,SITENUM)
+53 SET QUIT=0
+54 DO LOOP(HANG,SESSNUM,OS)
+55 IF 'QUIT
Begin DoDot:1
+56 SET RESULT=$$PACK(SESSNUM,SITENUM)
+57 SET XMZSENT=+RESULT
SET COMPDT=$PIECE(RESULT,U,2)
+58 SET X=$$OUT^KMPSLK(NOWDT,OS,SESSNUM,SITENUM,XMZSENT,.TEXT)
+59 DO MSG^KMPSLK(NOWDT,SESSNUM,.TEXT,COMPDT)
End DoDot:1
+60 DO END^KMPSLK
+61 QUIT
+62 ;
LOOP(HANG,SESSNUM,OS) ;
+1 ;---------------------------------------------------------------------
+2 ; Loop until all volume sets complete
+3 ;
+4 ; HANG..... time to wait to see if all volume sets have completed
+5 ; OS....... type of operating system
+6 ; SESSNUM.. +$Horolog number of session
+7 ;---------------------------------------------------------------------
+8 NEW GBL,UCIVOL1,I
+9 ;
+10 FOR
if '$DATA(^XTMP("KMPS","START"))!+$GET(^XTMP("KMPS","STOP"))
QUIT
HANG HANG
IF (+$HOROLOG>(SESSNUM+3))
DO TOOLNG
QUIT
+11 ;
+12 if QUIT
QUIT
+13 ;
+14 IF $DATA(^XTMP("KMPS","ERROR"))
Begin DoDot:1
+15 NEW J,JEND,OUT,TEXT,VOL
+16 SET QUIT=1
+17 SET TEXT(1)=" The SAGG Project has recorded an error on volume set(s):"
+18 SET OUT=0
SET VOL=""
SET JEND=$SELECT(OS="CVMS":2,OS="CWINNT":4,1:5)
+19 FOR I=3:1
if OUT
QUIT
Begin DoDot:2
+20 SET TEXT(I)=" "
+21 FOR J=1:1:JEND
SET VOL=$ORDER(^XTMP("KMPS","ERROR",VOL))
if VOL=""
SET OUT=1
if VOL=""
QUIT
SET TEXT(I)=TEXT(I)_VOL_" "
End DoDot:2
+22 SET (TEXT(2),TEXT(I))=""
+23 SET TEXT(I+1)=" See system error log for more details."
+24 IF OS["C"
Begin DoDot:2
+25 SET TEXT(I+2)=""
+26 SET TEXT(I+3)=" Also run "_$SELECT(OS="CVMS":"Integrity",1:"INTEGRIT")_" on the listed volume(s)."
End DoDot:2
+27 DO MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
End DoDot:1
QUIT
+28 ;
+29 IF $DATA(^XTMP("KMPS","STOP"))
Begin DoDot:1
+30 NEW TEXT
+31 SET QUIT=1
+32 SET TEXT(1)=" The SAGG Project collection routines have been STOPPED! No report"
+33 SET TEXT(2)=" has been generated."
+34 DO MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
End DoDot:1
QUIT
+35 ;
+36 IF '$DATA(^XTMP("KMPS",SITENUM,SESSNUM,NOWDT))
Begin DoDot:1
+37 NEW TEXT
+38 SET QUIT=1
+39 SET TEXT(1)=" The SAGG Project collection routines did NOT obtain ANY global"
+40 SET TEXT(2)=" information. Please ensure that the SAGG PROJECT file is"
+41 SET TEXT(3)=" properly setup. Then use the 'One-time Option Queue' under"
+42 SET TEXT(4)=" Task Manager to re-run the 'SAGG Master Background Task'"
+43 SET TEXT(5)=" [KMPS SAGG REPORT] option."
+44 DO MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
End DoDot:1
QUIT
+45 ;
+46 QUIT
+47 ;
PACK(SESSNUM,SITENUM) ;
+1 ;---------------------------------------------------------------------
+2 ; PackMan ^XTMP global to KMP1-SAGG-SERVER at Albany FO
+3 ;
+4 ; SESSNUM.. +$Horolog number of session
+5 ; SITENUM.. site number
+6 ;
+7 ; Return:
+8 ; RETURN... number of SAGG data message^completed date-time
+9 ;---------------------------------------------------------------------
+10 ;
+11 NEW COMPDT,N,NM,RETURN,X,XMSUB,XMTEXT,XMY,XMZ
+12 SET U="^"
SET N=$ORDER(^DIC(4,"D",SITENUM,0))
+13 SET NM=$SELECT($DATA(^DIC(4,N,0)):$PIECE(^(0),U),1:SITENUM)
+14 ;
+15 IF '$DATA(XMDUZ)
NEW XMDUZ
SET XMDUZ=.5
if '$DATA(DUZ)
SET DUZ=.5
+16 ; PROTECTED VARIABLE -- REMOVING KILL: KMPS*2.0*1
+17 ; K:$G(IO)="" IO
+18 ;
+19 ; set completed date-time
+20 SET COMPDT=$$NOW^XLFDT
+21 SET $PIECE(^XTMP("KMPS",SITENUM,0),U,5)=COMPDT
+22 ;
+23 SET XMSUB=NM_" (Session #"_SESSNUM_") XTMP(""KMPS"") Global"
+24 ;
+25 IF SITENUM=+SITENUM
SET XMTEXT="^XTMP(""KMPS"","_SITENUM_","
+26 IF '$TEST
SET XMTEXT="^XTMP(""KMPS"","""_SITENUM_""","
+27 SET XMY("S.KMP1-SAGG-SERVER@FO-ALBANY.DOMAIN.EXT")=""
+28 DO ENT^XMPG
+29 ;
+30 SET RETURN=XMZ_U_COMPDT
+31 ;
+32 QUIT RETURN
+33 ;
WAIT(HANG,MAXJOB) ;
+1 ;---------------------------------------------------------------------
+2 ; Wait here until less than MAXJOB volume sets are running
+3 ;
+4 ; HANG.... amount of time to wait
+5 ; MAXJOB.. maximum number of jobs allowed to run
+6 ;
+7 ; Return:
+8 ; RUN..... number of currently running jobs
+9 ;---------------------------------------------------------------------
+10 ;
+11 NEW RUN
+12 ;
+13 FOR
HANG HANG
SET RUN=$$RUN
if (RUN<MAXJOB)!+$GET(^XTMP("KMPS","STOP"))
QUIT
+14 ;
+15 QUIT RUN
+16 ;
RUN() ;-- number of currently running jobs
+1 NEW RUN,VOL
+2 ;
+3 SET RUN=0
SET VOL=""
+4 FOR
SET VOL=$ORDER(^XTMP("KMPS","START",VOL))
if VOL=""
QUIT
SET RUN=RUN+1
+5 ;
+6 QUIT RUN
+7 ;
TOOLNG ;-- job has been running too long
+1 ;
+2 NEW TEXT
+3 ;
+4 SET QUIT=1
+5 SET TEXT(1)=" The SAGG Project collection routines have been running for more"
+6 SET TEXT(2)=" than 3 days. No report has been generated."
+7 DO MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
+8 QUIT
+9 ;
ERR1 ;
+1 SET KMPSZE=$ZE
SET ZUZR=$ZR
SET X=""
SET @^%ZOSF("TRAP")
+2 DO @^%ZOSF("ERRTN")
+3 KILL TEXT
+4 SET TEXT(1)=" SAGG Project Error: "_KMPSZE
+5 SET TEXT(2)=" See system error log for more details."
+6 SET ^XTMP("KMPS","STOP")=""
+7 DO MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
+8 GOTO ^XUSCLEAN