       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID.    CSR02004.                                         
COB303 DATE-WRITTEN.     JANUARY 4, 1995.                               
       DATE-COMPILED.                                                   
                                                                        
CVT000******************************************************************00000600
CVT000*     - - - - - >   R P C   C O N V E R S I O N   < - - - - -    *00000700
CVT000*         S004 CONVERTED TO DB2 SP CSR02004 ON 10/26/2005        *00000800
CVT000*             -NOTE: AUTOMATED CONVERSION PROGRAM USED           *00000900
CVT000*                                                                *00001000
CVT000*                    CVT000 - CONVERTED CODE                     *00001100
CVT000*                    CVT004 - NEEDED REVIEW                      *00001200
CVT000*                    CVT999 - COMMENTED OUT CODE THAT CAN        *00001300
CVT000*                             POTENTIALLY BE DELETED             *00001400
CVT000*                                                                *00001500
CVT000******************************************************************00001600
      ******************************************************************00001700
      *                SOUTH CAROLINA ELECTRIC & GAS                   *00001800
      *                                                                *00001900
      *  THIS PROGRAM IS EXECUTED VIA A REMOTE PROCEDURE CALL (RPC).   *00002000
      *                                                                *00002100
      *  TRANID:        S004                                           *00002200
      *  PROGRAM:       S004                                           *00002300
      *  CALLING SP:    PD_FACTORUSEINFOGET                            *00002400
      *                                                                *00002500
      ******************************************************************00002600
      *                 P R O G R A M  S U M M A R Y                   *00002700
      *                                                                *00002800
      * THIS PROGRAM IS A REMOTE PROCEDURE CALL MADE FROM              *00002900
      * DESKTOP 2000 VIA THE SYBASE NETGATEWAY.                        *00003000
      *                                                                *00003100
      * THIS PROGRAM RETRIEVES ALL SPECIAL FACTOR TESTS, DESCRIPTIONS  *00003200
      * AND STATUS FOR EVERY DISTINCT FACTOR ID.                       *00003300
      *                                                                *00003400
      ******************************************************************00003500
      *                                                                *00003600
      *                     PROGRAM MODIFICATION LOG                   *00003700
      *                                                                *00003800
      *    DATE    INITIALS   COMMENTS                                 *00003900
      *  --------  --------   ---------------------------------------  *00004000
      *  01/04/95    WMG      CREATED.                                 *00004100
CBSI  *  07/13/98   CBSI      ABEND LOG MODIFIED TO INCLUDE ALL THE    *00004200
CBSI  *             MADRAS    ABEND PARAMETERS                         *00004300
T27237*  04/17/03   SK88120   GET UTIL FACTORS FOR ALL FACTORS         *00004400
REARCH*  10/25/05   CVNS      RPC TO COBOL DB2 SP CONVERSION.          *00004500
REARCH*             CHENNAI                                            *00004600
T34569*  07/20/07   PC97415   INCLUDED FACTOR_TYPE = 'F' IN THE CURSOR *00004700
      *                       FCTR-ID-CURSOR                           *00004800
ACT004*  05/23/16   TP7R341   REMOVE UNWANTED COLUMNS OF CSS_SPCL_FCTR *00004900
ACT004*   A04177                                                       *00005000
      ******************************************************************00005100
      ******************************************************************00005200
      *                                                                *00005300
      *                ---- BASIC SEQUENCE STRUCTURE ----              *00005400
      *                                                                *00005500
      *  0000 - 0999  MAIN CONTROL PATH AND INITIALIZATION             *00005600
      *  1000 - 1999  INPUT PROCESSING CONTROL PATH                    *00005700
      *  2000 - 2999  OUTPUT PROCESSING CONTROL PATH                   *00005800
      *  3000 - 4999  NOT USED                                         *00005900
      *  5000 - 5999  COMMON PROGRAM MODULES                           *00006000
      *  6000 - 6999  COMMON SYSTEM MODULES                            *00006100
      *  7000 - 7999  INPUT MODULES                                    *00006200
      *  8000 - 8999  OUTPUT MODULES                                   *00006300
      *  9000 - 9999  TERMINATION,ABEND, MESSAGING MODULES             *00006400
      *                                                                *00006500
      ******************************************************************00006600
                                                                        
       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 'CSR02004'.
MSQ017     COPY MFASQLM.
                                                                        
       01  WS-START                                   PIC X(40) VALUE   
REARCH     'WORKING STORAGE FOR CSR02004 STARTS HERE'.                  
                                                                        
      ******************************************************************00007500
      *    DB2 INCLUDES                                                *00007600
      ******************************************************************00007700
                                                                        
           EXEC SQL                                                     00007900
              INCLUDE SQLCA                                             00008000
           END-EXEC.                                                    00008100
                                                                        
           EXEC SQL                                                     00008300
              INCLUDE TBSPLFTR                                          00008400
           END-EXEC.                                                    00008500
                                                                        
           EXEC SQL                                                     00008700
              INCLUDE TBSPLAPL                                          00008800
           END-EXEC.                                                    00008900
                                                                        
           EXEC SQL                                                     00009100
              INCLUDE TBMODEL                                           00009200
           END-EXEC.                                                    00009300
                                                                        
      ******************************************************************00009500
      *    COBOL WORKING STORAGE COPY BOOKS                            *00009600
      ******************************************************************00009700
                                                                        
      * CONTAINS THE COBOL EQUATES NEEDED FOR USING THE                 00009900
      * SYBASE OPEN SERVER FOR CICS FACILITIES.                         00010000
CVT999*    COPY SYGWCOB.                                                00010100
      * ADDED TO SUPPORT CICS RPCS                                      00010200
CVT999*    COPY SYDBCOB.                                                00010300
      * ERROR HANDLING                                                  00010600
CVT999*    COPY CWS00010.                                               00010700
      * ERROR WORK AREA - SUPPORTS ONLINE/CSR JOURNALS                  00010800
           COPY CWS00027.                                               00010900
      * SUPPORTS DB2 AND SQL ERROR CHECKING                             00011000
           COPY CWS00303.                                               00011100
                                                                        
      ******************************************************************00011300
      *    WORK AREAS                                                  *00011400
      ******************************************************************00011500
                                                                        
       01  GW-LIB-MISC-FIELDS.                                          
