JES Log Presentation or Sharing
MFJESLOG - The COBOL Source Code
http://www.simotime.com
When technology complements business    Copyright © 1987-2010  SimoTime Enterprises  All Rights Reserved
  Table of Contents Version 10.03.20 
  Introduction
 
  What It Does
  How to Use
  The COBOL Source Code
  Summary
 
  Software Agreement and Disclaimer
  Downloads and Links to Similar Pages
  Glossary of Terms
  Comments or Suggestions
  About SimoTime

Introduction
(Next) (Previous) (Table-of-Contents)

This document provides a listing of the COBOL source code for viewing. Additional information about this program may be obtained by sending an e-mail to: helpdesk@simotime.com

MFJESLOG, What It Does
(Next) (Previous) (Table-of-Contents)

This program provides presentation alternatives for reviewing or sharing the contents of the Micro Focus JES log. The MFJESLOG program will read a JES Spool file created by Micro Focus and produce an HTML or CSV file with job and job step information such as start, stop and elapsed times along with the Job Name, Job Number and the condition code at the end of each step and at the end of job.

MFJESLOG, How To Use
(Next) (Previous) (Table-of-Contents)

The following command file (ezJESLOG.CMD) describes how to use the MFJESLOG program.

@echo OFF
rem  *
rem  * ESA, Enterprise Server Administration
rem  *      JES Log Presentation or Sharing Alternatives
rem  *
rem  * The following two environment variables identify the location of
rem  * the input and output files.
rem  *
rem  * JESNAME - Identifies the JES Spool File.
rem  * MFJESLOG_OUTDIR - Identifies the directory for the output files.
rem  *                   Must have a trailing slash or back-slash.
rem  *
rem  * The following three environment variables identify the functions
rem  * to enable.
rem  *
rem  * MFJESLOG_CSV - If set to "ENABLE" a CSV file will be created with
rem  *                a summary of start, stop and elapsed times for the
rem  *                job and the job steps.
rem  *
rem  * MFJESLOG_HTM - If set to "ENABLE" an HTML document will be created
rem  *                with a summary of start, stop and elapsed times for
rem  *                the job and the job steps.
rem  *
rem  * MFJESLOG_LOG - If set to "ENABLE" a copy of the JES File will be
rem  *                created with a summary of start, stop and elapsed
rem  *                 times for the job and the job steps.
rem  *
rem  * Note: the names of the output files are in the following format.
rem  *       MFJESLOG.JobName.JobNumber.Date.Time.ext
rem  *
     call ezSetEnv
     set JESNAME=%BaseLib1%\DataLibA\Asc1\MFE2009.S0727.S091727.J02282.D00000.DAT
     set MFJESLOG_HTM=ENABLE
     set MFJESLOG_LOG=ENABLE
     set MFJESLOG_OUTDIR=%BaseLib1%\LOGS\MFJESLOG\
rem  *
     echo *******************************************************ezJESLOG
     echo Starting JobName ezJESLOG, User is %USERNAME%
rem  *
     run MFJESLOG
     if not "%ERRORLEVEL%" == "0" goto EOJNOK
rem  *
:EOJAOK
     echo Finished JobName ezJESLOG, User is %USERNAME%
     goto END
rem  *
:EOJNOK
     echo ABENDING JobName ezJESLOG, User is %USERNAME%
rem  *
:END
     if not "%SimoMODE%" == "BATCH" pause

The COBOL Source Code
(Next) (Previous) (Table-of-Contents)

