       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID.    CSR02140.                                         
COB303 DATE-WRITTEN. SEPTEMBER 02, 2005                                 
       DATE-COMPILED.                                                   
                                                                        
CVT000******************************************************************00000100
CVT000*     - - - - - >   R P C   C O N V E R S I O N   < - - - - -    *00000200
CVT000*         S140 CONVERTED TO DB2 SP CSR02140 ON 09/02/2005        *00000300
CVT000*             -NOTE: AUTOMATED CONVERSION PROGRAM USED           *00000400
CVT000*                                                                *00000500
CVT000*                    CVT000 - CONVERTED CODE                     *00000501
CVT000*                    CVT004 - NEEDED REVIEW                      *00000502
CVT000*                    CVT999 - COMMENTED OUT CODE THAT CAN        *00000503
CVT000*                             POTENTIALLY BE DELETED             *00000510
CVT000*                                                                *00000520
CVT000******************************************************************00000600
      ******************************************************************00060000
      *                                                                *00070000
      *                SOUTH CAROLINA ELECTRIC & GAS                   *00080000
      *                                                                *00090000
      *  THIS PROGRAM IS EXECUTED VIA A REMOTE PROCEDURE CALL (RPC).   *00100000
      *                                                                *00110000
      *  TRANID:        S140                                           *00120000
      *  PROGRAM:       S140                                           *00130000
      *  CALLING SP:    PA_S140                                        *00140000
      *                                                                *00150000
      ******************************************************************00160000
      *                 P R O G R A M  S U M M A R Y                   *00170000
      *                                                                *00180000
      *  THIS PROGRAM DOES THE FOLLOWING:                              *00190000
      *  1. UPDATES/DELETES MASTER SUBMETER RELATIONSHIPS.             *00200000
      *                                                                *00210000
      ******************************************************************00220000
      *                                                                *00230000
      *                     PROGRAM MODIFICATION LOG                   *00240000
      *                                                                *00250000
      *    DATE    INITIALS   COMMENTS                                 *00260000
      *  --------  --------   ---------------------------------------  *00270000
      *  08/17/95    RTO      PROCEDURE ORIGINALLY CODED.              *00280000
      *  02/04/97    RTO      CHANGED PARM-CODE-RELATION-TYPE = 'C' TO *00290000
      *                       PARM-CODE-RELATION-TYPE NOT EQUAL TO ' '.*00291000
      *  09/19/97    GAC      TPR11934 - IF THE SUB IS RATE 65 OR 66,  *00291106
      *                       CHECK THAT A FACTOR EXISTS OF TYPE STATE-*00291206
      *                       LINE.  IF NOT 65/66, CHECK THAT A FACTOR *00291306
      *                       EXISTS OF TYPE ADDITIVE.                 *00291414
      *                       PCR - CHECK THAT THE FACTOR OF THE SUB   *00291514
      *                       ISN'T ATTACHED TO ANOTHER SUB OF A DIFFER*00291614
      *                       ENT MASTER ACCOUNT. *                     00291717
      *  10/03/97    GAC      PCR - CHECK THAT THE MASTER DOESN'T HAVE *00291817
      *                       ANY EXISTING DEP ACCTS WITH A DIFFERENT  *00291917
      *                       FACTOR THAN THIS ATTEMPTED DEP.          *00292017
T16168*  04/29/98    TDK      CORRECTED MC05 ABEND VALUES.             *00293000
CBSI  *  08/18/98   CBSI      ABEND LOG MODIFIED TO INCLUDE ALL THE    *        
CBSI  *             MADRAS    ABEND PARAMETERS                         *        
T17916*  09/22/98    TDK      CHANGED SELECT TO BE ABLE TO ADD A NEW   *00293000
T17916*                       SUB ACCT W/ THE SAME FACTOR AS THE MASTER*00293000
REARCH*  09/02/05   CVNS      RPC TO COBOL DB2 SP CONVERSION           *00293000
REARCH*             CHENNAI                                            *00293000
P00251*  04/02/10   MN90523   NET METERING CHANGES                     *00293000
P00251*  10/16/10   AW41078   INCORPORATE CHANGES PER MASTDEPREL HIST: *        
P00251*                       1. ADD TWO NEW PARMS DEP_REL_START_DT AND*        
P00251*                          DEP_REL_END_DT PER NEW UR COLUMNS     *        
P00251*                          AND INCORPORATE INTO EXISTING INSERT  *        
P00251*                          AND DELETE LOGIC.  BOTH ARE NEW COLS  *        
P00251*                          IN UR TABLE WHERE DEP_REL_START_DT IS *        
P00251*                          NOW PART OF PRIMARY KEY.              *        
P00251*                       3. ADD UPDATE PROCESS AS USERS WILL BE   *        
P00251*                          ALLOWED TO UPDATE THE DEP_REL_END_DT  *        
P00251*                          VIA PANEL253.                         *        
P00251*                       4. REMOVE ALL CODE_ACCT_USAGE LOGIC      *        
P00251*                       5. ADD 9000 CALL WHEN SQL ERROR OCCURS   *        
P00251*                          SO PROPER MSG CAN BE DISPLAYED ON     *        
P00251*                          PANEL.                                *        
P00251*                       6. CORRECT ISSUES WITH TRANSHIST RECORDS *        
P00251*                       7. ADD CHECK FOR EXISTING RELATIONSHIPS  *        
P00251*                          PRIOR TO INSERT/UPDATE. RETURN 90 IF  *        
P00251*                          RELATIONSHIP ALREADY EXISTS.          *        
P00251*                          DECIDED TO LET A METER BE A DEPENDENT *        
P00251*                          FOR MULTIPLE MASTERS.                 *        
ACT028*  03/22/12   VIJAY     DELETE 7430-CHECK-FCTR-USED CHECK.       *00293000
A04527*  06/07/13   MR7E794   REMOVED UNUSED COPYBOOK CWS00056.        *        
      ******************************************************************00300000
      ******************************************************************00310000
      *                                                                *00320000
      *                ---- BASIC SEQUENCE STRUCTURE ----              *00330000
      *                                                                *00340000
      *  0000 - 0999  MAIN CONTROL PATH AND INITIALIZATION             *00350000
      *  1000 - 1999  INPUT PROCESSING CONTROL PATH                    *00360000
      *  2000 - 2999  OUTPUT PROCESSING CONTROL PATH                   *00370000
      *  3000 - 4999  NOT USED                                         *00380000
      *  5000 - 5999  COMMON PROGRAM MODULES                           *00390000
      *  6000 - 6999  COMMON SYSTEM MODULES                            *00400000
      *  7000 - 7999  INPUT MODULES                                    *00410000
      *  8000 - 8999  OUTPUT MODULES                                   *00420000
      *  9000 - 9999  TERMINATION,ABEND, MESSAGING MODULES             *00430000
      *                                                                *00440000
      ******************************************************************00450000
                                                                        
       ENVIRONMENT DIVISION.                                            
       DATA DIVISION.                                                   
                                                                        
       WORKING-STORAGE SECTION.                                         

MSQ002  01 MFA-CSRERLOG.
MSQ002    05 ARG-5 PIC X(255).
MSQ002    05 ARG-6 PIC X(255).
MSQ002    05 ARG-7 PIC X(447).

MSQ017 01 MFA-PROGRAM-ID PIC X(8) VALUE 'CSR02140'.
MSQ017     COPY MFASQLM.
       01  WS-START                                   PIC X(40) VALUE   
REARCH     'WORKING STORAGE FOR CSR02140 STARTS HERE'.                  
                                                                        
      ******************************************************************00540000
      *    COBOL WORKING STORAGE COPY BOOKS                            *00550000
      ******************************************************************00560000
                                                                        
           COPY CCA00001.                                               00600000
           COPY CWS00027.                                               00620000
           COPY CWS00303.                                               00640000
                                                                        
      ******************************************************************00660000
      *    WORK AREAS                                                  *00670000
      ******************************************************************00680000
                                                                        
       01  WS-MISC.                                                     
REARCH     05  PROGRAM-NAME             PIC X(08) VALUE 'CSR02140'.     
           05  ALL-DONE-SW              PIC X(01) VALUE 'N'.            
               88 NOT-ALL-DONE                    VALUE 'N'.            
               88 ALL-DONE                        VALUE 'Y'.            
           05  SEND-DONE-SW             PIC X(01) VALUE 'Y'.            
               88 SEND-DONE-ERROR                 VALUE 'N'.            
               88 SEND-DONE-OK                    VALUE 'Y'.            
P00251     05  WS-CODE-EST-OK-DEP-UPDT  PIC X(01) VALUE 'N'.            
P00251         88 CODE-EST-OK-DEP-UPDT            VALUE 'Y'.            
P00251     05  WS-CODE-ESTIMATE-OK-DEP  PIC X(01) VALUE SPACES.         
           05  WS-ACCOUNT-NO            PIC 9(13).                      
COB305     05 WS-ACCOUNT-NO-NUM-MST        PIC S9(13) COMP-3 VALUE 0.           
COB305     05 WS-ACCOUNT-NO-NUM-DEP        PIC S9(13) COMP-3 VALUE 0.           
           05  WS-ROW-COUNT             PIC 9(5) VALUE 0.               
           05  WS-MASTER-COUNT          PIC S9(9) COMP VALUE +0.        
           05  WS-DEPEND-COUNT          PIC S9(9) COMP VALUE +0.        
           05  WS-TRAN-APPL-NO          PIC S9(9) COMP VALUE +0.        
T11934     05  WS-SUB-RATE              PIC X(03) VALUE '000'.          
T11934     05  WS-NO-ADD-FCTR         PIC S9(09) COMP VALUE +89.        
T11934     05  WS-NO-STAT-FCTR        PIC S9(09) COMP VALUE +88.        
T11934     05  WS-SUB-FCTR-SIGN       PIC X(01) VALUE 'Y'.              
PCR        05  WS-FCTR-USED-CODE      PIC S9(09) COMP VALUE +87.        
PCR        05  WS-FCTR-USED-SIGN      PIC X(01) VALUE 'Y'.              
PCR        05  WS-FCTR-NOT-SAME       PIC S9(09) COMP VALUE +86.        
PCR        05  WS-SAME-FCTR-SIGN      PIC X(01) VALUE 'Y'.              
P00251     05  WS-DEP-REL-START-DT      PIC X(10) VALUE SPACES.         
P00251     05  WS-DEP-REL-ST-DATE.                                      
P00251         10 WS-DEP-REL-ST-YR      PIC X(4)  VALUE SPACES.         
P00251         10 FILLER                PIC X(1)  VALUE '-'.            
P00251         10 WS-DEP-REL-ST-MM      PIC X(2)  VALUE SPACES.         
P00251         10 FILLER                PIC X(1)  VALUE '-'.            
P00251         10 WS-DEP-REL-ST-DT      PIC X(2)  VALUE SPACES.         
P00251     05  WS-DEP-REL-END-DT        PIC X(10) VALUE SPACES.         
P00251     05  WS-DEP-REL-ED-DATE.                                      
P00251         10 WS-DEP-REL-ED-YR      PIC X(4)  VALUE SPACES.         
P00251         10 FILLER                PIC X(1)  VALUE '-'.            
P00251         10 WS-DEP-REL-ED-MM      PIC X(2)  VALUE SPACES.         
P00251         10 FILLER                PIC X(1)  VALUE '-'.            
P00251         10 WS-DEP-REL-ED-DT      PIC X(2)  VALUE SPACES.         
P00251     05  WS-DEPREL-EXISTS         PIC X(1)  VALUE SPACES.         
P00251     05  WS-MSTDEPREL-EXISTS      PIC X(1)  VALUE SPACES.         
P00251     05  WS-REL-ALREADY-EXISTS    PIC S9(09) COMP VALUE +90.      
       01  WS-LITERAL.                                                  
           05  WS-A                     PIC X(01) VALUE 'A'.            
           05  WS-B                     PIC X(01) VALUE 'B'.            
           05  WS-C                     PIC X(01) VALUE 'C'.            
           05  WS-D                     PIC X(01) VALUE 'D'.            
           05  WS-G                     PIC X(01) VALUE 'G'.            
           05  WS-I                     PIC X(01) VALUE 'I'.            
           05  WS-M                     PIC X(01) VALUE 'M'.            
           05  WS-R                     PIC X(01) VALUE 'R'.            
           05  WS-DO-NOT-ESTIMATE-C     PIC X(01) VALUE 'C'.            
P00251     05  WS-803                   PIC S9(09) VALUE -803 COMP.     
                                                                        
       01  GW-LIB-MISC-FIELDS.                                          
           05  GWL-STATUS-SUBCODE       PIC S9(9) COMP.                 
       01  FILLER                       PIC X(11) VALUE 'PARM FIELDS'.  
                                                                        
       01  PARM-FIELDS.                                                 
           05  PARM-L                   PIC S9(09) COMP.                
           05  PARM-ACTION-FLAG         PIC  X(01).                     
           05  PARM-ACCOUNT-NO-MST      PIC  X(13).                     
           05  PARM-IC-NO-MST           PIC S9(09) COMP.                
           05  PARM-METER-REF-NO-MST    PIC S9(09) COMP.                
           05  PARM-METER-NO-MST        PIC  X(09).                     
           05  PARM-ACCOUNT-NO-DEP      PIC  X(13).                     
           05  PARM-IC-NO-DEP           PIC S9(09) COMP.                
           05  PARM-METER-REF-NO-DEP    PIC S9(09) COMP.                
           05  PARM-METER-NO-DEP        PIC  X(09).                     
           05  PARM-CODE-RELATION-TYPE  PIC  X(01).                     
           05  PARM-CODE-UTIL-TYPE      PIC  X(01).                     
           05  PARM-USER-ID             PIC  X(07).                     
           05  PARM-RESP-AREA-ID        PIC  X(03).                     
           05  PARM-TRAN-COMMENT        PIC  X(210).                    
           05  PARM-TRAN-COMMENT-LEN    PIC S9(09) COMP.                
P00251     05  PARM-DEP-REL-START-DT    PIC  X(10).                     
P00251     05  PARM-DEP-REL-END-DT      PIC  X(10).                     
                                                                        
       01  SNA-FIELDS.                                                  
           05  SNA-SUBC                PIC S9(9) COMP.                  
                                                                        
       01  COUNTER-FIELDS.                                              
           05  CTR-ROWS                PIC S9(9) COMP VALUE 0.          
                                                                        
       01  WORK-FIELDS.                                                 
           05  WRK-DONE-STATUS         PIC S9(9) COMP.                  
                                                                        
       01  FILLER  PIC X(32) VALUE 'THIS IS THE ROW RETURN AREA.'.      
REARCH 01  TDS-RETURN-FIELDS.                                           
           05  RS-RETURN-CODE           PIC S9(09) COMP VALUE +0.       
REARCH 01  GTT-RETURN-FIELDS.                                           
REARCH     05  S-RETURN-CODE            PIC S9(09) COMP VALUE +0.       
           EXEC SQL                                                     01480000
              INCLUDE SQLCA                                             01490000
           END-EXEC.                                                    01500000
                                                                        
           EXEC SQL                                                     01520000
              INCLUDE TBMODEL                                           01530000
           END-EXEC.                                                    01540000
                                                                        
           EXEC SQL                                                     01560000
              INCLUDE TBMTRENV                                          01570000
           END-EXEC.                                                    01580000
                                                                        
           EXEC SQL                                                     01600000
              INCLUDE TBACCT                                            01610000
           END-EXEC.                                                    01620000
                                                                        
           EXEC SQL                                                     01640000
              INCLUDE TBUTLENV                                          01650000
           END-EXEC.                                                    01660000
                                                                        
           EXEC SQL                                                     01680000
              INCLUDE TBNAME                                            01690000
           END-EXEC.                                                    01700000
                                                                        
           EXEC SQL                                                     01720000
              INCLUDE TBCUST                                            01730000
           END-EXEC.                                                    01740000
                                                                        
           EXEC SQL                                                     01760000
              INCLUDE TBUTLREL                                          01770000
           END-EXEC.                                                    01780000
                                                                        
           EXEC SQL                                                     01800000
              INCLUDE TBMNHIST                                          01810000
           END-EXEC.                                                    01820000
                                                                        
           EXEC SQL                                                     01840000
              INCLUDE TBMNHDT                                           01850000
           END-EXEC.                                                    01860000
                                                                        
           EXEC SQL                                                     01861006
              INCLUDE TBFXDFCT                                          01862006
           END-EXEC.                                                    01870006
                                                                        
P00251     EXEC SQL                                                     01861006
P00251        INCLUDE TBCDVALU                                          01862006
P00251     END-EXEC.                                                    01870006
                                                                        
HPCCDM*EJECT                                                            02180000
CVT000     EXEC SQL                                                     00000010
CVT000         INCLUDE CWSX0010                                         00000020
CVT000     END-EXEC.                                                    00000030
CVT000                                                                  
CVT000 01  CSRERLOG-P.                                                  
CVT000     10  S-SP-NAME                 PIC X(18) VALUE SPACES.        
CVT000     10  S-SQLCODE                 PIC S9(9) COMP VALUE 0.        
CVT000     10  S-SQLSTATE                PIC X(5)  VALUE ' '.           
CVT000     10  S-TABLE-NAME              PIC X(18) VALUE SPACES.        
CVT000     10  S-HOST-VARIABLES.                                        
CVT000         49  S-HOST-VARIABLES-L    PIC S9(4) USAGE COMP.          
CVT000         49  S-HOST-VARIABLES-V    PIC X(255).                    
CVT000     10  S-SQL-STATEMENT.                                         
CVT000         49  S-SQL-STATEMENT-L     PIC S9(4) USAGE COMP.          
CVT000         49  S-SQL-STATEMENT-V     PIC X(255).                    
CVT000     10  S-SQL-DESCRIPTION.                                       
CVT000         49  S-SQL-DESCRIPTION-L   PIC S9(4) USAGE COMP.          
CVT000         49  S-SQL-DESCRIPTION-V   PIC X(255).                    
CVT000     10  WS-ABEND-SQLERRMC.                                       
CVT000         49  WS-ABEND-SQLERRMC-L   PIC S9(4) USAGE COMP.          
CVT000         49  WS-ABEND-SQLERRMC-V   PIC X(255).                    
CVT000     10  WS-SQLSTATE               PIC X(05) VALUE SPACES.        
CVT000                                                                  
CVT000                                                                  
CVT000                                                                  
CVT000 LINKAGE SECTION.                                                 
CVT000 01  LINK-ACTION-FLAG         PIC  X(01)               .          
CVT000 01  LINK-ACCOUNT-NO-MST      PIC  X(13)               .          
CVT000 01  LINK-IC-NO-MST           PIC S9(09) COMP          .          
CVT000 01  LINK-METER-REF-NO-MST    PIC S9(09) COMP          .          
CVT000 01  LINK-METER-NO-MST        PIC  X(09)               .          
CVT000 01  LINK-ACCOUNT-NO-DEP      PIC  X(13)               .          
CVT000 01  LINK-IC-NO-DEP           PIC S9(09) COMP          .          
CVT000 01  LINK-METER-REF-NO-DEP    PIC S9(09) COMP          .          
CVT000 01  LINK-METER-NO-DEP        PIC  X(09)               .          
CVT000 01  LINK-CODE-RELATION-TYPE  PIC  X(01)               .          
CVT000 01  LINK-CODE-UTIL-TYPE      PIC  X(01)               .          
CVT000 01  LINK-USER-ID             PIC  X(07)               .          
CVT000 01  LINK-RESP-AREA-ID        PIC  X(03)               .          
CVT000 01  LINK-TRAN-COMMENT        PIC  X(210)              .          
CVT000 01  LINK-TRAN-COMMENT-LEN    PIC S9(09) COMP          .          
P00251 01  LINK-DEP-REL-START-DT    PIC  X(10)               .          
P00251 01  LINK-DEP-REL-END-DT      PIC  X(10)               .          
                                                                        
