       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID.    CSR02318.                                         
COB303 DATE-WRITTEN.                                                    
COB303            JANUARY 27, 1996.                                     
       DATE-COMPILED.                                                   
                                                                        
      ******************************************************************00070000
      *                SOUTH CAROLINA ELECTRIC & GAS                   *00080000
      *                                                                *00090000
      *  THIS PROGRAM IS EXECUTED VIA A REMOTE PROCEDURE CALL (RPC).   *00100000
      *                                                                *00110000
      *  TRANID:        S318                                           *00120000
      *  PROGRAM:       S318                                           *00130000
      *  CALLING SP:    PA_S318                                        *00140000
      *                                                                *00150000
      ******************************************************************00160000
      *                 P R O G R A M  S U M M A R Y                   *00170000
      *                                                                *00180000
      *  THIS PROGRAM IS A REMOTE PROCEDURE CALL MADE FROM             *00190000
      *  DESKTOP 2000 VIA THE SYBASE NETGATEWAY.                       *00200000
      *                                                                *00210000
      *  THIS PROGRAM RETRIEVES SUM OF VOUCHER REIMBURSEMENTS MADE BY  *00220000
      *  AGENCY WITH A PARTICULAR CHECK NO FROM CSS_LIEAP TABLE        *00230000
      ******************************************************************00240000
      *                                                                *00250000
      *                     PROGRAM MODIFICATION LOG                   *00260000
      *                                                                *00270000
      *    DATE    INITIALS   COMMENTS                                 *00280000
      *  --------  --------   ---------------------------------------  *00290000
      *  01/27/96    BB       CREATED.                                 *00300000
      *                                                                *00310000
P189  *  04/11/96    JBW      PCR189. CHANGED CHECK-NO FIELD FROM      *00311000
P189  *                       CHAR(5) TO CHAR(9).                      *00312000
CBSI  *  12/21/98    CBSI     ABEND LOG MODIFIED TO INCLUDE ALL THE    *00312100
CBSI  *              MADRAS   ABEND PARAMETERS                         *00312200
REARCH*  08/30/05    CVNS     RPC TO COBOL SP CONVERSION               *00312300
REARCH*              CHENNAI                                           *00312400
C33780*  03/23/06    LATHA    DO NOT WRITE THE ERROR LOG WHEN SQLCODE  *00313000
C33780*                       EQUAL 100 IN 2200- PARA.                 *00314008
      ******************************************************************00320000
      ******************************************************************00330000
      *                                                                *00340000
      *                ---- BASIC SEQUENCE STRUCTURE ----              *00350000
      *                                                                *00360000
      *  0000 - 0999  MAIN CONTROL PATH AND INITIALIZATION             *00370000
      *  1000 - 1999  INPUT PROCESSING CONTROL PATH                    *00380000
      *  2000 - 2999  OUTPUT PROCESSING CONTROL PATH                   *00390000
      *  3000 - 4999  NOT USED                                         *00400000
      *  5000 - 5999  COMMON PROGRAM MODULES                           *00410000
      *  6000 - 6999  COMMON SYSTEM MODULES                            *00420000
      *  7000 - 7999  INPUT MODULES                                    *00430000
      *  8000 - 8999  OUTPUT MODULES                                   *00440000
      *  9000 - 9999  TERMINATION,ABEND, MESSAGING MODULES             *00450000
      *                                                                *00460000
      ******************************************************************00470000
                                                                        
       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 'CSR02318'.
MSQ017     COPY MFASQLM.
                                                                        
       01  WS-START                                   PIC X(40) VALUE   
REARCH     'WORKING STORAGE FOR CSR02318 STARTS HERE'.                  
                                                                        
                                                                        
      ******************************************************************00570000
      *    DB2 INCLUDES                                                *00580000
      ******************************************************************00590000
                                                                        
           EXEC SQL                                                     00610000
              INCLUDE SQLCA                                             00620000
           END-EXEC.                                                    00630000
                                                                        
           EXEC SQL                                                     00650000
              INCLUDE TBLIEAP                                           00660000
           END-EXEC.                                                    00670000
                                                                        
           EXEC SQL                                                     00690000
              INCLUDE TBMODEL                                           00700000
           END-EXEC.                                                    00710000
                                                                        
           EXEC SQL                                                     00730000
              INCLUDE TBACCT                                            00740000
           END-EXEC.                                                    00750000
                                                                        
                                                                        
      ******************************************************************00780000
      *    COBOL WORKING STORAGE COPY BOOKS                            *00790000
      ******************************************************************00800000
                                                                        