REARCH     05  PROGRAM-NAME            PIC X(08) VALUE 'CSR02004'.      
CVT999*    05  GWL-PROC                POINTER.                         00011900
CVT999*    05  GWL-INIT-HANDLE         POINTER.                         00012000
CVT999*    05  GWL-RC                  PIC S9(9) COMP.                  00012100
CVT999*    05  GWL-STATUS-NR           PIC S9(9) COMP.                  00012200
CVT999*    05  GWL-STATUS-DONE         PIC S9(9) COMP.                  00012300
CVT999*    05  GWL-STATUS-COUNT        PIC S9(9) COMP.                  00012400
CVT999*    05  GWL-STATUS-COMM         PIC S9(9) COMP.                  00012500
CVT999*    05  GWL-STATUS-RETURN-CODE  PIC S9(9) COMP.                  00012600
           05  GWL-STATUS-SUBCODE      PIC S9(9) COMP.                  
                                                                        
       01  FILLER                      PIC X(11) VALUE 'PARM FIELDS'.   
                                                                        
       01  PARM-FIELDS.                                                 
           05  PARM-L                  PIC S9(9) COMP.                  
CVT999*    05  PARM-ID1                PIC S9(9) COMP VALUE 1.          00013300
                                                                        
       01  SNA-FIELDS.                                                  
           05  SNA-SUBC                PIC S9(9) COMP.                  
CVT999*    05  SNA-CONNECTION-NAME     PIC X(8)  VALUE SPACES.          00013700
                                                                        
       01  COUNTER-FIELDS.                                              
CVT999*    05  CTR-COLUMN              PIC S9(9) COMP VALUE 1.          00014000
           05  CTR-ROWS                PIC S9(9) COMP VALUE 0.          
           05  WS-ROW-COUNT            PIC S9(9) COMP VALUE 0.          
                                                                        
CBSI   01  WS-LITERALS.                                                 
CBSI       05  WS-A                    PIC X(1)  VALUE 'A'.             
                                                                        
       01  WORK-FIELDS.                                                 
CVT999*    05  MAX-LENGTH-PARM         PIC S9(9) COMP.                  00014800
CVT999*    05  WRKLEN1                 PIC S9(9) COMP.                  00014900
CVT999*    05  WRKLEN2                 PIC S9(9) COMP.                  00015000
           05  WRK-DONE-STATUS         PIC S9(9) COMP.                  
                                                                        
       01  WS-FLAG-VALUES.                                              
           05  WS-YES                  PIC X(01) VALUE 'Y'.             
           05  WS-NO                   PIC X(01) VALUE 'N'.             
           05  WS-ACTIVE-CODE          PIC X(01) VALUE 'A'.             
                                                                        
       01  FILLER  PIC X(32) VALUE 'THIS IS THE ROW RETURN AREA.'.      
                                                                        
REARCH 01  TDS-RETURN-FIELDS.                                           
           05  RS-RETURN-CODE          PIC S9(9) COMP VALUE 0.          
           05  RS-FACTOR-ID            PIC X(09)      VALUE SPACES.     
           05  RS-FACTOR-TEXT          PIC X(20)      VALUE SPACES.     
           05  RS-FACTOR-DESC          PIC X(60)      VALUE SPACES.     
           05  RS-FACTOR-STATUS        PIC X(01)      VALUE SPACES.     
T27237     05  RS-ELECTRIC-FACTOR      PIC X(01)      VALUE SPACES.     
T27237     05  RS-GAS-FACTOR           PIC X(01)      VALUE SPACES.     
T27237     05  RS-UNMETER-FACTOR       PIC X(01)      VALUE SPACES.     
                                                                        
REARCH 01  GTT-RETURN-FIELDS.                                           
REARCH     05  S-RETURN-CODE           PIC S9(9) COMP VALUE 0.          
REARCH     05  S-FACTOR-ID             PIC X(09)      VALUE SPACES.     
REARCH     05  S-FACTOR-TEXT           PIC X(20)      VALUE SPACES.     
REARCH     05  S-FACTOR-DESC           PIC X(60)      VALUE SPACES.     
REARCH     05  S-FACTOR-STATUS         PIC X(01)      VALUE SPACES.     
REARCH     05  S-ELECTRIC-FACTOR       PIC X(01)      VALUE SPACES.     
REARCH     05  S-GAS-FACTOR            PIC X(01)      VALUE SPACES.     
REARCH     05  S-UNMETER-FACTOR        PIC X(01)      VALUE SPACES.     
CVT999*01  CNS-COLUMN-NAMES.                                            00018500
CVT999*    05  CNS-RETURN-CODE        PIC X(11) VALUE 'RETURN_CODE'.    00018600
CVT999*    05  CNS-FACTOR-ID          PIC X(09) VALUE 'FACTOR_ID'.      00018700
CVT999*    05  CNS-FACTOR-TEXT        PIC X(11) VALUE 'FACTOR_TEXT'.    00018800
CVT999*    05  CNS-FACTOR-DESC        PIC X(11) VALUE 'FACTOR_DESC'.    00018900
CVT999*    05  CNS-FACTOR-STATUS      PIC X(13) VALUE 'FACTOR_STATUS'.  00019000
CVT999*    05  CNS-ELECTRIC-FACTOR    PIC X(15) VALUE 'ELECTRIC_FACTOR'.00019100
CVT999*    05  CNS-GAS-FACTOR         PIC X(10) VALUE 'GAS_FACTOR'.     00019200
CVT999*    05  CNS-WATER-FACTOR       PIC X(12) VALUE 'WATER_FACTOR'.   00019300
CVT999*    05  CNS-UNMETER-FACTOR     PIC X(14) VALUE 'UNMETER_FACTOR'. 00019400
CVT999*    05  CNS-SEWER-FACTOR       PIC X(12) VALUE 'SEWER_FACTOR'.   00019500
CVT999*    05  CNS-TRASH-FACTOR       PIC X(12) VALUE 'TRASH_FACTOR'.   00019600
CVT999*                                                                 00019700
       01  SWITCHES.                                                    
           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'.             
                                                                        
      ******************************************************************00020600
      *    CURSOR DECLARATIONS                                         *00020700
      ******************************************************************00020800
                                                                        
      * CURSOR FOR CSS_SPCL_FCTR                                        00021000
                                                                        
           EXEC SQL DECLARE FCTR-ID-CURSOR CURSOR FOR                   
               SELECT FACTOR_ID                                         
                     ,FACTOR_TEXT                                       
                     ,FACTOR_DESC                                       
                     ,CODE_STATUS                                       
T27237               ,RATE_ELEC_FCTR                                    
T27237               ,RATE_GAS_FCTR                                     
T27237               ,RATE_UNMTRD_FCTR                                  
                 FROM CSS_SPCL_FCTR                                     
                WHERE FACTOR_TYPE = 'A'                                 
T34569             OR FACTOR_TYPE = 'F'                                 
T34569             OR FACTOR_TYPE = 'V'                                 
           END-EXEC.                                                    
                                                                        