CVT000 PROCEDURE DIVISION USING                                         
CVT000          LINK-ACTION-FLAG                                        
CVT000         ,LINK-ACCOUNT-NO-MST                                     
CVT000         ,LINK-IC-NO-MST                                          
CVT000         ,LINK-METER-REF-NO-MST                                   
CVT000         ,LINK-METER-NO-MST                                       
CVT000         ,LINK-ACCOUNT-NO-DEP                                     
CVT000         ,LINK-IC-NO-DEP                                          
CVT000         ,LINK-METER-REF-NO-DEP                                   
CVT000         ,LINK-METER-NO-DEP                                       
CVT000         ,LINK-CODE-RELATION-TYPE                                 
CVT000         ,LINK-CODE-UTIL-TYPE                                     
CVT000         ,LINK-USER-ID                                            
CVT000         ,LINK-RESP-AREA-ID                                       
CVT000         ,LINK-TRAN-COMMENT                                       
CVT000         ,LINK-TRAN-COMMENT-LEN                                   
P00251         ,LINK-DEP-REL-START-DT                                   
P00251         ,LINK-DEP-REL-END-DT                                     
CVT000         .                                                        
CVT000     EXEC SQL                                                     
CVT000         WHENEVER SQLWARNING                                      
CVT000             CONTINUE                                             
CVT000     END-EXEC.                                                    
CVT000                                                                  
CVT000     EXEC SQL                                                     
CVT000         WHENEVER SQLERROR                                        
CVT000             CONTINUE                                             
CVT000     END-EXEC.                                                    
CVT000                                                                  
CVT000     EXEC SQL                                                     
CVT000         WHENEVER NOT FOUND                                       
CVT000             CONTINUE                                             
CVT000     END-EXEC.                                                    
CVT999*PROCEDURE DIVISION.                                              02190000
                                                                        
      ******************************************************************02210000
      * 0000-MAINLINE                                                  *02220000
      *     CONTROLS THE MAIN PATH OF THE PROGRAM                      *02230000
      ******************************************************************02240000
                                                                        
       0000-MAINLINE.                                                   
                                                                        
           PERFORM 0100-INITIALIZE     THRU 0100-EXIT.                  
           PERFORM 2000-PROCESS-OUTPUT THRU 2000-EXIT.                  
           PERFORM 9999-END-PROGRAM    THRU 9999-EXIT.                  
       0000-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************02350000
      * 0100-INITIALIZE                                                *02360000
      *                                                                *02370000
      *                                                                *02380000
      *     1. ESTABLISH GATEWAY ENVIRONMENT (TDINIT)                  *02390000
      *     2. ACCEPT CLIENT REQUEST/ESTABLISH SNA HANDLE (TDACCEPT)   *02400000
      *     3. DETERMINE IF CLIENT HAS SENT AN RPC PARAMETER (TDRESULT)*02410000
      *                                                                *02420000
      ******************************************************************02430000
                                                                        
       0100-INITIALIZE.                                                 
           MOVE '0100' TO ACTIVE-PARAGRAPH.                             
CVT000     EXEC SQL                                                     
CVT000       DECLARE C1 CURSOR  FOR                          
CVT000       SELECT                                                     
CVT000        :S-RETURN-CODE              AS    RETURN_CODE             
CVT000          FROM CIS.SYSDUMMY1                                   
CVT000     END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ027
MFA-TR*    EXEC SQL                                                             
MFA-TR*      DECLARE C1 CURSOR WITH RETURN FOR                                  
MFA-TR*      SELECT                                                             
MFA-TR*       :S-RETURN-CODE              AS    RETURN_CODE                     
MFA-TR*         FROM SYSIBM.SYSDUMMY1                                           
MFA-TR*    END-EXEC.                                                            
CVT000     MOVE LINK-ACTION-FLAG          TO PARM-ACTION-FLAG         . 
CVT000     MOVE LINK-ACCOUNT-NO-MST       TO PARM-ACCOUNT-NO-MST      . 
CVT000     MOVE LINK-IC-NO-MST            TO PARM-IC-NO-MST           . 
CVT000     MOVE LINK-METER-REF-NO-MST     TO PARM-METER-REF-NO-MST    . 
CVT000     MOVE LINK-METER-NO-MST         TO PARM-METER-NO-MST        . 
CVT000     MOVE LINK-ACCOUNT-NO-DEP       TO PARM-ACCOUNT-NO-DEP      . 
CVT000     MOVE LINK-IC-NO-DEP            TO PARM-IC-NO-DEP           . 
CVT000     MOVE LINK-METER-REF-NO-DEP     TO PARM-METER-REF-NO-DEP    . 
CVT000     MOVE LINK-METER-NO-DEP         TO PARM-METER-NO-DEP        . 
CVT000     MOVE LINK-CODE-RELATION-TYPE   TO PARM-CODE-RELATION-TYPE  . 
CVT000     MOVE LINK-CODE-UTIL-TYPE       TO PARM-CODE-UTIL-TYPE      . 
CVT000     MOVE LINK-USER-ID              TO PARM-USER-ID             . 
CVT000     MOVE LINK-RESP-AREA-ID         TO PARM-RESP-AREA-ID        . 
CVT000     MOVE LINK-TRAN-COMMENT         TO PARM-TRAN-COMMENT        . 
CVT000     MOVE LINK-TRAN-COMMENT-LEN     TO PARM-TRAN-COMMENT-LEN    . 
P00251     MOVE LINK-DEP-REL-START-DT     TO PARM-DEP-REL-START-DT    . 
P00251     MOVE LINK-DEP-REL-END-DT       TO PARM-DEP-REL-END-DT      . 
       0100-EXIT.                                                       
           EXIT.                                                        
                                                                        
                                                                        
      ******************************************************************04340000
      * 2000-PROCESS-OUTPUT.                                           *04350000
      *                                                                *04360000
      *     1. DESCRIBE RESULT SET                                     *04370000
      *     2. UPDATE DB2 DATA                                         *04380000
      *     3. BUILD RESULT SET                                        *04390000
      *     4. SEND RESULT SET                                         *04400000
      *                                                                *04410000
      ******************************************************************04420000
                                                                        
       2000-PROCESS-OUTPUT.                                             
           MOVE '2000' TO ACTIVE-PARAGRAPH.                             
                                                                        
           PERFORM 7300-GET-TIMESTAMP THRU 7300-EXIT.                   
           IF PARM-ACTION-FLAG      = 'I'                               
              PERFORM 2200-PROCESS-INSERT THRU 2200-EXIT                
           ELSE                                                         
P00251        IF PARM-ACTION-FLAG   = 'U'                               
P00251           PERFORM 2400-PROCESS-UPDATE THRU 2400-EXIT             
P00251        ELSE                                                      
                 PERFORM 2300-PROCESS-DELETE THRU 2300-EXIT             
P00251        END-IF                                                    
           END-IF.                                                      
                                                                        
           IF WS-ROW-COUNT < 1                                          
              MOVE WS-ACTIVE-RETURN-CODE TO RS-RETURN-CODE              
              ADD 1 TO WS-ROW-COUNT                                     
REARCH        PERFORM 2000A-MOVE-RESULT THRU 2000A-EXIT                 
REARCH        PERFORM 8100-SEND-RESULT THRU 8100-EXIT
           END-IF.                  
       2000-EXIT.                                                       
           EXIT.                                                        
REARCH******************************************************************        
REARCH*2000A-MOVE-RESULT.                                                       
REARCH******************************************************************        
REARCH 2000A-MOVE-RESULT.                                               
REARCH*                                                                         
REARCH     MOVE RS-RETURN-CODE         TO S-RETURN-CODE.                
REARCH*                                                                         
REARCH 2000A-EXIT.                                                      
REARCH     EXIT.                                                        
      ******************************************************************04930000
      * 1000-PROCESS-INSERT.                                           *04940000
      ******************************************************************04950000
                                                                        
       2200-PROCESS-INSERT.                                             
           MOVE PARM-ACCOUNT-NO-MST       TO WS-ACCOUNT-NO.             
           MOVE WS-ACCOUNT-NO             TO WS-ACCOUNT-NO-NUM-MST.     
P00251     MOVE WS-ACCOUNT-NO-NUM-MST     TO UR-ACCOUNT-NO-MST.         
           MOVE PARM-ACCOUNT-NO-DEP       TO WS-ACCOUNT-NO              
T11934                                       FF-ACCOUNT-NO.             
           MOVE WS-ACCOUNT-NO             TO WS-ACCOUNT-NO-NUM-DEP.     
           MOVE WS-ACCOUNT-NO-NUM-DEP     TO MN-ACCOUNT-NO              
                                             UR-ACCOUNT-NO-DEP          
                                             AT-ACCOUNT-NO.             
           MOVE PARM-CODE-UTIL-TYPE       TO UR-CODE-UTIL-TYPE-DEP      
                                             UR-CODE-UTIL-TYPE-MST      
P00251                                       UT-CODE-UTIL-TYPE          
                                             MN-CODE-UTIL-TYPE          
T11934                                       FF-CODE-UTIL-TYPE.         
           MOVE PARM-IC-NO-MST            TO UR-IC-NO-MST.              
           MOVE PARM-IC-NO-DEP            TO UR-IC-NO-DEP               
                                             MN-IC-NO                   
T11934                                       FF-IC-NO.                  
           MOVE PARM-METER-REF-NO-MST     TO UR-MTR-REF-NO-MST.         
           MOVE PARM-METER-REF-NO-DEP     TO UR-MTR-REF-NO-DEP          
                                             MN-MTR-REF-NO.             
P00251     MOVE PARM-CODE-RELATION-TYPE   TO UR-CODE-RELATION-TYPE.     
P00251*                                                                         
P00251     MOVE PARM-DEP-REL-START-DT       TO WS-DEP-REL-START-DT.     
P00251     MOVE WS-DEP-REL-START-DT(1:2)    TO WS-DEP-REL-ST-MM.        
P00251     MOVE WS-DEP-REL-START-DT(4:2)    TO WS-DEP-REL-ST-DT.        
P00251     MOVE WS-DEP-REL-START-DT(7:4)    TO WS-DEP-REL-ST-YR.        
P00251     MOVE WS-DEP-REL-ST-DATE          TO WS-DEP-REL-START-DT      
P00251                                         UR-DEP-REL-START-DT.     
P00251*                                                                 05110000
P00251     MOVE PARM-DEP-REL-END-DT         TO WS-DEP-REL-END-DT.       
P00251     MOVE WS-DEP-REL-END-DT (1:2)     TO WS-DEP-REL-ED-MM.        
P00251     MOVE WS-DEP-REL-END-DT (4:2)     TO WS-DEP-REL-ED-DT.        
P00251     MOVE WS-DEP-REL-END-DT (7:4)     TO WS-DEP-REL-ED-YR.        
P00251     MOVE WS-DEP-REL-ED-DATE          TO WS-DEP-REL-END-DT        
P00251                                         UR-DEP-REL-END-DT.       
P00251*                                                                         
P00251***  CHECK IF MASTER/DEPEND METER RELATIONSHIP ALREADY EXISTS             
P00251***  FOR SAME REVENUE MONTH. IF EXISTS EXIT AND RETURN SPECIAL            
P00251***  RETURN CODE.                                                         
P00251     PERFORM 7610-CHECK-MSTDEPREL-EXISTS THRU 7610-EXIT.          
P00251     IF WS-MSTDEPREL-EXISTS = 'Y'                                 
P00251        MOVE WS-REL-ALREADY-EXISTS TO RS-RETURN-CODE              
P00251        PERFORM 2000A-MOVE-RESULT THRU 2000A-EXIT                 
P00251        PERFORM 8100-SEND-RESULT THRU 8100-EXIT                   
P00251        PERFORM 9999-END-PROGRAM THRU 9999-EXIT                   
P00251     END-IF.                                                      
P00251*                                                                         
T11934     PERFORM 7410-GET-SUB-RATE  THRU 7410-EXIT.                   
P00251     IF WS-SUB-RATE = '065' OR WS-SUB-RATE = '066'                
T11934        MOVE 'SL' TO FF-FIXED-FCTR-TYP-CD                         
T11934        PERFORM 7420-GET-SUB-FACTOR-TYP THRU 7420-EXIT            
T11934        IF WS-ACTIVE-RETURN-CODE = NOT-FOUND                      
T11934           MOVE WS-NO-STAT-FCTR TO RS-RETURN-CODE                 
REARCH           PERFORM 2000A-MOVE-RESULT THRU 2000A-EXIT              
REARCH           PERFORM 8100-SEND-RESULT THRU 8100-EXIT                
T11934           PERFORM 9999-END-PROGRAM THRU 9999-EXIT                
T11934        END-IF                                                    
P00251        PERFORM 7432-CHECK-SAME-FCTR THRU 7432-EXIT               
PCR           IF WS-ACTIVE-RETURN-CODE NOT = NOT-FOUND                  
PCR              MOVE WS-FCTR-NOT-SAME  TO RS-RETURN-CODE               
REARCH           PERFORM 2000A-MOVE-RESULT THRU 2000A-EXIT              
REARCH           PERFORM 8100-SEND-RESULT THRU 8100-EXIT                
PCR              PERFORM 9999-END-PROGRAM THRU 9999-EXIT                
P00251        END-IF                                                    
P00251     END-IF.                                                      
           PERFORM 7035-SEL-ACCOUNT-CYC THRU 7035-EXIT.                 
           PERFORM 5000-MAINTENANCE-HISTORY THRU 5000-EXIT.             
           MOVE MH-TRANS-HIST-SEQ-NO TO MN-LAST-UPDATE-TS               
                                       AT-LAST-UPDATE-TS.               
                                                                        
           MOVE WS-ACCOUNT-NO-NUM-MST   TO MN-ACCOUNT-NO                
                                           UR-ACCOUNT-NO-MST            
                                           AT-ACCOUNT-NO.               
           MOVE PARM-IC-NO-MST          TO MN-IC-NO.                    
P00251     IF WS-ACCOUNT-NO-NUM-MST NOT = WS-ACCOUNT-NO-NUM-DEP         
             MOVE 'DEP ACCT NO'           TO MI-COLUMN-DESC             
             MOVE +13                     TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +13                     TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE UR-ACCOUNT-NO-DEP       TO MI-CHG-COLUMN-VALUE-TEXT   
             MOVE SPACES                  TO MI-TABLE-ID                
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
P00251     END-IF.                                                      
           MOVE 'DEP UTIL TYPE'         TO MI-COLUMN-DESC.              
           MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN.     
           MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT.    
           MOVE SPACES                  TO MI-TABLE-ID.                 
P00251     EVALUATE UR-CODE-UTIL-TYPE-DEP                               
P00251     WHEN 'E'                                                     
P00251       MOVE +8                    TO MI-CHG-COLUMN-VALUE-LEN      
P00251       MOVE 'ELECTRIC'            TO MI-CHG-COLUMN-VALUE-TEXT     
P00251     WHEN 'G'                                                     
P00251       MOVE +3                    TO MI-CHG-COLUMN-VALUE-LEN      
P00251       MOVE 'GAS'                 TO MI-CHG-COLUMN-VALUE-TEXT     
P00251     WHEN OTHER                                                   
P00251       MOVE +1                    TO MI-CHG-COLUMN-VALUE-LEN      
P00251       MOVE UR-CODE-UTIL-TYPE-DEP TO MI-CHG-COLUMN-VALUE-TEXT     
P00251     END-EVALUATE.                                                
           PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
           MOVE 'DEP IC NO   '          TO MI-COLUMN-DESC.              
           MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN.     
           MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT.    
           MOVE +4                      TO MI-CHG-COLUMN-VALUE-LEN.     
           MOVE SPACES                  TO MI-TABLE-ID.                 
           MOVE UR-IC-NO-DEP            TO MI-CHG-COLUMN-VALUE-TEXT.    
           PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
           MOVE 'DEP MTR REF NO'        TO MI-COLUMN-DESC.              
           MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN.     
           MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT.    
           MOVE +4                      TO MI-CHG-COLUMN-VALUE-LEN.     
           MOVE SPACES                  TO MI-TABLE-ID.                 
           MOVE UR-MTR-REF-NO-DEP       TO MI-CHG-COLUMN-VALUE-TEXT.    
           PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251     MOVE WS-ACCOUNT-NO-NUM-DEP   TO UT-ACCOUNT-NO.               
P00251     MOVE UR-IC-NO-DEP            TO UT-IC-NO.                    
P00251     PERFORM 7435-GET-UTIL-DETAILS    THRU 7435-EXIT.             
P00251     MOVE 'N'                         TO WS-CODE-EST-OK-DEP-UPDT. 
P00251     IF UT-CODE-ESTIMATE-OK NOT = WS-DO-NOT-ESTIMATE-C            
P00251        MOVE 'ESTIMATE OK'            TO MI-COLUMN-DESC           
P00251        MOVE +1                       TO MI-PRV-COLUMN-VALUE-LEN  
P00251        MOVE UT-CODE-ESTIMATE-OK      TO MI-PRV-COLUMN-VALUE-TEXT 
P00251                                         WS-CODE-ESTIMATE-OK-DEP  
P00251        MOVE '37'                     TO MI-TABLE-ID              
P00251        MOVE +1                       TO MI-CHG-COLUMN-VALUE-LEN  
P00251        MOVE WS-DO-NOT-ESTIMATE-C     TO MI-CHG-COLUMN-VALUE-TEXT 
P00251        PERFORM 5010-MNT-HST-DETAIL   THRU 5010-EXIT              
P00251        MOVE WS-DO-NOT-ESTIMATE-C     TO UT-CODE-ESTIMATE-OK      
P00251        PERFORM 7440-UPDATE-UT-DETAIL THRU 7440-EXIT              
P00251        SET CODE-EST-OK-DEP-UPDT      TO TRUE                     
P00251     END-IF.                                                      
                                                                        
P00251     IF WS-ACCOUNT-NO-NUM-MST NOT = WS-ACCOUNT-NO-NUM-DEP         
             MOVE 'MAST ACCOUNT NO'       TO MI-COLUMN-DESC             
             MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +13                     TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE UR-ACCOUNT-NO-MST       TO MI-CHG-COLUMN-VALUE-TEXT   
             MOVE SPACES                  TO MI-TABLE-ID                
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
P00251     END-IF.                                                      
           MOVE 'MAST UTIL TYPE'        TO MI-COLUMN-DESC.              
           MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN.     
           MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT.    
           MOVE SPACES                  TO MI-TABLE-ID.                 
