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

ACRFUFMI.m

Go to the documentation of this file.
ACRFUFMI ;IHS/OIRM/DSD/AEF - PO ITEMS ORDERED DATA EXTRACT [ 05/11/2007  10:05 AM ]
 ;;2.1;ADMIN RESOURCE MGT SYSTEM;**22**;NOV 05, 2001
 ;NEW ROUTINE FOR UFMS ARMS CORE OPEN DOCUMENT MATCH AND ITEM RETREIVAL;ACR*2.1*22
 ;
DESC ;----- ROUTINE DESCRIPTION    
 ;;Create Items Ordered Flat File
 ;;
 ;;This option will gather LINE item data for ARMS/CORE Open Documents
 ;;match and place them into a UNIX file which can be imported
 ;;into a database
 ;;
 ;;Fields included in the extract file are:f
 ;;     1
 ;;     3 Item Number                   
 ;;     4
 ;;    19 Keyword
 ;;    10 Quantity Required             23 
 ;;    11 Unit of Issue                 24  
 ;;    12 Unit Cost                     25  
 ;;    13                 26 Item Description
 Q  ; MUST ENTER AT LINE LABEL
 ;
ITEMS(ACRDOC,ACRSSDA,ACRCORE,ACRRFIN,ACRIFIN,ACRHIT)      ; EP
 ;----- GET ITEM DATA AND PUT IN ^ACRZ("ITEMS" GLOBAL
 ;
 N X,Z,ACRUI,ACRITM,ACRUCST,ACRKW,ACRDEPT,ACRQTY,ACRCANDA,ACRSINO
 N ACRDLCOD,ACRDESC,ACRMAIL,ACRSHIP,CLOCNAM,CLCODN,ACRECST
 S ACRHIT=0
 D SS(ACRSSDA,.ACRCANDA)
 D HIT1166^ACRFUFMX(ACRDOC,1)              ;RETURNS ACRXX
 I ACRXX=0 D  Q                            ;NOTHING IN PAYMENTS
 .D RR(ACRSSDA)
 .D CAN(ACRCANDA)
 .D SET(ACRSSDA)
 .S ACRHIT=1
 F I=1:1:ACRXX D
 .S ARRAY=$$MATCH2^ACRFUFMU(.ACRXX,I,.ACRV)
 .I ARRAY'=0 D
 ..D 112
 ..D RR(ACRSSDA)
 ..D CAN(ACRCANDA)
 ..D SET(ACRSSDA)
 ..S ACRHIT=1
 Q
SSX(X,N,B,E) ;RETURN PIECE FROM FMS SUPPLIES AND SERVICES FILE
 ;
 ; ENTER:  X = IEN OF FMS SUPPLIES AND SERVICES FILE
 ;         N = NODE NUMBER OR NAME
 ;         B = BEGIN PIECE NUMBER
 ;         E = END PIECE NUMBER
 ; RETURN: Y = DATA PIECE
 ;  
 N Y
 S Y=""
 I X S Y=$P($G(^ACRSS(X,N)),U,B,E)
 Q Y
LOCB(X) ;EP -- RETURNS DEPARTMENT/PROGRAM POINTER ***
 ;
 ;      X  =  FMS DEPARTMENT ACCOUNT IEN
 ;
 N Y
 S Y=""
 I X S Y=$P($G(^ACRLOCB(X,0)),U,5)         ;FMS DEPARTMENT ACCOUNT
 Q Y
PRG(X) ;EP -- RETURNS DEPARTMENT NAME ***
 ;
 ;      X  =  FMS DEPARTMENT/PROGRAM IEN
 ;
 N Y
 S Y=""
 I X S Y=$P($G(^AUTTPRG(X,0)),U)           ;FMS DEPARTMENT/PROGRAM
 Q Y
 ;
SS(X,ACRCANDA) ;SET VARIABLES FROM THE FMS SUPPLIES AND SERVICES FILE
 ;
 N DPTR,PRGPTR
 S ACRITM=$$SSX(X,0,1,1)                   ; ITEM NUMBER IN DOC
 S ACRCANDA=$$SSX(X,0,5,5)                  ; COMMON ACCOUNTING NUMBER POINTER
 S DPTR=$$SSX(X,0,6,6)                     ; DEPARTMENT ACCOUNT POINTER
 S ACRSINO=$$SSX(X,0,12,12)                ; ARMS STANDARD ITEM
 S ACRQTY=$$SSX(X,"DT",1,1)                ; QUANTITY REQUESTED
 S ACRKW=$$SSX(X,"NMS",5,5)                ; KEYWORD
 S ACRUCST=$$SSX(X,"DT",3,3)               ; UNIT COST
 S ACRUI=$$UI(X)                           ; UNIT OF ISSUE
 S ACRECST=$$SSX(X,"DT",4,4)               ; ESTIMATED COST
 I ACRQTY="",ACRUCST="",ACRUI="" D
 .I ACRECST>0 S ACRQTY=1,ACRUI="USD",ACRUCST=ACRECST
 S ACRQRCD=$$SSX(X,"DT",5,5)               ; QUANTITY RECEIVED
 S ACRQACP=$$SSX(X,"DT",6,6)               ; QUANTITY ACCEPTED
 I ACRQACP=""!(ACRQACP=0) S ACRQRCD=0      ; REMOVE FALSE RECEIVED
 S ACRAPD=""                               ; AMOUNT PAID
 S ACRQDI=$$SSX(X,"DT",14,14)              ; QUANTITY DUE IN
 S PRGPTR=$$LOCB(DPTR)                     ; POINTER TO FMS LOCB/PROG
 S ACRDESC=$$IDESC(X)                      ; ITEM DESCRIPTION TEXT
 S ACRDEPT=$$PRG(PRGPTR)                   ; DEPT NAME
 S ACRDLCOD=$$LCODN(DPTR)
 Q
CAN(X) ;
 N CAN0,DFLT,SHIP,MAIL,DFLT2,CLCOD,CLOC,CLOCPTR,ACRTYPE
 S (ACRMAIL,ACRSHIP,CLOCNAM)=""
 S ACRTYPE=$P(ACRCORE,U,2)       ;DOC-TYPE
 Q:'X
 S CAN0=$G(^ACRCAN(X,0))
 S DFLT=$G(^ACRCAN(X,"DFLT"))
 S SHIP=$P(DFLT,U,11)                  ;'SHIP TO' DEPT/PRG PTR
 S MAIL=$P(DFLT,U,12)                  ;'MAIL INV TO' DEPT/PRG PTR
 I ACRTYPE="TN" D
 .S DFLT2=$G(^ACRCAN(X,"DFLT2"))
 .S:SHIP="" SHIP=$P(DFLT2,U,2)         ;'TRAINING OFFICE' DEPT/PRG PTR
 .S:MAIL="" MAIL=$P(DFLT2,U,1)         ;'MAIL TRAINING INV TO' DEPT/PRG PTR
 S:MAIL ACRMAIL=$$PRG(MAIL)
 S:SHIP ACRSHIP=$$PRG(SHIP)
 S CLCOD=$P(CAN0,U,7)                      ;CAN LOCATION CODE PTR ^AUTTLCOD
 S CLCODN=$$LCODE(CLCOD)                   ;CAN LOCATION CODE NAME
 S CLOC=$P(CAN0,U,17)                ;LOCATION PTR ^AUTTLOC
 I CLOC D
 .S CLOCPTR=$P($G(^AUTTLOC(CLOC,0)),U)      ;LOCATION NAME
 .S:CLOCPTR CLOCNAM=$P($G(^DIC(4,CLOCPTR,0)),U)
 Q
ITEMSDHR(ARRAY,ACRCORE) ;EP -- FINDS ITEMS FROM FMS DOCUMENT HISTORY RECORDS FILE MATCH
 ;
 ;    ARRAY   =  ACRSTRING DATA _"@"_ACRZ_U_ACRCAN_U_ACROCC_U_ACRAMT_U_ACRIFIN
 N Y,ACRUI,ACRITM,ACRUCST,ACRKW,ACRDEPT,ACRQTY,ACRCANDA,ACRSINO,ACRECST
 N ACRDLCOD,ACRTMP,ACRZ,ACRDESC,ACRMAIL,ACRSHIP,CLOCNAM,CLCODN,ACRCST
 S ACRDOC=$P(ARRAY,U)
 S ACRTMP=$P(ARRAY,"@",2)
 S ACRZ=$P(ACRTMP,U)
 S ACRCAN=$P(ACRTMP,U,2)
 S ACROCC=$P(ACRTMP,U,3)
 S ACRCST=$P(ACRTMP,U,4)
 S ACRI=$E($P(ACRTMP,U,6),3)                     ;REVERSE CODE
 S ACRECST=$$DOL^ACRFUFMU(ACRCST,0)
 S ACRUCST=$$DOL^ACRFUFMU(ACRCST,ACRI)           ; DOLLAR AMOUNT
 S ACRIFIN=$P(ACRTMP,U,5)
 S ACRCANDA=$O(^AUTTCAN("B",ACRCAN,0))
 S ACROCCDA=$O(^AUTTOBJC("C",ACROCC,0))
 D CAN(ACRCANDA)
 S ACRDESC=$$DESC11(ACROCCDA)
 D RRDEF                                    ;SET DEFAULTS
 D SET(ACRZ)
 Q
ITEMS11(ARRAY) ;EP -- FINDS ITEMS FROM 1166 APPROVALS FOR PAYMENT FILE MATCH
 ;
 ;    ARRAY   =  ACRSTRING DATA _"@"_ POINTER TO 1166 FILE
 ;
 N Y,ACRUI,ACRITM,ACRUCST,ACRKW,ACRDEPT,ACRQTY,ACRCANDA,ACRSINO,ACRECST
 N ACRDLCOD,ACRTMP,ACRDESC,ACRMAIL,ACRSHIP,CLOCNAM,CLCODN,ACRI
 D 112
 S ACRIFIN=$S(ACRI="05":"OBLIGATION",ACRI="18":"PARTIAL INVOICE",ACRI="19":"FINAL INVOICE",1:ACRTCOD)
 D CAN(ACRCANDA)
 S ACRDESC=$$DESC11(ACROCCDA)
 D RRDEF                              ;DEFAULTS
 D SET(FY_BATCH_SEQ)
 Q
 ; *********************************
112 ; CALLED BY ITEMS AND ITEMS11
 S ACRDOC=$P(ARRAY,U)
 S ACRTMP=$P(ARRAY,"@",2)
 S FY=$P(ACRTMP,U,1)
 S BATCH=$P(ACRTMP,U,2)
 S SEQ=$P(ACRTMP,U,3)
 S ACRTMP=^AFSLAFP(FY,1,BATCH,1,SEQ,0)
 S ACRCANDA=$P(ACRTMP,U,7)
 S ACROCCDA=$P(ACRTMP,U,8)
 S ACRTCOD=$P(ACRTMP,U,18)            ;TRANSACTION CODE
 S ACRI=$E(ACRTCOD,1,2)               ;OBL OR PAYMENT
 S ACRREV=$E(ACRTCOD,3)               ;REVERSAL CODE
 S ACRAPD=+$P(ACRTMP,U,11)            ;AMOUNT PAID
 S:$G(ACRECST)="" ACRECST=ACRAPD
 S:$G(ACRUCST)="" ACRUCST=ACRAPD
 S:ACRREV=2 ACRAPD="-"_ACRAPD         ;MAKE IT NEGATIVE IF REVERSAL = 2
 Q
 ;*****************************
DESC11(OCC) ;----- RETURNS DESCRIPTION LINES 1-5
 ;
 ;      OCC  =  OBJECT CLASS CODE IEN
 N DESC,OCCN,OCCDA
 S DESC="UNKNOWN"
 I 'OCC Q DESC
 S OCCN=$P($G(^AUTTOBJC(OCC,0)),U,3)            ;GET OCC SHORT NAME
 I OCCN="" D
 .S OCCDA=$P($G(^AUTTOBJC(OCC,0)),U,2)
 .I OCCDA S OCCN=$P($G(^AUTTOCG(OCCDA,0)),U,2)  ;GET OCC GROUP NAME
 Q OCCN
 ; ********************************************
SET(Z) ;
 N STR1,STR2,STR3
 S $P(STR1,U,1)=ACRITM                      ; 1; ITEM NUMBER IN DOCUMENT
 S $P(STR1,U,2)=ACRUI                       ; 2; UNIT OF ISSUE
 S $P(STR1,U,3)=ACRQTY                      ; 3; QUANTITY
 S $P(STR1,U,4)=ACRUCST                     ; 4; UNIT COST
 S $P(STR1,U,5)=ACRECST                     ; 5; ESTIMATED COST
 S $P(STR1,U,6)=ACRQRCD                     ; 6; QUANTITY RECEIVED
 S $P(STR1,U,7)=ACRQACP                     ; 7; QUANTITY ACCEPTED
 S $P(STR1,U,8)=ACRQDI                      ; 8; QUANTITY DUE IN
 S $P(STR1,U,9)=ACRRQR                      ; 9; RR QUANTITY RECEIVED
 S $P(STR1,U,10)=ACRRQA                     ;10; RR QUANTITY ACCEPTED
 S $P(STR1,U,11)=ACRRIQ                     ;11; RR INVOICE QUANTITY
 S $P(STR1,U,12)=ACRAPD                     ;12; AMOUNT PAID
 S $P(STR1,U,13)=ACRRFIN                    ;13; FINAL/PARTIAL RR
 S $P(STR1,U,14)=ACRIFIN                    ;14; FINAL/PARTIAL INV 
 ;
 S $P(STR2,U,1)=$E(ACRDESC,1,240)           ; 1; LINE DESCRIPTION
 S $P(STR2,U,2)=ACRKW_U                     ; 2; KEYWORD
 S $P(STR2,U,3)=ACRSINO                     ; 3; ARMS STANDARD ITEM NUMBER
 ;
 S $P(STR3,U,1)=ACRDESC                     ; 1; ITEM DESCRIPTION
 S $P(STR3,U,2)=ACRMAIL                     ; 2; CAN MAIL INVOICE TO LOCATION
 S $P(STR3,U,3)=ACRSHIP                     ; 3; CAN SHIP TO LOCATION
 S $P(STR3,U,4)=ACRDEPT                     ; 4; DEPARTMENT NAME
 S $P(STR3,U,5)=ACRDLCOD                    ; 5; DEPARTMENT LOCATION CODE NAME
 S $P(STR3,U,6)=CLOCNAM                     ; 6; CAN LOCATION
 S $P(STR3,U,7)=CLCODN                      ; 7; CAN LOC CODE NAME
 S STR1=ACRCORE_U_STR1
 Q:$D(^ACRZ("ITEMS",ACRCDOC,Z))             ; ALREADY RECORDED
 S ^ACRZ("ITEMS",ACRCDOC,Z,1)=STR1
 S ^ACRZ("ITEMS",ACRCDOC,Z,2)=STR2
 S ^ACRZ("ITEMS",ACRCDOC,Z,3)=STR3
 S ^ACRZ("ITEMS","TOTAL")=$G(^ACRZ("ITEMS","TOTAL"))+1
 Q
 ;********************************************************
IDESC(X) ;----- RETURNS DESCRIPTION LINES 1-5
 ;
 ;      X  =  ITEM IEN
 N NOTE,DESC,OCC,OCCN,OCCDA
 S (DESC,NOTE)=""
 I 'X Q DESC
 S DESC=$$SSX(X,"DESC",1,5)
 S NOTE=$$SSX(X,"NOTES",1,5)
 I DESC]"" D
 .S:NOTE]"" DESC=DESC_"; "_NOTE
 .S DESC=$TR(DESC,U," ")
 I DESC']"" D
 .S OCC=$$SSX(X,0,4,4)                    ;GET OCC IEN FROM SS
 .S OCCN=$$DESC11(OCC)                    ;GET OCC SHORT NAME
 .S:OCCN]"" DESC=OCCN
 Q DESC
 ;*************************************************************
