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

ACRFEXP2.m

Go to the documentation of this file.
ACRFEXP2 ;IHS/OIRM/DSD/AEF - MAIN DRIVER ROUTINE FOR DHR & ECS EXPORT [ 09/23/2005  8:29 AM ]
 ;;2.1;ADMIN RESOURCE MGT SYSTEM;**2,19**;NOV 05, 2001
 ;
 ;ACR*2.1*2.1;THIS ROUTINE IS REWRITTEN TO RESTORE THE ACH-GROUPED
 ;PAYMENTS
 ;
 ;This routine processes payments from the 1166 Approvals
 ;for Payment file and places them into the DHR Data Records
 ;file for subsequent transmission to CORE and into the Treasury
 ;ECS file for transmission to Treasury
 ;
 ;      VARIABLES USED:
 ;      ACRALC = AGENCY LOCATION CODE USED BY TREASURY
 ;      ACRBTYP= BATCH TYPE: T=TRAVEL;V=VENDOR
 ;      ACRECS = UNIX TREASURY ECS FILE NAME
 ;      ACRFIN = FINANCE OFFICE IEN
 ;      ACRRFC = TREASURY REGIONAL FINANCE CENTER CODE
 ;      ACRACH = TREASURY SCHEDULE FORMAT:
 ;               T = TAPE-GROUPED
 ;               C = CHECKS GROUPED
 ;               N = CHECKS-NOT GROUPED
 ;               A = ACH-GROUPED (ELECTRONIC FUNDS TRANSFER)
 ;               B = ACH-NOT GROUPED (ELECTRONIC FUNDS TRANSFER)
 ;               G = DHR ONLY
 ;
 ;
EN(ACRD0,ACRD1)    ;EP
 ;----- MAIN DRIVER ENTRY POINT
 ;
 ;      ACRD0  = FY IEN IN 1166 APPROVALS FOR PAYMENT FILE
 ;      ACRD1  = BATCH IEN IN 1166 APPROVALS FOR PAYMENT FILE
 ;      ACRALC = AGENCY LOCATION CODE
 ;      ACRFIN = FINANCE OFFICE IEN
 ;      ACROUT = QUIT CONTROLLER         
 ;      ACRRFC = REGIONAL FINANCE CENTER
 ;
 N ACRALC,ACRECS,ACRFIN,ACROUT,ACRRFC
 ;
 D FINCHK(.ACRFIN,.ACROUT)
 Q:ACROUT
 ;
 D PARAMCK(1,.ACRALC,.ACRRFC,.ACROUT)
 Q:ACROUT
 ;
 D GET(ACRD0,ACRD1)
 Q:'$D(^TMP("ACR",$J))
 ;
 D DHR^ACRFEXP3
 ;
 D ECS^ACRFEXP4(ACRD0,ACRD1,ACRFIN,ACRALC,ACRRFC,.ACRECS)
 ;
 D UPDATE(ACRD0,ACRD1,$G(ACRECS))
 ;
 D BSR(ACRD0,ACRD1)
 ;
 K ^TMP("ACR",$J)
 ;
 Q