P00251     EVALUATE UR-CODE-UTIL-TYPE-MST                               
P00251     WHEN 'E'                                                     
P00251       MOVE +8                    TO MI-CHG-COLUMN-VALUE-LEN      
P00251       MOVE 'ELECTRIC'            TO MI-CHG-COLUMN-VALUE-TEXT     
P00251     WHEN 'G'                                                     
P00251       MOVE +3                    TO MI-CHG-COLUMN-VALUE-LEN      
P00251       MOVE 'GAS'                 TO MI-CHG-COLUMN-VALUE-TEXT     
P00251     WHEN OTHER                                                   
P00251       MOVE +1                    TO MI-CHG-COLUMN-VALUE-LEN      
P00251       MOVE UR-CODE-UTIL-TYPE-MST TO MI-CHG-COLUMN-VALUE-TEXT     
P00251     END-EVALUATE.                                                
           PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
           MOVE 'MAST IC NO'            TO MI-COLUMN-DESC.              
           MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN.     
           MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT.    
           MOVE +4                      TO MI-CHG-COLUMN-VALUE-LEN.     
           MOVE SPACES                  TO MI-TABLE-ID.                 
           MOVE UR-IC-NO-MST            TO MI-CHG-COLUMN-VALUE-TEXT.    
           PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
           MOVE 'MAST MTR REF NO'       TO MI-COLUMN-DESC.              
           MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN.     
           MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT.    
           MOVE +4                      TO MI-CHG-COLUMN-VALUE-LEN.     
           MOVE SPACES                  TO MI-TABLE-ID.                 
           MOVE UR-MTR-REF-NO-MST       TO MI-CHG-COLUMN-VALUE-TEXT.    
           PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251     MOVE WS-ACCOUNT-NO-NUM-MST   TO UT-ACCOUNT-NO                
P00251     MOVE UR-IC-NO-MST            TO UT-IC-NO                     
P00251     PERFORM 7435-GET-UTIL-DETAILS    THRU 7435-EXIT              
P00251     IF UT-CODE-ESTIMATE-OK NOT = WS-DO-NOT-ESTIMATE-C            
P00251       MOVE 'ESTIMATE OK'            TO MI-COLUMN-DESC            
P00251       MOVE +1                       TO MI-PRV-COLUMN-VALUE-LEN   
P00251       MOVE UT-CODE-ESTIMATE-OK      TO MI-PRV-COLUMN-VALUE-TEXT  
P00251       MOVE '37'                     TO MI-TABLE-ID               
P00251       MOVE +1                       TO MI-CHG-COLUMN-VALUE-LEN   
P00251       MOVE WS-DO-NOT-ESTIMATE-C     TO MI-CHG-COLUMN-VALUE-TEXT  
P00251       PERFORM 5010-MNT-HST-DETAIL   THRU 5010-EXIT               
P00251       MOVE WS-DO-NOT-ESTIMATE-C     TO UT-CODE-ESTIMATE-OK       
P00251       IF WS-ACCOUNT-NO-NUM-DEP = WS-ACCOUNT-NO-NUM-MST           
P00251          PERFORM 7440-UPDATE-UT-DETAIL THRU 7440-EXIT            
P00251       END-IF                                                     
P00251     END-IF.                                                      
           MOVE 'RELATION TYPE'         TO MI-COLUMN-DESC.              
           MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN.     
           MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT.    
           MOVE '50'                    TO MI-TABLE-ID.                 
P00251     MOVE UR-CODE-RELATION-TYPE   TO UV-CODE-VALUE-TEXT           
P00251     MOVE +1                      TO UV-CODE-VALUE-LEN            
P00251     MOVE 'CODE_RELATION_TYPE'    TO UV-COLUMN-NA-TEXT            
P00251     MOVE +18                     TO UV-COLUMN-NA-LEN             
P00251     MOVE 'CSS_UTL_BILL_REL'      TO UV-TABLE-NA-TEXT             
P00251     MOVE +16                     TO UV-TABLE-NA-LEN              
P00251     PERFORM 7040-GET-CODE-VALUE-DESC THRU 7040-EXIT.             
P00251     MOVE UV-CODE-SHORT-DESC      TO MI-CHG-COLUMN-VALUE.         
           PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251     MOVE 'START REV MTH'         TO MI-COLUMN-DESC.              
P00251     MOVE +10                     TO MI-PRV-COLUMN-VALUE-LEN.     
P00251     MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT.    
P00251     MOVE +10                     TO MI-CHG-COLUMN-VALUE-LEN.     
P00251     MOVE SPACES                  TO MI-TABLE-ID.                 
P00251     MOVE UR-DEP-REL-START-DT     TO MI-CHG-COLUMN-VALUE-TEXT.    
P00251     PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251     MOVE 'END REV MTH'           TO MI-COLUMN-DESC.              
P00251     MOVE +10                     TO MI-PRV-COLUMN-VALUE-LEN.     
P00251     MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT.    
P00251     MOVE +10                     TO MI-CHG-COLUMN-VALUE-LEN.     
P00251     MOVE SPACES                  TO MI-TABLE-ID.                 
P00251     MOVE UR-DEP-REL-END-DT       TO MI-CHG-COLUMN-VALUE-TEXT.    
P00251     PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251     IF WS-ACCOUNT-NO-NUM-MST NOT = WS-ACCOUNT-NO-NUM-DEP         
             PERFORM 7035-SEL-ACCOUNT-CYC THRU 7035-EXIT                
             PERFORM 5000-MAINTENANCE-HISTORY THRU 5000-EXIT            
             MOVE MH-TRANS-HIST-SEQ-NO TO MN-LAST-UPDATE-TS             
                                         AT-LAST-UPDATE-TS              
                                                                        
             MOVE 'DEP ACCOUNT NO'        TO MI-COLUMN-DESC             
             MOVE +13                     TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +13                     TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE UR-ACCOUNT-NO-DEP       TO MI-CHG-COLUMN-VALUE-TEXT   
             MOVE SPACES                  TO MI-TABLE-ID                
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
             MOVE 'DEP UTIL TYPE'         TO MI-COLUMN-DESC             
             MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE SPACES                  TO MI-TABLE-ID                
P00251       EVALUATE UR-CODE-UTIL-TYPE-DEP                             
P00251       WHEN 'E'                                                   
P00251         MOVE +8                    TO MI-CHG-COLUMN-VALUE-LEN    
P00251         MOVE 'ELECTRIC'            TO MI-CHG-COLUMN-VALUE-TEXT   
P00251       WHEN 'G'                                                   
P00251         MOVE +3                    TO MI-CHG-COLUMN-VALUE-LEN    
P00251         MOVE 'GAS'                 TO MI-CHG-COLUMN-VALUE-TEXT   
P00251       WHEN OTHER                                                 
P00251         MOVE +1                    TO MI-CHG-COLUMN-VALUE-LEN    
P00251         MOVE UR-CODE-UTIL-TYPE-DEP TO MI-CHG-COLUMN-VALUE-TEXT   
P00251       END-EVALUATE                                               
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
             MOVE 'DEP IC NO'             TO MI-COLUMN-DESC             
             MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +4                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE SPACES                  TO MI-TABLE-ID                
             MOVE UR-IC-NO-DEP            TO MI-CHG-COLUMN-VALUE-TEXT   
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
             MOVE 'DEP MTR REF NO'        TO MI-COLUMN-DESC             
             MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +4                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE SPACES                  TO MI-TABLE-ID                
             MOVE UR-MTR-REF-NO-DEP       TO MI-CHG-COLUMN-VALUE-TEXT   
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
                                                                        
P00251       IF WS-CODE-ESTIMATE-OK-DEP  NOT = WS-DO-NOT-ESTIMATE-C     
P00251          AND CODE-EST-OK-DEP-UPDT                                
P00251         MOVE 'ESTIMATE OK'            TO MI-COLUMN-DESC          
P00251         MOVE +1                       TO MI-PRV-COLUMN-VALUE-LEN 
P00251         MOVE WS-CODE-ESTIMATE-OK-DEP  TO MI-PRV-COLUMN-VALUE-TEXT
P00251         MOVE '37'                     TO MI-TABLE-ID             
P00251         MOVE +1                       TO MI-CHG-COLUMN-VALUE-LEN 
P00251         MOVE WS-DO-NOT-ESTIMATE-C     TO MI-CHG-COLUMN-VALUE-TEXT
P00251         PERFORM 5010-MNT-HST-DETAIL   THRU 5010-EXIT             
P00251       END-IF                                                     
             MOVE 'MAST ACCT NO'          TO MI-COLUMN-DESC             
             MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +13                     TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE UR-ACCOUNT-NO-MST       TO MI-CHG-COLUMN-VALUE-TEXT   
             MOVE SPACES                  TO MI-TABLE-ID                
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
             MOVE 'MAST UTIL TYPE'        TO MI-COLUMN-DESC             
             MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE SPACES                  TO MI-TABLE-ID                
P00251       EVALUATE UR-CODE-UTIL-TYPE-MST                             
P00251       WHEN 'E'                                                   
P00251         MOVE +8                    TO MI-CHG-COLUMN-VALUE-LEN    
P00251         MOVE 'ELECTRIC'            TO MI-CHG-COLUMN-VALUE-TEXT   
P00251       WHEN 'G'                                                   
P00251         MOVE +3                    TO MI-CHG-COLUMN-VALUE-LEN    
P00251         MOVE 'GAS'                 TO MI-CHG-COLUMN-VALUE-TEXT   
P00251       WHEN OTHER                                                 
P00251         MOVE +1                    TO MI-CHG-COLUMN-VALUE-LEN    
P00251         MOVE UR-CODE-UTIL-TYPE-MST TO MI-CHG-COLUMN-VALUE-TEXT   
P00251       END-EVALUATE                                               
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
             MOVE 'MAST IC NO  '          TO MI-COLUMN-DESC             
             MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +4                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE SPACES                  TO MI-TABLE-ID                
             MOVE UR-IC-NO-MST            TO MI-CHG-COLUMN-VALUE-TEXT   
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
             MOVE 'MAST MTR REF NO'       TO MI-COLUMN-DESC             
             MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +4                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE SPACES                  TO MI-TABLE-ID                
             MOVE UR-MTR-REF-NO-MST       TO MI-CHG-COLUMN-VALUE-TEXT   
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
P00251       MOVE WS-ACCOUNT-NO-NUM-MST   TO UT-ACCOUNT-NO              
P00251       MOVE UR-IC-NO-MST            TO UT-IC-NO                   
P00251       PERFORM 7435-GET-UTIL-DETAILS    THRU 7435-EXIT            
P00251       IF UT-CODE-ESTIMATE-OK NOT = WS-DO-NOT-ESTIMATE-C          
P00251         MOVE 'ESTIMATE OK'            TO MI-COLUMN-DESC          
P00251         MOVE +1                       TO MI-PRV-COLUMN-VALUE-LEN 
P00251         MOVE UT-CODE-ESTIMATE-OK      TO MI-PRV-COLUMN-VALUE-TEXT
P00251         MOVE '37'                     TO MI-TABLE-ID             
P00251         MOVE +1                       TO MI-CHG-COLUMN-VALUE-LEN 
P00251         MOVE WS-DO-NOT-ESTIMATE-C     TO MI-CHG-COLUMN-VALUE-TEXT
P00251         PERFORM 5010-MNT-HST-DETAIL   THRU 5010-EXIT             
P00251         MOVE WS-DO-NOT-ESTIMATE-C     TO UT-CODE-ESTIMATE-OK     
P00251         PERFORM 7440-UPDATE-UT-DETAIL THRU 7440-EXIT             
P00251       END-IF                                                     
             MOVE 'RELATION TYPE '        TO MI-COLUMN-DESC             
             MOVE +5                      TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE '50'                    TO MI-TABLE-ID                
P00251       MOVE UR-CODE-RELATION-TYPE   TO UV-CODE-VALUE-TEXT         
P00251       MOVE +1                      TO UV-CODE-VALUE-LEN          
P00251       MOVE 'CODE_RELATION_TYPE'    TO UV-COLUMN-NA-TEXT          
P00251       MOVE +18                     TO UV-COLUMN-NA-LEN           
P00251       MOVE 'CSS_UTL_BILL_REL'      TO UV-TABLE-NA-TEXT           
P00251       MOVE +16                     TO UV-TABLE-NA-LEN            
P00251       PERFORM 7040-GET-CODE-VALUE-DESC THRU 7040-EXIT            
P00251       MOVE UV-CODE-SHORT-DESC      TO MI-CHG-COLUMN-VALUE        
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
P00251       MOVE 'START REV MTH'         TO MI-COLUMN-DESC             
P00251       MOVE +10                     TO MI-PRV-COLUMN-VALUE-LEN    
P00251       MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT   
P00251       MOVE +10                     TO MI-CHG-COLUMN-VALUE-LEN    
P00251       MOVE SPACES                  TO MI-TABLE-ID                
P00251       MOVE UR-DEP-REL-START-DT     TO MI-CHG-COLUMN-VALUE-TEXT   
P00251       PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
P00251       MOVE 'END REV MTH'           TO MI-COLUMN-DESC             
P00251       MOVE +10                     TO MI-PRV-COLUMN-VALUE-LEN    
P00251       MOVE '*NEW*'                 TO MI-PRV-COLUMN-VALUE-TEXT   
P00251       MOVE +10                     TO MI-CHG-COLUMN-VALUE-LEN    
P00251       MOVE SPACES                  TO MI-TABLE-ID                
P00251       MOVE UR-DEP-REL-END-DT       TO MI-CHG-COLUMN-VALUE-TEXT   
P00251       PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
P00251     END-IF.                                                      
                                                                        
           PERFORM 7000-INSERT-UTL-BILL-REL THRU 7000-EXIT.             
P00251***  CHECK IF MASTER/DEPEND METER RELATIONSHIP ALREADY EXISTED            
P00251***  IF EXISTED EXIT AND RETURN SPECIAL RETURN CODE.                      
P00251     IF WS-ACTIVE-RETURN-CODE = WS-803                            
P00251        MOVE WS-REL-ALREADY-EXISTS TO RS-RETURN-CODE              
P00251        PERFORM 2000A-MOVE-RESULT  THRU 2000A-EXIT                
P00251        PERFORM 8100-SEND-RESULT   THRU 8100-EXIT                 
P00251        PERFORM 9999-END-PROGRAM   THRU 9999-EXIT                 
P00251     END-IF.                                                      
       2200-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************07490000
      * 2300-PROCESS-DELETE.                                           *07500000
      ******************************************************************07510000
                                                                        
       2300-PROCESS-DELETE.                                             
           MOVE PARM-ACCOUNT-NO-MST         TO WS-ACCOUNT-NO.           
           MOVE WS-ACCOUNT-NO               TO WS-ACCOUNT-NO-NUM-MST.   
P00251     MOVE WS-ACCOUNT-NO-NUM-MST       TO UR-ACCOUNT-NO-MST.       
           MOVE PARM-ACCOUNT-NO-DEP         TO WS-ACCOUNT-NO.           
           MOVE WS-ACCOUNT-NO               TO WS-ACCOUNT-NO-NUM-DEP.   
           MOVE WS-ACCOUNT-NO-NUM-DEP       TO UR-ACCOUNT-NO-DEP.       
           MOVE PARM-CODE-UTIL-TYPE         TO UR-CODE-UTIL-TYPE-DEP    
P00251                                         UR-CODE-UTIL-TYPE-MST.   
           MOVE PARM-IC-NO-DEP              TO UR-IC-NO-DEP.            
P00251     MOVE PARM-IC-NO-MST              TO UR-IC-NO-MST.            
           MOVE PARM-METER-REF-NO-DEP       TO UR-MTR-REF-NO-DEP.       
P00251     MOVE PARM-METER-REF-NO-MST       TO UR-MTR-REF-NO-MST.       
           MOVE WS-ACCOUNT-NO-NUM-DEP       TO AT-ACCOUNT-NO            
                                               MN-ACCOUNT-NO.           
           MOVE PARM-CODE-UTIL-TYPE         TO MN-CODE-UTIL-TYPE.       
           MOVE PARM-IC-NO-DEP              TO MN-IC-NO.                
           MOVE PARM-METER-REF-NO-DEP       TO MN-MTR-REF-NO.           
           MOVE PARM-METER-NO-DEP           TO MN-METER-NO.             
P00251*                                                                         
P00251     MOVE PARM-CODE-RELATION-TYPE     TO UR-CODE-RELATION-TYPE.   
P00251*                                                                         
P00251     MOVE PARM-DEP-REL-START-DT       TO WS-DEP-REL-START-DT.     
P00251     MOVE WS-DEP-REL-START-DT(1:2)    TO WS-DEP-REL-ST-MM.        
P00251     MOVE WS-DEP-REL-START-DT(4:2)    TO WS-DEP-REL-ST-DT.        
P00251     MOVE WS-DEP-REL-START-DT(7:4)    TO WS-DEP-REL-ST-YR.        
P00251     MOVE WS-DEP-REL-ST-DATE          TO WS-DEP-REL-START-DT      
P00251                                         UR-DEP-REL-START-DT.     
P00251*                                                                 05110000
P00251     MOVE PARM-DEP-REL-END-DT         TO WS-DEP-REL-END-DT.       
P00251     MOVE WS-DEP-REL-END-DT (1:2)     TO WS-DEP-REL-ED-MM.        
P00251     MOVE WS-DEP-REL-END-DT (4:2)     TO WS-DEP-REL-ED-DT.        
P00251     MOVE WS-DEP-REL-END-DT (7:4)     TO WS-DEP-REL-ED-YR.        
P00251     MOVE WS-DEP-REL-ED-DATE          TO WS-DEP-REL-END-DT        
P00251                                         UR-DEP-REL-END-DT.       
P00251*                                                                         
           PERFORM 7035-SEL-ACCOUNT-CYC THRU 7035-EXIT.                 
           PERFORM 5000-MAINTENANCE-HISTORY THRU 5000-EXIT.             
           MOVE MH-TRANS-HIST-SEQ-NO TO MN-LAST-UPDATE-TS               
                                       AT-LAST-UPDATE-TS.               
P00251     IF WS-ACCOUNT-NO-NUM-MST NOT = WS-ACCOUNT-NO-NUM-DEP         
             MOVE 'DEP ACCT NO'           TO MI-COLUMN-DESC             
             MOVE +13                     TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE UR-ACCOUNT-NO-DEP       TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT   
             MOVE SPACES                  TO MI-TABLE-ID                
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
P00251     END-IF                                                       
           MOVE 'DEP UTIL TYPE'         TO MI-COLUMN-DESC.              
P00251     EVALUATE UR-CODE-UTIL-TYPE-DEP                               
P00251     WHEN 'E'                                                     
P00251       MOVE +8                    TO MI-PRV-COLUMN-VALUE-LEN      
P00251       MOVE 'ELECTRIC'            TO MI-PRV-COLUMN-VALUE-TEXT     
P00251     WHEN 'G'                                                     
P00251       MOVE +3                    TO MI-PRV-COLUMN-VALUE-LEN      
P00251       MOVE 'GAS'                 TO MI-PRV-COLUMN-VALUE-TEXT     
P00251     WHEN OTHER                                                   
P00251       MOVE +1                    TO MI-PRV-COLUMN-VALUE-LEN      
P00251       MOVE UR-CODE-UTIL-TYPE-DEP TO MI-PRV-COLUMN-VALUE-TEXT     
P00251     END-EVALUATE.                                                
           MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN.     
           MOVE SPACES                  TO MI-TABLE-ID.                 
           MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT.    
           PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
           MOVE 'DEP IC NO   '          TO MI-COLUMN-DESC.              
           MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN.     
           MOVE UR-IC-NO-DEP            TO MI-PRV-COLUMN-VALUE-TEXT.    
           MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN.     
           MOVE SPACES                  TO MI-TABLE-ID.                 
           MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT.    
           PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
           MOVE 'DEP MTR REF NO'        TO MI-COLUMN-DESC.              
           MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN.     
           MOVE UR-MTR-REF-NO-DEP       TO MI-PRV-COLUMN-VALUE-TEXT.    
           MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN.     
           MOVE SPACES                  TO MI-TABLE-ID.                 
           MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT.    
           PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
                                                                        