REARCH*    COPY SYGWCOB.                                                00820000
REARCH*    COPY SYDBCOB.                                                00830000
           COPY CCA00001.                                               00840000
REARCH*    COPY CWS00010.                                               00850000
           COPY CWS00027.                                               00860000
           COPY CWS00303.                                               00870000
REARCH*                                                                 00871000
REARCH     EXEC SQL                                                     00872000
REARCH         INCLUDE CWSX0010                                         00873000
REARCH     END-EXEC.                                                    00874000
                                                                        
      ******************************************************************00890000
      *    WORK AREAS                                                  *00900000
      ******************************************************************00910000
                                                                        
REARCH*01  GW-LIB-MISC-FIELDS.                                          00930000
REARCH*    05  GWL-PROC                POINTER.                         00940000
REARCH*    05  GWL-INIT-HANDLE         POINTER.                         00950000
REARCH*    05  GWL-RC                  PIC S9(9) COMP.                  00960000
REARCH*    05  GWL-STATUS-NR           PIC S9(9) COMP.                  00970000
REARCH*    05  GWL-STATUS-DONE         PIC S9(9) COMP.                  00980000
REARCH*    05  GWL-STATUS-COUNT        PIC S9(9) COMP.                  00990000
REARCH*    05  GWL-STATUS-COMM         PIC S9(9) COMP.                  01000000
REARCH*    05  GWL-STATUS-RETURN-CODE  PIC S9(9) COMP.                  01010000
REARCH*    05  GWL-STATUS-SUBCODE      PIC S9(9) COMP.                  01020000
                                                                        
       01  FILLER                      PIC X(11) VALUE 'PARM FIELDS'.   
                                                                        
REARCH*01  PARM-FIELDS.                                                 01060000
REARCH*    05  PARM-L                  PIC S9(9) COMP.                  01070000
REARCH*    05  PARM-ID1                PIC S9(9) COMP VALUE 1.          01080000
REARCH*    05  PARM-CODE-AGENCY-ID     PIC X(05) VALUE SPACES .         01090000
P189  *    05  PARM-CHECK-NO           PIC X(09) VALUE SPACES .         01100000
       01  SNA-FIELDS.                                                  
           05  SNA-SUBC                PIC S9(9) COMP.                  
           05  SNA-CONNECTION-NAME     PIC X(8)  VALUE SPACES.          
                                                                        
       01  COUNTER-FIELDS.                                              
           05  CTR-COLUMN              PIC S9(9) COMP VALUE 1.          
           05  CTR-ROWS                PIC S9(9) COMP VALUE 0.          
           05  WS-ROW-COUNT            PIC S9(9) COMP VALUE 0.          
                                                                        
       01  WORK-FIELDS.                                                 
           05  MAX-LENGTH-PARM         PIC S9(9) COMP.                  
           05  WRKLEN1                 PIC S9(9) COMP.                  
           05  WRKLEN2                 PIC S9(9) COMP.                  
           05  WRK-DONE-STATUS         PIC S9(9) COMP.                  
                                                                        
       01  WS-MISC.                                                     
REARCH     05  PROGRAM-NAME            PIC X(08) VALUE 'CSR02318'.      
           05  WS-CODE-AGENCY-ID       PIC X(05)  VALUE SPACES.         
           05  WS-LIEAP-AGENCY         PIC X(05)  VALUE SPACES.         
                                                                        
       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.'.      
       01  TDS-RETURN-FIELDS.                                           
           05  RS-RETURN-CODE          PIC S9(9) COMP VALUE 0.          
           05  RS-VOUCHER-AMT          PIC S9(9)V99 COMP-3 VALUE 0.     
           05  RS-CODE-AGENCY-ID       PIC X(05) VALUE SPACES .         