GET(ACRD0,ACRD1)   ;
 ;----- LOOP THROUGH 1166 APPROVALS FOR PAYMENT SEQUENCES
 ;      TO GATHER PAYMENT DATA AND PUT INTO ^TMP("ACR",$J)
 ;      GLOBAL
 ;
 ;      ACRACH  = TREASURY SCHEDULE FORMAT
 ;      ACRAMT  = TRANSACTION AMOUNT
 ;      ACRAPPN = APPROPRIATION NUMBER
 ;      ACRBTYP = BATCH TYPE
 ;      ACRD0   = FY IEN IN 1166 APPROVALS FOR PAYMENT FILE
 ;      ACRD1   = BATCH IEN IN 1166 AFP FILE
 ;      ACRD2   = SEQ NO IEN IN 1166 AFP FILE
 ;      ACRIEN  = VENDOR/TRAVELER INTERNAL ENTRY NUMBER
 ;      ACRNAME = VENDOR/TRAVELER NAME
 ;      ACROCC  = OBJECT CLASS CODE
 ;      ACRPDFOR= ACH ADDENDUM/INVOICE NUMBER/TO NUMBER
 ;      ACRREF  = REFERENCE CODE
 ;      ACRSSN  = VENDOR EIN/TRAVELER SSN
 ;      ACRTCOD = TRANSACTION TYPE
 ;
 N ACRD2,ACRACH,ACRAMT,ACRAPPN,ACRBTYP,ACRDATA,ACRIEN,ACRNAME,ACROCC,ACRPDFOR,ACRREF,ACRSSN,ACRTCOD
 K ^TMP("ACR",$J)
 S ACRBTYP=$P($G(^AFSLAFP(ACRD0,1,ACRD1,0)),U,4)
 Q:ACRBTYP=""
 S ACRDATA=$G(^AFSLAFP(ACRD0,1,ACRD1,2))
 S ACRACH=$P(ACRDATA,U,8)
 Q:ACRACH=""
 S ACRD2=0
 F  S ACRD2=$O(^AFSLAFP(ACRD0,1,ACRD1,1,ACRD2)) Q:'ACRD2  D
 . S ACRDATA=$G(^AFSLAFP(ACRD0,1,ACRD1,1,ACRD2,0))
 . S ACRTCOD=$P(ACRDATA,U,18)
 . Q:ACRTCOD=""
 . S ACRAMT=+$P(ACRDATA,U,11)
 . I $E(ACRTCOD,U,4)=2 S ACRAMT=0-ACRAMT
 . S ACRREF=$P(ACRDATA,U,6)
 . S ACRREF=$TR(ACRREF," ","")
 . Q:ACRREF=""
 . S ACROCC=$P(ACRDATA,U,8)
 . Q:'ACROCC
 . S ACROCC=$P($G(^AUTTOBJC(ACROCC,0)),U)
 . Q:ACROCC=""
 . I ACRBTYP="V" D
 . . S ACRIEN=$P(ACRDATA,U,10)
 . . S ACRNAME=$P($G(^AUTTVNDR(ACRIEN,0)),U)
 . . S ACRSSN=$P($G(^AUTTVNDR(ACRIEN,11)),U,13)
 . I ACRBTYP="T" D
 . . S ACRIEN=$P(ACRDATA,U,24)
 . . ;S ACRNAME=$P($G(^VA(200,ACRIEN,0)),U)  ;ACR*2.1*19.02 IM16848
 . . S ACRNAME=$$NAME2^ACRFUTL1(ACRIEN)  ;ACR*2.1*19.02 IM16848
 . . S ACRSSN=$P($G(^VA(200,ACRIEN,1)),U,9)
 . Q:ACRNAME=""
 . S ACRAPPN=$P($G(^AFSLAFP(ACRD0,1,ACRD1,1,ACRD2,1)),U,21)
 . Q:ACRAPPN=""
 . S ACRNAME=$$UPPER^ACRFUTL(ACRNAME)
 . S ACRNAME=$TR(ACRNAME,"~"," ")
 . S ACRNAME=ACRNAME_"~"_ACRIEN_"~"_ACRAPPN
 . S ACRDATA=$G(^AFSLAFP(ACRD0,1,ACRD1,1,ACRD2,2))
 . S ACRPDFOR=$S(ACRACH="C"!(ACRACH="N"):$P(ACRDATA,U,14),1:$P(ACRDATA,U,2))
 . D DHRSET(ACRNAME,ACRD0,ACRD1,ACRD2,ACRAMT,ACRPDFOR)
 . Q:ACRACH="G"
 . Q:ACRACH="T"
 . ;Q:ACROCC="219M" ;COMMENTED OUT TO ALLOW TRAVEL MGT FEE TO GO TO ECS FILE
 . Q:"^061^192^191^190^182^181^199^"'[$E(ACRTCOD,1,3)
 . I ACRBTYP="T" D
 . . Q:$E(ACRTCOD,1,3)="061"
 . . S ACRDATA=$G(^AFSLAFP(ACRD0,1,ACRD1,1,ACRD2,0))
 . . S ACRAMT=ACRAMT-$P(ACRDATA,U,12)
 . D APPSET(ACRAPPN,ACRAMT)
 . I ACRACH="A" D A(ACRAMT,ACRD0,ACRD1,ACRD2,ACRNAME,ACRPDFOR)
 . I ACRACH="B" D B(ACRAMT,ACRD0,ACRD1,ACRD2,ACRNAME,ACRPDFOR)
 . I ACRACH="C" D C(ACRAMT,ACRD0,ACRD1,ACRD2,ACRNAME,ACRPDFOR)
 . I ACRACH="N" D N(ACRAMT,ACRD0,ACRD1,ACRD2,ACRNAME,ACRPDFOR)
 ;
 S ACRCNT=0
 S ACRAPPN=""
 F  S ACRAPPN=$O(^TMP("ACR",$J,"X",ACRAPPN)) Q:ACRAPPN']""  D
 . S ACRCNT=ACRCNT+1
 . S ^TMP("ACR",$J,"ECSAPPN",ACRCNT,0)=ACRAPPN_U_^TMP("ACR",$J,"X",ACRAPPN,0)
 Q