P00251*    PERFORM 7200-SELECT-UTL-BILL-REL THRU 7200-EXIT.             08020000
P00251     IF WS-ACCOUNT-NO-NUM-MST NOT = WS-ACCOUNT-NO-NUM-DEP         
             MOVE 'MAST ACCT NO'          TO MI-COLUMN-DESC             
             MOVE +13                     TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE  UR-ACCOUNT-NO-MST      TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT   
             MOVE SPACES                  TO MI-TABLE-ID                
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
P00251     END-IF                                                       
           MOVE 'MAST UTIL TYPE'        TO MI-COLUMN-DESC.              
P00251     EVALUATE UR-CODE-UTIL-TYPE-MST                               
P00251     WHEN 'E'                                                     
P00251       MOVE +8                    TO MI-PRV-COLUMN-VALUE-LEN      
P00251       MOVE 'ELECTRIC'            TO MI-PRV-COLUMN-VALUE-TEXT     
P00251     WHEN 'G'                                                     
P00251       MOVE +3                    TO MI-PRV-COLUMN-VALUE-LEN      
P00251       MOVE 'GAS'                 TO MI-PRV-COLUMN-VALUE-TEXT     
P00251     WHEN OTHER                                                   
P00251       MOVE +1                    TO MI-PRV-COLUMN-VALUE-LEN      
P00251       MOVE UR-CODE-UTIL-TYPE-MST TO MI-PRV-COLUMN-VALUE-TEXT     
P00251     END-EVALUATE.                                                
           MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN.     
           MOVE SPACES                  TO MI-TABLE-ID.                 
           MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT.    
           PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
           MOVE 'MAST IC NO  '          TO MI-COLUMN-DESC.              
           MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN.     
           MOVE UR-IC-NO-MST          TO MI-PRV-COLUMN-VALUE-TEXT.      
           MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN.     
           MOVE SPACES                  TO MI-TABLE-ID.                 
           MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT.    
           PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
           MOVE 'MAST MTR REF NO'       TO MI-COLUMN-DESC.              
           MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN.     
           MOVE UR-MTR-REF-NO-MST      TO MI-PRV-COLUMN-VALUE-TEXT.     
           MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN.     
           MOVE SPACES                  TO MI-TABLE-ID.                 
           MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT.    
           PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
           MOVE 'RELATION TYPE'         TO MI-COLUMN-DESC.              
P00251     MOVE UR-CODE-RELATION-TYPE   TO UV-CODE-VALUE-TEXT           
P00251     MOVE +1                      TO UV-CODE-VALUE-LEN            
P00251     MOVE 'CODE_RELATION_TYPE'    TO UV-COLUMN-NA-TEXT            
P00251     MOVE +18                     TO UV-COLUMN-NA-LEN             
P00251     MOVE 'CSS_UTL_BILL_REL'      TO UV-TABLE-NA-TEXT             
P00251     MOVE +16                     TO UV-TABLE-NA-LEN              
P00251     PERFORM 7040-GET-CODE-VALUE-DESC THRU 7040-EXIT.             
P00251     MOVE UV-CODE-SHORT-DESC      TO MI-PRV-COLUMN-VALUE.         
           MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN.     
           MOVE '50'                    TO MI-TABLE-ID.                 
           MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT.    
           PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251     MOVE 'START REV MTH'         TO MI-COLUMN-DESC.              
P00251     MOVE +10                     TO MI-PRV-COLUMN-VALUE-LEN.     
P00251     MOVE UR-DEP-REL-START-DT     TO MI-PRV-COLUMN-VALUE-TEXT.    
P00251     MOVE +10                     TO MI-CHG-COLUMN-VALUE-LEN.     
P00251     MOVE SPACES                  TO MI-TABLE-ID.                 
P00251     MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT.    
P00251     PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251     MOVE 'END REV MTH'           TO MI-COLUMN-DESC.              
P00251     MOVE +10                     TO MI-PRV-COLUMN-VALUE-LEN.     
P00251     MOVE UR-DEP-REL-END-DT       TO MI-PRV-COLUMN-VALUE-TEXT.    
P00251     MOVE +10                     TO MI-CHG-COLUMN-VALUE-LEN.     
P00251     MOVE SPACES                  TO MI-TABLE-ID.                 
P00251     MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT.    
P00251     PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
                                                                        
           PERFORM 7100-DEL-UTL-BILL-REL THRU 7100-EXIT.                
P00251     IF WS-ACCOUNT-NO-NUM-MST NOT = WS-ACCOUNT-NO-NUM-DEP         
             MOVE WS-ACCOUNT-NO-NUM-MST  TO UR-ACCOUNT-NO-MST           
                                            AT-ACCOUNT-NO               
                                                                        
             MOVE PARM-CODE-UTIL-TYPE TO UR-CODE-UTIL-TYPE-MST          
             MOVE PARM-IC-NO-MST      TO UR-IC-NO-MST                   
             MOVE PARM-METER-REF-NO-MST TO UR-MTR-REF-NO-MST            
                                                                        
      *   DO MAINTENACE HIST FOR MASTER ACCOUNT DEL                       087000
             PERFORM 7035-SEL-ACCOUNT-CYC THRU 7035-EXIT                
             PERFORM 5000-MAINTENANCE-HISTORY THRU 5000-EXIT            
             MOVE MH-TRANS-HIST-SEQ-NO TO MN-LAST-UPDATE-TS             
                                         AT-LAST-UPDATE-TS              
             MOVE 'DEP ACCT NO'           TO MI-COLUMN-DESC             
             MOVE +13                     TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE UR-ACCOUNT-NO-DEP       TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT   
             MOVE SPACES                  TO MI-TABLE-ID                
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
             MOVE 'DEP UTIL TYPE'         TO MI-COLUMN-DESC             
P00251       EVALUATE UR-CODE-UTIL-TYPE-DEP                             
P00251       WHEN 'E'                                                   
P00251         MOVE +8                    TO MI-PRV-COLUMN-VALUE-LEN    
P00251         MOVE 'ELECTRIC'            TO MI-PRV-COLUMN-VALUE-TEXT   
P00251       WHEN 'G'                                                   
P00251         MOVE +3                    TO MI-PRV-COLUMN-VALUE-LEN    
P00251         MOVE 'GAS'                 TO MI-PRV-COLUMN-VALUE-TEXT   
P00251       WHEN OTHER                                                 
P00251         MOVE +1                    TO MI-PRV-COLUMN-VALUE-LEN    
P00251         MOVE UR-CODE-UTIL-TYPE-DEP TO MI-PRV-COLUMN-VALUE-TEXT   
P00251       END-EVALUATE                                               
             MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE SPACES                  TO MI-TABLE-ID                
             MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT   
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
             MOVE 'DEP IC NO'             TO MI-COLUMN-DESC             
             MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE UR-IC-NO-DEP            TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE SPACES                  TO MI-TABLE-ID                
             MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT   
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
             MOVE 'DEP MTR REF NO'        TO MI-COLUMN-DESC             
             MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE UR-MTR-REF-NO-DEP       TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE SPACES                  TO MI-TABLE-ID                
             MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT   
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
                                                                        
             MOVE 'MAST ACCT NO'          TO MI-COLUMN-DESC             
             MOVE +13                     TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE PARM-ACCOUNT-NO-MST     TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT   
             MOVE SPACES                  TO MI-TABLE-ID                
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
             MOVE 'MAST UTIL TYPE'        TO MI-COLUMN-DESC             
                                                                        
P00251       EVALUATE PARM-CODE-UTIL-TYPE                               
P00251       WHEN 'E'                                                   
P00251         MOVE +8                    TO MI-PRV-COLUMN-VALUE-LEN    
P00251         MOVE 'ELECTRIC'            TO MI-PRV-COLUMN-VALUE-TEXT   
P00251       WHEN 'G'                                                   
P00251         MOVE +3                    TO MI-PRV-COLUMN-VALUE-LEN    
P00251         MOVE 'GAS'                 TO MI-PRV-COLUMN-VALUE-TEXT   
P00251       WHEN OTHER                                                 
P00251         MOVE +1                    TO MI-PRV-COLUMN-VALUE-LEN    
P00251         MOVE PARM-CODE-UTIL-TYPE   TO MI-PRV-COLUMN-VALUE-TEXT   
P00251       END-EVALUATE                                               
             MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE SPACES                  TO MI-TABLE-ID                
             MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT   
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
             MOVE 'MAST IC NO'            TO MI-COLUMN-DESC             
             MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN    
             MOVE PARM-IC-NO-MST        TO MI-PRV-COLUMN-VALUE-TEXT     
             MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE SPACES                  TO MI-TABLE-ID                
             MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT   
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
             MOVE 'MAST MTR REF NO'       TO MI-COLUMN-DESC             
             MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN    
P00251       MOVE UR-MTR-REF-NO-MST       TO MI-PRV-COLUMN-VALUE-TEXT   
             MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE SPACES                  TO MI-TABLE-ID                
             MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT   
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
             MOVE 'RELATION TYPE'         TO MI-COLUMN-DESC             
P00251       MOVE PARM-CODE-RELATION-TYPE TO UV-CODE-VALUE-TEXT         
P00251       MOVE +1                      TO UV-CODE-VALUE-LEN          
P00251       MOVE 'CODE_RELATION_TYPE'    TO UV-COLUMN-NA-TEXT          
P00251       MOVE +18                     TO UV-COLUMN-NA-LEN           
P00251       MOVE 'CSS_UTL_BILL_REL'      TO UV-TABLE-NA-TEXT           
P00251       MOVE +16                     TO UV-TABLE-NA-LEN            
P00251       PERFORM 7040-GET-CODE-VALUE-DESC THRU 7040-EXIT            
P00251       MOVE UV-CODE-SHORT-DESC      TO MI-PRV-COLUMN-VALUE        
             MOVE +9                      TO MI-CHG-COLUMN-VALUE-LEN    
             MOVE '50'                    TO MI-TABLE-ID                
             MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT   
             PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
P00251       MOVE 'START REV MTH'         TO MI-COLUMN-DESC             
P00251       MOVE +10                     TO MI-PRV-COLUMN-VALUE-LEN    
P00251       MOVE UR-DEP-REL-START-DT     TO MI-PRV-COLUMN-VALUE-TEXT   
P00251       MOVE +10                     TO MI-CHG-COLUMN-VALUE-LEN    
P00251       MOVE SPACES                  TO MI-TABLE-ID                
P00251       MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT   
P00251       PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
P00251       MOVE 'END REV MTH'           TO MI-COLUMN-DESC             
P00251       MOVE +10                     TO MI-PRV-COLUMN-VALUE-LEN    
P00251       MOVE UR-DEP-REL-END-DT       TO MI-PRV-COLUMN-VALUE-TEXT   
P00251       MOVE +10                     TO MI-CHG-COLUMN-VALUE-LEN    
P00251       MOVE SPACES                  TO MI-TABLE-ID                
P00251       MOVE '*DELETED*'             TO MI-CHG-COLUMN-VALUE-TEXT   
P00251       PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
P00251     END-IF.                                                      
                                                                        
       2300-EXIT.                                                       
           EXIT.                                                        
                                                                        