UI(X) ;----- RETURNS UNIT OF ISSUE   
 ;
 ;      X  =  ITEM IEN
 ;
 N Y
 S Y=""
 I X S Y=$P($G(^ACRSS(X,"DT")),U,2)
 I Y S Y=$P($G(^ACRUI(Y,0)),U)
 Q Y
 ; *************************************************************
ECOST(X) ;----- RETURNS ESTIMATED COST
 ;
 ;      X  =  ITEM IEN
 ;
 N Y
 S Y=""
 I X S Y=$P($G(^ACRSS(X,"DT")),U,4)
 Q Y
 ; *************************************************************
LCOD(X) ;EP -- RETURNS EXTERNAL LOCATION CODE
 ;
 ;      X  =  LOCATION CODE IEN
 ;
 N Y
 S Y=""
 I X S Y=$P($G(^AUTTLCOD(X,0)),U)
 Q Y
 ; *************************************************************
LOCNM(X) ;EP -- RETURNS EXTERNAL LOCATION NAME
 ;      X  =  LOCATION IEN
 ;
 N Y
 S Y=""
 I X S Y=$P($G(^DIC(4,X,0)),U)
 Q Y
 ;***************************************************************
LCODE(X) ;EP -- RETURNS LOCATION CODE NAME
 N Y
 S Y=""
 I X S Y=$P($G(^AUTTLCOD(X,0)),U,2)      ;LOCATION CODE NAME
 Q Y
 ;***************************************************************