APPSET(ACRAPPN,ACRAMT)       ;
 ;----- SET APPROPRIATION NUMBER/AMOUNT ARRAY
 ;
 S ^TMP("ACR",$J,"X",ACRAPPN,0)=$G(^TMP("ACR",$J,"X",ACRAPPN,0))+ACRAMT
 Q
DHRSET(ACRNAME,ACRD0,ACRD1,ACRD2,ACRAMT,ACRPDFOR)          ;
 ;----- SET ^TMP GLOBAL WITH DHR PAYMENT DATA
 ;
 ;      3RD PIECE = FY IEN OF 1166 APPROVALS FOR PAYMENT FILE
 ;      4TH PIECE = BATCH IEN
 ;      5TH PIECE = SEQUENCE NO IEN
 ;      OTHER DATA PIECES ARE INCLUDED FOR TROUBLESHOOTING PURPOSES
 ;      ALSO, VENDOR/TRAVELER NAMES ARE ALPHABETIZED
 ;
 S ^TMP("ACR",$J,"DHR",ACRNAME,ACRD2,0)=ACRD2_U_ACRAMT_U_ACRD0_U_ACRD1_U_ACRD2_U_ACRPDFOR
 Q
A(ACRAMT,ACRD0,ACRD1,ACRD2,ACRNAME,ACRPDFOR)     ;
 ;----- SET ^TMP GLOBAL FOR ACH-GROUPED PAYMENTS
 ;
 N ACRPDFRX,ACRPMT,ACRX
 ;
 S ACRPDFOR=$$PDFOR(ACRPDFOR)
 S ACRPDFRX=""
 ;
 I '$D(^TMP("ACR",$J,"ECS","A",ACRNAME,0)) D
 . S ^TMP("ACR",$J,"ECS","A",ACRNAME,0)="1^0"
 . S ACRDATA=$G(^TMP("ACR",$J,"ECS","A",0))
 . S $P(ACRDATA,U)=$P(ACRDATA,U)+1
 . S ^TMP("ACR",$J,"ECS","A",0)=ACRDATA
 ;
 S ACRPMT=$P(^TMP("ACR",$J,"ECS","A",ACRNAME,0),U)
 ;
 S ACRPDFRX=$TR(ACRPDFRX,"\","")
 I ACRPDFRX]"" S ACRPDFRX=ACRPDFRX_","
 S ACRPDFRX=ACRPDFRX_ACRPDFOR
 S ACRPDFRX=ACRPDFRX_"\"
 ;
 S ACRDATA=$G(^TMP("ACR",$J,"ECS","A",ACRNAME,ACRPMT,0))
 S $P(ACRDATA,U)=$P(ACRDATA,U)+1
 S $P(ACRDATA,U,2)=$P(ACRDATA,U,2)+ACRAMT
 S $P(ACRDATA,U,3)=ACRD0
 S $P(ACRDATA,U,4)=ACRD1
 S $P(ACRDATA,U,5)=ACRD2
 S $P(ACRDATA,U,6)=ACRPDFRX
 S ^TMP("ACR",$J,"ECS","A",ACRNAME,ACRPMT,0)=ACRDATA
 ;
 S ^TMP("ACR",$J,"ECS","A",ACRNAME,ACRPMT,$P(ACRDATA,U),0)=1_U_ACRAMT_U_ACRD0_U_ACRD1_U_ACRD2_U_ACRPDFOR
 ;
 S ACRDATA=^TMP("ACR",$J,"ECS","A",ACRNAME,0)
 S $P(ACRDATA,U,2)=$P(ACRDATA,U,2)+ACRAMT
 S ^TMP("ACR",$J,"ECS","A",ACRNAME,0)=ACRDATA
 ;
 S ACRDATA=$G(^TMP("ACR",$J,"ECS","A",0))
 S $P(ACRDATA,U,2)=$P(ACRDATA,U,2)+ACRAMT
 S ^TMP("ACR",$J,"ECS","A",0)=ACRDATA
 Q
