       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID.    CSR02547.                                         
COB303 DATE-WRITTEN.      APRIL 12, 2004.                               
       DATE-COMPILED.                                                   
                                                                        
CVT000******************************************************************00000100
CVT000*     - - - - - >   R P C   C O N V E R S I O N   < - - - - -    *00000200
CVT000*         S547 CONVERTED TO DB2 SP CSR02547 ON 06/15/2006        *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:        S547                                           *00120000
      *  PROGRAM:       S547                                           *00130000
      *  CALLING SP:    S547                                           *00140000
      *                                                                *00150000
      ******************************************************************00160000
      *                                                                *00170000
      *                 P R O G R A M  S U M M A R Y                   *00180000
      *                                                                *00190000
      *  THIS PROGRAM UPDATES CSS_SEB_MIA_XREF.                        *00200000
      *                                                                *00220000
      ******************************************************************00230000
      *                                                                *00240000
      *                     PROGRAM MODIFICATION LOG                   *00250000
      *                                                                *00260000
      *    DATE    INITIALS   COMMENTS                                 *00270000
      *  --------  --------   ---------------------------------------  *00280000
C29943*  04/12/04    FMB      RPC ORIGINALLY ADDED.                    *00290000
C31918*  12/15/04    RR       VERIFY AND CORRECT ACTION CODE IF NEC... *00290000
A04652*  08/06/13    DB18339  CHANGED 'TRACKING ID' TO 'CUST/AGL ACCTNO'00290000
      ******************************************************************00560000
                                                                        
       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 'CSR02547'.
MSQ017     COPY MFASQLM.
                                                                        
       01  WS-START                                   PIC X(40) VALUE   
           'WORKING STORAGE FOR RPC S547 STARTS HERE'.                  
                                                                        
      ******************************************************************00650000
      *    DB2 INCLUDES                                                *00660000
      ******************************************************************00670000
                                                                        
           EXEC SQL                                                     00690000
              INCLUDE SQLCA                                             00700000
           END-EXEC.                                                    00710000
                                                                        
           EXEC SQL                                                     00690000
              INCLUDE TBMODEL                                           00700000
           END-EXEC.                                                    00710000
                                                                        
           EXEC SQL                                                     00970000
              INCLUDE TBMIAXRF                                          00980000
           END-EXEC.                                                    00990000
                                                                        
           EXEC SQL                                                     00970000
              INCLUDE TBUSRPRF                                          00980000
           END-EXEC.                                                    00990000
                                                                        
           EXEC SQL                                                     00970000
              INCLUDE TBMNHIST                                          00980000
           END-EXEC.                                                    00990000
                                                                        
           EXEC SQL                                                     00970000
              INCLUDE TBMNHDT                                           00980000
           END-EXEC.                                                    00990000
                                                                        
CVT999*    COPY SYGWCOB.                                                01500000
CVT999*    COPY SYDBCOB.                                                01510000
           COPY CWS00303.                                               01520000
           COPY CCA00001.                                               01550000
           COPY CWS00027.                                               01560000
CVT999*    COPY CWS00010.                                               01570000
                                                                        
           EXEC SQL                                                     01590000
              INCLUDE CWS00013                                          01600000
           END-EXEC.                                                    01610000
                                                                        
       01  GW-LIB-MISC-FIELDS.                                          
CVT999*    05  GWL-PROC                POINTER.                         01840000
CVT999*    05  GWL-INIT-HANDLE         POINTER.                         01850000
CVT999*    05  GWL-RC                  PIC S9(9) COMP.                  01860000
CVT999*    05  GWL-STATUS-NR           PIC S9(9) COMP.                  01870000
CVT999*    05  GWL-STATUS-DONE         PIC S9(9) COMP.                  01880000
CVT999*    05  GWL-STATUS-COUNT        PIC S9(9) COMP.                  01890000
CVT999*    05  GWL-STATUS-COMM         PIC S9(9) COMP.                  01900000
CVT999*    05  GWL-STATUS-RETURN-CODE  PIC S9(9) COMP.                  01910000
           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.         01980000
           05  PARM-ACTION-CD           PIC X(01) VALUE SPACES.         
           05  PARM-ACCOUNT-NO          PIC X(13) VALUE SPACES.         
           05  PARM-CUSTOMER-NO         PIC X(10) VALUE SPACES.         
           05  PARM-AGL-TRACKING-ID     PIC X(30) VALUE SPACES.         
           05  PARM-USERID              PIC X(07) VALUE SPACES.         
                                                                        
       01  SNA-FIELDS.                                                  
           05  SNA-SUBC                PIC S9(9) COMP.                  