HPCCDM*EJECT                                                            00022900
CVT000     EXEC SQL                                                     00023000
CVT000         INCLUDE CWSX0010                                         00023100
CVT000     END-EXEC.                                                    00023200
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).                    
REARCH*    10  S-RETURN-CODE             PIC S9(9) COMP VALUE 0.        00025100
CVT000     10  WS-SQLSTATE               PIC X(05) VALUE SPACES.        
CVT000                                                                  
CVT000                                                                  
CVT000                                                                  
CVT000                                                                  
CVT000     EXEC SQL                                                     
CVT000         DECLARE C1 CURSOR  FOR                        
REARCH         SELECT                                                   
REARCH            RETURN_CODE                                           
REARCH           ,LTRIM(RTRIM(FACTOR_ID))          AS FACTOR_ID                
REARCH           ,LTRIM(RTRIM(FACTOR_TEXT))        AS FACTOR_TEXT              
REARCH           ,LTRIM(RTRIM(FACTOR_DESC))        AS FACTOR_DESC              
REARCH           ,LTRIM(RTRIM(FACTOR_STATUS))      AS FACTOR_STATUS            
REARCH           ,LTRIM(RTRIM(ELECTRIC_FACTOR))    AS ELECTRIC_FACTOR          
REARCH           ,LTRIM(RTRIM(GAS_FACTOR))         AS GAS_FACTOR               
REARCH           ,LTRIM(RTRIM(UNMETER_FACTOR))     AS UNMETER_FACTOR           
CVT000         FROM #CSR02004_R1                                 
CVT000     END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ029
MFA-TR* MSQ049
MFA-TR*    EXEC SQL                                                     00025700
MFA-TR*        DECLARE C1 CURSOR WITH RETURN FOR                        00025800
MFA-TR*        SELECT                                                   00025900
MFA-TR*           RETURN_CODE                                           00026000
MFA-TR*          ,STRIP(FACTOR_ID)          AS FACTOR_ID                00026100
MFA-TR*          ,STRIP(FACTOR_TEXT)        AS FACTOR_TEXT              00026200
MFA-TR*          ,STRIP(FACTOR_DESC)        AS FACTOR_DESC              00026300
MFA-TR*          ,STRIP(FACTOR_STATUS)      AS FACTOR_STATUS            00026400
MFA-TR*          ,STRIP(ELECTRIC_FACTOR)    AS ELECTRIC_FACTOR          00026500
MFA-TR*          ,STRIP(GAS_FACTOR)         AS GAS_FACTOR               00026600
MFA-TR*          ,STRIP(UNMETER_FACTOR)     AS UNMETER_FACTOR           00026800
MFA-TR*        FROM SESSION.CSR02004_R1                                 00027100
MFA-TR*    END-EXEC.                                                    00027200
CVT000                                                                  
                                                                        
REARCH*LINKAGE SECTION.                                                 00027500
                                                                        
REARCH*PROCEDURE-DIVISION.                                              00027700
REARCH*    EXEC SQL                                                     00027800
REARCH*        WHENEVER SQLWARNING                                      00027900
REARCH*            CONTINUE                                             00028000
REARCH*    END-EXEC.                                                    00028100
REARCH*                                                                 00028200
REARCH*    EXEC SQL                                                     00028300
REARCH*        WHENEVER SQLERROR                                        00028400
REARCH*            CONTINUE                                             00028500
REARCH*    END-EXEC.                                                    00028600
REARCH*                                                                 00028700
REARCH*    EXEC SQL                                                     00028800
REARCH*        WHENEVER NOT FOUND                                       00028900
CVT000*            CONTINUE                                             00029000
CVT000*    END-EXEC.                                                    00029100
REARCH PROCEDURE DIVISION.                                              
                                                                        
      ******************************************************************00029400
      * 0000-MAINLINE                                                  *00029500
      *     CONTROLS THE MAIN PATH OF THE PROGRAM.                     *00029600
      *                                                                *00029700
      ******************************************************************00029800
                                                                        
       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.                                                        
                                                                        
      ******************************************************************00030900
      * 0100-INITIALIZE                                                *00031000
      *     1. RESET DB2 ERROR HANDLERS                                *00031100
      *     2. ESTABLISH GATEWAY ENVIRONMENT (TDINIT)                  *00031200
      *     3. ACCEPT CLIENT REQUEST/ESTABLISH SNA HANDLE (TDACCEPT)   *00031300
      **    4. DETERMINE IF CLIENT HAS SENT AN RPC PARAMETER (TDRESULT)*00031400
      *                                                                *00031500
      *     CALLED BY: 0000-MAINLINE                                   *00031600
      *                                                                *00031700
      ******************************************************************00031800
                                                                        
       0100-INITIALIZE.                                                 
                                                                        
           MOVE '0100'          TO ACTIVE-PARAGRAPH.                    
                                                                        
REARCH     EXEC SQL WHENEVER SQLWARNING CONTINUE END-EXEC.              
REARCH     EXEC SQL WHENEVER SQLERROR   CONTINUE END-EXEC.              
REARCH     EXEC SQL WHENEVER NOT FOUND  CONTINUE END-EXEC.              
                                                                        
CVT999*    CALL 'TDINIT'   USING DFHEIBLK, GWL-RC, GWL-INIT-HANDLE.     00032800
                                                                        
CVT999*    CALL 'TDACCEPT' USING GWL-PROC, GWL-RC, GWL-INIT-HANDLE,     00033000
CVT999*                          SNA-CONNECTION-NAME, SNA-SUBC.         00033100
                                                                        
      *    CALL 'TDRESULT' USING GWL-PROC, GWL-RC.                      00033300
      *                                                                 00033400
      *    IF GWL-RC NOT = TDS-PARM-PRESENT                             00033500
      *       MOVE PROGRAM-NAME    TO ABEND-PROGRAM                     00033600
      *       MOVE 'TDRESULT - NO RPC PARM SENT' TO ABEND-FUNCTION      00033700
      *       MOVE 'CICS TRANSACTION'   TO TABLE-1                      00033800
      *       MOVE GWL-RC               TO WS-ACTIVE-RETURN-CODE        00033900
      *       PERFORM 9000-SEND-ERROR-RESULT  THRU 9000-EXIT            00034000
      *       PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT            00034100
      *    END-IF.                                                      00034200
                                                                        
CVT000     PERFORM 0100A-DECLARE-GTT                                    
CVT000       THRU 0100A-EXIT.                                           
       0100-EXIT.                                                       
           EXIT.                                                        
                                                                        
