@echo OFF
     set JOB_NAME=PUWEXTW1
rem  * *******************************************************************
rem  *        This Job Script is provided by SimoTime Technologies       *
rem  *           (C) Copyright 1987-2020 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Read RSEQ with Packed-Decimal-Signed, Write LSEQ_CSV.
rem  * Author - SimoTime Technologies
rem  * Date   - January 24, 1996
rem  *
rem  * The job will execute a program that will read an ASCII encoded,
rem  * Record Sequential file that contains various numeric values stored
rem  * in a packed-decimal format.
rem  *
rem  * Next, the program will write to a new ASCII encoded,
rem  * Line Sequential{LSEQ) file that contains a Comma-Separated-Values
rem  * (CSV) Record structure. The text strings will maintain their
rem  * ASCII encoded schema. The Packed Decimal Numerics valuses will be
rem  * expanded to a text oriented format with a separate leading sign
rem  * symbol and an explicit decimal point (or decimal separator).
rem  *
rem  *    ************
rem  *    * PUWEXTW1 *
rem  *    ********cmd*
rem  *         *
rem  *         *
rem  *    ************
rem  *    * ENV1BASE *
rem  *    ********cmd*
rem  *         *
rem  *         *
rem  *    ************
rem  *    * SIMONOTE *
rem  *    ********cmd*
rem  *         *
rem  *         *
rem  *    ************
rem  *    *   RUN    *---------------------------*
rem  *    ********rts*                           *
rem  *         *           ************     ************     ************
rem  *         *           *  SYSUT1  *--*--* PUWEXTC5 *--*--*  SYSUT2  *
rem  *         *           *  Note-1  *  *  ********cbl*  *  *  Note-2  *
rem  *         *           *******lseq*  *                *  *******lcsv*
rem  *         *                         *                *
rem  *         *           ************  *                *  ************
rem  *         *           *  CSVHDR  *--*                *--*  SYSOUT  *
rem  *         *           *  Note-3  *                      *  Note-4  *
rem  *         *           *******lseq*                      *******lseq*
rem  *    ************
rem  *    *   EOJ    *
rem  *    ************
rem  *
rem  *    Note-1: SYSUT1 is an ASCII-encoded, record sequential (RSEQ)
rem  *            file. The record content includes numeric values that
rem  *            are stored in a Packed-Decimal format.
rem  *
rem  *    Note-2: SYSUT2 is an ASCII-encoded,Line Sequential (LSEQ) file.
rem  *            Also, referred to as an ASCII/Text File.
rem  *            The record format is Comma-Separated-values (CSV).
rem  *
rem  *    Note-3: This file contains a list of field names that are
rem  *            extracted and re-formatted. The field names are obtained
rem  *            from a COBOL Copy File.
rem  *            This file is used to insert header information as the
rem  *            first record of the SYSUT2 file.
rem  *            Note: This is optional feature.
rem  *
rem  *    Note-4: SYSOUT is an ASCII-encoded, line sequential (LSEQ)
rem  *            file.
rem  *
rem  * *******************************************************************
rem  * Step 1, Set Environment Variables
rem  *         Delete any previously created ASCII-encoded file...
rem  *
     call ..\ENV1BASE
rem  *
     call SIMONOTE "*******************************************************************************%JOB_NAME% "
     call SIMONOTE "* Starting JobName %JOB_NAME%, User is %USERNAME% "
     call SIMONOTE "* Job_Step 01 of 03, Preparing the System and Job Environments"
     set JobStatus=0
     set PGMFLAGS=NNNNNNNN/NNNNYNNN
     set SYSOUT=%BaseLib1%\LOGS\SYSOUT_%JOB_NAME%.txt
     set SYSUT1=%BaseLib1%\DATA\ASC1\NVPUWDD1.DAT
     set SYSUT2=%BaseLib1%\DATA\CSV1\NVPUWDD1.csv
     set CSVHDR=%BaseLib1%\DATA\GENS\NVPDUWB1_EXTRACT.txt
     if exist %SYSUT2% del %SYSUT2%
rem  *
     call SIMONOTE "* --------------------------------------------------------------------------- * "
     call SIMONOTE "* Job_Step 02 of 03, Execute RSEQ_FFL to LSEQ_CSV Conversion"
     call SIMONOTE "* DataTake SYSUT1=%SYSUT1% "
     call SIMONOTE "* DataMake SYSUT2=%SYSUT2% "
     run PUWEXTC5
     if not "%ERRORLEVEL%" == "0" set JobStatus=10
     if not "%JobStatus%" == "0" goto EOJTAG
     if exist %SYSUT2% goto EOJTAG
     set JobStatus=20
rem  *
:EOJTAG
     call SIMONOTE "* --------------------------------------------------------------------------- * "
     call SIMONOTE "* Job_Step 03 of 03, End of Job Processing"
     if not "%JobStatus%" == "0" goto EojNOK
:EojAOK
     call SIMONOTE "* Produced  %SYSUT2% "
     call SIMONOTE "* Finished JOB_NAME %JOB_NAME%, Job Status is %JobStatus% "
     goto :End
:EojNOK
     call SIMONOTE "* ABENDING JOB_NAME %JOB_NAME%, Job Status is %JobStatus% "
     goto :End
:End
     call SIMONOTE "* Conclude SysOut is %SYSOUT% "
     if not "%1" == "nopause" pause
     exit /B %JobStatus%