The following (MFJESLOG.CBL) is the COBOL Source Code.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    MFJESLOG.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      * DISCLAIMER
      * ----------
      * We have made a significant effort to ensure that this program
      * is correct and accurate.
      *
      * We reserve the right to make changes without notice at any
      * time at the sole discretion of the author.
      *
      * The function delivered in this version is based on a set of
      * requirements of a specific group of customers.
      *
      * The intent is to add function as the need arises and in a
      * timeframe that is dependent upon the availability of resources.
      *
      *****************************************************************
      * Source Member: MFJESLOG.CBL
      * Copy Files:    None
      * Calls to:
      *****************************************************************
      * This program provides presentation alternatives for reviewing
      * or sharing the contents of the Micro Focus JES log.
      * The following functions are performed.
      *   1. Fetch the environment value for JESNAME file.
      *   2. Open JESNAME and get Job Number.
      *   3. Build a NEWNAME in the following format.
      *      JobName.JobNumb.Date.Time.LOG
      *   4. Write information to a LSEQ File
      *   5. If enabled, write a CSV File.
      *   6. If enabled, write a HTM File.
      *   7. If enabled, write a LOG File.
      *   8. If enabled, write a XML File.
      *
      *****************************************************************
      * MAINTENANCE
      * -----------
      *
      *****************************************************************
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT JES-FILE      ASSIGN TO JESNAME
                  ORGANIZATION  IS LINE SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS JESNAME-STATUS.
           SELECT CSV-FILE      ASSIGN TO CSVNAME
                  ORGANIZATION  IS LINE SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS CSV-STATUS.
           SELECT HTM-FILE      ASSIGN TO HTMNAME
                  ORGANIZATION  IS LINE SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS HTM-STATUS.
           SELECT LOG-FILE      ASSIGN TO LOGNAME
                  ORGANIZATION  IS LINE SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS LOG-STATUS.
           SELECT XML-FILE      ASSIGN TO XMLNAME
                  ORGANIZATION  IS LINE SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS XML-STATUS.
           SELECT CMDTOKEN-FILE ASSIGN TO CMDTOKEN
                  ORGANIZATION  IS LINE SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS CMDTOKEN-STATUS.
           SELECT JOB-FILE ASSIGN TO JOBFILE
                  ORGANIZATION  IS LINE SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS JOB-STATUS.

       DATA DIVISION.
       FILE SECTION.
       FD  JES-FILE
           DATA RECORD IS JESNAME-REC.
       01  JESNAME-REC.
           05  JESNAME-DATA-01 PIC X(00256).

       FD  CSV-FILE
           DATA RECORD IS CSV-REC.
       01  CSV-REC.
           05  CSV-DATA-01     PIC X(00256).

       FD  HTM-FILE
           DATA RECORD IS HTM-REC.
       01  HTM-REC.
           05  HTM-DATA-01     PIC X(00256).

       FD  LOG-FILE
           DATA RECORD IS LOG-REC.
       01  LOG-REC.
           05  LOG-DATA-01     PIC X(00256).

       FD  JOB-FILE
           DATA RECORD IS JOB-REC.
       01  JOB-REC.
           05  JOB-DATA-01     PIC X(00256).

       FD XML-FILE
           DATA RECORD IS XML-REC.
       01  XML-REC.
           05  XML-DATA-01     PIC X(00256).

       FD  CMDTOKEN-FILE
           DATA RECORD IS CMDTOKEN-RECORD.
       01  CMDTOKEN-RECORD.
           05  CMDTOKEN-REC-ID pic X(3).
           05  CMDTOKEN-DATA   pic X(509).

      *****************************************************************
       WORKING-STORAGE SECTION.
       01  JESNAME-STATUS.
           05  JESNAME-STATUS-L    pic X.
           05  JESNAME-STATUS-R    pic X.
       01  JESNAME-EOF             pic X       value 'N'.
       01  JESNAME-OPEN-FLAG       pic X       value 'C'.

       01  CSV-STATUS.
           05  CSV-STATUS-L        pic X.
           05  CSV-STATUS-R        pic X.
       01  CSV-EOF                 pic X       value 'N'.
       01  CSV-OPEN-FLAG           pic X       value 'C'.

       01  HTM-STATUS.
           05  HTM-STATUS-L        pic X.
           05  HTM-STATUS-R        pic X.
       01  HTM-EOF                 pic X       value 'N'.
       01  HTM-OPEN-FLAG           pic X       value 'C'.

       01  LOG-STATUS.
           05  LOG-STATUS-L        pic X.
           05  LOG-STATUS-R        pic X.
       01  LOG-EOF                 pic X       value 'N'.
       01  LOG-OPEN-FLAG           pic X       value 'C'.

       01  XML-STATUS.
           05  XML-STATUS-L        pic X.
           05  XML-STATUS-R        pic X.
       01  XML-EOF                 pic X       value 'N'.
       01  XML-OPEN-FLAG           pic X       value 'C'.

       01  JOB-STATUS.
           05  JOB-STATUS-L        pic X.
           05  JOB-STATUS-R        pic X.
       01  JOB-EOF                 pic X       value 'N'.
       01  JOB-OPEN-FLAG           pic X       value 'C'.

       01  CMDTOKEN-STATUS.
           05  CMDTOKEN-STAT1      pic X.
           05  CMDTOKEN-STAT2      pic X.
       01  CMDTOKEN-EOF            pic X       value 'N'.
       01  CMDTOKEN-OPEN-FLAG      pic X       value 'N'.

      *****************************************************************
      * The following buffers are used to create a four-byte status   *
      * code that may be displayed.                                   *
      *****************************************************************
       01  IO-STATUS.
           05  IO-STAT1            pic X.
           05  IO-STAT2            pic X.
       01  IO-STATUS-04.
           05  IO-STATUS-0401      pic 9     value 0.
           05  IO-STATUS-0403      pic 999   value 0.
       01  TWO-BYTES-BINARY        pic 9(4)  BINARY.
       01  TWO-BYTES-ALPHA         redefines TWO-BYTES-BINARY.
           05  TWO-BYTES-LEFT      pic X.
           05  TWO-BYTES-RIGHT     pic X.

      *****************************************************************
      * Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine.
      *
       01  MESSAGE-BUFFER.
      *    05  MESSAGE-HEADER      pic X(09)   value 'MFJESLOG,'.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(80)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(52)   value SPACES.

      *****************************************************************
      * Data-structure for environment variable get routine...
      *
       01  ENV-VAR-NAME            pic X(16)   value SPACES.
       01  ENV-VAR-VALUE           pic X(256)  value SPACES.

       01  WRKTOKEN-01R-RECORD.
           05  WRKTOKEN-REC-ID-01      pic X(3).
           05  WRKTOKEN-CMD-NUMBER.
               10  WRK-TOKEN-PREFIX    pic X(3).
               10  WRKTOKEN-NUMBER     pic 9(5).
           05  FILLER                  pic X(501).

       01  MESSAGE-LENGTH          pic 9(4)    value 512.

       01  XML-DATE-TIME.
           05  FILLER      pic X(15) value '<ExecutionDate>'.
           05  XML-DATE    pic X(8)  value SPACES.
           05  FILLER      pic X(16) value '</ExecutionDate>'.
           05  FILLER      pic X(15) value '<ExecutionTime>'.
           05  XML-TIME    pic X(8)  value SPACES.
           05  FILLER      pic X(16) value '</ExecutionTime>'.
           05  JOB-NUMBER-XML-GROUP.
               10  FILLER          pic X(11) value '<JobNumber>'.
               10  JOB-NUMBER-XML  pic X(8).
               10  FILLER          pic X(12) value '</JobNumber>'.
           05  JOB-NAME-XML-GROUP.
               10  FILLER          pic X(9)  value '<JobName>'.
               10  JOB-NAME-XML    pic X(8).
               10  FILLER          pic X(10) value '</JobName>'.

       01  XML-JOB-STARTED.
           05  FILLER  pic X(20)
                           value '<TaskID>JOB'.
           05  FILLER  pic X(32)
                           value '<TaskStatus>STARTED'.
       01  XML-JOB-ENDED.
           05  FILLER  pic X(20)
                           value '<TaskID>JOB'.
           05  FILLER  pic X(30)
                           value '<TaskStatus>ENDED'.
           05  FILLER  pic X(7)  value '<JobCC>'.
           05  XML-COND-CODE-JOB pic X(8)  value SPACES.
           05  FILLER  pic X(8)  value '</JobCC>'.
           05  FILLER  pic X(13) value '<ElapsedTime>'.
           05  XML-ELAPSED-JOB   pic X(8)  value SPACES.
           05  FILLER  pic X(14) value '</ElapsedTime>'.

       01  XML-STEP-STARTED.
           05  FILLER  pic X(21)
                           value '<TaskID>STEP'.
           05  FILLER  pic X(32)
                           value '<TaskStatus>STARTED'.
           05  FILLER  pic X(10) value '<StepName>'.
           05  XML-STEP-NAME     pic X(17) value SPACES.
           05  FILLER  pic X(11) value '</StepName>'.

       01  XML-STEP-BYPASSED.
           05  FILLER      pic X(21)
                           value '<TaskID>STEP'.
           05  FILLER      pic X(33)
                           value '<TaskStatus>BYPASSED'.
           05  FILLER      pic X(10) value '<StepName>'.
           05  XML-STEP-NAME-BYPASS     pic X(17) value SPACES.
           05  FILLER      pic X(11) value '</StepName>'.

       01  XML-STEP-ENDED.
           05  FILLER      pic X(21)
                           value '<TaskID>STEP'.
           05  FILLER      pic X(30)
                           value '<TaskStatus>ENDED'.
           05  FILLER      pic X(10) value '<StepName>'.
           05  XML-STEP-NAME-END
                           pic X(17) value SPACES.
           05  FILLER      pic X(11) value '</StepName>'.
           05  FILLER      pic X(8)  value '<StepCC>'.
           05  XML-COND-CODE
                           pic X(8)  value SPACES.
           05  FILLER      pic X(9)  value '</StepCC>'.
           05  FILLER      pic X(13) value '<ElapsedTime>'.
           05  XML-ELAPSED-TIME  pic X(8)  value SPACES.
           05  FILLER      pic X(14) value '</ElapsedTime>'.

       01  JOB-NUMBER.
           05  FILLER              pic X(3)    value 'JOB'.
           05  JOB-NUMBER-05       pic X(5)    value '00000'.
       01  JOB-NAME                pic X(8)    value SPACES.
       01  JOB-DATE.
           05  JOB-DATE-CCYY       pic X(4)    value SPACES.
           05  JOB-DATE-MMDD       pic X(4)    value SPACES.
       01  JOB-TIME                pic X(8)    value '00000000'.

       01  JOB-NUMBER-FLAG         pic X       value 'N'.
       01  OLD-NAME-SCAN-FLAG      pic X       value 'C'.
       01  CSV-ENABLED             pic X       value 'N'.
       01  CMD-ENABLED             pic X       value 'N'.
       01  HTM-ENABLED             pic X       value 'N'.
       01  LOG-ENABLED             pic X       value 'N'.
       01  XML-ENABLED             pic X       value 'N'.
       01  JOB-ENABLED             pic X       value 'N'.
       01  MSG-ENABLED             pic X       value 'N'.

       01  WORK-12                 pic X(12)   value SPACES.
       01  WORK-256                pic X(256)  value SPACES.
       01  MESSAGE-ID              pic X(12)   value SPACES.
       01  JOB-RETURN-CODE         pic S9(4)   BINARY  value 0.
       01  JOB-RETURN-CODE-4       pic 9(4)    value 0.
       01  PT-1                    pic 9(5)    value 0.
       01  PT-2                    pic 9(5)    value 0.
       01  LOOP-LIMIT              pic 9(5)    value 0.

       01  OLD-NAME                pic X(512)  value SPACES.
       01  NEW-NAME                pic X(512)  value SPACES.
       01  CSV-NAME                pic X(512)  value SPACES.
       01  HTM-NAME                pic X(512)  value SPACES.
       01  XML-NAME                pic X(512)  value SPACES.
       01  CMD-NAME                pic X(512)  value SPACES.
       01  LOG-NAME                pic X(512)  value SPACES.
       01  JOB-FILE-NAME           pic X(512)  value SPACES.

       01  IX-1                    pic 9(5)    value 0.
       01  IX-2                    pic 9(5)    value 0.
       01  IX-3                    pic 9(5)    value 0.

       01  WORK-DATE.
           05  WORK-DATE-08        pic X(8).
       01  WORK-TIME               pic X(8).

       01  APPL-RESULT             pic S9(9)   comp.
           88  APPL-AOK            value 0.
           88  APPL-EOF            value 16.

       01  JOB-START-SECS          pic 9(5)    value 0.
       01  JOB-STOP-SECS           pic 9(5)    value 0.
       01  STEP-START-SECS         pic 9(5)    value 0.
       01  STEP-STOP-SECS          pic 9(5)    value 0.
       01  WORK-ELAPSED-SECS       pic 9(5)    value 0.
       01  DIVIDE-REMAINDER        pic 9(5)    value 0.

       01  LOWER-CASE  pic X(26)   value 'abcdefghijklmnopqrstuvwxyz'.
       01  UPPER-CASE  pic X(26)   value 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.

       01  MFBSI-CSV.
           05  MFBSI-CSV-DATE.
               10  MFBSI-CSV-CCYY    pic X(4)  value SPACES.
               10  MFBSI-CSV-MM      pic X(2)  value SPACES.
               10  MFBSI-CSV-DD      pic X(2)  value SPACES.
           05  filler                pic X     value ','.
           05  MFBSI-CSV-TIME.
               10  MFBSI-CSV-HOURS   pic 9(2)  value 0.
               10  filler            pic X     value ':'.
               10  MFBSI-CSV-MINS    pic 9(2)  value 0.
               10  filler            pic X     value ':'.
               10  MFBSI-CSV-SECS    pic 9(2)  value 0.
           05  filler                pic X     value ','.
           05  MFBSI-CSV-MSG-ID      pic X(10) value SPACES.
           05  filler                pic X     value ','.
           05  MFBSI-CSV-JOB-NUMB    pic X(8)  value SPACES.
           05  filler                pic X     value ','.
           05  MFBSI-CSV-JOB-STEP    pic X(4)  value SPACES.
           05  filler                pic X     value ','.
           05  MFBSI-CSV-START-END   pic X(8)  value SPACES.
           05  filler                pic X     value ','.
           05  MFBSI-CSV-JOB-NAME    pic X(8)  value SPACES.
           05  filler                pic X     value ','.
           05  MFBSI-CSV-STEP-NAME   pic X(17) value SPACES.
           05  filler                pic X     value ','.
           05  MFBSI-CSV-COND-CODE   pic X(8)  value SPACES.
           05  filler                pic X     value ','.
           05  MFBSI-CSV-E-TIME.
               10  MFBSI-CSV-E-HOURS pic 9(2)  value 0.
               10  filler            pic X     value ':'.
               10  MFBSI-CSV-E-MINS  pic 9(2)  value 0.
               10  filler            pic X     value ':'.
               10  MFBSI-CSV-E-SECS  pic 9(2)  value 0.

       01  STATUS-FLAGS.
           05  JOB-RECORD-ACTIVE     pic X     value 'N'.

       01  BYTES-BINARY.
           05  BYTE-LT               pic X     value '<'.
           05  BYTE-GT               pic X     value '>'.

       01  COL-TITLES.
           05  FILLER  pic X(24)   value '<B>Date             '.
           05  FILLER  pic X(24)   value '<B>Time             '.
           05  FILLER  pic X(24)   value '<B>JCL Message      '.
           05  FILLER  pic X(24)   value '<B>Job Number       '.
           05  FILLER  pic X(24)   value '<B>Job or Step      '.
           05  FILLER  pic X(24)   value '<B>Condition        '.
           05  FILLER  pic X(24)   value '<B>Job Name         '.
           05  FILLER  pic X(24)   value '<B>Step Name        '.
           05  FILLER  pic X(24)   value '<B>Return Code      '.
           05  FILLER  pic X(24)   value '<B>Elapsed Time     '.
       01  COL-TABLE   redefines   COL-TITLES.
           05  COL-ELEMENT         pic X(24) occurs 10 times.
       01  COL-IDX     pic 9(3)    value 0.

       COPY HTMLCB01.

      *****************************************************************
       PROCEDURE DIVISION.
           perform GET-DATE-AND-TIME
           move SPACES to OLD-NAME
           move SPACES to NEW-NAME

           perform FETCH-BEHAVIOR-FLAGS

           perform FETCH-OLD-NAME

           perform GET-JOB-INFO

      *    perform BUILD-NEW-NAME

           move 0 to RETURN-CODE

           if  CSV-OPEN-FLAG = 'O'
               perform CSV-CLOSE
           end-if
           if  HTM-OPEN-FLAG = 'O'
               move BYTE-LT to HTM-REC
               move '/PRE'  to HTM-REC(2:4)
               move BYTE-GT to HTM-REC(6:1)
               perform HTM-WRITE
               perform HTML-TABLE-FOOTER
               perform HTML-FOOTER
               perform HTM-CLOSE
           end-if
           if  XML-OPEN-FLAG = 'O'
               move BYTE-LT    to XML-REC
               move '/JobInfo' to XML-REC(2:8)
               move BYTE-GT    to XML-REC(10:1)
               perform XML-WRITE
               perform XML-CLOSE
           end-if

      *    Copy JES Spool File into LOG file with new name...
           if  LOG-ENABLED = 'Y'
               perform LOG-OPEN
               if  LOG-OPEN-FLAG = 'O'
                   perform JESNAME-OPEN
                   perform until JESNAME-STATUS not = '00'
                     perform JESNAME-READ
                     move JESNAME-REC to LOG-REC
                     perform LOG-WRITE
                   end-perform
                   perform JESNAME-CLOSE
                   perform LOG-CLOSE
               end-if

           add JOB-RETURN-CODE to ZERO giving RETURN-CODE
           GOBACK.

      *****************************************************************
       HTML-HEADER.
           move HTML-TAG to HTM-REC
           perform HTM-WRITE
           move JOB-NAME   to TITLE-TEXT-NAME
           move JOB-NUMBER to TITLE-TEXT-NUMB
           move TITLE-RECORD to HTM-REC
           perform HTM-WRITE
           move BODY-TAG to HTM-REC
           perform HTM-WRITE
           exit.

      *****************************************************************
       HTML-FOOTER.
           move BODY-END to HTM-REC
           perform HTM-WRITE
           move HTML-END to HTM-REC
           perform HTM-WRITE
           exit.

      *****************************************************************
       HTML-TABLE-HEADER.
           move TABLE-TAG-2 to HTM-REC
           perform HTM-WRITE
           move TABLE-TR-TAG to HTM-REC
           perform HTM-WRITE
           perform varying COL-IDX from 1 by 1 until COL-IDX > 10
             move TABLE-TD-TAG to HTM-REC
             move COL-ELEMENT(COL-IDX) to HTM-REC(5:24)
             inspect HTM-REC replacing first '     '
                                          by TABLE-TD-END
             perform HTM-WRITE
           end-perform
           move TABLE-TR-END to HTM-REC
           perform HTM-WRITE
           exit.

      *****************************************************************
       HTML-TABLE-FOOTER.
           move TABLE-END to HTM-REC
           perform HTM-WRITE
           exit.

      *****************************************************************
       HTML-TABLE-TD-NBSP.
           move TABLE-TD-TAG to HTM-REC
           move ' '
             to HTM-REC(5:6)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE
           exit.

      *****************************************************************
       BUILD-NEW-NAME.
           if  JOB-DATE = SPACES
               move WORK-DATE to JOB-DATE
           end-if
           inspect NEW-NAME replacing first '        ' by 'MFJESLOG'
           inspect NEW-NAME replacing first '   '      by '.  '
           inspect NEW-NAME replacing first '        ' by JOB-NAME
           inspect NEW-NAME replacing first '   '      by '.  '
           inspect NEW-NAME replacing first '        ' by JOB-NUMBER
           inspect NEW-NAME replacing first '     '    by '.    '
           inspect NEW-NAME replacing first '        ' by JOB-DATE
           inspect NEW-NAME replacing first '     '    by '.    '
           inspect NEW-NAME replacing first '        ' by JOB-TIME
           exit.

      *****************************************************************
       BUILD-CMD-NAME.
           perform FETCH-MFBSI-DIR
           move ENV-VAR-VALUE to CMD-NAME
           inspect CMD-NAME replacing first '             '
                                         by '\CMDTOKEN.CFG'
           move SPACES     to ENV-VAR-NAME
           move 'CMDTOKEN' to ENV-VAR-NAME
           move CMD-NAME   to ENV-VAR-VALUE
           perform ENV-SET
           exit.

      *****************************************************************
       BUILD-CSV-NAME.
           move NEW-NAME to CSV-NAME
           inspect CSV-NAME replacing first '     '    by'.CSV '
           move SPACES     to ENV-VAR-NAME
           move 'CSVNAME ' to ENV-VAR-NAME
           move CSV-NAME   to ENV-VAR-VALUE
           perform ENV-SET
           if  CSV-ENABLED = 'Y'
               perform CSV-OPEN
           end-if
           exit.

      *****************************************************************
       BUILD-HTM-NAME.
           move NEW-NAME to HTM-NAME
           inspect HTM-NAME replacing first '     '    by'.HTM '
           move SPACES     to ENV-VAR-NAME
           move 'HTMNAME ' to ENV-VAR-NAME
           move HTM-NAME   to ENV-VAR-VALUE
           perform ENV-SET
           if  HTM-ENABLED = 'Y'
               perform HTM-OPEN
               perform HTML-HEADER
               perform HTML-TABLE-HEADER
               move BYTE-LT to HTM-REC
               move '/PRE'  to HTM-REC(2:4)
               move BYTE-GT to HTM-REC(6:1)
               perform HTM-WRITE
           end-if
           exit.

      *****************************************************************
       BUILD-LOG-NAME.
           move NEW-NAME to LOG-NAME
           inspect LOG-NAME replacing first '     '    by'.LOG '
           move SPACES     to ENV-VAR-NAME
           move 'LOGNAME ' to ENV-VAR-NAME
           move LOG-NAME   to ENV-VAR-VALUE
           perform ENV-SET
           exit.

      *****************************************************************
       BUILD-XML-NAME.
           move NEW-NAME to XML-NAME
           inspect XML-NAME replacing first '     '    by'.XML '
           move SPACES     to ENV-VAR-NAME
           move 'XMLNAME ' to ENV-VAR-NAME
           move XML-NAME   to ENV-VAR-VALUE
           perform ENV-SET
           if  XML-ENABLED = 'Y'
               perform XML-OPEN
               move '<?xml version="1.0" encoding="UTF-8"?>' to XML-REC
               perform XML-WRITE
               move '<JobInfo>' to XML-REC
               perform XML-WRITE
           end-if
           exit.

      *****************************************************************
       POSSIBLE-OPEN-JOB-FILE.
      *    move NEW-NAME to JOB-FILE-NAME
      *    inspect JOB-FILE-NAME replacing
      *                              first '                          '
      *                                 by 'SIMOTIME.UTIL.MFJOBLOG.CSV'
      *    move SPACES     to ENV-VAR-NAME
      *    move 'JOBFILE ' to ENV-VAR-NAME
      *    move JOB-FILE-NAME   to ENV-VAR-VALUE
      *    perform ENV-SET
           if  JOB-ENABLED = 'Y'
               perform JOB-OPEN
           end-if
           exit.

      *****************************************************************
       COMPRESS-TO-XML-REC.
           add 1 to ZERO giving PT-1
           add 1 to ZERO giving PT-2
           move SPACES to XML-REC
           perform 256 times
             if  WORK-256(PT-1:1) = SPACE
                 add 1 to PT-1
             else
                 move WORK-256(PT-1:1) to XML-REC(PT-2:1)
                 add 1 to PT-1
                 add 1 to PT-2
             end-if
           end-perform
           exit.

      *****************************************************************
       ENV-SET.
           display ENV-VAR-NAME  upon ENVIRONMENT-NAME
                   on exception add 4 to ZERO giving RETURN-CODE
           end-display
           display ENV-VAR-VALUE upon ENVIRONMENT-VALUE
                   on exception add 4 to ZERO giving RETURN-CODE
           end-display
           exit.

      *****************************************************************
       ENV-GET.
           move SPACE to ENV-VAR-VALUE
           move ZERO to RETURN-CODE
           display ENV-VAR-NAME  upon ENVIRONMENT-NAME
                   on exception add 4 to ZERO giving RETURN-CODE
           end-display
           accept  ENV-VAR-VALUE from ENVIRONMENT-VALUE
                   on exception add 4 to ZERO giving RETURN-CODE
           end-accept
           exit.

      *****************************************************************
       FETCH-BEHAVIOR-FLAGS.
           move SPACES to ENV-VAR-NAME
           move 'MFJESLOG_MSG' to ENV-VAR-NAME
           move SPACES to ENV-VAR-VALUE
           perform ENV-GET
           if RETURN-CODE = 0
              inspect ENV-VAR-VALUE converting LOWER-CASE to UPPER-CASE
              if  ENV-VAR-VALUE = 'ENABLE'
                  move 'Y' to MSG-ENABLED
              else
                  move 'N' to MSG-ENABLED
              end-if
           end-if
           if  MSG-ENABLED = 'Y'
               move 'MFJESLOG_MSG=' to MESSAGE-TEXT
               move MSG-ENABLED to MESSAGE-TEXT(14:1)
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if

           move SPACES to ENV-VAR-NAME
           move 'MFJESLOG_CSV' to ENV-VAR-NAME
           move SPACES to ENV-VAR-VALUE
           perform ENV-GET
           if RETURN-CODE = 0
              inspect ENV-VAR-VALUE converting LOWER-CASE to UPPER-CASE
              if  ENV-VAR-VALUE = 'ENABLE'
                  move 'Y' to CSV-ENABLED
              else
                  move 'N' to CSV-ENABLED
              end-if
           end-if
           if  MSG-ENABLED = 'Y'
               move 'MFJESLOG_CSV=' to MESSAGE-TEXT
               move CSV-ENABLED to MESSAGE-TEXT(14:1)
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if

           move SPACES to ENV-VAR-NAME
           move 'MFJESLOG_CMD' to ENV-VAR-NAME
           move SPACES to ENV-VAR-VALUE
           perform ENV-GET
           if RETURN-CODE = 0
              inspect ENV-VAR-VALUE converting LOWER-CASE to UPPER-CASE
              if  ENV-VAR-VALUE = 'ENABLE'
                  move 'Y' to CMD-ENABLED
              else
                  move 'N' to CMD-ENABLED
              end-if
           end-if
           if  MSG-ENABLED = 'Y'
               move 'MFJESLOG_CMD=' to MESSAGE-TEXT
               move CMD-ENABLED to MESSAGE-TEXT(14:1)
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if

           move SPACES to ENV-VAR-NAME
           move 'MFJESLOG_HTM' to ENV-VAR-NAME
           move SPACES to ENV-VAR-VALUE
           perform ENV-GET
           if RETURN-CODE = 0
              inspect ENV-VAR-VALUE converting LOWER-CASE to UPPER-CASE
              if  ENV-VAR-VALUE = 'ENABLE'
                  move 'Y' to HTM-ENABLED
              else
                  move 'N' to HTM-ENABLED
              end-if
           end-if
           if  MSG-ENABLED = 'Y'
               move 'MFJESLOG_HTM=' to MESSAGE-TEXT
               move HTM-ENABLED to MESSAGE-TEXT(14:1)
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if

           move SPACES to ENV-VAR-NAME
           move 'MFJESLOG_LOG' to ENV-VAR-NAME
           move SPACES to ENV-VAR-VALUE
           perform ENV-GET
           if RETURN-CODE = 0
              inspect ENV-VAR-VALUE converting LOWER-CASE to UPPER-CASE
              if  ENV-VAR-VALUE = 'ENABLE'
                  move 'Y' to LOG-ENABLED
              else
                  move 'N' to LOG-ENABLED
              end-if
           end-if
           if  MSG-ENABLED = 'Y'
               move 'MFJESLOG_LOG=' to MESSAGE-TEXT
               move LOG-ENABLED to MESSAGE-TEXT(14:1)
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if

           move SPACES to ENV-VAR-NAME
           move 'MFJESLOG_XML' to ENV-VAR-NAME
           move SPACES to ENV-VAR-VALUE
           perform ENV-GET
           if RETURN-CODE = 0
              inspect ENV-VAR-VALUE converting LOWER-CASE to UPPER-CASE
              if  ENV-VAR-VALUE = 'ENABLE'
                  move 'Y' to XML-ENABLED
              else
                  move 'N' to XML-ENABLED
              end-if
           end-if
           if  MSG-ENABLED = 'Y'
               move 'MFJESLOG_XML=' to MESSAGE-TEXT
               move XML-ENABLED to MESSAGE-TEXT(14:1)
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if

           move SPACES to ENV-VAR-NAME
           move 'MFJESLOG_JOB' to ENV-VAR-NAME
           move SPACES to ENV-VAR-VALUE
           perform ENV-GET
           if RETURN-CODE = 0
              inspect ENV-VAR-VALUE converting LOWER-CASE to UPPER-CASE
              if  ENV-VAR-VALUE = 'ENABLE'
                  move 'Y' to JOB-ENABLED
              else
                  move 'N' to JOB-ENABLED
              end-if
           end-if
           if  MSG-ENABLED = 'Y'
               move 'MFJESLOG_JOB=' to MESSAGE-TEXT
               move JOB-ENABLED to MESSAGE-TEXT(14:1)
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if

           move SPACES to ENV-VAR-NAME
           move 'MFJESLOG_OUTDIR' to ENV-VAR-NAME
           move SPACES to ENV-VAR-VALUE
           perform ENV-GET
           if RETURN-CODE = 0
              inspect ENV-VAR-VALUE converting LOWER-CASE to UPPER-CASE
              if  ENV-VAR-VALUE not = SPACES
                  move ENV-VAR-VALUE to NEW-NAME
              else
                  move SPACES        to NEW-NAME
              end-if
           end-if
           if  MSG-ENABLED = 'Y'
               move 'MFJESLOG_OUTDIR is USER Defined' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move NEW-NAME to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           exit.

      *****************************************************************
       FETCH-MFBSI-DIR.
           move SPACES to ENV-VAR-NAME
           move 'MFBSI_DIR' to ENV-VAR-NAME
           move SPACES to ENV-VAR-VALUE
           perform ENV-GET

           if  RETURN-CODE not = 0
               move SPACES to ENV-VAR-VALUE
           end-if
           exit.

      *****************************************************************
       FETCH-OLD-NAME.
           move SPACES to ENV-VAR-NAME
           move 'JESNAME ' to ENV-VAR-NAME
           move SPACES to OLD-NAME
           perform ENV-GET
           if  RETURN-CODE = 0
           and ENV-VAR-VALUE not = SPACES
           add 1 to ZERO giving IX-1
           add 1 to ZERO giving IX-2
           add length of ENV-VAR-VALUE to ZERO giving IX-3
      *    Attempt to reduce perform loop iterations
           if  IX-3 > 255
           and ENV-VAR-VALUE(IX-3 - 127:128) = SPACES
               subtract 128 from IX-3
           end-if
           perform until IX-1 > IX-3
             if  ENV-VAR-VALUE(IX-1:1) = '\'
             or  ENV-VAR-VALUE(IX-1:1) = '/'
                 add 1 to IX-1
                 add 1 to ZERO giving IX-2
                 move  SPACES to OLD-NAME
             else
                 move ENV-VAR-VALUE(IX-1:1) to OLD-NAME(IX-2:1)
                 add 1 to IX-1
                 add 1 to IX-2
             end-if
           end-perform
           end-if

           if  OLD-NAME(1:3)  = 'MFE'
           and OLD-NAME(8:2)  = '.S'
           and OLD-NAME(14:2) = '.S'
           and OLD-NAME(22:2) = '.J'
               move OLD-NAME(4:4 ) to JOB-DATE-CCYY
               move OLD-NAME(10:4) to JOB-DATE-MMDD
               move OLD-NAME(16:6) to JOB-TIME(1:6)
               move OLD-NAME(24:5) to JOB-NUMBER-05
           end-if

           move JOB-DATE to MFBSI-CSV-DATE

           exit.

      *****************************************************************
       GET-JOB-INFO.
           perform JESNAME-OPEN

           perform until JESNAME-STATUS not = '00'
                      or OLD-NAME-SCAN-FLAG = 'Q'
               perform JESNAME-READ
               if JESNAME-STATUS = '00'
                  move JESNAME-REC(1:12) to WORK-12
                  if WORK-12 not =  '     *-*-*  '
                     inspect WORK-12 replacing characters
                                                 by SPACE
                                              after SPACE
                  end-if
                  evaluate WORK-12
                    when 'JCLCM0187I  ' perform GET-JOB-INFO-JCLCM0187I
                    when '     *-*-*  ' perform GET-JOB-NUMBER-NAME
                    when 'CMDCM0187I  ' perform GET-JOB-INFO-JCLCM0187I
                    when '            ' perform GET-JOB-INFO-SPACES
                    when '--->        ' perform GET-JOB-INFO-SPACES
                    when '==>>        ' perform GET-JOB-INFO-ABEND
                  end-evaluate
               end-if
               if  XML-OPEN-FLAG = 'O'
               and JOB-RECORD-ACTIVE = 'Y'
                   move 'N' to JOB-RECORD-ACTIVE
                   move '</JobRecord>' to XML-REC
                   perform XML-WRITE
               end-if
           end-perform

           perform JESNAME-CLOSE
           exit.

      *****************************************************************
      * Process "     *-*-*  " message, get the Job Number & Job Name
       GET-JOB-NUMBER-NAME.
           if  JESNAME-REC(13:5) ='Job: '
           and JESNAME-REC(24:6) ='Name: '
               move JESNAME-REC(18:5) to JOB-NUMBER(4:5)
               move JESNAME-REC(30:8) to JOB-NAME
               perform GET-JOB-NUMBER-NAME-02
           end-if
           exit.

      *****************************************************************
       GET-JOB-NUMBER-NAME-02.
           if  XML-OPEN-FLAG = 'O'
               move 'Y' to JOB-RECORD-ACTIVE
               move '<JobRecord>' to XML-REC
               perform XML-WRITE
           end-if
           move JOB-NUMBER to JOB-NUMBER-XML
           if  JOB-NUMBER = 'CMD00000'
           and CMD-ENABLED = 'Y'
               perform GET-CMD-NUMB
           end-if
           move JOB-NUMBER        to MFBSI-CSV-JOB-NUMB
           move JOB-NAME to MFBSI-CSV-JOB-NAME
           move JOB-NAME to JOB-NAME-XML
           move 'Y' to JOB-NUMBER-FLAG
      *    move 'Q' to OLD-NAME-SCAN-FLAG
           if  MSG-ENABLED = 'Y'
               move JESNAME-REC to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           perform POSSIBLE-OPEN-JOB-FILE
           perform BUILD-NEW-NAME
           perform BUILD-CSV-NAME
           perform BUILD-HTM-NAME
           perform BUILD-LOG-NAME
           perform BUILD-XML-NAME
           exit.

      *****************************************************************
      * Process "Job Submitted" message, get the Job Number & Job Name
       GET-JOB-INFO-JCLCM0187I.
           move JESNAME-REC(12:8) to JOB-NUMBER
           move JESNAME-REC(21:8) to JOB-NAME
           perform GET-JOB-NUMBER-NAME-02
           exit.

      *****************************************************************
      * Process possible JOB or STEP message
       GET-JOB-INFO-SPACES.
           move JESNAME-REC(15:11) to MESSAGE-ID
           evaluate MESSAGE-ID
             when 'JCLCM0188I  ' perform GET-JOB-INFO-JCLCM0188I
             when 'JCLCM0189I  ' perform GET-JOB-INFO-JCLCM0189I
             when 'JCLCM0190I  ' perform GET-JOB-INFO-JCLCM0190I
             when 'JCLCM0191I  ' perform GET-JOB-INFO-JCLCM0191I
             when 'JCLCM0182I  ' perform GET-JOB-INFO-JCLCM0182I
           end-evaluate
           exit.

      *****************************************************************
      * Process possible JOB or STEP message
       GET-JOB-INFO-ABEND.
           move JESNAME-REC(15:11) to MESSAGE-ID
           evaluate MESSAGE-ID
             when 'JCLCM0192S  ' perform GET-JOB-INFO-JCLCM0191I
             when 'JCLCM0181S  ' perform GET-JOB-INFO-JCLCM0182I
           end-evaluate
           exit.

      *****************************************************************
      * Process "Job Started" message
       GET-JOB-INFO-JCLCM0188I.
           if  XML-OPEN-FLAG = 'O'
               move 'Y' to JOB-RECORD-ACTIVE
               move '<JobRecord>' to XML-REC
               perform XML-WRITE
           end-if
           move JESNAME-REC(6:2)  to MFBSI-CSV-HOURS
           move JESNAME-REC(9:2)  to MFBSI-CSV-MINS
           move JESNAME-REC(12:2) to MFBSI-CSV-SECS
           compute JOB-START-SECS = MFBSI-CSV-HOURS * 3600
                                  + MFBSI-CSV-MINS  * 60
                                  + MFBSI-CSV-SECS
           move SPACES       to MFBSI-CSV-E-TIME
           move MESSAGE-ID   to MFBSI-CSV-MSG-ID
           move 'JOB '       to MFBSI-CSV-JOB-STEP
           move 'STARTED'    to MFBSI-CSV-START-END
           move SPACES       to MFBSI-CSV-STEP-NAME
           move SPACES       to MFBSI-CSV-COND-CODE
           if  MSG-ENABLED = 'Y'
               move MFBSI-CSV    to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           if  CSV-OPEN-FLAG = 'O'
               move MFBSI-CSV to CSV-REC
               perform CSV-WRITE
           end-if
           if  XML-OPEN-FLAG = 'O'
               move MFBSI-CSV-DATE to XML-DATE
               move MFBSI-CSV-TIME to XML-TIME
               move XML-DATE-TIME to XML-REC
               perform XML-WRITE
               move XML-JOB-STARTED to XML-REC
               perform XML-WRITE
           end-if
           if  HTM-OPEN-FLAG = 'O'
               perform GET-JOB-INFO-JCLCM0188I-HTM
           end-if
           exit.

      *****************************************************************
      * Create an HTML Table row for output...
       GET-JOB-INFO-JCLCM0188I-HTM.
           add 1 to ZERO giving COL-IDX
           move TABLE-TR-TAG to HTM-REC
           perform HTM-WRITE

      *    Date
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-DATE
             to HTM-REC(5:LENGTH OF MFBSI-CSV-DATE)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Time
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-TIME
             to HTM-REC(5:LENGTH OF MFBSI-CSV-TIME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    JCL Message
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-MSG-ID
             to HTM-REC(5:LENGTH OF MFBSI-CSV-MSG-ID)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job Number
           move TABLE-TD-TAG to HTM-REC
           move JOB-NUMBER
             to HTM-REC(5:LENGTH OF JOB-NUMBER)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job or Step
           move TABLE-TD-TAG to HTM-REC
           move 'JOB ' to HTM-REC(5:4)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Condition
           move TABLE-TD-TAG to HTM-REC
           move 'STARTED'to HTM-REC(5:7)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job Name
           move TABLE-TD-TAG to HTM-REC
           move JOB-NAME
             to HTM-REC(5:LENGTH OF JOB-NAME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Step Name
           perform HTML-TABLE-TD-NBSP
      *    Return Code
           perform HTML-TABLE-TD-NBSP
      *    Elapsed Time
           perform HTML-TABLE-TD-NBSP
      *    End of Table ROw...
           move TABLE-TR-END to HTM-REC
           perform HTM-WRITE
           exit.

      *****************************************************************
      * Process "Job Ended" message
       GET-JOB-INFO-JCLCM0182I.
           if  XML-OPEN-FLAG = 'O'
               move 'Y' to JOB-RECORD-ACTIVE
               move '<JobRecord>' to XML-REC
               perform XML-WRITE
           end-if
           move JESNAME-REC(6:2)  to MFBSI-CSV-HOURS
           move JESNAME-REC(9:2)  to MFBSI-CSV-MINS
           move JESNAME-REC(12:2) to MFBSI-CSV-SECS

           compute JOB-STOP-SECS = (MFBSI-CSV-HOURS * 3600
                                 + MFBSI-CSV-MINS  * 60
                                 + MFBSI-CSV-SECS)
           if  JOB-START-SECS > JOB-STOP-SECS
               add 86400 to JOB-STOP-SECS
           end-if
           compute WORK-ELAPSED-SECS = JOB-STOP-SECS - JOB-START-SECS

           move '00:00:00' to MFBSI-CSV-E-TIME
           if  WORK-ELAPSED-SECS > 3599
               divide WORK-ELAPSED-SECS by 3600
               giving MFBSI-CSV-E-HOURS
               remainder DIVIDE-REMAINDER
               move DIVIDE-REMAINDER to WORK-ELAPSED-SECS
           end-if
           if  WORK-ELAPSED-SECS > 59
               divide WORK-ELAPSED-SECS by 60
               giving MFBSI-CSV-E-MINS
               remainder MFBSI-CSV-E-SECS
           else
               move WORK-ELAPSED-SECS to MFBSI-CSV-E-SECS
           end-if

           move MESSAGE-ID        to MFBSI-CSV-MSG-ID
           move 'JOB '            to MFBSI-CSV-JOB-STEP
           move JESNAME-REC(51:8) to MFBSI-CSV-COND-CODE
      *    move 'ENDED  '         to MFBSI-CSV-START-END
           move SPACES            to MFBSI-CSV-START-END
           if  MFBSI-CSV-COND-CODE(1:4) = '0000'
               move JESNAME-REC(31:7) to MFBSI-CSV-START-END
           else
               move 'ABENDED' to MFBSI-CSV-START-END
           end-if
           move SPACES            to MFBSI-CSV-STEP-NAME
           if  MSG-ENABLED ='Y'
               move MFBSI-CSV  to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           if  CSV-OPEN-FLAG = 'O'
               move MFBSI-CSV to CSV-REC
               perform CSV-WRITE
           end-if
           if  XML-OPEN-FLAG = 'O'
               move MFBSI-CSV-DATE to XML-DATE
               move MFBSI-CSV-TIME to XML-TIME
               move XML-DATE-TIME to XML-REC
               perform XML-WRITE
               move MFBSI-CSV-COND-CODE to XML-COND-CODE-JOB
               move MFBSI-CSV-E-TIME to XML-ELAPSED-JOB
               move XML-JOB-ENDED to XML-REC
               perform XML-WRITE
           end-if
           if  HTM-OPEN-FLAG = 'O'
               perform GET-JOB-INFO-JCLCM0182I-HTM
           end-if
           if  JOB-OPEN-FLAG = 'O'
               move MFBSI-CSV to JOB-REC
               perform JOB-WRITE
           end-if
           exit.

      *****************************************************************
       GET-JOB-INFO-JCLCM0182I-HTM.
           add 1 to ZERO giving COL-IDX
           move TABLE-TR-TAG to HTM-REC
           perform HTM-WRITE

      *    Date
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-DATE
             to HTM-REC(5:LENGTH OF MFBSI-CSV-DATE)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Time
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-TIME
             to HTM-REC(5:LENGTH OF MFBSI-CSV-TIME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    JCL Message
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-MSG-ID
             to HTM-REC(5:LENGTH OF MFBSI-CSV-MSG-ID)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job Number
           move TABLE-TD-TAG to HTM-REC
           move JOB-NUMBER
             to HTM-REC(5:LENGTH OF JOB-NUMBER)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job or Step
           move TABLE-TD-TAG to HTM-REC
           move 'JOB ' to HTM-REC(5:4)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Condition
           move TABLE-TD-TAG to HTM-REC
      *    move 'ENDED   'to HTM-REC(5:8)
           move SPACES            to HTM-REC(5:8)
           move MFBSI-CSV-START-END to HTM-REC(5:7)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job Name
           move TABLE-TD-TAG to HTM-REC
           move JOB-NAME
             to HTM-REC(5:LENGTH OF JOB-NAME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Step Name
           perform HTML-TABLE-TD-NBSP
      *    Return Code
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-COND-CODE
             to HTM-REC(5:LENGTH OF MFBSI-CSV-COND-CODE)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE
      *    Elapsed Time
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-E-TIME
             to HTM-REC(5:LENGTH OF MFBSI-CSV-E-TIME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE
      *    End of Table ROw...
           move TABLE-TR-END to HTM-REC
           perform HTM-WRITE
           exit.

      *****************************************************************
      * Process"Step Bypassed" message
       GET-JOB-INFO-JCLCM0189I.
           if  XML-OPEN-FLAG = 'O'
               move 'Y' to JOB-RECORD-ACTIVE
               move '<JobRecord>' to XML-REC
               perform XML-WRITE
           end-if
           move JESNAME-REC(6:2)  to MFBSI-CSV-HOURS
           move JESNAME-REC(9:2)  to MFBSI-CSV-MINS
           move JESNAME-REC(12:2) to MFBSI-CSV-SECS
           compute STEP-START-SECS = MFBSI-CSV-HOURS * 3600
                                   + MFBSI-CSV-MINS  * 60
                                   + MFBSI-CSV-SECS
           move SPACES            to MFBSI-CSV-E-TIME
           move MESSAGE-ID        to MFBSI-CSV-MSG-ID
           move 'STEP'    to MFBSI-CSV-JOB-STEP
           move 'BYPASSED' to MFBSI-CSV-START-END
           perform GET-JOB-INFO-STEPNAME-CC
           if  MSG-ENABLED = 'Y'
               move MFBSI-CSV to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           if  CSV-OPEN-FLAG = 'O'
               move MFBSI-CSV to CSV-REC
               perform CSV-WRITE
           end-if
           if  XML-OPEN-FLAG = 'O'
               move MFBSI-CSV-DATE to XML-DATE
               move MFBSI-CSV-TIME to XML-TIME
               move XML-DATE-TIME to XML-REC
               perform XML-WRITE
               move MFBSI-CSV-STEP-NAME to XML-STEP-NAME-BYPASS
               move SPACES to WORK-256
               move XML-STEP-BYPASSED to WORK-256
               perform COMPRESS-TO-XML-REC
               perform XML-WRITE
           end-if
           if  HTM-OPEN-FLAG = 'O'
               perform GET-JOB-INFO-JCLCM0189I-HTM
           end-if
           exit.

      *****************************************************************
      * Create an HTML Table row for Start of Step...
       GET-JOB-INFO-JCLCM0189I-HTM.
           add 1 to ZERO giving COL-IDX
           move TABLE-TR-TAG to HTM-REC
           perform HTM-WRITE

      *    Date
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-DATE
             to HTM-REC(5:LENGTH OF MFBSI-CSV-DATE)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Time
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-TIME
             to HTM-REC(5:LENGTH OF MFBSI-CSV-TIME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    JCL Message
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-MSG-ID
             to HTM-REC(5:LENGTH OF MFBSI-CSV-MSG-ID)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job Number
           move TABLE-TD-TAG to HTM-REC
           move JOB-NUMBER
             to HTM-REC(5:LENGTH OF JOB-NUMBER)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job or Step
           move TABLE-TD-TAG to HTM-REC
           move 'STEP' to HTM-REC(5:4)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Condition
           move TABLE-TD-TAG to HTM-REC
           move 'BYPASSED' TO HTM-REC(5:8)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job Name
           move TABLE-TD-TAG to HTM-REC
           move JOB-NAME
             to HTM-REC(5:LENGTH OF JOB-NAME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Step Name
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-STEP-NAME
             to HTM-REC(5:LENGTH OF MFBSI-CSV-STEP-NAME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Return Code
           perform HTML-TABLE-TD-NBSP
      *    Elapsed Time
           perform HTML-TABLE-TD-NBSP
      *    End of Table ROw...
           move TABLE-TR-END to HTM-REC
           perform HTM-WRITE
           exit.

      *****************************************************************
      * Process"Step Started" message
       GET-JOB-INFO-JCLCM0190I.
           if  XML-OPEN-FLAG = 'O'
               move 'Y' to JOB-RECORD-ACTIVE
               move '<JobRecord>' to XML-REC
               perform XML-WRITE
           end-if
           move JESNAME-REC(6:2)  to MFBSI-CSV-HOURS
           move JESNAME-REC(9:2)  to MFBSI-CSV-MINS
           move JESNAME-REC(12:2) to MFBSI-CSV-SECS
           compute STEP-START-SECS = MFBSI-CSV-HOURS * 3600
                                   + MFBSI-CSV-MINS  * 60
                                   + MFBSI-CSV-SECS
           move SPACES            to MFBSI-CSV-E-TIME
           move MESSAGE-ID        to MFBSI-CSV-MSG-ID
           move 'STEP'    to MFBSI-CSV-JOB-STEP
           move 'STARTED' to MFBSI-CSV-START-END
           perform GET-JOB-INFO-STEPNAME-CC
           if  MSG-ENABLED = 'Y'
               move MFBSI-CSV to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           if  CSV-OPEN-FLAG = 'O'
               move MFBSI-CSV to CSV-REC
               perform CSV-WRITE
           end-if
           if  XML-OPEN-FLAG = 'O'
               move MFBSI-CSV-DATE to XML-DATE
               move MFBSI-CSV-TIME to XML-TIME
               move XML-DATE-TIME to XML-REC
               perform XML-WRITE
               move MFBSI-CSV-STEP-NAME to XML-STEP-NAME
               move SPACES to WORK-256
               move XML-STEP-STARTED to WORK-256
               perform COMPRESS-TO-XML-REC
               perform XML-WRITE
           end-if
           if  HTM-OPEN-FLAG = 'O'
               perform GET-JOB-INFO-JCLCM0190I-HTM
           end-if
           exit.

      *****************************************************************
      * Create an HTML Table row for Start of Step...
       GET-JOB-INFO-JCLCM0190I-HTM.
           add 1 to ZERO giving COL-IDX
           move TABLE-TR-TAG to HTM-REC
           perform HTM-WRITE

      *    Date
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-DATE
             to HTM-REC(5:LENGTH OF MFBSI-CSV-DATE)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Time
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-TIME
             to HTM-REC(5:LENGTH OF MFBSI-CSV-TIME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    JCL Message
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-MSG-ID
             to HTM-REC(5:LENGTH OF MFBSI-CSV-MSG-ID)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job Number
           move TABLE-TD-TAG to HTM-REC
           move JOB-NUMBER
             to HTM-REC(5:LENGTH OF JOB-NUMBER)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job or Step
           move TABLE-TD-TAG to HTM-REC
           move 'STEP' to HTM-REC(5:4)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Condition
           move TABLE-TD-TAG to HTM-REC
           move 'STARTED'to HTM-REC(5:7)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job Name
           move TABLE-TD-TAG to HTM-REC
           move JOB-NAME
             to HTM-REC(5:LENGTH OF JOB-NAME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Step Name
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-STEP-NAME
             to HTM-REC(5:LENGTH OF MFBSI-CSV-STEP-NAME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Return Code
           perform HTML-TABLE-TD-NBSP
      *    Elapsed Time
           perform HTML-TABLE-TD-NBSP
      *    End of Table ROw...
           move TABLE-TR-END to HTM-REC
           perform HTM-WRITE
           exit.


      *****************************************************************
      * Process"Step Ended" message
       GET-JOB-INFO-JCLCM0191I.
           if  XML-OPEN-FLAG = 'O'
               move 'Y' to JOB-RECORD-ACTIVE
               move '<JobRecord>' to XML-REC
               perform XML-WRITE
           end-if
           move JESNAME-REC(6:2)  to MFBSI-CSV-HOURS
           move JESNAME-REC(9:2)  to MFBSI-CSV-MINS
           move JESNAME-REC(12:2) to MFBSI-CSV-SECS

           compute WORK-ELAPSED-SECS = (MFBSI-CSV-HOURS * 3600
                                     + MFBSI-CSV-MINS  * 60
                                     + MFBSI-CSV-SECS)
                                     - STEP-START-SECS


           compute STEP-STOP-SECS = (MFBSI-CSV-HOURS * 3600
                                  + MFBSI-CSV-MINS  * 60
                                  + MFBSI-CSV-SECS)
           if  STEP-START-SECS > STEP-STOP-SECS
               add 86400 to STEP-STOP-SECS
           end-if
           compute WORK-ELAPSED-SECS = STEP-STOP-SECS - STEP-START-SECS



           move '00:00:00' to MFBSI-CSV-E-TIME
           if  WORK-ELAPSED-SECS > 3599
               divide WORK-ELAPSED-SECS by 3600
               giving MFBSI-CSV-E-HOURS
               remainder DIVIDE-REMAINDER
               move DIVIDE-REMAINDER to WORK-ELAPSED-SECS
           end-if
           if  WORK-ELAPSED-SECS > 59
               divide WORK-ELAPSED-SECS by 60
               giving MFBSI-CSV-E-MINS
               remainder MFBSI-CSV-E-SECS
           else
               move WORK-ELAPSED-SECS to MFBSI-CSV-E-SECS
           end-if

           move MESSAGE-ID        to MFBSI-CSV-MSG-ID
           move 'STEP'            to MFBSI-CSV-JOB-STEP
      *    move 'ENDED  '         to MFBSI-CSV-START-END
           move SPACES            to MFBSI-CSV-START-END
      *    move JESNAME-REC(31:7) to MFBSI-CSV-START-END
           perform GET-JOB-INFO-STEPNAME-CC
           if  MFBSI-CSV-COND-CODE(1:4) = '0000'
               move JESNAME-REC(31:7) to MFBSI-CSV-START-END
           else
               move 'ABENDED' to MFBSI-CSV-START-END
           end-if
           if  MSG-ENABLED = 'Y'
               move MFBSI-CSV to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           if  CSV-OPEN-FLAG = 'O'
               move MFBSI-CSV to CSV-REC
               perform CSV-WRITE
           end-if
           if  XML-OPEN-FLAG = 'O'
               move MFBSI-CSV-DATE to XML-DATE
               move MFBSI-CSV-TIME to XML-TIME
               move XML-DATE-TIME to XML-REC
               perform XML-WRITE
               move MFBSI-CSV-STEP-NAME to XML-STEP-NAME-END
               move MFBSI-CSV-COND-CODE to XML-COND-CODE
               move MFBSI-CSV-E-TIME to XML-ELAPSED-TIME
               move SPACES to WORK-256
               move XML-STEP-ENDED to WORK-256
               perform COMPRESS-TO-XML-REC
               perform XML-WRITE
           end-if
           if  HTM-OPEN-FLAG = 'O'
               perform GET-JOB-INFO-JCLCM0191I-HTM
           end-if
           exit.

      *****************************************************************
       GET-JOB-INFO-JCLCM0191I-HTM.
           add 1 to ZERO giving COL-IDX
           move TABLE-TR-TAG to HTM-REC
           perform HTM-WRITE

      *    Date
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-DATE
             to HTM-REC(5:LENGTH OF MFBSI-CSV-DATE)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Time
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-TIME
             to HTM-REC(5:LENGTH OF MFBSI-CSV-TIME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    JCL Message
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-MSG-ID
             to HTM-REC(5:LENGTH OF MFBSI-CSV-MSG-ID)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job Number
           move TABLE-TD-TAG to HTM-REC
           move JOB-NUMBER
             to HTM-REC(5:LENGTH OF JOB-NUMBER)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job or Step
           move TABLE-TD-TAG to HTM-REC
           move 'STEP' to HTM-REC(5:4)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Condition
           move TABLE-TD-TAG to HTM-REC
      *    move 'ENDED   'to HTM-REC(5:8)
           move SPACES            to HTM-REC(5:8)
           move MFBSI-CSV-START-END to HTM-REC(5:7)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Job Name
           move TABLE-TD-TAG to HTM-REC
           move JOB-NAME
             to HTM-REC(5:LENGTH OF JOB-NAME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE

      *    Step Name
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-STEP-NAME
             to HTM-REC(5:LENGTH OF MFBSI-CSV-STEP-NAME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE
      *    Return Code
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-COND-CODE
             to HTM-REC(5:LENGTH OF MFBSI-CSV-COND-CODE)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE
      *    Elapsed Time
           move TABLE-TD-TAG to HTM-REC
           move MFBSI-CSV-E-TIME
             to HTM-REC(5:LENGTH OF MFBSI-CSV-E-TIME)
           inspect HTM-REC replacing first '     '
                                        by TABLE-TD-END
           perform HTM-WRITE
      *    End of Table ROw...
           move TABLE-TR-END to HTM-REC
           perform HTM-WRITE
           exit.

      *****************************************************************
      * ProcessCondition Code
       GET-JOB-INFO-STEPNAME-CC.
           move SPACES to MFBSI-CSV-STEP-NAME
           move SPACES to MFBSI-CSV-COND-CODE
           add 41 to ZERO giving PT-1
           add  1 to ZERO giving PT-2
           add  1 to ZERO giving LOOP-LIMIT
           perform varying LOOP-LIMIT from 1 by 1
                     until LOOP-LIMIT > 20
                        or JESNAME-REC(PT-1:1) = SPACE
             move JESNAME-REC(PT-1:1) to MFBSI-CSV-STEP-NAME(PT-2:1)
             add 1 to PT-1
             add 1 to PT-2
           end-perform
           if  JESNAME-REC(PT-1:13) = ' - COND CODE '
               add 13 to PT-1
               move JESNAME-REC(PT-1:8) to MFBSI-CSV-COND-CODE
           end-if
           exit.

      *****************************************************************
       GET-CMD-NUMB.
           perform BUILD-CMD-NAME
           perform CMDTOKEN-OPEN-UPDATE
           perform CMDTOKEN-READ
           if  CMDTOKEN-STATUS = '00'
               if  CMDTOKEN-REC-ID = '01R'
                   move CMDTOKEN-RECORD to WRKTOKEN-01R-RECORD
                   add 1 to WRKTOKEN-NUMBER
                   move WRKTOKEN-01R-RECORD to CMDTOKEN-RECORD
                   perform CMDTOKEN-REWRITE
               end-if
           else
               if  CMDTOKEN-STATUS = '47'
                   move SPACES     to WRKTOKEN-01R-RECORD
                   move '01R'      to WRKTOKEN-REC-ID-01
                   move 'CMD00000' to WRKTOKEN-CMD-NUMBER
                   add 1 to WRKTOKEN-NUMBER
                   move WRKTOKEN-01R-RECORD to CMDTOKEN-RECORD
                   perform CMDTOKEN-WRITE
               end-if
           end-if
           perform CMDTOKEN-CLOSE
           move WRKTOKEN-CMD-NUMBER to JOB-NUMBER
           exit.

      *****************************************************************
      * I/O Routines for the INPUT File...                            *
      *****************************************************************
       JESNAME-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close JES-FILE
           if  JESNAME-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CLOSE Failure with JESNAME' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move JESNAME-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       JESNAME-READ.
           read JES-FILE
           if  JESNAME-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  JESNAME-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               if  APPL-EOF
                   move 'Y' to JESNAME-EOF
               else
                   move 'READ Failure with JESNAME' to MESSAGE-TEXT
                   perform Z-DISPLAY-MESSAGE-TEXT
                   move JESNAME-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       JESNAME-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open input JES-FILE
           if  JESNAME-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to JESNAME-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'OPEN Failure with JESNAME' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move JESNAME-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * I/O Routines for the CSV File...                              *
      *****************************************************************
       CSV-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close CSV-FILE
           if  CSV-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CLOSE Failure with CSVNAME' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CSV-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       CSV-WRITE.
           write CSV-REC
           if  CSV-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  CSV-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               if  APPL-EOF
                   move 'Y' to CSV-EOF
               else
                   move 'WRITE Failure with CSVNAME' to MESSAGE-TEXT
                   perform Z-DISPLAY-MESSAGE-TEXT
                   move CSV-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       CSV-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open output CSV-FILE
           if  CSV-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to CSV-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
               move 'E' to CSV-OPEN-FLAG
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'OPEN Failure with CSVNAME' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CSV-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
       CMDTOKEN-READ.
           read CMDTOKEN-FILE
           if  CMDTOKEN-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  CMDTOKEN-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               if  APPL-EOF
                   move 'Y' to CMDTOKEN-EOF
               else
                   move 'Failed-READ, CMDTOKEN file' to MESSAGE-TEXT
                   perform Z-DISPLAY-MESSAGE-TEXT
                   move CMDTOKEN-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
      *            perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       CMDTOKEN-REWRITE.
           if  MESSAGE-LENGTH > 512
               add 1024 to MESSAGE-LENGTH giving MESSAGE-LENGTH
           end-if
           if  MESSAGE-LENGTH < 64
               add 64 to MESSAGE-LENGTH giving MESSAGE-LENGTH
           end-if
           rewrite CMDTOKEN-RECORD.
           if  CMDTOKEN-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  CMDTOKEN-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if.
           if  APPL-AOK
               CONTINUE
           else
               move 'FAILED-REWRITE, CMDTOKEN file' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CMDTOKEN-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
      *        perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       CMDTOKEN-OPEN-UPDATE.
           add 8 to ZERO giving APPL-RESULT.
           open I-O CMDTOKEN-FILE
           if  CMDTOKEN-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'Y' to CMDTOKEN-OPEN-FLAG
           else
               move 'CMDTOKEN, Open as output file' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               open output CMDTOKEN-FILE
               if  CMDTOKEN-STATUS = '00'
                   subtract APPL-RESULT from APPL-RESULT
                   move 'Y' to CMDTOKEN-OPEN-FLAG
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'FAILED-OPEN,CMDTOKEN file' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CMDTOKEN-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
      *        perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       CMDTOKEN-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close CMDTOKEN-FILE
           if  CMDTOKEN-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'FAILED-CLOSE, CMDTOKEN file' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CMDTOKEN-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
      *        perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       CMDTOKEN-WRITE.
           if  MESSAGE-LENGTH > 512
               add 1024 to MESSAGE-LENGTH giving MESSAGE-LENGTH
           end-if
           if  MESSAGE-LENGTH < 64
               add 64 to MESSAGE-LENGTH giving MESSAGE-LENGTH
           end-if
           write CMDTOKEN-RECORD.
           if  CMDTOKEN-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  CMDTOKEN-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if.
           if  APPL-AOK
               CONTINUE
           else
               move 'FAILED-WRITE, CMDTOKEN file' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CMDTOKEN-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
      *        perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * I/O Routines for the HTM File...                              *
      *****************************************************************
       HTM-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close HTM-FILE
           if  HTM-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CLOSE Failure with HTMNAME' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move HTM-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       HTM-WRITE.
           write HTM-REC
           if  HTM-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  HTM-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               if  APPL-EOF
                   move 'Y' to HTM-EOF
               else
                   move 'WRITE Failure with HTMNAME' to MESSAGE-TEXT
                   perform Z-DISPLAY-MESSAGE-TEXT
                   move HTM-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       HTM-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open output HTM-FILE
           if  HTM-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to HTM-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
               move 'E' to HTM-OPEN-FLAG
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'OPEN Failure with HTMNAME' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move HTM-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * I/O Routines for the output LOG File...                       *
      *****************************************************************
       LOG-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close LOG-FILE
           if  LOG-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CLOSE Failure with CSVNAME' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move LOG-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       LOG-WRITE.
           write LOG-REC
           if  LOG-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  LOG-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               if  APPL-EOF
                   move 'Y' to LOG-EOF
               else
                   move 'WRITE Failure with CSVNAME' to MESSAGE-TEXT
                   perform Z-DISPLAY-MESSAGE-TEXT
                   move LOG-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       LOG-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open output LOG-FILE
           if  LOG-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to LOG-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
               move 'E' to LOG-OPEN-FLAG
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'OPEN Failure with CSVNAME' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move LOG-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * I/O Routines for the XML File...                              *
      *****************************************************************
       XML-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close XML-FILE
           if  XML-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CLOSE Failure with XMLNAME' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move XML-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       XML-WRITE.
           write XML-REC
           if  XML-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  XML-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               if  APPL-EOF
                   move 'Y' to XML-EOF
               else
                   move 'WRITE Failure with XMLNAME' to MESSAGE-TEXT
                   perform Z-DISPLAY-MESSAGE-TEXT
                   move XML-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       XML-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open output XML-FILE
           if  XML-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to XML-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
               move 'E' to XML-OPEN-FLAG
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'OPEN Failure with XMLNAME' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move XML-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * I/O Routines for the XML File...                              *
      *****************************************************************
       JOB-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close JOB-FILE
           if  JOB-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CLOSE Failure with JOBFILE' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move JOB-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       JOB-WRITE.
           write JOB-REC
           if  JOB-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  JOB-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               if  APPL-EOF
                   move 'Y' to JOB-EOF
               else
                   move 'WRITE Failure with JOBFILE' to MESSAGE-TEXT
                   perform Z-DISPLAY-MESSAGE-TEXT
                   move JOB-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       JOB-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open extend JOB-FILE
           if  JOB-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to JOB-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
               move 'E' to JOB-OPEN-FLAG
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'OPEN Failure with JOBFILE' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move JOB-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
       GET-DATE-AND-TIME.
           accept WORK-DATE from DATE YYYYMMDD
           accept WORK-TIME from TIME
           move   WORK-DATE(1:4) to MFBSI-CSV-CCYY
           move   WORK-DATE(5:2) to MFBSI-CSV-MM
           move   WORK-DATE(7:2) to MFBSI-CSV-DD
           exit.

      *****************************************************************
      * ABEND the program, post a message to the console and issue    *
      * a STOP RUN.                                                   *
      *****************************************************************
       Z-ABEND-PROGRAM.
           if  MESSAGE-TEXT not = SPACES
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           move 'PROGRAM-IS-ABENDING...'  to MESSAGE-TEXT
           perform Z-DISPLAY-MESSAGE-TEXT
           add 12 to ZERO giving RETURN-CODE
           STOP RUN.
      *    exit.

      *****************************************************************
      * Display CONSOLE messages...                                   *
      *****************************************************************
       Z-DISPLAY-MESSAGE-TEXT.
           if  MESSAGE-TEXT-1(80:1) = SPACE
           and MESSAGE-TEXT-2       = SPACES
               display MESSAGE-BUFFER(1:79) upon console
           else
               display MESSAGE-BUFFER upon console
           end-if
           move all SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
      * Display the file status bytes. This routine will display as   *
      * four digits. If the full two byte file status is numeric it   *
      * will display as 00nn. If the 1st byte is a numeric nine (9)   *
      * the second byte will be treated as a binary number and will   *
      * display as 9nnn.                                              *
      *****************************************************************
       Z-DISPLAY-IO-STATUS.
           if  IO-STATUS not NUMERIC
           or  IO-STAT1 = '9'
               move IO-STAT1 to IO-STATUS-04(1:1)
               subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
               move IO-STAT2 to TWO-BYTES-RIGHT
               add TWO-BYTES-BINARY to ZERO giving IO-STATUS-0403
               move 'File Status is: nnnn' to MESSAGE-TEXT
               move IO-STATUS-04 to MESSAGE-TEXT(17:4)
               perform Z-DISPLAY-MESSAGE-TEXT
           else
               move '0000' to IO-STATUS-04
               move IO-STATUS to IO-STATUS-04(3:2)
               move 'File Status is: nnnn' to MESSAGE-TEXT
               move IO-STATUS-04 to MESSAGE-TEXT(17:4)
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           exit.


Summary
(Next) (Previous) (Table-of-Contents)

The purpose of this document is to provide a COBOL Source member for viewing.

Software Agreement and Disclaimer
(Next) (Previous) (Table-of-Contents)

Permission to use, copy, modify and distribute this software for any commercial purpose requires a fee to be paid to Simotime Enterprises. Once the fee is received by SimoTime the latest version of the software will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.

Permission to use, copy, modify and distribute this software for a non-commercial purpose and without fee is hereby granted, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.

SimoTime Enterprises makes no warranty or representations about the suitability of the software for any purpose. It is provided "AS IS" without any express or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Enterprises shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software.

Downloads and Links to Similar Pages
(Next) (Previous) (Table-of-Contents)

You may view the complete list of SimoTime callable Modules or Driver Programs at http://www.simotime.com/simomods.htm.

You may download this example at http://www.simotime.com/sim4dzip.htm#zPACKmfjeslog or view the complete list of SimoTime Examples at http://www.simotime.com/sim4dzip.htm.

The SimoZAPS Utility Program has the capability of generating a COBOL program that will do the conversion of sequential and VSAM (KSDS) files between EBCDIC and ASCII. SimoZAPScan also read a sequential file in EBCDIC format and create an ASCII/CRLF file or VSAM KSDS file in ASCII format. The conversion tables may be viewed or modified to meet unique requirements. The Hexcess/2 function provides the capability of viewing, finding or patching the contents of a file in hexadecimal.

This item will provide a link to  an ASCII or EBCDIC translation table. A column for decimal, hexadecimal and binary is also included.

This document provides a quick summary of the  File Status Key  for VSAM data sets and QSAM files.

To review all the information available on this site start at  The SimoTime Home Page .

Glossary of Terms
(Next) (Previous) (Table-of-Contents)

Check out  The SimoTime Glossary  for a list of terms and definitions used in the documents provided by SimoTime.

Comments or Suggestions
(Next) (Previous) (Table-of-Contents)

If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com

We appreciate your comments and feedback.

About SimoTime Enterprises
(Next) (Previous) (Table-of-Contents)

Founded in 1987, SimoTime Enterprises is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com


Return-to-Top
Copyright © 1987-2010 SimoTime Enterprises  All Rights Reserved
When technology complements business
http://www.simotime.com