B(ACRAMT,ACRD0,ACRD1,ACRD2,ACRNAME,ACRPDFOR)     ;
 ;----- SET ^TMP GLOBAL FOR ACH-NOT GROUPED PAYMENTS
 ;
 N ACRDATA,ACRPMT
 ;
 S ACRDATA=$G(^TMP("ACR",$J,"ECS","B",0))
 S $P(ACRDATA,U)=$P(ACRDATA,U)+1
 S $P(ACRDATA,U,2)=$P(ACRDATA,U,2)+ACRAMT
 S ^TMP("ACR",$J,"ECS","B",0)=ACRDATA
 ;
 S ACRDATA=$G(^TMP("ACR",$J,"ECS","B",ACRNAME,0))
 S $P(ACRDATA,U)=$P(ACRDATA,U)+1
 S $P(ACRDATA,U,2)=$P(ACRDATA,U,2)+ACRAMT
 S ^TMP("ACR",$J,"ECS","B",ACRNAME,0)=ACRDATA
 ;
 S ACRPMT=$P(^TMP("ACR",$J,"ECS","B",ACRNAME,0),U)
 S ^TMP("ACR",$J,"ECS","B",ACRNAME,ACRPMT,0)=1_U_ACRAMT_U_ACRD0_U_ACRD1_U_ACRD2_U_ACRPDFOR
 Q