CVT999*    05  SNA-CONNECTION-NAME     PIC X(08) VALUE SPACES.          02470000
                                                                        
       01  COUNTER-FIELDS.                                              
CVT999*    05  CTR-COLUMN              PIC S9(9) COMP VALUE 1.          02500000
           05  CTR-ROWS                PIC S9(9) COMP VALUE 0.          
                                                                        
       01  WORK-FIELDS.                                                 
CVT999*    05  MAX-LENGTH-PARM         PIC S9(9) COMP.                  02540000
CVT999*    05  WRKLEN1                 PIC S9(9) COMP.                  02550000
CVT999*    05  WRKLEN2                 PIC S9(9) COMP.                  02560000
           05  WRK-DONE-STATUS         PIC S9(9) COMP.                  
                                                                        
       01  FILLER  PIC X(32) VALUE 'THIS IS THE ROW RETURN AREA.'.      
                                                                        
       01  GTT-RETURN-FIELDS.                                           
           05  RS-RETURN-CODE               PIC S9(09) COMP VALUE +0.   
                                                                        
CVT999*01  CN-COLUMN-NAMES.                                             02660000
CVT999*    05  CN-RETURN-CODE          PIC X(11) VALUE 'RETURN_CODE'.   02670000
CVT999*                                                                 02710000
       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'.             
                                                                        
       01  WS-MISC.                                                     
           05  WS-TRANS-APPL-NO         PIC S9(04) COMP VALUE 0.        
           05  WS-ACCOUNT-NO-RED        PIC X(13).                      
           05  WS-ACCOUNT-NO            REDEFINES WS-ACCOUNT-NO-RED     
                                        PIC 9(13).                      
           05  WS-CUSTOMER-NO-RED       PIC X(10).                      
           05  WS-CUSTOMER-NO           REDEFINES WS-CUSTOMER-NO-RED    
                                        PIC 9(10).                      
           05  PROGRAM-NAME             PIC X(08) VALUE 'S547    '.     
           05  WS-CURRENT-TS            PIC X(26).                      
           05  WS-AGL-TRACKING-ID       PIC X(30).                      
                                                                        
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  S-RETURN-CODE             PIC S9(9) COMP VALUE 0.        
CVT000     10  WS-SQLSTATE               PIC X(05) VALUE SPACES.        
CVT000                                                                  
CVT000                                                                  
CVT000                                                                  
CVT000 LINKAGE SECTION.                                                 
CVT000 01  LINK-ACTION-CD           PIC X(01)                .          
CVT000 01  LINK-ACCOUNT-NO          PIC X(13)                .          
CVT000 01  LINK-CUSTOMER-NO         PIC X(10)                .          
CVT000 01  LINK-AGL-TRACKING-ID     PIC X(30)                .          
CVT000 01  LINK-USERID              PIC X(07)                .          
                                                                        
CVT000 PROCEDURE DIVISION USING                                         
CVT000          LINK-ACTION-CD                                          
CVT000         ,LINK-ACCOUNT-NO                                         
CVT000         ,LINK-CUSTOMER-NO                                        
CVT000         ,LINK-AGL-TRACKING-ID                                    
CVT000         ,LINK-USERID                                             
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.                                              04620000
                                                                        
      ******************************************************************04640000
      * 0000-MAINLINE                                                  *04650000
      *     CONTROLS THE MAIN PATH OF THE PROGRAM                      *04660000
      ******************************************************************04670000
                                                                        
       0000-MAINLINE.                                                   
                                                                        
           PERFORM 0100-INITIALIZE     THRU 0100-EXIT.                  
           PERFORM 1000-PROCESS-INPUT  THRU 1000-EXIT.                  
           PERFORM 2000-PROCESS-OUTPUT THRU 2000-EXIT.                  
           PERFORM 9999-END-PROGRAM    THRU 9999-EXIT.                  
                                                                        
       0000-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************04790000
      * 0100-INITIALIZE                                                *04800000
      *                                                                *04810000
      *     1. RESET DB2 ERROR HANDLERS                                *04820000
      *     2. ESTABLISH GATEWAY ENVIRONMENT (TDINIT)                  *04830000
      *     3. ACCEPT CLIENT REQUEST/ESTABLISH SNA HANDLE (TDACCEPT)   *04840000
      *     4. DETERMINE IF CLIENT HAS SENT AN RPC PARAMETER (TDRESULT)*04850000
      *                                                                *04860000
      ******************************************************************04870000
                                                                        
       0100-INITIALIZE.                                                 
                                                                        