CVT000 0100A-DECLARE-GTT.                                               
CVT000     EXEC SQL
             CALL CIS.DROP_TEMP_TABLE('#CSR02004_R1')
           END-EXEC
           EXEC SQL
             CREATE TABLE #CSR02004_R1
              (                                                          
CVT000         RETURN_CODE              INT                         
CVT000        ,FACTOR_ID CHAR(09)  COLLATE LATIN1_GENERAL_100_BIN2              
CVT000        ,FACTOR_TEXT CHAR(20)  COLLATE LATIN1_GENERAL_100_BIN2            
CVT000        ,FACTOR_DESC CHAR(60)  COLLATE LATIN1_GENERAL_100_BIN2            
CVT000        ,FACTOR_STATUS CHAR(01)  COLLATE LATIN1_GENERAL_100_BIN2          
CVT000        ,ELECTRIC_FACTOR CHAR(01)  COLLATE LATIN1_GENERAL_100_BIN2        
CVT000        ,GAS_FACTOR CHAR(01)  COLLATE LATIN1_GENERAL_100_BIN2             
CVT000        ,UNMETER_FACTOR CHAR(01)  COLLATE LATIN1_GENERAL_100_BIN2         
CVT000       )
           END-EXEC.                                                    

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

           MOVE SQLSTATE TO WS-SQLSTATE.                                
           MOVE SQLCODE  TO WS-ACTIVE-RETURN-CODE.                      
                                                                        
           IF WS-SQLSTATE = '42710'                                     
              PERFORM 8000A-DELETE-GTT-ROWS THRU 8000A-EXIT             
           ELSE                                                         
               IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL               
                   NEXT SENTENCE                                        
               ELSE                                                     
                  MOVE PROGRAM-NAME         TO ABEND-PROGRAM            
                  MOVE SQLCODE              TO ABEND-SQLCODE            
                  MOVE SQLSTATE             TO ABEND-SQLSTATE           
                  MOVE '0100A'               TO ACTIVE-PARAGRAPH        
                  MOVE 'DECLARE GTT'        TO ABEND-FUNCTION           
                  MOVE SPACES               TO ABEND-SQL-PREDICATES     
                                               ABEND-TABLES             
REARCH            MOVE 'CSR02004_R1'        TO TABLE-1                  
                  MOVE SPACES               TO TABLE-ELEMENT-1          
                  MOVE SPACES               TO HOSTVAR-ELEMENT-1        
                  PERFORM 9900-SQL-ERROR-ROUTINE  THRU  9900-EXIT       
               END-IF                                                   
           END-IF.                                                      
CVT000 0100A-EXIT.                                                      
CVT000         EXIT.                                                    
                                                                        
                                                                        
      ******************************************************************00039200
      * 2000-PROCESS-OUTPUT.                                           *00039300
      *      SET UP PARAMETERS TO BE RETURNED.                         *00039400
      *                                                                *00039500
      *      CALLED BY: 0000-MAINLINE                                  *00039600
      ******************************************************************00039700
                                                                        
       2000-PROCESS-OUTPUT.                                             
                                                                        
REARCH*    PERFORM 2100-DESCRIBE-RESULT          THRU 2100-EXIT.        00040100
           PERFORM 2200-BUILD-RESULT             THRU 2200-EXIT.        
                                                                        
       2000-EXIT.                                                       
           EXIT.                                                        
                                                                        
REARCH******************************************************************00040700
REARCH*2000A-MOVE-RESULT.                                               00040800
REARCH******************************************************************00040900
REARCH 2000A-MOVE-RESULT.                                               
REARCH*                                                                 00041100
REARCH     MOVE RS-RETURN-CODE     TO S-RETURN-CODE.                    
REARCH     MOVE RS-FACTOR-ID       TO S-FACTOR-ID.                      
REARCH     MOVE RS-FACTOR-TEXT     TO S-FACTOR-TEXT.                    
REARCH     MOVE RS-FACTOR-DESC     TO S-FACTOR-DESC.                    
REARCH     MOVE RS-FACTOR-STATUS   TO S-FACTOR-STATUS.                  
REARCH     MOVE RS-ELECTRIC-FACTOR TO S-ELECTRIC-FACTOR.                
REARCH     MOVE RS-GAS-FACTOR      TO S-GAS-FACTOR.                     
REARCH     MOVE RS-UNMETER-FACTOR  TO S-UNMETER-FACTOR.                 
REARCH*                                                                 00042300
REARCH 2000A-EXIT.                                                      
REARCH     EXIT.                                                        
      ******************************************************************00042600
      * 2100-DESCRIBE-RESULT                                           *00042700
      *     DESCRIBE RESULT SET.                                       *00042800
      *                                                                *00042900
      *     CALLED BY:  2000-PROCESS-OUTPUT                            *00043000
      ******************************************************************00043100
                                                                        
REARCH*2100-DESCRIBE-RESULT.                                            00043300
REARCH*                                                                 00043400
REARCH*    MOVE '2100'                       TO ACTIVE-PARAGRAPH.       00043500
                                                                        
CVT999*    MOVE 1                            TO CTR-COLUMN.             00043700
CVT999*    MOVE TDSINT4                      TO DB-HOST-TYPE.           00043800
CVT999*    MOVE TDSINT4                      TO DB-CLIENT-TYPE.         00043900
CVT999*    MOVE LENGTH OF RS-RETURN-CODE     TO WRKLEN1.                00044000
CVT999*    MOVE LENGTH OF CNS-RETURN-CODE    TO WRKLEN2.                00044100
                                                                        
CVT999*    CALL 'TDESCRIB' USING GWL-PROC,                              00044300
CVT999*                          GWL-RC,                                00044400
CVT999*                          CTR-COLUMN,                            00044500
CVT999*                          DB-HOST-TYPE,                          00044600
CVT999*                          WRKLEN1,                               00044700
CVT999*                          RS-RETURN-CODE,                        00044800
CVT999*                          DB-NULL-INDICATOR,                     00044900
CVT999*                          TDS-FALSE,                             00045000
CVT999*                          DB-CLIENT-TYPE,                        00045100
CVT999*                          WRKLEN1,                               00045200
CVT999*                          CNS-RETURN-CODE,                       00045300
CVT999*                          WRKLEN2.                               00045400
                                                                        
CVT999*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     00045600
                                                                        
CVT999*    ADD  1                                TO CTR-COLUMN.         00045800
CVT999*    MOVE TDSCHAR                          TO DB-HOST-TYPE.       00045900
CVT999*    MOVE TDSCHAR                          TO DB-CLIENT-TYPE.     00046000
CVT999*    MOVE LENGTH OF RS-FACTOR-ID           TO WRKLEN1.            00046100
CVT999*    MOVE LENGTH OF CNS-FACTOR-ID          TO WRKLEN2.            00046200
                                                                        