C(ACRAMT,ACRD0,ACRD1,ACRD2,ACRNAME,ACRPDFOR)     ;
 ;----- SET ^TMP GLOBAL FOR CHECKS-GROUPED PAYMENTS
 ;
 ;14 PAYMENT ID LINES
 ;
 N ACRDATA,ACRGPMT
 ;
 S ACRPDFOR=$$PDFOR(ACRPDFOR)
 ;
 S ACRDATA=$G(^TMP("ACR",$J,"ECS","C",0))
 S $P(ACRDATA,U,2)=$P(ACRDATA,U,2)+ACRAMT
 S ^TMP("ACR",$J,"ECS","C",0)=ACRDATA
 ;
 I '$D(^TMP("ACR",$J,"ECS","C",ACRNAME,0)) D
 . S ^TMP("ACR",$J,"ECS","C",ACRNAME,0)="1^0"
 . S ACRDATA=^TMP("ACR",$J,"ECS","C",0)
 . S $P(ACRDATA,U)=$P(ACRDATA,U)+1
 . S ^TMP("ACR",$J,"ECS","C",0)=ACRDATA
 ;
 S ACRDATA=$G(^TMP("ACR",$J,"ECS","C",ACRNAME,0))
 S $P(ACRDATA,U,2)=$P(ACRDATA,U,2)+ACRAMT
 S ^TMP("ACR",$J,"ECS","C",ACRNAME,0)=ACRDATA
 ;
 S ACRGPMT=$P(^TMP("ACR",$J,"ECS","C",ACRNAME,0),U)
 ;
 ;Only 14 payments in Checks-Grouped
 S ACRDATA=$G(^TMP("ACR",$J,"ECS","C",ACRNAME,ACRGPMT,0))
 I $P(ACRDATA,U)+1>14 D
 . S ACRGPMT=ACRGPMT+1
 . S $P(^TMP("ACR",$J,"ECS","C",ACRNAME,0),U)=ACRGPMT
 . S ACRDATA=^TMP("ACR",$J,"ECS","C",0)
 . S $P(ACRDATA,U)=$P(ACRDATA,U)+1
 . S ^TMP("ACR",$J,"ECS","C",0)=ACRDATA
 ;
 S ACRDATA=$G(^TMP("ACR",$J,"ECS","C",ACRNAME,ACRGPMT,0))
 S $P(ACRDATA,U)=$P(ACRDATA,U)+1
 S $P(ACRDATA,U,2)=$P(ACRDATA,U,2)+ACRAMT
 S $P(ACRDATA,U,3)=ACRD0
 S $P(ACRDATA,U,4)=ACRD1
 S $P(ACRDATA,U,5)=ACRD2
 S ^TMP("ACR",$J,"ECS","C",ACRNAME,ACRGPMT,0)=ACRDATA
 ;
 S ^TMP("ACR",$J,"ECS","C",ACRNAME,ACRGPMT,$P(ACRDATA,U),0)=1_U_ACRAMT_U_ACRD0_U_ACRD1_U_ACRD2_U_ACRPDFOR
 Q
N(ACRAMT,ACRD0,ACRD1,ACRD2,ACRNAME,ACRPDFOR)     ;
 ;----- SET ^TMP GLOBAL FOR CHECKS-NOT GROUPED PAYMENTS
 ;
 S ACRDATA=$G(^TMP("ACR",$J,"ECS","N",0))
 S $P(ACRDATA,U)=$P(ACRDATA,U)+1
 S $P(ACRDATA,U,2)=$P(ACRDATA,U,2)+ACRAMT
 S ^TMP("ACR",$J,"ECS","N",0)=ACRDATA
 ;
 S ACRPMT=$P(ACRDATA,U)
 S ^TMP("ACR",$J,"ECS","N",ACRNAME,ACRPMT,0)=1_U_ACRAMT_U_ACRD0_U_ACRD1_U_ACRD2_U_ACRPDFOR
 Q
FINCHK(ACRFIN,ACROUT)        ;
 ;----- CHECK IF PURCHASE AND FINANCE OFFICES SET UP PROPERLY
 ;
 ;      RETURNS:
 ;      ACRFIN = INTERNAL FINANCE OFFICE
 ;      ACROUT = QUIT CONTROLLER
 ;
 N X
 S ACROUT=0
 S ACRFIN=$P($G(^ACRPO(1,0)),U,8)
 I 'ACRFIN D  Q
 . S ACROUT=1
 . W !!,"The Area Purchase Office is not properly set up."
 . W !,"Contact your Area ARMS Manager for assistance."
 I '$D(^AUTTPRG(ACRFIN,"DT")) D  Q
 . S ACROUT=1
 . W !!,"Information on the Area Finance Office is not properly set up."
 . W !,"Contact your ARMS Manager for assistance."
 . D PAUSE^ACRFWARN
 Q
