ENY2REP7 ;;(WIRMFO)/DH-Print Y2K Sum by CSN ;8.7.98
;;7.0;ENGINEERING;**51,55**;August 17, 1993
;
; extension of ^ENY2REP1
;
CSN ; summary by category stock number
; csn initialization
S CSN(0)=0 F S CSN(0)=$O(^ENG(6914,"J",CSN(0))) Q:'CSN(0) S ^TMP($J,STATION("PARNT"),"COUNT",CSN(0))=0 F J=0,"NA","FC","NC","CC" S ^TMP($J,STATION("PARNT"),CSN(0),J)=0
; end csn initialization
; begin data gather
S CSN(0)=0,STATION=STATION("PARNT") F S CSN(0)=$O(^ENG(6914,"J",CSN(0))) Q:'CSN(0) K:'$D(^ENCSN(6917,CSN(0),0)) ^ENG(6914,"J",CSN(0)) I $D(^ENCSN(6917,CSN(0),0)) S (DA,COUNT)=0 F S DA=$O(^ENG(6914,"J",CSN(0),DA)) Q:'DA D
. Q:'$D(^ENG(6914,DA,0))
. I "^4^5^"[(U_$P($G(^ENG(6914,DA,3)),U)_U) Q
. I '$D(ZTQUEUED),'(DA#100) W "." ; activity indicator
. S Y2K=$P($G(^ENG(6914,DA,11)),U) S:Y2K="" Y2K=0
. I ENSUP,"^NA^FC^"[(U_Y2K_U) Q
. ; initialize station if need be
. I ENSTN S STATION=$S($P($G(^ENG(6914,DA,9)),U,5)]"":$P(^(9),U,5),1:STATION("PARNT")) D:'$D(^TMP($J,STATION))
.. S TOTAL(STATION)=0 F J=0,"FC","NC","CC","NA" S TOTAL(STATION,J)=0
.. S CSN(1)=0 F S CSN(1)=$O(^ENG(6914,"J",CSN(1))) Q:'CSN(1) S ^TMP($J,STATION,"COUNT",CSN(1))=0 F J=0,"FC","NC","CC","NA" S ^TMP($J,STATION,CSN(1),J)=0
.. ; end initialization
. S ^TMP($J,STATION,"COUNT",CSN(0))=^TMP($J,STATION,"COUNT",CSN(0))+1,^TMP($J,STATION,CSN(0),Y2K)=^TMP($J,STATION,CSN(0),Y2K)+1
. S TOTAL(STATION,Y2K)=TOTAL(STATION,Y2K)+1,TOTAL(STATION)=TOTAL(STATION)+1
. ; end data gather
; begin sort
S STATION=0 F S STATION=$O(^TMP($J,STATION)) Q:STATION="" S CSN(0)=0 F S CSN(0)=$O(^TMP($J,STATION,"COUNT",CSN(0))) Q:'CSN(0) S COUNT=^TMP($J,STATION,"COUNT",CSN(0)) I COUNT D
. I $E(ENSORT)="C" D Q
.. I $G(ENSORT("MIN"))>COUNT Q
.. S ^TMP($J,STATION,"SORT",COUNT,CSN(0))=""
. S CSN=$P($G(^ENCSN(6917,CSN(0),0)),U) S:CSN="" CSN=0 S ^TMP($J,STATION,"SORT",CSN,CSN(0))=""
. ; end sort
; print the list
U IO
S STATION=0 F S STATION=$O(^TMP($J,STATION)) Q:STATION=""!($G(ESCAPE)) D Q:$G(ESCAPE) D HOLD Q:$G(ESCAPE)
. D HEADR
. I '$D(^TMP($J,STATION,"SORT")) W !!,"** No records to print **" Q
. I $E(ENSORT)="C" S J=99999 F S J=$O(^TMP($J,STATION,"SORT",J),-1) Q:'J!($G(ESCAPE)) S CSN(0)=0 F S CSN(0)=$O(^TMP($J,STATION,"SORT",J,CSN(0))) Q:'CSN(0) D PRTCSN Q:$G(ESCAPE) ; J => count
. I $E(ENSORT)="A" S J="" F S J=$O(^TMP($J,STATION,"SORT",J)) Q:J=""!($G(ESCAPE)) S CSN(0)=0 F S CSN(0)=$O(^TMP($J,STATION,"SORT",J,CSN(0))) Q:'CSN(0) D PRTCSN Q:$G(ESCAPE) ; J => category stock number
. D TOTALS
K ENTYPE,ENSUP,ENSORT,ENSTN
G EXIT
;
PRTCSN I ENSUP W !,$P(^ENCSN(6917,CSN(0),0),U)_" "_$E($P(^(0),U,3),1,30),?42,$J(^TMP($J,STATION,CSN(0),"NC"),5),?49,$J(^("CC"),5),?63,$J(^(0),5),?71,$J(^TMP($J,STATION,"COUNT",CSN(0)),5)
I 'ENSUP W !,$P(^ENCSN(6917,CSN(0),0),U)_" "_$E($P(^(0),U,3),1,25),?35,$J(^TMP($J,STATION,CSN(0),"FC"),5),?42,$J(^("NC"),5),?49,$J(^("CC"),5),?56,$J(^("NA"),5),?63,$J(^(0),5),?71,$J(^TMP($J,STATION,"COUNT",CSN(0)),5)
S LINE=LINE+1 I (IOSL-LINE)'>4 D HOLD Q:$G(ESCAPE) I $O(^TMP($J,STATION,"SORT",J,CSN(0)))!($O(^TMP($J,STATION,"SORT",J))]"")!($O(^TMP($J,STATION))]"") D HEADR
Q
;
TOTALS ;
Q:$G(ESCAPE)!($G(ENSORT("MIN"))>1) ; skip totals if printing high counts only
K X S $P(X,"-",79)="-" W !,X
I ENSUP W !,"TOTALS",?42,$J(TOTAL(STATION,"NC"),5),?49,$J(TOTAL(STATION,"CC"),5),?63,$J(TOTAL(STATION,0),5),?71,$J(TOTAL(STATION),5)
I 'ENSUP W !,"TOTALS",?35,$J(TOTAL(STATION,"FC"),5),?42,$J(TOTAL(STATION,"NC"),5),?49,$J(TOTAL(STATION,"CC"),5),?56,$J(TOTAL(STATION,"NA"),5),?63,$J(TOTAL(STATION,0),5),?71,$J(TOTAL(STATION),5)
Q
;
HEADR ; header for summary listing
W:PAGE>0!($E(IOST,1,2)="C-") @IOF S PAGE=PAGE+1,LINE=4
W "Y2K Data by CATEGORY STOCK NUMBER",?45,DATE("PRNT"),?70,"Page: "_PAGE
W !,$S('ENSTN:"Consolidated ("_STATION("PARNT")_") ",1:"Station: "_STATION_" ")
I ENSUP W "(Y2K CATEGORIES 'FC' and 'NA' are being ignored.)"
W !,"CATEGORY STOCK NUMBER",?38,"FC",?45,"NC",?52,"CC",?59,"NA",?64,"NULL",?71,"TOTAL"
K X S $P(X,"-",79)="-" W !,X
Q
;
HOLD Q:$E(IOST,1,2)'="C-"
W !!,"Press <RETURN> to continue, '^' to escape..." R X:DTIME
I '$T!($E(X)="^") S ESCAPE=1
Q
EXIT ;
Q
;ENY2REP7
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HENY2REP7 4235 printed Nov 22, 2024@17:07:39 Page 2
ENY2REP7 ;;(WIRMFO)/DH-Print Y2K Sum by CSN ;8.7.98
+1 ;;7.0;ENGINEERING;**51,55**;August 17, 1993
+2 ;
+3 ; extension of ^ENY2REP1
+4 ;
CSN ; summary by category stock number
+1 ; csn initialization
+2 SET CSN(0)=0
FOR
SET CSN(0)=$ORDER(^ENG(6914,"J",CSN(0)))
if 'CSN(0)
QUIT
SET ^TMP($JOB,STATION("PARNT"),"COUNT",CSN(0))=0
FOR J=0,"NA","FC","NC","CC"
SET ^TMP($JOB,STATION("PARNT"),CSN(0),J)=0
+3 ; end csn initialization
+4 ; begin data gather
+5 SET CSN(0)=0
SET STATION=STATION("PARNT")
FOR
SET CSN(0)=$ORDER(^ENG(6914,"J",CSN(0)))
if 'CSN(0)
QUIT
if '$DATA(^ENCSN(6917,CSN(0),0))
KILL ^ENG(6914,"J",CSN(0))
IF $DATA(^ENCSN(6917,CSN(0),0))
SET (DA,COUNT)=0
FOR
SET DA=$ORDER(^ENG(6914,"J",CSN(0),DA))
if 'DA
QUIT
Begin DoDot:1
+6 if '$DATA(^ENG(6914,DA,0))
QUIT
+7 IF "^4^5^"[(U_$PIECE($GET(^ENG(6914,DA,3)),U)_U)
QUIT
+8 ; activity indicator
IF '$DATA(ZTQUEUED)
IF '(DA#100)
WRITE "."
+9 SET Y2K=$PIECE($GET(^ENG(6914,DA,11)),U)
if Y2K=""
SET Y2K=0
+10 IF ENSUP
IF "^NA^FC^"[(U_Y2K_U)
QUIT
+11 ; initialize station if need be
+12 IF ENSTN
SET STATION=$SELECT($PIECE($GET(^ENG(6914,DA,9)),U,5)]"":$PIECE(^(9),U,5),1:STATION("PARNT"))
if '$DATA(^TMP($JOB,STATION))
Begin DoDot:2
+13 SET TOTAL(STATION)=0
FOR J=0,"FC","NC","CC","NA"
SET TOTAL(STATION,J)=0
+14 SET CSN(1)=0
FOR
SET CSN(1)=$ORDER(^ENG(6914,"J",CSN(1)))
if 'CSN(1)
QUIT
SET ^TMP($JOB,STATION,"COUNT",CSN(1))=0
FOR J=0,"FC","NC","CC","NA"
SET ^TMP($JOB,STATION,CSN(1),J)=0
+15 ; end initialization
End DoDot:2
+16 SET ^TMP($JOB,STATION,"COUNT",CSN(0))=^TMP($JOB,STATION,"COUNT",CSN(0))+1
SET ^TMP($JOB,STATION,CSN(0),Y2K)=^TMP($JOB,STATION,CSN(0),Y2K)+1
+17 SET TOTAL(STATION,Y2K)=TOTAL(STATION,Y2K)+1
SET TOTAL(STATION)=TOTAL(STATION)+1
+18 ; end data gather
End DoDot:1
+19 ; begin sort
+20 SET STATION=0
FOR
SET STATION=$ORDER(^TMP($JOB,STATION))
if STATION=""
QUIT
SET CSN(0)=0
FOR
SET CSN(0)=$ORDER(^TMP($JOB,STATION,"COUNT",CSN(0)))
if 'CSN(0)
QUIT
SET COUNT=^TMP($JOB,STATION,"COUNT",CSN(0))
IF COUNT
Begin DoDot:1
+21 IF $EXTRACT(ENSORT)="C"
Begin DoDot:2
+22 IF $GET(ENSORT("MIN"))>COUNT
QUIT
+23 SET ^TMP($JOB,STATION,"SORT",COUNT,CSN(0))=""
End DoDot:2
QUIT
+24 SET CSN=$PIECE($GET(^ENCSN(6917,CSN(0),0)),U)
if CSN=""
SET CSN=0
SET ^TMP($JOB,STATION,"SORT",CSN,CSN(0))=""
+25 ; end sort
End DoDot:1
+26 ; print the list
+27 USE IO
+28 SET STATION=0
FOR
SET STATION=$ORDER(^TMP($JOB,STATION))
if STATION=""!($GET(ESCAPE))
QUIT
Begin DoDot:1
+29 DO HEADR
+30 IF '$DATA(^TMP($JOB,STATION,"SORT"))
WRITE !!,"** No records to print **"
QUIT
+31 ; J => count
IF $EXTRACT(ENSORT)="C"
SET J=99999
FOR
SET J=$ORDER(^TMP($JOB,STATION,"SORT",J),-1)
if 'J!($GET(ESCAPE))
QUIT
SET CSN(0)=0
FOR
SET CSN(0)=$ORDER(^TMP($JOB,STATION,"SORT",J,CSN(0)))
if 'CSN(0)
QUIT
DO PRTCSN
if $GET(ESCAPE)
QUIT
+32 ; J => category stock number
IF $EXTRACT(ENSORT)="A"
SET J=""
FOR
SET J=$ORDER(^TMP($JOB,STATION,"SORT",J))
if J=""!($GET(ESCAPE))
QUIT
SET CSN(0)=0
FOR
SET CSN(0)=$ORDER(^TMP($JOB,STATION,"SORT",J,CSN(0)))
if 'CSN(0)
QUIT
DO PRTCSN
if $GET(ESCAPE)
QUIT
+33 DO TOTALS
End DoDot:1
if $GET(ESCAPE)
QUIT
DO HOLD
if $GET(ESCAPE)
QUIT
+34 KILL ENTYPE,ENSUP,ENSORT,ENSTN
+35 GOTO EXIT
+36 ;
PRTCSN IF ENSUP
WRITE !,$PIECE(^ENCSN(6917,CSN(0),0),U)_" "_$EXTRACT($PIECE(^(0),U,3),1,30),?42,$JUSTIFY(^TMP($JOB,STATION,CSN(0),"NC"),5),?49,$JUSTIFY(^("CC"),5),?63,$JUSTIFY(^(0),5),?71,$JUSTIFY(^TMP($JOB,STATION,"COUNT",CSN(0)),5)
+1 IF 'ENSUP
WRITE !,$PIECE(^ENCSN(6917,CSN(0),0),U)_" "_$EXTRACT($PIECE(^(0),U,3),1,25),?35,$JUSTIFY(^TMP($JOB,STATION,CSN(0),"FC"),5),?42,$JUSTIFY(^("NC"),5),?49,$JUSTIFY(^("CC"),5),?56,$JUSTIFY(^("NA"),5),?63,$JUSTIFY(^(0),5),?71,...
... $JUSTIFY(^TMP($JOB,STATION,"COUNT",CSN(0)),5)
+2 SET LINE=LINE+1
IF (IOSL-LINE)'>4
DO HOLD
if $GET(ESCAPE)
QUIT
IF $ORDER(^TMP($JOB,STATION,"SORT",J,CSN(0)))!($ORDER(^TMP($JOB,STATION,"SORT",J))]"")!($ORDER(^TMP($JOB,STATION))]"")
DO HEADR
+3 QUIT
+4 ;
TOTALS ;
+1 ; skip totals if printing high counts only
if $GET(ESCAPE)!($GET(ENSORT("MIN"))>1)
QUIT
+2 KILL X
SET $PIECE(X,"-",79)="-"
WRITE !,X
+3 IF ENSUP
WRITE !,"TOTALS",?42,$JUSTIFY(TOTAL(STATION,"NC"),5),?49,$JUSTIFY(TOTAL(STATION,"CC"),5),?63,$JUSTIFY(TOTAL(STATION,0),5),?71,$JUSTIFY(TOTAL(STATION),5)
+4 IF 'ENSUP
WRITE !,"TOTALS",?35,$JUSTIFY(TOTAL(STATION,"FC"),5),?42,$JUSTIFY(TOTAL(STATION,"NC"),5),?49,$JUSTIFY(TOTAL(STATION,"CC"),5),?56,$JUSTIFY(TOTAL(STATION,"NA"),5),?63,$JUSTIFY(TOTAL(STATION,0),5),?71,$JUSTIFY(TOTAL(STATION),5)
+5 QUIT
+6 ;
HEADR ; header for summary listing
+1 if PAGE>0!($EXTRACT(IOST,1,2)="C-")
WRITE @IOF
SET PAGE=PAGE+1
SET LINE=4
+2 WRITE "Y2K Data by CATEGORY STOCK NUMBER",?45,DATE("PRNT"),?70,"Page: "_PAGE
+3 WRITE !,$SELECT('ENSTN:"Consolidated ("_STATION("PARNT")_") ",1:"Station: "_STATION_" ")
+4 IF ENSUP
WRITE "(Y2K CATEGORIES 'FC' and 'NA' are being ignored.)"
+5 WRITE !,"CATEGORY STOCK NUMBER",?38,"FC",?45,"NC",?52,"CC",?59,"NA",?64,"NULL",?71,"TOTAL"
+6 KILL X
SET $PIECE(X,"-",79)="-"
WRITE !,X
+7 QUIT
+8 ;
HOLD if $EXTRACT(IOST,1,2)'="C-"
QUIT
+1 WRITE !!,"Press <RETURN> to continue, '^' to escape..."
READ X:DTIME
+2 IF '$TEST!($EXTRACT(X)="^")
SET ESCAPE=1
+3 QUIT
EXIT ;
+1 QUIT
+2 ;ENY2REP7