P00251******************************************************************07490000
P00251* 2400-PROCESS-UPDATE.                                           *07500000
P00251******************************************************************07510000
P00251*                                                                 07520000
P00251 2400-PROCESS-UPDATE.                                             
P00251*                                                                 07680000
P00251     MOVE PARM-ACCOUNT-NO-DEP         TO WS-ACCOUNT-NO.           
P00251     MOVE WS-ACCOUNT-NO               TO WS-ACCOUNT-NO-NUM-DEP.   
P00251     MOVE WS-ACCOUNT-NO-NUM-DEP       TO UR-ACCOUNT-NO-DEP        
P00251                                         AT-ACCOUNT-NO.           
P00251     MOVE PARM-ACCOUNT-NO-MST         TO WS-ACCOUNT-NO.           
P00251     MOVE WS-ACCOUNT-NO               TO WS-ACCOUNT-NO-NUM-MST.   
P00251     MOVE WS-ACCOUNT-NO-NUM-MST       TO UR-ACCOUNT-NO-MST.       
P00251     MOVE PARM-CODE-UTIL-TYPE         TO UR-CODE-UTIL-TYPE-DEP    
P00251                                         UR-CODE-UTIL-TYPE-MST.   
P00251     MOVE PARM-IC-NO-DEP              TO UR-IC-NO-DEP.            
P00251     MOVE PARM-IC-NO-MST              TO UR-IC-NO-MST.            
P00251     MOVE PARM-METER-REF-NO-DEP       TO UR-MTR-REF-NO-DEP.       
P00251     MOVE PARM-METER-REF-NO-MST       TO UR-MTR-REF-NO-MST.       
P00251*                                                                         
P00251     MOVE PARM-CODE-RELATION-TYPE     TO UR-CODE-RELATION-TYPE.   
P20251*                                                                         
P00251     MOVE PARM-DEP-REL-START-DT       TO WS-DEP-REL-START-DT.     
P00251     MOVE WS-DEP-REL-START-DT(1:2)    TO WS-DEP-REL-ST-MM.        
P00251     MOVE WS-DEP-REL-START-DT(4:2)    TO WS-DEP-REL-ST-DT.        
P00251     MOVE WS-DEP-REL-START-DT(7:4)    TO WS-DEP-REL-ST-YR.        
P00251     MOVE WS-DEP-REL-ST-DATE          TO WS-DEP-REL-START-DT      
P00251                                         UR-DEP-REL-START-DT.     
P00251*                                                                 05110000
P00251     MOVE PARM-DEP-REL-END-DT         TO WS-DEP-REL-END-DT.       
P00251     MOVE WS-DEP-REL-END-DT (1:2)     TO WS-DEP-REL-ED-MM.        
P00251     MOVE WS-DEP-REL-END-DT (4:2)     TO WS-DEP-REL-ED-DT.        
P00251     MOVE WS-DEP-REL-END-DT (7:4)     TO WS-DEP-REL-ED-YR.        
P00251     MOVE WS-DEP-REL-ED-DATE          TO WS-DEP-REL-END-DT        
P00251                                         UR-DEP-REL-END-DT.       
P00251*                                                                         
P00251***  CHECK IF MASTER/DEPEND METER RELATIONSHIP ALREADY EXISTS             
P00251***  FOR SAME REVENUE MONTH. IF EXISTS EXIT AND RETURN SPECIAL            
P00251***  RETURN CODE.                                                         
P00251     PERFORM 7610-CHECK-MSTDEPREL-EXISTS THRU 7610-EXIT.          
P00251     IF WS-MSTDEPREL-EXISTS = 'Y'                                 
P00251        MOVE WS-REL-ALREADY-EXISTS TO RS-RETURN-CODE              
P00251        PERFORM 2000A-MOVE-RESULT THRU 2000A-EXIT                 
P00251        PERFORM 8100-SEND-RESULT THRU 8100-EXIT                   
P00251        PERFORM 9999-END-PROGRAM THRU 9999-EXIT                   
P00251     END-IF.                                                      
P00251*                                                                         
P00251***  RECORD CHANGE IN TRANSHIST FOR DEPENDENT ACCOUNT                     
P00251     PERFORM 7200-SELECT-UTL-BILL-REL THRU 7200-EXIT.             
P00251     PERFORM 5000-MAINTENANCE-HISTORY THRU 5000-EXIT.             
P00251     MOVE MH-TRANS-HIST-SEQ-NO TO MN-LAST-UPDATE-TS.              
P00251     IF WS-ACCOUNT-NO-NUM-MST NOT = WS-ACCOUNT-NO-NUM-DEP         
P00251       MOVE 'DEP ACCT NO'         TO MI-COLUMN-DESC               
P00251       MOVE +13                   TO MI-PRV-COLUMN-VALUE-LEN      
P00251       MOVE UR-ACCOUNT-NO-DEP     TO MI-PRV-COLUMN-VALUE-TEXT     
P00251       MOVE +11                   TO MI-CHG-COLUMN-VALUE-LEN      
P00251       MOVE '*NO CHANGE*'         TO MI-CHG-COLUMN-VALUE-TEXT     
P00251       MOVE SPACES                TO MI-TABLE-ID                  
P00251       PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
P00251     END-IF.                                                      
P00251     MOVE 'DEP UTIL TYPE'         TO MI-COLUMN-DESC.              
P00251     EVALUATE UR-CODE-UTIL-TYPE-DEP                               
P00251     WHEN 'E'                                                     
P00251       MOVE +8                    TO MI-PRV-COLUMN-VALUE-LEN      
P00251       MOVE 'ELECTRIC'            TO MI-PRV-COLUMN-VALUE-TEXT     
P00251     WHEN 'G'                                                     
P00251       MOVE +3                    TO MI-PRV-COLUMN-VALUE-LEN      
P00251       MOVE 'GAS'                 TO MI-PRV-COLUMN-VALUE-TEXT     
P00251     WHEN OTHER                                                   
P00251       MOVE +1                    TO MI-PRV-COLUMN-VALUE-LEN      
P00251       MOVE UR-CODE-UTIL-TYPE-DEP TO MI-PRV-COLUMN-VALUE-TEXT     
P00251     END-EVALUATE.                                                
P00251     MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN.     
P00251     MOVE SPACES                  TO MI-TABLE-ID.                 
P00251     MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT.    
P00251     PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251     MOVE 'DEP IC NO   '          TO MI-COLUMN-DESC.              
P00251     MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN.     
P00251     MOVE UR-IC-NO-DEP            TO MI-PRV-COLUMN-VALUE-TEXT.    
P00251     MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN.     
P00251     MOVE SPACES                  TO MI-TABLE-ID.                 
P00251     MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT.    
P00251     PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251     MOVE 'DEP MTR REF NO'        TO MI-COLUMN-DESC.              
P00251     MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN.     
P00251     MOVE UR-MTR-REF-NO-DEP       TO MI-PRV-COLUMN-VALUE-TEXT.    
P00251     MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN.     
P00251     MOVE SPACES                  TO MI-TABLE-ID.                 
P00251     MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT.    
P00251     PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251*    PERFORM 7200-SELECT-UTL-BILL-REL THRU 7200-EXIT.                     
P00251     IF WS-ACCOUNT-NO-NUM-MST NOT = WS-ACCOUNT-NO-NUM-DEP         
P00251       MOVE 'MAST ACCT NO'        TO MI-COLUMN-DESC               
P00251       MOVE +13                   TO MI-PRV-COLUMN-VALUE-LEN      
P00251       MOVE  UR-ACCOUNT-NO-MST    TO MI-PRV-COLUMN-VALUE-TEXT     
P00251       MOVE +11                   TO MI-CHG-COLUMN-VALUE-LEN      
P00251       MOVE '*NO CHANGE*'         TO MI-CHG-COLUMN-VALUE-TEXT     
P00251       MOVE SPACES                TO MI-TABLE-ID                  
P00251       PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT                
P00251     END-IF.                                                      
P00251     MOVE 'MAST UTIL TYPE'        TO MI-COLUMN-DESC.              
P00251     EVALUATE UR-CODE-UTIL-TYPE-MST                               
P00251     WHEN 'E'                                                     
P00251       MOVE +8                    TO MI-PRV-COLUMN-VALUE-LEN      
P00251       MOVE 'ELECTRIC'            TO MI-PRV-COLUMN-VALUE-TEXT     
P00251     WHEN 'G'                                                     
P00251       MOVE +3                    TO MI-PRV-COLUMN-VALUE-LEN      
P00251       MOVE 'GAS'                 TO MI-PRV-COLUMN-VALUE-TEXT     
P00251     WHEN OTHER                                                   
P00251       MOVE +1                    TO MI-PRV-COLUMN-VALUE-LEN      
P00251       MOVE UR-CODE-UTIL-TYPE-MST TO MI-PRV-COLUMN-VALUE-TEXT     
P00251     END-EVALUATE.                                                
P00251     MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN.     
P00251     MOVE SPACES                  TO MI-TABLE-ID.                 
P00251     MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT.    
P00251     PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251     MOVE 'MAST IC NO  '          TO MI-COLUMN-DESC.              
P00251     MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN.     
P00251     MOVE UR-IC-NO-MST            TO MI-PRV-COLUMN-VALUE-TEXT.    
P00251     MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN.     
P00251     MOVE SPACES                  TO MI-TABLE-ID.                 
P00251     MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT.    
P00251     PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251     MOVE 'MAST MTR REF NO'       TO MI-COLUMN-DESC.              
P00251     MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN.     
P00251     MOVE UR-MTR-REF-NO-MST       TO MI-PRV-COLUMN-VALUE-TEXT.    
P00251     MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN.     
P00251     MOVE SPACES                  TO MI-TABLE-ID.                 
P00251     MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT.    
P00251     PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251     MOVE 'RELATION TYPE'         TO MI-COLUMN-DESC.              
P00251     MOVE UR-CODE-RELATION-TYPE   TO UV-CODE-VALUE-TEXT.          
P00251     MOVE +1                      TO UV-CODE-VALUE-LEN.           
P00251     MOVE 'CODE_RELATION_TYPE'    TO UV-COLUMN-NA-TEXT.           
P00251     MOVE +18                     TO UV-COLUMN-NA-LEN.            
P00251     MOVE 'CSS_UTL_BILL_REL'      TO UV-TABLE-NA-TEXT.            
P00251     MOVE +16                     TO UV-TABLE-NA-LEN.             
P00251     PERFORM 7040-GET-CODE-VALUE-DESC THRU 7040-EXIT.             
P00251     MOVE UV-CODE-SHORT-DESC      TO MI-PRV-COLUMN-VALUE.         
P00251     MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN.     
P00251     MOVE '50'                    TO MI-TABLE-ID.                 
P00251     MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT.    
P00251     PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251     MOVE 'START REV MTH'         TO MI-COLUMN-DESC.              
P00251     MOVE +10                     TO MI-PRV-COLUMN-VALUE-LEN.     
P00251     MOVE UR-DEP-REL-START-DT     TO MI-PRV-COLUMN-VALUE-TEXT.    
P00251     MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN.     
P00251     MOVE SPACES                  TO MI-TABLE-ID.                 
P00251     MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT.    
P00251     PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251     MOVE 'END REV MTH'           TO MI-COLUMN-DESC.              
P00251     MOVE +10                     TO MI-PRV-COLUMN-VALUE-LEN.     
P00251     MOVE UR-DEP-REL-END-DT       TO MI-PRV-COLUMN-VALUE-TEXT.    
P00251     MOVE +10                     TO MI-CHG-COLUMN-VALUE-LEN.     
P00251     MOVE SPACES                  TO MI-TABLE-ID.                 
P00251     MOVE WS-DEP-REL-END-DT       TO MI-CHG-COLUMN-VALUE-TEXT.    
P00251     PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT.                 
P00251*                                                                         
P00251***  RECORD CHANGE IN TRANSHIST FOR MASTER ACCOUNT                        
P00251***  WHEN DIFFERENT FROM DEPENDENT ACCOUNT                                
P00251     IF WS-ACCOUNT-NO-NUM-MST NOT = WS-ACCOUNT-NO-NUM-DEP         
P00251        MOVE WS-ACCOUNT-NO-NUM-MST   TO AT-ACCOUNT-NO             
P00251        PERFORM 5000-MAINTENANCE-HISTORY THRU 5000-EXIT           
P00251        MOVE MH-TRANS-HIST-SEQ-NO TO MN-LAST-UPDATE-TS            
P00251        IF WS-ACCOUNT-NO-NUM-MST NOT = WS-ACCOUNT-NO-NUM-DEP      
P00251          MOVE 'DEP ACCT NO'         TO MI-COLUMN-DESC            
P00251          MOVE +13                   TO MI-PRV-COLUMN-VALUE-LEN   
P00251          MOVE UR-ACCOUNT-NO-DEP     TO MI-PRV-COLUMN-VALUE-TEXT  
P00251          MOVE +11                   TO MI-CHG-COLUMN-VALUE-LEN   
P00251          MOVE '*NO CHANGE*'         TO MI-CHG-COLUMN-VALUE-TEXT  
P00251          MOVE SPACES                TO MI-TABLE-ID               
P00251          PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT             
P00251        END-IF                                                    
P00251        MOVE 'DEP UTIL TYPE'         TO MI-COLUMN-DESC            
P00251        EVALUATE UR-CODE-UTIL-TYPE-DEP                            
P00251        WHEN 'E'                                                  
P00251          MOVE +8                    TO MI-PRV-COLUMN-VALUE-LEN   
P00251          MOVE 'ELECTRIC'            TO MI-PRV-COLUMN-VALUE-TEXT  
P00251        WHEN 'G'                                                  
P00251          MOVE +3                    TO MI-PRV-COLUMN-VALUE-LEN   
P00251          MOVE 'GAS'                 TO MI-PRV-COLUMN-VALUE-TEXT  
P00251        WHEN OTHER                                                
P00251          MOVE +1                    TO MI-PRV-COLUMN-VALUE-LEN   
P00251          MOVE UR-CODE-UTIL-TYPE-DEP TO MI-PRV-COLUMN-VALUE-TEXT  
P00251        END-EVALUATE                                              
P00251        MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN   
P00251        MOVE SPACES                  TO MI-TABLE-ID               
P00251        MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT  
P00251        PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT               
P00251        MOVE 'DEP IC NO   '          TO MI-COLUMN-DESC            
P00251        MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN   
P00251        MOVE UR-IC-NO-DEP            TO MI-PRV-COLUMN-VALUE-TEXT  
P00251        MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN   
P00251        MOVE SPACES                  TO MI-TABLE-ID               
P00251        MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT  
P00251        PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT               
P00251        MOVE 'DEP MTR REF NO'        TO MI-COLUMN-DESC            
P00251        MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN   
P00251        MOVE UR-MTR-REF-NO-DEP       TO MI-PRV-COLUMN-VALUE-TEXT  
P00251        MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN   
P00251        MOVE SPACES                  TO MI-TABLE-ID               
P00251        MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT  
P00251        PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT               
P00251*       PERFORM 7200-SELECT-UTL-BILL-REL THRU 7200-EXIT                   
P00251        IF WS-ACCOUNT-NO-NUM-MST NOT = WS-ACCOUNT-NO-NUM-DEP      
P00251          MOVE 'MAST ACCT NO'        TO MI-COLUMN-DESC            
P00251          MOVE +13                   TO MI-PRV-COLUMN-VALUE-LEN   
P00251          MOVE  UR-ACCOUNT-NO-MST    TO MI-PRV-COLUMN-VALUE-TEXT  
P00251          MOVE +11                   TO MI-CHG-COLUMN-VALUE-LEN   
P00251          MOVE '*NO CHANGE*'         TO MI-CHG-COLUMN-VALUE-TEXT  
P00251          MOVE SPACES                TO MI-TABLE-ID               
P00251          PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT             
P00251        END-IF                                                    
P00251        MOVE 'MAST UTIL TYPE'        TO MI-COLUMN-DESC            
P00251        EVALUATE UR-CODE-UTIL-TYPE-MST                            
P00251        WHEN 'E'                                                  
P00251          MOVE +8                    TO MI-PRV-COLUMN-VALUE-LEN   
P00251          MOVE 'ELECTRIC'            TO MI-PRV-COLUMN-VALUE-TEXT  
P00251        WHEN 'G'                                                  
P00251          MOVE +3                    TO MI-PRV-COLUMN-VALUE-LEN   
P00251          MOVE 'GAS'                 TO MI-PRV-COLUMN-VALUE-TEXT  
P00251        WHEN OTHER                                                
P00251          MOVE +1                    TO MI-PRV-COLUMN-VALUE-LEN   
P00251          MOVE UR-CODE-UTIL-TYPE-MST TO MI-PRV-COLUMN-VALUE-TEXT  
P00251        END-EVALUATE                                              
P00251        MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN   
P00251        MOVE SPACES                  TO MI-TABLE-ID               
P00251        MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT  
P00251        PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT               
P00251        MOVE 'MAST IC NO  '          TO MI-COLUMN-DESC            
P00251        MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN   
P00251        MOVE UR-IC-NO-MST            TO MI-PRV-COLUMN-VALUE-TEXT  
P00251        MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN   
P00251        MOVE SPACES                  TO MI-TABLE-ID               
P00251        MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT  
P00251        PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT               
P00251        MOVE 'MAST MTR REF NO'       TO MI-COLUMN-DESC            
P00251        MOVE +4                      TO MI-PRV-COLUMN-VALUE-LEN   
P00251        MOVE UR-MTR-REF-NO-MST       TO MI-PRV-COLUMN-VALUE-TEXT  
P00251        MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN   
P00251        MOVE SPACES                  TO MI-TABLE-ID               
P00251        MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT  
P00251        PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT               
P00251        MOVE 'RELATION TYPE'         TO MI-COLUMN-DESC            
P00251        MOVE UR-CODE-RELATION-TYPE   TO UV-CODE-VALUE-TEXT        
P00251        MOVE +1                      TO UV-CODE-VALUE-LEN         
P00251        MOVE 'CODE_RELATION_TYPE'    TO UV-COLUMN-NA-TEXT         
P00251        MOVE +18                     TO UV-COLUMN-NA-LEN          
P00251        MOVE 'CSS_UTL_BILL_REL'      TO UV-TABLE-NA-TEXT          
P00251        MOVE +16                     TO UV-TABLE-NA-LEN           
P00251        PERFORM 7040-GET-CODE-VALUE-DESC THRU 7040-EXIT           
P00251        MOVE UV-CODE-SHORT-DESC      TO MI-PRV-COLUMN-VALUE       
P00251        MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN   
P00251        MOVE '50'                    TO MI-TABLE-ID               
P00251        MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT  
P00251        PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT               
P00251        MOVE 'START REV MTH'         TO MI-COLUMN-DESC            
P00251        MOVE +10                     TO MI-PRV-COLUMN-VALUE-LEN   
P00251        MOVE UR-DEP-REL-START-DT     TO MI-PRV-COLUMN-VALUE-TEXT  
P00251        MOVE +11                     TO MI-CHG-COLUMN-VALUE-LEN   
P00251        MOVE SPACES                  TO MI-TABLE-ID               
P00251        MOVE '*NO CHANGE*'           TO MI-CHG-COLUMN-VALUE-TEXT  
P00251        PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT               
P00251        MOVE 'END REV MTH'           TO MI-COLUMN-DESC            
P00251        MOVE +10                     TO MI-PRV-COLUMN-VALUE-LEN   
P00251        MOVE UR-DEP-REL-END-DT       TO MI-PRV-COLUMN-VALUE-TEXT  
P00251        MOVE +10                     TO MI-CHG-COLUMN-VALUE-LEN   
P00251        MOVE SPACES                  TO MI-TABLE-ID               
P00251        MOVE WS-DEP-REL-END-DT       TO MI-CHG-COLUMN-VALUE-TEXT  
P00251        PERFORM 5010-MNT-HST-DETAIL  THRU 5010-EXIT               
P00251     END-IF.                                                      
P00251*                                                                         
P00251     MOVE WS-DEP-REL-ED-DATE    TO UR-DEP-REL-END-DT.             
P00251     PERFORM 7500-UPDATE-UTL-BILL-REL THRU 7500-EXIT.             
P00251*                                                                         
P00251 2400-EXIT.                                                       
P00251     EXIT.                                                        
                                                                        
      *************************************************************     09720000
      * 5000  PREPARE MAINTJOURNAL AND UPDATE                     *     09730000
      *************************************************************     09740000
       5000-MAINTENANCE-HISTORY.                                        
           PERFORM 7300-GET-TIMESTAMP THRU 7300-EXIT.                   
                                                                        
           MOVE 'F'                   TO MH-CODE-TRAN-TYPE.             
           MOVE PARM-RESP-AREA-ID     TO MH-RESP-AREA-ID.               
           MOVE AT-ACCOUNT-NO         TO MH-ACCOUNT-NO.                 
           MOVE ZEROS                 TO MH-PREMISE-NO.                 
           MOVE ZEROS                 TO MH-CUSTOMER-NO.                
           MOVE PARM-USER-ID          TO MH-USER-ID.                    
           MOVE 'PANEL253'            TO MH-APPL-PROGRAM-ID.            
           MOVE PARM-TRAN-COMMENT     TO MH-TRAN-COMMENT-TEXT.          
           MOVE PARM-TRAN-COMMENT-LEN TO MH-TRAN-COMMENT-LEN.           
           MOVE +1                    TO WS-TRAN-APPL-NO.               
       5000-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************09900000
      * 5010-MNT-HST-DETAIL.                                           *09910000
      ******************************************************************09920000
                                                                        
       5010-MNT-HST-DETAIL.                                             
           MOVE MH-TRANS-HIST-SEQ-NO TO MI-TRANS-HIST-SEQ-NO.           
           MOVE WS-TRAN-APPL-NO      TO MI-TRAN-APPL-NO.                
           PERFORM 6530-LOAD-MNT-TRANS-HIST THRU 6530-EXIT.             
           ADD 1                     TO WS-TRAN-APPL-NO.                
       5010-EXIT.                                                       
           EXIT.                                                        
                                                                        
                                                                        
                                                                        
                                                                        
      ******************************************************************10050000
      * 6400 - FINANCIAL JOURNALING ROUTINE                            *10060000
      ******************************************************************10070000
           EXEC SQL                                                     10080000
              INCLUDE CPD00067                                          10090000
           END-EXEC.                                                    10100000
                                                                        
                                                                        
      ****************************************************************  10130000
      * 7000-INSERT-UTL-BILL-REL.                                    *  10140000
      ****************************************************************  10150000
       7000-INSERT-UTL-BILL-REL.                                        
           EXEC SQL                                                     
             INSERT INTO CSS_UTL_BILL_REL                               
              (ACCOUNT_NO_DEP,                                          
               CODE_UTIL_TYPE_DEP,                                      
               IC_NO_DEP,                                               
               MTR_REF_NO_DEP,                                          
               ACCOUNT_NO_MST,                                          
               CODE_UTIL_TYPE_MST,                                      
               IC_NO_MST,                                               
               MTR_REF_NO_MST,                                          
               CODE_RELATION_TYPE,                                      
P00251         DEP_REL_START_DT,                                        
P00251         DEP_REL_END_DT)                                          
             VALUES(:UR-ACCOUNT-NO-DEP,                                 
                    :UR-CODE-UTIL-TYPE-DEP,                             
                    :UR-IC-NO-DEP,                                      
                    :UR-MTR-REF-NO-DEP,                                 
                    :UR-ACCOUNT-NO-MST,                                 
                    :UR-CODE-UTIL-TYPE-MST,                             
                    :UR-IC-NO-MST,                                      
                    :UR-MTR-REF-NO-MST,                                 
                    :UR-CODE-RELATION-TYPE,                             
P00251              IIF(TRY_CONVERT(DATE, :UR-DEP-REL-START-DT
              ) IS NULL OR (PATINDEX('%.%', :UR-DEP-REL-START-DT
              ) <> 0) OR (LEN(:UR-DEP-REL-START-DT
              ) <> 10), CIS.CHAR2DATE(:UR-DEP-REL-START-DT
              ), CONVERT(DATE, :UR-DEP-REL-START-DT) ),                        
P00251              IIF(TRY_CONVERT(DATE, :UR-DEP-REL-END-DT
              ) IS NULL OR (PATINDEX('%.%', :UR-DEP-REL-END-DT
              ) <> 0) OR (LEN(:UR-DEP-REL-END-DT
              ) <> 10), CIS.CHAR2DATE(:UR-DEP-REL-END-DT
              ), CONVERT(DATE, :UR-DEP-REL-END-DT) ))                          
           END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ054
MFA-TR*    EXEC SQL                                                     10170000
MFA-TR*      INSERT INTO CSS_UTL_BILL_REL                               10180000
MFA-TR*       (ACCOUNT_NO_DEP,                                          10190000
MFA-TR*        CODE_UTIL_TYPE_DEP,                                      10200000
MFA-TR*        IC_NO_DEP,                                               10210000
MFA-TR*        MTR_REF_NO_DEP,                                          10220000
MFA-TR*        ACCOUNT_NO_MST,                                          10230000
MFA-TR*        CODE_UTIL_TYPE_MST,                                      10240000
MFA-TR*        IC_NO_MST,                                               10250000
MFA-TR*        MTR_REF_NO_MST,                                          10260000
MFA-TR*        CODE_RELATION_TYPE,                                      10270000
MFA-TR*        DEP_REL_START_DT,                                                
MFA-TR*        DEP_REL_END_DT)                                                  
MFA-TR*      VALUES(:UR-ACCOUNT-NO-DEP,                                 10280000
MFA-TR*             :UR-CODE-UTIL-TYPE-DEP,                             10290000
MFA-TR*             :UR-IC-NO-DEP,                                      10300000
MFA-TR*             :UR-MTR-REF-NO-DEP,                                 10310000
MFA-TR*             :UR-ACCOUNT-NO-MST,                                 10320000
MFA-TR*             :UR-CODE-UTIL-TYPE-MST,                             10330000
MFA-TR*             :UR-IC-NO-MST,                                      10340000
MFA-TR*             :UR-MTR-REF-NO-MST,                                 10350000
MFA-TR*             :UR-CODE-RELATION-TYPE,                             10360000
MFA-TR*             :UR-DEP-REL-START-DT,                                       
MFA-TR*             :UR-DEP-REL-END-DT)                                         
MFA-TR*    END-EXEC.                                                    10370000

MSQ017     CALL "MFASQLCA"
MSQ017       USING SQLCA, BY VALUE MFA-PROGRAM-ID, "0", "0", "0",
MSQ017       BY REFERENCE MFSQLMESSAGETEXT
MSQ017     END-CALL

                                                                        
           MOVE SQLCODE TO WS-ACTIVE-RETURN-CODE.                       
                                                                        
P00251     IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL OR WS-803         
               NEXT SENTENCE                                            
           ELSE                                                         
CBSI          MOVE PROGRAM-NAME        TO ABEND-PROGRAM                 
              MOVE '7000'              TO ACTIVE-PARAGRAPH              
CBSI          MOVE 'INSERT'            TO ABEND-FUNCTION                
              MOVE SPACES              TO ABEND-SQL-PREDICATES          
                                          ABEND-TABLES                  
CBSI          MOVE 'CSS_UTL_BILL_REL'  TO TABLE-1                       
T16168        MOVE 'ACCOUNT_NO'        TO TABLE-ELEMENT-1               
CBSI          MOVE 'CODE_UTIL_TYPE_DEP'   TO TABLE-ELEMENT-2            
CBSI          MOVE 'IC_NO_DEP'            TO TABLE-ELEMENT-3            
CBSI          MOVE 'MTR_REF_NO_DEP'       TO TABLE-ELEMENT-4            
              MOVE PARM-ACCOUNT-NO-MST    TO HOSTVAR-ELEMENT-1          