CVT999*    EXEC SQL WHENEVER SQLWARNING CONTINUE END-EXEC.              04900000
CVT999*    EXEC SQL WHENEVER SQLERROR   CONTINUE END-EXEC.              04910000
CVT999*    EXEC SQL WHENEVER NOT FOUND  CONTINUE END-EXEC.              04920000
                                                                        
CVT999*    CALL 'TDINIT'   USING DFHEIBLK, GWL-RC, GWL-INIT-HANDLE.     04940000
                                                                        
CVT999*    CALL 'TDACCEPT' USING GWL-PROC, GWL-RC, GWL-INIT-HANDLE,     04960000
CVT999*                          SNA-CONNECTION-NAME, SNA-SUBC.         04970000
                                                                        
CVT999*    CALL 'TDRESULT' USING GWL-PROC, GWL-RC.                      04990000
                                                                        
CVT999*    IF GWL-RC NOT = TDS-PARM-PRESENT                             05010000
CVT999*       MOVE PROGRAM-NAME         TO ABEND-PROGRAM                05020000
CVT999*       MOVE '0100'               TO ACTIVE-PARAGRAPH             05030000
CVT999*       MOVE 'CICS TRANSACTION'   TO TABLE-1                      05050000
CVT999*       MOVE 'TDRESULT - NO RPC PARM SENT' TO TABLE-2             05051000
CVT999*       MOVE GWL-RC               TO WS-ACTIVE-RETURN-CODE        05060000
CVT999*       PERFORM 9000-SEND-ERROR-RESULT  THRU 9000-EXIT            05070000
CVT999*       PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT            05080000
CVT999*    END-IF.                                                      05090000
                                                                        
CVT000     EXEC SQL                                                     
CVT000       DECLARE C1 CURSOR  FOR                          
CVT000       SELECT                                                     
CVT000        :RS-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*       :RS-RETURN-CODE              AS    RETURN_CODE                    
MFA-TR*         FROM SYSIBM.SYSDUMMY1                                           
MFA-TR*    END-EXEC.                                                            
CVT000     MOVE LINK-ACTION-CD            TO PARM-ACTION-CD           . 
CVT000     MOVE LINK-ACCOUNT-NO           TO PARM-ACCOUNT-NO          . 
CVT000     MOVE LINK-CUSTOMER-NO          TO PARM-CUSTOMER-NO         . 
CVT000     MOVE LINK-AGL-TRACKING-ID      TO PARM-AGL-TRACKING-ID     . 
CVT000     MOVE LINK-USERID               TO PARM-USERID              . 
       0100-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************05140000
      * 1000-PROCESS-INPUT.                                            *05150000
      *                                                                *05160000
      *     1.  RECEIVE PARMS FROM THE CLIENT.                         *05170000
      *     2.  FORMAT PACKED NUMERICS.                                *05180000
      *                                                                *05190000
      ******************************************************************05200000
                                                                        
       1000-PROCESS-INPUT.                                              
                                                                        
           PERFORM 1100-RECEIVE-PARMS           THRU 1100-EXIT.         
           MOVE PARM-ACCOUNT-NO       TO WS-ACCOUNT-NO-RED.             
           MOVE PARM-CUSTOMER-NO      TO WS-CUSTOMER-NO-RED.            
           IF WS-ACCOUNT-NO-RED NOT NUMERIC                             
               MOVE ZEROES TO WS-ACCOUNT-NO-RED
           END-IF.                        
           IF WS-CUSTOMER-NO-RED NOT NUMERIC                            
               MOVE ZEROES TO WS-CUSTOMER-NO-RED
           END-IF.                       
                                                                        
       1000-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************05300000
      *   1100-RECEIVE-PARMS                                           *05310000
      *                                                                *05320000
      *     1.  RECEIVE PARMS FROM THE CLIENT.                         *05330000
      *                                                                *05340000
      ******************************************************************05350000
                                                                        
       1100-RECEIVE-PARMS.                                              
                                                                        