PARAMCK(ACRD0,ACRALC,ACRRFC,ACROUT)    ;
 ;----- SET UP REQUIRED ALC AND RFC PARAMETERS
 ;
 ;      INPUT:
 ;      ACRD0  =  THE IEN OF THE FACILITY IN THE FMS SYSTEM DEFAULTS
 ;                FILE
 ;
 ;      RETURNS:
 ;      ACRALC =  AGENCY LOCATION CODE
 ;      ACRRFC =  TREASURY REGIONAL FINANCIAL CENTER CODE
 ;      ACROUT =  QUIT CONTROLLER: 0=SUCCESSFUL, 1=UNSUCCESSFUL
 ;
 N ACRDATA
 S ACROUT=0
 S ACRDATA=$G(^ACRSYS(ACRD0,402))
 S ACRALC=$P(ACRDATA,U)
 S ACRRFC=$P(ACRDATA,U,2)
 I ACRALC=""!(ACRRFC="") D  S ACROUT=1 Q
 . W *7,!?5,"Agency Location Code and/or Regional Financial Center"
 . W !?5,"Code missing from FMS Systems Defaults File"
 . W !
 . H 2
 Q
BSR(ACRD0,ACRD1)   ;
 ;----- PRINTS BATCH STATUS REPORT
 ;      INTERFACE TO ROUTINE BS1^ACRFPAY8
 ;
 ;      INPUT:
 ;      ACRD0    = FY IEN IN 1166 APPROVALS FOR PAYMENT FILE
 ;      ACRD1    = BATCH IEN IN 1166 APPROVALS FOR PAYMENT FILE
 ;
 ;      VARIABLES NEEDED FOR CALL TO BS1^ACRFPAY8:
 ;      ACRBATDA = BATCH IEN
 ;      ACRBATNO = BATCH NUMBER
 ;      ACRFY    = FISCAL YEAR
 ;      ACRFYDA  = FISCAL YEAR IEN
 ;      ACROUT   = QUIT CONTROLLER - NOT USED HERE, BUT NEWED TO
 ;                 PREVENT IT FROM INTERFERING WHEN BS1^ACRFPAY8
 ;                 CALLS PAUSE^ACRFWARN
 ;                
 N ACRBATDA,ACRBATNO,ACRFY,ACRFYDA,ACROUT
 D HOME^%ZIS
 S ACRFY=$P($G(^AFSLAFP(ACRD0,0)),U)
 S ACRBATNO=$P($G(^AFSLAFP(ACRD0,1,ACRD1,0)),U)
 S ACRFYDA=ACRD0
 S ACRBATDA=ACRD1
 D BS1^ACRFPAY8
 Q
UPDATE(ACRD0,ACRD1,ACRECS)   ;
 ;----- UPDATE EXPORT FIELDS: EXPORT DATE, ECS FILE
 ;
 ;      ACRD0  = FY IEN IN 1166 APPROVALS FOR PAYMENT FILE
 ;      ACRD1  = BATCH IEN IN 1166 APPROVALS FOR PAYMENT FILE
 ;      ACRECS = TREASURY ECS FILE NAME
 ;
 N DA,DIE,DR,X,Y
 D ^XBKVAR
 S DA=ACRD1
 S DA(1)=ACRD0
 S DIE="^AFSLAFP("_DA(1)_",1,"
 S DR="5////"_DT_";25///"_$G(ACRECS)
 D ^DIE
 K ^AFSLAFP("EXPORT",ACRD0,ACRD1)
 Q
PDFOR(X) ;----- EXTRINSIC FUNCTION TO CONVERT PAID FOR
 ;
 I "REF*"[$E(X,1,4) D
 . S X=$P(X,"*",4)
 I "RMT*^RMR*"[$E(X,1,4) D
 . S X=$P(X,"*",3)
 S X=$TR(X,"\","")
 Q X