LCODN(X) ;EP -- RETURNS LOCATION CODE NAME OF DEPARTMENT ACCOUNT
 ;
 ;      X  =  FMS DEPARTMENT ACCOUNT IEN
 ;
 N Y
 S Y=""
 I X S Y=$P($G(^ACRLOCB(X,"DT")),U,11)         ;LOCATION CODE POINTER
 I Y S Y=$$LCODE(Y)                            ;LOCATION CODE NAME
 Q Y
 ;***************************************************************
RR(X) ; -- RETRIEVES RECEIVING REPORT DATA
 ;         X = FMS SUPPLIES AND SERVICES IEN
 ;
 S ACRRDA=$O(^ACRRR("B",X,0))
 S ACRIFIN="NO INVOICE"
 S ACRRFIN="NO RR"
 I 'ACRRDA D  Q                                ;NO RECEIVING REPORT
 .S (ACRRQR,ACRRQA,ACRRIQ,ACRRIUC)=0
 .S:ACRID["CANCEL" (ACRRFIN,ACRIFIN)="CANCELLED"
 S ACRRR0=$G(^ACRRR(ACRRDA,0))
 S ACRRFIN=$S($P(ACRRR0,U,8)=1:"FINAL RR",2:"PARTIAL RR",1:"NO RR")
 S ACRIFIN=$S($P(ACRRR0,U,11)=1:"FINAL INV",2:"PARTIAL INV",1:"NO INVOICE")
 S ACRRDT=$G(^ACRRR(ACRRDA,"DT"))
 S ACRRUC=$P(ACRRDT,U)                ;UNIT COST
 S ACRRQR=$P(ACRRDT,U,2)              ;QUANTITY RECEIVED
 S ACRRQA=$P(ACRRDT,U,3)              ;QUANTITY ACCEPTED
 I ACRRQA=""!(ACRRQA=0) S ACRRQR=0    ;REMOVE FALSE RECEIVED
 S ACRRIUC=$P(ACRRDT,U,5)             ;INVOICE UNIT COST
 S ACRRIQ=$P(ACRRDT,U,6)              ;INVOICE QUANTITY
 S ACRRIV=$P(ACRRDT,U,7)              ;INVOICE NUMBER
 Q
 ; **************************************************************
RRDEF ;RECEIVING REPORT DEFAULTS
 S (ACRSINO,ACRKW,ACRDEPT,ACRDLCOD,ACRUI)=""
 S (ACRRQR,ACRRQA,ACRRIQ,ACRAPD)=0           ;RECEIVING REPORT DEFAULTS
 S (ACRQTY,ACRQRCD,ACRQACP,ACRITM)=0         ;SUPPLIES & SERVICES DEFAULTS
 S ACRQDI=1
 S ACRRFIN="NO RR"
 I ACRIFIN'["OBLIGATION" D
 .S (ACRQTY,ACRQRCD,ACRQACP,ACRITM)=1
 .S (ACRRQR,ACRRQA,ACRRIQ)=1                 ;RECEIVING REPORT DEFAULTS
 .S ACRUI="USD"
 .S ACRQDI=$S(ACRIFIN["FINAL":0,1:1)         ;SET DUE IN TO 0 IF FINAL
 .S (ACRAPD,ACRRIUC)=ACRUCST                          ;INVOICE UNIT COST
 Q