CVT999*    MOVE 1                              TO PARM-ID1.             05380000
CVT999*    MOVE LENGTH OF PARM-ACTION-CD       TO MAX-LENGTH-PARM,              
CVT999*    CALL 'TDRCVPRM' USING GWL-PROC,                              05800000
CVT999*                          GWL-RC,                                05810000
CVT999*                          PARM-ID1,                              05820000
CVT999*                          PARM-ACTION-CD,                                
CVT999*                          TDSCHAR,                               05840000
CVT999*                          MAX-LENGTH-PARM,                       05850000
CVT999*                          PARM-L.                                05860000
                                                                        
CVT999*    ADD 1                               TO PARM-ID1.             05380000
CVT999*    MOVE LENGTH OF PARM-ACCOUNT-NO      TO MAX-LENGTH-PARM,              
CVT999*    CALL 'TDRCVPRM' USING GWL-PROC,                              05800000
CVT999*                          GWL-RC,                                05810000
CVT999*                          PARM-ID1,                              05820000
CVT999*                          PARM-ACCOUNT-NO,                               
CVT999*                          TDSCHAR,                               05840000
CVT999*                          MAX-LENGTH-PARM,                       05850000
CVT999*                          PARM-L.                                05860000
                                                                        
CVT999*    ADD 1                               TO PARM-ID1.             05380000
CVT999*    MOVE LENGTH OF PARM-CUSTOMER-NO     TO MAX-LENGTH-PARM,              
CVT999*    CALL 'TDRCVPRM' USING GWL-PROC,                              05800000
CVT999*                          GWL-RC,                                05810000
CVT999*                          PARM-ID1,                              05820000
CVT999*                          PARM-CUSTOMER-NO,                              
CVT999*                          TDSCHAR,                               05840000
CVT999*                          MAX-LENGTH-PARM,                       05850000
CVT999*                          PARM-L.                                05860000
                                                                        
CVT999*    ADD 1                               TO PARM-ID1.             05380000
CVT999*    MOVE LENGTH OF PARM-AGL-TRACKING-ID TO MAX-LENGTH-PARM,              
CVT999*    CALL 'TDRCVPRM' USING GWL-PROC,                              05800000
CVT999*                          GWL-RC,                                05810000
CVT999*                          PARM-ID1,                              05820000
CVT999*                          PARM-AGL-TRACKING-ID,                          
CVT999*                          TDSCHAR,                               05840000
CVT999*                          MAX-LENGTH-PARM,                       05850000
CVT999*                          PARM-L.                                05860000
                                                                        
CVT999*    ADD 1                               TO PARM-ID1.             05380000
CVT999*    MOVE LENGTH OF PARM-USERID          TO MAX-LENGTH-PARM,              
CVT999*    CALL 'TDRCVPRM' USING GWL-PROC,                              05800000
CVT999*                          GWL-RC,                                05810000
CVT999*                          PARM-ID1,                              05820000
CVT999*                          PARM-USERID,                                   
CVT999*                          TDSCHAR,                               05840000
CVT999*                          MAX-LENGTH-PARM,                       05850000
CVT999*                          PARM-L.                                05860000
                                                                        
       1100-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************09200000
      *   2000-PROCESS-OUTPUT                                          *09210000
      *                                                                *09220000
      *       1. DESCRIBE RESULT SET                                   *09230000
      *       2. RETRIEVE DB2 DATA                                     *09240000
      *       3. BUILD RESULT SET                                      *09250000
      *       4. SEND RESULT SET                                       *09260000
      *                                                                *09270000
      ******************************************************************09280000
                                                                        
       2000-PROCESS-OUTPUT.                                             
                                                                        
           PERFORM 2100-DESCRIBE-RESULT        THRU 2100-EXIT.          
                                                                        
           PERFORM 5000-BUILD-RESULT       THRU 5000-EXIT.              
                                                                        
           MOVE WS-ACTIVE-RETURN-CODE      TO RS-RETURN-CODE.           
           MOVE '2000'                     TO ACTIVE-PARAGRAPH.         
           PERFORM 8100-SEND-RESULT        THRU 8100-EXIT.              
                                                                        
       2000-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************09420000
      *   2100-DESCRIBE-RESULT                                         *09430000
      *                                                                *09440000
      *       1.  DESCRIBE EACH COLUMN IN THE RESULT SET.              *09450000
      *                                                                *09460000
      ******************************************************************09470000
                                                                        
       2100-DESCRIBE-RESULT.                                            
                                                                        
           MOVE '2100'                   TO ACTIVE-PARAGRAPH.           
                                                                        