P189       05  RS-CHECK-NO             PIC X(09) VALUE SPACES .         
REARCH*                                                                 01440100
REARCH 01  GTT-RETURN-FIELDS.                                           
REARCH     05  S-RETURN-CODE           PIC S9(9) COMP VALUE 0.          
REARCH     05  S-VOUCHER-AMT           PIC S9(9)V99 COMP-3 VALUE 0.     
REARCH     05  S-CODE-AGENCY-ID        PIC X(05) VALUE SPACES .         
REARCH     05  S-CHECK-NO              PIC X(09) VALUE SPACES .         
REARCH*                                                                 01446000
REARCH*01  CNS-COLUMN-NAMES.                                            01450000
REARCH*    05  CNS-RETURN-CODE         PIC X(11) VALUE                  01460000
REARCH*                                        'RETURN_CODE'.           01470000
REARCH*    05  CNS-VOUCHER-AMT         PIC X(11) VALUE                  01480000
REARCH*                                   'VOUCHER_AMT'.                01490000
REARCH*    05  CNS-CODE-AGENCY-ID      PIC X(14) VALUE                  01500000
REARCH*                                   'CODE_AGENCY_ID' .            01510000
REARCH*    05  CNS-CHECK-NO            PIC X(08) VALUE                  01520000
REARCH*                                   'CHECK-NO' .                  01530000
                                                                        
       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'.             
                                                                        
REARCH 01  CSRERLOG-P.                                                  
REARCH     10  S-SP-NAME               PIC X(18)      VALUE SPACES.     
REARCH     10  S-SQLCODE               PIC S9(9) COMP VALUE 0.          
REARCH     10  S-SQLSTATE              PIC X(5)       VALUE ' '.        
REARCH     10  S-TABLE-NAME            PIC X(18)      VALUE SPACES.     
REARCH     10  S-HOST-VARIABLES.                                        
REARCH         49  S-HOST-VARIABLES-L  PIC S9(4) USAGE COMP.            
REARCH         49  S-HOST-VARIABLES-V  PIC X(255).                      
REARCH     10  S-SQL-STATEMENT.                                         
REARCH         49  S-SQL-STATEMENT-L   PIC S9(4) USAGE COMP.            
REARCH         49  S-SQL-STATEMENT-V   PIC X(255).                      
REARCH     10  S-SQL-DESCRIPTION.                                       
REARCH         49  S-SQL-DESCRIPTION-L PIC S9(4) USAGE COMP.            
REARCH         49  S-SQL-DESCRIPTION-V PIC X(255).                      
REARCH*                                                                 01629600
      ******************************************************************01630000
      *    CURSOR DECLARATIONS                                         *01640000
      ******************************************************************01650000
           EXEC SQL                                                     
              DECLARE LI-CURSOR CURSOR FOR                              
              SELECT VOUCHER_AMT                                        
                FROM CSS_LIEAP                                          
               WHERE CHECK_NO          = :LI-CHECK-NO AND               
                     CODE_AGENCY_ID    = :LI-CODE-AGENCY-ID             
           END-EXEC.                                                    
                                                                        
REARCH LINKAGE SECTION.                                                 
REARCH*                                                                 01740000
REARCH 01  PARM-CODE-AGENCY-ID       PIC X(05).                         
REARCH 01  PARM-CHECK-NO             PIC X(09).                         
                                                                        
HPCCDM*EJECT                                                            01771000
REARCH PROCEDURE DIVISION USING     PARM-CODE-AGENCY-ID                 
REARCH                              PARM-CHECK-NO.                      
REARCH*                                                                 01771300
      ******************************************************************01780000
      * 0000-MAINLINE                                                  *01790000
      *     CONTROLS THE MAIN PATH OF THE PROGRAM                      *01800000
      ******************************************************************01810000
                                                                        
       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.                                                        
                                                                        
      ******************************************************************01930000
      * 0100-INITIALIZE                                                *01940000
      *                                                                *01950000
      *     1. RESET DB2 ERROR HANDLERS                                *01960000
      *     2. ESTABLISH GATEWAY ENVIRONMENT (TDINIT)                  *01970000
      *     3. ACCEPT CLIENT REQUEST/ESTABLISH SNA HANDLE (TDACCEPT)   *01980000
      *     4. DETERMINE IF CLIENT HAS SENT AN RPC PARAMETER (TDRESULT)*01990000
      *                                                                *02000000
      ******************************************************************02010000
                                                                        
       0100-INITIALIZE.                                                 
                                                                        
           EXEC SQL WHENEVER SQLWARNING CONTINUE END-EXEC.              
           EXEC SQL WHENEVER SQLERROR   CONTINUE END-EXEC.              
           EXEC SQL WHENEVER NOT FOUND  CONTINUE END-EXEC.              