CBSI          MOVE UR-CODE-UTIL-TYPE-DEP  TO HOSTVAR-ELEMENT-2          
CBSI          MOVE UR-IC-NO-DEP           TO HOSTVAR-ELEMENT-3          
CBSI          MOVE UR-MTR-REF-NO-DEP      TO HOSTVAR-ELEMENT-4          
P00251        MOVE WS-ACTIVE-RETURN-CODE     TO RS-RETURN-CODE          
P00251        PERFORM 9000-SEND-ERROR-RESULT THRU 9000-EXIT             
              PERFORM 9900-SQL-ERROR-ROUTINE  THRU  9900-EXIT           
           END-IF.                                                      
                                                                        
       7000-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ****************************************************************  11810000
      * 7035-SEL-ACCT-CYC                                         *     11820000
      ****************************************************************  11830000
                                                                        
       7035-SEL-ACCOUNT-CYC.                                            
                                                                        
            EXEC SQL                                                    
              SELECT CODE_ACCT_USAGE                                    
                INTO :AT-CODE-ACCT-USAGE                                
                FROM CSS_ACCOUNT                                        
                WHERE ACCOUNT_NO = :AT-ACCOUNT-NO                       
P00251                                                      
            END-EXEC.                                                   

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ003
MFA-TR*     EXEC SQL                                                    11870000
MFA-TR*       SELECT CODE_ACCT_USAGE                                    11880000
MFA-TR*         INTO :AT-CODE-ACCT-USAGE                                11910000
MFA-TR*         FROM CSS_ACCOUNT                                        11940000
MFA-TR*         WHERE ACCOUNT_NO = :AT-ACCOUNT-NO                       11950000
MFA-TR*         QUERYNO 7035                                                    
MFA-TR*     END-EXEC.                                                   11960000

MSQ017     CALL "MFASQLCA"
MSQ017       USING SQLCA, BY VALUE MFA-PROGRAM-ID, "0", "0", "0",
MSQ017       BY REFERENCE MFSQLMESSAGETEXT
MSQ017     END-CALL

                                                                        
            MOVE SQLCODE TO WS-ACTIVE-RETURN-CODE.                      
                                                                        
            IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL                  
                NEXT SENTENCE                                           
            ELSE                                                        
CBSI          MOVE PROGRAM-NAME        TO ABEND-PROGRAM                 
CBSI          MOVE '7035'              TO ACTIVE-PARAGRAPH              
CBSI          MOVE 'SELECT'            TO ABEND-FUNCTION                
              MOVE SPACES              TO ABEND-SQL-PREDICATES          
                                          ABEND-TABLES                  
              MOVE 'CSS_ACCOUNT'       TO TABLE-1                       
T16168        MOVE 'ACCOUNT_NO'        TO TABLE-ELEMENT-1               
              MOVE AT-ACCOUNT-NO       TO HOSTVAR-ELEMENT-1             
P00251        MOVE WS-ACTIVE-RETURN-CODE     TO RS-RETURN-CODE          
P00251        PERFORM 9000-SEND-ERROR-RESULT THRU 9000-EXIT             
              PERFORM 9900-SQL-ERROR-ROUTINE  THRU  9900-EXIT           
            END-IF.                                                     
                                                                        
       7035-EXIT.                                                       
           EXIT.                                                        
P00251****************************************************************  11810000
P00251* 7040-GET-CODE-VALUE-DESC                                  *     11820000
P00251****************************************************************  11830000
P00251                                                                  
P00251 7040-GET-CODE-VALUE-DESC.                                        
P00251                                                                  
P00251      EXEC SQL                                                    
P00251        SELECT CODE_SHORT_DESC                                    
P00251          INTO :UV-CODE-SHORT-DESC                                
P00251          FROM CSS_CODE_VALUE                                     
P00251         WHERE CODE_VALUE = :UV-CODE-VALUE                        
P00251           AND COLUMN_NA  = :UV-COLUMN-NA                         
P00251           AND COMPANY_NO = '01'                                  
P00251           AND PROGRAM_ID = 'ALL'                                 
P00251           AND TABLE_NA   = :UV-TABLE-NA                          
P00251                                                      
P00251      END-EXEC.                                                   

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ003
MFA-TR*     EXEC SQL                                                    11870000
MFA-TR*       SELECT CODE_SHORT_DESC                                    11880000
MFA-TR*         INTO :UV-CODE-SHORT-DESC                                11910000
MFA-TR*         FROM CSS_CODE_VALUE                                     11940000
MFA-TR*        WHERE CODE_VALUE = :UV-CODE-VALUE                        11950000
MFA-TR*          AND COLUMN_NA  = :UV-COLUMN-NA                         11950000
MFA-TR*          AND COMPANY_NO = '01'                                  11950000
MFA-TR*          AND PROGRAM_ID = 'ALL'                                 11950000
MFA-TR*          AND TABLE_NA   = :UV-TABLE-NA                          11950000
MFA-TR*         QUERYNO 7040                                                    
MFA-TR*     END-EXEC.                                                   11960000

MSQ017     CALL "MFASQLCA"
MSQ017       USING SQLCA, BY VALUE MFA-PROGRAM-ID, "0", "0", "0",
MSQ017       BY REFERENCE MFSQLMESSAGETEXT
MSQ017     END-CALL

P00251                                                                  
P00251      MOVE SQLCODE               TO WS-ACTIVE-RETURN-CODE.        
P00251                                                                  
P00251      IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL OR NOT-FOUND     
P00251         IF WS-ACTIVE-RETURN-CODE = NOT-FOUND                     
P00251            MOVE UV-CODE-VALUE   TO UV-CODE-SHORT-DESC            
P00251         END-IF                                                   
P00251      ELSE                                                        
P00251        MOVE PROGRAM-NAME        TO ABEND-PROGRAM                 
P00251        MOVE '7040'              TO ACTIVE-PARAGRAPH              
P00251        MOVE 'SELECT'            TO ABEND-FUNCTION                
P00251        MOVE SPACES              TO ABEND-SQL-PREDICATES          
P00251                                    ABEND-TABLES                  
P00251        MOVE 'CSS_CODE_VALUE'    TO TABLE-1                       
P00251        MOVE 'CODE_VALUE'        TO TABLE-ELEMENT-1               
P00251        MOVE 'TABLE_NA'          TO TABLE-ELEMENT-2               
P00251        MOVE 'COLUMN_NA'         TO TABLE-ELEMENT-3               
P00251        MOVE UV-CODE-VALUE-TEXT  TO HOSTVAR-ELEMENT-1             
P00251        MOVE UV-COLUMN-NA-TEXT   TO HOSTVAR-ELEMENT-2             
P00251        MOVE UV-TABLE-NA-TEXT    TO HOSTVAR-ELEMENT-3             
P00251        MOVE WS-ACTIVE-RETURN-CODE     TO RS-RETURN-CODE          
P00251        PERFORM 9000-SEND-ERROR-RESULT THRU 9000-EXIT             
P00251        PERFORM 9900-SQL-ERROR-ROUTINE  THRU  9900-EXIT           
P00251      END-IF.                                                     
P00251                                                                  
P00251 7040-EXIT.                                                       
P00251     EXIT.                                                        
                                                                        
      ****************************************************************  12150000
      * 7100-DEL-UTL-BILL-REL                                     *     12160000
      ****************************************************************  12170000
                                                                        
       7100-DEL-UTL-BILL-REL.                                           
                                                                        
            EXEC SQL                                                    
                DELETE FROM CSS_UTL_BILL_REL                            
                 WHERE ACCOUNT_NO_DEP   =:UR-ACCOUNT-NO-DEP             
                 AND CODE_UTIL_TYPE_DEP =:UR-CODE-UTIL-TYPE-DEP         
                 AND IC_NO_DEP          =:UR-IC-NO-DEP                  
                 AND MTR_REF_NO_DEP     =:UR-MTR-REF-NO-DEP             
P00251           AND ACCOUNT_NO_MST     =:UR-ACCOUNT-NO-MST             
P00251           AND CODE_UTIL_TYPE_MST =:UR-CODE-UTIL-TYPE-MST         
P00251           AND IC_NO_MST          =:UR-IC-NO-MST                  
P00251           AND MTR_REF_NO_MST     =:UR-MTR-REF-NO-MST             
P00251           AND CODE_RELATION_TYPE =:UR-CODE-RELATION-TYPE         
P00251           AND DEP_REL_START_DT   =IIF(TRY_CONVERT(DATE, 
                                                   :UR-DEP-REL-START-DT
              ) IS NULL OR (PATINDEX('%.%', :UR-DEP-REL-START-DT
              ) <> 0) OR (LEN(:UR-DEP-REL-START-DT
              ) <> 10), CIS.CHAR2DATE(:UR-DEP-REL-START-DT
              ), CONVERT(DATE, :UR-DEP-REL-START-DT) )           
P00251                                                      
            END-EXEC.                                                   

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ003
MFA-TR* MSQ054
MFA-TR*     EXEC SQL                                                    12210000
MFA-TR*         DELETE FROM CSS_UTL_BILL_REL                            12220000
MFA-TR*          WHERE ACCOUNT_NO_DEP   =:UR-ACCOUNT-NO-DEP             12230000
MFA-TR*          AND CODE_UTIL_TYPE_DEP =:UR-CODE-UTIL-TYPE-DEP         12240000
MFA-TR*          AND IC_NO_DEP          =:UR-IC-NO-DEP                  12250000
MFA-TR*          AND MTR_REF_NO_DEP     =:UR-MTR-REF-NO-DEP             12260000
MFA-TR*          AND ACCOUNT_NO_MST     =:UR-ACCOUNT-NO-MST                     
MFA-TR*          AND CODE_UTIL_TYPE_MST =:UR-CODE-UTIL-TYPE-MST                 
MFA-TR*          AND IC_NO_MST          =:UR-IC-NO-MST                          
MFA-TR*          AND MTR_REF_NO_MST     =:UR-MTR-REF-NO-MST                     
MFA-TR*          AND CODE_RELATION_TYPE =:UR-CODE-RELATION-TYPE                 
MFA-TR*          AND DEP_REL_START_DT   =:UR-DEP-REL-START-DT                   
MFA-TR*         QUERYNO 7100                                                    
MFA-TR*     END-EXEC.                                                   12270000

MSQ017     CALL "MFASQLCA"
MSQ017       USING SQLCA, BY VALUE MFA-PROGRAM-ID, "0", "0", "0",
MSQ017       BY REFERENCE MFSQLMESSAGETEXT
MSQ017     END-CALL

                                                                        
            MOVE SQLCODE TO WS-ACTIVE-RETURN-CODE.                      
                                                                        
            IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL                  
                NEXT SENTENCE                                           
            ELSE                                                        
CBSI          MOVE PROGRAM-NAME        TO ABEND-PROGRAM                 
              MOVE '7100'              TO ACTIVE-PARAGRAPH              
CBSI          MOVE 'DELETE'            TO ABEND-FUNCTION                
              MOVE SPACES              TO ABEND-SQL-PREDICATES          
                                          ABEND-TABLES                  
              MOVE 'CSS_UTL_BILL_REL'  TO TABLE-1                       
T16168        MOVE 'ACCOUNT_NO_DEP'    TO TABLE-ELEMENT-1               
T16168        MOVE 'CODE_UTIL_TYPE_DEP' TO TABLE-ELEMENT-2              
T16168        MOVE 'IC_NO_DEP'         TO TABLE-ELEMENT-3               
T16168        MOVE 'MTR_REF_NO_DEP' TO TABLE-ELEMENT-4                  
              MOVE UR-ACCOUNT-NO-DEP   TO HOSTVAR-ELEMENT-1             
T16168        MOVE UR-CODE-UTIL-TYPE-DEP TO HOSTVAR-ELEMENT-2           
T16168        MOVE UR-IC-NO-DEP        TO HOSTVAR-ELEMENT-3             
T16168        MOVE UR-MTR-REF-NO-DEP   TO HOSTVAR-ELEMENT-4             
P00251        MOVE WS-ACTIVE-RETURN-CODE     TO RS-RETURN-CODE          
P00251        PERFORM 9000-SEND-ERROR-RESULT THRU 9000-EXIT             
              PERFORM 9900-SQL-ERROR-ROUTINE  THRU  9900-EXIT           
            END-IF.                                                     
                                                                        
       7100-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ****************************************************************  13040000
      * 7200-SELECT-UTL-BILL-REL.                                 *     13050000
      ****************************************************************  13060000
                                                                        
       7200-SELECT-UTL-BILL-REL.                                        
           EXEC SQL                                                     
              SELECT ACCOUNT_NO_MST,                                    
                     CODE_UTIL_TYPE_MST,                                
                     IC_NO_MST,                                         
                     MTR_REF_NO_MST,                                    
                     CODE_RELATION_TYPE,                                
P00251               DEP_REL_END_DT                                     
               INTO  :UR-ACCOUNT-NO-MST,                                
                     :UR-CODE-UTIL-TYPE-MST,                            
                     :UR-IC-NO-MST,                                     
                     :UR-MTR-REF-NO-MST,                                
                     :UR-CODE-RELATION-TYPE,                            
P00251               :UR-DEP-REL-END-DT                                 
                FROM CSS_UTL_BILL_REL                                   
               WHERE ACCOUNT_NO_DEP     = :UR-ACCOUNT-NO-DEP            
                 AND CODE_UTIL_TYPE_DEP = :UR-CODE-UTIL-TYPE-DEP        
                 AND IC_NO_DEP          = :UR-IC-NO-DEP                 
                 AND MTR_REF_NO_DEP     = :UR-MTR-REF-NO-DEP            
P00251           AND ACCOUNT_NO_MST     = :UR-ACCOUNT-NO-MST            
P00251           AND CODE_UTIL_TYPE_MST = :UR-CODE-UTIL-TYPE-MST        
P00251           AND IC_NO_MST          = :UR-IC-NO-MST                 
P00251           AND MTR_REF_NO_MST     = :UR-MTR-REF-NO-MST            
P00251           AND CODE_RELATION_TYPE = :UR-CODE-RELATION-TYPE        
P00251           AND DEP_REL_START_DT   = IIF(TRY_CONVERT(DATE, 
                                                   :UR-DEP-REL-START-DT
              ) IS NULL OR (PATINDEX('%.%', :UR-DEP-REL-START-DT
              ) <> 0) OR (LEN(:UR-DEP-REL-START-DT
              ) <> 10), CIS.CHAR2DATE(:UR-DEP-REL-START-DT
              ), CONVERT(DATE, :UR-DEP-REL-START-DT) )          
P00251                                                      
           END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ003
MFA-TR* MSQ054
MFA-TR*    EXEC SQL                                                     13090000
MFA-TR*       SELECT ACCOUNT_NO_MST,                                    13100000
MFA-TR*              CODE_UTIL_TYPE_MST,                                13110000
MFA-TR*              IC_NO_MST,                                         13120000
MFA-TR*              MTR_REF_NO_MST,                                    13130000
MFA-TR*              CODE_RELATION_TYPE,                                13140000
MFA-TR*              DEP_REL_END_DT                                             
MFA-TR*        INTO  :UR-ACCOUNT-NO-MST,                                13150000
MFA-TR*              :UR-CODE-UTIL-TYPE-MST,                            13160000
MFA-TR*              :UR-IC-NO-MST,                                     13170000
MFA-TR*              :UR-MTR-REF-NO-MST,                                13180000
MFA-TR*              :UR-CODE-RELATION-TYPE,                            13190000
MFA-TR*              :UR-DEP-REL-END-DT                                         
MFA-TR*         FROM CSS_UTL_BILL_REL                                   13200000
MFA-TR*        WHERE ACCOUNT_NO_DEP     = :UR-ACCOUNT-NO-DEP            13210000
MFA-TR*          AND CODE_UTIL_TYPE_DEP = :UR-CODE-UTIL-TYPE-DEP        13220000
MFA-TR*          AND IC_NO_DEP          = :UR-IC-NO-DEP                 13230000
MFA-TR*          AND MTR_REF_NO_DEP     = :UR-MTR-REF-NO-DEP            13240000
MFA-TR*          AND ACCOUNT_NO_MST     = :UR-ACCOUNT-NO-MST            13210000
MFA-TR*          AND CODE_UTIL_TYPE_MST = :UR-CODE-UTIL-TYPE-MST        13220000
MFA-TR*          AND IC_NO_MST          = :UR-IC-NO-MST                 13230000
MFA-TR*          AND MTR_REF_NO_MST     = :UR-MTR-REF-NO-MST            13240000
MFA-TR*          AND CODE_RELATION_TYPE = :UR-CODE-RELATION-TYPE                
MFA-TR*          AND DEP_REL_START_DT   = :UR-DEP-REL-START-DT                  
MFA-TR*         QUERYNO 7200                                                    
MFA-TR*    END-EXEC.                                                    13250000

MSQ017     CALL "MFASQLCA"
MSQ017       USING SQLCA, BY VALUE MFA-PROGRAM-ID, "0", "0", "0",
MSQ017       BY REFERENCE MFSQLMESSAGETEXT
MSQ017     END-CALL

           MOVE SQLCODE TO WS-ACTIVE-RETURN-CODE.                       
           IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL                   
               NEXT SENTENCE                                            
           ELSE                                                         
CBSI          MOVE PROGRAM-NAME        TO ABEND-PROGRAM                 
              MOVE '7200'              TO ACTIVE-PARAGRAPH              
CBSI          MOVE 'SELECT'            TO ABEND-FUNCTION                
              MOVE SPACES              TO ABEND-SQL-PREDICATES          
                                          ABEND-TABLES                  
              MOVE 'CSS_UTL_BILL_REL'  TO TABLE-1                       
T16168        MOVE 'ACCOUNT_NO_DEP'    TO TABLE-ELEMENT-1               
T16168        MOVE 'CODE_UTIL_TYPE_DEP'  TO TABLE-ELEMENT-2             
T16168        MOVE 'IC_NO_DEP'         TO TABLE-ELEMENT-3               
T16168        MOVE 'MTR_REF_NO_DEP'    TO TABLE-ELEMENT-4               
              MOVE UR-ACCOUNT-NO-DEP   TO HOSTVAR-ELEMENT-1             
T16168        MOVE UR-CODE-UTIL-TYPE-DEP TO HOSTVAR-ELEMENT-2           
T16168        MOVE UR-IC-NO-DEP        TO HOSTVAR-ELEMENT-3             
T16168        MOVE UR-MTR-REF-NO-DEP   TO HOSTVAR-ELEMENT-4             
P00251        MOVE WS-ACTIVE-RETURN-CODE     TO RS-RETURN-CODE          
P00251        PERFORM 9000-SEND-ERROR-RESULT THRU 9000-EXIT             
              PERFORM 9900-SQL-ERROR-ROUTINE  THRU  9900-EXIT           
           END-IF.                                                      
                                                                        
       7200-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ****************************************************************  13410000
      * 7300-GET-TIMESTAMP.                                       *     13420000
      ****************************************************************  13430000
                                                                        
       7300-GET-TIMESTAMP.                                              
           EXEC SQL                                                     
P00251        SELECT
              REPLACE(REPLACE(CONVERT(CHAR(26), CIS.CURRENT$TIMESTAMP()
           , 121), ' ', '-'), ':', '.'),
              CAST(SYSDATETIMEOFFSET() AS DATE)
            INTO
              :MH-TRANS-HIST-SEQ-NO,
              :MH-DATE-TRANS                  
           END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ006