CVT999*    MOVE 1                        TO CTR-COLUMN.                 09510000
CVT999*    MOVE TDSINT4                  TO DB-HOST-TYPE.               09520000
CVT999*    MOVE TDSINT4                  TO DB-CLIENT-TYPE.             09530000
CVT999*    MOVE LENGTH OF RS-RETURN-CODE TO WRKLEN1.                            
CVT999*    MOVE LENGTH OF CN-RETURN-CODE TO WRKLEN2.                    09550000
CVT999*    CALL 'TDESCRIB' USING GWL-PROC,                              09560000
CVT999*                          GWL-RC,                                09570000
CVT999*                          CTR-COLUMN,                            09580000
CVT999*                          DB-HOST-TYPE,                          09590000
CVT999*                          WRKLEN1,                               09600000
CVT999*                          RS-RETURN-CODE,                                
CVT999*                          DB-NULL-INDICATOR,                     09620000
CVT999*                          TDS-FALSE,                             09630000
CVT999*                          DB-CLIENT-TYPE,                        09640000
CVT999*                          WRKLEN1,                               09650000
CVT999*                          CN-RETURN-CODE,                        09660000
CVT999*                          WRKLEN2.                               09670000
CVT999*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     09680000
                                                                        
       2100-EXIT.                                                       
           EXIT.                                                        
                                                                        
       5000-BUILD-RESULT.                                               
                                                                        
           EXEC SQL                                                     
              SELECT REPLACE(REPLACE(CONVERT(CHAR(26), 
           CIS.CURRENT$TIMESTAMP(), 121), ' ', '-'), ':', '.')                 
                INTO :WS-CURRENT-TS                                     
                FROM CSS_MODEL_SQL                                      
           END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ028
MFA-TR* MSQ061
MFA-TR*    EXEC SQL                                                             
MFA-TR*       SELECT CURRENT TIMESTAMP                                          
MFA-TR*         INTO :WS-CURRENT-TS                                             
MFA-TR*         FROM CSS_MODEL_SQL                                              
MFA-TR*    END-EXEC.                                                            

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

                                                                        
           PERFORM 5100-FORMAT-MH THRU 5100-EXIT.                       
                                                                        
C31918     MOVE PARM-ACCOUNT-NO                     TO JM-ACCOUNT-NO.   
C31918     PERFORM 7100-CHECK-ACTION-CODE           THRU 7100-EXIT.     
                                                                        
           EVALUATE PARM-ACTION-CD                                      
               WHEN 'I'                                                 
                   PERFORM 5300-INSERT-SEB-MIA-XREF THRU 5300-EXIT      
               WHEN 'U'                                                 
                   PERFORM 5500-UPDATE-SEB-MIA-XREF THRU 5500-EXIT      
               WHEN 'D'                                                 
                   PERFORM 5400-DELETE-SEB-MIA-XREF THRU 5400-EXIT      
               WHEN OTHER                                               
                   MOVE +100 TO WS-ACTIVE-RETURN-CODE                   
           END-EVALUATE.                                                
                                                                        
       5000-EXIT.                                                       
           EXIT.                                                        
                                                                        
       5100-FORMAT-MH.                                                  
                                                                        
           EXEC SQL                                                     
              SELECT CAST(SYSDATETIMEOFFSET() AS DATE)                          
                INTO :MH-DATE-TRANS                                     
                FROM CSS_MODEL_SQL                                      
           END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ028