REARCH*    CALL 'TDINIT'   USING DFHEIBLK, GWL-RC, GWL-INIT-HANDLE.     02080000
REARCH*                                                                 02090000
REARCH*    CALL 'TDACCEPT' USING GWL-PROC, GWL-RC, GWL-INIT-HANDLE,     02100000
REARCH*                          SNA-CONNECTION-NAME, SNA-SUBC.         02110000
REARCH*                                                                 02120000
REARCH*    CALL 'TDRESULT' USING GWL-PROC, GWL-RC.                      02130000
REARCH*                                                                 02140000
REARCH*    IF GWL-RC NOT = TDS-PARM-PRESENT                             02150000
REARCH*       MOVE PROGRAM-NAME    TO ABEND-PROGRAM                     02160000
REARCH*       MOVE '0100'          TO ACTIVE-PARAGRAPH                  02170000
REARCH*       MOVE 'TDRESULT - NO RPC PARM SENT' TO ABEND-FUNCTION      02180000
REARCH*       MOVE 'CICS TRANSACTION'   TO TABLE-1                      02190000
REARCH*       MOVE GWL-RC               TO WS-ACTIVE-RETURN-CODE        02200000
REARCH*       PERFORM 9000-SEND-ERROR-RESULT  THRU 9000-EXIT            02210000
REARCH*       PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT            02220000
REARCH*    END-IF.                                                      02230000
REARCH     EXEC SQL                                                     
REARCH         DECLARE C1 CURSOR  FOR                        
REARCH         SELECT                                                   
REARCH             :S-RETURN-CODE             AS RETURN_CODE            
REARCH            ,:S-VOUCHER-AMT             AS VOUCHER_AMT            
REARCH            ,LTRIM(RTRIM(:S-CODE-AGENCY-ID))   AS CODE_AGENCY_ID         
REARCH            ,LTRIM(RTRIM(:S-CHECK-NO))         AS CHECK_NO               
REARCH         FROM                                                     
REARCH             CIS.SYSDUMMY1                                     
REARCH     END-EXEC.                                                    

MFA-TR* TRANSFORMATION LIST
MFA-TR* MSQ027
MFA-TR* MSQ029
MFA-TR*    EXEC SQL                                                     02240000
MFA-TR*        DECLARE C1 CURSOR WITH RETURN FOR                        02241000
MFA-TR*        SELECT                                                   02242000
MFA-TR*            :S-RETURN-CODE             AS RETURN_CODE            02247000
MFA-TR*           ,:S-VOUCHER-AMT             AS VOUCHER_AMT            02248000
MFA-TR*           ,STRIP(:S-CODE-AGENCY-ID)   AS CODE_AGENCY_ID         02249000
MFA-TR*           ,STRIP(:S-CHECK-NO)         AS CHECK_NO               02249100
MFA-TR*        FROM                                                     02249200
MFA-TR*            SYSIBM.SYSDUMMY1                                     02249300
MFA-TR*    END-EXEC.                                                    02249400
REARCH*                                                                 02249500
       0100-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************02280000
      * 1000-PROCESS-INPUT                                             *02290000
      *                                                                *02300000
      *     1. RECEIVE PARMS.                                          *02310000
      *                                                                *02320000
      ******************************************************************02330000
                                                                        
       1000-PROCESS-INPUT.                                              
                                                                        