CVT999*    CALL 'TDESCRIB' USING GWL-PROC,                              00046400
CVT999*                          GWL-RC,                                00046500
CVT999*                          CTR-COLUMN,                            00046600
CVT999*                          DB-HOST-TYPE,                          00046700
CVT999*                          WRKLEN1,                               00046800
CVT999*                          RS-FACTOR-ID,                          00046900
CVT999*                          DB-NULL-INDICATOR,                     00047000
CVT999*                          TDS-FALSE,                             00047100
CVT999*                          DB-CLIENT-TYPE,                        00047200
CVT999*                          WRKLEN1,                               00047300
CVT999*                          CNS-FACTOR-ID,                         00047400
CVT999*                          WRKLEN2.                               00047500
                                                                        
CVT999*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     00047700
                                                                        
CVT999*    ADD  1                                TO CTR-COLUMN.         00047900
CVT999*    MOVE TDSCHAR                          TO DB-HOST-TYPE.       00048000
CVT999*    MOVE TDSCHAR                          TO DB-CLIENT-TYPE.     00048100
CVT999*    MOVE LENGTH OF RS-FACTOR-TEXT         TO WRKLEN1.            00048200
CVT999*    MOVE LENGTH OF CNS-FACTOR-TEXT        TO WRKLEN2.            00048300
                                                                        
CVT999*    CALL 'TDESCRIB' USING GWL-PROC,                              00048500
CVT999*                          GWL-RC,                                00048600
CVT999*                          CTR-COLUMN,                            00048700
CVT999*                          DB-HOST-TYPE,                          00048800
CVT999*                          WRKLEN1,                               00048900
CVT999*                          RS-FACTOR-TEXT,                        00049000
CVT999*                          DB-NULL-INDICATOR,                     00049100
CVT999*                          TDS-FALSE,                             00049200
CVT999*                          DB-CLIENT-TYPE,                        00049300
CVT999*                          WRKLEN1,                               00049400
CVT999*                          CNS-FACTOR-TEXT,                       00049500
CVT999*                          WRKLEN2.                               00049600
                                                                        
CVT999*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     00049800
                                                                        
CVT999*    ADD  1                                TO CTR-COLUMN.         00050000
CVT999*    MOVE TDSCHAR                          TO DB-HOST-TYPE.       00050100
CVT999*    MOVE TDSCHAR                          TO DB-CLIENT-TYPE.     00050200
CVT999*    MOVE LENGTH OF RS-FACTOR-DESC         TO WRKLEN1.            00050300
CVT999*    MOVE LENGTH OF CNS-FACTOR-DESC        TO WRKLEN2.            00050400
                                                                        
CVT999*    CALL 'TDESCRIB' USING GWL-PROC,                              00050600
CVT999*                          GWL-RC,                                00050700
CVT999*                          CTR-COLUMN,                            00050800
CVT999*                          DB-HOST-TYPE,                          00050900
CVT999*                          WRKLEN1,                               00051000
CVT999*                          RS-FACTOR-DESC,                        00051100
CVT999*                          DB-NULL-INDICATOR,                     00051200
CVT999*                          TDS-FALSE,                             00051300
CVT999*                          DB-CLIENT-TYPE,                        00051400
CVT999*                          WRKLEN1,                               00051500
CVT999*                          CNS-FACTOR-DESC,                       00051600
CVT999*                          WRKLEN2.                               00051700
                                                                        
CVT999*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     00051900
      *                                                                 00052000
CVT999*    ADD  1                                TO CTR-COLUMN.         00052100
CVT999*    MOVE TDSCHAR                          TO DB-HOST-TYPE.       00052200
CVT999*    MOVE TDSCHAR                          TO DB-CLIENT-TYPE.     00052300
CVT999*    MOVE LENGTH OF RS-FACTOR-STATUS       TO WRKLEN1.            00052400
CVT999*    MOVE LENGTH OF CNS-FACTOR-STATUS      TO WRKLEN2.            00052500
                                                                        
CVT999*    CALL 'TDESCRIB' USING GWL-PROC,                              00052700
CVT999*                          GWL-RC,                                00052800
CVT999*                          CTR-COLUMN,                            00052900
CVT999*                          DB-HOST-TYPE,                          00053000
CVT999*                          WRKLEN1,                               00053100
CVT999*                          RS-FACTOR-STATUS,                      00053200
CVT999*                          DB-NULL-INDICATOR,                     00053300
CVT999*                          TDS-FALSE,                             00053400
CVT999*                          DB-CLIENT-TYPE,                        00053500
CVT999*                          WRKLEN1,                               00053600
CVT999*                          CNS-FACTOR-STATUS,                     00053700
CVT999*                          WRKLEN2.                               00053800
                                                                        
CVT999*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     00054000
      *                                                                 00054100
CVT999*    ADD  1                                TO CTR-COLUMN.         00054200
CVT999*    MOVE TDSCHAR                          TO DB-HOST-TYPE.       00054300
CVT999*    MOVE TDSCHAR                          TO DB-CLIENT-TYPE.     00054400
CVT999*    MOVE LENGTH OF RS-ELECTRIC-FACTOR     TO WRKLEN1.            00054500
CVT999*    MOVE LENGTH OF CNS-ELECTRIC-FACTOR    TO WRKLEN2.            00054600
T27237                                                                  
CVT999*    CALL 'TDESCRIB' USING GWL-PROC,                              00054800
CVT999*                          GWL-RC,                                00054900
CVT999*                          CTR-COLUMN,                            00055000
CVT999*                          DB-HOST-TYPE,                          00055100
CVT999*                          WRKLEN1,                               00055200
CVT999*                          RS-ELECTRIC-FACTOR,                    00055300
CVT999*                          DB-NULL-INDICATOR,                     00055400
CVT999*                          TDS-FALSE,                             00055500
CVT999*                          DB-CLIENT-TYPE,                        00055600
CVT999*                          WRKLEN1,                               00055700
CVT999*                          CNS-ELECTRIC-FACTOR,                   00055800
CVT999*                          WRKLEN2.                               00055900
T27237                                                                  
CVT999*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     00056100
      *                                                                 00056200