MFA-TR*    EXEC SQL                                                             
MFA-TR*       SELECT CURRENT DATE                                               
MFA-TR*         INTO :MH-DATE-TRANS                                             
MFA-TR*         FROM CSS_MODEL_SQL                                              
MFA-TR*    END-EXEC.                                                            

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

                                                                        
           MOVE WS-CURRENT-TS            TO MH-TRANS-HIST-SEQ-NO.       
           MOVE 'F'                      TO MH-CODE-TRAN-TYPE.          
           PERFORM 7200-RESP-AREA        THRU 7200-EXIT.                
           MOVE PF-RESP-AREA-ID          TO MH-RESP-AREA-ID.            
           MOVE WS-CUSTOMER-NO           TO MH-CUSTOMER-NO.             
           MOVE WS-ACCOUNT-NO            TO MH-ACCOUNT-NO.              
           MOVE ZEROES                   TO MH-PREMISE-NO.              
           MOVE PARM-USERID              TO MH-USER-ID.                 
           MOVE 'PANEL085'               TO MH-APPL-PROGRAM-ID.         
           MOVE 1                        TO WS-TRANS-APPL-NO.           
                                                                        
       5100-EXIT.                                                       
           EXIT.                                                        
                                                                        
       5300-INSERT-SEB-MIA-XREF.                                        
                                                                        
           MOVE '5300'                 TO ACTIVE-PARAGRAPH.             
           MOVE PARM-ACCOUNT-NO        TO JM-ACCOUNT-NO.                
           MOVE PARM-CUSTOMER-NO       TO JM-CUSTOMER-NO.               
           MOVE PARM-AGL-TRACKING-ID   TO JM-AGL-TRACKING-ID.           
                                                                        
           PERFORM 8200-INSERT-XREF THRU 8200-EXIT.                     
                                                                        
           MOVE MH-TRANS-HIST-SEQ-NO   TO MI-TRANS-HIST-SEQ-NO.         
           MOVE WS-TRANS-APPL-NO       TO MI-TRAN-APPL-NO.              
           MOVE +5                     TO MI-PRV-COLUMN-VALUE-LEN.      
           MOVE +30                    TO MI-CHG-COLUMN-VALUE-LEN.      
           MOVE JM-AGL-TRACKING-ID     TO MI-CHG-COLUMN-VALUE-TEXT.     
           MOVE '*NEW*'                TO MI-PRV-COLUMN-VALUE-TEXT.     
A04652     MOVE 'CUST/AGL ACCTNO'      TO MI-COLUMN-DESC.               
           PERFORM 6530-LOAD-MNT-TRANS-HIST  THRU 6530-EXIT.            
           ADD +1                      TO WS-TRANS-APPL-NO.             
                                                                        
       5300-EXIT.                                                       
           EXIT.                                                        
                                                                        
       5400-DELETE-SEB-MIA-XREF.                                        
                                                                        
           MOVE '5400'                 TO ACTIVE-PARAGRAPH.             
           MOVE PARM-ACCOUNT-NO        TO JM-ACCOUNT-NO.                
           MOVE PARM-CUSTOMER-NO       TO JM-CUSTOMER-NO.               
           MOVE PARM-AGL-TRACKING-ID   TO JM-AGL-TRACKING-ID.           
                                                                        
           PERFORM 8300-DELETE-XREF THRU 8300-EXIT.                     
                                                                        
           MOVE MH-TRANS-HIST-SEQ-NO   TO MI-TRANS-HIST-SEQ-NO.         
           MOVE WS-TRANS-APPL-NO       TO MI-TRAN-APPL-NO.              
           MOVE +8                     TO MI-CHG-COLUMN-VALUE-LEN.      
           MOVE +30                    TO MI-PRV-COLUMN-VALUE-LEN.      
           MOVE JM-AGL-TRACKING-ID     TO MI-PRV-COLUMN-VALUE-TEXT.     
           MOVE '*DELETE*'             TO MI-CHG-COLUMN-VALUE-TEXT.     
A04652     MOVE 'CUST/AGL ACCTNO'      TO MI-COLUMN-DESC.               
           PERFORM 6530-LOAD-MNT-TRANS-HIST  THRU 6530-EXIT.            
           ADD +1                      TO WS-TRANS-APPL-NO.             
                                                                        
       5400-EXIT.                                                       
           EXIT.                                                        
                                                                        
       5500-UPDATE-SEB-MIA-XREF.                                        
                                                                        
           MOVE '5500'                 TO ACTIVE-PARAGRAPH.             
                                                                        
           MOVE PARM-ACCOUNT-NO        TO JM-ACCOUNT-NO.                
           MOVE PARM-CUSTOMER-NO       TO JM-CUSTOMER-NO.               
           MOVE PARM-AGL-TRACKING-ID   TO JM-AGL-TRACKING-ID.           
                                                                        
           PERFORM 7000-GET-TRACKING-ID THRU 7000-EXIT.                 
                                                                        
           PERFORM 8400-UPDATE-XREF THRU 8400-EXIT.                     
                                                                        
           MOVE MH-TRANS-HIST-SEQ-NO   TO MI-TRANS-HIST-SEQ-NO.         
           MOVE WS-TRANS-APPL-NO       TO MI-TRAN-APPL-NO.              
           MOVE +30                    TO MI-CHG-COLUMN-VALUE-LEN.      
           MOVE +30                    TO MI-PRV-COLUMN-VALUE-LEN.      
           MOVE JM-AGL-TRACKING-ID     TO MI-CHG-COLUMN-VALUE-TEXT.     
           MOVE WS-AGL-TRACKING-ID     TO MI-PRV-COLUMN-VALUE-TEXT.     