REARCH*    PERFORM 1100-RECEIVE-PARMS     THRU 1100-EXIT.               02370000
           MOVE PARM-CODE-AGENCY-ID       TO LI-CODE-AGENCY-ID .        
           MOVE PARM-CHECK-NO             TO LI-CHECK-NO.               
       1000-EXIT.                                                       
           EXIT.                                                        
                                                                        
REARCH*'1100-RECEIVE-PARMS.                                             02430000
REARCH*'   MOVE 1                          TO PARM-ID1.                 02440000
REARCH*'   MOVE LENGTH OF PARM-CODE-AGENCY-ID TO MAX-LENGTH-PARM.       02450000
REARCH*'                                                                02460000
REARCH*'   CALL 'TDRCVPRM' USING GWL-PROC,                              02470000
REARCH*'                         GWL-RC,                                02480000
REARCH*'                         PARM-ID1,                              02490000
REARCH*'                         PARM-CODE-AGENCY-ID,                   02500000
REARCH*'                         TDSCHAR,                               02510000
REARCH*'                         MAX-LENGTH-PARM,                       02520000
REARCH*'                         PARM-L.                                02530000
REARCH*'                                                                02540000
REARCH*'   ADD 1                          TO PARM-ID1.                  02550000
REARCH*'   MOVE LENGTH OF PARM-CHECK-NO TO MAX-LENGTH-PARM.             02560000
REARCH*'                                                                02570000
REARCH*'   CALL 'TDRCVPRM' USING GWL-PROC,                              02580000
REARCH*'                         GWL-RC,                                02590000
REARCH*'                         PARM-ID1,                              02600000
REARCH*'                         PARM-CHECK-NO,                         02610000
REARCH*'                         TDSCHAR,                               02620000
REARCH*'                         MAX-LENGTH-PARM,                       02630000
REARCH*'                         PARM-L.                                02640000
REARCH*'1100-EXIT.                                                      02650000
REARCH*'   EXIT.                                                        02660000
REARCH*'                                                                02670000
      ******************************************************************02680000
      * 2000-PROCESS-OUTPUT.                                           *02690000
      *                                                                *02700000
      ******************************************************************02710000
       2000-PROCESS-OUTPUT.                                             
           MOVE '2000' TO ACTIVE-PARAGRAPH.                             
                                                                        
REARCH*    PERFORM 2100-DESCRIBE-RESULT  THRU 2100-EXIT.                02750000
           PERFORM 2200-BUILD-RESULT     THRU 2200-EXIT.                
                                                                        
       2000-EXIT.                                                       
           EXIT.                                                        
                                                                        
REARCH******************************************************************02801000
REARCH* 2000A-MOVE-RESULT.                                             *02802000
REARCH******************************************************************02803000
REARCH*                                                                 02804000
REARCH 2000A-MOVE-RESULT.                                               
REARCH*                                                                 02806000
REARCH     MOVE  RS-RETURN-CODE       TO S-RETURN-CODE.                 
REARCH     MOVE  RS-VOUCHER-AMT       TO S-VOUCHER-AMT.                 
REARCH     MOVE  RS-CODE-AGENCY-ID    TO S-CODE-AGENCY-ID.              
REARCH     MOVE  RS-CHECK-NO          TO S-CHECK-NO.                    
REARCH*                                                                 02809600
REARCH 2000A-EXIT.                                                      
REARCH      EXIT.                                                       
REARCH*                                                                 02809900
      ******************************************************************02810000
      * 2100-DESCRIBE-RESULT                                           *02820000
      ******************************************************************02830000
                                                                        