CVT999*    ADD  1                                TO CTR-COLUMN.         00056300
CVT999*    MOVE TDSCHAR                          TO DB-HOST-TYPE.       00056400
CVT999*    MOVE TDSCHAR                          TO DB-CLIENT-TYPE.     00056500
CVT999*    MOVE LENGTH OF RS-GAS-FACTOR          TO WRKLEN1.            00056600
CVT999*    MOVE LENGTH OF CNS-GAS-FACTOR         TO WRKLEN2.            00056700
T27237                                                                  
CVT999*    CALL 'TDESCRIB' USING GWL-PROC,                              00056900
CVT999*                          GWL-RC,                                00057000
CVT999*                          CTR-COLUMN,                            00057100
CVT999*                          DB-HOST-TYPE,                          00057200
CVT999*                          WRKLEN1,                               00057300
CVT999*                          RS-GAS-FACTOR,                         00057400
CVT999*                          DB-NULL-INDICATOR,                     00057500
CVT999*                          TDS-FALSE,                             00057600
CVT999*                          DB-CLIENT-TYPE,                        00057700
CVT999*                          WRKLEN1,                               00057800
CVT999*                          CNS-GAS-FACTOR,                        00057900
CVT999*                          WRKLEN2.                               00058000
T27237                                                                  
CVT999*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     00058200
      *                                                                 00058300
CVT999*    ADD  1                                TO CTR-COLUMN.         00058400
CVT999*    MOVE TDSCHAR                          TO DB-HOST-TYPE.       00058500
CVT999*    MOVE TDSCHAR                          TO DB-CLIENT-TYPE.     00058600
CVT999*    MOVE LENGTH OF RS-WATER-FACTOR        TO WRKLEN1.            00058700
CVT999*    MOVE LENGTH OF CNS-WATER-FACTOR       TO WRKLEN2.            00058800
T27237                                                                  
CVT999*    CALL 'TDESCRIB' USING GWL-PROC,                              00059000
CVT999*                          GWL-RC,                                00059100
CVT999*                          CTR-COLUMN,                            00059200
CVT999*                          DB-HOST-TYPE,                          00059300
CVT999*                          WRKLEN1,                               00059400
CVT999*                          RS-WATER-FACTOR,                       00059500
CVT999*                          DB-NULL-INDICATOR,                     00059600
CVT999*                          TDS-FALSE,                             00059700
CVT999*                          DB-CLIENT-TYPE,                        00059800
CVT999*                          WRKLEN1,                               00059900
CVT999*                          CNS-WATER-FACTOR,                      00060000
CVT999*                          WRKLEN2.                               00060100
T27237                                                                  
CVT999*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     00060300
      *                                                                 00060400
CVT999*    ADD  1                                TO CTR-COLUMN.         00060500
CVT999*    MOVE TDSCHAR                          TO DB-HOST-TYPE.       00060600
CVT999*    MOVE TDSCHAR                          TO DB-CLIENT-TYPE.     00060700
CVT999*    MOVE LENGTH OF RS-UNMETER-FACTOR      TO WRKLEN1.            00060800
CVT999*    MOVE LENGTH OF CNS-UNMETER-FACTOR     TO WRKLEN2.            00060900
T27237                                                                  
CVT999*    CALL 'TDESCRIB' USING GWL-PROC,                              00061100
CVT999*                          GWL-RC,                                00061200
CVT999*                          CTR-COLUMN,                            00061300
CVT999*                          DB-HOST-TYPE,                          00061400
CVT999*                          WRKLEN1,                               00061500
CVT999*                          RS-UNMETER-FACTOR,                     00061600
CVT999*                          DB-NULL-INDICATOR,                     00061700
CVT999*                          TDS-FALSE,                             00061800
CVT999*                          DB-CLIENT-TYPE,                        00061900
CVT999*                          WRKLEN1,                               00062000
CVT999*                          CNS-UNMETER-FACTOR,                    00062100
CVT999*                          WRKLEN2.                               00062200
T27237                                                                  
CVT999*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     00062400
      *                                                                 00062500
CVT999*    ADD  1                                TO CTR-COLUMN.         00062600
CVT999*    MOVE TDSCHAR                          TO DB-HOST-TYPE.       00062700
CVT999*    MOVE TDSCHAR                          TO DB-CLIENT-TYPE.     00062800
CVT999*    MOVE LENGTH OF RS-SEWER-FACTOR        TO WRKLEN1.            00062900
CVT999*    MOVE LENGTH OF CNS-SEWER-FACTOR       TO WRKLEN2.            00063000
T27237                                                                  
CVT999*    CALL 'TDESCRIB' USING GWL-PROC,                              00063200
CVT999*                          GWL-RC,                                00063300
CVT999*                          CTR-COLUMN,                            00063400
CVT999*                          DB-HOST-TYPE,                          00063500
CVT999*                          WRKLEN1,                               00063600
CVT999*                          RS-SEWER-FACTOR,                       00063700
CVT999*                          DB-NULL-INDICATOR,                     00063800
CVT999*                          TDS-FALSE,                             00063900
CVT999*                          DB-CLIENT-TYPE,                        00064000
CVT999*                          WRKLEN1,                               00064100
CVT999*                          CNS-SEWER-FACTOR,                      00064200
CVT999*                          WRKLEN2.                               00064300
T27237                                                                  
CVT999*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     00064500
      *                                                                 00064600
CVT999*    ADD  1                                TO CTR-COLUMN.         00064700
CVT999*    MOVE TDSCHAR                          TO DB-HOST-TYPE.       00064800
CVT999*    MOVE TDSCHAR                          TO DB-CLIENT-TYPE.     00064900
CVT999*    MOVE LENGTH OF RS-TRASH-FACTOR        TO WRKLEN1.            00065000
CVT999*    MOVE LENGTH OF CNS-TRASH-FACTOR       TO WRKLEN2.            00065100
T27237                                                                  
CVT999*    CALL 'TDESCRIB' USING GWL-PROC,                              00065300
CVT999*                          GWL-RC,                                00065400
CVT999*                          CTR-COLUMN,                            00065500
CVT999*                          DB-HOST-TYPE,                          00065600
CVT999*                          WRKLEN1,                               00065700
CVT999*                          RS-TRASH-FACTOR,                       00065800
CVT999*                          DB-NULL-INDICATOR,                     00065900
CVT999*                          TDS-FALSE,                             00066000
CVT999*                          DB-CLIENT-TYPE,                        00066100
CVT999*                          WRKLEN1,                               00066200
CVT999*                          CNS-TRASH-FACTOR,                      00066300
CVT999*                          WRKLEN2.                               00066400
T27237                                                                  
CVT999*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     00066600
      *                                                                 00066700
