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

ENFAEIL.m

Go to the documentation of this file.
  1. ENFAEIL ;(WIRMFO)/SAB-EDIT CMR AND NATIONAL EIL FILES ;12/17/1998
  1. ;;7.0;ENGINEERING;**39,60**;AUG 17, 1993
  1. ;
  1. EIL ; Enter/Edit National EIL file - called by option ENFA EIL
  1. W !!,"The National EIL file should only be changed at the direction of"
  1. W !,"VACO. If the cost center associated with an EIL code is changed"
  1. W !,"then FR Documents will automatically be generated in order to"
  1. W !,"update the cost center value in Fixed Assets. A FR Document will"
  1. W !,"be sent for each equipment item that belongs to a CMR that starts"
  1. W !,"with the EIL code and is currently established in Fixed Assets."
  1. EILASK ;
  1. W !
  1. S DLAYGO=6914.9
  1. S DIC="^ENG(6914.9,",DIC(0)="AQELMZ"
  1. D ^DIC K DLAYGO G:Y'>0 EILX
  1. S ENEIL("DA")=+Y,ENEIL=$P(Y,U,2),ENEIL("CC",0)=$P(Y(0),U,3)
  1. ;
  1. L +^ENG(6914.9,ENEIL("DA")):5 I '$T W $C(7),!,"Another user is editing this EIL. Please try again later." G EILASK
  1. ;
  1. S DIE=DIC,DR="1;2",DA=ENEIL("DA") D ^DIE
  1. ;
  1. S ENEIL("CC")=$P($G(^ENG(6914.9,ENEIL("DA"),0)),U,3)
  1. I ENEIL("CC")]"",ENEIL("CC")'=ENEIL("CC",0) D
  1. . W !,"Since the COST CENTER was changed, FR Documents will be sent"
  1. . W !,"for appropriate equipment associated with the EIL."
  1. . ; confirm cost center change
  1. . S DIR(0)="Y",DIR("A")="Did you really want to change the cost center"
  1. . D ^DIR K DIR I 'Y D Q
  1. . . W !,"Restoring the EIL's cost center to it's previous value..."
  1. . . S DIE="^ENG(6914.9,",DA=ENEIL("DA")
  1. . . S DR=$S(ENEIL("CC",0)]"":"2///^S X=ENEIL(""CC"",0)",1:"2///@")
  1. . . D ^DIE K DIE,DR,DA
  1. . W !,"Generating FR Documents..."
  1. . K ^TMP($J)
  1. . S X=$$FREIL(ENEIL)
  1. . W X," sent."
  1. . I $D(^TMP($J)) D FRERR K ^TMP($J)
  1. L -^ENG(6914.9,ENEIL("DA"))
  1. ;
  1. G EILASK
  1. ;
  1. EILX ;
  1. K DA,DIC,DIE,DR,DTOUT,X,Y
  1. K ENEIL
  1. Q
  1. ;
  1. CMR ; Enter/Edit CMR file - called by option ENCMR
  1. CMRASK ;
  1. W !
  1. S DLAYGO=6914.1
  1. S DIC="^ENG(6914.1,",DIC(0)="AQELMZ"
  1. D ^DIC K DLAYGO G:Y'>0 CMRX
  1. S ENCMR("DA")=+Y,ENCMR=$P(Y,U,2)
  1. S ENCMR("SN",0)=$P($G(^ENG(6914.1,ENCMR("DA"),0)),U,7)
  1. ;
  1. L +^ENG(6914.1,ENCMR("DA")):5 I '$T W $C(7),!,"Another user is editing this CMR. Please try again later." G CMRASK
  1. ;
  1. S DIE=DIC,DR=".01:99",DA=ENCMR("DA") D ^DIE
  1. ;
  1. I $D(^ENG(6914.1,ENCMR("DA"),0)),$E($P(^(0),U),1,5)'=$E(ENCMR,1,5) D
  1. . W !!,"The first five digits of the CMR name were changed. This change"
  1. . W !,"affects all equipment records which point to this CMR."
  1. . W !,"The computer will automatically generate FR Documents for"
  1. . W !,"appropriate capitalized equipment on this CMR to update Fixed"
  1. . W !,"Assets (FAP) with the new department and cost center.",!
  1. . I '$D(^XUSEC("ENFACS",DUZ)) D Q
  1. . . W !,"Since you do not hold the security key for sending documents"
  1. . . W !,"to FAP ('ENFACS'), the system can't send FR Documents."
  1. . . W !,"Therefore, the CMR name can only be changed if none of the"
  1. . . W !,"equipment on the CMR is reported to FAP."
  1. . . W !!,"Checking equipment..."
  1. . . S ENCMR("FAP")=0,ENEQ("DA")=0
  1. . . F S ENEQ("DA")=$O(^ENG(6914,"AD",ENCMR("DA"),ENEQ("DA"))) Q:'ENEQ("DA") I +$$CHKFA^ENFAUTL(ENEQ("DA")) S ENCMR("FAP")=1 Q
  1. . . I ENCMR("FAP") D
  1. . . . W "one or more items are reported to FAP.",$C(7)
  1. . . . W !,"Sorry, I must restore this CMR to it's previous name."
  1. . . . S DIE="^ENG(6914.1,",DA=ENCMR("DA"),DR=".01///^S X=ENCMR" D ^DIE
  1. . . I 'ENCMR("FAP") W "none reported to FAP. Name change accepted."
  1. . ; confirm name change
  1. . S DIR(0)="Y",DIR("A")="Did you really want to change the CMR name"
  1. . D ^DIR K DIR I 'Y D Q
  1. . . W !,"Restoring CMR to previous name..."
  1. . . S DIE="^ENG(6914.1,",DA=ENCMR("DA"),DR=".01///^S X=ENCMR" D ^DIE
  1. . W !,"Generating FR Documents..."
  1. . K ^TMP($J)
  1. . S X=$$FRCMR(ENCMR("DA"))
  1. . W X," sent."
  1. . I $D(^TMP($J)) D FRERR K ^TMP($J)
  1. ;
  1. S ENCMR("SN")=$P($G(^ENG(6914.1,ENCMR("DA"),0)),U,7)
  1. I ENCMR("SN")]"",ENCMR("SN")'=ENCMR("SN",0) D
  1. . W !!,"Since a new station number was entered, the computer will"
  1. . W !,"attempt to update the station numbers of equipment on this CMR."
  1. . S DA=ENCMR("DA") D CMRSTA^ENFAUTL
  1. ;
  1. L -^ENG(6914.1,ENCMR("DA"))
  1. ;
  1. G CMRASK
  1. CMRX ;
  1. K DA,DIC,DIE,DR,DTOUT,X,Y
  1. K ENCMR,ENEQ
  1. Q
  1. ;
  1. FREIL(ENEIL) ; Batch Send FR Documents for equipment on EIL
  1. ; Input
  1. ; ENEIL - EIL code
  1. ; Returns number of FR Documents sent
  1. ; Output
  1. ; (optional) ^TMP($J,"BAD",equipment ien,line#)=validation problem
  1. N ENC,ENCMR
  1. S ENC=0
  1. ; check format of EIL
  1. Q:ENEIL'?2E ENC
  1. ; loop thru CMRs that begin with the EIL
  1. S ENCMR=ENEIL_$C(9) ; force non-numeric
  1. F S ENCMR=$O(^ENG(6914.1,"B1",ENCMR)) Q:$E(ENCMR,1,2)'=ENEIL D
  1. . S ENCMR("DA")=0
  1. . F S ENCMR("DA")=$O(^ENG(6914.1,"B1",ENCMR,ENCMR("DA"))) Q:'ENCMR("DA") S ENC=ENC+$$FRCMR(ENCMR("DA"))
  1. Q ENC
  1. ;
  1. FRCMR(ENCMRI) ; Batch Send FR Documents for equipment on CMR
  1. ; This code is used to generate FR Documents without user interaction.
  1. ; It is called when a batch of FR Documents are being sent due to
  1. ; a change of CMR name or EIL cost center.
  1. ; Input
  1. ; ENCMRI - ien of CMR
  1. ; Returns number of FR Documents sent
  1. ; Output
  1. ; (optional) ^TMP($J,"BAD",equipment ien,line#)=validation problem
  1. ;
  1. N ENBAT,ENC,ENDO,ENEQ,ENFA,ENFAP,ENFR,ENX
  1. ;W !,?5,"CMR: ",$P($G(^ENG(6914.1,ENCMRI,0)),U)
  1. S ENC=0,ENBAT("SILENT")=1
  1. ; loop thru equipment on cmr
  1. S ENEQ("DA")=0
  1. F S ENEQ("DA")=$O(^ENG(6914,"AD",ENCMRI,ENEQ("DA"))) Q:'ENEQ("DA") D
  1. . S ENX=$$CHKFA^ENFAUTL(ENEQ("DA"))
  1. . Q:+ENX=0 ; don't send FR when equipment not reported to FAP
  1. . ;W !,?10,"ENTRY #: ",ENEQ("DA")
  1. . S ENFA("DA")=$P(ENX,U,4)
  1. . F I=1,2,3,8,9 S ENEQ(I)=$G(^ENG(6914,ENEQ("DA"),I))
  1. . ; create and send a FR document
  1. . S ENDO=1,ENFR("DA")=""
  1. . D ADDFR^ENFAXFR
  1. . D:ENDO
  1. . . ; populate FR Document
  1. . . S ENFAP(100)=$G(^ENG(6915.6,ENFR("DA"),100))
  1. . . S $P(ENFAP(100),U,2)=$P(ENEQ(9),U,7) ; fund (required)
  1. . . S $P(ENFAP(100),U,3)=$P(ENEQ(9),U,8) ; a/o (required)
  1. . . S $P(ENFAP(100),U,5)=$P(ENEQ(9),U,6) ; boc (deleted when blank sent)
  1. . . S $P(ENFAP(100),U,6)=$P(ENEQ(2),U,9) ; cmr (determines cost ctr)
  1. . . S ^ENG(6915.6,ENFR("DA"),100)=ENFAP(100)
  1. . D:ENDO CVTDATA^ENFAXFR
  1. . D:ENDO
  1. . . S ENFAP("DOC")="FR" D ^ENFAVAL
  1. . . I $D(^TMP($J,"BAD",ENEQ("DA"))) S ENDO=0
  1. . I 'ENDO,$G(ENFR("DA"))]"" D
  1. . . S DA=ENFR("DA"),DIK="^ENG(6915.6," D ^DIK K DIK
  1. . I ENDO D ^ENFAXMT S ENC=ENC+1
  1. . I $G(ENFR("DA"))]"" L -^ENG(6915.6,ENFR("DA"))
  1. Q ENC
  1. ;
  1. FRERR ; List equipment whose FR failed validation
  1. ; Input
  1. ; ^TMP($J,"BAD",equipment ien,line#)=validation problem
  1. Q:'$D(^TMP($J,"BAD"))
  1. N ENDA,ENI
  1. W !!,"FR Documents could not be created for some equipment items."
  1. S ENDA=0 F S ENDA=$O(^TMP($J,"BAD",ENDA)) Q:'ENDA D
  1. . W !!,?2,"Equipment Entry #",ENDA,"'s FR Document invalid because"
  1. . F ENI=1:1 Q:'$D(^TMP($J,"BAD",ENDA,ENI)) W !,?4,^(ENI)
  1. Q
  1. ;
  1. ;ENFAEIL