REARCH*2100-DESCRIBE-RESULT.                                            02850000
REARCH*    MOVE '2000' TO ACTIVE-PARAGRAPH.                             02860000
REARCH*                                                                 02870000
REARCH*    MOVE 1       TO CTR-COLUMN.                                  02880000
REARCH*    MOVE TDSINT4 TO DB-HOST-TYPE.                                02890000
REARCH*    MOVE TDSINT4 TO DB-CLIENT-TYPE.                              02900000
REARCH*    MOVE LENGTH OF RS-RETURN-CODE      TO WRKLEN1.               02910000
REARCH*    MOVE LENGTH OF CNS-RETURN-CODE     TO WRKLEN2.               02920000
REARCH*                                                                 02930000
REARCH*    CALL 'TDESCRIB' USING GWL-PROC,                              02940000
REARCH*                          GWL-RC,                                02950000
REARCH*                          CTR-COLUMN,                            02960000
REARCH*                          DB-HOST-TYPE,                          02970000
REARCH*                          WRKLEN1,                               02980000
REARCH*                          RS-RETURN-CODE,                        02990000
REARCH*                          DB-NULL-INDICATOR,                     03000000
REARCH*                          TDS-FALSE,                             03010000
REARCH*                          DB-CLIENT-TYPE,                        03020000
REARCH*                          WRKLEN1,                               03030000
REARCH*                          CNS-RETURN-CODE,                       03040000
REARCH*                          WRKLEN2.                               03050000
REARCH*                                                                 03060000
REARCH*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     03070000
REARCH*                                                                 03080000
REARCH*                                                                 03090000
REARCH*    ADD 1        TO CTR-COLUMN.                                  03100000
REARCH*    MOVE TDSDECIMAL         TO DB-HOST-TYPE.                     03110000
REARCH*    MOVE TDSFLT8            TO DB-CLIENT-TYPE.                   03120000
REARCH*    MOVE LENGTH OF RS-VOUCHER-AMT  TO WRKLEN1.                   03130000
REARCH*    MOVE LENGTH OF CNS-VOUCHER-AMT TO WRKLEN2.                   03140000
REARCH*                                                                 03150000
REARCH*    CALL 'TDESCRIB' USING GWL-PROC,                              03160000
REARCH*                          GWL-RC,                                03170000
REARCH*                          CTR-COLUMN,                            03180000
REARCH*                          DB-HOST-TYPE,                          03190000
REARCH*                          WRKLEN1,                               03200000
REARCH*                          RS-VOUCHER-AMT,                        03210000
REARCH*                          DB-NULL-INDICATOR,                     03220000
REARCH*                          TDS-FALSE,                             03230000
REARCH*                          DB-CLIENT-TYPE,                        03240000
REARCH*                          WRKLEN1,                               03250000
REARCH*                          CNS-VOUCHER-AMT,                       03260000
REARCH*                          WRKLEN2.                               03270000
REARCH*                                                                 03280000
REARCH*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     03290000
REARCH*                                                                 03300000
REARCH*    MOVE +2 TO WRKLEN2.                                          03310000
REARCH*    CALL 'TDSETBCD' USING GWL-PROC,                              03320000
REARCH*                          GWL-RC,                                03330000
REARCH*                          TDS-OBJECT-COL,                        03340000
REARCH*                          CTR-COLUMN,                            03350000
REARCH*                          WRKLEN1,                               03360000
REARCH*                          WRKLEN2.                               03370000
REARCH*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     03380000
REARCH*                                                                 03390000
REARCH*                                                                 03400000
REARCH*                                                                 03410000
REARCH*    ADD  1                  TO CTR-COLUMN.                       03420000
REARCH*    MOVE TDSCHAR            TO DB-HOST-TYPE.                     03430000
REARCH*    MOVE TDSCHAR            TO DB-CLIENT-TYPE.                   03440000
REARCH*    MOVE LENGTH OF RS-CODE-AGENCY-ID   TO WRKLEN1.               03450000
REARCH*    MOVE LENGTH OF CNS-CODE-AGENCY-ID  TO WRKLEN2.               03460000
REARCH*                                                                 03470000
REARCH*    CALL 'TDESCRIB' USING GWL-PROC,                              03480000
REARCH*                          GWL-RC,                                03490000
REARCH*                          CTR-COLUMN,                            03500000
REARCH*                          DB-HOST-TYPE,                          03510000
REARCH*                          WRKLEN1,                               03520000
REARCH*                          RS-CODE-AGENCY-ID ,                    03530000
REARCH*                          DB-NULL-INDICATOR,                     03540000
REARCH*                          TDS-FALSE,                             03550000
REARCH*                          DB-CLIENT-TYPE,                        03560000
REARCH*                          WRKLEN1,                               03570000
REARCH*                          CNS-CODE-AGENCY-ID,                    03580000
REARCH*                          WRKLEN2.                               03590000
REARCH*                                                                 03600000
REARCH*    ADD  1                  TO CTR-COLUMN.                       03610000
REARCH*    MOVE TDSCHAR            TO DB-HOST-TYPE.                     03620000
REARCH*    MOVE TDSCHAR            TO DB-CLIENT-TYPE.                   03630000
REARCH*    MOVE LENGTH OF RS-CHECK-NO         TO WRKLEN1.               03640000
REARCH*    MOVE LENGTH OF CNS-CHECK-NO        TO WRKLEN2.               03650000
REARCH*                                                                 03660000
REARCH*    CALL 'TDESCRIB' USING GWL-PROC,                              03670000
REARCH*                          GWL-RC,                                03680000
REARCH*                          CTR-COLUMN,                            03690000
REARCH*                          DB-HOST-TYPE,                          03700000
REARCH*                          WRKLEN1,                               03710000
REARCH*                          RS-CHECK-NO ,                          03720000
REARCH*                          DB-NULL-INDICATOR,                     03730000
REARCH*                          TDS-FALSE,                             03740000
REARCH*                          DB-CLIENT-TYPE,                        03750000
REARCH*                          WRKLEN1,                               03760000
REARCH*                          CNS-CHECK-NO,                          03770000
REARCH*                          WRKLEN2.                               03780000
REARCH*    PERFORM 9100-CHECK-ERROR THRU 9100-EXIT.                     03790000
REARCH*                                                                 03800000
REARCH*                                                                 03810000
REARCH*                                                                 03820000
REARCH*2100-EXIT.                                                       03830000
REARCH*    EXIT.                                                        03840000
REARCH*                                                                 03850000
      ******************************************************************03860000
      * 2200-BUILD-RESULT                                              *03870000
      ******************************************************************03880000
       2200-BUILD-RESULT.                                               
           PERFORM 7700-OPEN-LI-CURSOR           THRU 7700-EXIT .       
                                                                        
           PERFORM 7000-FETCH-LI-CURSOR          THRU 7000-EXIT.        
                                                                        
           IF WS-ACTIVE-RETURN-CODE = NOT-FOUND                         
