KMPBEMRT ;SP/JML - VBEM Nightly compression and transmission;2/1/2023
;;4.0;CAPACITY MANAGEMENT;**1,2,3,4**;3/1/2018;Build 36
;
; Reference to $$WORKDAY^XUWORKDY in ICR #10046
; Reference to $$HTFM^XLFDT in ICR #10103
; Reference to $$SITE^VASTIE in ICR #10112
; Reference to GETENV^%ZOSV, EC^%ZOSV and LGR^%ZOSV in ICR #10097
; Reference to $ESTACK, $ETRAP, ^%ZTER and UNWIND^%ZTER in ICR #1621
;
RUN ;
N $ESTACK,$ETRAP S $ETRAP="D ^%ZTER Q"
I $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969,"I") D RU^%ZOSVKR("KMP VBEM DRIVER")
N KMPPARMS,KMPVSITE,KMPVSINF,KMPSC,KMPVSTOP,KMPVCHKH,KMPVH,KMPVSINT,KMPVHANG,KMPVSLOT,ZTDTH,ZTRTN,ZTDESC,ZTSAVE,%
N KMPDET,KMPDST,KMPETSO,KMPTIMES,KMPUTCE,KMPUTCO,KMPVLINE,KMPVNODE,KMPVTEST,Y,KMPFMDAY
; ALWAYS - verify data is not building past configured number of days - if so for any reason, delete it
D PURGEDLY^KMPVCBG("VBEM")
; Quit if monitor is not turned on
I $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969)'="ON" D Q
.I $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969,"I") D RU^%ZOSVKR("KMP VBEM DRIVER END")
; Environment Check
; if TEST system - quit if system is a front end OR allow test=no
; if PROD system - quit if system is a front end AND allow test=no
S KMPVTEST=$$GETVAL^KMPVCCFG("VBEM","ALLOW TEST SYSTEM",8969,"I")
D GETENV^%ZOSV S KMPVNODE=$P(Y,U,3)_":"_$P($P(Y,U,4),":",2) ;supported by ICR #10097
I $$PROD^KMPVCCFG'="prod",$$GETVAL^KMPVCCFG("VTCM","ALLOW TEST SYSTEM",8969,"I")'=1 Q
;
D NOW^%DTC
S KMPVSITE=$$SITE^VASITE($P(%,".")) ;supported by ICR #10112
S KMPVSINF=$$SITEINFO^KMPVCCFG()
S KMPSC=$P(KMPVSINF,"^",5)
;
; COMPRESS DATA - REMOVE $J SPECIFICITY - KILL 'DLY' NODE
S KMPVSTOP=0,KMPVCHKH=+$H
; Setup Parameter array to send to job
S KMPPARMS("KMPVSITE")=KMPVSITE,KMPPARMS("KMPVSINF")=KMPVSINF
S KMPPARMS("KMPSC")=KMPSC,KMPPARMS("KMPVCHKH")=KMPVCHKH
S KMPPARMS("KMPFMDAY")=+$$HTFM^XLFDT($H,1) ;supported by ICR #10103
F D Q:KMPVSTOP
.I $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969)'="ON" S KMPVSTOP=1 Q ; RUN FLAG SET TO 0
.S KMPVH=$H
.I KMPVH>KMPVCHKH SET KMPVSTOP=1 Q
.S KMPVSINT=$$GETVAL^KMPVCCFG("VBEM","COLLECTION INTERVAL",8969)
.S KMPVHANG=KMPVSINT*60
.S KMPVSLOT=$$SLOT^KMPVCCFG(KMPVH,KMPVSINT,"HOROLOG")
.S KMPPARMS("KMPVH")=KMPVH,KMPPARMS("KMPVSINT")=KMPVSINT
.S KMPPARMS("KMPVSLOT")=KMPVSLOT
.M ^KMPTMP("KMPV","VBEM",KMPVNODE,"PARMS")=KMPPARMS
.J COLLECT(KMPVNODE)
.H KMPVHANG
I $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969,"I") D RU^%ZOSVKR("KMP VBEM DRIVER END")
Q
COLLECT(KMPVNODE) ;
N $ES,$ETRAP S $ETRAP="D ^%ZTER Q"
I $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969,"I") D RU^%ZOSVKR("KMP VBEM COLLECTOR")
N B,KMPCNT,KMPDATA,KMPDATE,KMPDONE,KMPETS,KMPINST,KMPLI,KMPMAX,KMPNT,KMPSTAT,KMPTI,KMPVD,KMPVDATA,KMPVFMDAY,KMPVHDAY
N KMPVI,KMPVJ,KMPVJTOT,KMPVLN,KMPVN,KMPVO,KMPVOPT,KMPVTIME,KMPVUTOT,KMPVWD
N KMPDARR,KMPJMSG
;
K ^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE)
K ^KMPTMP("KMPV","VBEM","COMPRESS",KMPVNODE)
M KMPPARMS=^KMPTMP("KMPV","VBEM",KMPVNODE,"PARMS")
S KMPVSITE=KMPPARMS("KMPVSITE"),KMPVSINF=KMPPARMS("KMPVSINF")
S KMPSC=KMPPARMS("KMPSC"),KMPVCHKH=KMPPARMS("KMPVCHKH")
S KMPVH=KMPPARMS("KMPVH"),KMPVSINT=KMPPARMS("KMPVSINT")
S KMPVSLOT=KMPPARMS("KMPVSLOT"),KMPFMDAY=KMPPARMS("KMPFMDAY"),U="^"
;
S KMPVHDAY=""
F S KMPVHDAY=$O(^KMPTMP("KMPV","VBEM","DLY",KMPVHDAY)) Q:(KMPVHDAY="") D
.S KMPVTIME=""
.F S KMPVTIME=$O(^KMPTMP("KMPV","VBEM","DLY",KMPVHDAY,KMPVNODE,KMPVTIME)) Q:KMPVTIME="" D
..I KMPVTIME>=KMPVSLOT,KMPVHDAY>=+$H Q
..S KMPVOPT=""
..F S KMPVOPT=$O(^KMPTMP("KMPV","VBEM","DLY",KMPVHDAY,KMPVNODE,KMPVTIME,KMPVOPT)) Q:KMPVOPT="" D
...S KMPVJ="",KMPVDATA="",KMPVJTOT="",KMPVUTOT=0
...F S KMPVJ=$O(^KMPTMP("KMPV","VBEM","DLY",KMPVHDAY,KMPVNODE,KMPVTIME,KMPVOPT,KMPVJ)) Q:KMPVJ="" D
....S KMPVDATA=$G(^KMPTMP("KMPV","VBEM","DLY",KMPVHDAY,KMPVNODE,KMPVTIME,KMPVOPT,KMPVJ))
....F KMPVI=1:1:6 S $P(KMPVJTOT,"^",KMPVI)=$P(KMPVDATA,"^",KMPVI)+$P(KMPVJTOT,"^",KMPVI)
....S KMPVUTOT=KMPVUTOT+1
...S ^KMPTMP("KMPV","VBEM","COMPRESS",KMPVNODE,KMPVHDAY,KMPVTIME,KMPVOPT)=KMPVJTOT_"^"_KMPVUTOT
..K ^KMPTMP("KMPV","VBEM","DLY",KMPVHDAY,KMPVNODE,KMPVTIME) ; Kill node once all data compiled in 'compress' node
; PROCESS 'COMPRESS' NODE FOR TRANSMISSION
S KMPVHDAY="",B="|"
F S KMPVHDAY=$O(^KMPTMP("KMPV","VBEM","COMPRESS",KMPVNODE,KMPVHDAY)) Q:KMPVHDAY="" D
.; IF BETWEEN 1 AND 7 DAYS OLD AND NOT TRANSMITTED SEND WARNING MESSAGE AND ATTEMPT TO TRANSMIT AGAIN
.I KMPVHDAY<(+$H-1) D CANMSG^KMPUTLW("TRANWARN","VBEM",KMPVSITE,KMPVHDAY)
.S KMPVLN=1
.S KMPVTIME=""
.F S KMPVTIME=$O(^KMPTMP("KMPV","VBEM","COMPRESS",KMPVNODE,KMPVHDAY,KMPVTIME)) Q:KMPVTIME="" D
..S KMPVOPT=""
..F S KMPVOPT=$O(^KMPTMP("KMPV","VBEM","COMPRESS",KMPVNODE,KMPVHDAY,KMPVTIME,KMPVOPT)) Q:KMPVOPT="" D
...S KMPVDATA=$G(^KMPTMP("KMPV","VBEM","COMPRESS",KMPVNODE,KMPVHDAY,KMPVTIME,KMPVOPT))
...S KMPVO=$TR($$EVTPKG^KMPUTLW2(KMPVOPT),"^","|")
...S KMPVD=$TR(KMPVDATA,"^","|")
...S ^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE,$J,KMPVHDAY,KMPVTIME,KMPVLN)=KMPVO_B_KMPVD,KMPVLN=KMPVLN+1
...; eventname|parentevent|eventtype|eventsource|packagenamespace|packagename|occurrences|cputime|r-lines|rcmd|gref|elapsed time|user count
.K ^KMPTMP("KMPV","VBEM","COMPRESS",KMPVNODE,KMPVHDAY)
; quit if no data to transmit.
I '$D(^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE,$J)) D Q
.I $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969,"I") D RU^%ZOSVKR("KMP VBEM COLLECTOR END")
S KMPVHDAY=""
F S KMPVHDAY=$O(^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE,$J,KMPVHDAY)) Q:KMPVHDAY="" D
.S KMPVFMDAY=+$$HTFM^XLFDT(KMPVHDAY,1) ;supported by ICR #10103
.S KMPVWD=$$WORKDAY^XUWORKDY(KMPVFMDAY) ;supported by ICR #10046
.S KMPDATE=$$SHORTDAT^KMPUTLW(KMPVHDAY,"HOROLOG")
.S KMPVTIME=""
.F S KMPVTIME=$O(^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE,$J,KMPVHDAY,KMPVTIME)) Q:KMPVTIME="" D
..S KMPTIMES=$$TSTAMP^KMPUTLW(KMPVHDAY_","_KMPVTIME,"HOROLOG",1) ; yyy-mm-dd hh:mm:ssZtz
..S KMPETSO=$P(KMPTIMES,"^")
..S KMPUTCO=$P(KMPTIMES,"^",2)
..S KMPUTCE=$P(KMPTIMES,"^",3)
..S KMPDST=$P(KMPTIMES,"^",4)
..S KMPVN=$P(KMPVNODE,":")
..S KMPINST=$P(KMPVNODE,":",2),KMPNT=$$NODETYPE^KMPUTLW(KMPINST)
..S KMPJSON=##class(%DynamicObject).%New()
..S KMPJSON.Function="VBEM"
..D SITE^KMPUTLW(KMPJSON)
..S KMPJMSG=##class(%DynamicObject).%New()
..S KMPJMSG.Date=KMPDATE
..S KMPJMSG.Workday=KMPVWD
..S KMPJMSG.Timestamp=KMPETSO
..S KMPJMSG.UtcOdbc=KMPUTCO
..S KMPJMSG.UtcEpoch=KMPUTCE
..S KMPJMSG.IsDst=KMPDST
..S KMPJMSG.Node=KMPVN,KMPJMSG.NodeType=KMPNT
..S KMPJMSG.Instance=KMPINST
..S KMPJSON.MessageData=KMPJMSG
..S KMPDARR=##class(%DynamicArray).%New()
..S KMPVLINE=""
..F S KMPVLINE=$O(^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE,$J,KMPVHDAY,KMPVTIME,KMPVLINE)) Q:KMPVLINE="" D
...S KMPDET=$G(^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE,$J,KMPVHDAY,KMPVTIME,KMPVLINE))
...D KMPDARR.%Push(KMPDET)
..S KMPJSON.Details=KMPDARR
..S KMPSTAT=$$POST^KMPUTLW(KMPJSON,"/businessevent",1,"VBEM")
..I +KMPSTAT'=200 H 30 S KMPSTAT=$$POST^KMPUTLW(KMPJSON,"/businessevent",1,"VBEM")
..K ^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE,$J,KMPVHDAY,KMPVTIME)
..S ^XTMP("KMP "_KMPFMDAY,"VBEM","HTTP",KMPVNODE,$P($H,",",2))=KMPSTAT
..I +KMPSTAT'=200 D SETRETRY
I $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969,"I") D RU^%ZOSVKR("KMP VBEM COLLECTOR END")
Q
;
SETRETRY ;
N KMPTEXT
S KMPTEXT("SUBJECT")="VSM FAILED SEND: VBEM at "_KMPJSON.Site.SiteCode
S KMPTEXT(1)="Status Code: "_+KMPSTAT
S KMPTEXT(2)="Status Text: "_$P(KMPSTAT,"^",2)
S KMPTEXT(3)="Response Time: "_$P(KMPSTAT,"^",3)
S KMPTEXT(4)="Node: "_KMPVNODE
D INFOMSG^KMPUTLW(.KMPTEXT)
S ^KMPTMP("KMPV","VBEM","RETRY",KMPVNODE,+$H,$H)=KMPJSON.%ToJSON()
Q
;
RETRY ; retry failed POSTS
N KMPDAY,KMPI,KMPJSON,KMPSTAT,KMPVNODE,Y
;
D GETENV^%ZOSV S KMPVNODE=$P(Y,"^",3)_":"_$P($P(Y,"^",4),":",2) ;supported by ICR #10097
S KMPDAY=""
F S KMPDAY=$O(^KMPTMP("KMPV","VBEM","RETRY",KMPVNODE,KMPDAY)) Q:KMPDAY="" D
.S KMPI=""
.F S KMPI=$O(^KMPTMP("KMPV","VBEM","RETRY",KMPVNODE,KMPDAY,KMPI)) Q:KMPI="" D
..S KMPJSON=$G(^KMPTMP("KMPV","VBEM","RETRY",KMPVNODE,KMPDAY,KMPI))
..S KMPSTAT=$$POST^KMPUTLW({}.%FromJSON(KMPJSON),"/businessevent",1,"VBEM")
..I +KMPSTAT=200 K ^KMPTMP("KMPV","VBEM","RETRY",KMPVNODE,KMPDAY,KMPI)
..H $R(10)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPBEMRT 8343 printed Nov 22, 2024@16:50:40 Page 2
KMPBEMRT ;SP/JML - VBEM Nightly compression and transmission;2/1/2023
+1 ;;4.0;CAPACITY MANAGEMENT;**1,2,3,4**;3/1/2018;Build 36
+2 ;
+3 ; Reference to $$WORKDAY^XUWORKDY in ICR #10046
+4 ; Reference to $$HTFM^XLFDT in ICR #10103
+5 ; Reference to $$SITE^VASTIE in ICR #10112
+6 ; Reference to GETENV^%ZOSV, EC^%ZOSV and LGR^%ZOSV in ICR #10097
+7 ; Reference to $ESTACK, $ETRAP, ^%ZTER and UNWIND^%ZTER in ICR #1621
+8 ;
RUN ;
+1 NEW $ESTACK,$ETRAP
SET $ETRAP="D ^%ZTER Q"
+2 IF $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969,"I")
DO RU^%ZOSVKR("KMP VBEM DRIVER")
+3 NEW KMPPARMS,KMPVSITE,KMPVSINF,KMPSC,KMPVSTOP,KMPVCHKH,KMPVH,KMPVSINT,KMPVHANG,KMPVSLOT,ZTDTH,ZTRTN,ZTDESC,ZTSAVE,%
+4 NEW KMPDET,KMPDST,KMPETSO,KMPTIMES,KMPUTCE,KMPUTCO,KMPVLINE,KMPVNODE,KMPVTEST,Y,KMPFMDAY
+5 ; ALWAYS - verify data is not building past configured number of days - if so for any reason, delete it
+6 DO PURGEDLY^KMPVCBG("VBEM")
+7 ; Quit if monitor is not turned on
+8 IF $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969)'="ON"
Begin DoDot:1
+9 IF $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969,"I")
DO RU^%ZOSVKR("KMP VBEM DRIVER END")
End DoDot:1
QUIT
+10 ; Environment Check
+11 ; if TEST system - quit if system is a front end OR allow test=no
+12 ; if PROD system - quit if system is a front end AND allow test=no
+13 SET KMPVTEST=$$GETVAL^KMPVCCFG("VBEM","ALLOW TEST SYSTEM",8969,"I")
+14 ;supported by ICR #10097
DO GETENV^%ZOSV
SET KMPVNODE=$PIECE(Y,U,3)_":"_$PIECE($PIECE(Y,U,4),":",2)
+15 IF $$PROD^KMPVCCFG'="prod"
IF $$GETVAL^KMPVCCFG("VTCM","ALLOW TEST SYSTEM",8969,"I")'=1
QUIT
+16 ;
+17 DO NOW^%DTC
+18 ;supported by ICR #10112
SET KMPVSITE=$$SITE^VASITE($PIECE(%,"."))
+19 SET KMPVSINF=$$SITEINFO^KMPVCCFG()
+20 SET KMPSC=$PIECE(KMPVSINF,"^",5)
+21 ;
+22 ; COMPRESS DATA - REMOVE $J SPECIFICITY - KILL 'DLY' NODE
+23 SET KMPVSTOP=0
SET KMPVCHKH=+$HOROLOG
+24 ; Setup Parameter array to send to job
+25 SET KMPPARMS("KMPVSITE")=KMPVSITE
SET KMPPARMS("KMPVSINF")=KMPVSINF
+26 SET KMPPARMS("KMPSC")=KMPSC
SET KMPPARMS("KMPVCHKH")=KMPVCHKH
+27 ;supported by ICR #10103
SET KMPPARMS("KMPFMDAY")=+$$HTFM^XLFDT($HOROLOG,1)
+28 FOR
Begin DoDot:1
+29 ; RUN FLAG SET TO 0
IF $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969)'="ON"
SET KMPVSTOP=1
QUIT
+30 SET KMPVH=$HOROLOG
+31 IF KMPVH>KMPVCHKH
SET KMPVSTOP=1
QUIT
+32 SET KMPVSINT=$$GETVAL^KMPVCCFG("VBEM","COLLECTION INTERVAL",8969)
+33 SET KMPVHANG=KMPVSINT*60
+34 SET KMPVSLOT=$$SLOT^KMPVCCFG(KMPVH,KMPVSINT,"HOROLOG")
+35 SET KMPPARMS("KMPVH")=KMPVH
SET KMPPARMS("KMPVSINT")=KMPVSINT
+36 SET KMPPARMS("KMPVSLOT")=KMPVSLOT
+37 MERGE ^KMPTMP("KMPV","VBEM",KMPVNODE,"PARMS")=KMPPARMS
+38 JOB COLLECT(KMPVNODE)
+39 HANG KMPVHANG
End DoDot:1
if KMPVSTOP
QUIT
+40 IF $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969,"I")
DO RU^%ZOSVKR("KMP VBEM DRIVER END")
+41 QUIT
COLLECT(KMPVNODE) ;
+1 NEW $ESTACK,$ETRAP
SET $ETRAP="D ^%ZTER Q"
+2 IF $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969,"I")
DO RU^%ZOSVKR("KMP VBEM COLLECTOR")
+3 NEW B,KMPCNT,KMPDATA,KMPDATE,KMPDONE,KMPETS,KMPINST,KMPLI,KMPMAX,KMPNT,KMPSTAT,KMPTI,KMPVD,KMPVDATA,KMPVFMDAY,KMPVHDAY
+4 NEW KMPVI,KMPVJ,KMPVJTOT,KMPVLN,KMPVN,KMPVO,KMPVOPT,KMPVTIME,KMPVUTOT,KMPVWD
+5 NEW KMPDARR,KMPJMSG
+6 ;
+7 KILL ^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE)
+8 KILL ^KMPTMP("KMPV","VBEM","COMPRESS",KMPVNODE)
+9 MERGE KMPPARMS=^KMPTMP("KMPV","VBEM",KMPVNODE,"PARMS")
+10 SET KMPVSITE=KMPPARMS("KMPVSITE")
SET KMPVSINF=KMPPARMS("KMPVSINF")
+11 SET KMPSC=KMPPARMS("KMPSC")
SET KMPVCHKH=KMPPARMS("KMPVCHKH")
+12 SET KMPVH=KMPPARMS("KMPVH")
SET KMPVSINT=KMPPARMS("KMPVSINT")
+13 SET KMPVSLOT=KMPPARMS("KMPVSLOT")
SET KMPFMDAY=KMPPARMS("KMPFMDAY")
SET U="^"
+14 ;
+15 SET KMPVHDAY=""
+16 FOR
SET KMPVHDAY=$ORDER(^KMPTMP("KMPV","VBEM","DLY",KMPVHDAY))
if (KMPVHDAY="")
QUIT
Begin DoDot:1
+17 SET KMPVTIME=""
+18 FOR
SET KMPVTIME=$ORDER(^KMPTMP("KMPV","VBEM","DLY",KMPVHDAY,KMPVNODE,KMPVTIME))
if KMPVTIME=""
QUIT
Begin DoDot:2
+19 IF KMPVTIME>=KMPVSLOT
IF KMPVHDAY>=+$HOROLOG
QUIT
+20 SET KMPVOPT=""
+21 FOR
SET KMPVOPT=$ORDER(^KMPTMP("KMPV","VBEM","DLY",KMPVHDAY,KMPVNODE,KMPVTIME,KMPVOPT))
if KMPVOPT=""
QUIT
Begin DoDot:3
+22 SET KMPVJ=""
SET KMPVDATA=""
SET KMPVJTOT=""
SET KMPVUTOT=0
+23 FOR
SET KMPVJ=$ORDER(^KMPTMP("KMPV","VBEM","DLY",KMPVHDAY,KMPVNODE,KMPVTIME,KMPVOPT,KMPVJ))
if KMPVJ=""
QUIT
Begin DoDot:4
+24 SET KMPVDATA=$GET(^KMPTMP("KMPV","VBEM","DLY",KMPVHDAY,KMPVNODE,KMPVTIME,KMPVOPT,KMPVJ))
+25 FOR KMPVI=1:1:6
SET $PIECE(KMPVJTOT,"^",KMPVI)=$PIECE(KMPVDATA,"^",KMPVI)+$PIECE(KMPVJTOT,"^",KMPVI)
+26 SET KMPVUTOT=KMPVUTOT+1
End DoDot:4
+27 SET ^KMPTMP("KMPV","VBEM","COMPRESS",KMPVNODE,KMPVHDAY,KMPVTIME,KMPVOPT)=KMPVJTOT_"^"_KMPVUTOT
End DoDot:3
+28 ; Kill node once all data compiled in 'compress' node
KILL ^KMPTMP("KMPV","VBEM","DLY",KMPVHDAY,KMPVNODE,KMPVTIME)
End DoDot:2
End DoDot:1
+29 ; PROCESS 'COMPRESS' NODE FOR TRANSMISSION
+30 SET KMPVHDAY=""
SET B="|"
+31 FOR
SET KMPVHDAY=$ORDER(^KMPTMP("KMPV","VBEM","COMPRESS",KMPVNODE,KMPVHDAY))
if KMPVHDAY=""
QUIT
Begin DoDot:1
+32 ; IF BETWEEN 1 AND 7 DAYS OLD AND NOT TRANSMITTED SEND WARNING MESSAGE AND ATTEMPT TO TRANSMIT AGAIN
+33 IF KMPVHDAY<(+$HOROLOG-1)
DO CANMSG^KMPUTLW("TRANWARN","VBEM",KMPVSITE,KMPVHDAY)
+34 SET KMPVLN=1
+35 SET KMPVTIME=""
+36 FOR
SET KMPVTIME=$ORDER(^KMPTMP("KMPV","VBEM","COMPRESS",KMPVNODE,KMPVHDAY,KMPVTIME))
if KMPVTIME=""
QUIT
Begin DoDot:2
+37 SET KMPVOPT=""
+38 FOR
SET KMPVOPT=$ORDER(^KMPTMP("KMPV","VBEM","COMPRESS",KMPVNODE,KMPVHDAY,KMPVTIME,KMPVOPT))
if KMPVOPT=""
QUIT
Begin DoDot:3
+39 SET KMPVDATA=$GET(^KMPTMP("KMPV","VBEM","COMPRESS",KMPVNODE,KMPVHDAY,KMPVTIME,KMPVOPT))
+40 SET KMPVO=$TRANSLATE($$EVTPKG^KMPUTLW2(KMPVOPT),"^","|")
+41 SET KMPVD=$TRANSLATE(KMPVDATA,"^","|")
+42 SET ^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE,$JOB,KMPVHDAY,KMPVTIME,KMPVLN)=KMPVO_B_KMPVD
SET KMPVLN=KMPVLN+1
+43 ; eventname|parentevent|eventtype|eventsource|packagenamespace|packagename|occurrences|cputime|r-lines|rcmd|gref|elapsed time|user count
End DoDot:3
End DoDot:2
+44 KILL ^KMPTMP("KMPV","VBEM","COMPRESS",KMPVNODE,KMPVHDAY)
End DoDot:1
+45 ; quit if no data to transmit.
+46 IF '$DATA(^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE,$JOB))
Begin DoDot:1
+47 IF $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969,"I")
DO RU^%ZOSVKR("KMP VBEM COLLECTOR END")
End DoDot:1
QUIT
+48 SET KMPVHDAY=""
+49 FOR
SET KMPVHDAY=$ORDER(^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE,$JOB,KMPVHDAY))
if KMPVHDAY=""
QUIT
Begin DoDot:1
+50 ;supported by ICR #10103
SET KMPVFMDAY=+$$HTFM^XLFDT(KMPVHDAY,1)
+51 ;supported by ICR #10046
SET KMPVWD=$$WORKDAY^XUWORKDY(KMPVFMDAY)
+52 SET KMPDATE=$$SHORTDAT^KMPUTLW(KMPVHDAY,"HOROLOG")
+53 SET KMPVTIME=""
+54 FOR
SET KMPVTIME=$ORDER(^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE,$JOB,KMPVHDAY,KMPVTIME))
if KMPVTIME=""
QUIT
Begin DoDot:2
+55 ; yyy-mm-dd hh:mm:ssZtz
SET KMPTIMES=$$TSTAMP^KMPUTLW(KMPVHDAY_","_KMPVTIME,"HOROLOG",1)
+56 SET KMPETSO=$PIECE(KMPTIMES,"^")
+57 SET KMPUTCO=$PIECE(KMPTIMES,"^",2)
+58 SET KMPUTCE=$PIECE(KMPTIMES,"^",3)
+59 SET KMPDST=$PIECE(KMPTIMES,"^",4)
+60 SET KMPVN=$PIECE(KMPVNODE,":")
+61 SET KMPINST=$PIECE(KMPVNODE,":",2)
SET KMPNT=$$NODETYPE^KMPUTLW(KMPINST)
+62 SET KMPJSON=##class(%DynamicObject).%New()
+63 SET KMPJSON.Function="VBEM"
+64 DO SITE^KMPUTLW(KMPJSON)
+65 SET KMPJMSG=##class(%DynamicObject).%New()
+66 SET KMPJMSG.Date=KMPDATE
+67 SET KMPJMSG.Workday=KMPVWD
+68 SET KMPJMSG.Timestamp=KMPETSO
+69 SET KMPJMSG.UtcOdbc=KMPUTCO
+70 SET KMPJMSG.UtcEpoch=KMPUTCE
+71 SET KMPJMSG.IsDst=KMPDST
+72 SET KMPJMSG.Node=KMPVN
SET KMPJMSG.NodeType=KMPNT
+73 SET KMPJMSG.Instance=KMPINST
+74 SET KMPJSON.MessageData=KMPJMSG
+75 SET KMPDARR=##class(%DynamicArray).%New()
+76 SET KMPVLINE=""
+77 FOR
SET KMPVLINE=$ORDER(^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE,$JOB,KMPVHDAY,KMPVTIME,KMPVLINE))
if KMPVLINE=""
QUIT
Begin DoDot:3
+78 SET KMPDET=$GET(^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE,$JOB,KMPVHDAY,KMPVTIME,KMPVLINE))
+79 DO KMPDARR.%Push(KMPDET)
End DoDot:3
+80 SET KMPJSON.Details=KMPDARR
+81 SET KMPSTAT=$$POST^KMPUTLW(KMPJSON,"/businessevent",1,"VBEM")
+82 IF +KMPSTAT'=200
HANG 30
SET KMPSTAT=$$POST^KMPUTLW(KMPJSON,"/businessevent",1,"VBEM")
+83 KILL ^KMPTMP("KMPV","VBEM","TRANSMIT",KMPVNODE,$JOB,KMPVHDAY,KMPVTIME)
+84 SET ^XTMP("KMP "_KMPFMDAY,"VBEM","HTTP",KMPVNODE,$PIECE($HOROLOG,",",2))=KMPSTAT
+85 IF +KMPSTAT'=200
DO SETRETRY
End DoDot:2
End DoDot:1
+86 IF $$GETVAL^KMPVCCFG("VBEM","ONOFF",8969,"I")
DO RU^%ZOSVKR("KMP VBEM COLLECTOR END")
+87 QUIT
+88 ;
SETRETRY ;
+1 NEW KMPTEXT
+2 SET KMPTEXT("SUBJECT")="VSM FAILED SEND: VBEM at "_KMPJSON.Site.SiteCode
+3 SET KMPTEXT(1)="Status Code: "_+KMPSTAT
+4 SET KMPTEXT(2)="Status Text: "_$PIECE(KMPSTAT,"^",2)
+5 SET KMPTEXT(3)="Response Time: "_$PIECE(KMPSTAT,"^",3)
+6 SET KMPTEXT(4)="Node: "_KMPVNODE
+7 DO INFOMSG^KMPUTLW(.KMPTEXT)
+8 SET ^KMPTMP("KMPV","VBEM","RETRY",KMPVNODE,+$HOROLOG,$HOROLOG)=KMPJSON.%ToJSON()
+9 QUIT
+10 ;
RETRY ; retry failed POSTS
+1 NEW KMPDAY,KMPI,KMPJSON,KMPSTAT,KMPVNODE,Y
+2 ;
+3 ;supported by ICR #10097
DO GETENV^%ZOSV
SET KMPVNODE=$PIECE(Y,"^",3)_":"_$PIECE($PIECE(Y,"^",4),":",2)
+4 SET KMPDAY=""
+5 FOR
SET KMPDAY=$ORDER(^KMPTMP("KMPV","VBEM","RETRY",KMPVNODE,KMPDAY))
if KMPDAY=""
QUIT
Begin DoDot:1
+6 SET KMPI=""
+7 FOR
SET KMPI=$ORDER(^KMPTMP("KMPV","VBEM","RETRY",KMPVNODE,KMPDAY,KMPI))
if KMPI=""
QUIT
Begin DoDot:2
+8 SET KMPJSON=$GET(^KMPTMP("KMPV","VBEM","RETRY",KMPVNODE,KMPDAY,KMPI))
+9 SET KMPSTAT=$$POST^KMPUTLW({}.%FromJSON(KMPJSON),"/businessevent",1,"VBEM")
+10 IF +KMPSTAT=200
KILL ^KMPTMP("KMPV","VBEM","RETRY",KMPVNODE,KMPDAY,KMPI)
+11 HANG $RANDOM(10)
End DoDot:2
End DoDot:1
+12 QUIT