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

ACRFUFMR.m

Go to the documentation of this file.
ACRFUFMR ;IHS/OIRM/DSD/AEF - UTILITY STANDALONE TO READ OPEN DOCUMENTS FROM CORE FOR UFMS [ 05/16/2007   9:44 AM ]
 ;;2.1;ADMIN RESOURCE MGMT SYSTEM;**22**;NOV 05, 2001
 ;NEW ROUTINE ACR*2.1*22 UFMS
 ;
 ;*************************************************************
READ ;EP;READ CONTENTS OF UNIX CORE FILES INTO ^ACRZ GLOBALS 
 ;
 ;   ACRFN = ARMS/CORE FILENAME -- Docs##.txt ; ## = Accounting point
 ;
 N ACRDIR,X,%DEV,ACRSTR,ACRI,ACRFN,ACRFAP
 N P1,P2,P3,P4,P5,P6,P7,P8,P9,ACRQUIT
 S ACRFAP=$P(^AUTTACPT($P(^ACRSYS(1,"DT1"),U,13),0),U)
 I ACRFAP=65 S ACRFAP="65-94"              ;MODIFY FOR HQ/NP
 S ACRFN="Docs"_ACRFAP_".txt"
 S ACRDIR=$$ARMSDIR^ACRFSYS(1)
 I ACRDIR["/usr/ACR/" S ACRDIR="/usr/ACR/"
 D HFS^ACRFZISH(ACRDIR,ACRFN,"R",.%DEV)
 Q:$G(%DEV)']""
 K ^ACRZ("ACRCORE")
 U %DEV
 S (ACRI,ACRQUIT)=0
 F  R X:DTIME D  I ACRQUIT>4 Q           ;DIRECT READ OF UNIX FLAT FILE
 . S ACRSTR=$$STR(X)
 . Q:ACRSTR=0
 . S ACRI=ACRI+1
 . S ^ACRZ("ACRCORE",ACRI)=ACRSTR
 ;
 D CLOSE^%ZISH("FILE")
 S ^ACRZ("ACRCORE")=$$NOW^ACRFUTL              ;DATE AND TIME STAMP
 S ^ACRZ("ACRCORE","TOTAL")=ACRI               ;NUMBER OF RECORDS
 ;
 D EN^ACRFUFMZ
 Q
 ;
 ;*************************************************************
STR(X) ; PARSING STRING
 ;40,AP,6007002300          ,2005,J40DU05,252Z,13292,100,1860777569A1
 I X="" D  Q 0                   ;SET QUIT CONDITION IF NULL
 .S ACRQUIT=ACRQUIT+1            ;IF IT FINDS FIVE NULL LINES, MUST BE EOF
 S P7=$P(X,",",7)                ;DOL AMT
 I P7=0!(P7="") Q 0              ;SKIP ZERO DOLLAR AMOUNTS
 S P1=$P(X,",",1)                ;AP
 S P2=$P(X,",",2)                ;DOC-TYPE
 S P3=$E($P(X,",",3),1,10)       ;DOCUMENT
 S P4=$P(X,",",4)                ;FY
 S P5=$P(X,",",5)                ;CAN
 S P6=$P(X,",",6)                ;OCC
 S P8=$P(X,",",8)                ;REF CODE
 S P9=$P(X,",",9)                ;VENDOR EIN
 S STR=P1_U_P2_U_P3_U_P4_U_P5_U_P6_U_P7_U_P8_U_P9
 Q STR
 ;*************************************************************
 ; BEGIN REPORT FILE CREATION
 ;*************************************************************
ENW ;EP; ENTRY POINT FOR RECORDS GENERATED BY ^ACRFUFMZ
 ;
 N ACRNODE,ACRTOT,ACRTOTAL,ACRSITE,ACRCNT,ACRRPTOT,I,ACRCORE,ACRMTCH,TRCNT
 S ACRSITEN=$P($G(^AUTTAREA(+$G(^ACRSYS(1,0)),0)),U)    ;SITE NAME
 K ACRARY
 ;CREATE FILE NAME
 S ACRSITE=$E(ACRSITEN,1,3)
 S:ACRSITE="NAT" ACRSITE="HQ"
 S ACRTAIL=".csv"                          ; USE COMMA SEPARTED VALUE FORMAT
 S ACRPFX=ACRSITE_"_CORE_OPEN_"
 S (ACRTOT,ACRRPTOT,TRCNT)=0
 ;
 ;LOOP THROUGH NODES TO CREATE REPORT FILES
 F ACRNODE="ITEMS","ACRDOC","VNDR","NOHIT","NOMATCH","NOVNDR","ERR","TR","PAY","GTRIP","CHS","GR","CEIN" D
 .S ACRFILE=ACRPFX_ACRNODE_ACRTAIL
 .D WRITE(ACRNODE,ACRFILE)
 ;
 S ACRCORE=$G(^ACRZ("ACRCORE","TOTAL"))     ;NUMBER OF RECORDS IN CORE FILE
 S ACRMTCH=0
 F I="ACRDOC","NOVNDR","TR" D                    ;TOTAL ALL ARMS MATCHES
 .S ACRMTCH=ACRMTCH+$G(^ACRZ(I,"TOTAL"))
 S ACRMTCH=ACRMTCH-TRCNT                    ;SUBTRACT NUMBER OF NO HIT/MATCH TRAVEL
 S ACRSTR=ACRSITEN_U_ACRCORE_U_ACRMTCH
 ;
 F I="TOTALS","ACRDOC","NOVNDR","VNDR","ERR","NOHIT","NOMATCH","TR","PAY","GTRIP","CHS","GR" D
 .S ACRSTR=ACRSTR_U_$G(^ACRZ(I,"TOTAL"))    ;CREATE 'TOTALS' SUMMARY STRING
 .Q:I="ERR"
 .Q:I="VNDR"
 .S:I'="TOTALS" ACRRPTOT=ACRRPTOT+^ACRZ(I,"TOTAL")  ;TOTAL NUMBER IN REPORTS
 ;
 S ACRSTR=ACRSTR_U_ACRRPTOT
 S ^ACRZ("TOTALS")=ACRSTR
 S ACRFILE=ACRPFX_"TOTALS"_ACRTAIL
 D WRITE("TOTALS",ACRFILE)
 I IOST'["C-" Q                       ;TASKED JOB
 U 0
 S RAY=0
 F  S RAY=$O(ACRARY(RAY)) Q:RAY=""  D
 .W !,ACRARY(RAY)
 W !!,"CORE OPEN DOCUMENT FILE IMPORTED ",$G(^ACRZ("ACRCORE"))
 W !,"TOTAL RECORDS FROM CORE FILE    = ",ACRCORE
 W !,"TOTAL RECORDS IN REPORT FILES   = ",ACRRPTOT
 W !?10,"TOTAL MATCHED DOCUMENTS                    = ",ACRMTCH
 W !?10,"TOTAL VENDORS IN MATCHED FILES             = ",^ACRZ("VNDR","TOTAL")
 W !?10,"TOTAL MATCHED DOCUMENTS WITH VENDOR ERRORS = ",^ACRZ("ERR","TOTAL")
 D PAUSE^ACRFWARN
 Q
 ;
 ;*************************************************************
WRITE(ACRNODE,ACRFILE) ;----- WRITE ^ACRZ(ACRNODE GLOBAL TO UNIX FILE
 ;
 N %DEV,ACR,ACRDIR,I,ACRI,ACRD,ACRN,ACRSTR,ACRFY
 K ACRARY(ACRNODE)
 S ACRSTR=""
 S ACRDIR=$$ARMSDIR^ACRFSYS(1)
 D HFS^ACRFZISH(ACRDIR,.ACRFILE,"W",.%DEV)
 Q:'$D(%DEV)
 U %DEV
 D @(ACRNODE_"H")                            ;WRITE HEADING
 I ACRNODE="TOTALS" D  Q                      ;SINGLE STRING ONLY
 .S ACRSTR=^ACRZ(ACRNODE)
 .D CNT
 .S ACRARY(ACRNODE)=ACRCNT_" records have been put into file "_ACRDIR_ACRFILE
 .D CLOSE^%ZISH("FILE")
 S ACRCNT=0
 S ACRD=""
 F  S ACRD=$O(^ACRZ(ACRNODE,ACRD)) Q:ACRD=""  D
 .Q:ACRD="TOTAL"
 .S ACRSTR=$G(^ACRZ(ACRNODE,ACRD))
 .I ACRNODE="ACRDOC"!(ACRNODE="VNDR")!(ACRNODE="ERR") D
 ..S ACRSTR=$P(ACRSTR,U,3,99)                 ;STRIP AP/VIEN FROM REPORTS
 .I ACRNODE="ITEMS" D  Q                      ;LOOP THRU MULTIPLE ITEMS
 ..S NUM=0
 ..F  S NUM=$O(^ACRZ(ACRNODE,ACRD,NUM)) Q:'NUM  D
 ...S ACRSTR=""
 ...F I=1:1:3 S ACRSTR=ACRSTR_$G(^ACRZ(ACRNODE,ACRD,NUM,I))_U
 ...D CNT
 .D CNT
 W !,$C(34)_"TOTAL = "_ACRCNT_$C(34)
 S ACRARY(ACRNODE)=ACRCNT_" records have been put into file "_ACRDIR_ACRFILE
 D CLOSE^%ZISH("FILE")
 S ACRTOT=ACRTOT+ACRCNT
 Q
 ;*************************************************
CNT ;
 W !
 F I=1:1:$L(ACRSTR,U) D
 .S TMP=$P(ACRSTR,U,I)
 .W $C(34)                             ;WRITE " DOUBLE QUOTE
 .I $E(TMP)="0",$L(TMP)'=1 W $C(39)    ;WRITE ' SINGLE QUOTE IN FRONT OF ZERO
 .W TMP_$C(34)_$C(44)                  ;WRITE " DOUBLE QUOTE AND COMMA
 I ACRNODE="TR",$E(ACRSTR,1,3)="NO " S TRCNT=TRCNT+1 ;COUNT NO HIT/MATCH TRAVEL
 S ACRCNT=ACRCNT+1
 Q
 ;
 ;*************************************************************
TRH ;TRAVEL DOCUMENTS
NOMATCHH ;HEADING; DOCUMENT HIT BUT NO MATCH WITH CORE
NOVNDRH ;HEADING; MATCHED DOCUMENTS WITH NO VENDOR
 W $C(34)_"NAME"_$C(34)
 W $C(44)_$C(34)_"REQUISITION"_$C(34)
 W $C(44)_$C(34)_"DATE OF DOCUMENT/TRANSMISSION"_$C(34)
 W $C(44)_$C(34)_"IDENTIFIER/INVOICE"_$C(34)
 D COREH
 I ACRNODE'="NOMATCH" D
 .W $C(44)_$C(34)_"ARMS RR STATUS"_$C(34)
 .W $C(44)_$C(34)_"ARMS INVOICE STATUS"_$C(34)
 Q
 ;
 ;*************************************************************
ACRDOCH ;HEADING; MATCHED DOCUMENTS WITH VENDOR AND ERROR FLAG
VNDRH ;HEADING; MATCHED DOCUMENT VENDORS WITH ERRORS
ERRH ;HEADING; VENDOR ERRORS WITH DOCUMENTS TO FLAT FILE
 W $C(34)_"VENDOR NAME"_$C(34)
 W $C(44)_$C(34)_"VENDOR EIN"_$C(34)
 W $C(44)_$C(34)_"SUFFIX"_$C(34)
 W $C(44)_$C(34)_"ARMS REQUISITION"_$C(34)
 W $C(44)_$C(34)_"DATE OF DOCUMENT/TRANSMISSION"_$C(34)
 W $C(44)_$C(34)_"IDENTIFIER/INVOICE"_$C(34)
 D COREH
 W $C(44)_$C(34)_"ARMS RR STATUS"_$C(34)
 W $C(44)_$C(34)_"ARMS INVOICE STATUS"_$C(34)
 W $C(44)_$C(34)_"VENDOR ERRORS"_$C(34)
 Q
 ;
 ;*************************************************************
NOHITH ;WRITE NO HITS WITH CORE FILE HEADINGS FOR FLAT FILE
GRH ;GRANT DOCUMENTS
NOTRH ;TRAVEL WITHOUT A HIT (NON-GTRIP)
CHSH ;CHS DOCUMENTS
GTRIPH ;GOVTRIP DOCUMENTS
PAYH ;PAY ROLL ENTRIES IN CORE FILE
CEINH ;CORE/ARMS VENDOR CHECK
 W $C(34)_"NAME"_$C(34)
COREH ;WRITE ALL CORE RECORDS HEADINGS FOR FLAT FILE
 W:ACRNODE'="ITEMS" $C(44)
 W $C(34)_"ACCOUNTING POINT"_$C(34)
 W $C(44)_$C(34)_"CORE DOC-TYPE"_$C(34)
 W $C(44)_$C(34)_"CORE DOCUMENT"_$C(34)
 W $C(44)_$C(34)_"FISCAL YEAR"_$C(34)
 W $C(44)_$C(34)_"CAN"_$C(34)
 W $C(44)_$C(34)_"OCC"_$C(34)
 W $C(44)_$C(34)_"CORE DOLLAR AMOUNT"_$C(34)
 W $C(44)_$C(34)_"CORE REFERENCE CODE"_$C(34)
 W $C(44)_$C(34)_"CORE VENDOR EIN"_$C(34)
 Q
TOTALSH ;WRITE SUMMARY TOTALS
 W $C(34)_"AREA OFFICE SITE"_$C(34)
 W $C(44)_$C(34)_"RECORDS FROM CORE (ACRCORE)"_$C(34)
 W $C(44)_$C(34)_"ARMS DOCUMENTS MATCHED WITH OPEN CORE RECORDS"_$C(34)
 W $C(44)_$C(34)_"TOTAL UNDISBURSED AMOUNT"_$C(34)
 W $C(44)_$C(34)_"MATCHED WITH VENDORS (ACRDOC)"_$C(34)
 W $C(44)_$C(34)_"MATCHED WITH NO VENDOR (NOVNDR)"_$C(34)
 W $C(44)_$C(34)_"UNIQUE MATCHED DOCUMENT VENDORS (VNDR)"_$C(34)
 W $C(44)_$C(34)_"MATCHED RECORDS WITH VENDOR ERRORS (ERR)"_$C(34)
 W $C(44)_$C(34)_"RECORDS WITH NO MATCHING DOC # (NOHIT)"_$C(34)
 W $C(44)_$C(34)_"RECORDS WITH MATCHING DOC # AND NO MATCH ON CAN, OCC, FY (NOMATCH)"_$C(34)
 W $C(44)_$C(34)_"ALL ARMS TRAVEL DOCUMENTS"_$C(34)
 W $C(44)_$C(34)_"NO HIT PAYROLL RECORDS (PAY)"_$C(34)
 W $C(44)_$C(34)_"NO HIT GOVTRIP DOCUMENTS"_$C(34)
 W $C(44)_$C(34)_"NO HIT CHS DOCUMENTS"_$C(34)
 W $C(44)_$C(34)_"NO HIT GRANT DOCUMENT"_$C(34)
 W $C(44)_$C(34)_"RECORDS IN REPORTS"_$C(34)
 Q
ITEMSH ;WRITE HEADINGS FOR LINE ITEMS
 D COREH
1 W $C(44)_$C(34)_"ITEM NUMBER IN DOCUMENT"_$C(34)
 W $C(44)_$C(34)_"UNIT OF ISSUE"_$C(34)
 W $C(44)_$C(34)_"QUANTITY"_$C(34)
 W $C(44)_$C(34)_"UNIT COST"_$C(34)
 W $C(44)_$C(34)_"ESTIMATED COST"_$C(34)
 W $C(44)_$C(34)_"QUANTITY RECEIVED"_$C(34)
 W $C(44)_$C(34)_"QUANTITY ACCEPTED"_$C(34)
 W $C(44)_$C(34)_"QUANTITY DUE IN"_$C(34)
 W $C(44)_$C(34)_"RR QUANTITY RECEIVED"_$C(34)
 W $C(44)_$C(34)_"RR QUANTITY ACCEPTED"_$C(34)
 W $C(44)_$C(34)_"RR INVOICE QUANTITY"_$C(34)
 W $C(44)_$C(34)_"AMOUNT PAID"_$C(34)
 W $C(44)_$C(34)_"ARMS RR STATUS"_$C(34)
 W $C(44)_$C(34)_"ARMS INVOICE STATUS"_$C(34)
 ;
2 W $C(44)_$C(34)_"LINE DESCRIPTION"_$C(34)
 W $C(44)_$C(34)_"KEYWORD"_$C(34)
 W $C(44)_$C(34)_"STANDARD ITEM NUMBER"_$C(34)
3 ;
 W $C(44)_$C(34)_"ITEM DESCRIPTION"_$C(34)
 W $C(44)_$C(34)_"CAN 'BILL TO' LOCATION"_$C(34)
 W $C(44)_$C(34)_"CAN 'SHIP TO' LOCATION"_$C(34)
 W $C(44)_$C(34)_"DEPARTMENT LOCATION"_$C(34)
 W $C(44)_$C(34)_"DEPARTMENT LOCATION CODE NAME"_$C(34)
 W $C(44)_$C(34)_"CAN LOCATION"_$C(34)
 W $C(44)_$C(34)_"CAN LOCATION CODE NAME"_$C(34)
 ;
 Q