C33780****    NO MC05 LOG WRITTEN                                       03941008
C33780        MOVE WS-ACTIVE-RETURN-CODE         TO RS-RETURN-CODE      
C33780        PERFORM 2000A-MOVE-RESULT          THRU 2000A-EXIT        
C33780        ADD +1                             TO   CTR-ROWS          
C33780        PERFORM 7800-CLOSE-LI-CURSOR       THRU 7800-EXIT         
C33780        PERFORM 9999-END-PROGRAM           THRU 9999-EXIT         
           END-IF.                                                      
                                                                        
           PERFORM 2300-PROCESS-FETCH            THRU 2300-EXIT         
           UNTIL WS-ACTIVE-RETURN-CODE = NOT-FOUND .                    
REARCH     PERFORM 2000A-MOVE-RESULT       THRU 2000A-EXIT.             
REARCH     ADD +1                          TO   CTR-ROWS.               
REARCH*    PERFORM 8100-SEND-RESULT        THRU 8100-EXIT.              04060000
                                                                        
           PERFORM 7800-CLOSE-LI-CURSOR          THRU 7800-EXIT .       
       2200-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************04120000
      * 2300-PROCESS-FETCH                                             *04130000
      ******************************************************************04140000
       2300-PROCESS-FETCH.                                              
                                                                        
           MOVE '2300'                TO ACTIVE-PARAGRAPH.              
                                                                        
           MOVE 0                     TO RS-RETURN-CODE.                
           ADD  LI-VOUCHER-AMT        TO RS-VOUCHER-AMT.                
           MOVE LI-CODE-AGENCY-ID     TO RS-CODE-AGENCY-ID              
           MOVE LI-CHECK-NO           TO RS-CHECK-NO .                  
                                                                        
           PERFORM 7000-FETCH-LI-CURSOR          THRU 7000-EXIT.        
       2300-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************04280000
      * 7000-FETCH-LI-CURSOR                                           *04290000
      ******************************************************************04300000
       7000-FETCH-LI-CURSOR.                                            
              EXEC SQL                                                  
                 FETCH LI-CURSOR                                        
                  INTO :LI-VOUCHER-AMT                                  
              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 '7000'               TO ACTIVE-PARAGRAPH          