REARCH*2100-EXIT.                                                       00066800
REARCH*    EXIT.                                                        00066900
                                                                        
      ******************************************************************00067100
      * 2200-BUILD-RESULT                                              *00067200
      *     BUILD RESULT SET.                                          *00067300
      *                                                                *00067400
      *     CALLED BY:  2000-PROCESS-OUTPUT                            *00067500
      ******************************************************************00067600
                                                                        
       2200-BUILD-RESULT.                                               
                                                                        
           PERFORM 7700-OPEN-FCTR-ID-CURSOR       THRU 7700-EXIT.       
                                                                        
           PERFORM 2210-PROCESS-FETCH             THRU 2210-EXIT        
              UNTIL WS-ACTIVE-RETURN-CODE = NOT-FOUND.                  
                                                                        
           PERFORM 7800-CLOSE-FCTR-ID-CURSOR      THRU 7800-EXIT.       
                                                                        
       2200-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************00069000
      * 2210-PROCESS-FETCH                                             *00069100
      *     READ CSS_SPCL_FCTR ROW, FORMAT RETURN VARIABLES,           *00069200
      *     SEND RESULT.                                               *00069300
      *                                                                *00069400
      *     CALLED BY:  2200-BUILD-RESULT                              *00069500
      ******************************************************************00069600
       2210-PROCESS-FETCH.                                              
                                                                        
           PERFORM 7000-FETCH-FACTOR-ID     THRU 7000-EXIT.             
                                                                        
           IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL                   
              MOVE WS-ACTIVE-RETURN-CODE    TO RS-RETURN-CODE           
              MOVE SF-FACTOR-ID             TO RS-FACTOR-ID             
              MOVE SF-FACTOR-TEXT           TO RS-FACTOR-TEXT           
              MOVE SF-FACTOR-DESC           TO RS-FACTOR-DESC           
              MOVE SF-CODE-STATUS           TO RS-FACTOR-STATUS         
T27237        MOVE SF-RATE-ELEC-FCTR        TO RS-ELECTRIC-FACTOR       
T27237        MOVE SF-RATE-GAS-FCTR         TO RS-GAS-FACTOR            
T27237        MOVE SF-RATE-UNMTRD-FCTR      TO RS-UNMETER-FACTOR        
REARCH        PERFORM 2000A-MOVE-RESULT     THRU 2000A-EXIT             
              PERFORM 8100-SEND-RESULT      THRU 8100-EXIT              
           END-IF.                                                      
                                                                        
       2210-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************00072000
      * 7000-FETCH-FACTOR-ID                                           *00072100
      *     FETCHES CSS_SPCL_FCTR TABLE ROW.                           *00072200
      *                                                                *00072300
      *     CALLED BY:  2200-BUILD-RESULT                              *00072400
      ******************************************************************00072500
       7000-FETCH-FACTOR-ID.                                            
                                                                        
           MOVE '7000'               TO ACTIVE-PARAGRAPH.               
                                                                        
           EXEC SQL                                                     
              FETCH FCTR-ID-CURSOR                                      
              INTO  :SF-FACTOR-ID                                       
                   ,:SF-FACTOR-TEXT                                     
                   ,:SF-FACTOR-DESC                                     
                   ,:SF-CODE-STATUS                                     
T27237             ,:SF-RATE-ELEC-FCTR                                  
T27237             ,:SF-RATE-GAS-FCTR                                   
T27237             ,:SF-RATE-UNMTRD-FCTR                                
           END-EXEC.                                                    

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 OR NOT-FOUND      
              NEXT SENTENCE                                             
           ELSE                                                         
              MOVE PROGRAM-NAME               TO ABEND-PROGRAM          
CBSI          MOVE 'FETCH'                    TO ABEND-FUNCTION         
CBSI          MOVE SPACES                     TO ABEND-SQL-PREDICATES   
CBSI                                             ABEND-TABLES           
              MOVE 'CSS_SPCL_FCTR'            TO TABLE-1                
              MOVE 'FACTOR_TEXT'              TO TABLE-ELEMENT-1        
CBSI          MOVE WS-A                       TO HOSTVAR-ELEMENT-1      
              PERFORM 9000-SEND-ERROR-RESULT  THRU 9000-EXIT            
              PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT            
           END-IF.                                                      
                                                                        
       7000-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************00076300
      * 7700-OPEN-FCTR-ID-CURSOR.                                      *00076400
      *     OPEN CURSOR.                                               *00076500
      *                                                                *00076600
      *     CALLED BY:  2200-BUILD-RESULT                              *00076700
      ******************************************************************00076800
       7700-OPEN-FCTR-ID-CURSOR.                                        
                                                                        
           MOVE '7700'                     TO ACTIVE-PARAGRAPH.         
                                                                        
           EXEC SQL                                                     
              OPEN FCTR-ID-CURSOR                                       
           END-EXEC.                                                    

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 PROGRAM-NAME               TO ABEND-PROGRAM          
CBSI          MOVE 'OPEN'                     TO ABEND-FUNCTION         
CBSI          MOVE SPACES                     TO ABEND-SQL-PREDICATES   
CBSI                                             ABEND-TABLES           
              MOVE 'CSS_SPCL_FCTR'            TO TABLE-1                
              MOVE 'FACTOR_TEXT'              TO TABLE-ELEMENT-1        
CBSI          MOVE WS-A                       TO HOSTVAR-ELEMENT-1      
              PERFORM 9000-SEND-ERROR-RESULT  THRU 9000-EXIT            
              PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT            
           END-IF.                                                      
                                                                        
       7700-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************00079600
      * 7800-CLOSE-FCTR-ID-CURSOR                                      *00079700
      *     CLOSE CURSOR.                                              *00079800
      *                                                                *00079900
      *     CALLED BY:  2200-BUILD-RESULT                              *00080000
      ******************************************************************00080100
       7800-CLOSE-FCTR-ID-CURSOR.                                       
                                                                        
           MOVE '7800'                     TO ACTIVE-PARAGRAPH.         
                                                                        
           EXEC SQL                                                     
              CLOSE  FCTR-ID-CURSOR                                     
           END-EXEC.                                                    

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 PROGRAM-NAME               TO ABEND-PROGRAM          
CBSI          MOVE 'CLOSE'                    TO ABEND-FUNCTION         
CBSI          MOVE SPACES                     TO ABEND-SQL-PREDICATES   
CBSI                                             ABEND-TABLES           
              MOVE 'CSS_SPCL_FCTR'            TO TABLE-1                
              MOVE 'FACTOR_TEXT'              TO TABLE-ELEMENT-1        