A04652     MOVE 'CUST/AGL ACCTNO'      TO MI-COLUMN-DESC.               
           PERFORM 6530-LOAD-MNT-TRANS-HIST  THRU 6530-EXIT.            
           ADD +1                      TO WS-TRANS-APPL-NO.             
                                                                        
       5500-EXIT.                                                       
           EXIT.                                                        
                                                                        
       7000-GET-TRACKING-ID.                                            
                                                                        
           EXEC SQL                                                     
              SELECT AGL_TRACKING_ID                                    
                INTO :WS-AGL-TRACKING-ID                                
                FROM CSS_SEB_MIA_XREF                                   
               WHERE ACCOUNT_NO = :JM-ACCOUNT-NO                        
           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               
              MOVE '7000'                TO ACTIVE-PARAGRAPH            
              MOVE 'SELECT'              TO ABEND-FUNCTION              
              MOVE 'CSS_SEB_MIA_XREF'    TO TABLE-1                     
              MOVE 'ACCOUNT_NO'          TO TABLE-ELEMENT-1             
              MOVE WS-ACCOUNT-NO         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.                                                        
                                                                        
       7100-CHECK-ACTION-CODE.                                          
                                                                        
           EXEC SQL                                                     
              SELECT AGL_TRACKING_ID                                    
                INTO :WS-AGL-TRACKING-ID                                
                FROM CSS_SEB_MIA_XREF                                   
               WHERE ACCOUNT_NO = :JM-ACCOUNT-NO                        
           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                   