CBSI             MOVE 'FETCH'              TO ABEND-FUNCTION            
                 MOVE 'CSS_LIEAP'          TO TABLE-1                   
CBSI             MOVE 'CHECK_NO'           TO TABLE-ELEMENT-1           
                 MOVE 'CODE_AGENCY_ID'     TO TABLE-ELEMENT-2           
                 MOVE LI-CHECK-NO          TO HOSTVAR-ELEMENT-1         
                 MOVE LI-CODE-AGENCY-ID    TO HOSTVAR-ELEMENT-2         
                 PERFORM 9000-SEND-ERROR-RESULT  THRU 9000-EXIT         
                 PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT         
              END-IF .                                                  
                                                                        
       7000-EXIT.                                                       
           EXIT.                                                        
      ******************************************************************04570000
      * 7700-OPEN-LI-CURSOR                                            *04580000
      ******************************************************************04590000
       7700-OPEN-LI-CURSOR.                                             
                                                                        
              EXEC SQL                                                  
                 OPEN LI-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             
                 MOVE '7700'               TO ACTIVE-PARAGRAPH          
CBSI             MOVE 'OPEN'               TO ABEND-FUNCTION            
                 MOVE 'CSS_LIEAP'          TO TABLE-1                   
                 MOVE 'CHECK_NO'           TO TABLE-ELEMENT-1           
CBSI             MOVE 'CODE_AGENCY_ID'     TO TABLE-ELEMENT-2           
                 MOVE LI-CHECK-NO          TO HOSTVAR-ELEMENT-1         
CBSI             MOVE LI-CODE-AGENCY-ID    TO HOSTVAR-ELEMENT-2         
                 PERFORM 9000-SEND-ERROR-RESULT  THRU 9000-EXIT         
                 PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT         
                                                                        
               END-IF.                                                  
       7700-EXIT.                                                       
           EXIT.                                                        
                                                                        
      ******************************************************************04840000
      * 7800-CLOSE-LI-CURSOR                                           *04850000
      ******************************************************************04860000
       7800-CLOSE-LI-CURSOR.                                            
                                                                        
           MOVE '7800'          TO ACTIVE-PARAGRAPH                     
                                                                        
              EXEC SQL                                                  
                 CLOSE LI-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            
                 MOVE 'CSS_LIEAP'          TO TABLE-1                   
CBSI             MOVE 'CHECK_NO'           TO TABLE-ELEMENT-1           
CBSI             MOVE 'CODE_AGENCY_ID'     TO TABLE-ELEMENT-2           
CBSI             MOVE LI-CHECK-NO          TO HOSTVAR-ELEMENT-1         
CBSI             MOVE LI-CODE-AGENCY-ID    TO HOSTVAR-ELEMENT-2         
                 PERFORM 9000-SEND-ERROR-RESULT  THRU 9000-EXIT         
                 PERFORM 9900-SQL-ERROR-ROUTINE  THRU 9900-EXIT         
              END-IF.                                                   
                                                                        
       7800-EXIT.                                                       
           EXIT.                                                        
                                                                        
                                                                        
      ******************************************************************05130000
      * 9900- JOURNALING / ERROR HANDLING INCLUDE *                     05140000
      ******************************************************************05150000
           EXEC SQL                                                     05160000
REARCH*       INCLUDE CPD00300                                          05170000
REARCH        INCLUDE CPDSP300                                          05171000
           END-EXEC.                                                    05180000
                                                                        
      ******************************************************************05200000
      *       END PROGRAM COPYLIB                                      *05210000
      ******************************************************************05220000
REARCH*    COPY CPD00302.                                               05230000
REARCH     EXEC SQL                                                     05231000
REARCH        INCLUDE CPD00321                                          05232000
REARCH     END-EXEC.                                                    05233000
                                                                        