MFA-TR* MSQ028
MFA-TR* MSQ061
MFA-TR*    EXEC SQL                                                     13460000
MFA-TR*       SET :MH-TRANS-HIST-SEQ-NO = CURRENT TIMESTAMP             13490000
MFA-TR*          ,:MH-DATE-TRANS        = CURRENT DATE                  13500000
MFA-TR*    END-EXEC.                                                    13520000

MSQ017     CALL "MFASQLCA"
MSQ017       USING SQLCA, BY VALUE MFA-PROGRAM-ID, "0", "0", "0",
MSQ017       BY REFERENCE MFSQLMESSAGETEXT
MSQ017     END-CALL

                                                                        
           MOVE SQLCODE TO WS-ACTIVE-RETURN-CODE.                       
           IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL                   
              NEXT SENTENCE                                             
           ELSE                                                         
              MOVE WS-ACTIVE-RETURN-CODE TO RS-RETURN-CODE              
              MOVE PROGRAM-NAME        TO ABEND-PROGRAM                 
              MOVE '7300'              TO ACTIVE-PARAGRAPH              
              MOVE 'SELECT'            TO ABEND-FUNCTION                
              MOVE SPACES              TO ABEND-SQL-PREDICATES          
                                          ABEND-TABLES                  
              MOVE 'CSS_MODEL_SQL'     TO TABLE-1                       
CBSI          MOVE 'ACCOUNT_NO'        TO TABLE-ELEMENT-1               
CBSI          MOVE PARM-ACCOUNT-NO-MST TO HOSTVAR-ELEMENT-1             
              PERFORM 9000-SEND-ERROR-RESULT THRU 9000-EXIT             
              PERFORM 9900-SQL-ERROR-ROUTINE  THRU  9900-EXIT
           END-IF.          
       7300-EXIT.                                                       
           EXIT.                                                        
                                                                        
                                                                        
T11934****************************************************************  13701501
T11934* 7410-GET-SUB-RATE.                                           *  13701601
T11934* THIS WILL GET THE RATE OF THE SUB ACCOUNT.  THIS RATE WILL   *  13701701
T11934* BE USED TO COMPARE TO THE MASTER RATE AND ENSURE THEY'RE THE *  13701801
T11934* SAME (UNLESS SUB RATE IS 65 OR 66).                          *  13701901
T11934****************************************************************  13702001
T11934                                                                  
T11934 7410-GET-SUB-RATE.                                               
T11934     EXEC SQL                                                     
T11934        SELECT RATE_PLAN_NO                                       
T11934        INTO   :WS-SUB-RATE                                       
T11934        FROM   CSS_UTIL_ENVRNMT                                   
T11934        WHERE  ACCOUNT_NO        = :WS-ACCOUNT-NO-NUM-DEP         
T11934        AND    CODE_UTIL_TYPE    = :UR-CODE-UTIL-TYPE-DEP         
T11934        AND    IC_NO             = :UR-IC-NO-DEP                  
P00251                                                      
T11934     END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ003
MFA-TR*    EXEC SQL                                                     13702301
MFA-TR*       SELECT RATE_PLAN_NO                                       13702401
MFA-TR*       INTO   :WS-SUB-RATE                                       13702501
MFA-TR*       FROM   CSS_UTIL_ENVRNMT                                   13702601
MFA-TR*       WHERE  ACCOUNT_NO        = :WS-ACCOUNT-NO-NUM-DEP         13702702
MFA-TR*       AND    CODE_UTIL_TYPE    = :UR-CODE-UTIL-TYPE-DEP         13702802
MFA-TR*       AND    IC_NO             = :UR-IC-NO-DEP                  13702902
MFA-TR*       QUERYNO 7410                                                      
MFA-TR*    END-EXEC.                                                    13703001

MSQ017     CALL "MFASQLCA"
MSQ017       USING SQLCA, BY VALUE MFA-PROGRAM-ID, "0", "0", "0",
MSQ017       BY REFERENCE MFSQLMESSAGETEXT
MSQ017     END-CALL

T11934                                                                  
T11934     MOVE SQLCODE TO WS-ACTIVE-RETURN-CODE.                       
T11934     IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL                   
T11934        NEXT SENTENCE                                             
T11934     ELSE                                                         
T11934        MOVE WS-ACTIVE-RETURN-CODE TO RS-RETURN-CODE              
T11934        MOVE PROGRAM-NAME        TO ABEND-PROGRAM                 
T11934        MOVE '7410'              TO ACTIVE-PARAGRAPH              
T11934        MOVE 'SELECT'            TO ABEND-FUNCTION                
T11934        MOVE SPACES              TO ABEND-SQL-PREDICATES          
T11934                                    ABEND-TABLES                  
T11934        MOVE 'CSS_UTIL_ENVRNMT'  TO TABLE-1                       
T16168        MOVE 'ACCOUNT_NO'        TO TABLE-ELEMENT-1               
T16168        MOVE 'CODE_UTIL_TYPE'    TO TABLE-ELEMENT-2               
T16168        MOVE 'IC_NO'             TO TABLE-ELEMENT-3               
T16168        MOVE WS-ACCOUNT-NO-NUM-DEP TO HOSTVAR-ELEMENT-1           
T16168        MOVE UR-CODE-UTIL-TYPE-DEP TO HOSTVAR-ELEMENT-2           
T16168        MOVE UR-IC-NO-DEP        TO HOSTVAR-ELEMENT-3             
T11934        PERFORM 9000-SEND-ERROR-RESULT THRU 9000-EXIT             
T11934        PERFORM 9900-SQL-ERROR-ROUTINE  THRU  9900-EXIT
           END-IF.          
T11934 7410-EXIT.                                                       
T11934     EXIT.                                                        
T11934****************************************************************  13704706
T11934* 7420-GET-SUB-FACTOR-TYP.                                     *  13704806
T11934*  THIS WILL SELECT THE ROW FROM TABLE CSS_FIXED_FCTR          *  13704906
T11934*  CORRESPONDING TO THE SUB ACCOUNT.  THIS INFO WILL THEN BE   *  13705006
T11934*  USED TO MAKE SURE THE SUB ALREADY HAS THE APPROPRIATE FACTOR*  13705106
T11934****************************************************************  13705306
T11934                                                                  
T11934 7420-GET-SUB-FACTOR-TYP.                                         
T11934     EXEC SQL                                                     
T11934        SELECT 'Y'                                                
T11934         INTO  :WS-SUB-FCTR-SIGN                                  
T11934          FROM CSS_FIXED_FCTR                                     
T11934         WHERE ACCOUNT_NO         = :FF-ACCOUNT-NO                
T11934           AND CODE_UTIL_TYPE     = :FF-CODE-UTIL-TYPE            
T11934           AND IC_NO              = :FF-IC-NO                     
T11934           AND FIXED_FCTR_TYP_CD  = :FF-FIXED-FCTR-TYP-CD         
P00251                                                      
T11934     END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ003
MFA-TR*    EXEC SQL                                                     13705606
MFA-TR*       SELECT 'Y'                                                13705710
MFA-TR*        INTO  :WS-SUB-FCTR-SIGN                                  13705810
MFA-TR*         FROM CSS_FIXED_FCTR                                     13705906
MFA-TR*        WHERE ACCOUNT_NO         = :FF-ACCOUNT-NO                13706006
MFA-TR*          AND CODE_UTIL_TYPE     = :FF-CODE-UTIL-TYPE            13706106
MFA-TR*          AND IC_NO              = :FF-IC-NO                     13706206
MFA-TR*          AND FIXED_FCTR_TYP_CD  = :FF-FIXED-FCTR-TYP-CD         13706406
MFA-TR*       QUERYNO 7420                                                      
MFA-TR*    END-EXEC.                                                    13706506

MSQ017     CALL "MFASQLCA"
MSQ017       USING SQLCA, BY VALUE MFA-PROGRAM-ID, "0", "0", "0",
MSQ017       BY REFERENCE MFSQLMESSAGETEXT
MSQ017     END-CALL

T11934     MOVE SQLCODE TO WS-ACTIVE-RETURN-CODE.                       
T11934     IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL OR NOT-FOUND      
T11934         NEXT SENTENCE                                            
T11934     ELSE                                                         
CBSI          MOVE PROGRAM-NAME        TO ABEND-PROGRAM                 
T11934        MOVE '7420'              TO ACTIVE-PARAGRAPH              
CBSI          MOVE 'SELECT'            TO ABEND-FUNCTION                
T11934        MOVE SPACES              TO ABEND-SQL-PREDICATES          
T11934                                    ABEND-TABLES                  
T11934        MOVE 'CSS_FIXED_FCTR'    TO TABLE-1                       
T16168        MOVE 'ACCOUNT_NO'        TO TABLE-ELEMENT-1               
T16168        MOVE 'CODE_UTIL_TYPE'    TO TABLE-ELEMENT-2               
T16168        MOVE 'IC_NO'             TO TABLE-ELEMENT-3               
T16168        MOVE 'FIXED_FCTR_TYP_CD' TO TABLE-ELEMENT-4               
T11934        MOVE FF-ACCOUNT-NO       TO HOSTVAR-ELEMENT-1             
T16168        MOVE FF-CODE-UTIL-TYPE   TO HOSTVAR-ELEMENT-2             
T16168        MOVE FF-IC-NO            TO HOSTVAR-ELEMENT-3             
T11934        MOVE FF-FIXED-FCTR-TYP-CD TO HOSTVAR-ELEMENT-4            
P00251        MOVE WS-ACTIVE-RETURN-CODE     TO RS-RETURN-CODE          
P00251        PERFORM 9000-SEND-ERROR-RESULT THRU 9000-EXIT             
T11934        PERFORM 9900-SQL-ERROR-ROUTINE  THRU  9900-EXIT           
T11934     END-IF.                                                      
T11934                                                                  
T11934 7420-EXIT.                                                       
T11934     EXIT.                                                        
T11934                                                                  
                                                                        
PCR   ****************************************************************  13712718
PCR   * 7432-CHECK-SAME-FCTR.                                        *  13712818
PCR   *  ALL DEPS OF A SINGLE MASTER MUST HAVE THE SAME FACTOR.  THIS*  13712918
PCR   *  WILL CHECK THAT THERE ARE NO DEP ACCTS OF THIS MASTER THAT  *  13713018
PCR   *  HAVE A DIFFERENT FACTOR ID THAN THE PROPOSED DEP.           *  13713118
PCR   ****************************************************************  13713218
PCR                                                                     
PCR    7432-CHECK-SAME-FCTR.                                            
PCR        EXEC SQL                                                     
PCR           SELECT DISTINCT 'Y'                                       
PCR            INTO  :WS-SAME-FCTR-SIGN                                 
PCR             FROM CSS_UTL_BILL_REL,                                  
PCR                  CSS_FIXED_FCTR                                     
PCR            WHERE ACCOUNT_NO_DEP     = ACCOUNT_NO                    
PCR              AND ACCOUNT_NO_MST     = :WS-ACCOUNT-NO-NUM-MST        
PCR              AND CODE_UTIL_TYPE_MST = :UR-CODE-UTIL-TYPE-MST        
PCR              AND IC_NO_MST          = :UR-IC-NO-MST                 
T17916           AND (FIXED_FCTR_TYP_CD = 'AD'                          
T17916                OR  FIXED_FCTR_TYP_CD = 'SL')                     
PCR          AND NOT FACTOR_ID =                                        
PCR                (SELECT FACTOR_ID                                    
PCR                 FROM CSS_FIXED_FCTR                                 
PCR                WHERE ACCOUNT_NO = :FF-ACCOUNT-NO                    
PCR                 AND  (FIXED_FCTR_TYP_CD = 'AD'                      
PCR                   OR  FIXED_FCTR_TYP_CD = 'SL'))                    
P00251                                                      
PCR        END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ003
MFA-TR*    EXEC SQL                                                     13713518
MFA-TR*       SELECT DISTINCT 'Y'                                       13713618
MFA-TR*        INTO  :WS-SAME-FCTR-SIGN                                 13713718
MFA-TR*         FROM CSS_UTL_BILL_REL,                                  13713818
MFA-TR*              CSS_FIXED_FCTR                                     13713918
MFA-TR*        WHERE ACCOUNT_NO_DEP     = ACCOUNT_NO                    13714018
MFA-TR*          AND ACCOUNT_NO_MST     = :WS-ACCOUNT-NO-NUM-MST        13714118
MFA-TR*          AND CODE_UTIL_TYPE_MST = :UR-CODE-UTIL-TYPE-MST        13714218
MFA-TR*          AND IC_NO_MST          = :UR-IC-NO-MST                 13714318
MFA-TR*          AND (FIXED_FCTR_TYP_CD = 'AD'                          13714818
MFA-TR*               OR  FIXED_FCTR_TYP_CD = 'SL')                     13714918
MFA-TR*      AND NOT FACTOR_ID =                                        13714418
MFA-TR*            (SELECT FACTOR_ID                                    13714518
MFA-TR*             FROM CSS_FIXED_FCTR                                 13714618
MFA-TR*            WHERE ACCOUNT_NO = :FF-ACCOUNT-NO                    13714718
MFA-TR*             AND  (FIXED_FCTR_TYP_CD = 'AD'                      13714818
MFA-TR*               OR  FIXED_FCTR_TYP_CD = 'SL'))                    13714918
MFA-TR*       QUERYNO 7432                                                      
MFA-TR*    END-EXEC.                                                    13715018

MSQ017     CALL "MFASQLCA"
MSQ017       USING SQLCA, BY VALUE MFA-PROGRAM-ID, "0", "0", "0",
MSQ017       BY REFERENCE MFSQLMESSAGETEXT
MSQ017     END-CALL

PCR        MOVE SQLCODE TO WS-ACTIVE-RETURN-CODE.                       
PCR        IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL OR NOT-FOUND      
PCR            NEXT SENTENCE                                            
PCR        ELSE                                                         
CBSI          MOVE PROGRAM-NAME        TO ABEND-PROGRAM                 
PCR           MOVE '7432'              TO ACTIVE-PARAGRAPH              
CBSI          MOVE 'SELECT'             TO ABEND-FUNCTION               
PCR           MOVE SPACES              TO ABEND-SQL-PREDICATES          
PCR                                       ABEND-TABLES                  
PCR           MOVE 'CSS_UTL_BILL_REL'  TO TABLE-1                       
PCR           MOVE 'CSS_FIXED_FCTR'    TO TABLE-2                       
T16168        MOVE 'ACCOUNT_NO'        TO TABLE-ELEMENT-1               
CBSI          MOVE 'CODE_UTIL_TYPE_MST' TO TABLE-ELEMENT-2              
T16168        MOVE 'IC_NO'             TO TABLE-ELEMENT-3               
CBSI          MOVE 'ACCOUNT_NO_MST'    TO TABLE-ELEMENT-4               
CBSI          MOVE FF-ACCOUNT-NO       TO HOSTVAR-ELEMENT-1             
T16168        MOVE UR-CODE-UTIL-TYPE-MST TO HOSTVAR-ELEMENT-2           
T16168        MOVE UR-IC-NO-MST        TO HOSTVAR-ELEMENT-3             
CBSI          MOVE WS-ACCOUNT-NO-NUM-MST TO HOSTVAR-ELEMENT-4           
P00251        MOVE WS-ACTIVE-RETURN-CODE     TO RS-RETURN-CODE          
P00251        PERFORM 9000-SEND-ERROR-RESULT THRU 9000-EXIT             
PCR           PERFORM 9900-SQL-ERROR-ROUTINE  THRU  9900-EXIT           
PCR        END-IF.                                                      
PCR                                                                     
PCR    7432-EXIT.                                                       
PCR        EXIT.                                                        
P00251******************************************************************13712718
P00251* 7435-GET-UTIL-DETAILS.                                         *13712818
P00251*  SELECT CODE-ESTIMATE-OK                                       *13712918
P00251******************************************************************13713218
P00251*                                                                 13713318
P00251 7435-GET-UTIL-DETAILS.                                           
P00251*                                                                 13713318
P00251     EXEC SQL                                                     
P00251        SELECT TOP(1) CODE_ESTIMATE_OK                                   
P00251         INTO  :UT-CODE-ESTIMATE-OK                               
P00251          FROM CSS_UTIL_ENVRNMT WITH(READUNCOMMITTED)                     
P00251         WHERE ACCOUNT_NO         = :UT-ACCOUNT-NO                
P00251           AND CODE_UTIL_TYPE     = :UT-CODE-UTIL-TYPE            
P00251           AND IC_NO              = :UT-IC-NO                     
P00251                                              
P00251                                                      
P00251                                                           
P00251     END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ003
MFA-TR* MSQ020
MFA-TR* MSQ022
MFA-TR*    EXEC SQL                                                     13713518
MFA-TR*       SELECT CODE_ESTIMATE_OK                                   13713618
MFA-TR*        INTO  :UT-CODE-ESTIMATE-OK                               13713718
MFA-TR*         FROM CSS_UTIL_ENVRNMT                                   13713818
MFA-TR*        WHERE ACCOUNT_NO         = :UT-ACCOUNT-NO                13714018
MFA-TR*          AND CODE_UTIL_TYPE     = :UT-CODE-UTIL-TYPE            13714118
MFA-TR*          AND IC_NO              = :UT-IC-NO                     13714218
MFA-TR*        FETCH FIRST ROW ONLY                                             
MFA-TR*        QUERYNO 7435                                                     
MFA-TR*         WITH UR                                                         
MFA-TR*    END-EXEC.                                                    13715018

MSQ017     CALL "MFASQLCA"
MSQ017       USING SQLCA, BY VALUE MFA-PROGRAM-ID, "0", "0", "0",
MSQ017       BY REFERENCE MFSQLMESSAGETEXT
MSQ017     END-CALL

P00251     MOVE SQLCODE                TO WS-ACTIVE-RETURN-CODE.        
P00251     IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL OR NOT-FOUND      
P00251         NEXT SENTENCE                                            
P00251     ELSE                                                         
P00251        MOVE PROGRAM-NAME        TO ABEND-PROGRAM                 
P00251        MOVE '7435'              TO ACTIVE-PARAGRAPH              
P00251        MOVE 'SELECT'            TO ABEND-FUNCTION                
P00251        MOVE 'CSS_UTIL_ENVRNMT'  TO TABLE-1                       
P00251        MOVE 'ACCOUNT_NO'        TO TABLE-ELEMENT-1               
P00251        MOVE 'CODE_UTIL_TYPE'    TO TABLE-ELEMENT-2               
P00251        MOVE 'IC_NO'             TO TABLE-ELEMENT-3               
P00251        MOVE UT-ACCOUNT-NO       TO HOSTVAR-ELEMENT-1             
P00251        MOVE UT-CODE-UTIL-TYPE   TO HOSTVAR-ELEMENT-2             
P00251        MOVE UT-IC-NO            TO HOSTVAR-ELEMENT-3             
P00251        MOVE WS-ACTIVE-RETURN-CODE     TO RS-RETURN-CODE          
P00251        PERFORM 9000-SEND-ERROR-RESULT THRU 9000-EXIT             
P00251        PERFORM 9900-SQL-ERROR-ROUTINE  THRU  9900-EXIT           
P00251     END-IF.                                                      
P00251                                                                  
P00251 7435-EXIT.                                                       
P00251     EXIT.                                                        
P00251                                                                  
P00251******************************************************************13712718
P00251* 7440-UPDATE-UT-DETAIL.                                         *13712818
P00251*  UPDATE CODE-ESTIMATE-OK                                       *13712918
P00251******************************************************************13713218
P00251*                                                                 13713318
P00251 7440-UPDATE-UT-DETAIL.                                           
P00251*                                                                 13713318
P00251     EXEC SQL                                                     
P00251        UPDATE CSS_UTIL_ENVRNMT                                   
P00251           SET CODE_ESTIMATE_OK = :UT-CODE-ESTIMATE-OK            
P00251         WHERE ACCOUNT_NO       = :UT-ACCOUNT-NO                  
P00251           AND CODE_UTIL_TYPE   = :UT-CODE-UTIL-TYPE              
P00251           AND IC_NO            = :UT-IC-NO                       
P00251                                                      
P00251     END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ003
MFA-TR*    EXEC SQL                                                     13713518
MFA-TR*       UPDATE CSS_UTIL_ENVRNMT                                           
MFA-TR*          SET CODE_ESTIMATE_OK = :UT-CODE-ESTIMATE-OK                    
MFA-TR*        WHERE ACCOUNT_NO       = :UT-ACCOUNT-NO                  13714018
MFA-TR*          AND CODE_UTIL_TYPE   = :UT-CODE-UTIL-TYPE              13714118
MFA-TR*          AND IC_NO            = :UT-IC-NO                       13714218
MFA-TR*       QUERYNO 7440                                                      
MFA-TR*    END-EXEC.                                                    13715018