C31918          IF PARM-ACTION-CD = 'I'                                 
C31918             MOVE 'U' TO PARM-ACTION-CD                           
C31918          END-IF                                                  
C31918     ELSE IF WS-ACTIVE-RETURN-CODE = NOT-FOUND                    
C31918          IF PARM-ACTION-CD = 'U'                                 
C31918             MOVE 'I' TO PARM-ACTION-CD                           
C31918          END-IF                                                  
           ELSE                                                         
              MOVE PROGRAM-NAME          TO ABEND-PROGRAM               
              MOVE '7000'                TO ACTIVE-PARAGRAPH            
              MOVE 'SELECT'              TO ABEND-FUNCTION              
              MOVE 'CSS_SEB_MIA_XREF'    TO TABLE-1                     
              MOVE 'ACCOUNT_NO'          TO TABLE-ELEMENT-1             
              MOVE WS-ACCOUNT-NO         TO HOSTVAR-ELEMENT-1           
              PERFORM 9000-SEND-ERROR-RESULT  THRU 9000-EXIT            
              PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT            
           END-IF
           END-IF.                                                      
                                                                        
       7100-EXIT.                                                       
                                                                        
       7200-RESP-AREA.                                                  
                                                                        
           EXEC SQL                                                     
              SELECT RESP_AREA_ID                                       
                INTO :PF-RESP-AREA-ID                                   
                FROM CSS_USER_PROFILE                                   
               WHERE USER_ID = :PARM-USERID                             
           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               
              MOVE '7200'                TO ACTIVE-PARAGRAPH            
              MOVE 'SELECT'              TO ABEND-FUNCTION              
              MOVE 'CSS_USER_PROFILE'    TO TABLE-1                     
              MOVE 'USER_ID'             TO TABLE-ELEMENT-1             
              MOVE 'ACCOUNT_NO'          TO TABLE-ELEMENT-2             
              MOVE PARM-USERID           TO HOSTVAR-ELEMENT-1           
              MOVE WS-ACCOUNT-NO         TO HOSTVAR-ELEMENT-2           
              PERFORM 9000-SEND-ERROR-RESULT  THRU 9000-EXIT            
              PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT            
           END-IF.                                                      
                                                                        
       7200-EXIT.                                                       
           EXIT.                                                        
                                                                        
       8200-INSERT-XREF.                                                
                                                                        
           EXEC SQL                                                     
              INSERT INTO CSS_SEB_MIA_XREF                              
                   ( AGL_TRACKING_ID,                                   
                     ACCOUNT_NO,                                        
                     CUSTOMER_NO)                                       
              VALUES                                                    
                   (:JM-AGL-TRACKING-ID,                                
                    :JM-ACCOUNT-NO,                                     
                    :JM-CUSTOMER-NO)                                    
           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               
              MOVE '8100'                TO ACTIVE-PARAGRAPH            
              MOVE 'INSERT'              TO ABEND-FUNCTION              
              MOVE 'CSS_SEB_MIA_XREF'    TO TABLE-1                     
              MOVE 'ACCOUNT_NO'          TO TABLE-ELEMENT-1             
              MOVE 'CUSTOMER_NO'         TO TABLE-ELEMENT-2             
              MOVE WS-ACCOUNT-NO         TO HOSTVAR-ELEMENT-1           
              MOVE WS-CUSTOMER-NO        TO HOSTVAR-ELEMENT-2           
              PERFORM 9000-SEND-ERROR-RESULT  THRU 9000-EXIT            
              PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT
           END-IF.           
                                                                        
       8200-EXIT.                                                       
           EXIT.                                                        
                                                                        
       8300-DELETE-XREF.                                                
                                                                        
           EXEC SQL                                                     
              DELETE                                                    
                FROM CSS_SEB_MIA_XREF                                   
               WHERE ACCOUNT_NO      = :JM-ACCOUNT-NO                   
                 AND AGL_TRACKING_ID = :JM-AGL-TRACKING-ID              
           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               
              MOVE '8200'                TO ACTIVE-PARAGRAPH            
              MOVE 'DELETE'              TO ABEND-FUNCTION              
              MOVE 'CSS_SEB_MIA_XREF'    TO TABLE-1                     
              MOVE 'ACCOUNT_NO'          TO TABLE-ELEMENT-1             
              MOVE 'CUSTOMER_NO'         TO TABLE-ELEMENT-2             
              MOVE 'AGL-TRACKING-ID'     TO TABLE-ELEMENT-3             
              MOVE WS-ACCOUNT-NO         TO HOSTVAR-ELEMENT-1           
              MOVE WS-CUSTOMER-NO        TO HOSTVAR-ELEMENT-2           
              MOVE PARM-AGL-TRACKING-ID  TO HOSTVAR-ELEMENT-3           
              PERFORM 9000-SEND-ERROR-RESULT  THRU 9000-EXIT            
              PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT
           END-IF.           
                                                                        
       8300-EXIT.                                                       
           EXIT.                                                        
                                                                        
       8400-UPDATE-XREF.                                                
                                                                        
           EXEC SQL                                                     
              UPDATE CSS_SEB_MIA_XREF                                   
                 SET AGL_TRACKING_ID = :JM-AGL-TRACKING-ID              
               WHERE ACCOUNT_NO      = :JM-ACCOUNT-NO                   
           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               
              MOVE '8500'                TO ACTIVE-PARAGRAPH            
              MOVE 'UPDATE'              TO ABEND-FUNCTION              
              MOVE 'CSS_SEB_MIA_XREF'    TO TABLE-1                     
              MOVE 'ACCOUNT_NO'          TO TABLE-ELEMENT-1             
              MOVE 'AGL-TRACKING-ID'     TO TABLE-ELEMENT-2             
              MOVE WS-ACCOUNT-NO         TO HOSTVAR-ELEMENT-1           
              MOVE PARM-AGL-TRACKING-ID  TO HOSTVAR-ELEMENT-2           
              PERFORM 9000-SEND-ERROR-RESULT  THRU 9000-EXIT            
              PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT
           END-IF.           
                                                                        
       8400-EXIT.                                                       
           EXIT.                                                        
                                                                        
           EXEC SQL                                                     29920000
              INCLUDE CPD00067                                          29930000
           END-EXEC.                                                    29940000
                                                                        
           EXEC SQL                                                     46890000
              INCLUDE CPDSP300                                          46900000
           END-EXEC.                                                    46910000
                                                                        
CVT999*    COPY CPD00302.                                               46960000
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