CBSI          MOVE WS-A                       TO HOSTVAR-ELEMENT-1      
              PERFORM 9000-SEND-ERROR-RESULT  THRU 9000-EXIT            
              PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT            
           END-IF.                                                      
                                                                        
       7800-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************00082900
      * 9900- JOURNALING / ERROR HANDLING INCLUDE *                     00083000
      ******************************************************************00083100
           EXEC SQL                                                     00083200
              INCLUDE CPDSP300                                          00083300
           END-EXEC.                                                    00083400
                                                                        
      ******************************************************************00083600
      *       END PROGRAM COPYLIB                                      *00083700
      ******************************************************************00083800
                                                                        
CVT000 8100-SEND-RESULT.                                                
CVT000     EXEC SQL                                                     
CVT000       INSERT INTO #CSR02004_R1                            
CVT000       (                                                          
CVT000        RETURN_CODE                                               
CVT000       ,FACTOR_ID                                                 
CVT000       ,FACTOR_TEXT                                               
CVT000       ,FACTOR_DESC                                               
CVT000       ,FACTOR_STATUS                                             
CVT000       ,ELECTRIC_FACTOR                                           
CVT000       ,GAS_FACTOR                                                
CVT000       ,UNMETER_FACTOR                                            
CVT000       )                                                          
CVT000       VALUES                                                     
CVT000       (                                                          
REARCH        :S-RETURN-CODE                                            
REARCH       ,:S-FACTOR-ID                                              
REARCH       ,:S-FACTOR-TEXT                                            
REARCH       ,:S-FACTOR-DESC                                            
REARCH       ,:S-FACTOR-STATUS                                          
REARCH       ,:S-ELECTRIC-FACTOR                                        
REARCH       ,:S-GAS-FACTOR                                             
REARCH       ,:S-UNMETER-FACTOR                                         
CVT000       )                                                          
CVT000     END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ049
MFA-TR*    EXEC SQL                                                     00084200
MFA-TR*      INSERT INTO SESSION.CSR02004_R1                            00084300
MFA-TR*      (                                                          00084400
MFA-TR*       RETURN_CODE                                               00084500
MFA-TR*      ,FACTOR_ID                                                 00084600
MFA-TR*      ,FACTOR_TEXT                                               00084700
MFA-TR*      ,FACTOR_DESC                                               00084800
MFA-TR*      ,FACTOR_STATUS                                             00084900
MFA-TR*      ,ELECTRIC_FACTOR                                           00085000
MFA-TR*      ,GAS_FACTOR                                                00085100
MFA-TR*      ,UNMETER_FACTOR                                            00085300
MFA-TR*      )                                                          00085600
MFA-TR*      VALUES                                                     00085700
MFA-TR*      (                                                          00085800
MFA-TR*       :S-RETURN-CODE                                            00085900
MFA-TR*      ,:S-FACTOR-ID                                              00086000
MFA-TR*      ,:S-FACTOR-TEXT                                            00086100
MFA-TR*      ,:S-FACTOR-DESC                                            00086200
MFA-TR*      ,:S-FACTOR-STATUS                                          00086300
MFA-TR*      ,:S-ELECTRIC-FACTOR                                        00086400
MFA-TR*      ,:S-GAS-FACTOR                                             00086500
MFA-TR*      ,:S-UNMETER-FACTOR                                         00086700
MFA-TR*      )                                                          00087000
MFA-TR*    END-EXEC.                                                    00087100

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

CVT000     MOVE SQLCODE                 TO WS-ACTIVE-RETURN-CODE.       
CVT000                                                                  
CVT000     IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL                   
CVT000        NEXT SENTENCE                                             
CVT000     ELSE                                                         
CVT000        MOVE PROGRAM-NAME         TO ABEND-PROGRAM                
CVT000         MOVE SQLCODE              TO ABEND-SQLCODE               
CVT000         MOVE SQLSTATE             TO ABEND-SQLSTATE              
REARCH        MOVE '8100'               TO ACTIVE-PARAGRAPH             
CVT000        MOVE 'INSERT'             TO ABEND-FUNCTION               
REARCH        MOVE 'CSR02004_R1'        TO TABLE-1                      
CVT000        PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT            
CVT000     END-IF.                                                      
CVT000                                                                  
CVT000     ADD 1 TO CTR-ROWS.                                           
CVT000*    INITIALIZE GTT-RETURN-FIELDS.                                00088700
CVT000*                                                                 00088800
CVT000 8100-EXIT.                                                       
CVT000      EXIT.                                                       
CVT000******************************************************************00089100
CVT000* 8000A-DELETE-GTT-ROWS.                                         *00089200
CVT000******************************************************************00089300
CVT000 8000A-DELETE-GTT-ROWS.                                           
CVT000*                                                                 00089500
CVT000     MOVE                                                         
CVT000     'DELETE ROWS'                                                
CVT000         TO S-SQL-STATEMENT-V.                                    
CVT000*                                                                 00089900
CVT000      EXEC SQL                                                    
CVT000          DELETE FROM #CSR02004_R1                         
CVT000      END-EXEC.                                                   

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ049
MFA-TR*     EXEC SQL                                                    00090000
MFA-TR*         DELETE FROM SESSION.CSR02004_R1                         00090100
MFA-TR*     END-EXEC.                                                   00090200

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

CVT000*                                                                 00090300
CVT000      MOVE SQLCODE TO WS-ACTIVE-RETURN-CODE.                      
CVT000*                                                                 00090500
CVT000      IF WS-ACTIVE-RETURN-CODE = SUCCESSFUL-CALL OR NOT-FOUND     
CVT000          NEXT SENTENCE                                           
CVT000      ELSE                                                        
CVT000         MOVE PROGRAM-NAME         TO ABEND-PROGRAM               
CVT000         MOVE SQLCODE              TO ABEND-SQLCODE               
CVT000         MOVE SQLSTATE             TO ABEND-SQLSTATE              
CVT000         MOVE '8000A'              TO ACTIVE-PARAGRAPH            
CVT000         MOVE 'DELETE'             TO ABEND-FUNCTION              
CVT000         MOVE SPACES               TO ABEND-SQL-PREDICATES        
CVT000                                      ABEND-TABLES                
CVT000         MOVE 'CSR02004_R1'        TO TABLE-1                     
CVT000         MOVE SPACES               TO TABLE-ELEMENT-1             
CVT000         MOVE SPACES               TO HOSTVAR-ELEMENT-1           
CVT000         PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT           
CVT000     END-IF.                                                      
CVT000*                                                                 00092100
CVT000 8000A-EXIT.                                                      
CVT000     EXIT.                                                        
CVT000*                                                                 00092400
CVT000     EXEC SQL                                                     00092500
CVT000         INCLUDE CPD00320                                         00092600
CVT000     END-EXEC.                                                    00092700