MSQ017     CALL "MFASQLCA"
MSQ017       USING SQLCA, BY VALUE MFA-PROGRAM-ID, "0", "0", "0",
MSQ017       BY REFERENCE MFSQLMESSAGETEXT
MSQ017     END-CALL

P00251     MOVE SQLCODE                TO WS-ACTIVE-RETURN-CODE.        
P00251     IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL OR NOT-FOUND      
P00251         NEXT SENTENCE                                            
P00251     ELSE                                                         
P00251        MOVE PROGRAM-NAME        TO ABEND-PROGRAM                 
P00251        MOVE '7440'              TO ACTIVE-PARAGRAPH              
P00251        MOVE 'UPDATE'            TO ABEND-FUNCTION                
P00251        MOVE 'CSS_UTIL_ENVRNMT'  TO TABLE-1                       
P00251        MOVE 'ACCOUNT_NO'        TO TABLE-ELEMENT-1               
P00251        MOVE 'CODE_UTIL_TYPE'    TO TABLE-ELEMENT-2               
P00251        MOVE 'IC_NO'             TO TABLE-ELEMENT-3               
P00251        MOVE UT-ACCOUNT-NO       TO HOSTVAR-ELEMENT-1             
P00251        MOVE UT-CODE-UTIL-TYPE   TO HOSTVAR-ELEMENT-2             
P00251        MOVE UT-IC-NO            TO HOSTVAR-ELEMENT-3             
P00251        MOVE WS-ACTIVE-RETURN-CODE     TO RS-RETURN-CODE          
P00251        PERFORM 9000-SEND-ERROR-RESULT THRU 9000-EXIT             
P00251        PERFORM 9900-SQL-ERROR-ROUTINE  THRU  9900-EXIT           
P00251     END-IF.                                                      
P00251                                                                  
P00251 7440-EXIT.                                                       
P00251     EXIT.                                                        
P00251*                                                                 13716918
P00251******************************************************************13712718
P00251* 7500-UPDATE-UTL-BILL-REL.                                      *13712818
P00251*  UPDATE CSS_UTL_BILL_REL                                       *13712918
P00251******************************************************************13713218
P00251*                                                                 13713318
P00251 7500-UPDATE-UTL-BILL-REL.                                        
P00251*                                                                 13713318
P00251     EXEC SQL                                                     
P00251        UPDATE CSS_UTL_BILL_REL                                   
P00251           SET DEP_REL_END_DT     =IIF(TRY_CONVERT(DATE, 
                                                     :UR-DEP-REL-END-DT
              ) IS NULL OR (PATINDEX('%.%', :UR-DEP-REL-END-DT
              ) <> 0) OR (LEN(:UR-DEP-REL-END-DT
              ) <> 10), CIS.CHAR2DATE(:UR-DEP-REL-END-DT
              ), CONVERT(DATE, :UR-DEP-REL-END-DT) )             
P00251         WHERE ACCOUNT_NO_DEP     =:UR-ACCOUNT-NO-DEP             
P00251           AND CODE_UTIL_TYPE_DEP =:UR-CODE-UTIL-TYPE-DEP         
P00251           AND IC_NO_DEP          =:UR-IC-NO-DEP                  
P00251           AND MTR_REF_NO_DEP     =:UR-MTR-REF-NO-DEP             
P00251           AND ACCOUNT_NO_MST     =:UR-ACCOUNT-NO-MST             
P00251           AND CODE_UTIL_TYPE_MST =:UR-CODE-UTIL-TYPE-MST         
P00251           AND IC_NO_MST          =:UR-IC-NO-MST                  
P00251           AND MTR_REF_NO_MST     =:UR-MTR-REF-NO-MST             
P00251           AND CODE_RELATION_TYPE =:UR-CODE-RELATION-TYPE         
P00251           AND DEP_REL_START_DT   =IIF(TRY_CONVERT(DATE, 
                                                   :UR-DEP-REL-START-DT
              ) IS NULL OR (PATINDEX('%.%', :UR-DEP-REL-START-DT
              ) <> 0) OR (LEN(:UR-DEP-REL-START-DT
              ) <> 10), CIS.CHAR2DATE(:UR-DEP-REL-START-DT
              ), CONVERT(DATE, :UR-DEP-REL-START-DT) )           
P00251                                                      
P00251     END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ003
MFA-TR* MSQ054
MFA-TR*    EXEC SQL                                                     13713518
MFA-TR*       UPDATE CSS_UTL_BILL_REL                                           
MFA-TR*          SET DEP_REL_END_DT     =:UR-DEP-REL-END-DT                     
MFA-TR*        WHERE ACCOUNT_NO_DEP     =:UR-ACCOUNT-NO-DEP                     
MFA-TR*          AND CODE_UTIL_TYPE_DEP =:UR-CODE-UTIL-TYPE-DEP                 
MFA-TR*          AND IC_NO_DEP          =:UR-IC-NO-DEP                          
MFA-TR*          AND MTR_REF_NO_DEP     =:UR-MTR-REF-NO-DEP                     
MFA-TR*          AND ACCOUNT_NO_MST     =:UR-ACCOUNT-NO-MST                     
MFA-TR*          AND CODE_UTIL_TYPE_MST =:UR-CODE-UTIL-TYPE-MST                 
MFA-TR*          AND IC_NO_MST          =:UR-IC-NO-MST                          
MFA-TR*          AND MTR_REF_NO_MST     =:UR-MTR-REF-NO-MST                     
MFA-TR*          AND CODE_RELATION_TYPE =:UR-CODE-RELATION-TYPE                 
MFA-TR*          AND DEP_REL_START_DT   =:UR-DEP-REL-START-DT                   
MFA-TR*        QUERYNO 7500                                                     
MFA-TR*    END-EXEC.                                                    13715018

MSQ017     CALL "MFASQLCA"
MSQ017       USING SQLCA, BY VALUE MFA-PROGRAM-ID, "0", "0", "0",
MSQ017       BY REFERENCE MFSQLMESSAGETEXT
MSQ017     END-CALL

P00251     MOVE SQLCODE                TO WS-ACTIVE-RETURN-CODE.        
P00251     IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL                   
P00251         NEXT SENTENCE                                            
P00251     ELSE                                                         
P00251        MOVE PROGRAM-NAME          TO ABEND-PROGRAM               
P00251        MOVE '7500'                TO ACTIVE-PARAGRAPH            
P00251        MOVE 'UPDATE'              TO ABEND-FUNCTION              
P00251        MOVE 'CSS_UTL_BILL_REL'    TO TABLE-1                     
P00251        MOVE 'ACCOUNT_NO_DEP'      TO TABLE-ELEMENT-1             
P00251        MOVE 'CODE_UTIL_TYPE_DEP'  TO TABLE-ELEMENT-2             
P00251        MOVE 'IC_NO_DEP'           TO TABLE-ELEMENT-3             
P00251        MOVE 'MTR_REF_NO_DEP'      TO TABLE-ELEMENT-4             
P00251        MOVE UR-ACCOUNT-NO-DEP     TO HOSTVAR-ELEMENT-1           
P00251        MOVE UR-CODE-UTIL-TYPE-DEP TO HOSTVAR-ELEMENT-2           
P00251        MOVE UR-IC-NO-DEP          TO HOSTVAR-ELEMENT-3           
P00251        MOVE UR-MTR-REF-NO-DEP     TO HOSTVAR-ELEMENT-4           
P00251        MOVE WS-ACTIVE-RETURN-CODE     TO RS-RETURN-CODE          
P00251        PERFORM 9000-SEND-ERROR-RESULT THRU 9000-EXIT             
P00251        PERFORM 9900-SQL-ERROR-ROUTINE  THRU  9900-EXIT           
P00251     END-IF.                                                      
P00251                                                                  
P00251 7500-EXIT.                                                       
P00251     EXIT.                                                        
P00251*                                                                 13717010
P00251****************************************************************  13040000
P00251* 7610-CHECK-MSTDEPREL-EXISTS.                                 *  13050000
P00251****************************************************************  13060000
P00251                                                                  
P00251 7610-CHECK-MSTDEPREL-EXISTS.                                     
P00251     EXEC SQL                                                     
P00251        SELECT TOP(1) 'Y'                                                
P00251         INTO  :WS-MSTDEPREL-EXISTS                               
P00251          FROM CSS_UTL_BILL_REL WITH(READUNCOMMITTED)                     
P00251         WHERE ACCOUNT_NO_DEP     =  :UR-ACCOUNT-NO-DEP           
P00251           AND CODE_UTIL_TYPE_DEP =  :UR-CODE-UTIL-TYPE-DEP       
P00251           AND IC_NO_DEP          =  :UR-IC-NO-DEP                
P00251           AND MTR_REF_NO_DEP     =  :UR-MTR-REF-NO-DEP           
P00251           AND ACCOUNT_NO_MST     =  :UR-ACCOUNT-NO-MST           
P00251           AND CODE_UTIL_TYPE_MST =  :UR-CODE-UTIL-TYPE-MST       
P00251           AND IC_NO_MST          =  :UR-IC-NO-MST                
P00251           AND MTR_REF_NO_MST     =  :UR-MTR-REF-NO-MST           
P00251           AND CODE_RELATION_TYPE =  :UR-CODE-RELATION-TYPE       
P00251           AND DEP_REL_START_DT   <> IIF(TRY_CONVERT(DATE, 
                                                   :UR-DEP-REL-START-DT
              ) IS NULL OR (PATINDEX('%.%', :UR-DEP-REL-START-DT
              ) <> 0) OR (LEN(:UR-DEP-REL-START-DT
              ) <> 10), CIS.CHAR2DATE(:UR-DEP-REL-START-DT
              ), CONVERT(DATE, :UR-DEP-REL-START-DT) )         
P00251           AND (IIF(TRY_CONVERT(DATE, :UR-DEP-REL-START-DT
              ) IS NULL OR (PATINDEX('%.%', :UR-DEP-REL-START-DT
              ) <> 0) OR (LEN(:UR-DEP-REL-START-DT
              ) <> 10), CIS.CHAR2DATE(:UR-DEP-REL-START-DT
              ), CONVERT(DATE, :UR-DEP-REL-START-DT) ) BETWEEN 
           DEP_REL_START_DT     
P00251                                     AND DEP_REL_END_DT           
P00251            OR IIF(TRY_CONVERT(DATE, :UR-DEP-REL-END-DT
              ) IS NULL OR (PATINDEX('%.%', :UR-DEP-REL-END-DT
              ) <> 0) OR (LEN(:UR-DEP-REL-END-DT
              ) <> 10), CIS.CHAR2DATE(:UR-DEP-REL-END-DT
              ), CONVERT(DATE, :UR-DEP-REL-END-DT) )    BETWEEN 
           DEP_REL_START_DT     
P00251                                     AND DEP_REL_END_DT           
P00251            OR DEP_REL_START_DT      BETWEEN 
              IIF(TRY_CONVERT(DATE, :UR-DEP-REL-START-DT
              ) IS NULL OR (PATINDEX('%.%', :UR-DEP-REL-START-DT
              ) <> 0) OR (LEN(:UR-DEP-REL-START-DT
              ) <> 10), CIS.CHAR2DATE(:UR-DEP-REL-START-DT
              ), CONVERT(DATE, :UR-DEP-REL-START-DT) ) 
P00251                                     AND IIF(TRY_CONVERT(DATE, 
                                                     :UR-DEP-REL-END-DT
              ) IS NULL OR (PATINDEX('%.%', :UR-DEP-REL-END-DT
              ) <> 0) OR (LEN(:UR-DEP-REL-END-DT
              ) <> 10), CIS.CHAR2DATE(:UR-DEP-REL-END-DT
              ), CONVERT(DATE, :UR-DEP-REL-END-DT) )       
P00251            OR DEP_REL_END_DT        BETWEEN 
              IIF(TRY_CONVERT(DATE, :UR-DEP-REL-START-DT
              ) IS NULL OR (PATINDEX('%.%', :UR-DEP-REL-START-DT
              ) <> 0) OR (LEN(:UR-DEP-REL-START-DT
              ) <> 10), CIS.CHAR2DATE(:UR-DEP-REL-START-DT
              ), CONVERT(DATE, :UR-DEP-REL-START-DT) ) 
P00251                                     AND IIF(TRY_CONVERT(DATE, 
                                                     :UR-DEP-REL-END-DT
              ) IS NULL OR (PATINDEX('%.%', :UR-DEP-REL-END-DT
              ) <> 0) OR (LEN(:UR-DEP-REL-END-DT
              ) <> 10), CIS.CHAR2DATE(:UR-DEP-REL-END-DT
              ), CONVERT(DATE, :UR-DEP-REL-END-DT) ))      
P00251                                            
P00251                                                           
P00251                                                      
P00251     END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ003
MFA-TR* MSQ020
MFA-TR* MSQ022
MFA-TR* MSQ054
MFA-TR*    EXEC SQL                                                     13090000
MFA-TR*       SELECT 'Y'                                                13100000
MFA-TR*        INTO  :WS-MSTDEPREL-EXISTS                               13150000
MFA-TR*         FROM CSS_UTL_BILL_REL                                   13200000
MFA-TR*        WHERE ACCOUNT_NO_DEP     =  :UR-ACCOUNT-NO-DEP           13210000
MFA-TR*          AND CODE_UTIL_TYPE_DEP =  :UR-CODE-UTIL-TYPE-DEP       13220000
MFA-TR*          AND IC_NO_DEP          =  :UR-IC-NO-DEP                13230000
MFA-TR*          AND MTR_REF_NO_DEP     =  :UR-MTR-REF-NO-DEP           13240000
MFA-TR*          AND ACCOUNT_NO_MST     =  :UR-ACCOUNT-NO-MST                   
MFA-TR*          AND CODE_UTIL_TYPE_MST =  :UR-CODE-UTIL-TYPE-MST               
MFA-TR*          AND IC_NO_MST          =  :UR-IC-NO-MST                        
MFA-TR*          AND MTR_REF_NO_MST     =  :UR-MTR-REF-NO-MST                   
MFA-TR*          AND CODE_RELATION_TYPE =  :UR-CODE-RELATION-TYPE               
MFA-TR*          AND DEP_REL_START_DT   <> :UR-DEP-REL-START-DT                 
MFA-TR*          AND (:UR-DEP-REL-START-DT BETWEEN DEP_REL_START_DT             
MFA-TR*                                    AND DEP_REL_END_DT                   
MFA-TR*           OR :UR-DEP-REL-END-DT    BETWEEN DEP_REL_START_DT             
MFA-TR*                                    AND DEP_REL_END_DT                   
MFA-TR*           OR DEP_REL_START_DT      BETWEEN :UR-DEP-REL-START-DT         
MFA-TR*                                    AND :UR-DEP-REL-END-DT               
MFA-TR*           OR DEP_REL_END_DT        BETWEEN :UR-DEP-REL-START-DT         
MFA-TR*                                    AND :UR-DEP-REL-END-DT)              
MFA-TR*         FETCH FIRST 1 ROW ONLY                                          
MFA-TR*         WITH UR                                                         
MFA-TR*         QUERYNO 7610                                                    
MFA-TR*    END-EXEC.                                                    13250000

MSQ017     CALL "MFASQLCA"
MSQ017       USING SQLCA, BY VALUE MFA-PROGRAM-ID, "0", "0", "0",
MSQ017       BY REFERENCE MFSQLMESSAGETEXT
MSQ017     END-CALL

P00251     MOVE SQLCODE TO WS-ACTIVE-RETURN-CODE.                       
P00251     IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL OR NOT-FOUND      
P00251         NEXT SENTENCE                                            
P00251     ELSE                                                         
P00251        MOVE PROGRAM-NAME          TO ABEND-PROGRAM               
P00251        MOVE '7610'                TO ACTIVE-PARAGRAPH            
P00251        MOVE 'SELECT'              TO ABEND-FUNCTION              
P00251        MOVE SPACES                TO ABEND-SQL-PREDICATES        
P00251                                      ABEND-TABLES                
P00251        MOVE 'CSS_UTL_BILL_REL'    TO TABLE-1                     
P00251        MOVE 'ACCOUNT_NO_DEP'      TO TABLE-ELEMENT-1             
P00251        MOVE 'CODE_UTIL_TYPE_DEP'  TO TABLE-ELEMENT-2             
P00251        MOVE 'IC_NO_DEP'           TO TABLE-ELEMENT-3             
P00251        MOVE 'MTR_REF_NO_DEP'      TO TABLE-ELEMENT-4             
P00251        MOVE UR-ACCOUNT-NO-DEP     TO HOSTVAR-ELEMENT-1           
P00251        MOVE UR-CODE-UTIL-TYPE-DEP TO HOSTVAR-ELEMENT-2           
P00251        MOVE UR-IC-NO-DEP          TO HOSTVAR-ELEMENT-3           
P00251        MOVE UR-MTR-REF-NO-DEP     TO HOSTVAR-ELEMENT-4           
P00251        MOVE WS-ACTIVE-RETURN-CODE TO RS-RETURN-CODE              
P00251        PERFORM 9000-SEND-ERROR-RESULT THRU 9000-EXIT             
P00251        PERFORM 9900-SQL-ERROR-ROUTINE  THRU  9900-EXIT           
P00251     END-IF.                                                      
P00251                                                                  
P00251 7610-EXIT.                                                       
P00251     EXIT.                                                        
P00251*                                                                         
      ******************************************************************13717100
      * 9900 - JOURNALING / ERROR HANDLING ROUTINE                     *13718000
      ******************************************************************13720000
           EXEC SQL                                                     13730000
              INCLUDE CPDSP300                                          13740000
           END-EXEC.                                                    13750000
                                                                        
      ******************************************************************13770000
      *       END PROGRAM COPYLIB                                      *13780000
      ******************************************************************13790000
                                                                        
                                                                        
CVT000 8100-SEND-RESULT.                                                
CVT000       ADD 1 TO CTR-ROWS.                                         
CVT000 8100-EXIT.                                                       
CVT000        EXIT.                                                     
CVT000     EXEC SQL                                                     00000100
CVT000         INCLUDE CPD00321                                         00000200
CVT000     END-EXEC.                                                    00000300
